|
21063
|
921
|
2
|
2026-05-11T17:07:05.045986+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-11/1778 /Users/lukas/.screenpipe/data/data/2026-05-11/1778519225045_m2.jpg...
|
Code
|
Implement and run pipe l… — screenpipe [SSH: nas]
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧ Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py
M
db.py
docker-compose.yml
Dockerfile
M
main.py
M
requirements.txt
M
data
logs
pipes
.gitignore
app_settings.json
archive.db
archive.db-bak
U
db.sqlite
db.sqlite-shm
db.sqlite-wal
screenpipe_sync_updated.sh
U...
|
[{"role":"AXRadioButton","text [{"role":"AXRadioButton","text":"Explorer (⇧⌘E)","depth":19,"bounds":{"left":0.0,"top":0.047885075,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":true},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.057462092,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Search (⇧⌘F)","depth":19,"bounds":{"left":0.0,"top":0.08619314,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.09577015,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Source Control (⌃⇧G) - 10 pending changes","depth":19,"bounds":{"left":0.0,"top":0.1245012,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.13407822,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"10","depth":22,"bounds":{"left":0.00831117,"top":0.1452514,"width":0.003656915,"height":0.008778931},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.00831117,"top":0.14604948,"width":0.0016622341,"height":0.007980846}},{"char_start":1,"char_count":1,"bounds":{"left":0.009973404,"top":0.14604948,"width":0.0023271276,"height":0.007980846}}],"role_description":"text"},{"role":"AXRadioButton","text":"Run and Debug (⇧⌘D)","depth":19,"bounds":{"left":0.0,"top":0.16280925,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.17238627,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Remote Explorer","depth":19,"bounds":{"left":0.0,"top":0.20111732,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.21069433,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Extensions (⇧⌘X) - 2 require update","depth":19,"bounds":{"left":0.0,"top":0.23942538,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.2490024,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"2","depth":22,"bounds":{"left":0.009640957,"top":0.2601756,"width":0.0019946808,"height":0.008778931},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Claude Code","depth":19,"bounds":{"left":0.0,"top":0.27773345,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"Containers","depth":19,"bounds":{"left":0.0,"top":0.3160415,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXHeading","text":"EXPLORER","depth":17,"bounds":{"left":0.022606382,"top":0.047885075,"width":0.018949468,"height":0.02793296},"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"EXPLORER","depth":18,"bounds":{"left":0.022606382,"top":0.056664005,"width":0.018949468,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.022606382,"top":0.056664005,"width":0.0023271276,"height":0.0103751}},{"char_start":1,"char_count":7,"bounds":{"left":0.024933511,"top":0.056664005,"width":0.01662234,"height":0.0103751}}],"role_description":"text"},{"role":"AXButton","text":"Explorer Section: screenpipe [SSH: nas]","depth":21,"bounds":{"left":0.015957447,"top":0.07581804,"width":0.09940159,"height":0.017557861},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":true},{"role":"AXStaticText","text":"","depth":23,"bounds":{"left":0.01662234,"top":0.07821229,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"Explorer Section: screenpipe [SSH: nas]","depth":22,"bounds":{"left":0.022606382,"top":0.07581804,"width":0.045877658,"height":0.017557861},"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"SCREENPIPE [SSH: NAS]","depth":23,"bounds":{"left":0.022606382,"top":0.079010375,"width":0.045877658,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.022606382,"top":0.07980846,"width":0.0026595744,"height":0.0103751}},{"char_start":1,"char_count":20,"bounds":{"left":0.025265958,"top":0.07980846,"width":0.043218084,"height":0.0103751}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.09577015,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"#recycle","depth":27,"bounds":{"left":0.025930852,"top":0.09577015,"width":0.017287234,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.096568234,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":7,"bounds":{"left":0.028590426,"top":0.096568234,"width":0.01462766,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.11332801,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"app","depth":27,"bounds":{"left":0.025930852,"top":0.11332801,"width":0.0076462766,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.11412609,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":2,"bounds":{"left":0.02825798,"top":0.11412609,"width":0.005319149,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.11412609,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.022273935,"top":0.13088587,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"__pycache__","depth":27,"bounds":{"left":0.028590426,"top":0.13088587,"width":0.026595745,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.13168396,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":10,"bounds":{"left":0.030917553,"top":0.13168396,"width":0.024268618,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.022273935,"top":0.14844373,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"consumers","depth":27,"bounds":{"left":0.028590426,"top":0.14844373,"width":0.022273935,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.14924182,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":8,"bounds":{"left":0.030917553,"top":0.14924182,"width":0.019946808,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.14924182,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.022273935,"top":0.1660016,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"static","depth":27,"bounds":{"left":0.028590426,"top":0.1660016,"width":0.010970744,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.16679968,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":5,"bounds":{"left":0.030917553,"top":0.16679968,"width":0.008976064,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.16679968,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.1819633,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":".env","depth":27,"bounds":{"left":0.028590426,"top":0.18355946,"width":0.00831117,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.18435754,"width":0.0013297872,"height":0.011971269}},{"char_start":1,"char_count":3,"bounds":{"left":0.029920213,"top":0.18435754,"width":0.006981383,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.19952115,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"cli.py","depth":27,"bounds":{"left":0.028590426,"top":0.20111732,"width":0.010638298,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.2019154,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":5,"bounds":{"left":0.030917553,"top":0.2019154,"width":0.00831117,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.2019154,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.21707901,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.py","depth":27,"bounds":{"left":0.028590426,"top":0.21867518,"width":0.011303191,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.21947326,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":4,"bounds":{"left":0.03125,"top":0.21947326,"width":0.008643617,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.23463687,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"docker-compose.yml","depth":27,"bounds":{"left":0.028590426,"top":0.23623304,"width":0.042220745,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.23703113,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":17,"bounds":{"left":0.03125,"top":0.23703113,"width":0.03956117,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.25219473,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Dockerfile","depth":27,"bounds":{"left":0.028590426,"top":0.25379092,"width":0.020611702,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.254589,"width":0.0033244682,"height":0.011971269}},{"char_start":1,"char_count":9,"bounds":{"left":0.031914894,"top":0.254589,"width":0.017287234,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.254589,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.2697526,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"main.py","depth":27,"bounds":{"left":0.028590426,"top":0.27134877,"width":0.015625,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.27214685,"width":0.003656915,"height":0.011971269}},{"char_start":1,"char_count":6,"bounds":{"left":0.032247342,"top":0.27214685,"width":0.012300532,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.27214685,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.28731045,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"requirements.txt","depth":27,"bounds":{"left":0.028590426,"top":0.28890663,"width":0.032912236,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.2897047,"width":0.0016622341,"height":0.011971269}},{"char_start":1,"char_count":15,"bounds":{"left":0.03025266,"top":0.2897047,"width":0.03158245,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.2897047,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.3064645,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"data","depth":27,"bounds":{"left":0.025930852,"top":0.3064645,"width":0.008976064,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.30726257,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":3,"bounds":{"left":0.028590426,"top":0.30726257,"width":0.0063164895,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.32402235,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"logs","depth":27,"bounds":{"left":0.025930852,"top":0.32402235,"width":0.00831117,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.32482043,"width":0.0009973404,"height":0.011971269}},{"char_start":1,"char_count":3,"bounds":{"left":0.026928192,"top":0.32482043,"width":0.0076462766,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.32482043,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.3415802,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"pipes","depth":27,"bounds":{"left":0.025930852,"top":0.3415802,"width":0.010970744,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.3423783,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":4,"bounds":{"left":0.028590426,"top":0.3423783,"width":0.00831117,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.3575419,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":".gitignore","depth":27,"bounds":{"left":0.025930852,"top":0.35913807,"width":0.018949468,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.35993615,"width":0.0013297872,"height":0.011971269}},{"char_start":1,"char_count":9,"bounds":{"left":0.027260639,"top":0.35993615,"width":0.017952127,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.37509975,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"app_settings.json","depth":27,"bounds":{"left":0.025930852,"top":0.37669593,"width":0.03557181,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.377494,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":16,"bounds":{"left":0.02825798,"top":0.377494,"width":0.03324468,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.3926576,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"archive.db","depth":27,"bounds":{"left":0.025930852,"top":0.3942538,"width":0.020944148,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.39505187,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":9,"bounds":{"left":0.02825798,"top":0.39505187,"width":0.01861702,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.4102155,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"archive.db-bak","depth":27,"bounds":{"left":0.025930852,"top":0.41181165,"width":0.03025266,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.41260973,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":13,"bounds":{"left":0.02825798,"top":0.41260973,"width":0.027925532,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"U","depth":27,"bounds":{"left":0.10704787,"top":0.41260973,"width":0.0029920214,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.42777336,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite","depth":27,"bounds":{"left":0.025930852,"top":0.4293695,"width":0.017287234,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.4301676,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":8,"bounds":{"left":0.028590426,"top":0.4301676,"width":0.014960106,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.44533122,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite-shm","depth":27,"bounds":{"left":0.025930852,"top":0.44692737,"width":0.027925532,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.44772545,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":12,"bounds":{"left":0.028590426,"top":0.44772545,"width":0.025265958,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.46288908,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite-wal","depth":27,"bounds":{"left":0.025930852,"top":0.46448523,"width":0.025930852,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.46528333,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":12,"bounds":{"left":0.028590426,"top":0.46528333,"width":0.023603724,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.48044693,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe_sync_updated.sh","depth":27,"bounds":{"left":0.025930852,"top":0.4820431,"width":0.059175532,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.4828412,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":25,"bounds":{"left":0.02825798,"top":0.4828412,"width":0.056848403,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"U","depth":27,"bounds":{"left":0.10704787,"top":0.4828412,"width":0.0029920214,"height":0.011173184},"on_screen":true,"role_description":"text"}]...
|
7092479069048414903
|
-5570334927859576448
|
idle
|
accessibility
|
NULL
|
Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧ Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py
M
db.py
docker-compose.yml
Dockerfile
M
main.py
M
requirements.txt
M
data
logs
pipes
.gitignore
app_settings.json
archive.db
archive.db-bak
U
db.sqlite
db.sqlite-shm
db.sqlite-wal
screenpipe_sync_updated.sh
U...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
21064
|
920
|
2
|
2026-05-11T17:07:17.284111+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-11/1778 /Users/lukas/.screenpipe/data/data/2026-05-11/1778519237284_m1.jpg...
|
Code
|
Implement and run pipe l… — screenpipe [SSH: nas]
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧ Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py
M
db.py
docker-compose.yml
Dockerfile
M
main.py
M
requirements.txt
M
data
logs
pipes
.gitignore
app_settings.json
archive.db
archive.db-bak
U
db.sqlite
db.sqlite-shm
db.sqlite-wal
screenpipe_sync_updated.sh
U
screenpipe_sync.sh
screenpipe.db
Outline Section
OUTLINE
OUTLINE
Timeline Section
TIMELINE
TIMELINE
app_settings.json, Editor Group 1
screenpipe_sync.sh, Editor Group 1
pipe.md, Editor Group 1
.env, Editor Group 1
[ENV_SECRET]
[ENV_SECRET]
Implement and run pipe l…, Editor Group 2
Problems (⇧⌘M)
PROBLEMS
Output (⇧⌘U)
OUTPUT
Debug Console (⇧⌘Y)
DEBUG CONSOLE
Terminal (⌃`)
TERMINAL
Ports - 1 forwarded port
PORTS
1
remote SSH: nas
SSH: nas
screenpipe (Git) - master*, Checkout Branch/Tag...
master*
screenpipe (Git) - Synchronize Changes
No Problems
0
0
Forwarded Ports: 8766
1
Notifications
Sign In
Sign In
Info: Setting up SSH Host nas: Setting up SSH tunnel
Implement and run pipe logic
Session history
New session
Message actions
main.py
main.py
lets implement logic with pipes. how can I run it?
Thinking
Thinking
Let me look at the current project structure to understand what's already in place.
Bash
List project files
IN
find /volume1/screenpipe -type f | head -50 && echo "---" && ls /volume1/screenpipe
Copy code to clipboard
OUT
/volume1/screenpipe/.DS_Store
/volume1/screenpipe/screenpipe.db
/volume1/screenpipe/screenpipe_sync.sh
/volume1/screenpipe/app_settings.json
/volume1/screenpipe/.gitignore
/volume1/screenpipe/archive.db
/volume1/screenpipe/db.sqlite
/volume1/screenpipe/db.sqlite-wal
/volume1/screenpipe/db.sqlite-shm
/volume1/screenpipe/#recycle/desktop.ini
/volume1/screenpipe/#recycle/db.sqlite
/volume1/screenpipe/#recycle/Copy #1 of db.sqlite
/volume1/screenpipe/#recycle/.DS_Store
/volume1/screenpipe/#recycle/Copy #2 of db.sqlite
/volume1/screenpipe/#recycle/archive.db
/volume1/screenpipe/#recycle/Copy #1 of archive.db
/volume1/screenpipe/#recycle/Copy #2 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of archive.db
/volume1/screenpipe/#recycle/Copy #4 of archive.db
/volume1/screenpipe/#recycle/Copy #5 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of db.sqlite
/volume1/screenpipe/#recycle/Copy #4 of db.sqlite
/volume1/screenpipe/#recycle/Copy #6 of archive.db
/volume1/screenpipe/#recycle/test.txt
/volume1/screenpipe/#recycle/Copy #7 of archive.db
/volume1/screenpipe/#recycle/Copy #8 of archive.db
/volume1/screenpipe/#recycle/archive.db-journal
/volume1/screenpipe/#recycle/Copy #1 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #2 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #3 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #4 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #6 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #7 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of db.sqlite
/volume1/screenpipe/pipes/.DS_Store
/volume1/screenpipe/app/.env
/volume1/screenpipe/app/cli.py
/volume1/screenpipe/app/.DS_Store
/volume1/screenpipe/app/db.py
/volume1/screenpipe/app/docker-compose.yml
/volume1/screenpipe/app/main.py
/volume1/screenpipe/app/requirements.txt
/volume1/screenpipe/app/Dockerfile
/volume1/screenpipe/data/.DS_Store
/volume1/screenpipe/.git/description
/volume1/screenpipe/.git/HEAD
/volume1/screenpipe/.git/index
/volume1/screenpipe/.git/COMMIT_EDITMSG
/volume1/screenpipe/#recycle/data/.DS_Store
---
app
app_settings.json
archive.db
data
db.sqlite
db.sqlite-shm
db.sqlite-wal
pipes
#recycle
screenpipe.db
screenpipe_sync.sh
Read
main.py
main.py
Bash
Check pipes directory and docker-compose
IN
ls /volume1/screenpipe/pipes/ && ls /volume1/screenpipe/app/ && cat /volume1/screenpipe/app/docker-compose.yml
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
cli.py
consumers
db.py
docker-compose.yml
Dockerfile
main.py
__pycache__
requirements.txt
static
services:
screenpipe-app:
build: .
container_name: screenpipe-app
restart: unless-stopped
ports:
- "8766:8000"
volumes:
- /volume1/screenpipe:/data
env_file:
- .env
environment:
TZ: Europe/Sofia
DB_PATH: /data/db.sqlite
sqlite-web-archive:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-archive
restart: unless-stopped
ports:
- "8767:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/archive.db"]
sqlite-web-live:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-live
restart: unless-stopped
ports:
- "8768:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/db.sqlite"]
Read
requirements.txt
requirements.txt
Bash
Inspect a pipe directory
IN
ls /volume1/screenpipe/pipes/day-recap/ && cat /volume1/screenpipe/pipes/day-recap/pipe.json 2>/dev/null || ls /volume1/screenpipe/pipes/day-recap/
Copy code to clipboard
OUT
pipe.md
pipe.md
Read
cli.py
cli.py
Bash
List all pipes and their contents
IN
ls /volume1/screenpipe/pipes/ && for d in /volume1/screenpipe/pipes/*/; do echo "=== $d ==="; ls "$d"; done
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
=== /volume1/screenpipe/pipes/ai-habits/ ===
pipe.md
=== /volume1/screenpipe/pipes/day-recap/ ===
pipe.md
=== /volume1/screenpipe/pipes/meeting-summary/ ===
pipe.md
=== /volume1/screenpipe/pipes/standup-update/ ===
pipe.md
=== /volume1/screenpipe/pipes/time-breakdown/ ===
pipe.md
=== /volume1/screenpipe/pipes/video-export/ ===
pipe.md
Bash
Read pipe markdown files
IN
cat /volume1/screenpipe/pipes/day-recap/pipe.md && echo "===" && cat /volume1/screenpipe/pipes/meeting-summary/pipe.md 2>/dev/null | head -50
Copy code to clipboard
OUT
---
schedule: manual
enabled: true
template: true
title: Day Recap
description: "Today's accomplishments, key moments, and unfinished work"
icon: "📋"
featured: true
---
Analyze my screen and audio recordings from today (last 16 hours only).
Read screenpipe skill first.
Use this exact format:
## Summary
One sentence: what I mainly did today.
## Accomplishments
- Top 3 things I finished, with timestamps (e.g. "2:30 PM")
- Name specific apps, files, or projects
## Key Moments
- Important things I saw, said, or heard — with timestamps
## Unfinished Work
- What I should continue tomorrow — name the app/file/task
## Patterns
- Apps I used most, topics that came up repeatedly
Only report what you can verify from the data. End with: "**Next step:** [most important thing to continue]"
===
---
schedule: manual
enabled: true
template: true
title: Meeting Summary
description: "Summarize meeting transcript with key takeaways and action items"
icon: "🤝"
featured: false
---
Summarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.
Read screenpipe skill first.
Use this exact format:
## Meeting Summary
One sentence: what this meeting was about.
## Key Takeaways
- Top 3-5 important points discussed
- Include who said what when relevant
## Action Items
- [ ] Task — assigned to whom, deadline if mentioned
- [ ] Task — assigned to whom
## Decisions Made
- List any decisions or agreements reached
## Open Questions
- Anything unresolved or needing follow-up
Keep it concise and actionable.
Thinking
Thinking
Bash
Read summary consumer
IN
ls /volume1/screenpipe/app/consumers/ && cat /volume1/screenpipe/app/consumers/summary.py
Copy code to clipboard
OUT
activity.py
audio.py
elements.py
__init__.py
interactions.py
ocr.py
__pycache__
report.py
summary.py
"""AI summary generator using Claude."""
import os
from datetime import date
from typing import Any
from consumers.activity import app_time, summary_stats, browser_urls, ui_event_summary
from consumers.ocr import deduplicated_text
from consumers.audio import formatted_transcript
SUMMARY_TYPES = {
"day_recap": {
"title": "Day Recap",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
## Audio/speech:
{audio}
Write a concise day recap using EXACTLY this format:
## Summary
One sentence: what I mainly worked on today.
## Accomplishments
- Top 3 things I finished, with approximate times
- Name specific apps, files, or projects
## Key Moments
- Important things seen or heard, with timestamps
## Unfinished Work
- What to continue tomorrow
## Patterns
- Apps used most, topics that came up repeatedly
Only report what you can verify from the data. End with:
**Next step:** [most important thing to continue]""",
},
"standup": {
"title": "Standup Update",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
## Audio/speech:
{audio}
Write a brief standup update:
**Yesterday:** What I worked on (2-3 bullets)
**Today:** What I plan to continue (1-2 bullets)
**Blockers:** Any issues observed (or "None")
Keep it under 150 words. Only report what's verifiable from the data.""",
},
"focus_time": {
"title": "Focus & Distraction Analysis",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
Analyze focus vs distraction patterns:
## Deep Work Periods
- When and how long were sustained focus sessions?
- What was being worked on?
## Distractions
- Which apps/sites were used recreationally?
- How much time was lost to context switching?
## Recommendations
- 2-3 concrete suggestions to improve focus tomorrow
Be specific with times and app names.""",
},
}
def _build_context(for_date: date) -> dict[str, str]:
apps = app_time(for_date)
app_lines = "\n".join(f"- {a['app_name']}: {a['minutes']} min" for a in apps[:20])
urls = browser_urls(for_date, limit=20)
url_lines = "\n".join(
f"- {u['browser_url'][:100]} ({u['minutes']} min)" for u in urls
)
ui_rows = ui_event_summary(for_date)
ui_lines = "\n".join(
f"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches"
for r in ui_rows[:15]
)
ocr_rows = deduplicated_text(for_date, chunk_minutes=5)
ocr_lines = "\n".join(
f"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}"
for r in ocr_rows[:100]
)
audio = formatted_transcript(for_date)
return {
"app_time": app_lines or "(no app data)",
"browser_urls": url_lines or "(no browser data)",
"ui_events": ui_lines or "(no UI event data)",
"ocr_text": ocr_lines or "(no screen data)",
"audio": audio[:3000] if len(audio) > 3000 else audio,
}
def generate(
summary_type: str = "day_recap",
for_date: date | None = None,
api_key: str | None = None,
) -> dict[str, Any]:
"""Generate an AI summary. Returns dict with 'title', 'content', 'date'."""
import anthropic
d = for_date or date.today()
key = api_key or os.environ.get("ANTHROPIC_API_KEY", "")
if not key:
return {
"title": "Error",
"content": "ANTHROPIC_API_KEY not set. Add it to your .env file.",
"date": str(d),
}
spec = SUMMARY_TYPES.get(summary_type)
if not spec:
return {"title": "Error", "content": f"Unknown summary type: {summary_type}", "date": str(d)}
stats = summary_stats(d)
if stats["total_frames"] == 0:
return {
"title": spec["title"],
"content": f"No screen data found for {d}.",
"date": str(d),
}
ctx = _build_context(d)
prompt = spec["prompt"].format(**ctx)
client = anthropic.Anthropic(api_key=key)
message = client.messages.create(
model="claude-haiku-4-5-20251001",
max_tokens=1024,
messages=[{"role": "user", "content": prompt}],
)
return {
"title": spec["title"],
"content": message.content[0].text,
"date": str(d),
"stats": stats,
}
Thinking
Thinking
Bash
Read all pipe.md files
IN
for f in /volume1/screenpipe/pipes/*/pipe.md; do echo "=== $f ==="; cat "$f"; echo; done
Copy code to clipboard
OUT
=== /volume1/screenpipe/pipes/ai-habits/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: AI Habits
description: "How you use AI tools — patterns and insights"
icon: "🤖"
featured: true
---
Search my recordings from the last 24 hours for AI tool usage. Use app_name filter for each tool separately: ChatGPT, Claude, Copilot, Cursor, Gemini, Perplexity. Use limit=5 per search, max 6 searches total.
Read screenpipe skill first.
Use this exact format:
## AI Tools Used
- List each tool with approximate time spent (e.g. "Claude: ~45min")
## What I Used Them For
- For each tool: coding, writing, research, or brainstorming
## Usage Patterns
- Do I switch between tools? Use them in bursts or steadily?
## Effectiveness
- Which tool appeared alongside completed work vs. abandoned attempts
If no AI usage is found, say so clearly. End with: "**Tip:** [one suggestion to use AI tools more effectively]"
=== /volume1/screenpipe/pipes/day-recap/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Day Recap
description: "Today's accomplishments, key moments, and unfinished work"
icon: "📋"
featured: true
---
Analyze my screen and audio recordings from today (last 16 hours only).
Read screenpipe skill first.
Use this exact format:
## Summary
One sentence: what I mainly did today.
## Accomplishments
- Top 3 things I finished, with timestamps (e.g. "2:30 PM")
- Name specific apps, files, or projects
## Key Moments
- Important things I saw, said, or heard — with timestamps
## Unfinished Work
- What I should continue tomorrow — name the app/file/task
## Patterns
- Apps I used most, topics that came up repeatedly
Only report what you can verify from the data. End with: "**Next step:** [most important thing to continue]"
=== /volume1/screenpipe/pipes/meeting-summary/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Meeting Summary
description: "Summarize meeting transcript with key takeaways and action items"
icon: "🤝"
featured: false
---
Summarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.
Read screenpipe skill first.
Use this exact format:
## Meeting Summary
One sentence: what this meeting was about.
## Key Takeaways
- Top 3-5 important points discussed
- Include who said what when relevant
## Action Items
- [ ] Task — assigned to whom, deadline if mentioned
- [ ] Task — assigned to whom
## Decisions Made
- List any decisions or agreements reached
## Open Questions
- Anything unresolved or needing follow-up
Keep it concise and actionable.
=== /volume1/screenpipe/pipes/standup-update/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Standup Update
description: "What you did, what's next, and any blockers"
icon: "🏢"
featured: true
---
Based on my recordings from the last 24 hours, generate a standup update. Use limit=10 per search, max 3 searches total.
Read screenpipe skill first.
Use this exact format:
## Yesterday
- What I worked on (name specific projects, files, tools, PRs)
## Today
- What I will work on next (based on unfinished tasks and recent activity)
## Blockers
- Issues I hit — errors, slow builds, waiting on someone
- If no blockers, write "None"
Keep it under 150 words. Copy-paste ready for a team standup.
=== /volume1/screenpipe/pipes/time-breakdown/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Time Breakdown
description: "Where your time went — by app, project, and category"
icon: "⏱"
featured: false
---
Analyze my app usage from today (last 12 hours). Use limit=10 per search, max 4 searches. Prefer /raw_sql with COUNT/GROUP BY queries.
Read screenpipe skill first.
Use this exact format with durations and percentages:
## By Application
- List each app with duration and percentage, sorted by time (e.g. "VS Code: 2h 15min (28%)")
## By Category
- Group into: coding, meetings, browsing, writing, communication, other
- Show hours and percentage per category
## By Project
- Group related activities by project/topic. Name specific repos or tasks.
## Productivity Score
- Calculate: focused_work_hours / total_hours as a percentage
- Focused = coding + writing. Unfocused = browsing + switching.
End with: "**Suggestion:** [one specific change to improve tomorrow's productivity]"
=== /volume1/screenpipe/pipes/video-export/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Export Video Clip
description: "Create a video of your recent screen activity"
icon: "🎬"
featured: false
---
Export a video of my screen activity from the last 5 minutes.
Read screenpipe skill first.
Use the POST /frames/export endpoint with the time range and fps=1.0. Then show me the exported video file path as an inline code block so I can watch it.
If the export is large, suggest a lower fps or shorter time range.
Thinking
Thinking
Now I have a clear picture. The pipes are markdown prompt templates in
/volume1/screenpipe/pipes/
, but there's no code to actually load and run them —
consumers/summary.py
has its own hardcoded prompts instead.
Here's what I'll implement:
consumers/pipes.py
— dynamically loads pipe.md files and runs them via Claude (data injected as system message, pipe body as user prompt)
main.py
— two new endpoints:
GET /api/pipes
and
POST /api/pipes/{pipe_id}/run
cli.py
— a
pipe
command to run pipes from the terminal
Let me build it:
Bash
Check browser_urls signature
IN
cat /volume1/screenpipe/app/consumers/activity.py | grep "def browser_urls" -A 5
Copy code to clipboard
OUT
def browser_urls(
for_date: date | None = None,
app_name: str | None = None,
ts_from: str | None = None,
ts_to: str | None = None,
limit: int = 30,
Write
pipes.py
pipes.py
143 lines
"""Dynamic pipe loader and runner."""
import os
import re
from datetime import date
from pathlib import Path
from typing import Any
def _parse_frontmatter(text: str) -> tuple[dict, str]:
if not text.startswith("---"):
return {}, text
try:
end = text.index("---", 3)
except ValueError:
return {}, text
fm_text = text[3:end].strip()
body = text[end + 3:].strip()
meta: dict = {}
for line in fm_text.splitlines():
if ":" in line:
k, _, v = line.partition(":")
meta[k.strip()] = v.strip().strip('"')
return meta, body
def load_pipes(pipes_dir: Path) -> list[dict]:
if not pipes_dir.exists():
return []
pipes = []
for pipe_dir in sorted(pipes_dir.iterdir()):
if not pipe_dir.is_dir() or pipe_dir.name.startswith("."):
continue
pipe_md = pipe_dir / "pipe.md"
if not pipe_md.exists():
continue
text = pipe_md.read_text(encoding="utf-8")
meta, body = _parse_frontmatter(text)
if meta.get("enabled", "true").lower() == "false":
continue
body = re.sub(r"Read screenpipe skill first\.?\n?", "", body).strip()
pipes.append({
"id": pipe_dir.name,
"title": meta.get("title", pipe_dir.name),
"description": meta.get("description", ""),
"icon": meta.get("icon", ""),
"schedule": meta.get("schedule", "manual"),
"featured": meta.get("featured", "false").lower() == "true",
"prompt": body,
})
return pipes
def _build_system(d: date, stats: dict) -> str:
from consumers.activity import app_time, browser_urls, ui_event_summary
from consumers.ocr import deduplicated_text
from consumers.audio import formatted_transcript
apps = app_time(d)
app_lines = "\n".join(f"- {a['app_name']}: {a['minutes']} min" for a in apps[:20])
urls = browser_urls(d, limit=20)
url_lines = "\n".join(f"- {u['browser_url'][:100]} ({u['minutes']} min)" for u in urls)
ui_rows = ui_event_summary(d)
ui_lines = "\n".join(
f"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches"
for r in ui_rows[:15]
)
ocr_rows = deduplicated_text(d, chunk_minutes=5)
ocr_lines = "\n".join(
f"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}"
for r in ocr_rows[:100]
)
audio = formatted_transcript(d)
if len(audio) > 3000:
audio = audio[:3000]
return f"""You are analyzing screenpipe data — recordings of a person's computer activity.
## App usage (minutes per app):
{app_lines or '(no app data)'}
## Browser URLs visited:
{url_lines or '(no browser data)'}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_lines or '(no UI event data)'}
## Screen content (sampled every 5 minutes):
{ocr_lines or '(no screen data)'}
## Audio / speech:
{audio or '(no audio data)'}
Date: {d}
Total frames recorded: {stats['total_frames']}"""
def run_pipe(
pipe_id: str,
for_date: date | None = None,
api_key: str | None = None,
pipes_dir: Path | None = None,
) -> dict[str, Any]:
import anthropic
from consumers.activity import summary_stats
d = for_date or date.today()
key = api_key or os.environ.get("ANTHROPIC_API_KEY", "")
if not key:
return {"title": "Error", "content": "ANTHROPIC_API_KEY not set.", "date": str(d)}
_pipes_dir = pipes_dir or Path(os.environ.get("PIPES_DIR", "/data/pipes"))
all_pipes = {p["id"]: p for p in load_pipes(_pipes_dir)}
if pipe_id not in all_pipes:
return {"title": "Error", "content": f"Pipe not found: {pipe_id}", "date": str(d)}
pipe = all_pipes[pipe_id]
stats = summary_stats(d)
if stats["total_frames"] == 0:
return {"title": pipe["title"], "content": f"No screen data found for {d}.", "date": str(d)}
system = _build_system(d, stats)
client = anthropic.Anthropic(api_key=key)
message = client.messages.create(
model="claude-haiku-4-5-20251001",
max_tokens=1024,
system=system,
messages=[{"role": "user", "content": pipe["prompt"]}],
)
return {
"title": pipe["title"],
"content": message.content[0].text,
"date": str(d),
"stats": stats,
}
Now add the API endpoints to
main.py
:
Edit
main.py
main.py
Added 1 line
Edit
main.py
main.py
Added 1 line
Now add the pipe endpoints at the end of main.py, before the closing summary section:
Edit
main.py
main.py
Added 14 lines
Now add the CLI command to
cli.py
cli.py
:
Edit
cli.py
cli.py
Added 40 lines
Done. Here's how to run pipes:
How to run pipes
How to run pipes
Via Docker (inside the running container):
Copy code to clipboard
docker exec -it screenpipe-app python cli.py pipe --list
docker exec -it screenpipe-app python cli.py pipe day-recap
docker exec -it screenpipe-app python cli.py pipe standup-update --date yesterday
Via the API
(once the container is running on port 8766):
Copy code to clipboard
# List pipes
curl [URL_WITH_CREDENTIALS] sudo docker exec -it screenpipe-app python cli.py pipe day-recap --date 2026-04-20
Running pipe 'day-recap' for 2026-04-20...
Traceback (most recent call last):
File "/app/cli.py", line 245, in <module>
cli()
File "/usr/local/lib/python3.12/site-packages/click/core.py", line 1161, in __call__
return self.main(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/click/core.py", line 1082, in main
rv = self.invoke(ctx)
^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/click/core.py", line 1697, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/click/core.py", line 1443, in invoke
return ctx.invoke(self.callback, **ctx.params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/click/core.py", line 788, in invoke
return __callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/cli.py", line 225, in pipe
result = run_pipe(pipe_id, target, pipes_dir=pipes_dir)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/consumers/pipes.py", line 130, in run_pipe
message = client.messages.create(
^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/anthropic/_utils/_utils.py", line 275, in wrapper
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/anthropic/resources/messages/messages.py", line 953, in create
return self._post(
^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/anthropic/_base_client.py", line 1336, in post
return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/anthropic/_base_client.py", line 1013, in request
return self._request(
^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/anthropic/_base_client.py", line 1117, in _request
raise self._make_status_error_from_response(err.response) from None
anthropic.AuthenticationError: Error code: 401 - {'type': 'error', 'error': {'type': 'authentication_error', 'message': 'invalid x-api-key'}, 'request_id': 'req_011CaSoR75WgV8fTcHTYJMDY'}
Adm1n@DXP4800PLUS-B5F8:/volume1/screenpipe/app$
Thinking
Thinking...
|
[{"role":"AXRadioButton","text [{"role":"AXRadioButton","text":"Explorer (⇧⌘E)","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":true},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Search (⇧⌘F)","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Source Control (⌃⇧G) - 10 pending changes","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"10","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Run and Debug (⇧⌘D)","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Remote Explorer","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Extensions (⇧⌘X) - 2 require update","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"2","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Claude Code","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"Containers","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXHeading","text":"EXPLORER","depth":17,"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"EXPLORER","depth":18,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Explorer Section: screenpipe [SSH: nas]","depth":21,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":true},{"role":"AXStaticText","text":"","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"Explorer Section: screenpipe [SSH: nas]","depth":22,"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"SCREENPIPE [SSH: NAS]","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"#recycle","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"app","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"__pycache__","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"consumers","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"static","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":".env","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"cli.py","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.py","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"docker-compose.yml","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Dockerfile","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"main.py","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"requirements.txt","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"data","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"logs","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"pipes","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":".gitignore","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"app_settings.json","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"archive.db","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"archive.db-bak","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"U","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite-shm","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite-wal","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe_sync_updated.sh","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"U","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe_sync.sh","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe.db","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Outline Section","depth":21,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"OUTLINE","depth":22,"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"OUTLINE","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Timeline Section","depth":21,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"TIMELINE","depth":22,"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"TIMELINE","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"app_settings.json, Editor Group 1","depth":28,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"screenpipe_sync.sh, Editor Group 1","depth":28,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"pipe.md, Editor Group 1","depth":28,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":".env, Editor Group 1","depth":28,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":false},{"role":"AXStaticText","text":"","depth":29,"on_screen":true,"role_description":"text"},{"role":"AXTextArea","text":"ANTHROPIC_API_KEY=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","depth":28,"on_screen":true,"value":"ANTHROPIC_API_KEY=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","role_description":"editor","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"ANTHROPIC_API_KEY=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","depth":29,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Implement and run pipe l…, Editor Group 2","depth":28,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":false},{"role":"AXRadioButton","text":"Problems (⇧⌘M)","depth":22,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"PROBLEMS","depth":24,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Output (⇧⌘U)","depth":22,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUTPUT","depth":24,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Debug Console (⇧⌘Y)","depth":22,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"DEBUG CONSOLE","depth":24,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Terminal (⌃`)","depth":22,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":true},{"role":"AXStaticText","text":"TERMINAL","depth":24,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Ports - 1 forwarded port","depth":22,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"PORTS","depth":24,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":25,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"remote SSH: nas","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"SSH: nas","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"screenpipe (Git) - master*, Checkout Branch/Tag...","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"master*","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"screenpipe (Git) - Synchronize Changes","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"No Problems","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"0","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"0","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Forwarded Ports: 8766","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Notifications","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sign In","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Sign In","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Info: Setting up SSH Host nas: Setting up SSH tunnel","depth":12,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Implement and run pipe logic","depth":19,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Session history","depth":19,"on_screen":true,"help_text":"Session history","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"New session","depth":19,"on_screen":true,"help_text":"New session","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Message actions","depth":24,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"main.py","depth":23,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"lets implement logic with pipes. how can I run it?","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Let me look at the current project structure to understand what's already in place.","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"List project files","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"find /volume1/screenpipe -type f | head -50 && echo \"---\" && ls /volume1/screenpipe","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"/volume1/screenpipe/.DS_Store\n/volume1/screenpipe/screenpipe.db\n/volume1/screenpipe/screenpipe_sync.sh\n/volume1/screenpipe/app_settings.json\n/volume1/screenpipe/.gitignore\n/volume1/screenpipe/archive.db\n/volume1/screenpipe/db.sqlite\n/volume1/screenpipe/db.sqlite-wal\n/volume1/screenpipe/db.sqlite-shm\n/volume1/screenpipe/#recycle/desktop.ini\n/volume1/screenpipe/#recycle/db.sqlite\n/volume1/screenpipe/#recycle/Copy #1 of db.sqlite\n/volume1/screenpipe/#recycle/.DS_Store\n/volume1/screenpipe/#recycle/Copy #2 of db.sqlite\n/volume1/screenpipe/#recycle/archive.db\n/volume1/screenpipe/#recycle/Copy #1 of archive.db\n/volume1/screenpipe/#recycle/Copy #2 of archive.db\n/volume1/screenpipe/#recycle/Copy #3 of archive.db\n/volume1/screenpipe/#recycle/Copy #4 of archive.db\n/volume1/screenpipe/#recycle/Copy #5 of archive.db\n/volume1/screenpipe/#recycle/Copy #3 of db.sqlite\n/volume1/screenpipe/#recycle/Copy #4 of db.sqlite\n/volume1/screenpipe/#recycle/Copy #6 of archive.db\n/volume1/screenpipe/#recycle/test.txt\n/volume1/screenpipe/#recycle/Copy #7 of archive.db\n/volume1/screenpipe/#recycle/Copy #8 of archive.db\n/volume1/screenpipe/#recycle/archive.db-journal\n/volume1/screenpipe/#recycle/Copy #1 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #2 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #3 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #4 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #5 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #6 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #7 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #5 of db.sqlite\n/volume1/screenpipe/pipes/.DS_Store\n/volume1/screenpipe/app/.env\n/volume1/screenpipe/app/cli.py\n/volume1/screenpipe/app/.DS_Store\n/volume1/screenpipe/app/db.py\n/volume1/screenpipe/app/docker-compose.yml\n/volume1/screenpipe/app/main.py\n/volume1/screenpipe/app/requirements.txt\n/volume1/screenpipe/app/Dockerfile\n/volume1/screenpipe/data/.DS_Store\n/volume1/screenpipe/.git/description\n/volume1/screenpipe/.git/HEAD\n/volume1/screenpipe/.git/index\n/volume1/screenpipe/.git/COMMIT_EDITMSG\n/volume1/screenpipe/#recycle/data/.DS_Store\n---\napp\napp_settings.json\narchive.db\ndata\ndb.sqlite\ndb.sqlite-shm\ndb.sqlite-wal\npipes\n#recycle\nscreenpipe.db\nscreenpipe_sync.sh","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"main.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Check pipes directory and docker-compose","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/pipes/ && ls /volume1/screenpipe/app/ && cat /volume1/screenpipe/app/docker-compose.yml","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ai-habits\nday-recap\nmeeting-summary\nstandup-update\ntime-breakdown\nvideo-export\ncli.py\nconsumers\ndb.py\ndocker-compose.yml\nDockerfile\nmain.py\n__pycache__\nrequirements.txt\nstatic\nservices:\n screenpipe-app:\n build: .\n container_name: screenpipe-app\n restart: unless-stopped\n ports:\n - \"8766:8000\"\n volumes:\n - /volume1/screenpipe:/data\n env_file:\n - .env\n environment:\n TZ: Europe/Sofia\n DB_PATH: /data/db.sqlite\n\n sqlite-web-archive:\n image: ghcr.io/coleifer/sqlite-web:latest\n container_name: screenpipe-sqlweb-archive\n restart: unless-stopped\n ports:\n - \"8767:8080\"\n volumes:\n - /volume1/screenpipe:/data\n command: [\"-H\", \"0.0.0.0\", \"-r\", \"/data/archive.db\"]\n\n sqlite-web-live:\n image: ghcr.io/coleifer/sqlite-web:latest\n container_name: screenpipe-sqlweb-live\n restart: unless-stopped\n ports:\n - \"8768:8080\"\n volumes:\n - /volume1/screenpipe:/data\n command: [\"-H\", \"0.0.0.0\", \"-r\", \"/data/db.sqlite\"]","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"requirements.txt","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"requirements.txt","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Inspect a pipe directory","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/pipes/day-recap/ && cat /volume1/screenpipe/pipes/day-recap/pipe.json 2>/dev/null || ls /volume1/screenpipe/pipes/day-recap/","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"pipe.md\npipe.md","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"cli.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"cli.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"List all pipes and their contents","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/pipes/ && for d in /volume1/screenpipe/pipes/*/; do echo \"=== $d ===\"; ls \"$d\"; done","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ai-habits\nday-recap\nmeeting-summary\nstandup-update\ntime-breakdown\nvideo-export\n=== /volume1/screenpipe/pipes/ai-habits/ ===\npipe.md\n=== /volume1/screenpipe/pipes/day-recap/ ===\npipe.md\n=== /volume1/screenpipe/pipes/meeting-summary/ ===\npipe.md\n=== /volume1/screenpipe/pipes/standup-update/ ===\npipe.md\n=== /volume1/screenpipe/pipes/time-breakdown/ ===\npipe.md\n=== /volume1/screenpipe/pipes/video-export/ ===\npipe.md","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read pipe markdown files","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"cat /volume1/screenpipe/pipes/day-recap/pipe.md && echo \"===\" && cat /volume1/screenpipe/pipes/meeting-summary/pipe.md 2>/dev/null | head -50","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Day Recap\ndescription: \"Today's accomplishments, key moments, and unfinished work\"\nicon: \"📋\"\nfeatured: true\n---\n\nAnalyze my screen and audio recordings from today (last 16 hours only). \n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Summary\nOne sentence: what I mainly did today.\n\n## Accomplishments\n- Top 3 things I finished, with timestamps (e.g. \"2:30 PM\")\n- Name specific apps, files, or projects\n\n## Key Moments\n- Important things I saw, said, or heard — with timestamps\n\n## Unfinished Work\n- What I should continue tomorrow — name the app/file/task\n\n## Patterns\n- Apps I used most, topics that came up repeatedly\n\nOnly report what you can verify from the data. End with: \"**Next step:** [most important thing to continue]\"\n===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Meeting Summary\ndescription: \"Summarize meeting transcript with key takeaways and action items\"\nicon: \"🤝\"\nfeatured: false\n---\n\nSummarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.\n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Meeting Summary\nOne sentence: what this meeting was about.\n\n## Key Takeaways\n- Top 3-5 important points discussed\n- Include who said what when relevant\n\n## Action Items\n- [ ] Task — assigned to whom, deadline if mentioned\n- [ ] Task — assigned to whom\n\n## Decisions Made\n- List any decisions or agreements reached\n\n## Open Questions\n- Anything unresolved or needing follow-up\n\nKeep it concise and actionable.","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read summary consumer","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/app/consumers/ && cat /volume1/screenpipe/app/consumers/summary.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"activity.py\naudio.py\nelements.py\n__init__.py\ninteractions.py\nocr.py\n__pycache__\nreport.py\nsummary.py\n\"\"\"AI summary generator using Claude.\"\"\"\nimport os\nfrom datetime import date\nfrom typing import Any\n\nfrom consumers.activity import app_time, summary_stats, browser_urls, ui_event_summary\nfrom consumers.ocr import deduplicated_text\nfrom consumers.audio import formatted_transcript\n\n\nSUMMARY_TYPES = {\n \"day_recap\": {\n \"title\": \"Day Recap\",\n \"prompt\": \"\"\"\\\nYou are analyzing a person's computer activity for the day.\n\n## App usage (minutes per app):\n{app_time}\n\n## Browser URLs visited:\n{browser_urls}\n\n## UI activity per app (clicks / keystrokes / app-switches):\n{ui_events}\n\n## Screen content (sampled every 5 minutes):\n{ocr_text}\n\n## Audio/speech:\n{audio}\n\nWrite a concise day recap using EXACTLY this format:\n\n## Summary\nOne sentence: what I mainly worked on today.\n\n## Accomplishments\n- Top 3 things I finished, with approximate times\n- Name specific apps, files, or projects\n\n## Key Moments\n- Important things seen or heard, with timestamps\n\n## Unfinished Work\n- What to continue tomorrow\n\n## Patterns\n- Apps used most, topics that came up repeatedly\n\nOnly report what you can verify from the data. End with:\n**Next step:** [most important thing to continue]\"\"\",\n },\n \"standup\": {\n \"title\": \"Standup Update\",\n \"prompt\": \"\"\"\\\nYou are analyzing a person's computer activity for the day.\n\n## App usage (minutes per app):\n{app_time}\n\n## Browser URLs visited:\n{browser_urls}\n\n## UI activity per app (clicks / keystrokes / app-switches):\n{ui_events}\n\n## Screen content (sampled every 5 minutes):\n{ocr_text}\n\n## Audio/speech:\n{audio}\n\nWrite a brief standup update:\n\n**Yesterday:** What I worked on (2-3 bullets)\n**Today:** What I plan to continue (1-2 bullets)\n**Blockers:** Any issues observed (or \"None\")\n\nKeep it under 150 words. Only report what's verifiable from the data.\"\"\",\n },\n \"focus_time\": {\n \"title\": \"Focus & Distraction Analysis\",\n \"prompt\": \"\"\"\\\nYou are analyzing a person's computer activity for the day.\n\n## App usage (minutes per app):\n{app_time}\n\n## Browser URLs visited:\n{browser_urls}\n\n## UI activity per app (clicks / keystrokes / app-switches):\n{ui_events}\n\n## Screen content (sampled every 5 minutes):\n{ocr_text}\n\nAnalyze focus vs distraction patterns:\n\n## Deep Work Periods\n- When and how long were sustained focus sessions?\n- What was being worked on?\n\n## Distractions\n- Which apps/sites were used recreationally?\n- How much time was lost to context switching?\n\n## Recommendations\n- 2-3 concrete suggestions to improve focus tomorrow\n\nBe specific with times and app names.\"\"\",\n },\n}\n\n\ndef _build_context(for_date: date) -> dict[str, str]:\n apps = app_time(for_date)\n app_lines = \"\\n\".join(f\"- {a['app_name']}: {a['minutes']} min\" for a in apps[:20])\n\n urls = browser_urls(for_date, limit=20)\n url_lines = \"\\n\".join(\n f\"- {u['browser_url'][:100]} ({u['minutes']} min)\" for u in urls\n )\n\n ui_rows = ui_event_summary(for_date)\n ui_lines = \"\\n\".join(\n f\"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches\"\n for r in ui_rows[:15]\n )\n\n ocr_rows = deduplicated_text(for_date, chunk_minutes=5)\n ocr_lines = \"\\n\".join(\n f\"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}\"\n for r in ocr_rows[:100]\n )\n\n audio = formatted_transcript(for_date)\n\n return {\n \"app_time\": app_lines or \"(no app data)\",\n \"browser_urls\": url_lines or \"(no browser data)\",\n \"ui_events\": ui_lines or \"(no UI event data)\",\n \"ocr_text\": ocr_lines or \"(no screen data)\",\n \"audio\": audio[:3000] if len(audio) > 3000 else audio,\n }\n\n\ndef generate(\n summary_type: str = \"day_recap\",\n for_date: date | None = None,\n api_key: str | None = None,\n) -> dict[str, Any]:\n \"\"\"Generate an AI summary. Returns dict with 'title', 'content', 'date'.\"\"\"\n import anthropic\n\n d = for_date or date.today()\n key = api_key or os.environ.get(\"ANTHROPIC_API_KEY\", \"\")\n if not key:\n return {\n \"title\": \"Error\",\n \"content\": \"ANTHROPIC_API_KEY not set. Add it to your .env file.\",\n \"date\": str(d),\n }\n\n spec = SUMMARY_TYPES.get(summary_type)\n if not spec:\n return {\"title\": \"Error\", \"content\": f\"Unknown summary type: {summary_type}\", \"date\": str(d)}\n\n stats = summary_stats(d)\n if stats[\"total_frames\"] == 0:\n return {\n \"title\": spec[\"title\"],\n \"content\": f\"No screen data found for {d}.\",\n \"date\": str(d),\n }\n\n ctx = _build_context(d)\n prompt = spec[\"prompt\"].format(**ctx)\n\n client = anthropic.Anthropic(api_key=key)\n message = client.messages.create(\n model=\"claude-haiku-4-5-20251001\",\n max_tokens=1024,\n messages=[{\"role\": \"user\", \"content\": prompt}],\n )\n\n return {\n \"title\": spec[\"title\"],\n \"content\": message.content[0].text,\n \"date\": str(d),\n \"stats\": stats,\n }","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read all pipe.md files","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"for f in /volume1/screenpipe/pipes/*/pipe.md; do echo \"=== $f ===\"; cat \"$f\"; echo; done","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"=== /volume1/screenpipe/pipes/ai-habits/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: AI Habits\ndescription: \"How you use AI tools — patterns and insights\"\nicon: \"🤖\"\nfeatured: true\n---\n\nSearch my recordings from the last 24 hours for AI tool usage. Use app_name filter for each tool separately: ChatGPT, Claude, Copilot, Cursor, Gemini, Perplexity. Use limit=5 per search, max 6 searches total.\n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## AI Tools Used\n- List each tool with approximate time spent (e.g. \"Claude: ~45min\")\n\n## What I Used Them For\n- For each tool: coding, writing, research, or brainstorming\n\n## Usage Patterns\n- Do I switch between tools? Use them in bursts or steadily?\n\n## Effectiveness\n- Which tool appeared alongside completed work vs. abandoned attempts\n\nIf no AI usage is found, say so clearly. End with: \"**Tip:** [one suggestion to use AI tools more effectively]\"\n\n=== /volume1/screenpipe/pipes/day-recap/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Day Recap\ndescription: \"Today's accomplishments, key moments, and unfinished work\"\nicon: \"📋\"\nfeatured: true\n---\n\nAnalyze my screen and audio recordings from today (last 16 hours only). \n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Summary\nOne sentence: what I mainly did today.\n\n## Accomplishments\n- Top 3 things I finished, with timestamps (e.g. \"2:30 PM\")\n- Name specific apps, files, or projects\n\n## Key Moments\n- Important things I saw, said, or heard — with timestamps\n\n## Unfinished Work\n- What I should continue tomorrow — name the app/file/task\n\n## Patterns\n- Apps I used most, topics that came up repeatedly\n\nOnly report what you can verify from the data. End with: \"**Next step:** [most important thing to continue]\"\n\n=== /volume1/screenpipe/pipes/meeting-summary/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Meeting Summary\ndescription: \"Summarize meeting transcript with key takeaways and action items\"\nicon: \"🤝\"\nfeatured: false\n---\n\nSummarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.\n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Meeting Summary\nOne sentence: what this meeting was about.\n\n## Key Takeaways\n- Top 3-5 important points discussed\n- Include who said what when relevant\n\n## Action Items\n- [ ] Task — assigned to whom, deadline if mentioned\n- [ ] Task — assigned to whom\n\n## Decisions Made\n- List any decisions or agreements reached\n\n## Open Questions\n- Anything unresolved or needing follow-up\n\nKeep it concise and actionable.\n\n=== /volume1/screenpipe/pipes/standup-update/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Standup Update\ndescription: \"What you did, what's next, and any blockers\"\nicon: \"🏢\"\nfeatured: true\n---\n\nBased on my recordings from the last 24 hours, generate a standup update. Use limit=10 per search, max 3 searches total.\n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Yesterday\n- What I worked on (name specific projects, files, tools, PRs)\n\n## Today\n- What I will work on next (based on unfinished tasks and recent activity)\n\n## Blockers\n- Issues I hit — errors, slow builds, waiting on someone\n- If no blockers, write \"None\"\n\nKeep it under 150 words. Copy-paste ready for a team standup.\n\n=== /volume1/screenpipe/pipes/time-breakdown/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Time Breakdown\ndescription: \"Where your time went — by app, project, and category\"\nicon: \"⏱\"\nfeatured: false\n---\n\nAnalyze my app usage from today (last 12 hours). Use limit=10 per search, max 4 searches. Prefer /raw_sql with COUNT/GROUP BY queries.\n\nRead screenpipe skill first.\n\nUse this exact format with durations and percentages:\n\n## By Application\n- List each app with duration and percentage, sorted by time (e.g. \"VS Code: 2h 15min (28%)\")\n\n## By Category\n- Group into: coding, meetings, browsing, writing, communication, other\n- Show hours and percentage per category\n\n## By Project\n- Group related activities by project/topic. Name specific repos or tasks.\n\n## Productivity Score\n- Calculate: focused_work_hours / total_hours as a percentage\n- Focused = coding + writing. Unfocused = browsing + switching.\n\nEnd with: \"**Suggestion:** [one specific change to improve tomorrow's productivity]\"\n\n=== /volume1/screenpipe/pipes/video-export/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Export Video Clip\ndescription: \"Create a video of your recent screen activity\"\nicon: \"🎬\"\nfeatured: false\n---\n\nExport a video of my screen activity from the last 5 minutes.\n\nRead screenpipe skill first.\n\nUse the POST /frames/export endpoint with the time range and fps=1.0. Then show me the exported video file path as an inline code block so I can watch it.\n\nIf the export is large, suggest a lower fps or shorter time range.","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Now I have a clear picture. The pipes are markdown prompt templates in","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"/volume1/screenpipe/pipes/","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":", but there's no code to actually load and run them —","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"consumers/summary.py","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"has its own hardcoded prompts instead.","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Here's what I'll implement:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"consumers/pipes.py","depth":26,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"— dynamically loads pipe.md files and runs them via Claude (data injected as system message, pipe body as user prompt)","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"main.py","depth":26,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"— two new endpoints:","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"GET /api/pipes","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"and","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"POST /api/pipes/{pipe_id}/run","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"cli.py","depth":26,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"— a","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"pipe","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"command to run pipes from the terminal","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Let me build it:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Check browser_urls signature","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"cat /volume1/screenpipe/app/consumers/activity.py | grep \"def browser_urls\" -A 5","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"def browser_urls(\n for_date: date | None = None,\n app_name: str | None = None,\n ts_from: str | None = None,\n ts_to: str | None = None,\n limit: int = 30,","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Write","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"pipes.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"pipes.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"143 lines","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"\"\"\"Dynamic pipe loader and runner.\"\"\"\nimport os\nimport re\nfrom datetime import date\nfrom pathlib import Path\nfrom typing import Any\n\n\ndef _parse_frontmatter(text: str) -> tuple[dict, str]:\n if not text.startswith(\"---\"):\n return {}, text\n try:\n end = text.index(\"---\", 3)\n except ValueError:\n return {}, text\n fm_text = text[3:end].strip()\n body = text[end + 3:].strip()\n meta: dict = {}\n for line in fm_text.splitlines():\n if \":\" in line:\n k, _, v = line.partition(\":\")\n meta[k.strip()] = v.strip().strip('\"')\n return meta, body\n\n\ndef load_pipes(pipes_dir: Path) -> list[dict]:\n if not pipes_dir.exists():\n return []\n pipes = []\n for pipe_dir in sorted(pipes_dir.iterdir()):\n if not pipe_dir.is_dir() or pipe_dir.name.startswith(\".\"):\n continue\n pipe_md = pipe_dir / \"pipe.md\"\n if not pipe_md.exists():\n continue\n text = pipe_md.read_text(encoding=\"utf-8\")\n meta, body = _parse_frontmatter(text)\n if meta.get(\"enabled\", \"true\").lower() == \"false\":\n continue\n body = re.sub(r\"Read screenpipe skill first\\.?\\n?\", \"\", body).strip()\n pipes.append({\n \"id\": pipe_dir.name,\n \"title\": meta.get(\"title\", pipe_dir.name),\n \"description\": meta.get(\"description\", \"\"),\n \"icon\": meta.get(\"icon\", \"\"),\n \"schedule\": meta.get(\"schedule\", \"manual\"),\n \"featured\": meta.get(\"featured\", \"false\").lower() == \"true\",\n \"prompt\": body,\n })\n return pipes\n\n\ndef _build_system(d: date, stats: dict) -> str:\n from consumers.activity import app_time, browser_urls, ui_event_summary\n from consumers.ocr import deduplicated_text\n from consumers.audio import formatted_transcript\n\n apps = app_time(d)\n app_lines = \"\\n\".join(f\"- {a['app_name']}: {a['minutes']} min\" for a in apps[:20])\n\n urls = browser_urls(d, limit=20)\n url_lines = \"\\n\".join(f\"- {u['browser_url'][:100]} ({u['minutes']} min)\" for u in urls)\n\n ui_rows = ui_event_summary(d)\n ui_lines = \"\\n\".join(\n f\"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches\"\n for r in ui_rows[:15]\n )\n\n ocr_rows = deduplicated_text(d, chunk_minutes=5)\n ocr_lines = \"\\n\".join(\n f\"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}\"\n for r in ocr_rows[:100]\n )\n\n audio = formatted_transcript(d)\n if len(audio) > 3000:\n audio = audio[:3000]\n\n return f\"\"\"You are analyzing screenpipe data — recordings of a person's computer activity.\n\n## App usage (minutes per app):\n{app_lines or '(no app data)'}\n\n## Browser URLs visited:\n{url_lines or '(no browser data)'}\n\n## UI activity per app (clicks / keystrokes / app-switches):\n{ui_lines or '(no UI event data)'}\n\n## Screen content (sampled every 5 minutes):\n{ocr_lines or '(no screen data)'}\n\n## Audio / speech:\n{audio or '(no audio data)'}\n\nDate: {d}\nTotal frames recorded: {stats['total_frames']}\"\"\"\n\n\ndef run_pipe(\n pipe_id: str,\n for_date: date | None = None,\n api_key: str | None = None,\n pipes_dir: Path | None = None,\n) -> dict[str, Any]:\n import anthropic\n from consumers.activity import summary_stats\n\n d = for_date or date.today()\n key = api_key or os.environ.get(\"ANTHROPIC_API_KEY\", \"\")\n if not key:\n return {\"title\": \"Error\", \"content\": \"ANTHROPIC_API_KEY not set.\", \"date\": str(d)}\n\n _pipes_dir = pipes_dir or Path(os.environ.get(\"PIPES_DIR\", \"/data/pipes\"))\n all_pipes = {p[\"id\"]: p for p in load_pipes(_pipes_dir)}\n\n if pipe_id not in all_pipes:\n return {\"title\": \"Error\", \"content\": f\"Pipe not found: {pipe_id}\", \"date\": str(d)}\n\n pipe = all_pipes[pipe_id]\n stats = summary_stats(d)\n\n if stats[\"total_frames\"] == 0:\n return {\"title\": pipe[\"title\"], \"content\": f\"No screen data found for {d}.\", \"date\": str(d)}\n\n system = _build_system(d, stats)\n\n client = anthropic.Anthropic(api_key=key)\n message = client.messages.create(\n model=\"claude-haiku-4-5-20251001\",\n max_tokens=1024,\n system=system,\n messages=[{\"role\": \"user\", \"content\": pipe[\"prompt\"]}],\n )\n\n return {\n \"title\": pipe[\"title\"],\n \"content\": message.content[0].text,\n \"date\": str(d),\n \"stats\": stats,\n }","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Now add the API endpoints to","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"main.py","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":":","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Edit","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"main.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Added 1 line","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Edit","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"main.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Added 1 line","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Now add the pipe endpoints at the end of main.py, before the closing summary section:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Edit","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"main.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Added 14 lines","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Now add the CLI command to","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"cli.py","depth":23,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"cli.py","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":":","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Edit","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"cli.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"cli.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Added 40 lines","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Done. Here's how to run pipes:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXHeading","text":"How to run pipes","depth":22,"on_screen":false,"role_description":"heading"},{"role":"AXStaticText","text":"How to run pipes","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Via Docker (inside the running container):","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":23,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"docker exec -it screenpipe-app python cli.py pipe --list\ndocker exec -it screenpipe-app python cli.py pipe day-recap\ndocker exec -it screenpipe-app python cli.py pipe standup-update --date yesterday","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Via the API","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"(once the container is running on port 8766):","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":23,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"# List pipes\ncurl http://localhost:8766/api/pipes\n\n# Run a pipe\ncurl -X POST \"http://localhost:8766/api/pipes/day-recap/run\"\ncurl -X POST \"http://localhost:8766/api/pipes/standup-update/run?d=2026-04-25\"","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Rebuild and restart","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"to pick up the changes:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":23,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"cd /volume1/screenpipe/app\ndocker compose up --build -d","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"How it works:","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Each","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"pipe.md","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"file is loaded dynamically — the frontmatter provides metadata and the body becomes the user prompt. Screenpipe data (app usage, browser URLs, OCR, audio) is injected as a Claude system message so the pipe prompt can reference it naturally. The \"Read screenpipe skill first\" line is stripped automatically.","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"The pipes directory inside Docker is","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"/data/pipes","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"(since","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"/volume1/screenpipe","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"→","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"/data","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"). You can override it with a","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"PIPES_DIR","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"env var if needed.","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Message actions","depth":24,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"pipe.md","depth":23,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"pipe.md","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"where to place api key and can I use different keys","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read .env file","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"cat /volume1/screenpipe/app/.env","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ANTHROPIC_API_KEY=your_key_here","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Where to place the key:","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"app/.env","depth":23,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"app/.env","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"— replace","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"your_key_here","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"with your actual key:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":23,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"ANTHROPIC_API_KEY=sk-ant-...","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"That file is loaded by","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"load_dotenv()","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"at startup and is excluded from git via","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":".gitignore","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":".","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Can you use different keys per pipe?","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Not currently — all pipes share the one key from","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":".env","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":". But you can add per-pipe key support by adding an","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"api_key","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"field to the pipe's frontmatter:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":23,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"---\ntitle: Meeting Summary\napi_key_env: ANTHROPIC_KEY_MEETINGS\n---","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Then in","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"consumers/pipes.py","depth":23,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"consumers/pipes.py","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":", read it in","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"_parse_frontmatter","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"and pass it through","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"run_pipe","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":". Want me to add that?","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Message actions","depth":24,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"pipe.md","depth":23,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"pipe.md","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"can I use mistral or other llm? or is is build for antrophic only","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Currently it's Anthropic-only — the code calls the","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"anthropic","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"SDK directly in both","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"consumers/pipes.py","depth":23,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"consumers/pipes.py","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"and","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"consumers/summary.py","depth":23,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"consumers/summary.py","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":".","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Adding other providers is straightforward since Mistral, Ollama, OpenRouter, Groq, and most modern LLMs expose an OpenAI-compatible API. The cleanest approach: add the","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"openai","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"package and let you configure the provider via","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":".env","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":":","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":23,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"# Anthropic (default)\nANTHROPIC_API_KEY=sk-ant-...\n\n# OR: any OpenAI-compatible provider\nLLM_PROVIDER=openai-compatible\nLLM_BASE_URL=https://api.mistral.ai/v1\nLLM_API_KEY=your-mistral-key\nLLM_MODEL=mistral-small-latest","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"This would cover Mistral, Ollama (","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"http://localhost:11434/v1","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"), OpenRouter, Groq, etc. with one code path.","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Want me to implement that? It's a small change — a","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"_call_llm(system, user_prompt)","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"helper in","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"pipes.py","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"that branches on","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"LLM_PROVIDER","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":", and","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"openai","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"added to","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"requirements.txt","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":".","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Message actions","depth":24,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"lets test it with anthropic first, how to run pipe","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Check if container is running","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"cd /volume1/screenpipe/app && docker compose ps 2>/dev/null || docker ps --filter name=screenpipe","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Exit code 1\npermission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get \"http://%2Fvar%2Frun%2Fdocker.sock/v1.45/containers/json?filters=%7B%22name%22%3A%7B%22screenpipe%22%3Atrue%7D%7D\": dial unix /var/run/docker.sock: connect: permission denied","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"I don't have Docker socket access, so you'll need to run these yourself. Here are your options:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Option A — via Docker (if container is already running):","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":23,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"# List available pipes\ndocker exec -it screenpipe-app python cli.py pipe --list\n\n# Run a specific pipe\ndocker exec -it screenpipe-app python cli.py pipe day-recap","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Option B — rebuild first (since we added new files), then run:","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":23,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"cd /volume1/screenpipe/app\ndocker compose up --build -d\ndocker exec -it screenpipe-app python cli.py pipe day-recap","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Option C — via the API","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"(if container is up on port 8766):","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":23,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"# List pipes\ncurl http://localhost:8766/api/pipes\n\n# Run a pipe\ncurl -X POST http://localhost:8766/api/pipes/day-recap/run","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"The","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"day-recap","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"or","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"standup-update","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"pipes are the best ones to test first since they use all data sources. Which option works for you?","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Message actions","depth":24,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"how ot run for specifiday","depth":25,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Docker exec:","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":23,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"docker exec -it screenpipe-app python cli.py pipe day-recap --date 2026-04-25\n# or shortcuts:\ndocker exec -it screenpipe-app python cli.py pipe day-recap --date yesterday\ndocker exec -it screenpipe-app python cli.py pipe day-recap --date today","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"API:","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":23,"on_screen":true,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"curl -X POST \"http://localhost:8766/api/pipes/day-recap/run?d=2026-04-25\"","depth":25,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Message actions","depth":24,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Adm1n@DXP4800PLUS-B5F8:/volume1/screenpipe/app$ sudo docker exec -it screenpipe-app python cli.py pipe day-recap --date 2026-04-20\nRunning pipe 'day-recap' for 2026-04-20...\nTraceback (most recent call last):\n File \"/app/cli.py\", line 245, in <module>\n cli()\n File \"/usr/local/lib/python3.12/site-packages/click/core.py\", line 1161, in __call__\n return self.main(*args, **kwargs)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/usr/local/lib/python3.12/site-packages/click/core.py\", line 1082, in main\n rv = self.invoke(ctx)\n ^^^^^^^^^^^^^^^^\n File \"/usr/local/lib/python3.12/site-packages/click/core.py\", line 1697, in invoke\n return _process_result(sub_ctx.command.invoke(sub_ctx))\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/usr/local/lib/python3.12/site-packages/click/core.py\", line 1443, in invoke\n return ctx.invoke(self.callback, **ctx.params)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/usr/local/lib/python3.12/site-packages/click/core.py\", line 788, in invoke\n return __callback(*args, **kwargs)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/app/cli.py\", line 225, in pipe\n result = run_pipe(pipe_id, target, pipes_dir=pipes_dir)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/app/consumers/pipes.py\", line 130, in run_pipe\n message = client.messages.create(\n ^^^^^^^^^^^^^^^^^^^^^^^\n File \"/usr/local/lib/python3.12/site-packages/anthropic/_utils/_utils.py\", line 275, in wrapper\n return func(*args, **kwargs)\n ^^^^^^^^^^^^^^^^^^^^^\n File \"/usr/local/lib/python3.12/site-packages/anthropic/resources/messages/messages.py\", line 953, in create\n return self._post(\n ^^^^^^^^^^^\n File \"/usr/local/lib/python3.12/site-packages/anthropic/_base_client.py\", line 1336, in post\n return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls))\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/usr/local/lib/python3.12/site-packages/anthropic/_base_client.py\", line 1013, in request\n return self._request(\n ^^^^^^^^^^^^^^\n File \"/usr/local/lib/python3.12/site-packages/anthropic/_base_client.py\", line 1117, in _request\n raise self._make_status_error_from_response(err.response) from None\nanthropic.AuthenticationError: Error code: 401 - {'type': 'error', 'error': {'type': 'authentication_error', 'message': 'invalid x-api-key'}, 'request_id': 'req_011CaSoR75WgV8fTcHTYJMDY'}\nAdm1n@DXP4800PLUS-B5F8:/volume1/screenpipe/app$","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":true,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":true,"role_description":"text"}]...
|
2158626665587694396
|
-8196324427125781304
|
idle
|
accessibility
|
NULL
|
Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧ Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py
M
db.py
docker-compose.yml
Dockerfile
M
main.py
M
requirements.txt
M
data
logs
pipes
.gitignore
app_settings.json
archive.db
archive.db-bak
U
db.sqlite
db.sqlite-shm
db.sqlite-wal
screenpipe_sync_updated.sh
U
screenpipe_sync.sh
screenpipe.db
Outline Section
OUTLINE
OUTLINE
Timeline Section
TIMELINE
TIMELINE
app_settings.json, Editor Group 1
screenpipe_sync.sh, Editor Group 1
pipe.md, Editor Group 1
.env, Editor Group 1
[ENV_SECRET]
[ENV_SECRET]
Implement and run pipe l…, Editor Group 2
Problems (⇧⌘M)
PROBLEMS
Output (⇧⌘U)
OUTPUT
Debug Console (⇧⌘Y)
DEBUG CONSOLE
Terminal (⌃`)
TERMINAL
Ports - 1 forwarded port
PORTS
1
remote SSH: nas
SSH: nas
screenpipe (Git) - master*, Checkout Branch/Tag...
master*
screenpipe (Git) - Synchronize Changes
No Problems
0
0
Forwarded Ports: 8766
1
Notifications
Sign In
Sign In
Info: Setting up SSH Host nas: Setting up SSH tunnel
Implement and run pipe logic
Session history
New session
Message actions
main.py
main.py
lets implement logic with pipes. how can I run it?
Thinking
Thinking
Let me look at the current project structure to understand what's already in place.
Bash
List project files
IN
find /volume1/screenpipe -type f | head -50 && echo "---" && ls /volume1/screenpipe
Copy code to clipboard
OUT
/volume1/screenpipe/.DS_Store
/volume1/screenpipe/screenpipe.db
/volume1/screenpipe/screenpipe_sync.sh
/volume1/screenpipe/app_settings.json
/volume1/screenpipe/.gitignore
/volume1/screenpipe/archive.db
/volume1/screenpipe/db.sqlite
/volume1/screenpipe/db.sqlite-wal
/volume1/screenpipe/db.sqlite-shm
/volume1/screenpipe/#recycle/desktop.ini
/volume1/screenpipe/#recycle/db.sqlite
/volume1/screenpipe/#recycle/Copy #1 of db.sqlite
/volume1/screenpipe/#recycle/.DS_Store
/volume1/screenpipe/#recycle/Copy #2 of db.sqlite
/volume1/screenpipe/#recycle/archive.db
/volume1/screenpipe/#recycle/Copy #1 of archive.db
/volume1/screenpipe/#recycle/Copy #2 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of archive.db
/volume1/screenpipe/#recycle/Copy #4 of archive.db
/volume1/screenpipe/#recycle/Copy #5 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of db.sqlite
/volume1/screenpipe/#recycle/Copy #4 of db.sqlite
/volume1/screenpipe/#recycle/Copy #6 of archive.db
/volume1/screenpipe/#recycle/test.txt
/volume1/screenpipe/#recycle/Copy #7 of archive.db
/volume1/screenpipe/#recycle/Copy #8 of archive.db
/volume1/screenpipe/#recycle/archive.db-journal
/volume1/screenpipe/#recycle/Copy #1 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #2 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #3 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #4 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #6 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #7 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of db.sqlite
/volume1/screenpipe/pipes/.DS_Store
/volume1/screenpipe/app/.env
/volume1/screenpipe/app/cli.py
/volume1/screenpipe/app/.DS_Store
/volume1/screenpipe/app/db.py
/volume1/screenpipe/app/docker-compose.yml
/volume1/screenpipe/app/main.py
/volume1/screenpipe/app/requirements.txt
/volume1/screenpipe/app/Dockerfile
/volume1/screenpipe/data/.DS_Store
/volume1/screenpipe/.git/description
/volume1/screenpipe/.git/HEAD
/volume1/screenpipe/.git/index
/volume1/screenpipe/.git/COMMIT_EDITMSG
/volume1/screenpipe/#recycle/data/.DS_Store
---
app
app_settings.json
archive.db
data
db.sqlite
db.sqlite-shm
db.sqlite-wal
pipes
#recycle
screenpipe.db
screenpipe_sync.sh
Read
main.py
main.py
Bash
Check pipes directory and docker-compose
IN
ls /volume1/screenpipe/pipes/ && ls /volume1/screenpipe/app/ && cat /volume1/screenpipe/app/docker-compose.yml
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
cli.py
consumers
db.py
docker-compose.yml
Dockerfile
main.py
__pycache__
requirements.txt
static
services:
screenpipe-app:
build: .
container_name: screenpipe-app
restart: unless-stopped
ports:
- "8766:8000"
volumes:
- /volume1/screenpipe:/data
env_file:
- .env
environment:
TZ: Europe/Sofia
DB_PATH: /data/db.sqlite
sqlite-web-archive:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-archive
restart: unless-stopped
ports:
- "8767:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/archive.db"]
sqlite-web-live:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-live
restart: unless-stopped
ports:
- "8768:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/db.sqlite"]
Read
requirements.txt
requirements.txt
Bash
Inspect a pipe directory
IN
ls /volume1/screenpipe/pipes/day-recap/ && cat /volume1/screenpipe/pipes/day-recap/pipe.json 2>/dev/null || ls /volume1/screenpipe/pipes/day-recap/
Copy code to clipboard
OUT
pipe.md
pipe.md
Read
cli.py
cli.py
Bash
List all pipes and their contents
IN
ls /volume1/screenpipe/pipes/ && for d in /volume1/screenpipe/pipes/*/; do echo "=== $d ==="; ls "$d"; done
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
=== /volume1/screenpipe/pipes/ai-habits/ ===
pipe.md
=== /volume1/screenpipe/pipes/day-recap/ ===
pipe.md
=== /volume1/screenpipe/pipes/meeting-summary/ ===
pipe.md
=== /volume1/screenpipe/pipes/standup-update/ ===
pipe.md
=== /volume1/screenpipe/pipes/time-breakdown/ ===
pipe.md
=== /volume1/screenpipe/pipes/video-export/ ===
pipe.md
Bash
Read pipe markdown files
IN
cat /volume1/screenpipe/pipes/day-recap/pipe.md && echo "===" && cat /volume1/screenpipe/pipes/meeting-summary/pipe.md 2>/dev/null | head -50
Copy code to clipboard
OUT
---
schedule: manual
enabled: true
template: true
title: Day Recap
description: "Today's accomplishments, key moments, and unfinished work"
icon: "📋"
featured: true
---
Analyze my screen and audio recordings from today (last 16 hours only).
Read screenpipe skill first.
Use this exact format:
## Summary
One sentence: what I mainly did today.
## Accomplishments
- Top 3 things I finished, with timestamps (e.g. "2:30 PM")
- Name specific apps, files, or projects
## Key Moments
- Important things I saw, said, or heard — with timestamps
## Unfinished Work
- What I should continue tomorrow — name the app/file/task
## Patterns
- Apps I used most, topics that came up repeatedly
Only report what you can verify from the data. End with: "**Next step:** [most important thing to continue]"
===
---
schedule: manual
enabled: true
template: true
title: Meeting Summary
description: "Summarize meeting transcript with key takeaways and action items"
icon: "🤝"
featured: false
---
Summarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.
Read screenpipe skill first.
Use this exact format:
## Meeting Summary
One sentence: what this meeting was about.
## Key Takeaways
- Top 3-5 important points discussed
- Include who said what when relevant
## Action Items
- [ ] Task — assigned to whom, deadline if mentioned
- [ ] Task — assigned to whom
## Decisions Made
- List any decisions or agreements reached
## Open Questions
- Anything unresolved or needing follow-up
Keep it concise and actionable.
Thinking
Thinking
Bash
Read summary consumer
IN
ls /volume1/screenpipe/app/consumers/ && cat /volume1/screenpipe/app/consumers/summary.py
Copy code to clipboard
OUT
activity.py
audio.py
elements.py
__init__.py
interactions.py
ocr.py
__pycache__
report.py
summary.py
"""AI summary generator using Claude."""
import os
from datetime import date
from typing import Any
from consumers.activity import app_time, summary_stats, browser_urls, ui_event_summary
from consumers.ocr import deduplicated_text
from consumers.audio import formatted_transcript
SUMMARY_TYPES = {
"day_recap": {
"title": "Day Recap",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
## Audio/speech:
{audio}
Write a concise day recap using EXACTLY this format:
## Summary
One sentence: what I mainly worked on today.
## Accomplishments
- Top 3 things I finished, with approximate times
- Name specific apps, files, or projects
## Key Moments
- Important things seen or heard, with timestamps
## Unfinished Work
- What to continue tomorrow
## Patterns
- Apps used most, topics that came up repeatedly
Only report what you can verify from the data. End with:
**Next step:** [most important thing to continue]""",
},
"standup": {
"title": "Standup Update",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
## Audio/speech:
{audio}
Write a brief standup update:
**Yesterday:** What I worked on (2-3 bullets)
**Today:** What I plan to continue (1-2 bullets)
**Blockers:** Any issues observed (or "None")
Keep it under 150 words. Only report what's verifiable from the data.""",
},
"focus_time": {
"title": "Focus & Distraction Analysis",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
Analyze focus vs distraction patterns:
## Deep Work Periods
- When and how long were sustained focus sessions?
- What was being worked on?
## Distractions
- Which apps/sites were used recreationally?
- How much time was lost to context switching?
## Recommendations
- 2-3 concrete suggestions to improve focus tomorrow
Be specific with times and app names.""",
},
}
def _build_context(for_date: date) -> dict[str, str]:
apps = app_time(for_date)
app_lines = "\n".join(f"- {a['app_name']}: {a['minutes']} min" for a in apps[:20])
urls = browser_urls(for_date, limit=20)
url_lines = "\n".join(
f"- {u['browser_url'][:100]} ({u['minutes']} min)" for u in urls
)
ui_rows = ui_event_summary(for_date)
ui_lines = "\n".join(
f"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches"
for r in ui_rows[:15]
)
ocr_rows = deduplicated_text(for_date, chunk_minutes=5)
ocr_lines = "\n".join(
f"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}"
for r in ocr_rows[:100]
)
audio = formatted_transcript(for_date)
return {
"app_time": app_lines or "(no app data)",
"browser_urls": url_lines or "(no browser data)",
"ui_events": ui_lines or "(no UI event data)",
"ocr_text": ocr_lines or "(no screen data)",
"audio": audio[:3000] if len(audio) > 3000 else audio,
}
def generate(
summary_type: str = "day_recap",
for_date: date | None = None,
api_key: str | None = None,
) -> dict[str, Any]:
"""Generate an AI summary. Returns dict with 'title', 'content', 'date'."""
import anthropic
d = for_date or date.today()
key = api_key or os.environ.get("ANTHROPIC_API_KEY", "")
if not key:
return {
"title": "Error",
"content": "ANTHROPIC_API_KEY not set. Add it to your .env file.",
"date": str(d),
}
spec = SUMMARY_TYPES.get(summary_type)
if not spec:
return {"title": "Error", "content": f"Unknown summary type: {summary_type}", "date": str(d)}
stats = summary_stats(d)
if stats["total_frames"] == 0:
return {
"title": spec["title"],
"content": f"No screen data found for {d}.",
"date": str(d),
}
ctx = _build_context(d)
prompt = spec["prompt"].format(**ctx)
client = anthropic.Anthropic(api_key=key)
message = client.messages.create(
model="claude-haiku-4-5-20251001",
max_tokens=1024,
messages=[{"role": "user", "content": prompt}],
)
return {
"title": spec["title"],
"content": message.content[0].text,
"date": str(d),
"stats": stats,
}
Thinking
Thinking
Bash
Read all pipe.md files
IN
for f in /volume1/screenpipe/pipes/*/pipe.md; do echo "=== $f ==="; cat "$f"; echo; done
Copy code to clipboard
OUT
=== /volume1/screenpipe/pipes/ai-habits/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: AI Habits
description: "How you use AI tools — patterns and insights"
icon: "🤖"
featured: true
---
Search my recordings from the last 24 hours for AI tool usage. Use app_name filter for each tool separately: ChatGPT, Claude, Copilot, Cursor, Gemini, Perplexity. Use limit=5 per search, max 6 searches total.
Read screenpipe skill first.
Use this exact format:
## AI Tools Used
- List each tool with approximate time spent (e.g. "Claude: ~45min")
## What I Used Them For
- For each tool: coding, writing, research, or brainstorming
## Usage Patterns
- Do I switch between tools? Use them in bursts or steadily?
## Effectiveness
- Which tool appeared alongside completed work vs. abandoned attempts
If no AI usage is found, say so clearly. End with: "**Tip:** [one suggestion to use AI tools more effectively]"
=== /volume1/screenpipe/pipes/day-recap/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Day Recap
description: "Today's accomplishments, key moments, and unfinished work"
icon: "📋"
featured: true
---
Analyze my screen and audio recordings from today (last 16 hours only).
Read screenpipe skill first.
Use this exact format:
## Summary
One sentence: what I mainly did today.
## Accomplishments
- Top 3 things I finished, with timestamps (e.g. "2:30 PM")
- Name specific apps, files, or projects
## Key Moments
- Important things I saw, said, or heard — with timestamps
## Unfinished Work
- What I should continue tomorrow — name the app/file/task
## Patterns
- Apps I used most, topics that came up repeatedly
Only report what you can verify from the data. End with: "**Next step:** [most important thing to continue]"
=== /volume1/screenpipe/pipes/meeting-summary/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Meeting Summary
description: "Summarize meeting transcript with key takeaways and action items"
icon: "🤝"
featured: false
---
Summarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.
Read screenpipe skill first.
Use this exact format:
## Meeting Summary
One sentence: what this meeting was about.
## Key Takeaways
- Top 3-5 important points discussed
- Include who said what when relevant
## Action Items
- [ ] Task — assigned to whom, deadline if mentioned
- [ ] Task — assigned to whom
## Decisions Made
- List any decisions or agreements reached
## Open Questions
- Anything unresolved or needing follow-up
Keep it concise and actionable.
=== /volume1/screenpipe/pipes/standup-update/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Standup Update
description: "What you did, what's next, and any blockers"
icon: "🏢"
featured: true
---
Based on my recordings from the last 24 hours, generate a standup update. Use limit=10 per search, max 3 searches total.
Read screenpipe skill first.
Use this exact format:
## Yesterday
- What I worked on (name specific projects, files, tools, PRs)
## Today
- What I will work on next (based on unfinished tasks and recent activity)
## Blockers
- Issues I hit — errors, slow builds, waiting on someone
- If no blockers, write "None"
Keep it under 150 words. Copy-paste ready for a team standup.
=== /volume1/screenpipe/pipes/time-breakdown/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Time Breakdown
description: "Where your time went — by app, project, and category"
icon: "⏱"
featured: false
---
Analyze my app usage from today (last 12 hours). Use limit=10 per search, max 4 searches. Prefer /raw_sql with COUNT/GROUP BY queries.
Read screenpipe skill first.
Use this exact format with durations and percentages:
## By Application
- List each app with duration and percentage, sorted by time (e.g. "VS Code: 2h 15min (28%)")
## By Category
- Group into: coding, meetings, browsing, writing, communication, other
- Show hours and percentage per category
## By Project
- Group related activities by project/topic. Name specific repos or tasks.
## Productivity Score
- Calculate: focused_work_hours / total_hours as a percentage
- Focused = coding + writing. Unfocused = browsing + switching.
End with: "**Suggestion:** [one specific change to improve tomorrow's productivity]"
=== /volume1/screenpipe/pipes/video-export/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Export Video Clip
description: "Create a video of your recent screen activity"
icon: "🎬"
featured: false
---
Export a video of my screen activity from the last 5 minutes.
Read screenpipe skill first.
Use the POST /frames/export endpoint with the time range and fps=1.0. Then show me the exported video file path as an inline code block so I can watch it.
If the export is large, suggest a lower fps or shorter time range.
Thinking
Thinking
Now I have a clear picture. The pipes are markdown prompt templates in
/volume1/screenpipe/pipes/
, but there's no code to actually load and run them —
consumers/summary.py
has its own hardcoded prompts instead.
Here's what I'll implement:
consumers/pipes.py
— dynamically loads pipe.md files and runs them via Claude (data injected as system message, pipe body as user prompt)
main.py
— two new endpoints:
GET /api/pipes
and
POST /api/pipes/{pipe_id}/run
cli.py
— a
pipe
command to run pipes from the terminal
Let me build it:
Bash
Check browser_urls signature
IN
cat /volume1/screenpipe/app/consumers/activity.py | grep "def browser_urls" -A 5
Copy code to clipboard
OUT
def browser_urls(
for_date: date | None = None,
app_name: str | None = None,
ts_from: str | None = None,
ts_to: str | None = None,
limit: int = 30,
Write
pipes.py
pipes.py
143 lines
"""Dynamic pipe loader and runner."""
import os
import re
from datetime import date
from pathlib import Path
from typing import Any
def _parse_frontmatter(text: str) -> tuple[dict, str]:
if not text.startswith("---"):
return {}, text
try:
end = text.index("---", 3)
except ValueError:
return {}, text
fm_text = text[3:end].strip()
body = text[end + 3:].strip()
meta: dict = {}
for line in fm_text.splitlines():
if ":" in line:
k, _, v = line.partition(":")
meta[k.strip()] = v.strip().strip('"')
return meta, body
def load_pipes(pipes_dir: Path) -> list[dict]:
if not pipes_dir.exists():
return []
pipes = []
for pipe_dir in sorted(pipes_dir.iterdir()):
if not pipe_dir.is_dir() or pipe_dir.name.startswith("."):
continue
pipe_md = pipe_dir / "pipe.md"
if not pipe_md.exists():
continue
text = pipe_md.read_text(encoding="utf-8")
meta, body = _parse_frontmatter(text)
if meta.get("enabled", "true").lower() == "false":
continue
body = re.sub(r"Read screenpipe skill first\.?\n?", "", body).strip()
pipes.append({
"id": pipe_dir.name,
"title": meta.get("title", pipe_dir.name),
"description": meta.get("description", ""),
"icon": meta.get("icon", ""),
"schedule": meta.get("schedule", "manual"),
"featured": meta.get("featured", "false").lower() == "true",
"prompt": body,
})
return pipes
def _build_system(d: date, stats: dict) -> str:
from consumers.activity import app_time, browser_urls, ui_event_summary
from consumers.ocr import deduplicated_text
from consumers.audio import formatted_transcript
apps = app_time(d)
app_lines = "\n".join(f"- {a['app_name']}: {a['minutes']} min" for a in apps[:20])
urls = browser_urls(d, limit=20)
url_lines = "\n".join(f"- {u['browser_url'][:100]} ({u['minutes']} min)" for u in urls)
ui_rows = ui_event_summary(d)
ui_lines = "\n".join(
f"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches"
for r in ui_rows[:15]
)
ocr_rows = deduplicated_text(d, chunk_minutes=5)
ocr_lines = "\n".join(
f"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}"
for r in ocr_rows[:100]
)
audio = formatted_transcript(d)
if len(audio) > 3000:
audio = audio[:3000]
return f"""You are analyzing screenpipe data — recordings of a person's computer activity.
## App usage (minutes per app):
{app_lines or '(no app data)'}
## Browser URLs visited:
{url_lines or '(no browser data)'}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_lines or '(no UI event data)'}
## Screen content (sampled every 5 minutes):
{ocr_lines or '(no screen data)'}
## Audio / speech:
{audio or '(no audio data)'}
Date: {d}
Total frames recorded: {stats['total_frames']}"""
def run_pipe(
pipe_id: str,
for_date: date | None = None,
api_key: str | None = None,
pipes_dir: Path | None = None,
) -> dict[str, Any]:
import anthropic
from consumers.activity import summary_stats
d = for_date or date.today()
key = api_key or os.environ.get("ANTHROPIC_API_KEY", "")
if not key:
return {"title": "Error", "content": "ANTHROPIC_API_KEY not set.", "date": str(d)}
_pipes_dir = pipes_dir or Path(os.environ.get("PIPES_DIR", "/data/pipes"))
all_pipes = {p["id"]: p for p in load_pipes(_pipes_dir)}
if pipe_id not in all_pipes:
return {"title": "Error", "content": f"Pipe not found: {pipe_id}", "date": str(d)}
pipe = all_pipes[pipe_id]
stats = summary_stats(d)
if stats["total_frames"] == 0:
return {"title": pipe["title"], "content": f"No screen data found for {d}.", "date": str(d)}
system = _build_system(d, stats)
client = anthropic.Anthropic(api_key=key)
message = client.messages.create(
model="claude-haiku-4-5-20251001",
max_tokens=1024,
system=system,
messages=[{"role": "user", "content": pipe["prompt"]}],
)
return {
"title": pipe["title"],
"content": message.content[0].text,
"date": str(d),
"stats": stats,
}
Now add the API endpoints to
main.py
:
Edit
main.py
main.py
Added 1 line
Edit
main.py
main.py
Added 1 line
Now add the pipe endpoints at the end of main.py, before the closing summary section:
Edit
main.py
main.py
Added 14 lines
Now add the CLI command to
cli.py
cli.py
:
Edit
cli.py
cli.py
Added 40 lines
Done. Here's how to run pipes:
How to run pipes
How to run pipes
Via Docker (inside the running container):
Copy code to clipboard
docker exec -it screenpipe-app python cli.py pipe --list
docker exec -it screenpipe-app python cli.py pipe day-recap
docker exec -it screenpipe-app python cli.py pipe standup-update --date yesterday
Via the API
(once the container is running on port 8766):
Copy code to clipboard
# List pipes
curl [URL_WITH_CREDENTIALS] sudo docker exec -it screenpipe-app python cli.py pipe day-recap --date 2026-04-20
Running pipe 'day-recap' for 2026-04-20...
Traceback (most recent call last):
File "/app/cli.py", line 245, in <module>
cli()
File "/usr/local/lib/python3.12/site-packages/click/core.py", line 1161, in __call__
return self.main(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/click/core.py", line 1082, in main
rv = self.invoke(ctx)
^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/click/core.py", line 1697, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/click/core.py", line 1443, in invoke
return ctx.invoke(self.callback, **ctx.params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/click/core.py", line 788, in invoke
return __callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/cli.py", line 225, in pipe
result = run_pipe(pipe_id, target, pipes_dir=pipes_dir)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/consumers/pipes.py", line 130, in run_pipe
message = client.messages.create(
^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/anthropic/_utils/_utils.py", line 275, in wrapper
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/anthropic/resources/messages/messages.py", line 953, in create
return self._post(
^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/anthropic/_base_client.py", line 1336, in post
return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/anthropic/_base_client.py", line 1013, in request
return self._request(
^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/anthropic/_base_client.py", line 1117, in _request
raise self._make_status_error_from_response(err.response) from None
anthropic.AuthenticationError: Error code: 401 - {'type': 'error', 'error': {'type': 'authentication_error', 'message': 'invalid x-api-key'}, 'request_id': 'req_011CaSoR75WgV8fTcHTYJMDY'}
Adm1n@DXP4800PLUS-B5F8:/volume1/screenpipe/app$
Thinking
Thinking...
|
21062
|
NULL
|
NULL
|
NULL
|
|
21065
|
921
|
3
|
2026-05-11T17:07:35.584854+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-11/1778 /Users/lukas/.screenpipe/data/data/2026-05-11/1778519255584_m2.jpg...
|
Code
|
Implement and run pipe l… — screenpipe [SSH: nas]
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧ Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py
M
db.py
docker-compose.yml
Dockerfile
M
main.py
M
requirements.txt
M
data
logs
pipes
.gitignore
app_settings.json
archive.db
archive.db-bak
U
db.sqlite
db.sqlite-shm
db.sqlite-wal
screenpipe_sync_updated.sh
U
screenpipe_sync.sh
screenpipe.db
Outline Section
OUTLINE
OUTLINE
Timeline Section
TIMELINE
TIMELINE
app_settings.json, Editor Group 1
screenpipe_sync.sh, Editor Group 1
pipe.md, Editor Group 1
.env, Editor Group 1
[ENV_SECRET]
[ENV_SECRET]
Implement and run pipe l…, Editor Group 2
Problems (⇧⌘M)
PROBLEMS
Output (⇧⌘U)
OUTPUT
Debug Console (⇧⌘Y)
DEBUG CONSOLE
Terminal (⌃`)
TERMINAL
Ports - 1 forwarded port
PORTS
1
remote SSH: nas
SSH: nas
screenpipe (Git) - master*, Checkout Branch/Tag...
master*
screenpipe (Git) - Synchronize Changes
No Problems
0
0
Forwarded Ports: 8766
1
Notifications
Sign In
Sign In
Info: Setting up SSH Host nas: Setting up SSH tunnel
Implement and run pipe logic
Session history
New session
Message actions
main.py
main.py
lets implement logic with pipes. how can I run it?
Thinking
Thinking
Let me look at the current project structure to understand what's already in place.
Bash
List project files
IN
find /volume1/screenpipe -type f | head -50 && echo "---" && ls /volume1/screenpipe
Copy code to clipboard
OUT
/volume1/screenpipe/.DS_Store
/volume1/screenpipe/screenpipe.db
/volume1/screenpipe/screenpipe_sync.sh
/volume1/screenpipe/app_settings.json
/volume1/screenpipe/.gitignore
/volume1/screenpipe/archive.db
/volume1/screenpipe/db.sqlite
/volume1/screenpipe/db.sqlite-wal
/volume1/screenpipe/db.sqlite-shm
/volume1/screenpipe/#recycle/desktop.ini
/volume1/screenpipe/#recycle/db.sqlite
/volume1/screenpipe/#recycle/Copy #1 of db.sqlite
/volume1/screenpipe/#recycle/.DS_Store
/volume1/screenpipe/#recycle/Copy #2 of db.sqlite
/volume1/screenpipe/#recycle/archive.db
/volume1/screenpipe/#recycle/Copy #1 of archive.db
/volume1/screenpipe/#recycle/Copy #2 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of archive.db
/volume1/screenpipe/#recycle/Copy #4 of archive.db
/volume1/screenpipe/#recycle/Copy #5 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of db.sqlite
/volume1/screenpipe/#recycle/Copy #4 of db.sqlite
/volume1/screenpipe/#recycle/Copy #6 of archive.db
/volume1/screenpipe/#recycle/test.txt
/volume1/screenpipe/#recycle/Copy #7 of archive.db
/volume1/screenpipe/#recycle/Copy #8 of archive.db
/volume1/screenpipe/#recycle/archive.db-journal
/volume1/screenpipe/#recycle/Copy #1 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #2 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #3 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #4 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #6 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #7 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of db.sqlite
/volume1/screenpipe/pipes/.DS_Store
/volume1/screenpipe/app/.env
/volume1/screenpipe/app/cli.py
/volume1/screenpipe/app/.DS_Store
/volume1/screenpipe/app/db.py
/volume1/screenpipe/app/docker-compose.yml
/volume1/screenpipe/app/main.py
/volume1/screenpipe/app/requirements.txt
/volume1/screenpipe/app/Dockerfile
/volume1/screenpipe/data/.DS_Store
/volume1/screenpipe/.git/description
/volume1/screenpipe/.git/HEAD
/volume1/screenpipe/.git/index
/volume1/screenpipe/.git/COMMIT_EDITMSG
/volume1/screenpipe/#recycle/data/.DS_Store
---
app
app_settings.json
archive.db
data
db.sqlite
db.sqlite-shm
db.sqlite-wal
pipes
#recycle
screenpipe.db
screenpipe_sync.sh
Read
main.py
main.py
Bash
Check pipes directory and docker-compose
IN
ls /volume1/screenpipe/pipes/ && ls /volume1/screenpipe/app/ && cat /volume1/screenpipe/app/docker-compose.yml
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
cli.py
consumers
db.py
docker-compose.yml
Dockerfile
main.py
__pycache__
requirements.txt
static
services:
screenpipe-app:
build: .
container_name: screenpipe-app
restart: unless-stopped
ports:
- "8766:8000"
volumes:
- /volume1/screenpipe:/data
env_file:
- .env
environment:
TZ: Europe/Sofia
DB_PATH: /data/db.sqlite
sqlite-web-archive:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-archive
restart: unless-stopped
ports:
- "8767:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/archive.db"]
sqlite-web-live:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-live
restart: unless-stopped
ports:
- "8768:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/db.sqlite"]
Read
requirements.txt
requirements.txt
Bash
Inspect a pipe directory
IN
ls /volume1/screenpipe/pipes/day-recap/ && cat /volume1/screenpipe/pipes/day-recap/pipe.json 2>/dev/null || ls /volume1/screenpipe/pipes/day-recap/
Copy code to clipboard
OUT
pipe.md
pipe.md
Read
cli.py
cli.py
Bash
List all pipes and their contents
IN
ls /volume1/screenpipe/pipes/ && for d in /volume1/screenpipe/pipes/*/; do echo "=== $d ==="; ls "$d"; done
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
=== /volume1/screenpipe/pipes/ai-habits/ ===
pipe.md
=== /volume1/screenpipe/pipes/day-recap/ ===
pipe.md
=== /volume1/screenpipe/pipes/meeting-summary/ ===
pipe.md
=== /volume1/screenpipe/pipes/standup-update/ ===
pipe.md
=== /volume1/screenpipe/pipes/time-breakdown/ ===
pipe.md
=== /volume1/screenpipe/pipes/video-export/ ===
pipe.md
Bash
Read pipe markdown files
IN
cat /volume1/screenpipe/pipes/day-recap/pipe.md && echo "===" && cat /volume1/screenpipe/pipes/meeting-summary/pipe.md 2>/dev/null | head -50
Copy code to clipboard
OUT
---
schedule: manual
enabled: true
template: true
title: Day Recap
description: "Today's accomplishments, key moments, and unfinished work"
icon: "📋"
featured: true
---
Analyze my screen and audio recordings from today (last 16 hours only).
Read screenpipe skill first.
Use this exact format:
## Summary
One sentence: what I mainly did today.
## Accomplishments
- Top 3 things I finished, with timestamps (e.g. "2:30 PM")
- Name specific apps, files, or projects
## Key Moments
- Important things I saw, said, or heard — with timestamps
## Unfinished Work
- What I should continue tomorrow — name the app/file/task
## Patterns
- Apps I used most, topics that came up repeatedly
Only report what you can verify from the data. End with: "**Next step:** [most important thing to continue]"
===
---
schedule: manual
enabled: true
template: true
title: Meeting Summary
description: "Summarize meeting transcript with key takeaways and action items"
icon: "🤝"
featured: false
---
Summarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.
Read screenpipe skill first.
Use this exact format:
## Meeting Summary
One sentence: what this meeting was about.
## Key Takeaways
- Top 3-5 important points discussed
- Include who said what when relevant
## Action Items
- [ ] Task — assigned to whom, deadline if mentioned
- [ ] Task — assigned to whom
## Decisions Made
- List any decisions or agreements reached
## Open Questions
- Anything unresolved or needing follow-up
Keep it concise and actionable.
Thinking
Thinking
Bash
Read summary consumer
IN
ls /volume1/screenpipe/app/consumers/ && cat /volume1/screenpipe/app/consumers/summary.py
Copy code to clipboard
OUT
activity.py
audio.py
elements.py
__init__.py
interactions.py
ocr.py
__pycache__
report.py
summary.py
"""AI summary generator using Claude."""
import os
from datetime import date
from typing import Any
from consumers.activity import app_time, summary_stats, browser_urls, ui_event_summary
from consumers.ocr import deduplicated_text
from consumers.audio import formatted_transcript
SUMMARY_TYPES = {
"day_recap": {
"title": "Day Recap",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
## Audio/speech:
{audio}
Write a concise day recap using EXACTLY this format:
## Summary
One sentence: what I mainly worked on today.
## Accomplishments
- Top 3 things I finished, with approximate times
- Name specific apps, files, or projects
## Key Moments
- Important things seen or heard, with timestamps
## Unfinished Work
- What to continue tomorrow
## Patterns
- Apps used most, topics that came up repeatedly
Only report what you can verify from the data. End with:
**Next step:** [most important thing to continue]""",
},
"standup": {
"title": "Standup Update",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
## Audio/speech:
{audio}
Write a brief standup update:
**Yesterday:** What I worked on (2-3 bullets)
**Today:** What I plan to continue (1-2 bullets)
**Blockers:** Any issues observed (or "None")
Keep it under 150 words. Only report what's verifiable from the data.""",
},
"focus_time": {
"title": "Focus & Distraction Analysis",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
Analyze focus vs distraction patterns:
## Deep Work Periods
- When and how long were sustained focus sessions?
- What was being worked on?
## Distractions
- Which apps/sites were used recreationally?
- How much time was lost to context switching?
## Recommendations
- 2-3 concrete suggestions to improve focus tomorrow
Be specific with times and app names.""",
},
}
def _build_context(for_date: date) -> dict[str, str]:
apps = app_time(for_date)
app_lines = "\n".join(f"- {a['app_name']}: {a['minutes']} min" for a in apps[:20])
urls = browser_urls(for_date, limit=20)
url_lines = "\n".join(
f"- {u['browser_url'][:100]} ({u['minutes']} min)" for u in urls
)
ui_rows = ui_event_summary(for_date)
ui_lines = "\n".join(
f"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches"
for r in ui_rows[:15]
)
ocr_rows = deduplicated_text(for_date, chunk_minutes=5)
ocr_lines = "\n".join(
f"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}"
for r in ocr_rows[:100]
)
audio = formatted_transcript(for_date)
return {
"app_time": app_lines or "(no app data)",
"browser_urls": url_lines or "(no browser data)",
"ui_events": ui_lines or "(no UI event data)",
"ocr_text": ocr_lines or "(no screen data)",
"audio": audio[:3000] if len(audio) > 3000 else audio,
}
def generate(
summary_type: str = "day_recap",
for_date: date | None = None,
api_key: str | None = None,
) -> dict[str, Any]:
"""Generate an AI summary. Returns dict with 'title', 'content', 'date'."""
import anthropic
d = for_date or date.today()
key = api_key or os.environ.get("ANTHROPIC_API_KEY", "")
if not key:
return {
"title": "Error",
"content": "ANTHROPIC_API_KEY not set. Add it to your .env file.",
"date": str(d),
}
spec = SUMMARY_TYPES.get(summary_type)
if not spec:
return {"title": "Error", "content": f"Unknown summary type: {summary_type}", "date": str(d)}
stats = summary_stats(d)
if stats["total_frames"] == 0:
return {
"title": spec["title"],
"content": f"No screen data found for {d}.",
"date": str(d),
}
ctx = _build_context(d)
prompt = spec["prompt"].format(**ctx)
client = anthropic.Anthropic(api_key=key)
message = client.messages.create(
model="claude-haiku-4-5-20251001",
max_tokens=1024,
messages=[{"role": "user", "content": prompt}],
)
return {
"title": spec["title"],
"content": message.content[0].text,
"date": str(d),
"stats": stats,
}
Thinking
Thinking
Bash
Read all pipe.md files
IN
for f in /volume1/screenpipe/pipes/*/pipe.md; do echo "=== $f ==="; cat "$f"; echo; done
Copy code to clipboard
OUT
=== /volume1/screenpipe/pipes/ai-habits/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: AI Habits
description: "How you use AI tools — patterns and insights"
icon: "🤖"
featured: true
---
Search my recordings from the last 24 hours for AI tool usage. Use app_name filter for each tool separately: ChatGPT, Claude, Copilot, Cursor, Gemini, Perplexity. Use limit=5 per search, max 6 searches total.
Read screenpipe skill first.
Use this exact format:
## AI Tools Used
- List each tool with approximate time spent (e.g. "Claude: ~45min")
## What I Used Them For
- For each tool: coding, writing, research, or brainstorming
## Usage Patterns
- Do I switch between tools? Use them in bursts or steadily?
## Effectiveness
- Which tool appeared alongside completed work vs. abandoned attempts
If no AI usage is found, say so clearly. End with: "**Tip:** [one suggestion to use AI tools more effectively]"
=== /volume1/screenpipe/pipes/day-recap/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Day Recap
description: "Today's accomplishments, key moments, and unfinished work"
icon: "📋"
featured: true
---
Analyze my screen and audio recordings from today (last 16 hours only).
Read screenpipe skill first.
Use this exact format:
## Summary
One sentence: what I mainly did today.
## Accomplishments
- Top 3 things I finished, with timestamps (e.g. "2:30 PM")
- Name specific apps, files, or projects
## Key Moments
- Important things I saw, said, or heard — with timestamps
## Unfinished Work
- What I should continue tomorrow — name the app/file/task
## Patterns
- Apps I used most, topics that came up repeatedly
Only report what you can verify from the data. End with: "**Next step:** [most important thing to continue]"
=== /volume1/screenpipe/pipes/meeting-summary/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Meeting Summary
description: "Summarize meeting transcript with key takeaways and action items"
icon: "🤝"
featured: false
---
Summarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.
Read screenpipe skill first.
Use this exact format:
## Meeting Summary
One sentence: what this meeting was about.
## Key Takeaways
- Top 3-5 important points discussed
- Include who said what when relevant
## Action Items
- [ ] Task — assigned to whom, deadline if mentioned
- [ ] Task — assigned to whom
## Decisions Made
- List any decisions or agreements reached
## Open Questions
- Anything unresolved or needing follow-up
Keep it concise and actionable.
=== /volume1/screenpipe/pipes/standup-update/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Standup Update
description: "What you did, what's next, and any blockers"
icon: "🏢"
featured: true
---
Based on my recordings from the last 24 hours, generate a standup update. Use limit=10 per search, max 3 searches total.
Read screenpipe skill first.
Use this exact format:
## Yesterday
- What I worked on (name specific projects, files, tools, PRs)
## Today
- What I will work on next (based on unfinished tasks and recent activity)
## Blockers
- Issues I hit — errors, slow builds, waiting on someone
- If no blockers, write "None"
Keep it under 150 words. Copy-paste ready for a team standup.
=== /volume1/screenpipe/pipes/time-breakdown/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Time Breakdown
description: "Where your time went — by app, project, and category"
icon: "⏱"
featured: false
---
Analyze my app usage from today (last 12 hours). Use limit=10 per search, max 4 searches. Prefer /raw_sql with COUNT/GROUP BY queries.
Read screenpipe skill first.
Use this exact format with durations and percentages:
## By Application
- List each app with duration and percentage, sorted by time (e.g. "VS Code: 2h 15min (28%)")
## By Category
- Group into: coding, meetings, browsing, writing, communication, other
- Show hours and percentage per category
## By Project
- Group related activities by project/topic. Name specific repos or tasks.
## Productivity Score
- Calculate: focused_work_hours / total_hours as a percentage
- Focused = coding + writing. Unfocused = browsing + switching.
End with: "**Suggestion:** [one specific change to improve tomorrow's productivity]"
=== /volume1/screenpipe/pipes/video-export/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Export Video Clip
description: "Create a video of your recent screen activity"
icon: "🎬"
featured: false
---
Export a video of my screen activity from the last 5 minutes.
Read screenpipe skill first.
Use the POST /frames/export endpoint with the time range and fps=1.0. Then show me the exported video file path as an inline code block so I can watch it.
If the export is large, suggest a lower fps or shorter time range.
Thinking
Thinking
Now I have a clear picture. The pipes are markdown prompt templates in
/volume1/screenpipe/pipes/
, but there's no code to actually load and run them —
consumers/summary.py
has its own hardcoded prompts instead.
Here's what I'll implement:
consumers/pipes.py
— dynamically loads pipe.md files and runs them via Claude (data injected as system message, pipe body as user prompt)
main.py
— two new endpoints:
GET /api/pipes
and
POST /api/pipes/{pipe_id}/run
cli.py
— a
pipe
command to run pipes from the terminal
Let me build it:
Bash
Check browser_urls signature
IN
cat /volume1/screenpipe/app/consumers/activity.py | grep "def browser_urls" -A 5
Copy code to clipboard
OUT
def browser_urls(
for_date: date | None = None,
app_name: str | None = None,
ts_from: str | None = None,
ts_to: str | None = None,
limit: int = 30,
Write
pipes.py
pipes.py
143 lines
"""Dynamic pipe loader and runner."""
import os
import re
from datetime import date
from pathlib import Path
from typing import Any
def _parse_frontmatter(text: str) -> tuple[dict, str]:
if not text.startswith("---"):
return {}, text
try:
end = text.index("---", 3)
except ValueError:
return {}, text
fm_text = text[3:end].strip()
body = text[end + 3:].strip()
meta: dict = {}
for line in fm_text.splitlines():
if ":" in line:
k, _, v = line.partition(":")
meta[k.strip()] = v.strip().strip('"')
return meta, body
def load_pipes(pipes_dir: Path) -> list[dict]:
if not pipes_dir.exists():
return []
pipes = []
for pipe_dir in sorted(pipes_dir.iterdir()):
if not pipe_dir.is_dir() or pipe_dir.name.startswith("."):
continue
pipe_md = pipe_dir / "pipe.md"
if not pipe_md.exists():
continue
text = pipe_md.read_text(encoding="utf-8")
meta, body = _parse_frontmatter(text)
if meta.get("enabled", "true").lower() == "false":
continue
body = re.sub(r"Read screenpipe skill first\.?\n?", "", body).strip()
pipes.append({
"id": pipe_dir.name,
"title": meta.get("title", pipe_dir.name),
"description": meta.get("description", ""),
"icon": meta.get("icon", ""),
"schedule": meta.get("schedule", "manual"),
"featured": meta.get("featured", "false").lower() == "true",
"prompt": body,
})
return pipes
def _build_system(d: date, stats: dict) -> str:
from consumers.activity import app_time, browser_urls, ui_event_summary
from consumers.ocr import deduplicated_text
from consumers.audio import formatted_transcript
apps = app_time(d)
app_lines = "\n".join(f"- {a['app_name']}: {a['minutes']} min" for a in apps[:20])
urls = browser_urls(d, limit=20)
url_lines = "\n".join(f"- {u['browser_url'][:100]} ({u['minutes']} min)" for u in urls)
ui_rows = ui_event_summary(d)
ui_lines = "\n".join(
f"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches"
for r in ui_rows[:15]
)
ocr_rows = deduplicated_text(d, chunk_minutes=5)
ocr_lines = "\n".join(
f"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}"
for r in ocr_rows[:100]
)
audio = formatted_transcript(d)
if len(audio) > 3000:
audio = audio[:3000]
return f"""You are analyzing screenpipe data — recordings of a person's computer activity.
## App usage (minutes per app):
{app_lines or '(no app data)'}
## Browser URLs visited:
{url_lines or '(no browser data)'}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_lines or '(no UI event data)'}
## Screen content (sampled every 5 minutes):
{ocr_lines or '(no screen data)'}
## Audio / speech:
{audio or '(no audio data)'}
Date: {d}
Total frames recorded: {stats['total_frames']}"""
def run_pipe(
pipe_id: str,
for_date: date | None = None,
api_key: str | None = None,
pipes_dir: Path | None = None,
) -> dict[str, Any]:
import anthropic
from consumers.activity import summary_stats
d = for_date or date.today()
key = api_key or os.environ.get("ANTHROPIC_API_KEY", "")
if not key:
return {"title": "Error", "content": "ANTHROPIC_API_KEY not set.", "date": str(d)}
_pipes_dir = pipes_dir or Path(os.environ.get("PIPES_DIR", "/data/pipes"))
all_pipes = {p["id"]: p for p in load_pipes(_pipes_dir)}
if pipe_id not in all_pipes:
return {"title": "Error", "content": f"Pipe not found: {pipe_id}", "date": str(d)}
pipe = all_pipes[pipe_id]
stats = summary_stats(d)
if stats["total_frames"] == 0:
return {"title": pipe["title"], "content": f"No screen data found for {d}.", "date": str(d)}
system = _build_system(d, stats)
client = anthropic.Anthropic(api_key=key)
message = client.messages.create(
model="claude-haiku-4-5-20251001",
max_tokens=1024,
system=system,
messages=[{"role": "user", "content": pipe["prompt"]}],
)
return {
"title": pipe["title"],
"content": message.content[0].text,
"date": str(d),
"stats": stats,
}
Now add the API endpoints to
main.py
:
Edit
main.py
main.py
Added 1 line
Edit
main.py
main.py
Added 1 line
Now add the pipe endpoints at the end of main.py, before the closing summary section:
Edit
main.py
main.py
Added 14 lines...
|
[{"role":"AXRadioButton","text [{"role":"AXRadioButton","text":"Explorer (⇧⌘E)","depth":19,"bounds":{"left":0.0,"top":0.047885075,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":true},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.057462092,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Search (⇧⌘F)","depth":19,"bounds":{"left":0.0,"top":0.08619314,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.09577015,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Source Control (⌃⇧G) - 10 pending changes","depth":19,"bounds":{"left":0.0,"top":0.1245012,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.13407822,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"10","depth":22,"bounds":{"left":0.00831117,"top":0.1452514,"width":0.003656915,"height":0.008778931},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.00831117,"top":0.14604948,"width":0.0016622341,"height":0.007980846}},{"char_start":1,"char_count":1,"bounds":{"left":0.009973404,"top":0.14604948,"width":0.0023271276,"height":0.007980846}}],"role_description":"text"},{"role":"AXRadioButton","text":"Run and Debug (⇧⌘D)","depth":19,"bounds":{"left":0.0,"top":0.16280925,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.17238627,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Remote Explorer","depth":19,"bounds":{"left":0.0,"top":0.20111732,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.21069433,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Extensions (⇧⌘X) - 2 require update","depth":19,"bounds":{"left":0.0,"top":0.23942538,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.2490024,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"2","depth":22,"bounds":{"left":0.009640957,"top":0.2601756,"width":0.0019946808,"height":0.008778931},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Claude Code","depth":19,"bounds":{"left":0.0,"top":0.27773345,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"Containers","depth":19,"bounds":{"left":0.0,"top":0.3160415,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXHeading","text":"EXPLORER","depth":17,"bounds":{"left":0.022606382,"top":0.047885075,"width":0.018949468,"height":0.02793296},"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"EXPLORER","depth":18,"bounds":{"left":0.022606382,"top":0.056664005,"width":0.018949468,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.022606382,"top":0.056664005,"width":0.0023271276,"height":0.0103751}},{"char_start":1,"char_count":7,"bounds":{"left":0.024933511,"top":0.056664005,"width":0.01662234,"height":0.0103751}}],"role_description":"text"},{"role":"AXButton","text":"Explorer Section: screenpipe [SSH: nas]","depth":21,"bounds":{"left":0.015957447,"top":0.07581804,"width":0.09940159,"height":0.017557861},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":true},{"role":"AXStaticText","text":"","depth":23,"bounds":{"left":0.01662234,"top":0.07821229,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"Explorer Section: screenpipe [SSH: nas]","depth":22,"bounds":{"left":0.022606382,"top":0.07581804,"width":0.045877658,"height":0.017557861},"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"SCREENPIPE [SSH: NAS]","depth":23,"bounds":{"left":0.022606382,"top":0.079010375,"width":0.045877658,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.022606382,"top":0.07980846,"width":0.0026595744,"height":0.0103751}},{"char_start":1,"char_count":20,"bounds":{"left":0.025265958,"top":0.07980846,"width":0.043218084,"height":0.0103751}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.09577015,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"#recycle","depth":27,"bounds":{"left":0.025930852,"top":0.09577015,"width":0.017287234,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.096568234,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":7,"bounds":{"left":0.028590426,"top":0.096568234,"width":0.01462766,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.11332801,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"app","depth":27,"bounds":{"left":0.025930852,"top":0.11332801,"width":0.0076462766,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.11412609,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":2,"bounds":{"left":0.02825798,"top":0.11412609,"width":0.005319149,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.11412609,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.022273935,"top":0.13088587,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"__pycache__","depth":27,"bounds":{"left":0.028590426,"top":0.13088587,"width":0.026595745,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.13168396,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":10,"bounds":{"left":0.030917553,"top":0.13168396,"width":0.024268618,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.022273935,"top":0.14844373,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"consumers","depth":27,"bounds":{"left":0.028590426,"top":0.14844373,"width":0.022273935,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.14924182,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":8,"bounds":{"left":0.030917553,"top":0.14924182,"width":0.019946808,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.14924182,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.022273935,"top":0.1660016,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"static","depth":27,"bounds":{"left":0.028590426,"top":0.1660016,"width":0.010970744,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.16679968,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":5,"bounds":{"left":0.030917553,"top":0.16679968,"width":0.008976064,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.16679968,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.1819633,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":".env","depth":27,"bounds":{"left":0.028590426,"top":0.18355946,"width":0.00831117,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.18435754,"width":0.0013297872,"height":0.011971269}},{"char_start":1,"char_count":3,"bounds":{"left":0.029920213,"top":0.18435754,"width":0.006981383,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.19952115,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"cli.py","depth":27,"bounds":{"left":0.028590426,"top":0.20111732,"width":0.010638298,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.2019154,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":5,"bounds":{"left":0.030917553,"top":0.2019154,"width":0.00831117,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.2019154,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.21707901,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.py","depth":27,"bounds":{"left":0.028590426,"top":0.21867518,"width":0.011303191,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.21947326,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":4,"bounds":{"left":0.03125,"top":0.21947326,"width":0.008643617,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.23463687,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"docker-compose.yml","depth":27,"bounds":{"left":0.028590426,"top":0.23623304,"width":0.042220745,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.23703113,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":17,"bounds":{"left":0.03125,"top":0.23703113,"width":0.03956117,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.25219473,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Dockerfile","depth":27,"bounds":{"left":0.028590426,"top":0.25379092,"width":0.020611702,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.254589,"width":0.0033244682,"height":0.011971269}},{"char_start":1,"char_count":9,"bounds":{"left":0.031914894,"top":0.254589,"width":0.017287234,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.254589,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.2697526,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"main.py","depth":27,"bounds":{"left":0.028590426,"top":0.27134877,"width":0.015625,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.27214685,"width":0.003656915,"height":0.011971269}},{"char_start":1,"char_count":6,"bounds":{"left":0.032247342,"top":0.27214685,"width":0.012300532,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.27214685,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.28731045,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"requirements.txt","depth":27,"bounds":{"left":0.028590426,"top":0.28890663,"width":0.032912236,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.2897047,"width":0.0016622341,"height":0.011971269}},{"char_start":1,"char_count":15,"bounds":{"left":0.03025266,"top":0.2897047,"width":0.03158245,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.2897047,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.3064645,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"data","depth":27,"bounds":{"left":0.025930852,"top":0.3064645,"width":0.008976064,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.30726257,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":3,"bounds":{"left":0.028590426,"top":0.30726257,"width":0.0063164895,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.32402235,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"logs","depth":27,"bounds":{"left":0.025930852,"top":0.32402235,"width":0.00831117,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.32482043,"width":0.0009973404,"height":0.011971269}},{"char_start":1,"char_count":3,"bounds":{"left":0.026928192,"top":0.32482043,"width":0.0076462766,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.32482043,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.3415802,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"pipes","depth":27,"bounds":{"left":0.025930852,"top":0.3415802,"width":0.010970744,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.3423783,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":4,"bounds":{"left":0.028590426,"top":0.3423783,"width":0.00831117,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.3575419,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":".gitignore","depth":27,"bounds":{"left":0.025930852,"top":0.35913807,"width":0.018949468,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.35993615,"width":0.0013297872,"height":0.011971269}},{"char_start":1,"char_count":9,"bounds":{"left":0.027260639,"top":0.35993615,"width":0.017952127,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.37509975,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"app_settings.json","depth":27,"bounds":{"left":0.025930852,"top":0.37669593,"width":0.03557181,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.377494,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":16,"bounds":{"left":0.02825798,"top":0.377494,"width":0.03324468,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.3926576,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"archive.db","depth":27,"bounds":{"left":0.025930852,"top":0.3942538,"width":0.020944148,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.39505187,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":9,"bounds":{"left":0.02825798,"top":0.39505187,"width":0.01861702,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.4102155,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"archive.db-bak","depth":27,"bounds":{"left":0.025930852,"top":0.41181165,"width":0.03025266,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.41260973,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":13,"bounds":{"left":0.02825798,"top":0.41260973,"width":0.027925532,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"U","depth":27,"bounds":{"left":0.10704787,"top":0.41260973,"width":0.0029920214,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.42777336,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite","depth":27,"bounds":{"left":0.025930852,"top":0.4293695,"width":0.017287234,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.4301676,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":8,"bounds":{"left":0.028590426,"top":0.4301676,"width":0.014960106,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.44533122,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite-shm","depth":27,"bounds":{"left":0.025930852,"top":0.44692737,"width":0.027925532,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.44772545,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":12,"bounds":{"left":0.028590426,"top":0.44772545,"width":0.025265958,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.46288908,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite-wal","depth":27,"bounds":{"left":0.025930852,"top":0.46448523,"width":0.025930852,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.46528333,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":12,"bounds":{"left":0.028590426,"top":0.46528333,"width":0.023603724,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.48044693,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe_sync_updated.sh","depth":27,"bounds":{"left":0.025930852,"top":0.4820431,"width":0.059175532,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.4828412,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":25,"bounds":{"left":0.02825798,"top":0.4828412,"width":0.056848403,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"U","depth":27,"bounds":{"left":0.10704787,"top":0.4828412,"width":0.0029920214,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.4980048,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe_sync.sh","depth":27,"bounds":{"left":0.025930852,"top":0.49960095,"width":0.039893616,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.50039905,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":17,"bounds":{"left":0.02825798,"top":0.50039905,"width":0.037898935,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.51556265,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe.db","depth":27,"bounds":{"left":0.025930852,"top":0.5171588,"width":0.028590426,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.5179569,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":12,"bounds":{"left":0.02825798,"top":0.5179569,"width":0.026595745,"height":0.011971269}}],"role_description":"text"},{"role":"AXButton","text":"Outline Section","depth":21,"bounds":{"left":0.015957447,"top":0.9473264,"width":0.09940159,"height":0.017557861},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":23,"bounds":{"left":0.01662234,"top":0.9497207,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"OUTLINE","depth":22,"bounds":{"left":0.022606382,"top":0.9473264,"width":0.01662234,"height":0.017557861},"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"OUTLINE","depth":23,"bounds":{"left":0.022606382,"top":0.95131683,"width":0.01662234,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.022606382,"top":0.95131683,"width":0.0029920214,"height":0.0103751}},{"char_start":1,"char_count":6,"bounds":{"left":0.025598405,"top":0.95131683,"width":0.013630319,"height":0.0103751}}],"role_description":"text"},{"role":"AXButton","text":"Timeline Section","depth":21,"bounds":{"left":0.015957447,"top":0.9648843,"width":0.09940159,"height":0.017557861},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":23,"bounds":{"left":0.01662234,"top":0.96727854,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"TIMELINE","depth":22,"bounds":{"left":0.022606382,"top":0.9648843,"width":0.01761968,"height":0.017557861},"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"TIMELINE","depth":23,"bounds":{"left":0.022606382,"top":0.9688747,"width":0.01761968,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.022606382,"top":0.9688747,"width":0.0026595744,"height":0.0103751}},{"char_start":1,"char_count":7,"bounds":{"left":0.025265958,"top":0.9688747,"width":0.015292553,"height":0.0103751}}],"role_description":"text"},{"role":"AXRadioButton","text":"app_settings.json, Editor Group 1","depth":28,"bounds":{"left":0.11569149,"top":0.047885075,"width":0.055851065,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"screenpipe_sync.sh, Editor Group 1","depth":28,"bounds":{"left":0.17154256,"top":0.047885075,"width":0.06050532,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"pipe.md, Editor Group 1","depth":28,"bounds":{"left":0.23171543,"top":0.047885075,"width":0.040226065,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":".env, Editor Group 1","depth":28,"bounds":{"left":0.27194148,"top":0.047885075,"width":0.039893616,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":false},{"role":"AXStaticText","text":"","depth":29,"bounds":{"left":0.12832446,"top":0.07821229,"width":0.0056515955,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXTextArea","text":"ANTHROPIC_API_KEY=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","depth":28,"bounds":{"left":0.13763298,"top":0.10774142,"width":0.30285904,"height":0.014365523},"on_screen":true,"value":"ANTHROPIC_API_KEY=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","role_description":"editor","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"ANTHROPIC_API_KEY=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","depth":29,"bounds":{"left":0.13763298,"top":0.09497207,"width":0.30285904,"height":0.011173184},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.13763298,"top":0.09497207,"width":0.0023271276,"height":0.011173184}},{"char_start":1,"char_count":125,"bounds":{"left":0.13996011,"top":0.09497207,"width":0.30053192,"height":0.011173184}}],"role_description":"text"},{"role":"AXRadioButton","text":"Implement and run pipe l…, Editor Group 2","depth":28,"bounds":{"left":0.5578458,"top":0.047885075,"width":0.073803194,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":false},{"role":"AXRadioButton","text":"Problems (⇧⌘M)","depth":22,"bounds":{"left":0.118351065,"top":0.7278532,"width":0.027925532,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"PROBLEMS","depth":24,"bounds":{"left":0.122340426,"top":0.7366321,"width":0.019946808,"height":0.0103751},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Output (⇧⌘U)","depth":22,"bounds":{"left":0.14594415,"top":0.7278532,"width":0.023603724,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUTPUT","depth":24,"bounds":{"left":0.14993352,"top":0.7366321,"width":0.015625,"height":0.0103751},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Debug Console (⇧⌘Y)","depth":22,"bounds":{"left":0.16921543,"top":0.7278532,"width":0.039893616,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"DEBUG CONSOLE","depth":24,"bounds":{"left":0.1732048,"top":0.7366321,"width":0.031914894,"height":0.0103751},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Terminal (⌃`)","depth":22,"bounds":{"left":0.2087766,"top":0.7278532,"width":0.026595745,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":true},{"role":"AXStaticText","text":"TERMINAL","depth":24,"bounds":{"left":0.21276596,"top":0.7366321,"width":0.01861702,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.2130984,"top":0.73743016,"width":0.0023271276,"height":0.0103751}},{"char_start":1,"char_count":7,"bounds":{"left":0.21542554,"top":0.73743016,"width":0.016289894,"height":0.0103751}}],"role_description":"text"},{"role":"AXRadioButton","text":"Ports - 1 forwarded port","depth":22,"bounds":{"left":0.23537233,"top":0.7278532,"width":0.026263298,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"PORTS","depth":24,"bounds":{"left":0.2393617,"top":0.7366321,"width":0.012300532,"height":0.0103751},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":25,"bounds":{"left":0.25465426,"top":0.73743016,"width":0.0019946808,"height":0.008778931},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"remote SSH: nas","depth":16,"bounds":{"left":0.0006648936,"top":0.98244214,"width":0.028590426,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.0033244682,"top":0.9848364,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"SSH: nas","depth":17,"bounds":{"left":0.008643617,"top":0.9856345,"width":0.017952127,"height":0.011173184},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.008643617,"top":0.9856345,"width":0.0013297872,"height":0.011173184}},{"char_start":1,"char_count":7,"bounds":{"left":0.009973404,"top":0.9856345,"width":0.01462766,"height":0.011173184}}],"role_description":"text"},{"role":"AXButton","text":"screenpipe (Git) - master*, Checkout Branch/Tag...","depth":16,"bounds":{"left":0.030917553,"top":0.98244214,"width":0.023271276,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.031914894,"top":0.9848364,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"master*","depth":17,"bounds":{"left":0.03723404,"top":0.9856345,"width":0.015957447,"height":0.011173184},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.03723404,"top":0.9856345,"width":0.0013297872,"height":0.011173184}},{"char_start":1,"char_count":6,"bounds":{"left":0.03856383,"top":0.9856345,"width":0.012965426,"height":0.011173184}}],"role_description":"text"},{"role":"AXButton","text":"screenpipe (Git) - Synchronize Changes","depth":16,"bounds":{"left":0.05418883,"top":0.98244214,"width":0.00731383,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"No Problems","depth":16,"bounds":{"left":0.06416223,"top":0.98244214,"width":0.022606382,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.06582447,"top":0.9848364,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"0","depth":17,"bounds":{"left":0.07114362,"top":0.9856345,"width":0.004986702,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.07579787,"top":0.9848364,"width":0.0056515955,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"0","depth":17,"bounds":{"left":0.08111702,"top":0.9856345,"width":0.0039893617,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Forwarded Ports: 8766","depth":16,"bounds":{"left":0.08843085,"top":0.98244214,"width":0.012632979,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.09009308,"top":0.9848364,"width":0.0056515955,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":17,"bounds":{"left":0.09541223,"top":0.9856345,"width":0.0039893617,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Notifications","depth":16,"bounds":{"left":0.9886968,"top":0.98244214,"width":0.010638298,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sign In","depth":16,"bounds":{"left":0.9650931,"top":0.98244214,"width":0.022606382,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.96675533,"top":0.9848364,"width":0.0056515955,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Sign In","depth":17,"bounds":{"left":0.97207445,"top":0.9856345,"width":0.013962766,"height":0.011173184},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.97207445,"top":0.9856345,"width":0.0013297872,"height":0.011173184}},{"char_start":1,"char_count":6,"bounds":{"left":0.9734042,"top":0.9856345,"width":0.010638298,"height":0.011173184}}],"role_description":"text"},{"role":"AXStaticText","text":"Info: Setting up SSH Host nas: Setting up SSH tunnel","depth":12,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Implement and run pipe logic","depth":19,"bounds":{"left":0.56017286,"top":0.08060654,"width":0.07114362,"height":0.022346368},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Session history","depth":19,"bounds":{"left":0.9780585,"top":0.08060654,"width":0.00930851,"height":0.022346368},"on_screen":true,"help_text":"Session history","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"New session","depth":19,"bounds":{"left":0.9886968,"top":0.08060654,"width":0.00930851,"height":0.022346368},"on_screen":true,"help_text":"New session","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Message actions","depth":24,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"main.py","depth":23,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"lets implement logic with pipes. how can I run it?","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Let me look at the current project structure to understand what's already in place.","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"List project files","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"find /volume1/screenpipe -type f | head -50 && echo \"---\" && ls /volume1/screenpipe","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"/volume1/screenpipe/.DS_Store\n/volume1/screenpipe/screenpipe.db\n/volume1/screenpipe/screenpipe_sync.sh\n/volume1/screenpipe/app_settings.json\n/volume1/screenpipe/.gitignore\n/volume1/screenpipe/archive.db\n/volume1/screenpipe/db.sqlite\n/volume1/screenpipe/db.sqlite-wal\n/volume1/screenpipe/db.sqlite-shm\n/volume1/screenpipe/#recycle/desktop.ini\n/volume1/screenpipe/#recycle/db.sqlite\n/volume1/screenpipe/#recycle/Copy #1 of db.sqlite\n/volume1/screenpipe/#recycle/.DS_Store\n/volume1/screenpipe/#recycle/Copy #2 of db.sqlite\n/volume1/screenpipe/#recycle/archive.db\n/volume1/screenpipe/#recycle/Copy #1 of archive.db\n/volume1/screenpipe/#recycle/Copy #2 of archive.db\n/volume1/screenpipe/#recycle/Copy #3 of archive.db\n/volume1/screenpipe/#recycle/Copy #4 of archive.db\n/volume1/screenpipe/#recycle/Copy #5 of archive.db\n/volume1/screenpipe/#recycle/Copy #3 of db.sqlite\n/volume1/screenpipe/#recycle/Copy #4 of db.sqlite\n/volume1/screenpipe/#recycle/Copy #6 of archive.db\n/volume1/screenpipe/#recycle/test.txt\n/volume1/screenpipe/#recycle/Copy #7 of archive.db\n/volume1/screenpipe/#recycle/Copy #8 of archive.db\n/volume1/screenpipe/#recycle/archive.db-journal\n/volume1/screenpipe/#recycle/Copy #1 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #2 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #3 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #4 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #5 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #6 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #7 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #5 of db.sqlite\n/volume1/screenpipe/pipes/.DS_Store\n/volume1/screenpipe/app/.env\n/volume1/screenpipe/app/cli.py\n/volume1/screenpipe/app/.DS_Store\n/volume1/screenpipe/app/db.py\n/volume1/screenpipe/app/docker-compose.yml\n/volume1/screenpipe/app/main.py\n/volume1/screenpipe/app/requirements.txt\n/volume1/screenpipe/app/Dockerfile\n/volume1/screenpipe/data/.DS_Store\n/volume1/screenpipe/.git/description\n/volume1/screenpipe/.git/HEAD\n/volume1/screenpipe/.git/index\n/volume1/screenpipe/.git/COMMIT_EDITMSG\n/volume1/screenpipe/#recycle/data/.DS_Store\n---\napp\napp_settings.json\narchive.db\ndata\ndb.sqlite\ndb.sqlite-shm\ndb.sqlite-wal\npipes\n#recycle\nscreenpipe.db\nscreenpipe_sync.sh","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"main.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Check pipes directory and docker-compose","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/pipes/ && ls /volume1/screenpipe/app/ && cat /volume1/screenpipe/app/docker-compose.yml","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ai-habits\nday-recap\nmeeting-summary\nstandup-update\ntime-breakdown\nvideo-export\ncli.py\nconsumers\ndb.py\ndocker-compose.yml\nDockerfile\nmain.py\n__pycache__\nrequirements.txt\nstatic\nservices:\n screenpipe-app:\n build: .\n container_name: screenpipe-app\n restart: unless-stopped\n ports:\n - \"8766:8000\"\n volumes:\n - /volume1/screenpipe:/data\n env_file:\n - .env\n environment:\n TZ: Europe/Sofia\n DB_PATH: /data/db.sqlite\n\n sqlite-web-archive:\n image: ghcr.io/coleifer/sqlite-web:latest\n container_name: screenpipe-sqlweb-archive\n restart: unless-stopped\n ports:\n - \"8767:8080\"\n volumes:\n - /volume1/screenpipe:/data\n command: [\"-H\", \"0.0.0.0\", \"-r\", \"/data/archive.db\"]\n\n sqlite-web-live:\n image: ghcr.io/coleifer/sqlite-web:latest\n container_name: screenpipe-sqlweb-live\n restart: unless-stopped\n ports:\n - \"8768:8080\"\n volumes:\n - /volume1/screenpipe:/data\n command: [\"-H\", \"0.0.0.0\", \"-r\", \"/data/db.sqlite\"]","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"requirements.txt","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"requirements.txt","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Inspect a pipe directory","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/pipes/day-recap/ && cat /volume1/screenpipe/pipes/day-recap/pipe.json 2>/dev/null || ls /volume1/screenpipe/pipes/day-recap/","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"pipe.md\npipe.md","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"cli.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"cli.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"List all pipes and their contents","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/pipes/ && for d in /volume1/screenpipe/pipes/*/; do echo \"=== $d ===\"; ls \"$d\"; done","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ai-habits\nday-recap\nmeeting-summary\nstandup-update\ntime-breakdown\nvideo-export\n=== /volume1/screenpipe/pipes/ai-habits/ ===\npipe.md\n=== /volume1/screenpipe/pipes/day-recap/ ===\npipe.md\n=== /volume1/screenpipe/pipes/meeting-summary/ ===\npipe.md\n=== /volume1/screenpipe/pipes/standup-update/ ===\npipe.md\n=== /volume1/screenpipe/pipes/time-breakdown/ ===\npipe.md\n=== /volume1/screenpipe/pipes/video-export/ ===\npipe.md","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read pipe markdown files","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"cat /volume1/screenpipe/pipes/day-recap/pipe.md && echo \"===\" && cat /volume1/screenpipe/pipes/meeting-summary/pipe.md 2>/dev/null | head -50","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Day Recap\ndescription: \"Today's accomplishments, key moments, and unfinished work\"\nicon: \"📋\"\nfeatured: true\n---\n\nAnalyze my screen and audio recordings from today (last 16 hours only). \n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Summary\nOne sentence: what I mainly did today.\n\n## Accomplishments\n- Top 3 things I finished, with timestamps (e.g. \"2:30 PM\")\n- Name specific apps, files, or projects\n\n## Key Moments\n- Important things I saw, said, or heard — with timestamps\n\n## Unfinished Work\n- What I should continue tomorrow — name the app/file/task\n\n## Patterns\n- Apps I used most, topics that came up repeatedly\n\nOnly report what you can verify from the data. End with: \"**Next step:** [most important thing to continue]\"\n===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Meeting Summary\ndescription: \"Summarize meeting transcript with key takeaways and action items\"\nicon: \"🤝\"\nfeatured: false\n---\n\nSummarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.\n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Meeting Summary\nOne sentence: what this meeting was about.\n\n## Key Takeaways\n- Top 3-5 important points discussed\n- Include who said what when relevant\n\n## Action Items\n- [ ] Task — assigned to whom, deadline if mentioned\n- [ ] Task — assigned to whom\n\n## Decisions Made\n- List any decisions or agreements reached\n\n## Open Questions\n- Anything unresolved or needing follow-up\n\nKeep it concise and actionable.","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read summary consumer","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/app/consumers/ && cat /volume1/screenpipe/app/consumers/summary.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"activity.py\naudio.py\nelements.py\n__init__.py\ninteractions.py\nocr.py\n__pycache__\nreport.py\nsummary.py\n\"\"\"AI summary generator using Claude.\"\"\"\nimport os\nfrom datetime import date\nfrom typing import Any\n\nfrom consumers.activity import app_time, summary_stats, browser_urls, ui_event_summary\nfrom consumers.ocr import deduplicated_text\nfrom consumers.audio import formatted_transcript\n\n\nSUMMARY_TYPES = {\n \"day_recap\": {\n \"title\": \"Day Recap\",\n \"prompt\": \"\"\"\\\nYou are analyzing a person's computer activity for the day.\n\n## App usage (minutes per app):\n{app_time}\n\n## Browser URLs visited:\n{browser_urls}\n\n## UI activity per app (clicks / keystrokes / app-switches):\n{ui_events}\n\n## Screen content (sampled every 5 minutes):\n{ocr_text}\n\n## Audio/speech:\n{audio}\n\nWrite a concise day recap using EXACTLY this format:\n\n## Summary\nOne sentence: what I mainly worked on today.\n\n## Accomplishments\n- Top 3 things I finished, with approximate times\n- Name specific apps, files, or projects\n\n## Key Moments\n- Important things seen or heard, with timestamps\n\n## Unfinished Work\n- What to continue tomorrow\n\n## Patterns\n- Apps used most, topics that came up repeatedly\n\nOnly report what you can verify from the data. End with:\n**Next step:** [most important thing to continue]\"\"\",\n },\n \"standup\": {\n \"title\": \"Standup Update\",\n \"prompt\": \"\"\"\\\nYou are analyzing a person's computer activity for the day.\n\n## App usage (minutes per app):\n{app_time}\n\n## Browser URLs visited:\n{browser_urls}\n\n## UI activity per app (clicks / keystrokes / app-switches):\n{ui_events}\n\n## Screen content (sampled every 5 minutes):\n{ocr_text}\n\n## Audio/speech:\n{audio}\n\nWrite a brief standup update:\n\n**Yesterday:** What I worked on (2-3 bullets)\n**Today:** What I plan to continue (1-2 bullets)\n**Blockers:** Any issues observed (or \"None\")\n\nKeep it under 150 words. Only report what's verifiable from the data.\"\"\",\n },\n \"focus_time\": {\n \"title\": \"Focus & Distraction Analysis\",\n \"prompt\": \"\"\"\\\nYou are analyzing a person's computer activity for the day.\n\n## App usage (minutes per app):\n{app_time}\n\n## Browser URLs visited:\n{browser_urls}\n\n## UI activity per app (clicks / keystrokes / app-switches):\n{ui_events}\n\n## Screen content (sampled every 5 minutes):\n{ocr_text}\n\nAnalyze focus vs distraction patterns:\n\n## Deep Work Periods\n- When and how long were sustained focus sessions?\n- What was being worked on?\n\n## Distractions\n- Which apps/sites were used recreationally?\n- How much time was lost to context switching?\n\n## Recommendations\n- 2-3 concrete suggestions to improve focus tomorrow\n\nBe specific with times and app names.\"\"\",\n },\n}\n\n\ndef _build_context(for_date: date) -> dict[str, str]:\n apps = app_time(for_date)\n app_lines = \"\\n\".join(f\"- {a['app_name']}: {a['minutes']} min\" for a in apps[:20])\n\n urls = browser_urls(for_date, limit=20)\n url_lines = \"\\n\".join(\n f\"- {u['browser_url'][:100]} ({u['minutes']} min)\" for u in urls\n )\n\n ui_rows = ui_event_summary(for_date)\n ui_lines = \"\\n\".join(\n f\"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches\"\n for r in ui_rows[:15]\n )\n\n ocr_rows = deduplicated_text(for_date, chunk_minutes=5)\n ocr_lines = \"\\n\".join(\n f\"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}\"\n for r in ocr_rows[:100]\n )\n\n audio = formatted_transcript(for_date)\n\n return {\n \"app_time\": app_lines or \"(no app data)\",\n \"browser_urls\": url_lines or \"(no browser data)\",\n \"ui_events\": ui_lines or \"(no UI event data)\",\n \"ocr_text\": ocr_lines or \"(no screen data)\",\n \"audio\": audio[:3000] if len(audio) > 3000 else audio,\n }\n\n\ndef generate(\n summary_type: str = \"day_recap\",\n for_date: date | None = None,\n api_key: str | None = None,\n) -> dict[str, Any]:\n \"\"\"Generate an AI summary. Returns dict with 'title', 'content', 'date'.\"\"\"\n import anthropic\n\n d = for_date or date.today()\n key = api_key or os.environ.get(\"ANTHROPIC_API_KEY\", \"\")\n if not key:\n return {\n \"title\": \"Error\",\n \"content\": \"ANTHROPIC_API_KEY not set. Add it to your .env file.\",\n \"date\": str(d),\n }\n\n spec = SUMMARY_TYPES.get(summary_type)\n if not spec:\n return {\"title\": \"Error\", \"content\": f\"Unknown summary type: {summary_type}\", \"date\": str(d)}\n\n stats = summary_stats(d)\n if stats[\"total_frames\"] == 0:\n return {\n \"title\": spec[\"title\"],\n \"content\": f\"No screen data found for {d}.\",\n \"date\": str(d),\n }\n\n ctx = _build_context(d)\n prompt = spec[\"prompt\"].format(**ctx)\n\n client = anthropic.Anthropic(api_key=key)\n message = client.messages.create(\n model=\"claude-haiku-4-5-20251001\",\n max_tokens=1024,\n messages=[{\"role\": \"user\", \"content\": prompt}],\n )\n\n return {\n \"title\": spec[\"title\"],\n \"content\": message.content[0].text,\n \"date\": str(d),\n \"stats\": stats,\n }","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read all pipe.md files","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"for f in /volume1/screenpipe/pipes/*/pipe.md; do echo \"=== $f ===\"; cat \"$f\"; echo; done","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"=== /volume1/screenpipe/pipes/ai-habits/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: AI Habits\ndescription: \"How you use AI tools — patterns and insights\"\nicon: \"🤖\"\nfeatured: true\n---\n\nSearch my recordings from the last 24 hours for AI tool usage. Use app_name filter for each tool separately: ChatGPT, Claude, Copilot, Cursor, Gemini, Perplexity. Use limit=5 per search, max 6 searches total.\n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## AI Tools Used\n- List each tool with approximate time spent (e.g. \"Claude: ~45min\")\n\n## What I Used Them For\n- For each tool: coding, writing, research, or brainstorming\n\n## Usage Patterns\n- Do I switch between tools? Use them in bursts or steadily?\n\n## Effectiveness\n- Which tool appeared alongside completed work vs. abandoned attempts\n\nIf no AI usage is found, say so clearly. End with: \"**Tip:** [one suggestion to use AI tools more effectively]\"\n\n=== /volume1/screenpipe/pipes/day-recap/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Day Recap\ndescription: \"Today's accomplishments, key moments, and unfinished work\"\nicon: \"📋\"\nfeatured: true\n---\n\nAnalyze my screen and audio recordings from today (last 16 hours only). \n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Summary\nOne sentence: what I mainly did today.\n\n## Accomplishments\n- Top 3 things I finished, with timestamps (e.g. \"2:30 PM\")\n- Name specific apps, files, or projects\n\n## Key Moments\n- Important things I saw, said, or heard — with timestamps\n\n## Unfinished Work\n- What I should continue tomorrow — name the app/file/task\n\n## Patterns\n- Apps I used most, topics that came up repeatedly\n\nOnly report what you can verify from the data. End with: \"**Next step:** [most important thing to continue]\"\n\n=== /volume1/screenpipe/pipes/meeting-summary/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Meeting Summary\ndescription: \"Summarize meeting transcript with key takeaways and action items\"\nicon: \"🤝\"\nfeatured: false\n---\n\nSummarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.\n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Meeting Summary\nOne sentence: what this meeting was about.\n\n## Key Takeaways\n- Top 3-5 important points discussed\n- Include who said what when relevant\n\n## Action Items\n- [ ] Task — assigned to whom, deadline if mentioned\n- [ ] Task — assigned to whom\n\n## Decisions Made\n- List any decisions or agreements reached\n\n## Open Questions\n- Anything unresolved or needing follow-up\n\nKeep it concise and actionable.\n\n=== /volume1/screenpipe/pipes/standup-update/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Standup Update\ndescription: \"What you did, what's next, and any blockers\"\nicon: \"🏢\"\nfeatured: true\n---\n\nBased on my recordings from the last 24 hours, generate a standup update. Use limit=10 per search, max 3 searches total.\n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Yesterday\n- What I worked on (name specific projects, files, tools, PRs)\n\n## Today\n- What I will work on next (based on unfinished tasks and recent activity)\n\n## Blockers\n- Issues I hit — errors, slow builds, waiting on someone\n- If no blockers, write \"None\"\n\nKeep it under 150 words. Copy-paste ready for a team standup.\n\n=== /volume1/screenpipe/pipes/time-breakdown/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Time Breakdown\ndescription: \"Where your time went — by app, project, and category\"\nicon: \"⏱\"\nfeatured: false\n---\n\nAnalyze my app usage from today (last 12 hours). Use limit=10 per search, max 4 searches. Prefer /raw_sql with COUNT/GROUP BY queries.\n\nRead screenpipe skill first.\n\nUse this exact format with durations and percentages:\n\n## By Application\n- List each app with duration and percentage, sorted by time (e.g. \"VS Code: 2h 15min (28%)\")\n\n## By Category\n- Group into: coding, meetings, browsing, writing, communication, other\n- Show hours and percentage per category\n\n## By Project\n- Group related activities by project/topic. Name specific repos or tasks.\n\n## Productivity Score\n- Calculate: focused_work_hours / total_hours as a percentage\n- Focused = coding + writing. Unfocused = browsing + switching.\n\nEnd with: \"**Suggestion:** [one specific change to improve tomorrow's productivity]\"\n\n=== /volume1/screenpipe/pipes/video-export/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Export Video Clip\ndescription: \"Create a video of your recent screen activity\"\nicon: \"🎬\"\nfeatured: false\n---\n\nExport a video of my screen activity from the last 5 minutes.\n\nRead screenpipe skill first.\n\nUse the POST /frames/export endpoint with the time range and fps=1.0. Then show me the exported video file path as an inline code block so I can watch it.\n\nIf the export is large, suggest a lower fps or shorter time range.","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Now I have a clear picture. The pipes are markdown prompt templates in","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"/volume1/screenpipe/pipes/","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":", but there's no code to actually load and run them —","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"consumers/summary.py","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"has its own hardcoded prompts instead.","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Here's what I'll implement:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"consumers/pipes.py","depth":26,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"— dynamically loads pipe.md files and runs them via Claude (data injected as system message, pipe body as user prompt)","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"main.py","depth":26,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"— two new endpoints:","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"GET /api/pipes","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"and","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"POST /api/pipes/{pipe_id}/run","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"cli.py","depth":26,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"— a","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"pipe","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"command to run pipes from the terminal","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Let me build it:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Check browser_urls signature","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"cat /volume1/screenpipe/app/consumers/activity.py | grep \"def browser_urls\" -A 5","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"def browser_urls(\n for_date: date | None = None,\n app_name: str | None = None,\n ts_from: str | None = None,\n ts_to: str | None = None,\n limit: int = 30,","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Write","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"pipes.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"pipes.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"143 lines","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"\"\"\"Dynamic pipe loader and runner.\"\"\"\nimport os\nimport re\nfrom datetime import date\nfrom pathlib import Path\nfrom typing import Any\n\n\ndef _parse_frontmatter(text: str) -> tuple[dict, str]:\n if not text.startswith(\"---\"):\n return {}, text\n try:\n end = text.index(\"---\", 3)\n except ValueError:\n return {}, text\n fm_text = text[3:end].strip()\n body = text[end + 3:].strip()\n meta: dict = {}\n for line in fm_text.splitlines():\n if \":\" in line:\n k, _, v = line.partition(\":\")\n meta[k.strip()] = v.strip().strip('\"')\n return meta, body\n\n\ndef load_pipes(pipes_dir: Path) -> list[dict]:\n if not pipes_dir.exists():\n return []\n pipes = []\n for pipe_dir in sorted(pipes_dir.iterdir()):\n if not pipe_dir.is_dir() or pipe_dir.name.startswith(\".\"):\n continue\n pipe_md = pipe_dir / \"pipe.md\"\n if not pipe_md.exists():\n continue\n text = pipe_md.read_text(encoding=\"utf-8\")\n meta, body = _parse_frontmatter(text)\n if meta.get(\"enabled\", \"true\").lower() == \"false\":\n continue\n body = re.sub(r\"Read screenpipe skill first\\.?\\n?\", \"\", body).strip()\n pipes.append({\n \"id\": pipe_dir.name,\n \"title\": meta.get(\"title\", pipe_dir.name),\n \"description\": meta.get(\"description\", \"\"),\n \"icon\": meta.get(\"icon\", \"\"),\n \"schedule\": meta.get(\"schedule\", \"manual\"),\n \"featured\": meta.get(\"featured\", \"false\").lower() == \"true\",\n \"prompt\": body,\n })\n return pipes\n\n\ndef _build_system(d: date, stats: dict) -> str:\n from consumers.activity import app_time, browser_urls, ui_event_summary\n from consumers.ocr import deduplicated_text\n from consumers.audio import formatted_transcript\n\n apps = app_time(d)\n app_lines = \"\\n\".join(f\"- {a['app_name']}: {a['minutes']} min\" for a in apps[:20])\n\n urls = browser_urls(d, limit=20)\n url_lines = \"\\n\".join(f\"- {u['browser_url'][:100]} ({u['minutes']} min)\" for u in urls)\n\n ui_rows = ui_event_summary(d)\n ui_lines = \"\\n\".join(\n f\"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches\"\n for r in ui_rows[:15]\n )\n\n ocr_rows = deduplicated_text(d, chunk_minutes=5)\n ocr_lines = \"\\n\".join(\n f\"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}\"\n for r in ocr_rows[:100]\n )\n\n audio = formatted_transcript(d)\n if len(audio) > 3000:\n audio = audio[:3000]\n\n return f\"\"\"You are analyzing screenpipe data — recordings of a person's computer activity.\n\n## App usage (minutes per app):\n{app_lines or '(no app data)'}\n\n## Browser URLs visited:\n{url_lines or '(no browser data)'}\n\n## UI activity per app (clicks / keystrokes / app-switches):\n{ui_lines or '(no UI event data)'}\n\n## Screen content (sampled every 5 minutes):\n{ocr_lines or '(no screen data)'}\n\n## Audio / speech:\n{audio or '(no audio data)'}\n\nDate: {d}\nTotal frames recorded: {stats['total_frames']}\"\"\"\n\n\ndef run_pipe(\n pipe_id: str,\n for_date: date | None = None,\n api_key: str | None = None,\n pipes_dir: Path | None = None,\n) -> dict[str, Any]:\n import anthropic\n from consumers.activity import summary_stats\n\n d = for_date or date.today()\n key = api_key or os.environ.get(\"ANTHROPIC_API_KEY\", \"\")\n if not key:\n return {\"title\": \"Error\", \"content\": \"ANTHROPIC_API_KEY not set.\", \"date\": str(d)}\n\n _pipes_dir = pipes_dir or Path(os.environ.get(\"PIPES_DIR\", \"/data/pipes\"))\n all_pipes = {p[\"id\"]: p for p in load_pipes(_pipes_dir)}\n\n if pipe_id not in all_pipes:\n return {\"title\": \"Error\", \"content\": f\"Pipe not found: {pipe_id}\", \"date\": str(d)}\n\n pipe = all_pipes[pipe_id]\n stats = summary_stats(d)\n\n if stats[\"total_frames\"] == 0:\n return {\"title\": pipe[\"title\"], \"content\": f\"No screen data found for {d}.\", \"date\": str(d)}\n\n system = _build_system(d, stats)\n\n client = anthropic.Anthropic(api_key=key)\n message = client.messages.create(\n model=\"claude-haiku-4-5-20251001\",\n max_tokens=1024,\n system=system,\n messages=[{\"role\": \"user\", \"content\": pipe[\"prompt\"]}],\n )\n\n return {\n \"title\": pipe[\"title\"],\n \"content\": message.content[0].text,\n \"date\": str(d),\n \"stats\": stats,\n }","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Now add the API endpoints to","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"main.py","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":":","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Edit","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"main.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Added 1 line","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Edit","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"main.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Added 1 line","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Now add the pipe endpoints at the end of main.py, before the closing summary section:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Edit","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"main.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Added 14 lines","depth":24,"on_screen":false,"role_description":"text"}]...
|
-5020969173427241853
|
-8187034928260855700
|
idle
|
accessibility
|
NULL
|
Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧ Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py
M
db.py
docker-compose.yml
Dockerfile
M
main.py
M
requirements.txt
M
data
logs
pipes
.gitignore
app_settings.json
archive.db
archive.db-bak
U
db.sqlite
db.sqlite-shm
db.sqlite-wal
screenpipe_sync_updated.sh
U
screenpipe_sync.sh
screenpipe.db
Outline Section
OUTLINE
OUTLINE
Timeline Section
TIMELINE
TIMELINE
app_settings.json, Editor Group 1
screenpipe_sync.sh, Editor Group 1
pipe.md, Editor Group 1
.env, Editor Group 1
[ENV_SECRET]
[ENV_SECRET]
Implement and run pipe l…, Editor Group 2
Problems (⇧⌘M)
PROBLEMS
Output (⇧⌘U)
OUTPUT
Debug Console (⇧⌘Y)
DEBUG CONSOLE
Terminal (⌃`)
TERMINAL
Ports - 1 forwarded port
PORTS
1
remote SSH: nas
SSH: nas
screenpipe (Git) - master*, Checkout Branch/Tag...
master*
screenpipe (Git) - Synchronize Changes
No Problems
0
0
Forwarded Ports: 8766
1
Notifications
Sign In
Sign In
Info: Setting up SSH Host nas: Setting up SSH tunnel
Implement and run pipe logic
Session history
New session
Message actions
main.py
main.py
lets implement logic with pipes. how can I run it?
Thinking
Thinking
Let me look at the current project structure to understand what's already in place.
Bash
List project files
IN
find /volume1/screenpipe -type f | head -50 && echo "---" && ls /volume1/screenpipe
Copy code to clipboard
OUT
/volume1/screenpipe/.DS_Store
/volume1/screenpipe/screenpipe.db
/volume1/screenpipe/screenpipe_sync.sh
/volume1/screenpipe/app_settings.json
/volume1/screenpipe/.gitignore
/volume1/screenpipe/archive.db
/volume1/screenpipe/db.sqlite
/volume1/screenpipe/db.sqlite-wal
/volume1/screenpipe/db.sqlite-shm
/volume1/screenpipe/#recycle/desktop.ini
/volume1/screenpipe/#recycle/db.sqlite
/volume1/screenpipe/#recycle/Copy #1 of db.sqlite
/volume1/screenpipe/#recycle/.DS_Store
/volume1/screenpipe/#recycle/Copy #2 of db.sqlite
/volume1/screenpipe/#recycle/archive.db
/volume1/screenpipe/#recycle/Copy #1 of archive.db
/volume1/screenpipe/#recycle/Copy #2 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of archive.db
/volume1/screenpipe/#recycle/Copy #4 of archive.db
/volume1/screenpipe/#recycle/Copy #5 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of db.sqlite
/volume1/screenpipe/#recycle/Copy #4 of db.sqlite
/volume1/screenpipe/#recycle/Copy #6 of archive.db
/volume1/screenpipe/#recycle/test.txt
/volume1/screenpipe/#recycle/Copy #7 of archive.db
/volume1/screenpipe/#recycle/Copy #8 of archive.db
/volume1/screenpipe/#recycle/archive.db-journal
/volume1/screenpipe/#recycle/Copy #1 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #2 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #3 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #4 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #6 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #7 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of db.sqlite
/volume1/screenpipe/pipes/.DS_Store
/volume1/screenpipe/app/.env
/volume1/screenpipe/app/cli.py
/volume1/screenpipe/app/.DS_Store
/volume1/screenpipe/app/db.py
/volume1/screenpipe/app/docker-compose.yml
/volume1/screenpipe/app/main.py
/volume1/screenpipe/app/requirements.txt
/volume1/screenpipe/app/Dockerfile
/volume1/screenpipe/data/.DS_Store
/volume1/screenpipe/.git/description
/volume1/screenpipe/.git/HEAD
/volume1/screenpipe/.git/index
/volume1/screenpipe/.git/COMMIT_EDITMSG
/volume1/screenpipe/#recycle/data/.DS_Store
---
app
app_settings.json
archive.db
data
db.sqlite
db.sqlite-shm
db.sqlite-wal
pipes
#recycle
screenpipe.db
screenpipe_sync.sh
Read
main.py
main.py
Bash
Check pipes directory and docker-compose
IN
ls /volume1/screenpipe/pipes/ && ls /volume1/screenpipe/app/ && cat /volume1/screenpipe/app/docker-compose.yml
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
cli.py
consumers
db.py
docker-compose.yml
Dockerfile
main.py
__pycache__
requirements.txt
static
services:
screenpipe-app:
build: .
container_name: screenpipe-app
restart: unless-stopped
ports:
- "8766:8000"
volumes:
- /volume1/screenpipe:/data
env_file:
- .env
environment:
TZ: Europe/Sofia
DB_PATH: /data/db.sqlite
sqlite-web-archive:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-archive
restart: unless-stopped
ports:
- "8767:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/archive.db"]
sqlite-web-live:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-live
restart: unless-stopped
ports:
- "8768:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/db.sqlite"]
Read
requirements.txt
requirements.txt
Bash
Inspect a pipe directory
IN
ls /volume1/screenpipe/pipes/day-recap/ && cat /volume1/screenpipe/pipes/day-recap/pipe.json 2>/dev/null || ls /volume1/screenpipe/pipes/day-recap/
Copy code to clipboard
OUT
pipe.md
pipe.md
Read
cli.py
cli.py
Bash
List all pipes and their contents
IN
ls /volume1/screenpipe/pipes/ && for d in /volume1/screenpipe/pipes/*/; do echo "=== $d ==="; ls "$d"; done
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
=== /volume1/screenpipe/pipes/ai-habits/ ===
pipe.md
=== /volume1/screenpipe/pipes/day-recap/ ===
pipe.md
=== /volume1/screenpipe/pipes/meeting-summary/ ===
pipe.md
=== /volume1/screenpipe/pipes/standup-update/ ===
pipe.md
=== /volume1/screenpipe/pipes/time-breakdown/ ===
pipe.md
=== /volume1/screenpipe/pipes/video-export/ ===
pipe.md
Bash
Read pipe markdown files
IN
cat /volume1/screenpipe/pipes/day-recap/pipe.md && echo "===" && cat /volume1/screenpipe/pipes/meeting-summary/pipe.md 2>/dev/null | head -50
Copy code to clipboard
OUT
---
schedule: manual
enabled: true
template: true
title: Day Recap
description: "Today's accomplishments, key moments, and unfinished work"
icon: "📋"
featured: true
---
Analyze my screen and audio recordings from today (last 16 hours only).
Read screenpipe skill first.
Use this exact format:
## Summary
One sentence: what I mainly did today.
## Accomplishments
- Top 3 things I finished, with timestamps (e.g. "2:30 PM")
- Name specific apps, files, or projects
## Key Moments
- Important things I saw, said, or heard — with timestamps
## Unfinished Work
- What I should continue tomorrow — name the app/file/task
## Patterns
- Apps I used most, topics that came up repeatedly
Only report what you can verify from the data. End with: "**Next step:** [most important thing to continue]"
===
---
schedule: manual
enabled: true
template: true
title: Meeting Summary
description: "Summarize meeting transcript with key takeaways and action items"
icon: "🤝"
featured: false
---
Summarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.
Read screenpipe skill first.
Use this exact format:
## Meeting Summary
One sentence: what this meeting was about.
## Key Takeaways
- Top 3-5 important points discussed
- Include who said what when relevant
## Action Items
- [ ] Task — assigned to whom, deadline if mentioned
- [ ] Task — assigned to whom
## Decisions Made
- List any decisions or agreements reached
## Open Questions
- Anything unresolved or needing follow-up
Keep it concise and actionable.
Thinking
Thinking
Bash
Read summary consumer
IN
ls /volume1/screenpipe/app/consumers/ && cat /volume1/screenpipe/app/consumers/summary.py
Copy code to clipboard
OUT
activity.py
audio.py
elements.py
__init__.py
interactions.py
ocr.py
__pycache__
report.py
summary.py
"""AI summary generator using Claude."""
import os
from datetime import date
from typing import Any
from consumers.activity import app_time, summary_stats, browser_urls, ui_event_summary
from consumers.ocr import deduplicated_text
from consumers.audio import formatted_transcript
SUMMARY_TYPES = {
"day_recap": {
"title": "Day Recap",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
## Audio/speech:
{audio}
Write a concise day recap using EXACTLY this format:
## Summary
One sentence: what I mainly worked on today.
## Accomplishments
- Top 3 things I finished, with approximate times
- Name specific apps, files, or projects
## Key Moments
- Important things seen or heard, with timestamps
## Unfinished Work
- What to continue tomorrow
## Patterns
- Apps used most, topics that came up repeatedly
Only report what you can verify from the data. End with:
**Next step:** [most important thing to continue]""",
},
"standup": {
"title": "Standup Update",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
## Audio/speech:
{audio}
Write a brief standup update:
**Yesterday:** What I worked on (2-3 bullets)
**Today:** What I plan to continue (1-2 bullets)
**Blockers:** Any issues observed (or "None")
Keep it under 150 words. Only report what's verifiable from the data.""",
},
"focus_time": {
"title": "Focus & Distraction Analysis",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
Analyze focus vs distraction patterns:
## Deep Work Periods
- When and how long were sustained focus sessions?
- What was being worked on?
## Distractions
- Which apps/sites were used recreationally?
- How much time was lost to context switching?
## Recommendations
- 2-3 concrete suggestions to improve focus tomorrow
Be specific with times and app names.""",
},
}
def _build_context(for_date: date) -> dict[str, str]:
apps = app_time(for_date)
app_lines = "\n".join(f"- {a['app_name']}: {a['minutes']} min" for a in apps[:20])
urls = browser_urls(for_date, limit=20)
url_lines = "\n".join(
f"- {u['browser_url'][:100]} ({u['minutes']} min)" for u in urls
)
ui_rows = ui_event_summary(for_date)
ui_lines = "\n".join(
f"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches"
for r in ui_rows[:15]
)
ocr_rows = deduplicated_text(for_date, chunk_minutes=5)
ocr_lines = "\n".join(
f"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}"
for r in ocr_rows[:100]
)
audio = formatted_transcript(for_date)
return {
"app_time": app_lines or "(no app data)",
"browser_urls": url_lines or "(no browser data)",
"ui_events": ui_lines or "(no UI event data)",
"ocr_text": ocr_lines or "(no screen data)",
"audio": audio[:3000] if len(audio) > 3000 else audio,
}
def generate(
summary_type: str = "day_recap",
for_date: date | None = None,
api_key: str | None = None,
) -> dict[str, Any]:
"""Generate an AI summary. Returns dict with 'title', 'content', 'date'."""
import anthropic
d = for_date or date.today()
key = api_key or os.environ.get("ANTHROPIC_API_KEY", "")
if not key:
return {
"title": "Error",
"content": "ANTHROPIC_API_KEY not set. Add it to your .env file.",
"date": str(d),
}
spec = SUMMARY_TYPES.get(summary_type)
if not spec:
return {"title": "Error", "content": f"Unknown summary type: {summary_type}", "date": str(d)}
stats = summary_stats(d)
if stats["total_frames"] == 0:
return {
"title": spec["title"],
"content": f"No screen data found for {d}.",
"date": str(d),
}
ctx = _build_context(d)
prompt = spec["prompt"].format(**ctx)
client = anthropic.Anthropic(api_key=key)
message = client.messages.create(
model="claude-haiku-4-5-20251001",
max_tokens=1024,
messages=[{"role": "user", "content": prompt}],
)
return {
"title": spec["title"],
"content": message.content[0].text,
"date": str(d),
"stats": stats,
}
Thinking
Thinking
Bash
Read all pipe.md files
IN
for f in /volume1/screenpipe/pipes/*/pipe.md; do echo "=== $f ==="; cat "$f"; echo; done
Copy code to clipboard
OUT
=== /volume1/screenpipe/pipes/ai-habits/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: AI Habits
description: "How you use AI tools — patterns and insights"
icon: "🤖"
featured: true
---
Search my recordings from the last 24 hours for AI tool usage. Use app_name filter for each tool separately: ChatGPT, Claude, Copilot, Cursor, Gemini, Perplexity. Use limit=5 per search, max 6 searches total.
Read screenpipe skill first.
Use this exact format:
## AI Tools Used
- List each tool with approximate time spent (e.g. "Claude: ~45min")
## What I Used Them For
- For each tool: coding, writing, research, or brainstorming
## Usage Patterns
- Do I switch between tools? Use them in bursts or steadily?
## Effectiveness
- Which tool appeared alongside completed work vs. abandoned attempts
If no AI usage is found, say so clearly. End with: "**Tip:** [one suggestion to use AI tools more effectively]"
=== /volume1/screenpipe/pipes/day-recap/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Day Recap
description: "Today's accomplishments, key moments, and unfinished work"
icon: "📋"
featured: true
---
Analyze my screen and audio recordings from today (last 16 hours only).
Read screenpipe skill first.
Use this exact format:
## Summary
One sentence: what I mainly did today.
## Accomplishments
- Top 3 things I finished, with timestamps (e.g. "2:30 PM")
- Name specific apps, files, or projects
## Key Moments
- Important things I saw, said, or heard — with timestamps
## Unfinished Work
- What I should continue tomorrow — name the app/file/task
## Patterns
- Apps I used most, topics that came up repeatedly
Only report what you can verify from the data. End with: "**Next step:** [most important thing to continue]"
=== /volume1/screenpipe/pipes/meeting-summary/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Meeting Summary
description: "Summarize meeting transcript with key takeaways and action items"
icon: "🤝"
featured: false
---
Summarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.
Read screenpipe skill first.
Use this exact format:
## Meeting Summary
One sentence: what this meeting was about.
## Key Takeaways
- Top 3-5 important points discussed
- Include who said what when relevant
## Action Items
- [ ] Task — assigned to whom, deadline if mentioned
- [ ] Task — assigned to whom
## Decisions Made
- List any decisions or agreements reached
## Open Questions
- Anything unresolved or needing follow-up
Keep it concise and actionable.
=== /volume1/screenpipe/pipes/standup-update/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Standup Update
description: "What you did, what's next, and any blockers"
icon: "🏢"
featured: true
---
Based on my recordings from the last 24 hours, generate a standup update. Use limit=10 per search, max 3 searches total.
Read screenpipe skill first.
Use this exact format:
## Yesterday
- What I worked on (name specific projects, files, tools, PRs)
## Today
- What I will work on next (based on unfinished tasks and recent activity)
## Blockers
- Issues I hit — errors, slow builds, waiting on someone
- If no blockers, write "None"
Keep it under 150 words. Copy-paste ready for a team standup.
=== /volume1/screenpipe/pipes/time-breakdown/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Time Breakdown
description: "Where your time went — by app, project, and category"
icon: "⏱"
featured: false
---
Analyze my app usage from today (last 12 hours). Use limit=10 per search, max 4 searches. Prefer /raw_sql with COUNT/GROUP BY queries.
Read screenpipe skill first.
Use this exact format with durations and percentages:
## By Application
- List each app with duration and percentage, sorted by time (e.g. "VS Code: 2h 15min (28%)")
## By Category
- Group into: coding, meetings, browsing, writing, communication, other
- Show hours and percentage per category
## By Project
- Group related activities by project/topic. Name specific repos or tasks.
## Productivity Score
- Calculate: focused_work_hours / total_hours as a percentage
- Focused = coding + writing. Unfocused = browsing + switching.
End with: "**Suggestion:** [one specific change to improve tomorrow's productivity]"
=== /volume1/screenpipe/pipes/video-export/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Export Video Clip
description: "Create a video of your recent screen activity"
icon: "🎬"
featured: false
---
Export a video of my screen activity from the last 5 minutes.
Read screenpipe skill first.
Use the POST /frames/export endpoint with the time range and fps=1.0. Then show me the exported video file path as an inline code block so I can watch it.
If the export is large, suggest a lower fps or shorter time range.
Thinking
Thinking
Now I have a clear picture. The pipes are markdown prompt templates in
/volume1/screenpipe/pipes/
, but there's no code to actually load and run them —
consumers/summary.py
has its own hardcoded prompts instead.
Here's what I'll implement:
consumers/pipes.py
— dynamically loads pipe.md files and runs them via Claude (data injected as system message, pipe body as user prompt)
main.py
— two new endpoints:
GET /api/pipes
and
POST /api/pipes/{pipe_id}/run
cli.py
— a
pipe
command to run pipes from the terminal
Let me build it:
Bash
Check browser_urls signature
IN
cat /volume1/screenpipe/app/consumers/activity.py | grep "def browser_urls" -A 5
Copy code to clipboard
OUT
def browser_urls(
for_date: date | None = None,
app_name: str | None = None,
ts_from: str | None = None,
ts_to: str | None = None,
limit: int = 30,
Write
pipes.py
pipes.py
143 lines
"""Dynamic pipe loader and runner."""
import os
import re
from datetime import date
from pathlib import Path
from typing import Any
def _parse_frontmatter(text: str) -> tuple[dict, str]:
if not text.startswith("---"):
return {}, text
try:
end = text.index("---", 3)
except ValueError:
return {}, text
fm_text = text[3:end].strip()
body = text[end + 3:].strip()
meta: dict = {}
for line in fm_text.splitlines():
if ":" in line:
k, _, v = line.partition(":")
meta[k.strip()] = v.strip().strip('"')
return meta, body
def load_pipes(pipes_dir: Path) -> list[dict]:
if not pipes_dir.exists():
return []
pipes = []
for pipe_dir in sorted(pipes_dir.iterdir()):
if not pipe_dir.is_dir() or pipe_dir.name.startswith("."):
continue
pipe_md = pipe_dir / "pipe.md"
if not pipe_md.exists():
continue
text = pipe_md.read_text(encoding="utf-8")
meta, body = _parse_frontmatter(text)
if meta.get("enabled", "true").lower() == "false":
continue
body = re.sub(r"Read screenpipe skill first\.?\n?", "", body).strip()
pipes.append({
"id": pipe_dir.name,
"title": meta.get("title", pipe_dir.name),
"description": meta.get("description", ""),
"icon": meta.get("icon", ""),
"schedule": meta.get("schedule", "manual"),
"featured": meta.get("featured", "false").lower() == "true",
"prompt": body,
})
return pipes
def _build_system(d: date, stats: dict) -> str:
from consumers.activity import app_time, browser_urls, ui_event_summary
from consumers.ocr import deduplicated_text
from consumers.audio import formatted_transcript
apps = app_time(d)
app_lines = "\n".join(f"- {a['app_name']}: {a['minutes']} min" for a in apps[:20])
urls = browser_urls(d, limit=20)
url_lines = "\n".join(f"- {u['browser_url'][:100]} ({u['minutes']} min)" for u in urls)
ui_rows = ui_event_summary(d)
ui_lines = "\n".join(
f"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches"
for r in ui_rows[:15]
)
ocr_rows = deduplicated_text(d, chunk_minutes=5)
ocr_lines = "\n".join(
f"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}"
for r in ocr_rows[:100]
)
audio = formatted_transcript(d)
if len(audio) > 3000:
audio = audio[:3000]
return f"""You are analyzing screenpipe data — recordings of a person's computer activity.
## App usage (minutes per app):
{app_lines or '(no app data)'}
## Browser URLs visited:
{url_lines or '(no browser data)'}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_lines or '(no UI event data)'}
## Screen content (sampled every 5 minutes):
{ocr_lines or '(no screen data)'}
## Audio / speech:
{audio or '(no audio data)'}
Date: {d}
Total frames recorded: {stats['total_frames']}"""
def run_pipe(
pipe_id: str,
for_date: date | None = None,
api_key: str | None = None,
pipes_dir: Path | None = None,
) -> dict[str, Any]:
import anthropic
from consumers.activity import summary_stats
d = for_date or date.today()
key = api_key or os.environ.get("ANTHROPIC_API_KEY", "")
if not key:
return {"title": "Error", "content": "ANTHROPIC_API_KEY not set.", "date": str(d)}
_pipes_dir = pipes_dir or Path(os.environ.get("PIPES_DIR", "/data/pipes"))
all_pipes = {p["id"]: p for p in load_pipes(_pipes_dir)}
if pipe_id not in all_pipes:
return {"title": "Error", "content": f"Pipe not found: {pipe_id}", "date": str(d)}
pipe = all_pipes[pipe_id]
stats = summary_stats(d)
if stats["total_frames"] == 0:
return {"title": pipe["title"], "content": f"No screen data found for {d}.", "date": str(d)}
system = _build_system(d, stats)
client = anthropic.Anthropic(api_key=key)
message = client.messages.create(
model="claude-haiku-4-5-20251001",
max_tokens=1024,
system=system,
messages=[{"role": "user", "content": pipe["prompt"]}],
)
return {
"title": pipe["title"],
"content": message.content[0].text,
"date": str(d),
"stats": stats,
}
Now add the API endpoints to
main.py
:
Edit
main.py
main.py
Added 1 line
Edit
main.py
main.py
Added 1 line
Now add the pipe endpoints at the end of main.py, before the closing summary section:
Edit
main.py
main.py
Added 14 lines...
|
21063
|
NULL
|
NULL
|
NULL
|
|
21066
|
920
|
3
|
2026-05-11T17:07:47.643228+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-11/1778 /Users/lukas/.screenpipe/data/data/2026-05-11/1778519267643_m1.jpg...
|
Code
|
Implement and run pipe l… — screenpipe [SSH: nas]
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧ Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py
M
db.py
docker-compose.yml
Dockerfile
M
main.py
M
requirements.txt
M
data
logs
pipes
.gitignore
app_settings.json
archive.db
archive.db-bak
U
db.sqlite
db.sqlite-shm
db.sqlite-wal
screenpipe_sync_updated.sh
U
screenpipe_sync.sh
screenpipe.db
Outline Section
OUTLINE
OUTLINE
Timeline Section
TIMELINE
TIMELINE
app_settings.json, Editor Group 1
screenpipe_sync.sh, Editor Group 1
pipe.md, Editor Group 1
.env, Editor Group 1
[ENV_SECRET]
[ENV_SECRET]
Implement and run pipe l…, Editor Group 2
Problems (⇧⌘M)
PROBLEMS
Output (⇧⌘U)
OUTPUT
Debug Console (⇧⌘Y)
DEBUG CONSOLE
Terminal (⌃`)
TERMINAL
Ports - 1 forwarded port
PORTS
1
remote SSH: nas
SSH: nas
screenpipe (Git) - master*, Checkout Branch/Tag...
master*
screenpipe (Git) - Synchronize Changes
No Problems
0
0
Forwarded Ports: 8766
1
Notifications
Sign In
Sign In
Info: Setting up SSH Host nas: Setting up SSH tunnel
Implement and run pipe logic
Session history
New session
Message actions
main.py
main.py
lets implement logic with pipes. how can I run it?
Thinking
Thinking
Let me look at the current project structure to understand what's already in place.
Bash
List project files
IN
find /volume1/screenpipe -type f | head -50 && echo "---" && ls /volume1/screenpipe
Copy code to clipboard
OUT
/volume1/screenpipe/.DS_Store
/volume1/screenpipe/screenpipe.db
/volume1/screenpipe/screenpipe_sync.sh
/volume1/screenpipe/app_settings.json
/volume1/screenpipe/.gitignore
/volume1/screenpipe/archive.db
/volume1/screenpipe/db.sqlite
/volume1/screenpipe/db.sqlite-wal
/volume1/screenpipe/db.sqlite-shm
/volume1/screenpipe/#recycle/desktop.ini
/volume1/screenpipe/#recycle/db.sqlite
/volume1/screenpipe/#recycle/Copy #1 of db.sqlite
/volume1/screenpipe/#recycle/.DS_Store
/volume1/screenpipe/#recycle/Copy #2 of db.sqlite
/volume1/screenpipe/#recycle/archive.db
/volume1/screenpipe/#recycle/Copy #1 of archive.db
/volume1/screenpipe/#recycle/Copy #2 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of archive.db
/volume1/screenpipe/#recycle/Copy #4 of archive.db
/volume1/screenpipe/#recycle/Copy #5 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of db.sqlite
/volume1/screenpipe/#recycle/Copy #4 of db.sqlite
/volume1/screenpipe/#recycle/Copy #6 of archive.db
/volume1/screenpipe/#recycle/test.txt
/volume1/screenpipe/#recycle/Copy #7 of archive.db
/volume1/screenpipe/#recycle/Copy #8 of archive.db
/volume1/screenpipe/#recycle/archive.db-journal
/volume1/screenpipe/#recycle/Copy #1 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #2 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #3 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #4 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #6 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #7 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of db.sqlite
/volume1/screenpipe/pipes/.DS_Store
/volume1/screenpipe/app/.env
/volume1/screenpipe/app/cli.py
/volume1/screenpipe/app/.DS_Store
/volume1/screenpipe/app/db.py
/volume1/screenpipe/app/docker-compose.yml
/volume1/screenpipe/app/main.py
/volume1/screenpipe/app/requirements.txt
/volume1/screenpipe/app/Dockerfile
/volume1/screenpipe/data/.DS_Store
/volume1/screenpipe/.git/description
/volume1/screenpipe/.git/HEAD
/volume1/screenpipe/.git/index
/volume1/screenpipe/.git/COMMIT_EDITMSG
/volume1/screenpipe/#recycle/data/.DS_Store
---
app
app_settings.json
archive.db
data
db.sqlite
db.sqlite-shm
db.sqlite-wal
pipes
#recycle
screenpipe.db
screenpipe_sync.sh
Read
main.py
main.py
Bash
Check pipes directory and docker-compose
IN
ls /volume1/screenpipe/pipes/ && ls /volume1/screenpipe/app/ && cat /volume1/screenpipe/app/docker-compose.yml
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
cli.py
consumers
db.py
docker-compose.yml
Dockerfile
main.py
__pycache__
requirements.txt
static
services:
screenpipe-app:
build: .
container_name: screenpipe-app
restart: unless-stopped
ports:
- "8766:8000"
volumes:
- /volume1/screenpipe:/data
env_file:
- .env
environment:
TZ: Europe/Sofia
DB_PATH: /data/db.sqlite
sqlite-web-archive:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-archive
restart: unless-stopped
ports:
- "8767:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/archive.db"]
sqlite-web-live:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-live
restart: unless-stopped
ports:
- "8768:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/db.sqlite"]
Read
requirements.txt
requirements.txt
Bash
Inspect a pipe directory
IN
ls /volume1/screenpipe/pipes/day-recap/ && cat /volume1/screenpipe/pipes/day-recap/pipe.json 2>/dev/null || ls /volume1/screenpipe/pipes/day-recap/
Copy code to clipboard
OUT
pipe.md
pipe.md
Read
cli.py
cli.py
Bash
List all pipes and their contents
IN
ls /volume1/screenpipe/pipes/ && for d in /volume1/screenpipe/pipes/*/; do echo "=== $d ==="; ls "$d"; done
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
=== /volume1/screenpipe/pipes/ai-habits/ ===
pipe.md
=== /volume1/screenpipe/pipes/day-recap/ ===
pipe.md
=== /volume1/screenpipe/pipes/meeting-summary/ ===
pipe.md
=== /volume1/screenpipe/pipes/standup-update/ ===
pipe.md
=== /volume1/screenpipe/pipes/time-breakdown/ ===
pipe.md
=== /volume1/screenpipe/pipes/video-export/ ===
pipe.md
Bash
Read pipe markdown files
IN
cat /volume1/screenpipe/pipes/day-recap/pipe.md && echo "===" && cat /volume1/screenpipe/pipes/meeting-summary/pipe.md 2>/dev/null | head -50
Copy code to clipboard
OUT
---
schedule: manual
enabled: true
template: true
title: Day Recap
description: "Today's accomplishments, key moments, and unfinished work"
icon: "📋"
featured: true
---
Analyze my screen and audio recordings from today (last 16 hours only).
Read screenpipe skill first.
Use this exact format:
## Summary
One sentence: what I mainly did today.
## Accomplishments
- Top 3 things I finished, with timestamps (e.g. "2:30 PM")
- Name specific apps, files, or projects
## Key Moments
- Important things I saw, said, or heard — with timestamps
## Unfinished Work
- What I should continue tomorrow — name the app/file/task
## Patterns
- Apps I used most, topics that came up repeatedly
Only report what you can verify from the data. End with: "**Next step:** [most important thing to continue]"
===
---
schedule: manual
enabled: true
template: true
title: Meeting Summary
description: "Summarize meeting transcript with key takeaways and action items"
icon: "🤝"
featured: false
---
Summarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.
Read screenpipe skill first.
Use this exact format:
## Meeting Summary
One sentence: what this meeting was about.
## Key Takeaways
- Top 3-5 important points discussed
- Include who said what when relevant
## Action Items
- [ ] Task — assigned to whom, deadline if mentioned
- [ ] Task — assigned to whom
## Decisions Made
- List any decisions or agreements reached
## Open Questions
- Anything unresolved or needing follow-up
Keep it concise and actionable.
Thinking
Thinking
Bash
Read summary consumer
IN
ls /volume1/screenpipe/app/consumers/ && cat /volume1/screenpipe/app/consumers/summary.py
Copy code to clipboard
OUT
activity.py
audio.py
elements.py
__init__.py
interactions.py
ocr.py
__pycache__
report.py
summary.py
"""AI summary generator using Claude."""
import os
from datetime import date
from typing import Any
from consumers.activity import app_time, summary_stats, browser_urls, ui_event_summary
from consumers.ocr import deduplicated_text
from consumers.audio import formatted_transcript
SUMMARY_TYPES = {
"day_recap": {
"title": "Day Recap",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
## Audio/speech:
{audio}
Write a concise day recap using EXACTLY this format:
## Summary
One sentence: what I mainly worked on today.
## Accomplishments
- Top 3 things I finished, with approximate times
- Name specific apps, files, or projects
## Key Moments
- Important things seen or heard, with timestamps
## Unfinished Work
- What to continue tomorrow
## Patterns
- Apps used most, topics that came up repeatedly
Only report what you can verify from the data. End with:
**Next step:** [most important thing to continue]""",
},
"standup": {
"title": "Standup Update",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
## Audio/speech:
{audio}
Write a brief standup update:
**Yesterday:** What I worked on (2-3 bullets)
**Today:** What I plan to continue (1-2 bullets)
**Blockers:** Any issues observed (or "None")
Keep it under 150 words. Only report what's verifiable from the data.""",
},
"focus_time": {
"title": "Focus & Distraction Analysis",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
Analyze focus vs distraction patterns:
## Deep Work Periods
- When and how long were sustained focus sessions?
- What was being worked on?
## Distractions
- Which apps/sites were used recreationally?
- How much time was lost to context switching?
## Recommendations
- 2-3 concrete suggestions to improve focus tomorrow
Be specific with times and app names.""",
},
}
def _build_context(for_date: date) -> dict[str, str]:
apps = app_time(for_date)
app_lines = "\n".join(f"- {a['app_name']}: {a['minutes']} min" for a in apps[:20])
urls = browser_urls(for_date, limit=20)
url_lines = "\n".join(
f"- {u['browser_url'][:100]} ({u['minutes']} min)" for u in urls
)
ui_rows = ui_event_summary(for_date)
ui_lines = "\n".join(
f"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches"
for r in ui_rows[:15]
)
ocr_rows = deduplicated_text(for_date, chunk_minutes=5)
ocr_lines = "\n".join(
f"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}"
for r in ocr_rows[:100]
)
audio = formatted_transcript(for_date)
return {
"app_time": app_lines or "(no app data)",
"browser_urls": url_lines or "(no browser data)",
"ui_events": ui_lines or "(no UI event data)",
"ocr_text": ocr_lines or "(no screen data)",
"audio": audio[:3000] if len(audio) > 3000 else audio,
}
def generate(
summary_type: str = "day_recap",
for_date: date | None = None,
api_key: str | None = None,
) -> dict[str, Any]:
"""Generate an AI summary. Returns dict with 'title', 'content', 'date'."""
import anthropic
d = for_date or date.today()
key = api_key or os.environ.get("ANTHROPIC_API_KEY", "")
if not key:
return {
"title": "Error",
"content": "ANTHROPIC_API_KEY not set. Add it to your .env file.",
"date": str(d),
}
spec = SUMMARY_TYPES.get(summary_type)
if not spec:
return {"title": "Error", "content": f"Unknown summary type: {summary_type}", "date": str(d)}
stats = summary_stats(d)
if stats["total_frames"] == 0:
return {
"title": spec["title"],
"content": f"No screen data found for {d}.",
"date": str(d),
}
ctx = _build_context(d)
prompt = spec["prompt"].format(**ctx)
client = anthropic.Anthropic(api_key=key)
message = client.messages.create(
model="claude-haiku-4-5-20251001",
max_tokens=1024,
messages=[{"role": "user", "content": prompt}],
)
return {
"title": spec["title"],
"content": message.content[0].text,
"date": str(d),
"stats": stats,
}
Thinking
Thinking
Bash
Read all pipe.md files
IN
for f in /volume1/screenpipe/pipes/*/pipe.md; do echo "=== $f ==="; cat "$f"; echo; done
Copy code to clipboard
OUT
=== /volume1/screenpipe/pipes/ai-habits/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: AI Habits
description: "How you use AI tools — patterns and insights"
icon: "🤖"
featured: true
---
Search my recordings from the last 24 hours for AI tool usage. Use app_name filter for each tool separately: ChatGPT, Claude, Copilot, Cursor, Gemini, Perplexity. Use limit=5 per search, max 6 searches total.
Read screenpipe skill first.
Use this exact format:
## AI Tools Used
- List each tool with approximate time spent (e.g. "Claude: ~45min")
## What I Used Them For
- For each tool: coding, writing, research, or brainstorming
## Usage Patterns
- Do I switch between tools? Use them in bursts or steadily?
## Effectiveness
- Which tool appeared alongside completed work vs. abandoned attempts
If no AI usage is found, say so clearly. End with: "**Tip:** [one suggestion to use AI tools more effectively]"
=== /volume1/screenpipe/pipes/day-recap/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Day Recap
description: "Today's accomplishments, key moments, and unfinished work"
icon: "📋"
featured: true
---
Analyze my screen and audio recordings from today (last 16 hours only).
Read screenpipe skill first.
Use this exact format:
## Summary
One sentence: what I mainly did today.
## Accomplishments
- Top 3 things I finished, with timestamps (e.g. "2:30 PM")
- Name specific apps, files, or projects
## Key Moments
- Important things I saw, said, or heard — with timestamps
## Unfinished Work
- What I should continue tomorrow — name the app/file/task
## Patterns
- Apps I used most, topics that came up repeatedly
Only report what you can verify from the data. End with: "**Next step:** [most important thing to continue]"
=== /volume1/screenpipe/pipes/meeting-summary/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Meeting Summary
description: "Summarize meeting transcript with key takeaways and action items"
icon: "🤝"
featured: false
---
Summarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.
Read screenpipe skill first.
Use this exact format:
## Meeting Summary
One sentence: what this meeting was about.
## Key Takeaways
- Top 3-5 important points discussed
- Include who said what when relevant
## Action Items
- [ ] Task — assigned to whom, deadline if mentioned
- [ ] Task — assigned to whom
## Decisions Made
- List any decisions or agreements reached
## Open Questions
- Anything unresolved or needing follow-up
Keep it concise and actionable.
=== /volume1/screenpipe/pipes/standup-update/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Standup Update
description: "What you did, what's next, and any blockers"
icon: "🏢"
featured: true
---
Based on my recordings from the last 24 hours, generate a standup update. Use limit=10 per search, max 3 searches total.
Read screenpipe skill first.
Use this exact format:
## Yesterday
- What I worked on (name specific projects, files, tools, PRs)
## Today
- What I will work on next (based on unfinished tasks and recent activity)
## Blockers
- Issues I hit — errors, slow builds, waiting on someone
- If no blockers, write "None"
Keep it under 150 words. Copy-paste ready for a team standup.
=== /volume1/screenpipe/pipes/time-breakdown/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Time Breakdown
description: "Where your time went — by app, project, and category"
icon: "⏱"
featured: false
---
Analyze my app usage from today (last 12 hours). Use limit=10 per search, max 4 searches. Prefer /raw_sql with COUNT/GROUP BY queries.
Read screenpipe skill first.
Use this exact format with durations and percentages:
## By Application
- List each app with duration and percentage, sorted by time (e.g. "VS Code: 2h 15min (28%)")
## By Category
- Group into: coding, meetings, browsing, writing, communication, other
- Show hours and percentage per category
## By Project
- Group related activities by project/topic. Name specific repos or tasks.
## Productivity Score
- Calculate: focused_work_hours / total_hours as a percentage
- Focused = coding + writing. Unfocused = browsing + switching.
End with: "**Suggestion:** [one specific change to improve tomorrow's productivity]"
=== /volume1/screenpipe/pipes/video-export/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Export Video Clip
description: "Create a video of your recent screen activity"
icon: "🎬"
featured: false
---
Export a video of my screen activity from the last 5 minutes.
Read screenpipe skill first.
Use the POST /frames/export endpoint with the time range and fps=1.0. Then show me the exported video file path as an inline code block so I can watch it.
If the export is large, suggest a lower fps or shorter time range.
Thinking
Thinking
Now I have a clear picture. The pipes are markdown prompt templates in
/volume1/screenpipe/pipes/
, but there's no code to actually load and run them —
consumers/summary.py
has its own hardcoded prompts instead.
Here's what I'll implement:
consumers/pipes.py
— dynamically loads pipe.md files and runs them via Claude (data injected as system message, pipe body as user prompt)
main.py
— two new endpoints:
GET /api/pipes
and
POST /api/pipes/{pipe_id}/run
cli.py
— a
pipe
command to run pipes from the terminal
Let me build it:
Bash
Check browser_urls signature
IN
cat /volume1/screenpipe/app/consumers/activity.py | grep "def browser_urls" -A 5
Copy code to clipboard
OUT
def browser_urls(
for_date: date | None = None,
app_name: str | None = None,
ts_from: str | None = None,
ts_to: str | None = None,
limit: int = 30,
Write
pipes.py
pipes.py
143 lines
"""Dynamic pipe loader and runner."""
import os
import re
from datetime import date
from pathlib import Path
from typing import Any
def _parse_frontmatter(text: str) -> tuple[dict, str]:
if not text.startswith("---"):
return {}, text
try:
end = text.index("---", 3)
except ValueError:
return {}, text
fm_text = text[3:end].strip()
body = text[end + 3:].strip()
meta: dict = {}
for line in fm_text.splitlines():
if ":" in line:
k, _, v = line.partition(":")
meta[k.strip()] = v.strip().strip('"')
return meta, body
def load_pipes(pipes_dir: Path) -> list[dict]:
if not pipes_dir.exists():
return []
pipes = []
for pipe_dir in sorted(pipes_dir.iterdir()):
if not pipe_dir.is_dir() or pipe_dir.name.startswith("."):
continue
pipe_md = pipe_dir / "pipe.md"
if not pipe_md.exists():
continue
text = pipe_md.read_text(encoding="utf-8")
meta, body = _parse_frontmatter(text)
if meta.get("enabled", "true").lower() == "false":
continue
body = re.sub(r"Read screenpipe skill first\.?\n?", "", body).strip()
pipes.append({
"id": pipe_dir.name,
"title": meta.get("title", pipe_dir.name),
"description": meta.get("description", ""),
"icon": meta.get("icon", ""),
"schedule": meta.get("schedule", "manual"),
"featured": meta.get("featured", "false").lower() == "true",
"prompt": body,
})
return pipes
def _build_system(d: date, stats: dict) -> str:
from consumers.activity import app_time, browser_urls, ui_event_summary
from consumers.ocr import deduplicated_text
from consumers.audio import formatted_transcript
apps = app_time(d)
app_lines = "\n".join(f"- {a['app_name']}: {a['minutes']} min" for a in apps[:20])
urls = browser_urls(d, limit=20)
url_lines = "\n".join(f"- {u['browser_url'][:100]} ({u['minutes']} min)" for u in urls)
ui_rows = ui_event_summary(d)
ui_lines = "\n".join(
f"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches"
for r in ui_rows[:15]
)
ocr_rows = deduplicated_text(d, chunk_minutes=5)
ocr_lines = "\n".join(
f"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}"
for r in ocr_rows[:100]
)
audio = formatted_transcript(d)
if len(audio) > 3000:
audio = audio[:3000]
return f"""You are analyzing screenpipe data — recordings of a person's computer activity.
## App usage (minutes per app):
{app_lines or '(no app data)'}
## Browser URLs visited:
{url_lines or '(no browser data)'}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_lines or '(no UI event data)'}
## Screen content (sampled every 5 minutes):
{ocr_lines or '(no screen data)'}
## Audio / speech:
{audio or '(no audio data)'}
Date: {d}
Total frames recorded: {stats['total_frames']}"""
def run_pipe(
pipe_id: str,
for_date: date | None = None,
api_key: str | None = None,
pipes_dir: Path | None = None,
) -> dict[str, Any]:
import anthropic
from consumers.activity import summary_stats
d = for_date or date.today()
key = api_key or os.environ.get("ANTHROPIC_API_KEY", "")
if not key:
return {"title": "Error", "content": "ANTHROPIC_API_KEY not set.", "date": str(d)}
_pipes_dir = pipes_dir or Path(os.environ.get("PIPES_DIR", "/data/pipes"))
all_pipes = {p["id"]: p for p in load_pipes(_pipes_dir)}
if pipe_id not in all_pipes:
return {"title": "Error", "content": f"Pipe not found: {pipe_id}", "date": str(d)}
pipe = all_pipes[pipe_id]
stats = summary_stats(d)
if stats["total_frames"] == 0:
return {"title": pipe["title"], "content": f"No screen data found for {d}.", "date": str(d)}
system = _build_system(d, stats)
client = anthropic.Anthropic(api_key=key)
message = client.messages.create(
model="claude-haiku-4-5-20251001",
max_tokens=1024,
system=system,
messages=[{"role": "user", "content": pipe["prompt"]}],
)
return {
"title": pipe["title"],
"content": message.content[0].text,
"date": str(d),
"stats": stats,
}
Now add the API endpoints to
main.py
:
Edit
main.py
main.py
Added 1 line
Edit
main.py
main.py
Added 1 line
Now add the pipe endpoints at the end of main.py, before the closing summary section:
Edit
main.py
main.py
Added 14 lines
Now add the CLI command to
cli.py
cli.py
:
Edit
cli.py
cli.py
Added 40 lines
Done. Here's how to run pipes:
How to run pipes
How to run pipes
Via Docker (inside the running container):
Copy code to clipboard
docker exec -it screenpipe-app python cli.py pipe --list
docker exec -it screenpipe-app python cli.py pipe day-recap
docker exec -it screenpipe-app python cli.py pipe standup-update --date yesterday
Via the API
(once the container is running on port 8766):
Copy code to clipboard...
|
[{"role":"AXRadioButton","text [{"role":"AXRadioButton","text":"Explorer (⇧⌘E)","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":true},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Search (⇧⌘F)","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Source Control (⌃⇧G) - 10 pending changes","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"10","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Run and Debug (⇧⌘D)","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Remote Explorer","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Extensions (⇧⌘X) - 2 require update","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"2","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Claude Code","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"Containers","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXHeading","text":"EXPLORER","depth":17,"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"EXPLORER","depth":18,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Explorer Section: screenpipe [SSH: nas]","depth":21,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":true},{"role":"AXStaticText","text":"","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"Explorer Section: screenpipe [SSH: nas]","depth":22,"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"SCREENPIPE [SSH: NAS]","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"#recycle","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"app","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"__pycache__","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"consumers","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"static","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":".env","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"cli.py","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.py","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"docker-compose.yml","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Dockerfile","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"main.py","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"requirements.txt","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"data","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"logs","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"pipes","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":".gitignore","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"app_settings.json","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"archive.db","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"archive.db-bak","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"U","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite-shm","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite-wal","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe_sync_updated.sh","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"U","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe_sync.sh","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe.db","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Outline Section","depth":21,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"OUTLINE","depth":22,"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"OUTLINE","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Timeline Section","depth":21,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"TIMELINE","depth":22,"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"TIMELINE","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"app_settings.json, Editor Group 1","depth":28,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"screenpipe_sync.sh, Editor Group 1","depth":28,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"pipe.md, Editor Group 1","depth":28,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":".env, Editor Group 1","depth":28,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":false},{"role":"AXStaticText","text":"","depth":29,"on_screen":true,"role_description":"text"},{"role":"AXTextArea","text":"ANTHROPIC_API_KEY=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","depth":28,"on_screen":true,"value":"ANTHROPIC_API_KEY=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","role_description":"editor","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"ANTHROPIC_API_KEY=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","depth":29,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Implement and run pipe l…, Editor Group 2","depth":28,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":false},{"role":"AXRadioButton","text":"Problems (⇧⌘M)","depth":22,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"PROBLEMS","depth":24,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Output (⇧⌘U)","depth":22,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUTPUT","depth":24,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Debug Console (⇧⌘Y)","depth":22,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"DEBUG CONSOLE","depth":24,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Terminal (⌃`)","depth":22,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":true},{"role":"AXStaticText","text":"TERMINAL","depth":24,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Ports - 1 forwarded port","depth":22,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"PORTS","depth":24,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":25,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"remote SSH: nas","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"SSH: nas","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"screenpipe (Git) - master*, Checkout Branch/Tag...","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"master*","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"screenpipe (Git) - Synchronize Changes","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"No Problems","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"0","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"0","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Forwarded Ports: 8766","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Notifications","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sign In","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Sign In","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Info: Setting up SSH Host nas: Setting up SSH tunnel","depth":12,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Implement and run pipe logic","depth":19,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Session history","depth":19,"on_screen":true,"help_text":"Session history","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"New session","depth":19,"on_screen":true,"help_text":"New session","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Message actions","depth":24,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"main.py","depth":23,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"lets implement logic with pipes. how can I run it?","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Let me look at the current project structure to understand what's already in place.","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"List project files","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"find /volume1/screenpipe -type f | head -50 && echo \"---\" && ls /volume1/screenpipe","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"/volume1/screenpipe/.DS_Store\n/volume1/screenpipe/screenpipe.db\n/volume1/screenpipe/screenpipe_sync.sh\n/volume1/screenpipe/app_settings.json\n/volume1/screenpipe/.gitignore\n/volume1/screenpipe/archive.db\n/volume1/screenpipe/db.sqlite\n/volume1/screenpipe/db.sqlite-wal\n/volume1/screenpipe/db.sqlite-shm\n/volume1/screenpipe/#recycle/desktop.ini\n/volume1/screenpipe/#recycle/db.sqlite\n/volume1/screenpipe/#recycle/Copy #1 of db.sqlite\n/volume1/screenpipe/#recycle/.DS_Store\n/volume1/screenpipe/#recycle/Copy #2 of db.sqlite\n/volume1/screenpipe/#recycle/archive.db\n/volume1/screenpipe/#recycle/Copy #1 of archive.db\n/volume1/screenpipe/#recycle/Copy #2 of archive.db\n/volume1/screenpipe/#recycle/Copy #3 of archive.db\n/volume1/screenpipe/#recycle/Copy #4 of archive.db\n/volume1/screenpipe/#recycle/Copy #5 of archive.db\n/volume1/screenpipe/#recycle/Copy #3 of db.sqlite\n/volume1/screenpipe/#recycle/Copy #4 of db.sqlite\n/volume1/screenpipe/#recycle/Copy #6 of archive.db\n/volume1/screenpipe/#recycle/test.txt\n/volume1/screenpipe/#recycle/Copy #7 of archive.db\n/volume1/screenpipe/#recycle/Copy #8 of archive.db\n/volume1/screenpipe/#recycle/archive.db-journal\n/volume1/screenpipe/#recycle/Copy #1 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #2 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #3 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #4 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #5 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #6 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #7 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #5 of db.sqlite\n/volume1/screenpipe/pipes/.DS_Store\n/volume1/screenpipe/app/.env\n/volume1/screenpipe/app/cli.py\n/volume1/screenpipe/app/.DS_Store\n/volume1/screenpipe/app/db.py\n/volume1/screenpipe/app/docker-compose.yml\n/volume1/screenpipe/app/main.py\n/volume1/screenpipe/app/requirements.txt\n/volume1/screenpipe/app/Dockerfile\n/volume1/screenpipe/data/.DS_Store\n/volume1/screenpipe/.git/description\n/volume1/screenpipe/.git/HEAD\n/volume1/screenpipe/.git/index\n/volume1/screenpipe/.git/COMMIT_EDITMSG\n/volume1/screenpipe/#recycle/data/.DS_Store\n---\napp\napp_settings.json\narchive.db\ndata\ndb.sqlite\ndb.sqlite-shm\ndb.sqlite-wal\npipes\n#recycle\nscreenpipe.db\nscreenpipe_sync.sh","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"main.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Check pipes directory and docker-compose","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/pipes/ && ls /volume1/screenpipe/app/ && cat /volume1/screenpipe/app/docker-compose.yml","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ai-habits\nday-recap\nmeeting-summary\nstandup-update\ntime-breakdown\nvideo-export\ncli.py\nconsumers\ndb.py\ndocker-compose.yml\nDockerfile\nmain.py\n__pycache__\nrequirements.txt\nstatic\nservices:\n screenpipe-app:\n build: .\n container_name: screenpipe-app\n restart: unless-stopped\n ports:\n - \"8766:8000\"\n volumes:\n - /volume1/screenpipe:/data\n env_file:\n - .env\n environment:\n TZ: Europe/Sofia\n DB_PATH: /data/db.sqlite\n\n sqlite-web-archive:\n image: ghcr.io/coleifer/sqlite-web:latest\n container_name: screenpipe-sqlweb-archive\n restart: unless-stopped\n ports:\n - \"8767:8080\"\n volumes:\n - /volume1/screenpipe:/data\n command: [\"-H\", \"0.0.0.0\", \"-r\", \"/data/archive.db\"]\n\n sqlite-web-live:\n image: ghcr.io/coleifer/sqlite-web:latest\n container_name: screenpipe-sqlweb-live\n restart: unless-stopped\n ports:\n - \"8768:8080\"\n volumes:\n - /volume1/screenpipe:/data\n command: [\"-H\", \"0.0.0.0\", \"-r\", \"/data/db.sqlite\"]","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"requirements.txt","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"requirements.txt","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Inspect a pipe directory","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/pipes/day-recap/ && cat /volume1/screenpipe/pipes/day-recap/pipe.json 2>/dev/null || ls /volume1/screenpipe/pipes/day-recap/","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"pipe.md\npipe.md","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"cli.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"cli.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"List all pipes and their contents","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/pipes/ && for d in /volume1/screenpipe/pipes/*/; do echo \"=== $d ===\"; ls \"$d\"; done","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ai-habits\nday-recap\nmeeting-summary\nstandup-update\ntime-breakdown\nvideo-export\n=== /volume1/screenpipe/pipes/ai-habits/ ===\npipe.md\n=== /volume1/screenpipe/pipes/day-recap/ ===\npipe.md\n=== /volume1/screenpipe/pipes/meeting-summary/ ===\npipe.md\n=== /volume1/screenpipe/pipes/standup-update/ ===\npipe.md\n=== /volume1/screenpipe/pipes/time-breakdown/ ===\npipe.md\n=== /volume1/screenpipe/pipes/video-export/ ===\npipe.md","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read pipe markdown files","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"cat /volume1/screenpipe/pipes/day-recap/pipe.md && echo \"===\" && cat /volume1/screenpipe/pipes/meeting-summary/pipe.md 2>/dev/null | head -50","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Day Recap\ndescription: \"Today's accomplishments, key moments, and unfinished work\"\nicon: \"📋\"\nfeatured: true\n---\n\nAnalyze my screen and audio recordings from today (last 16 hours only). \n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Summary\nOne sentence: what I mainly did today.\n\n## Accomplishments\n- Top 3 things I finished, with timestamps (e.g. \"2:30 PM\")\n- Name specific apps, files, or projects\n\n## Key Moments\n- Important things I saw, said, or heard — with timestamps\n\n## Unfinished Work\n- What I should continue tomorrow — name the app/file/task\n\n## Patterns\n- Apps I used most, topics that came up repeatedly\n\nOnly report what you can verify from the data. End with: \"**Next step:** [most important thing to continue]\"\n===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Meeting Summary\ndescription: \"Summarize meeting transcript with key takeaways and action items\"\nicon: \"🤝\"\nfeatured: false\n---\n\nSummarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.\n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Meeting Summary\nOne sentence: what this meeting was about.\n\n## Key Takeaways\n- Top 3-5 important points discussed\n- Include who said what when relevant\n\n## Action Items\n- [ ] Task — assigned to whom, deadline if mentioned\n- [ ] Task — assigned to whom\n\n## Decisions Made\n- List any decisions or agreements reached\n\n## Open Questions\n- Anything unresolved or needing follow-up\n\nKeep it concise and actionable.","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read summary consumer","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/app/consumers/ && cat /volume1/screenpipe/app/consumers/summary.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"activity.py\naudio.py\nelements.py\n__init__.py\ninteractions.py\nocr.py\n__pycache__\nreport.py\nsummary.py\n\"\"\"AI summary generator using Claude.\"\"\"\nimport os\nfrom datetime import date\nfrom typing import Any\n\nfrom consumers.activity import app_time, summary_stats, browser_urls, ui_event_summary\nfrom consumers.ocr import deduplicated_text\nfrom consumers.audio import formatted_transcript\n\n\nSUMMARY_TYPES = {\n \"day_recap\": {\n \"title\": \"Day Recap\",\n \"prompt\": \"\"\"\\\nYou are analyzing a person's computer activity for the day.\n\n## App usage (minutes per app):\n{app_time}\n\n## Browser URLs visited:\n{browser_urls}\n\n## UI activity per app (clicks / keystrokes / app-switches):\n{ui_events}\n\n## Screen content (sampled every 5 minutes):\n{ocr_text}\n\n## Audio/speech:\n{audio}\n\nWrite a concise day recap using EXACTLY this format:\n\n## Summary\nOne sentence: what I mainly worked on today.\n\n## Accomplishments\n- Top 3 things I finished, with approximate times\n- Name specific apps, files, or projects\n\n## Key Moments\n- Important things seen or heard, with timestamps\n\n## Unfinished Work\n- What to continue tomorrow\n\n## Patterns\n- Apps used most, topics that came up repeatedly\n\nOnly report what you can verify from the data. End with:\n**Next step:** [most important thing to continue]\"\"\",\n },\n \"standup\": {\n \"title\": \"Standup Update\",\n \"prompt\": \"\"\"\\\nYou are analyzing a person's computer activity for the day.\n\n## App usage (minutes per app):\n{app_time}\n\n## Browser URLs visited:\n{browser_urls}\n\n## UI activity per app (clicks / keystrokes / app-switches):\n{ui_events}\n\n## Screen content (sampled every 5 minutes):\n{ocr_text}\n\n## Audio/speech:\n{audio}\n\nWrite a brief standup update:\n\n**Yesterday:** What I worked on (2-3 bullets)\n**Today:** What I plan to continue (1-2 bullets)\n**Blockers:** Any issues observed (or \"None\")\n\nKeep it under 150 words. Only report what's verifiable from the data.\"\"\",\n },\n \"focus_time\": {\n \"title\": \"Focus & Distraction Analysis\",\n \"prompt\": \"\"\"\\\nYou are analyzing a person's computer activity for the day.\n\n## App usage (minutes per app):\n{app_time}\n\n## Browser URLs visited:\n{browser_urls}\n\n## UI activity per app (clicks / keystrokes / app-switches):\n{ui_events}\n\n## Screen content (sampled every 5 minutes):\n{ocr_text}\n\nAnalyze focus vs distraction patterns:\n\n## Deep Work Periods\n- When and how long were sustained focus sessions?\n- What was being worked on?\n\n## Distractions\n- Which apps/sites were used recreationally?\n- How much time was lost to context switching?\n\n## Recommendations\n- 2-3 concrete suggestions to improve focus tomorrow\n\nBe specific with times and app names.\"\"\",\n },\n}\n\n\ndef _build_context(for_date: date) -> dict[str, str]:\n apps = app_time(for_date)\n app_lines = \"\\n\".join(f\"- {a['app_name']}: {a['minutes']} min\" for a in apps[:20])\n\n urls = browser_urls(for_date, limit=20)\n url_lines = \"\\n\".join(\n f\"- {u['browser_url'][:100]} ({u['minutes']} min)\" for u in urls\n )\n\n ui_rows = ui_event_summary(for_date)\n ui_lines = \"\\n\".join(\n f\"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches\"\n for r in ui_rows[:15]\n )\n\n ocr_rows = deduplicated_text(for_date, chunk_minutes=5)\n ocr_lines = \"\\n\".join(\n f\"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}\"\n for r in ocr_rows[:100]\n )\n\n audio = formatted_transcript(for_date)\n\n return {\n \"app_time\": app_lines or \"(no app data)\",\n \"browser_urls\": url_lines or \"(no browser data)\",\n \"ui_events\": ui_lines or \"(no UI event data)\",\n \"ocr_text\": ocr_lines or \"(no screen data)\",\n \"audio\": audio[:3000] if len(audio) > 3000 else audio,\n }\n\n\ndef generate(\n summary_type: str = \"day_recap\",\n for_date: date | None = None,\n api_key: str | None = None,\n) -> dict[str, Any]:\n \"\"\"Generate an AI summary. Returns dict with 'title', 'content', 'date'.\"\"\"\n import anthropic\n\n d = for_date or date.today()\n key = api_key or os.environ.get(\"ANTHROPIC_API_KEY\", \"\")\n if not key:\n return {\n \"title\": \"Error\",\n \"content\": \"ANTHROPIC_API_KEY not set. Add it to your .env file.\",\n \"date\": str(d),\n }\n\n spec = SUMMARY_TYPES.get(summary_type)\n if not spec:\n return {\"title\": \"Error\", \"content\": f\"Unknown summary type: {summary_type}\", \"date\": str(d)}\n\n stats = summary_stats(d)\n if stats[\"total_frames\"] == 0:\n return {\n \"title\": spec[\"title\"],\n \"content\": f\"No screen data found for {d}.\",\n \"date\": str(d),\n }\n\n ctx = _build_context(d)\n prompt = spec[\"prompt\"].format(**ctx)\n\n client = anthropic.Anthropic(api_key=key)\n message = client.messages.create(\n model=\"claude-haiku-4-5-20251001\",\n max_tokens=1024,\n messages=[{\"role\": \"user\", \"content\": prompt}],\n )\n\n return {\n \"title\": spec[\"title\"],\n \"content\": message.content[0].text,\n \"date\": str(d),\n \"stats\": stats,\n }","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read all pipe.md files","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"for f in /volume1/screenpipe/pipes/*/pipe.md; do echo \"=== $f ===\"; cat \"$f\"; echo; done","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"=== /volume1/screenpipe/pipes/ai-habits/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: AI Habits\ndescription: \"How you use AI tools — patterns and insights\"\nicon: \"🤖\"\nfeatured: true\n---\n\nSearch my recordings from the last 24 hours for AI tool usage. Use app_name filter for each tool separately: ChatGPT, Claude, Copilot, Cursor, Gemini, Perplexity. Use limit=5 per search, max 6 searches total.\n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## AI Tools Used\n- List each tool with approximate time spent (e.g. \"Claude: ~45min\")\n\n## What I Used Them For\n- For each tool: coding, writing, research, or brainstorming\n\n## Usage Patterns\n- Do I switch between tools? Use them in bursts or steadily?\n\n## Effectiveness\n- Which tool appeared alongside completed work vs. abandoned attempts\n\nIf no AI usage is found, say so clearly. End with: \"**Tip:** [one suggestion to use AI tools more effectively]\"\n\n=== /volume1/screenpipe/pipes/day-recap/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Day Recap\ndescription: \"Today's accomplishments, key moments, and unfinished work\"\nicon: \"📋\"\nfeatured: true\n---\n\nAnalyze my screen and audio recordings from today (last 16 hours only). \n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Summary\nOne sentence: what I mainly did today.\n\n## Accomplishments\n- Top 3 things I finished, with timestamps (e.g. \"2:30 PM\")\n- Name specific apps, files, or projects\n\n## Key Moments\n- Important things I saw, said, or heard — with timestamps\n\n## Unfinished Work\n- What I should continue tomorrow — name the app/file/task\n\n## Patterns\n- Apps I used most, topics that came up repeatedly\n\nOnly report what you can verify from the data. End with: \"**Next step:** [most important thing to continue]\"\n\n=== /volume1/screenpipe/pipes/meeting-summary/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Meeting Summary\ndescription: \"Summarize meeting transcript with key takeaways and action items\"\nicon: \"🤝\"\nfeatured: false\n---\n\nSummarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.\n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Meeting Summary\nOne sentence: what this meeting was about.\n\n## Key Takeaways\n- Top 3-5 important points discussed\n- Include who said what when relevant\n\n## Action Items\n- [ ] Task — assigned to whom, deadline if mentioned\n- [ ] Task — assigned to whom\n\n## Decisions Made\n- List any decisions or agreements reached\n\n## Open Questions\n- Anything unresolved or needing follow-up\n\nKeep it concise and actionable.\n\n=== /volume1/screenpipe/pipes/standup-update/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Standup Update\ndescription: \"What you did, what's next, and any blockers\"\nicon: \"🏢\"\nfeatured: true\n---\n\nBased on my recordings from the last 24 hours, generate a standup update. Use limit=10 per search, max 3 searches total.\n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Yesterday\n- What I worked on (name specific projects, files, tools, PRs)\n\n## Today\n- What I will work on next (based on unfinished tasks and recent activity)\n\n## Blockers\n- Issues I hit — errors, slow builds, waiting on someone\n- If no blockers, write \"None\"\n\nKeep it under 150 words. Copy-paste ready for a team standup.\n\n=== /volume1/screenpipe/pipes/time-breakdown/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Time Breakdown\ndescription: \"Where your time went — by app, project, and category\"\nicon: \"⏱\"\nfeatured: false\n---\n\nAnalyze my app usage from today (last 12 hours). Use limit=10 per search, max 4 searches. Prefer /raw_sql with COUNT/GROUP BY queries.\n\nRead screenpipe skill first.\n\nUse this exact format with durations and percentages:\n\n## By Application\n- List each app with duration and percentage, sorted by time (e.g. \"VS Code: 2h 15min (28%)\")\n\n## By Category\n- Group into: coding, meetings, browsing, writing, communication, other\n- Show hours and percentage per category\n\n## By Project\n- Group related activities by project/topic. Name specific repos or tasks.\n\n## Productivity Score\n- Calculate: focused_work_hours / total_hours as a percentage\n- Focused = coding + writing. Unfocused = browsing + switching.\n\nEnd with: \"**Suggestion:** [one specific change to improve tomorrow's productivity]\"\n\n=== /volume1/screenpipe/pipes/video-export/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Export Video Clip\ndescription: \"Create a video of your recent screen activity\"\nicon: \"🎬\"\nfeatured: false\n---\n\nExport a video of my screen activity from the last 5 minutes.\n\nRead screenpipe skill first.\n\nUse the POST /frames/export endpoint with the time range and fps=1.0. Then show me the exported video file path as an inline code block so I can watch it.\n\nIf the export is large, suggest a lower fps or shorter time range.","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Now I have a clear picture. The pipes are markdown prompt templates in","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"/volume1/screenpipe/pipes/","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":", but there's no code to actually load and run them —","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"consumers/summary.py","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"has its own hardcoded prompts instead.","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Here's what I'll implement:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"consumers/pipes.py","depth":26,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"— dynamically loads pipe.md files and runs them via Claude (data injected as system message, pipe body as user prompt)","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"main.py","depth":26,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"— two new endpoints:","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"GET /api/pipes","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"and","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"POST /api/pipes/{pipe_id}/run","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"cli.py","depth":26,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"— a","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"pipe","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"command to run pipes from the terminal","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Let me build it:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Check browser_urls signature","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"cat /volume1/screenpipe/app/consumers/activity.py | grep \"def browser_urls\" -A 5","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"def browser_urls(\n for_date: date | None = None,\n app_name: str | None = None,\n ts_from: str | None = None,\n ts_to: str | None = None,\n limit: int = 30,","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Write","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"pipes.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"pipes.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"143 lines","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"\"\"\"Dynamic pipe loader and runner.\"\"\"\nimport os\nimport re\nfrom datetime import date\nfrom pathlib import Path\nfrom typing import Any\n\n\ndef _parse_frontmatter(text: str) -> tuple[dict, str]:\n if not text.startswith(\"---\"):\n return {}, text\n try:\n end = text.index(\"---\", 3)\n except ValueError:\n return {}, text\n fm_text = text[3:end].strip()\n body = text[end + 3:].strip()\n meta: dict = {}\n for line in fm_text.splitlines():\n if \":\" in line:\n k, _, v = line.partition(\":\")\n meta[k.strip()] = v.strip().strip('\"')\n return meta, body\n\n\ndef load_pipes(pipes_dir: Path) -> list[dict]:\n if not pipes_dir.exists():\n return []\n pipes = []\n for pipe_dir in sorted(pipes_dir.iterdir()):\n if not pipe_dir.is_dir() or pipe_dir.name.startswith(\".\"):\n continue\n pipe_md = pipe_dir / \"pipe.md\"\n if not pipe_md.exists():\n continue\n text = pipe_md.read_text(encoding=\"utf-8\")\n meta, body = _parse_frontmatter(text)\n if meta.get(\"enabled\", \"true\").lower() == \"false\":\n continue\n body = re.sub(r\"Read screenpipe skill first\\.?\\n?\", \"\", body).strip()\n pipes.append({\n \"id\": pipe_dir.name,\n \"title\": meta.get(\"title\", pipe_dir.name),\n \"description\": meta.get(\"description\", \"\"),\n \"icon\": meta.get(\"icon\", \"\"),\n \"schedule\": meta.get(\"schedule\", \"manual\"),\n \"featured\": meta.get(\"featured\", \"false\").lower() == \"true\",\n \"prompt\": body,\n })\n return pipes\n\n\ndef _build_system(d: date, stats: dict) -> str:\n from consumers.activity import app_time, browser_urls, ui_event_summary\n from consumers.ocr import deduplicated_text\n from consumers.audio import formatted_transcript\n\n apps = app_time(d)\n app_lines = \"\\n\".join(f\"- {a['app_name']}: {a['minutes']} min\" for a in apps[:20])\n\n urls = browser_urls(d, limit=20)\n url_lines = \"\\n\".join(f\"- {u['browser_url'][:100]} ({u['minutes']} min)\" for u in urls)\n\n ui_rows = ui_event_summary(d)\n ui_lines = \"\\n\".join(\n f\"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches\"\n for r in ui_rows[:15]\n )\n\n ocr_rows = deduplicated_text(d, chunk_minutes=5)\n ocr_lines = \"\\n\".join(\n f\"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}\"\n for r in ocr_rows[:100]\n )\n\n audio = formatted_transcript(d)\n if len(audio) > 3000:\n audio = audio[:3000]\n\n return f\"\"\"You are analyzing screenpipe data — recordings of a person's computer activity.\n\n## App usage (minutes per app):\n{app_lines or '(no app data)'}\n\n## Browser URLs visited:\n{url_lines or '(no browser data)'}\n\n## UI activity per app (clicks / keystrokes / app-switches):\n{ui_lines or '(no UI event data)'}\n\n## Screen content (sampled every 5 minutes):\n{ocr_lines or '(no screen data)'}\n\n## Audio / speech:\n{audio or '(no audio data)'}\n\nDate: {d}\nTotal frames recorded: {stats['total_frames']}\"\"\"\n\n\ndef run_pipe(\n pipe_id: str,\n for_date: date | None = None,\n api_key: str | None = None,\n pipes_dir: Path | None = None,\n) -> dict[str, Any]:\n import anthropic\n from consumers.activity import summary_stats\n\n d = for_date or date.today()\n key = api_key or os.environ.get(\"ANTHROPIC_API_KEY\", \"\")\n if not key:\n return {\"title\": \"Error\", \"content\": \"ANTHROPIC_API_KEY not set.\", \"date\": str(d)}\n\n _pipes_dir = pipes_dir or Path(os.environ.get(\"PIPES_DIR\", \"/data/pipes\"))\n all_pipes = {p[\"id\"]: p for p in load_pipes(_pipes_dir)}\n\n if pipe_id not in all_pipes:\n return {\"title\": \"Error\", \"content\": f\"Pipe not found: {pipe_id}\", \"date\": str(d)}\n\n pipe = all_pipes[pipe_id]\n stats = summary_stats(d)\n\n if stats[\"total_frames\"] == 0:\n return {\"title\": pipe[\"title\"], \"content\": f\"No screen data found for {d}.\", \"date\": str(d)}\n\n system = _build_system(d, stats)\n\n client = anthropic.Anthropic(api_key=key)\n message = client.messages.create(\n model=\"claude-haiku-4-5-20251001\",\n max_tokens=1024,\n system=system,\n messages=[{\"role\": \"user\", \"content\": pipe[\"prompt\"]}],\n )\n\n return {\n \"title\": pipe[\"title\"],\n \"content\": message.content[0].text,\n \"date\": str(d),\n \"stats\": stats,\n }","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Now add the API endpoints to","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"main.py","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":":","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Edit","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"main.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Added 1 line","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Edit","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"main.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Added 1 line","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Now add the pipe endpoints at the end of main.py, before the closing summary section:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Edit","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"main.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Added 14 lines","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Now add the CLI command to","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"cli.py","depth":23,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"cli.py","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":":","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Edit","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"cli.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"cli.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Added 40 lines","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Done. Here's how to run pipes:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXHeading","text":"How to run pipes","depth":22,"on_screen":false,"role_description":"heading"},{"role":"AXStaticText","text":"How to run pipes","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Via Docker (inside the running container):","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":23,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"docker exec -it screenpipe-app python cli.py pipe --list\ndocker exec -it screenpipe-app python cli.py pipe day-recap\ndocker exec -it screenpipe-app python cli.py pipe standup-update --date yesterday","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Via the API","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"(once the container is running on port 8766):","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":23,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
-8963375894614035486
|
-8691439177447798548
|
idle
|
accessibility
|
NULL
|
Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧ Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py
M
db.py
docker-compose.yml
Dockerfile
M
main.py
M
requirements.txt
M
data
logs
pipes
.gitignore
app_settings.json
archive.db
archive.db-bak
U
db.sqlite
db.sqlite-shm
db.sqlite-wal
screenpipe_sync_updated.sh
U
screenpipe_sync.sh
screenpipe.db
Outline Section
OUTLINE
OUTLINE
Timeline Section
TIMELINE
TIMELINE
app_settings.json, Editor Group 1
screenpipe_sync.sh, Editor Group 1
pipe.md, Editor Group 1
.env, Editor Group 1
[ENV_SECRET]
[ENV_SECRET]
Implement and run pipe l…, Editor Group 2
Problems (⇧⌘M)
PROBLEMS
Output (⇧⌘U)
OUTPUT
Debug Console (⇧⌘Y)
DEBUG CONSOLE
Terminal (⌃`)
TERMINAL
Ports - 1 forwarded port
PORTS
1
remote SSH: nas
SSH: nas
screenpipe (Git) - master*, Checkout Branch/Tag...
master*
screenpipe (Git) - Synchronize Changes
No Problems
0
0
Forwarded Ports: 8766
1
Notifications
Sign In
Sign In
Info: Setting up SSH Host nas: Setting up SSH tunnel
Implement and run pipe logic
Session history
New session
Message actions
main.py
main.py
lets implement logic with pipes. how can I run it?
Thinking
Thinking
Let me look at the current project structure to understand what's already in place.
Bash
List project files
IN
find /volume1/screenpipe -type f | head -50 && echo "---" && ls /volume1/screenpipe
Copy code to clipboard
OUT
/volume1/screenpipe/.DS_Store
/volume1/screenpipe/screenpipe.db
/volume1/screenpipe/screenpipe_sync.sh
/volume1/screenpipe/app_settings.json
/volume1/screenpipe/.gitignore
/volume1/screenpipe/archive.db
/volume1/screenpipe/db.sqlite
/volume1/screenpipe/db.sqlite-wal
/volume1/screenpipe/db.sqlite-shm
/volume1/screenpipe/#recycle/desktop.ini
/volume1/screenpipe/#recycle/db.sqlite
/volume1/screenpipe/#recycle/Copy #1 of db.sqlite
/volume1/screenpipe/#recycle/.DS_Store
/volume1/screenpipe/#recycle/Copy #2 of db.sqlite
/volume1/screenpipe/#recycle/archive.db
/volume1/screenpipe/#recycle/Copy #1 of archive.db
/volume1/screenpipe/#recycle/Copy #2 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of archive.db
/volume1/screenpipe/#recycle/Copy #4 of archive.db
/volume1/screenpipe/#recycle/Copy #5 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of db.sqlite
/volume1/screenpipe/#recycle/Copy #4 of db.sqlite
/volume1/screenpipe/#recycle/Copy #6 of archive.db
/volume1/screenpipe/#recycle/test.txt
/volume1/screenpipe/#recycle/Copy #7 of archive.db
/volume1/screenpipe/#recycle/Copy #8 of archive.db
/volume1/screenpipe/#recycle/archive.db-journal
/volume1/screenpipe/#recycle/Copy #1 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #2 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #3 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #4 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #6 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #7 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of db.sqlite
/volume1/screenpipe/pipes/.DS_Store
/volume1/screenpipe/app/.env
/volume1/screenpipe/app/cli.py
/volume1/screenpipe/app/.DS_Store
/volume1/screenpipe/app/db.py
/volume1/screenpipe/app/docker-compose.yml
/volume1/screenpipe/app/main.py
/volume1/screenpipe/app/requirements.txt
/volume1/screenpipe/app/Dockerfile
/volume1/screenpipe/data/.DS_Store
/volume1/screenpipe/.git/description
/volume1/screenpipe/.git/HEAD
/volume1/screenpipe/.git/index
/volume1/screenpipe/.git/COMMIT_EDITMSG
/volume1/screenpipe/#recycle/data/.DS_Store
---
app
app_settings.json
archive.db
data
db.sqlite
db.sqlite-shm
db.sqlite-wal
pipes
#recycle
screenpipe.db
screenpipe_sync.sh
Read
main.py
main.py
Bash
Check pipes directory and docker-compose
IN
ls /volume1/screenpipe/pipes/ && ls /volume1/screenpipe/app/ && cat /volume1/screenpipe/app/docker-compose.yml
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
cli.py
consumers
db.py
docker-compose.yml
Dockerfile
main.py
__pycache__
requirements.txt
static
services:
screenpipe-app:
build: .
container_name: screenpipe-app
restart: unless-stopped
ports:
- "8766:8000"
volumes:
- /volume1/screenpipe:/data
env_file:
- .env
environment:
TZ: Europe/Sofia
DB_PATH: /data/db.sqlite
sqlite-web-archive:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-archive
restart: unless-stopped
ports:
- "8767:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/archive.db"]
sqlite-web-live:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-live
restart: unless-stopped
ports:
- "8768:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/db.sqlite"]
Read
requirements.txt
requirements.txt
Bash
Inspect a pipe directory
IN
ls /volume1/screenpipe/pipes/day-recap/ && cat /volume1/screenpipe/pipes/day-recap/pipe.json 2>/dev/null || ls /volume1/screenpipe/pipes/day-recap/
Copy code to clipboard
OUT
pipe.md
pipe.md
Read
cli.py
cli.py
Bash
List all pipes and their contents
IN
ls /volume1/screenpipe/pipes/ && for d in /volume1/screenpipe/pipes/*/; do echo "=== $d ==="; ls "$d"; done
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
=== /volume1/screenpipe/pipes/ai-habits/ ===
pipe.md
=== /volume1/screenpipe/pipes/day-recap/ ===
pipe.md
=== /volume1/screenpipe/pipes/meeting-summary/ ===
pipe.md
=== /volume1/screenpipe/pipes/standup-update/ ===
pipe.md
=== /volume1/screenpipe/pipes/time-breakdown/ ===
pipe.md
=== /volume1/screenpipe/pipes/video-export/ ===
pipe.md
Bash
Read pipe markdown files
IN
cat /volume1/screenpipe/pipes/day-recap/pipe.md && echo "===" && cat /volume1/screenpipe/pipes/meeting-summary/pipe.md 2>/dev/null | head -50
Copy code to clipboard
OUT
---
schedule: manual
enabled: true
template: true
title: Day Recap
description: "Today's accomplishments, key moments, and unfinished work"
icon: "📋"
featured: true
---
Analyze my screen and audio recordings from today (last 16 hours only).
Read screenpipe skill first.
Use this exact format:
## Summary
One sentence: what I mainly did today.
## Accomplishments
- Top 3 things I finished, with timestamps (e.g. "2:30 PM")
- Name specific apps, files, or projects
## Key Moments
- Important things I saw, said, or heard — with timestamps
## Unfinished Work
- What I should continue tomorrow — name the app/file/task
## Patterns
- Apps I used most, topics that came up repeatedly
Only report what you can verify from the data. End with: "**Next step:** [most important thing to continue]"
===
---
schedule: manual
enabled: true
template: true
title: Meeting Summary
description: "Summarize meeting transcript with key takeaways and action items"
icon: "🤝"
featured: false
---
Summarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.
Read screenpipe skill first.
Use this exact format:
## Meeting Summary
One sentence: what this meeting was about.
## Key Takeaways
- Top 3-5 important points discussed
- Include who said what when relevant
## Action Items
- [ ] Task — assigned to whom, deadline if mentioned
- [ ] Task — assigned to whom
## Decisions Made
- List any decisions or agreements reached
## Open Questions
- Anything unresolved or needing follow-up
Keep it concise and actionable.
Thinking
Thinking
Bash
Read summary consumer
IN
ls /volume1/screenpipe/app/consumers/ && cat /volume1/screenpipe/app/consumers/summary.py
Copy code to clipboard
OUT
activity.py
audio.py
elements.py
__init__.py
interactions.py
ocr.py
__pycache__
report.py
summary.py
"""AI summary generator using Claude."""
import os
from datetime import date
from typing import Any
from consumers.activity import app_time, summary_stats, browser_urls, ui_event_summary
from consumers.ocr import deduplicated_text
from consumers.audio import formatted_transcript
SUMMARY_TYPES = {
"day_recap": {
"title": "Day Recap",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
## Audio/speech:
{audio}
Write a concise day recap using EXACTLY this format:
## Summary
One sentence: what I mainly worked on today.
## Accomplishments
- Top 3 things I finished, with approximate times
- Name specific apps, files, or projects
## Key Moments
- Important things seen or heard, with timestamps
## Unfinished Work
- What to continue tomorrow
## Patterns
- Apps used most, topics that came up repeatedly
Only report what you can verify from the data. End with:
**Next step:** [most important thing to continue]""",
},
"standup": {
"title": "Standup Update",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
## Audio/speech:
{audio}
Write a brief standup update:
**Yesterday:** What I worked on (2-3 bullets)
**Today:** What I plan to continue (1-2 bullets)
**Blockers:** Any issues observed (or "None")
Keep it under 150 words. Only report what's verifiable from the data.""",
},
"focus_time": {
"title": "Focus & Distraction Analysis",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
Analyze focus vs distraction patterns:
## Deep Work Periods
- When and how long were sustained focus sessions?
- What was being worked on?
## Distractions
- Which apps/sites were used recreationally?
- How much time was lost to context switching?
## Recommendations
- 2-3 concrete suggestions to improve focus tomorrow
Be specific with times and app names.""",
},
}
def _build_context(for_date: date) -> dict[str, str]:
apps = app_time(for_date)
app_lines = "\n".join(f"- {a['app_name']}: {a['minutes']} min" for a in apps[:20])
urls = browser_urls(for_date, limit=20)
url_lines = "\n".join(
f"- {u['browser_url'][:100]} ({u['minutes']} min)" for u in urls
)
ui_rows = ui_event_summary(for_date)
ui_lines = "\n".join(
f"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches"
for r in ui_rows[:15]
)
ocr_rows = deduplicated_text(for_date, chunk_minutes=5)
ocr_lines = "\n".join(
f"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}"
for r in ocr_rows[:100]
)
audio = formatted_transcript(for_date)
return {
"app_time": app_lines or "(no app data)",
"browser_urls": url_lines or "(no browser data)",
"ui_events": ui_lines or "(no UI event data)",
"ocr_text": ocr_lines or "(no screen data)",
"audio": audio[:3000] if len(audio) > 3000 else audio,
}
def generate(
summary_type: str = "day_recap",
for_date: date | None = None,
api_key: str | None = None,
) -> dict[str, Any]:
"""Generate an AI summary. Returns dict with 'title', 'content', 'date'."""
import anthropic
d = for_date or date.today()
key = api_key or os.environ.get("ANTHROPIC_API_KEY", "")
if not key:
return {
"title": "Error",
"content": "ANTHROPIC_API_KEY not set. Add it to your .env file.",
"date": str(d),
}
spec = SUMMARY_TYPES.get(summary_type)
if not spec:
return {"title": "Error", "content": f"Unknown summary type: {summary_type}", "date": str(d)}
stats = summary_stats(d)
if stats["total_frames"] == 0:
return {
"title": spec["title"],
"content": f"No screen data found for {d}.",
"date": str(d),
}
ctx = _build_context(d)
prompt = spec["prompt"].format(**ctx)
client = anthropic.Anthropic(api_key=key)
message = client.messages.create(
model="claude-haiku-4-5-20251001",
max_tokens=1024,
messages=[{"role": "user", "content": prompt}],
)
return {
"title": spec["title"],
"content": message.content[0].text,
"date": str(d),
"stats": stats,
}
Thinking
Thinking
Bash
Read all pipe.md files
IN
for f in /volume1/screenpipe/pipes/*/pipe.md; do echo "=== $f ==="; cat "$f"; echo; done
Copy code to clipboard
OUT
=== /volume1/screenpipe/pipes/ai-habits/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: AI Habits
description: "How you use AI tools — patterns and insights"
icon: "🤖"
featured: true
---
Search my recordings from the last 24 hours for AI tool usage. Use app_name filter for each tool separately: ChatGPT, Claude, Copilot, Cursor, Gemini, Perplexity. Use limit=5 per search, max 6 searches total.
Read screenpipe skill first.
Use this exact format:
## AI Tools Used
- List each tool with approximate time spent (e.g. "Claude: ~45min")
## What I Used Them For
- For each tool: coding, writing, research, or brainstorming
## Usage Patterns
- Do I switch between tools? Use them in bursts or steadily?
## Effectiveness
- Which tool appeared alongside completed work vs. abandoned attempts
If no AI usage is found, say so clearly. End with: "**Tip:** [one suggestion to use AI tools more effectively]"
=== /volume1/screenpipe/pipes/day-recap/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Day Recap
description: "Today's accomplishments, key moments, and unfinished work"
icon: "📋"
featured: true
---
Analyze my screen and audio recordings from today (last 16 hours only).
Read screenpipe skill first.
Use this exact format:
## Summary
One sentence: what I mainly did today.
## Accomplishments
- Top 3 things I finished, with timestamps (e.g. "2:30 PM")
- Name specific apps, files, or projects
## Key Moments
- Important things I saw, said, or heard — with timestamps
## Unfinished Work
- What I should continue tomorrow — name the app/file/task
## Patterns
- Apps I used most, topics that came up repeatedly
Only report what you can verify from the data. End with: "**Next step:** [most important thing to continue]"
=== /volume1/screenpipe/pipes/meeting-summary/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Meeting Summary
description: "Summarize meeting transcript with key takeaways and action items"
icon: "🤝"
featured: false
---
Summarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.
Read screenpipe skill first.
Use this exact format:
## Meeting Summary
One sentence: what this meeting was about.
## Key Takeaways
- Top 3-5 important points discussed
- Include who said what when relevant
## Action Items
- [ ] Task — assigned to whom, deadline if mentioned
- [ ] Task — assigned to whom
## Decisions Made
- List any decisions or agreements reached
## Open Questions
- Anything unresolved or needing follow-up
Keep it concise and actionable.
=== /volume1/screenpipe/pipes/standup-update/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Standup Update
description: "What you did, what's next, and any blockers"
icon: "🏢"
featured: true
---
Based on my recordings from the last 24 hours, generate a standup update. Use limit=10 per search, max 3 searches total.
Read screenpipe skill first.
Use this exact format:
## Yesterday
- What I worked on (name specific projects, files, tools, PRs)
## Today
- What I will work on next (based on unfinished tasks and recent activity)
## Blockers
- Issues I hit — errors, slow builds, waiting on someone
- If no blockers, write "None"
Keep it under 150 words. Copy-paste ready for a team standup.
=== /volume1/screenpipe/pipes/time-breakdown/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Time Breakdown
description: "Where your time went — by app, project, and category"
icon: "⏱"
featured: false
---
Analyze my app usage from today (last 12 hours). Use limit=10 per search, max 4 searches. Prefer /raw_sql with COUNT/GROUP BY queries.
Read screenpipe skill first.
Use this exact format with durations and percentages:
## By Application
- List each app with duration and percentage, sorted by time (e.g. "VS Code: 2h 15min (28%)")
## By Category
- Group into: coding, meetings, browsing, writing, communication, other
- Show hours and percentage per category
## By Project
- Group related activities by project/topic. Name specific repos or tasks.
## Productivity Score
- Calculate: focused_work_hours / total_hours as a percentage
- Focused = coding + writing. Unfocused = browsing + switching.
End with: "**Suggestion:** [one specific change to improve tomorrow's productivity]"
=== /volume1/screenpipe/pipes/video-export/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Export Video Clip
description: "Create a video of your recent screen activity"
icon: "🎬"
featured: false
---
Export a video of my screen activity from the last 5 minutes.
Read screenpipe skill first.
Use the POST /frames/export endpoint with the time range and fps=1.0. Then show me the exported video file path as an inline code block so I can watch it.
If the export is large, suggest a lower fps or shorter time range.
Thinking
Thinking
Now I have a clear picture. The pipes are markdown prompt templates in
/volume1/screenpipe/pipes/
, but there's no code to actually load and run them —
consumers/summary.py
has its own hardcoded prompts instead.
Here's what I'll implement:
consumers/pipes.py
— dynamically loads pipe.md files and runs them via Claude (data injected as system message, pipe body as user prompt)
main.py
— two new endpoints:
GET /api/pipes
and
POST /api/pipes/{pipe_id}/run
cli.py
— a
pipe
command to run pipes from the terminal
Let me build it:
Bash
Check browser_urls signature
IN
cat /volume1/screenpipe/app/consumers/activity.py | grep "def browser_urls" -A 5
Copy code to clipboard
OUT
def browser_urls(
for_date: date | None = None,
app_name: str | None = None,
ts_from: str | None = None,
ts_to: str | None = None,
limit: int = 30,
Write
pipes.py
pipes.py
143 lines
"""Dynamic pipe loader and runner."""
import os
import re
from datetime import date
from pathlib import Path
from typing import Any
def _parse_frontmatter(text: str) -> tuple[dict, str]:
if not text.startswith("---"):
return {}, text
try:
end = text.index("---", 3)
except ValueError:
return {}, text
fm_text = text[3:end].strip()
body = text[end + 3:].strip()
meta: dict = {}
for line in fm_text.splitlines():
if ":" in line:
k, _, v = line.partition(":")
meta[k.strip()] = v.strip().strip('"')
return meta, body
def load_pipes(pipes_dir: Path) -> list[dict]:
if not pipes_dir.exists():
return []
pipes = []
for pipe_dir in sorted(pipes_dir.iterdir()):
if not pipe_dir.is_dir() or pipe_dir.name.startswith("."):
continue
pipe_md = pipe_dir / "pipe.md"
if not pipe_md.exists():
continue
text = pipe_md.read_text(encoding="utf-8")
meta, body = _parse_frontmatter(text)
if meta.get("enabled", "true").lower() == "false":
continue
body = re.sub(r"Read screenpipe skill first\.?\n?", "", body).strip()
pipes.append({
"id": pipe_dir.name,
"title": meta.get("title", pipe_dir.name),
"description": meta.get("description", ""),
"icon": meta.get("icon", ""),
"schedule": meta.get("schedule", "manual"),
"featured": meta.get("featured", "false").lower() == "true",
"prompt": body,
})
return pipes
def _build_system(d: date, stats: dict) -> str:
from consumers.activity import app_time, browser_urls, ui_event_summary
from consumers.ocr import deduplicated_text
from consumers.audio import formatted_transcript
apps = app_time(d)
app_lines = "\n".join(f"- {a['app_name']}: {a['minutes']} min" for a in apps[:20])
urls = browser_urls(d, limit=20)
url_lines = "\n".join(f"- {u['browser_url'][:100]} ({u['minutes']} min)" for u in urls)
ui_rows = ui_event_summary(d)
ui_lines = "\n".join(
f"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches"
for r in ui_rows[:15]
)
ocr_rows = deduplicated_text(d, chunk_minutes=5)
ocr_lines = "\n".join(
f"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}"
for r in ocr_rows[:100]
)
audio = formatted_transcript(d)
if len(audio) > 3000:
audio = audio[:3000]
return f"""You are analyzing screenpipe data — recordings of a person's computer activity.
## App usage (minutes per app):
{app_lines or '(no app data)'}
## Browser URLs visited:
{url_lines or '(no browser data)'}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_lines or '(no UI event data)'}
## Screen content (sampled every 5 minutes):
{ocr_lines or '(no screen data)'}
## Audio / speech:
{audio or '(no audio data)'}
Date: {d}
Total frames recorded: {stats['total_frames']}"""
def run_pipe(
pipe_id: str,
for_date: date | None = None,
api_key: str | None = None,
pipes_dir: Path | None = None,
) -> dict[str, Any]:
import anthropic
from consumers.activity import summary_stats
d = for_date or date.today()
key = api_key or os.environ.get("ANTHROPIC_API_KEY", "")
if not key:
return {"title": "Error", "content": "ANTHROPIC_API_KEY not set.", "date": str(d)}
_pipes_dir = pipes_dir or Path(os.environ.get("PIPES_DIR", "/data/pipes"))
all_pipes = {p["id"]: p for p in load_pipes(_pipes_dir)}
if pipe_id not in all_pipes:
return {"title": "Error", "content": f"Pipe not found: {pipe_id}", "date": str(d)}
pipe = all_pipes[pipe_id]
stats = summary_stats(d)
if stats["total_frames"] == 0:
return {"title": pipe["title"], "content": f"No screen data found for {d}.", "date": str(d)}
system = _build_system(d, stats)
client = anthropic.Anthropic(api_key=key)
message = client.messages.create(
model="claude-haiku-4-5-20251001",
max_tokens=1024,
system=system,
messages=[{"role": "user", "content": pipe["prompt"]}],
)
return {
"title": pipe["title"],
"content": message.content[0].text,
"date": str(d),
"stats": stats,
}
Now add the API endpoints to
main.py
:
Edit
main.py
main.py
Added 1 line
Edit
main.py
main.py
Added 1 line
Now add the pipe endpoints at the end of main.py, before the closing summary section:
Edit
main.py
main.py
Added 14 lines
Now add the CLI command to
cli.py
cli.py
:
Edit
cli.py
cli.py
Added 40 lines
Done. Here's how to run pipes:
How to run pipes
How to run pipes
Via Docker (inside the running container):
Copy code to clipboard
docker exec -it screenpipe-app python cli.py pipe --list
docker exec -it screenpipe-app python cli.py pipe day-recap
docker exec -it screenpipe-app python cli.py pipe standup-update --date yesterday
Via the API
(once the container is running on port 8766):
Copy code to clipboard...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
21067
|
921
|
4
|
2026-05-11T17:08:06.091583+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-11/1778 /Users/lukas/.screenpipe/data/data/2026-05-11/1778519286091_m2.jpg...
|
Code
|
Implement and run pipe l… — screenpipe [SSH: nas]
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧ Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py
M
db.py
docker-compose.yml
Dockerfile
M
main.py
M
requirements.txt
M
data
logs
pipes
.gitignore
app_settings.json
archive.db
archive.db-bak
U
db.sqlite
db.sqlite-shm
db.sqlite-wal
screenpipe_sync_updated.sh
U
screenpipe_sync.sh
screenpipe.db
Outline Section
OUTLINE
OUTLINE
Timeline Section
TIMELINE
TIMELINE
app_settings.json, Editor Group 1
screenpipe_sync.sh, Editor Group 1
pipe.md, Editor Group 1
.env, Editor Group 1
[ENV_SECRET]
[ENV_SECRET]
Implement and run pipe l…, Editor Group 2
Problems (⇧⌘M)
PROBLEMS
Output (⇧⌘U)
OUTPUT
Debug Console (⇧⌘Y)
DEBUG CONSOLE
Terminal (⌃`)
TERMINAL
Ports - 1 forwarded port
PORTS
1
remote SSH: nas
SSH: nas
screenpipe (Git) - master*, Checkout Branch/Tag...
master*
screenpipe (Git) - Synchronize Changes
No Problems
0
0
Forwarded Ports: 8766
1
Notifications
Sign In
Sign In
Info: Setting up SSH Host nas: Setting up SSH tunnel
Implement and run pipe logic
Session history
New session
Message actions
main.py
main.py
lets implement logic with pipes. how can I run it?
Thinking
Thinking
Let me look at the current project structure to understand what's already in place.
Bash
List project files
IN
find /volume1/screenpipe -type f | head -50 && echo "---" && ls /volume1/screenpipe
Copy code to clipboard
OUT
/volume1/screenpipe/.DS_Store
/volume1/screenpipe/screenpipe.db
/volume1/screenpipe/screenpipe_sync.sh
/volume1/screenpipe/app_settings.json
/volume1/screenpipe/.gitignore
/volume1/screenpipe/archive.db
/volume1/screenpipe/db.sqlite
/volume1/screenpipe/db.sqlite-wal
/volume1/screenpipe/db.sqlite-shm
/volume1/screenpipe/#recycle/desktop.ini
/volume1/screenpipe/#recycle/db.sqlite
/volume1/screenpipe/#recycle/Copy #1 of db.sqlite
/volume1/screenpipe/#recycle/.DS_Store
/volume1/screenpipe/#recycle/Copy #2 of db.sqlite
/volume1/screenpipe/#recycle/archive.db
/volume1/screenpipe/#recycle/Copy #1 of archive.db
/volume1/screenpipe/#recycle/Copy #2 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of archive.db
/volume1/screenpipe/#recycle/Copy #4 of archive.db
/volume1/screenpipe/#recycle/Copy #5 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of db.sqlite
/volume1/screenpipe/#recycle/Copy #4 of db.sqlite
/volume1/screenpipe/#recycle/Copy #6 of archive.db
/volume1/screenpipe/#recycle/test.txt
/volume1/screenpipe/#recycle/Copy #7 of archive.db
/volume1/screenpipe/#recycle/Copy #8 of archive.db
/volume1/screenpipe/#recycle/archive.db-journal
/volume1/screenpipe/#recycle/Copy #1 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #2 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #3 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #4 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #6 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #7 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of db.sqlite
/volume1/screenpipe/pipes/.DS_Store
/volume1/screenpipe/app/.env
/volume1/screenpipe/app/cli.py
/volume1/screenpipe/app/.DS_Store
/volume1/screenpipe/app/db.py
/volume1/screenpipe/app/docker-compose.yml
/volume1/screenpipe/app/main.py
/volume1/screenpipe/app/requirements.txt
/volume1/screenpipe/app/Dockerfile
/volume1/screenpipe/data/.DS_Store
/volume1/screenpipe/.git/description
/volume1/screenpipe/.git/HEAD
/volume1/screenpipe/.git/index
/volume1/screenpipe/.git/COMMIT_EDITMSG
/volume1/screenpipe/#recycle/data/.DS_Store
---
app
app_settings.json
archive.db
data
db.sqlite
db.sqlite-shm
db.sqlite-wal
pipes
#recycle
screenpipe.db
screenpipe_sync.sh
Read
main.py
main.py
Bash
Check pipes directory and docker-compose
IN
ls /volume1/screenpipe/pipes/ && ls /volume1/screenpipe/app/ && cat /volume1/screenpipe/app/docker-compose.yml
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
cli.py
consumers
db.py
docker-compose.yml
Dockerfile
main.py
__pycache__
requirements.txt
static
services:
screenpipe-app:
build: .
container_name: screenpipe-app
restart: unless-stopped
ports:
- "8766:8000"
volumes:
- /volume1/screenpipe:/data
env_file:
- .env
environment:
TZ: Europe/Sofia
DB_PATH: /data/db.sqlite
sqlite-web-archive:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-archive
restart: unless-stopped
ports:
- "8767:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/archive.db"]
sqlite-web-live:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-live
restart: unless-stopped
ports:
- "8768:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/db.sqlite"]
Read
requirements.txt
requirements.txt
Bash
Inspect a pipe directory
IN
ls /volume1/screenpipe/pipes/day-recap/ && cat /volume1/screenpipe/pipes/day-recap/pipe.json 2>/dev/null || ls /volume1/screenpipe/pipes/day-recap/
Copy code to clipboard
OUT
pipe.md
pipe.md
Read
cli.py
cli.py
Bash
List all pipes and their contents
IN
ls /volume1/screenpipe/pipes/ && for d in /volume1/screenpipe/pipes/*/; do echo "=== $d ==="; ls "$d"; done
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
=== /volume1/screenpipe/pipes/ai-habits/ ===
pipe.md
=== /volume1/screenpipe/pipes/day-recap/ ===
pipe.md
=== /volume1/screenpipe/pipes/meeting-summary/ ===
pipe.md
=== /volume1/screenpipe/pipes/standup-update/ ===
pipe.md
=== /volume1/screenpipe/pipes/time-breakdown/ ===
pipe.md
=== /volume1/screenpipe/pipes/video-export/ ===
pipe.md
Bash
Read pipe markdown files
IN
cat /volume1/screenpipe/pipes/day-recap/pipe.md && echo "===" && cat /volume1/screenpipe/pipes/meeting-summary/pipe.md 2>/dev/null | head -50
Copy code to clipboard
OUT
---
schedule: manual
enabled: true
template: true
title: Day Recap
description: "Today's accomplishments, key moments, and unfinished work"
icon: "📋"
featured: true
---
Analyze my screen and audio recordings from today (last 16 hours only).
Read screenpipe skill first.
Use this exact format:
## Summary
One sentence: what I mainly did today.
## Accomplishments
- Top 3 things I finished, with timestamps (e.g. "2:30 PM")
- Name specific apps, files, or projects
## Key Moments
- Important things I saw, said, or heard — with timestamps
## Unfinished Work
- What I should continue tomorrow — name the app/file/task
## Patterns
- Apps I used most, topics that came up repeatedly
Only report what you can verify from the data. End with: "**Next step:** [most important thing to continue]"
===
---
schedule: manual
enabled: true
template: true
title: Meeting Summary
description: "Summarize meeting transcript with key takeaways and action items"
icon: "🤝"
featured: false
---
Summarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.
Read screenpipe skill first.
Use this exact format:
## Meeting Summary
One sentence: what this meeting was about.
## Key Takeaways
- Top 3-5 important points discussed
- Include who said what when relevant
## Action Items
- [ ] Task — assigned to whom, deadline if mentioned
- [ ] Task — assigned to whom
## Decisions Made
- List any decisions or agreements reached
## Open Questions
- Anything unresolved or needing follow-up
Keep it concise and actionable.
Thinking
Thinking
Bash
Read summary consumer
IN
ls /volume1/screenpipe/app/consumers/ && cat /volume1/screenpipe/app/consumers/summary.py
Copy code to clipboard
OUT
activity.py
audio.py
elements.py
__init__.py
interactions.py
ocr.py
__pycache__
report.py
summary.py
"""AI summary generator using Claude."""
import os
from datetime import date
from typing import Any
from consumers.activity import app_time, summary_stats, browser_urls, ui_event_summary
from consumers.ocr import deduplicated_text
from consumers.audio import formatted_transcript
SUMMARY_TYPES = {
"day_recap": {
"title": "Day Recap",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
## Audio/speech:
{audio}
Write a concise day recap using EXACTLY this format:
## Summary
One sentence: what I mainly worked on today.
## Accomplishments
- Top 3 things I finished, with approximate times
- Name specific apps, files, or projects
## Key Moments
- Important things seen or heard, with timestamps
## Unfinished Work
- What to continue tomorrow
## Patterns
- Apps used most, topics that came up repeatedly
Only report what you can verify from the data. End with:
**Next step:** [most important thing to continue]""",
},
"standup": {
"title": "Standup Update",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
## Audio/speech:
{audio}
Write a brief standup update:
**Yesterday:** What I worked on (2-3 bullets)
**Today:** What I plan to continue (1-2 bullets)
**Blockers:** Any issues observed (or "None")
Keep it under 150 words. Only report what's verifiable from the data.""",
},
"focus_time": {
"title": "Focus & Distraction Analysis",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
Analyze focus vs distraction patterns:
## Deep Work Periods
- When and how long were sustained focus sessions?
- What was being worked on?
## Distractions
- Which apps/sites were used recreationally?
- How much time was lost to context switching?
## Recommendations
- 2-3 concrete suggestions to improve focus tomorrow
Be specific with times and app names.""",
},
}
def _build_context(for_date: date) -> dict[str, str]:
apps = app_time(for_date)
app_lines = "\n".join(f"- {a['app_name']}: {a['minutes']} min" for a in apps[:20])
urls = browser_urls(for_date, limit=20)
url_lines = "\n".join(
f"- {u['browser_url'][:100]} ({u['minutes']} min)" for u in urls
)
ui_rows = ui_event_summary(for_date)
ui_lines = "\n".join(
f"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches"
for r in ui_rows[:15]
)
ocr_rows = deduplicated_text(for_date, chunk_minutes=5)
ocr_lines = "\n".join(
f"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}"
for r in ocr_rows[:100]
)
audio = formatted_transcript(for_date)
return {
"app_time": app_lines or "(no app data)",
"browser_urls": url_lines or "(no browser data)",
"ui_events": ui_lines or "(no UI event data)",
"ocr_text": ocr_lines or "(no screen data)",
"audio": audio[:3000] if len(audio) > 3000 else audio,
}
def generate(
summary_type: str = "day_recap",
for_date: date | None = None,
api_key: str | None = None,
) -> dict[str, Any]:
"""Generate an AI summary. Returns dict with 'title', 'content', 'date'."""
import anthropic
d = for_date or date.today()
key = api_key or os.environ.get("ANTHROPIC_API_KEY", "")
if not key:
return {
"title": "Error",
"content": "ANTHROPIC_API_KEY not set. Add it to your .env file.",
"date": str(d),
}
spec = SUMMARY_TYPES.get(summary_type)
if not spec:
return {"title": "Error", "content": f"Unknown summary type: {summary_type}", "date": str(d)}
stats = summary_stats(d)
if stats["total_frames"] == 0:
return {
"title": spec["title"],
"content": f"No screen data found for {d}.",
"date": str(d),
}
ctx = _build_context(d)
prompt = spec["prompt"].format(**ctx)
client = anthropic.Anthropic(api_key=key)
message = client.messages.create(
model="claude-haiku-4-5-20251001",
max_tokens=1024,
messages=[{"role": "user", "content": prompt}],
)
return {
"title": spec["title"],
"content": message.content[0].text,
"date": str(d),
"stats": stats,
}
Thinking
Thinking
Bash
Read all pipe.md files
IN
for f in /volume1/screenpipe/pipes/*/pipe.md; do echo "=== $f ==="; cat "$f"; echo; done
Copy code to clipboard
OUT
=== /volume1/screenpipe/pipes/ai-habits/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: AI Habits
description: "How you use AI tools — patterns and insights"
icon: "🤖"
featured: true
---
Search my recordings from the last 24 hours for AI tool usage. Use app_name filter for each tool separately: ChatGPT, Claude, Copilot, Cursor, Gemini, Perplexity. Use limit=5 per search, max 6 searches total.
Read screenpipe skill first.
Use this exact format:
## AI Tools Used
- List each tool with approximate time spent (e.g. "Claude: ~45min")
## What I Used Them For
- For each tool: coding, writing, research, or brainstorming
## Usage Patterns
- Do I switch between tools? Use them in bursts or steadily?
## Effectiveness
- Which tool appeared alongside completed work vs. abandoned attempts
If no AI usage is found, say so clearly. End with: "**Tip:** [one suggestion to use AI tools more effectively]"
=== /volume1/screenpipe/pipes/day-recap/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Day Recap
description: "Today's accomplishments, key moments, and unfinished work"
icon: "📋"
featured: true
---
Analyze my screen and audio recordings from today (last 16 hours only).
Read screenpipe skill first.
Use this exact format:
## Summary
One sentence: what I mainly did today.
## Accomplishments
- Top 3 things I finished, with timestamps (e.g. "2:30 PM")
- Name specific apps, files, or projects
## Key Moments
- Important things I saw, said, or heard — with timestamps
## Unfinished Work
- What I should continue tomorrow — name the app/file/task
## Patterns
- Apps I used most, topics that came up repeatedly
Only report what you can verify from the data. End with: "**Next step:** [most important thing to continue]"
=== /volume1/screenpipe/pipes/meeting-summary/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Meeting Summary
description: "Summarize meeting transcript with key takeaways and action items"
icon: "🤝"
featured: false
---
Summarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.
Read screenpipe skill first.
Use this exact format:
## Meeting Summary
One sentence: what this meeting was about.
## Key Takeaways
- Top 3-5 important points discussed
- Include who said what when relevant
## Action Items
- [ ] Task — assigned to whom, deadline if mentioned
- [ ] Task — assigned to whom
## Decisions Made
- List any decisions or agreements reached
## Open Questions
- Anything unresolved or needing follow-up
Keep it concise and actionable.
=== /volume1/screenpipe/pipes/standup-update/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Standup Update
description: "What you did, what's next, and any blockers"
icon: "🏢"
featured: true
---
Based on my recordings from the last 24 hours, generate a standup update. Use limit=10 per search, max 3 searches total.
Read screenpipe skill first.
Use this exact format:
## Yesterday
- What I worked on (name specific projects, files, tools, PRs)
## Today
- What I will work on next (based on unfinished tasks and recent activity)
## Blockers
- Issues I hit — errors, slow builds, waiting on someone
- If no blockers, write "None"
Keep it under 150 words. Copy-paste ready for a team standup.
=== /volume1/screenpipe/pipes/time-breakdown/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Time Breakdown
description: "Where your time went — by app, project, and category"
icon: "⏱"
featured: false
---
Analyze my app usage from today (last 12 hours). Use limit=10 per search, max 4 searches. Prefer /raw_sql with COUNT/GROUP BY queries.
Read screenpipe skill first.
Use this exact format with durations and percentages:
## By Application
- List each app with duration and percentage, sorted by time (e.g. "VS Code: 2h 15min (28%)")
## By Category
- Group into: coding, meetings, browsing, writing, communication, other
- Show hours and percentage per category
## By Project
- Group related activities by project/topic. Name specific repos or tasks.
## Productivity Score
- Calculate: focused_work_hours / total_hours as a percentage
- Focused = coding + writing. Unfocused = browsing + switching.
End with: "**Suggestion:** [one specific change to improve tomorrow's productivity]"
=== /volume1/screenpipe/pipes/video-export/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Export Video Clip
description: "Create a video of your recent screen activity"
icon: "🎬"
featured: false
---
Export a video of my screen activity from the last 5 minutes.
Read screenpipe skill first.
Use the POST /frames/export endpoint with the time range and fps=1.0. Then show me the exported video file path as an inline code block so I can watch it.
If the export is large, suggest a lower fps or shorter time range.
Thinking
Thinking
Now I have a clear picture. The pipes are markdown prompt templates in
/volume1/screenpipe/pipes/
, but there's no code to actually load and run them —
consumers/summary.py
has its own hardcoded prompts instead.
Here's what I'll implement:
consumers/pipes.py
— dynamically loads pipe.md files and runs them via Claude (data injected as system message, pipe body as user prompt)
main.py
— two new endpoints:
GET /api/pipes
and
POST /api/pipes/{pipe_id}/run
cli.py
— a
pipe
command to run pipes from the terminal
Let me build it:
Bash
Check browser_urls signature
IN
cat /volume1/screenpipe/app/consumers/activity.py | grep "def browser_urls" -A 5
Copy code to clipboard
OUT
def browser_urls(
for_date: date | None = None,
app_name: str | None = None,
ts_from: str | None = None,
ts_to: str | None = None,
limit: int = 30,
Write
pipes.py
pipes.py
143 lines
"""Dynamic pipe loader and runner."""
import os
import re
from datetime import date
from pathlib import Path
from typing import Any
def _parse_frontmatter(text: str) -> tuple[dict, str]:
if not text.startswith("---"):
return {}, text
try:
end = text.index("---", 3)
except ValueError:
return {}, text
fm_text = text[3:end].strip()
body = text[end + 3:].strip()
meta: dict = {}
for line in fm_text.splitlines():
if ":" in line:
k, _, v = line.partition(":")
meta[k.strip()] = v.strip().strip('"')
return meta, body
def load_pipes(pipes_dir: Path) -> list[dict]:
if not pipes_dir.exists():
return []
pipes = []
for pipe_dir in sorted(pipes_dir.iterdir()):
if not pipe_dir.is_dir() or pipe_dir.name.startswith("."):
continue
pipe_md = pipe_dir / "pipe.md"
if not pipe_md.exists():
continue
text = pipe_md.read_text(encoding="utf-8")
meta, body = _parse_frontmatter(text)
if meta.get("enabled", "true").lower() == "false":
continue
body = re.sub(r"Read screenpipe skill first\.?\n?", "", body).strip()
pipes.append({
"id": pipe_dir.name,
"title": meta.get("title", pipe_dir.name),
"description": meta.get("description", ""),
"icon": meta.get("icon", ""),
"schedule": meta.get("schedule", "manual"),
"featured": meta.get("featured", "false").lower() == "true",
"prompt": body,
})
return pipes
def _build_system(d: date, stats: dict) -> str:
from consumers.activity import app_time, browser_urls, ui_event_summary
from consumers.ocr import deduplicated_text
from consumers.audio import formatted_transcript
apps = app_time(d)
app_lines = "\n".join(f"- {a['app_name']}: {a['minutes']} min" for a in apps[:20])
urls = browser_urls(d, limit=20)
url_lines = "\n".join(f"- {u['browser_url'][:100]} ({u['minutes']} min)" for u in urls)
ui_rows = ui_event_summary(d)
ui_lines = "\n".join(
f"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches"
for r in ui_rows[:15]
)
ocr_rows = deduplicated_text(d, chunk_minutes=5)
ocr_lines = "\n".join(
f"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}"
for r in ocr_rows[:100]
)
audio = formatted_transcript(d)
if len(audio) > 3000:
audio = audio[:3000]
return f"""You are analyzing screenpipe data — recordings of a person's computer activity.
## App usage (minutes per app):
{app_lines or '(no app data)'}
## Browser URLs visited:
{url_lines or '(no browser data)'}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_lines or '(no UI event data)'}
## Screen content (sampled every 5 minutes):
{ocr_lines or '(no screen data)'}
## Audio / speech:
{audio or '(no audio data)'}
Date: {d}
Total frames recorded: {stats['total_frames']}"""
def run_pipe(
pipe_id: str,
for_date: date | None = None,
api_key: str | None = None,
pipes_dir: Path | None = None,
) -> dict[str, Any]:
import anthropic
from consumers.activity import summary_stats
d = for_date or date.today()
key = api_key or os.environ.get("ANTHROPIC_API_KEY", "")
if not key:
return {"title": "Error", "content": "ANTHROPIC_API_KEY not set.", "date": str(d)}
_pipes_dir = pipes_dir or Path(os.environ.get("PIPES_DIR", "/data/pipes"))
all_pipes = {p["id"]: p for p in load_pipes(_pipes_dir)}
if pipe_id not in all_pipes:
return {"title": "Error", "content": f"Pipe not found: {pipe_id}", "date": str(d)}
pipe = all_pipes[pipe_id]
stats = summary_stats(d)
if stats["total_frames"] == 0:
return {"title": pipe["title"], "content": f"No screen data found for {d}.", "date": str(d)}
system = _build_system(d, stats)
client = anthropic.Anthropic(api_key=key)
message = client.messages.create(
model="claude-haiku-4-5-20251001",
max_tokens=1024,
system=system,
messages=[{"role": "user", "content": pipe["prompt"]}],
)
return {
"title": pipe["title"],
"content": message.content[0].text,
"date": str(d),
"stats": stats,
}
Now add the API endpoints to
main.py
:
Edit
main.py
main.py
Added 1 line
Edit
main.py
main.py
Added 1 line
Now add the pipe endpoints at the end of main.py, before the closing summary section:
Edit
main.py
main.py
Added 14 lines
Now add the CLI command to
cli.py
cli.py
:
Edit
cli.py
cli.py
Added 40 lines
Done. Here's how to run pipes:
How to run pipes
How to run pipes
Via Docker (inside the running container):
Copy code to clipboard
docker exec -it screenpipe-app python cli.py pipe --list
docker exec -it screenpipe-app python cli.py pipe day-recap
docker exec -it screenpipe-app python cli.py pipe standup-update --date yesterday
Via the API
(once the container is running on port 8766):
Copy code to clipboard
# List pipes
curl http://localhost:8766/api/pipes
# Run a pipe
curl -X POST "http://localhost:8766/api/pipes/day-recap/run"
curl -X POST "http://localhost:8766/api/pipes/standup-update/run?d=2026-04-25"
Rebuild and restart
to pick up the changes:
Copy code to clipboard
cd /volume1/screenpipe/app
docker compose up --build -d
How it works:
Each
pipe.md
file is loaded dynamically — the frontmatter provides metadata and the body becomes the user prompt. Screenpipe data (app usage, browser URLs, OCR, audio) is injected as a Claude system message so the pipe prompt can reference it naturally. The "Read screenpipe skill first" line is stripped automatically.
The pipes directory inside Docker is
/data/pipes
(since
/volume1/screenpipe
→
/data
). You can override it with a
PIPES_DIR
env var if needed.
Message actions
pipe.md
pipe.md
where to place api key and can I use different keys
Thinking
Thinking
Bash
Read .env file
IN
cat /volume1/screenpipe/app/.env
Copy code to clipboard
OUT
[ENV_SECRET]
Where to place the key:
app/.env
app/.env
— replace
your_key_here
with your actual key:
Copy code to clipboard
[ENV_SECRET]
That file is loaded by
load_dotenv()
at startup and is excluded from git via
.gitignore
.
Can you use different keys per pipe?
Not currently — all pipes share the one key from
.env
. But you can add per-pipe key support by adding an
api_key
field to the pipe's frontmatter:
Copy code to clipboard
---
title: Meeting Summary
api_key_env: ANTHROPIC_KEY_MEETINGS
---
Then in
consumers/pipes.py
consumers/pipes.py
, read it in
_parse_frontmatter
and pass it through
run_pipe
. Want me to add that?
Message actions
pipe.md
pipe.md
can I use mistral or other llm? or is is build for antrophic only
Thinking
Thinking
Currently it's Anthropic-only — the code calls the
anthropic
SDK directly in both
consumers/pipes.py
consumers/pipes.py
and
consumers/summary.py
consumers/summary.py
.
Adding other providers is straightforward since Mistral, Ollama, OpenRouter, Groq, and most modern LLMs expose an OpenAI-compatible API. The cleanest approach: add the
openai
package and let you configure the provider via
.env
:...
|
[{"role":"AXRadioButton","text [{"role":"AXRadioButton","text":"Explorer (⇧⌘E)","depth":19,"bounds":{"left":0.0,"top":0.047885075,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":true},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.057462092,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Search (⇧⌘F)","depth":19,"bounds":{"left":0.0,"top":0.08619314,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.09577015,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Source Control (⌃⇧G) - 10 pending changes","depth":19,"bounds":{"left":0.0,"top":0.1245012,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.13407822,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"10","depth":22,"bounds":{"left":0.00831117,"top":0.1452514,"width":0.003656915,"height":0.008778931},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.00831117,"top":0.14604948,"width":0.0016622341,"height":0.007980846}},{"char_start":1,"char_count":1,"bounds":{"left":0.009973404,"top":0.14604948,"width":0.0023271276,"height":0.007980846}}],"role_description":"text"},{"role":"AXRadioButton","text":"Run and Debug (⇧⌘D)","depth":19,"bounds":{"left":0.0,"top":0.16280925,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.17238627,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Remote Explorer","depth":19,"bounds":{"left":0.0,"top":0.20111732,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.21069433,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Extensions (⇧⌘X) - 2 require update","depth":19,"bounds":{"left":0.0,"top":0.23942538,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.2490024,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"2","depth":22,"bounds":{"left":0.009640957,"top":0.2601756,"width":0.0019946808,"height":0.008778931},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Claude Code","depth":19,"bounds":{"left":0.0,"top":0.27773345,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"Containers","depth":19,"bounds":{"left":0.0,"top":0.3160415,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXHeading","text":"EXPLORER","depth":17,"bounds":{"left":0.022606382,"top":0.047885075,"width":0.018949468,"height":0.02793296},"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"EXPLORER","depth":18,"bounds":{"left":0.022606382,"top":0.056664005,"width":0.018949468,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.022606382,"top":0.056664005,"width":0.0023271276,"height":0.0103751}},{"char_start":1,"char_count":7,"bounds":{"left":0.024933511,"top":0.056664005,"width":0.01662234,"height":0.0103751}}],"role_description":"text"},{"role":"AXButton","text":"Explorer Section: screenpipe [SSH: nas]","depth":21,"bounds":{"left":0.015957447,"top":0.07581804,"width":0.09940159,"height":0.017557861},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":true},{"role":"AXStaticText","text":"","depth":23,"bounds":{"left":0.01662234,"top":0.07821229,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"Explorer Section: screenpipe [SSH: nas]","depth":22,"bounds":{"left":0.022606382,"top":0.07581804,"width":0.045877658,"height":0.017557861},"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"SCREENPIPE [SSH: NAS]","depth":23,"bounds":{"left":0.022606382,"top":0.079010375,"width":0.045877658,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.022606382,"top":0.07980846,"width":0.0026595744,"height":0.0103751}},{"char_start":1,"char_count":20,"bounds":{"left":0.025265958,"top":0.07980846,"width":0.043218084,"height":0.0103751}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.09577015,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"#recycle","depth":27,"bounds":{"left":0.025930852,"top":0.09577015,"width":0.017287234,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.096568234,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":7,"bounds":{"left":0.028590426,"top":0.096568234,"width":0.01462766,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.11332801,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"app","depth":27,"bounds":{"left":0.025930852,"top":0.11332801,"width":0.0076462766,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.11412609,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":2,"bounds":{"left":0.02825798,"top":0.11412609,"width":0.005319149,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.11412609,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.022273935,"top":0.13088587,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"__pycache__","depth":27,"bounds":{"left":0.028590426,"top":0.13088587,"width":0.026595745,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.13168396,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":10,"bounds":{"left":0.030917553,"top":0.13168396,"width":0.024268618,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.022273935,"top":0.14844373,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"consumers","depth":27,"bounds":{"left":0.028590426,"top":0.14844373,"width":0.022273935,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.14924182,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":8,"bounds":{"left":0.030917553,"top":0.14924182,"width":0.019946808,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.14924182,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.022273935,"top":0.1660016,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"static","depth":27,"bounds":{"left":0.028590426,"top":0.1660016,"width":0.010970744,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.16679968,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":5,"bounds":{"left":0.030917553,"top":0.16679968,"width":0.008976064,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.16679968,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.1819633,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":".env","depth":27,"bounds":{"left":0.028590426,"top":0.18355946,"width":0.00831117,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.18435754,"width":0.0013297872,"height":0.011971269}},{"char_start":1,"char_count":3,"bounds":{"left":0.029920213,"top":0.18435754,"width":0.006981383,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.19952115,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"cli.py","depth":27,"bounds":{"left":0.028590426,"top":0.20111732,"width":0.010638298,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.2019154,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":5,"bounds":{"left":0.030917553,"top":0.2019154,"width":0.00831117,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.2019154,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.21707901,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.py","depth":27,"bounds":{"left":0.028590426,"top":0.21867518,"width":0.011303191,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.21947326,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":4,"bounds":{"left":0.03125,"top":0.21947326,"width":0.008643617,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.23463687,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"docker-compose.yml","depth":27,"bounds":{"left":0.028590426,"top":0.23623304,"width":0.042220745,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.23703113,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":17,"bounds":{"left":0.03125,"top":0.23703113,"width":0.03956117,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.25219473,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Dockerfile","depth":27,"bounds":{"left":0.028590426,"top":0.25379092,"width":0.020611702,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.254589,"width":0.0033244682,"height":0.011971269}},{"char_start":1,"char_count":9,"bounds":{"left":0.031914894,"top":0.254589,"width":0.017287234,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.254589,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.2697526,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"main.py","depth":27,"bounds":{"left":0.028590426,"top":0.27134877,"width":0.015625,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.27214685,"width":0.003656915,"height":0.011971269}},{"char_start":1,"char_count":6,"bounds":{"left":0.032247342,"top":0.27214685,"width":0.012300532,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.27214685,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.28731045,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"requirements.txt","depth":27,"bounds":{"left":0.028590426,"top":0.28890663,"width":0.032912236,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.2897047,"width":0.0016622341,"height":0.011971269}},{"char_start":1,"char_count":15,"bounds":{"left":0.03025266,"top":0.2897047,"width":0.03158245,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.2897047,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.3064645,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"data","depth":27,"bounds":{"left":0.025930852,"top":0.3064645,"width":0.008976064,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.30726257,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":3,"bounds":{"left":0.028590426,"top":0.30726257,"width":0.0063164895,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.32402235,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"logs","depth":27,"bounds":{"left":0.025930852,"top":0.32402235,"width":0.00831117,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.32482043,"width":0.0009973404,"height":0.011971269}},{"char_start":1,"char_count":3,"bounds":{"left":0.026928192,"top":0.32482043,"width":0.0076462766,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.32482043,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.3415802,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"pipes","depth":27,"bounds":{"left":0.025930852,"top":0.3415802,"width":0.010970744,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.3423783,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":4,"bounds":{"left":0.028590426,"top":0.3423783,"width":0.00831117,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.3575419,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":".gitignore","depth":27,"bounds":{"left":0.025930852,"top":0.35913807,"width":0.018949468,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.35993615,"width":0.0013297872,"height":0.011971269}},{"char_start":1,"char_count":9,"bounds":{"left":0.027260639,"top":0.35993615,"width":0.017952127,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.37509975,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"app_settings.json","depth":27,"bounds":{"left":0.025930852,"top":0.37669593,"width":0.03557181,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.377494,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":16,"bounds":{"left":0.02825798,"top":0.377494,"width":0.03324468,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.3926576,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"archive.db","depth":27,"bounds":{"left":0.025930852,"top":0.3942538,"width":0.020944148,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.39505187,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":9,"bounds":{"left":0.02825798,"top":0.39505187,"width":0.01861702,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.4102155,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"archive.db-bak","depth":27,"bounds":{"left":0.025930852,"top":0.41181165,"width":0.03025266,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.41260973,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":13,"bounds":{"left":0.02825798,"top":0.41260973,"width":0.027925532,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"U","depth":27,"bounds":{"left":0.10704787,"top":0.41260973,"width":0.0029920214,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.42777336,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite","depth":27,"bounds":{"left":0.025930852,"top":0.4293695,"width":0.017287234,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.4301676,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":8,"bounds":{"left":0.028590426,"top":0.4301676,"width":0.014960106,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.44533122,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite-shm","depth":27,"bounds":{"left":0.025930852,"top":0.44692737,"width":0.027925532,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.44772545,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":12,"bounds":{"left":0.028590426,"top":0.44772545,"width":0.025265958,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.46288908,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite-wal","depth":27,"bounds":{"left":0.025930852,"top":0.46448523,"width":0.025930852,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.46528333,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":12,"bounds":{"left":0.028590426,"top":0.46528333,"width":0.023603724,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.48044693,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe_sync_updated.sh","depth":27,"bounds":{"left":0.025930852,"top":0.4820431,"width":0.059175532,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.4828412,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":25,"bounds":{"left":0.02825798,"top":0.4828412,"width":0.056848403,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"U","depth":27,"bounds":{"left":0.10704787,"top":0.4828412,"width":0.0029920214,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.4980048,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe_sync.sh","depth":27,"bounds":{"left":0.025930852,"top":0.49960095,"width":0.039893616,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.50039905,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":17,"bounds":{"left":0.02825798,"top":0.50039905,"width":0.037898935,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.51556265,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe.db","depth":27,"bounds":{"left":0.025930852,"top":0.5171588,"width":0.028590426,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.5179569,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":12,"bounds":{"left":0.02825798,"top":0.5179569,"width":0.026595745,"height":0.011971269}}],"role_description":"text"},{"role":"AXButton","text":"Outline Section","depth":21,"bounds":{"left":0.015957447,"top":0.9473264,"width":0.09940159,"height":0.017557861},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":23,"bounds":{"left":0.01662234,"top":0.9497207,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"OUTLINE","depth":22,"bounds":{"left":0.022606382,"top":0.9473264,"width":0.01662234,"height":0.017557861},"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"OUTLINE","depth":23,"bounds":{"left":0.022606382,"top":0.95131683,"width":0.01662234,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.022606382,"top":0.95131683,"width":0.0029920214,"height":0.0103751}},{"char_start":1,"char_count":6,"bounds":{"left":0.025598405,"top":0.95131683,"width":0.013630319,"height":0.0103751}}],"role_description":"text"},{"role":"AXButton","text":"Timeline Section","depth":21,"bounds":{"left":0.015957447,"top":0.9648843,"width":0.09940159,"height":0.017557861},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":23,"bounds":{"left":0.01662234,"top":0.96727854,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"TIMELINE","depth":22,"bounds":{"left":0.022606382,"top":0.9648843,"width":0.01761968,"height":0.017557861},"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"TIMELINE","depth":23,"bounds":{"left":0.022606382,"top":0.9688747,"width":0.01761968,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.022606382,"top":0.9688747,"width":0.0026595744,"height":0.0103751}},{"char_start":1,"char_count":7,"bounds":{"left":0.025265958,"top":0.9688747,"width":0.015292553,"height":0.0103751}}],"role_description":"text"},{"role":"AXRadioButton","text":"app_settings.json, Editor Group 1","depth":28,"bounds":{"left":0.11569149,"top":0.047885075,"width":0.055851065,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"screenpipe_sync.sh, Editor Group 1","depth":28,"bounds":{"left":0.17154256,"top":0.047885075,"width":0.06050532,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"pipe.md, Editor Group 1","depth":28,"bounds":{"left":0.23171543,"top":0.047885075,"width":0.040226065,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":".env, Editor Group 1","depth":28,"bounds":{"left":0.27194148,"top":0.047885075,"width":0.039893616,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":false},{"role":"AXStaticText","text":"","depth":29,"bounds":{"left":0.12832446,"top":0.07821229,"width":0.0056515955,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXTextArea","text":"ANTHROPIC_API_KEY=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","depth":28,"bounds":{"left":0.13763298,"top":0.10774142,"width":0.30285904,"height":0.014365523},"on_screen":true,"value":"ANTHROPIC_API_KEY=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","role_description":"editor","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"ANTHROPIC_API_KEY=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","depth":29,"bounds":{"left":0.13763298,"top":0.09497207,"width":0.30285904,"height":0.011173184},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.13763298,"top":0.09497207,"width":0.0023271276,"height":0.011173184}},{"char_start":1,"char_count":125,"bounds":{"left":0.13996011,"top":0.09497207,"width":0.30053192,"height":0.011173184}}],"role_description":"text"},{"role":"AXRadioButton","text":"Implement and run pipe l…, Editor Group 2","depth":28,"bounds":{"left":0.5578458,"top":0.047885075,"width":0.073803194,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":false},{"role":"AXRadioButton","text":"Problems (⇧⌘M)","depth":22,"bounds":{"left":0.118351065,"top":0.7278532,"width":0.027925532,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"PROBLEMS","depth":24,"bounds":{"left":0.122340426,"top":0.7366321,"width":0.019946808,"height":0.0103751},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Output (⇧⌘U)","depth":22,"bounds":{"left":0.14594415,"top":0.7278532,"width":0.023603724,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUTPUT","depth":24,"bounds":{"left":0.14993352,"top":0.7366321,"width":0.015625,"height":0.0103751},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Debug Console (⇧⌘Y)","depth":22,"bounds":{"left":0.16921543,"top":0.7278532,"width":0.039893616,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"DEBUG CONSOLE","depth":24,"bounds":{"left":0.1732048,"top":0.7366321,"width":0.031914894,"height":0.0103751},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Terminal (⌃`)","depth":22,"bounds":{"left":0.2087766,"top":0.7278532,"width":0.026595745,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":true},{"role":"AXStaticText","text":"TERMINAL","depth":24,"bounds":{"left":0.21276596,"top":0.7366321,"width":0.01861702,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.2130984,"top":0.73743016,"width":0.0023271276,"height":0.0103751}},{"char_start":1,"char_count":7,"bounds":{"left":0.21542554,"top":0.73743016,"width":0.016289894,"height":0.0103751}}],"role_description":"text"},{"role":"AXRadioButton","text":"Ports - 1 forwarded port","depth":22,"bounds":{"left":0.23537233,"top":0.7278532,"width":0.026263298,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"PORTS","depth":24,"bounds":{"left":0.2393617,"top":0.7366321,"width":0.012300532,"height":0.0103751},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":25,"bounds":{"left":0.25465426,"top":0.73743016,"width":0.0019946808,"height":0.008778931},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"remote SSH: nas","depth":16,"bounds":{"left":0.0006648936,"top":0.98244214,"width":0.028590426,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.0033244682,"top":0.9848364,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"SSH: nas","depth":17,"bounds":{"left":0.008643617,"top":0.9856345,"width":0.017952127,"height":0.011173184},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.008643617,"top":0.9856345,"width":0.0013297872,"height":0.011173184}},{"char_start":1,"char_count":7,"bounds":{"left":0.009973404,"top":0.9856345,"width":0.01462766,"height":0.011173184}}],"role_description":"text"},{"role":"AXButton","text":"screenpipe (Git) - master*, Checkout Branch/Tag...","depth":16,"bounds":{"left":0.030917553,"top":0.98244214,"width":0.023271276,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.031914894,"top":0.9848364,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"master*","depth":17,"bounds":{"left":0.03723404,"top":0.9856345,"width":0.015957447,"height":0.011173184},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.03723404,"top":0.9856345,"width":0.0013297872,"height":0.011173184}},{"char_start":1,"char_count":6,"bounds":{"left":0.03856383,"top":0.9856345,"width":0.012965426,"height":0.011173184}}],"role_description":"text"},{"role":"AXButton","text":"screenpipe (Git) - Synchronize Changes","depth":16,"bounds":{"left":0.05418883,"top":0.98244214,"width":0.00731383,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"No Problems","depth":16,"bounds":{"left":0.06416223,"top":0.98244214,"width":0.022606382,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.06582447,"top":0.9848364,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"0","depth":17,"bounds":{"left":0.07114362,"top":0.9856345,"width":0.004986702,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.07579787,"top":0.9848364,"width":0.0056515955,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"0","depth":17,"bounds":{"left":0.08111702,"top":0.9856345,"width":0.0039893617,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Forwarded Ports: 8766","depth":16,"bounds":{"left":0.08843085,"top":0.98244214,"width":0.012632979,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.09009308,"top":0.9848364,"width":0.0056515955,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":17,"bounds":{"left":0.09541223,"top":0.9856345,"width":0.0039893617,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Notifications","depth":16,"bounds":{"left":0.9886968,"top":0.98244214,"width":0.010638298,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sign In","depth":16,"bounds":{"left":0.9650931,"top":0.98244214,"width":0.022606382,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.96675533,"top":0.9848364,"width":0.0056515955,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Sign In","depth":17,"bounds":{"left":0.97207445,"top":0.9856345,"width":0.013962766,"height":0.011173184},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.97207445,"top":0.9856345,"width":0.0013297872,"height":0.011173184}},{"char_start":1,"char_count":6,"bounds":{"left":0.9734042,"top":0.9856345,"width":0.010638298,"height":0.011173184}}],"role_description":"text"},{"role":"AXStaticText","text":"Info: Setting up SSH Host nas: Setting up SSH tunnel","depth":12,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Implement and run pipe logic","depth":19,"bounds":{"left":0.56017286,"top":0.08060654,"width":0.07114362,"height":0.022346368},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Session history","depth":19,"bounds":{"left":0.9780585,"top":0.08060654,"width":0.00930851,"height":0.022346368},"on_screen":true,"help_text":"Session history","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"New session","depth":19,"bounds":{"left":0.9886968,"top":0.08060654,"width":0.00930851,"height":0.022346368},"on_screen":true,"help_text":"New session","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Message actions","depth":24,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"main.py","depth":23,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"lets implement logic with pipes. how can I run it?","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Let me look at the current project structure to understand what's already in place.","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"List project files","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"find /volume1/screenpipe -type f | head -50 && echo \"---\" && ls /volume1/screenpipe","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"/volume1/screenpipe/.DS_Store\n/volume1/screenpipe/screenpipe.db\n/volume1/screenpipe/screenpipe_sync.sh\n/volume1/screenpipe/app_settings.json\n/volume1/screenpipe/.gitignore\n/volume1/screenpipe/archive.db\n/volume1/screenpipe/db.sqlite\n/volume1/screenpipe/db.sqlite-wal\n/volume1/screenpipe/db.sqlite-shm\n/volume1/screenpipe/#recycle/desktop.ini\n/volume1/screenpipe/#recycle/db.sqlite\n/volume1/screenpipe/#recycle/Copy #1 of db.sqlite\n/volume1/screenpipe/#recycle/.DS_Store\n/volume1/screenpipe/#recycle/Copy #2 of db.sqlite\n/volume1/screenpipe/#recycle/archive.db\n/volume1/screenpipe/#recycle/Copy #1 of archive.db\n/volume1/screenpipe/#recycle/Copy #2 of archive.db\n/volume1/screenpipe/#recycle/Copy #3 of archive.db\n/volume1/screenpipe/#recycle/Copy #4 of archive.db\n/volume1/screenpipe/#recycle/Copy #5 of archive.db\n/volume1/screenpipe/#recycle/Copy #3 of db.sqlite\n/volume1/screenpipe/#recycle/Copy #4 of db.sqlite\n/volume1/screenpipe/#recycle/Copy #6 of archive.db\n/volume1/screenpipe/#recycle/test.txt\n/volume1/screenpipe/#recycle/Copy #7 of archive.db\n/volume1/screenpipe/#recycle/Copy #8 of archive.db\n/volume1/screenpipe/#recycle/archive.db-journal\n/volume1/screenpipe/#recycle/Copy #1 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #2 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #3 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #4 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #5 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #6 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #7 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #5 of db.sqlite\n/volume1/screenpipe/pipes/.DS_Store\n/volume1/screenpipe/app/.env\n/volume1/screenpipe/app/cli.py\n/volume1/screenpipe/app/.DS_Store\n/volume1/screenpipe/app/db.py\n/volume1/screenpipe/app/docker-compose.yml\n/volume1/screenpipe/app/main.py\n/volume1/screenpipe/app/requirements.txt\n/volume1/screenpipe/app/Dockerfile\n/volume1/screenpipe/data/.DS_Store\n/volume1/screenpipe/.git/description\n/volume1/screenpipe/.git/HEAD\n/volume1/screenpipe/.git/index\n/volume1/screenpipe/.git/COMMIT_EDITMSG\n/volume1/screenpipe/#recycle/data/.DS_Store\n---\napp\napp_settings.json\narchive.db\ndata\ndb.sqlite\ndb.sqlite-shm\ndb.sqlite-wal\npipes\n#recycle\nscreenpipe.db\nscreenpipe_sync.sh","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"main.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Check pipes directory and docker-compose","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/pipes/ && ls /volume1/screenpipe/app/ && cat /volume1/screenpipe/app/docker-compose.yml","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ai-habits\nday-recap\nmeeting-summary\nstandup-update\ntime-breakdown\nvideo-export\ncli.py\nconsumers\ndb.py\ndocker-compose.yml\nDockerfile\nmain.py\n__pycache__\nrequirements.txt\nstatic\nservices:\n screenpipe-app:\n build: .\n container_name: screenpipe-app\n restart: unless-stopped\n ports:\n - \"8766:8000\"\n volumes:\n - /volume1/screenpipe:/data\n env_file:\n - .env\n environment:\n TZ: Europe/Sofia\n DB_PATH: /data/db.sqlite\n\n sqlite-web-archive:\n image: ghcr.io/coleifer/sqlite-web:latest\n container_name: screenpipe-sqlweb-archive\n restart: unless-stopped\n ports:\n - \"8767:8080\"\n volumes:\n - /volume1/screenpipe:/data\n command: [\"-H\", \"0.0.0.0\", \"-r\", \"/data/archive.db\"]\n\n sqlite-web-live:\n image: ghcr.io/coleifer/sqlite-web:latest\n container_name: screenpipe-sqlweb-live\n restart: unless-stopped\n ports:\n - \"8768:8080\"\n volumes:\n - /volume1/screenpipe:/data\n command: [\"-H\", \"0.0.0.0\", \"-r\", \"/data/db.sqlite\"]","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"requirements.txt","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"requirements.txt","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Inspect a pipe directory","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/pipes/day-recap/ && cat /volume1/screenpipe/pipes/day-recap/pipe.json 2>/dev/null || ls /volume1/screenpipe/pipes/day-recap/","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"pipe.md\npipe.md","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"cli.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"cli.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"List all pipes and their contents","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/pipes/ && for d in /volume1/screenpipe/pipes/*/; do echo \"=== $d ===\"; ls \"$d\"; done","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ai-habits\nday-recap\nmeeting-summary\nstandup-update\ntime-breakdown\nvideo-export\n=== /volume1/screenpipe/pipes/ai-habits/ ===\npipe.md\n=== /volume1/screenpipe/pipes/day-recap/ ===\npipe.md\n=== /volume1/screenpipe/pipes/meeting-summary/ ===\npipe.md\n=== /volume1/screenpipe/pipes/standup-update/ ===\npipe.md\n=== /volume1/screenpipe/pipes/time-breakdown/ ===\npipe.md\n=== /volume1/screenpipe/pipes/video-export/ ===\npipe.md","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read pipe markdown files","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"cat /volume1/screenpipe/pipes/day-recap/pipe.md && echo \"===\" && cat /volume1/screenpipe/pipes/meeting-summary/pipe.md 2>/dev/null | head -50","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Day Recap\ndescription: \"Today's accomplishments, key moments, and unfinished work\"\nicon: \"📋\"\nfeatured: true\n---\n\nAnalyze my screen and audio recordings from today (last 16 hours only). \n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Summary\nOne sentence: what I mainly did today.\n\n## Accomplishments\n- Top 3 things I finished, with timestamps (e.g. \"2:30 PM\")\n- Name specific apps, files, or projects\n\n## Key Moments\n- Important things I saw, said, or heard — with timestamps\n\n## Unfinished Work\n- What I should continue tomorrow — name the app/file/task\n\n## Patterns\n- Apps I used most, topics that came up repeatedly\n\nOnly report what you can verify from the data. End with: \"**Next step:** [most important thing to continue]\"\n===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Meeting Summary\ndescription: \"Summarize meeting transcript with key takeaways and action items\"\nicon: \"🤝\"\nfeatured: false\n---\n\nSummarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.\n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Meeting Summary\nOne sentence: what this meeting was about.\n\n## Key Takeaways\n- Top 3-5 important points discussed\n- Include who said what when relevant\n\n## Action Items\n- [ ] Task — assigned to whom, deadline if mentioned\n- [ ] Task — assigned to whom\n\n## Decisions Made\n- List any decisions or agreements reached\n\n## Open Questions\n- Anything unresolved or needing follow-up\n\nKeep it concise and actionable.","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read summary consumer","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/app/consumers/ && cat /volume1/screenpipe/app/consumers/summary.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"activity.py\naudio.py\nelements.py\n__init__.py\ninteractions.py\nocr.py\n__pycache__\nreport.py\nsummary.py\n\"\"\"AI summary generator using Claude.\"\"\"\nimport os\nfrom datetime import date\nfrom typing import Any\n\nfrom consumers.activity import app_time, summary_stats, browser_urls, ui_event_summary\nfrom consumers.ocr import deduplicated_text\nfrom consumers.audio import formatted_transcript\n\n\nSUMMARY_TYPES = {\n \"day_recap\": {\n \"title\": \"Day Recap\",\n \"prompt\": \"\"\"\\\nYou are analyzing a person's computer activity for the day.\n\n## App usage (minutes per app):\n{app_time}\n\n## Browser URLs visited:\n{browser_urls}\n\n## UI activity per app (clicks / keystrokes / app-switches):\n{ui_events}\n\n## Screen content (sampled every 5 minutes):\n{ocr_text}\n\n## Audio/speech:\n{audio}\n\nWrite a concise day recap using EXACTLY this format:\n\n## Summary\nOne sentence: what I mainly worked on today.\n\n## Accomplishments\n- Top 3 things I finished, with approximate times\n- Name specific apps, files, or projects\n\n## Key Moments\n- Important things seen or heard, with timestamps\n\n## Unfinished Work\n- What to continue tomorrow\n\n## Patterns\n- Apps used most, topics that came up repeatedly\n\nOnly report what you can verify from the data. End with:\n**Next step:** [most important thing to continue]\"\"\",\n },\n \"standup\": {\n \"title\": \"Standup Update\",\n \"prompt\": \"\"\"\\\nYou are analyzing a person's computer activity for the day.\n\n## App usage (minutes per app):\n{app_time}\n\n## Browser URLs visited:\n{browser_urls}\n\n## UI activity per app (clicks / keystrokes / app-switches):\n{ui_events}\n\n## Screen content (sampled every 5 minutes):\n{ocr_text}\n\n## Audio/speech:\n{audio}\n\nWrite a brief standup update:\n\n**Yesterday:** What I worked on (2-3 bullets)\n**Today:** What I plan to continue (1-2 bullets)\n**Blockers:** Any issues observed (or \"None\")\n\nKeep it under 150 words. Only report what's verifiable from the data.\"\"\",\n },\n \"focus_time\": {\n \"title\": \"Focus & Distraction Analysis\",\n \"prompt\": \"\"\"\\\nYou are analyzing a person's computer activity for the day.\n\n## App usage (minutes per app):\n{app_time}\n\n## Browser URLs visited:\n{browser_urls}\n\n## UI activity per app (clicks / keystrokes / app-switches):\n{ui_events}\n\n## Screen content (sampled every 5 minutes):\n{ocr_text}\n\nAnalyze focus vs distraction patterns:\n\n## Deep Work Periods\n- When and how long were sustained focus sessions?\n- What was being worked on?\n\n## Distractions\n- Which apps/sites were used recreationally?\n- How much time was lost to context switching?\n\n## Recommendations\n- 2-3 concrete suggestions to improve focus tomorrow\n\nBe specific with times and app names.\"\"\",\n },\n}\n\n\ndef _build_context(for_date: date) -> dict[str, str]:\n apps = app_time(for_date)\n app_lines = \"\\n\".join(f\"- {a['app_name']}: {a['minutes']} min\" for a in apps[:20])\n\n urls = browser_urls(for_date, limit=20)\n url_lines = \"\\n\".join(\n f\"- {u['browser_url'][:100]} ({u['minutes']} min)\" for u in urls\n )\n\n ui_rows = ui_event_summary(for_date)\n ui_lines = \"\\n\".join(\n f\"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches\"\n for r in ui_rows[:15]\n )\n\n ocr_rows = deduplicated_text(for_date, chunk_minutes=5)\n ocr_lines = \"\\n\".join(\n f\"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}\"\n for r in ocr_rows[:100]\n )\n\n audio = formatted_transcript(for_date)\n\n return {\n \"app_time\": app_lines or \"(no app data)\",\n \"browser_urls\": url_lines or \"(no browser data)\",\n \"ui_events\": ui_lines or \"(no UI event data)\",\n \"ocr_text\": ocr_lines or \"(no screen data)\",\n \"audio\": audio[:3000] if len(audio) > 3000 else audio,\n }\n\n\ndef generate(\n summary_type: str = \"day_recap\",\n for_date: date | None = None,\n api_key: str | None = None,\n) -> dict[str, Any]:\n \"\"\"Generate an AI summary. Returns dict with 'title', 'content', 'date'.\"\"\"\n import anthropic\n\n d = for_date or date.today()\n key = api_key or os.environ.get(\"ANTHROPIC_API_KEY\", \"\")\n if not key:\n return {\n \"title\": \"Error\",\n \"content\": \"ANTHROPIC_API_KEY not set. Add it to your .env file.\",\n \"date\": str(d),\n }\n\n spec = SUMMARY_TYPES.get(summary_type)\n if not spec:\n return {\"title\": \"Error\", \"content\": f\"Unknown summary type: {summary_type}\", \"date\": str(d)}\n\n stats = summary_stats(d)\n if stats[\"total_frames\"] == 0:\n return {\n \"title\": spec[\"title\"],\n \"content\": f\"No screen data found for {d}.\",\n \"date\": str(d),\n }\n\n ctx = _build_context(d)\n prompt = spec[\"prompt\"].format(**ctx)\n\n client = anthropic.Anthropic(api_key=key)\n message = client.messages.create(\n model=\"claude-haiku-4-5-20251001\",\n max_tokens=1024,\n messages=[{\"role\": \"user\", \"content\": prompt}],\n )\n\n return {\n \"title\": spec[\"title\"],\n \"content\": message.content[0].text,\n \"date\": str(d),\n \"stats\": stats,\n }","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read all pipe.md files","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"for f in /volume1/screenpipe/pipes/*/pipe.md; do echo \"=== $f ===\"; cat \"$f\"; echo; done","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"=== /volume1/screenpipe/pipes/ai-habits/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: AI Habits\ndescription: \"How you use AI tools — patterns and insights\"\nicon: \"🤖\"\nfeatured: true\n---\n\nSearch my recordings from the last 24 hours for AI tool usage. Use app_name filter for each tool separately: ChatGPT, Claude, Copilot, Cursor, Gemini, Perplexity. Use limit=5 per search, max 6 searches total.\n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## AI Tools Used\n- List each tool with approximate time spent (e.g. \"Claude: ~45min\")\n\n## What I Used Them For\n- For each tool: coding, writing, research, or brainstorming\n\n## Usage Patterns\n- Do I switch between tools? Use them in bursts or steadily?\n\n## Effectiveness\n- Which tool appeared alongside completed work vs. abandoned attempts\n\nIf no AI usage is found, say so clearly. End with: \"**Tip:** [one suggestion to use AI tools more effectively]\"\n\n=== /volume1/screenpipe/pipes/day-recap/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Day Recap\ndescription: \"Today's accomplishments, key moments, and unfinished work\"\nicon: \"📋\"\nfeatured: true\n---\n\nAnalyze my screen and audio recordings from today (last 16 hours only). \n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Summary\nOne sentence: what I mainly did today.\n\n## Accomplishments\n- Top 3 things I finished, with timestamps (e.g. \"2:30 PM\")\n- Name specific apps, files, or projects\n\n## Key Moments\n- Important things I saw, said, or heard — with timestamps\n\n## Unfinished Work\n- What I should continue tomorrow — name the app/file/task\n\n## Patterns\n- Apps I used most, topics that came up repeatedly\n\nOnly report what you can verify from the data. End with: \"**Next step:** [most important thing to continue]\"\n\n=== /volume1/screenpipe/pipes/meeting-summary/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Meeting Summary\ndescription: \"Summarize meeting transcript with key takeaways and action items\"\nicon: \"🤝\"\nfeatured: false\n---\n\nSummarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.\n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Meeting Summary\nOne sentence: what this meeting was about.\n\n## Key Takeaways\n- Top 3-5 important points discussed\n- Include who said what when relevant\n\n## Action Items\n- [ ] Task — assigned to whom, deadline if mentioned\n- [ ] Task — assigned to whom\n\n## Decisions Made\n- List any decisions or agreements reached\n\n## Open Questions\n- Anything unresolved or needing follow-up\n\nKeep it concise and actionable.\n\n=== /volume1/screenpipe/pipes/standup-update/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Standup Update\ndescription: \"What you did, what's next, and any blockers\"\nicon: \"🏢\"\nfeatured: true\n---\n\nBased on my recordings from the last 24 hours, generate a standup update. Use limit=10 per search, max 3 searches total.\n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Yesterday\n- What I worked on (name specific projects, files, tools, PRs)\n\n## Today\n- What I will work on next (based on unfinished tasks and recent activity)\n\n## Blockers\n- Issues I hit — errors, slow builds, waiting on someone\n- If no blockers, write \"None\"\n\nKeep it under 150 words. Copy-paste ready for a team standup.\n\n=== /volume1/screenpipe/pipes/time-breakdown/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Time Breakdown\ndescription: \"Where your time went — by app, project, and category\"\nicon: \"⏱\"\nfeatured: false\n---\n\nAnalyze my app usage from today (last 12 hours). Use limit=10 per search, max 4 searches. Prefer /raw_sql with COUNT/GROUP BY queries.\n\nRead screenpipe skill first.\n\nUse this exact format with durations and percentages:\n\n## By Application\n- List each app with duration and percentage, sorted by time (e.g. \"VS Code: 2h 15min (28%)\")\n\n## By Category\n- Group into: coding, meetings, browsing, writing, communication, other\n- Show hours and percentage per category\n\n## By Project\n- Group related activities by project/topic. Name specific repos or tasks.\n\n## Productivity Score\n- Calculate: focused_work_hours / total_hours as a percentage\n- Focused = coding + writing. Unfocused = browsing + switching.\n\nEnd with: \"**Suggestion:** [one specific change to improve tomorrow's productivity]\"\n\n=== /volume1/screenpipe/pipes/video-export/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Export Video Clip\ndescription: \"Create a video of your recent screen activity\"\nicon: \"🎬\"\nfeatured: false\n---\n\nExport a video of my screen activity from the last 5 minutes.\n\nRead screenpipe skill first.\n\nUse the POST /frames/export endpoint with the time range and fps=1.0. Then show me the exported video file path as an inline code block so I can watch it.\n\nIf the export is large, suggest a lower fps or shorter time range.","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Now I have a clear picture. The pipes are markdown prompt templates in","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"/volume1/screenpipe/pipes/","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":", but there's no code to actually load and run them —","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"consumers/summary.py","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"has its own hardcoded prompts instead.","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Here's what I'll implement:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"consumers/pipes.py","depth":26,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"— dynamically loads pipe.md files and runs them via Claude (data injected as system message, pipe body as user prompt)","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"main.py","depth":26,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"— two new endpoints:","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"GET /api/pipes","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"and","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"POST /api/pipes/{pipe_id}/run","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"cli.py","depth":26,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"— a","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"pipe","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"command to run pipes from the terminal","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Let me build it:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Check browser_urls signature","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"cat /volume1/screenpipe/app/consumers/activity.py | grep \"def browser_urls\" -A 5","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"def browser_urls(\n for_date: date | None = None,\n app_name: str | None = None,\n ts_from: str | None = None,\n ts_to: str | None = None,\n limit: int = 30,","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Write","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"pipes.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"pipes.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"143 lines","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"\"\"\"Dynamic pipe loader and runner.\"\"\"\nimport os\nimport re\nfrom datetime import date\nfrom pathlib import Path\nfrom typing import Any\n\n\ndef _parse_frontmatter(text: str) -> tuple[dict, str]:\n if not text.startswith(\"---\"):\n return {}, text\n try:\n end = text.index(\"---\", 3)\n except ValueError:\n return {}, text\n fm_text = text[3:end].strip()\n body = text[end + 3:].strip()\n meta: dict = {}\n for line in fm_text.splitlines():\n if \":\" in line:\n k, _, v = line.partition(\":\")\n meta[k.strip()] = v.strip().strip('\"')\n return meta, body\n\n\ndef load_pipes(pipes_dir: Path) -> list[dict]:\n if not pipes_dir.exists():\n return []\n pipes = []\n for pipe_dir in sorted(pipes_dir.iterdir()):\n if not pipe_dir.is_dir() or pipe_dir.name.startswith(\".\"):\n continue\n pipe_md = pipe_dir / \"pipe.md\"\n if not pipe_md.exists():\n continue\n text = pipe_md.read_text(encoding=\"utf-8\")\n meta, body = _parse_frontmatter(text)\n if meta.get(\"enabled\", \"true\").lower() == \"false\":\n continue\n body = re.sub(r\"Read screenpipe skill first\\.?\\n?\", \"\", body).strip()\n pipes.append({\n \"id\": pipe_dir.name,\n \"title\": meta.get(\"title\", pipe_dir.name),\n \"description\": meta.get(\"description\", \"\"),\n \"icon\": meta.get(\"icon\", \"\"),\n \"schedule\": meta.get(\"schedule\", \"manual\"),\n \"featured\": meta.get(\"featured\", \"false\").lower() == \"true\",\n \"prompt\": body,\n })\n return pipes\n\n\ndef _build_system(d: date, stats: dict) -> str:\n from consumers.activity import app_time, browser_urls, ui_event_summary\n from consumers.ocr import deduplicated_text\n from consumers.audio import formatted_transcript\n\n apps = app_time(d)\n app_lines = \"\\n\".join(f\"- {a['app_name']}: {a['minutes']} min\" for a in apps[:20])\n\n urls = browser_urls(d, limit=20)\n url_lines = \"\\n\".join(f\"- {u['browser_url'][:100]} ({u['minutes']} min)\" for u in urls)\n\n ui_rows = ui_event_summary(d)\n ui_lines = \"\\n\".join(\n f\"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches\"\n for r in ui_rows[:15]\n )\n\n ocr_rows = deduplicated_text(d, chunk_minutes=5)\n ocr_lines = \"\\n\".join(\n f\"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}\"\n for r in ocr_rows[:100]\n )\n\n audio = formatted_transcript(d)\n if len(audio) > 3000:\n audio = audio[:3000]\n\n return f\"\"\"You are analyzing screenpipe data — recordings of a person's computer activity.\n\n## App usage (minutes per app):\n{app_lines or '(no app data)'}\n\n## Browser URLs visited:\n{url_lines or '(no browser data)'}\n\n## UI activity per app (clicks / keystrokes / app-switches):\n{ui_lines or '(no UI event data)'}\n\n## Screen content (sampled every 5 minutes):\n{ocr_lines or '(no screen data)'}\n\n## Audio / speech:\n{audio or '(no audio data)'}\n\nDate: {d}\nTotal frames recorded: {stats['total_frames']}\"\"\"\n\n\ndef run_pipe(\n pipe_id: str,\n for_date: date | None = None,\n api_key: str | None = None,\n pipes_dir: Path | None = None,\n) -> dict[str, Any]:\n import anthropic\n from consumers.activity import summary_stats\n\n d = for_date or date.today()\n key = api_key or os.environ.get(\"ANTHROPIC_API_KEY\", \"\")\n if not key:\n return {\"title\": \"Error\", \"content\": \"ANTHROPIC_API_KEY not set.\", \"date\": str(d)}\n\n _pipes_dir = pipes_dir or Path(os.environ.get(\"PIPES_DIR\", \"/data/pipes\"))\n all_pipes = {p[\"id\"]: p for p in load_pipes(_pipes_dir)}\n\n if pipe_id not in all_pipes:\n return {\"title\": \"Error\", \"content\": f\"Pipe not found: {pipe_id}\", \"date\": str(d)}\n\n pipe = all_pipes[pipe_id]\n stats = summary_stats(d)\n\n if stats[\"total_frames\"] == 0:\n return {\"title\": pipe[\"title\"], \"content\": f\"No screen data found for {d}.\", \"date\": str(d)}\n\n system = _build_system(d, stats)\n\n client = anthropic.Anthropic(api_key=key)\n message = client.messages.create(\n model=\"claude-haiku-4-5-20251001\",\n max_tokens=1024,\n system=system,\n messages=[{\"role\": \"user\", \"content\": pipe[\"prompt\"]}],\n )\n\n return {\n \"title\": pipe[\"title\"],\n \"content\": message.content[0].text,\n \"date\": str(d),\n \"stats\": stats,\n }","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Now add the API endpoints to","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"main.py","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":":","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Edit","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"main.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Added 1 line","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Edit","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"main.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Added 1 line","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Now add the pipe endpoints at the end of main.py, before the closing summary section:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Edit","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"main.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Added 14 lines","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Now add the CLI command to","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"cli.py","depth":23,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"cli.py","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":":","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Edit","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"cli.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"cli.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Added 40 lines","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Done. Here's how to run pipes:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXHeading","text":"How to run pipes","depth":22,"on_screen":false,"role_description":"heading"},{"role":"AXStaticText","text":"How to run pipes","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Via Docker (inside the running container):","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":23,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"docker exec -it screenpipe-app python cli.py pipe --list\ndocker exec -it screenpipe-app python cli.py pipe day-recap\ndocker exec -it screenpipe-app python cli.py pipe standup-update --date yesterday","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Via the API","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"(once the container is running on port 8766):","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":23,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"# List pipes\ncurl http://localhost:8766/api/pipes\n\n# Run a pipe\ncurl -X POST \"http://localhost:8766/api/pipes/day-recap/run\"\ncurl -X POST \"http://localhost:8766/api/pipes/standup-update/run?d=2026-04-25\"","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Rebuild and restart","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"to pick up the changes:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":23,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"cd /volume1/screenpipe/app\ndocker compose up --build -d","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"How it works:","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Each","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"pipe.md","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"file is loaded dynamically — the frontmatter provides metadata and the body becomes the user prompt. Screenpipe data (app usage, browser URLs, OCR, audio) is injected as a Claude system message so the pipe prompt can reference it naturally. The \"Read screenpipe skill first\" line is stripped automatically.","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"The pipes directory inside Docker is","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"/data/pipes","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"(since","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"/volume1/screenpipe","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"→","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"/data","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"). You can override it with a","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"PIPES_DIR","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"env var if needed.","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Message actions","depth":24,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"pipe.md","depth":23,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"pipe.md","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"where to place api key and can I use different keys","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read .env file","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"cat /volume1/screenpipe/app/.env","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ANTHROPIC_API_KEY=your_key_here","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Where to place the key:","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"app/.env","depth":23,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"app/.env","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"— replace","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"your_key_here","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"with your actual key:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":23,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"ANTHROPIC_API_KEY=sk-ant-...","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"That file is loaded by","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"load_dotenv()","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"at startup and is excluded from git via","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":".gitignore","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":".","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Can you use different keys per pipe?","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Not currently — all pipes share the one key from","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":".env","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":". But you can add per-pipe key support by adding an","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"api_key","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"field to the pipe's frontmatter:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":23,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"---\ntitle: Meeting Summary\napi_key_env: ANTHROPIC_KEY_MEETINGS\n---","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Then in","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"consumers/pipes.py","depth":23,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"consumers/pipes.py","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":", read it in","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"_parse_frontmatter","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"and pass it through","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"run_pipe","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":". Want me to add that?","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Message actions","depth":24,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"pipe.md","depth":23,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"pipe.md","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"can I use mistral or other llm? or is is build for antrophic only","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Currently it's Anthropic-only — the code calls the","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"anthropic","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"SDK directly in both","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"consumers/pipes.py","depth":23,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"consumers/pipes.py","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"and","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"consumers/summary.py","depth":23,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"consumers/summary.py","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":".","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Adding other providers is straightforward since Mistral, Ollama, OpenRouter, Groq, and most modern LLMs expose an OpenAI-compatible API. The cleanest approach: add the","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"openai","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"package and let you configure the provider via","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":".env","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":":","depth":23,"on_screen":false,"role_description":"text"}]...
|
-5925903718893812484
|
-8196323327614154520
|
idle
|
accessibility
|
NULL
|
Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧ Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py
M
db.py
docker-compose.yml
Dockerfile
M
main.py
M
requirements.txt
M
data
logs
pipes
.gitignore
app_settings.json
archive.db
archive.db-bak
U
db.sqlite
db.sqlite-shm
db.sqlite-wal
screenpipe_sync_updated.sh
U
screenpipe_sync.sh
screenpipe.db
Outline Section
OUTLINE
OUTLINE
Timeline Section
TIMELINE
TIMELINE
app_settings.json, Editor Group 1
screenpipe_sync.sh, Editor Group 1
pipe.md, Editor Group 1
.env, Editor Group 1
[ENV_SECRET]
[ENV_SECRET]
Implement and run pipe l…, Editor Group 2
Problems (⇧⌘M)
PROBLEMS
Output (⇧⌘U)
OUTPUT
Debug Console (⇧⌘Y)
DEBUG CONSOLE
Terminal (⌃`)
TERMINAL
Ports - 1 forwarded port
PORTS
1
remote SSH: nas
SSH: nas
screenpipe (Git) - master*, Checkout Branch/Tag...
master*
screenpipe (Git) - Synchronize Changes
No Problems
0
0
Forwarded Ports: 8766
1
Notifications
Sign In
Sign In
Info: Setting up SSH Host nas: Setting up SSH tunnel
Implement and run pipe logic
Session history
New session
Message actions
main.py
main.py
lets implement logic with pipes. how can I run it?
Thinking
Thinking
Let me look at the current project structure to understand what's already in place.
Bash
List project files
IN
find /volume1/screenpipe -type f | head -50 && echo "---" && ls /volume1/screenpipe
Copy code to clipboard
OUT
/volume1/screenpipe/.DS_Store
/volume1/screenpipe/screenpipe.db
/volume1/screenpipe/screenpipe_sync.sh
/volume1/screenpipe/app_settings.json
/volume1/screenpipe/.gitignore
/volume1/screenpipe/archive.db
/volume1/screenpipe/db.sqlite
/volume1/screenpipe/db.sqlite-wal
/volume1/screenpipe/db.sqlite-shm
/volume1/screenpipe/#recycle/desktop.ini
/volume1/screenpipe/#recycle/db.sqlite
/volume1/screenpipe/#recycle/Copy #1 of db.sqlite
/volume1/screenpipe/#recycle/.DS_Store
/volume1/screenpipe/#recycle/Copy #2 of db.sqlite
/volume1/screenpipe/#recycle/archive.db
/volume1/screenpipe/#recycle/Copy #1 of archive.db
/volume1/screenpipe/#recycle/Copy #2 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of archive.db
/volume1/screenpipe/#recycle/Copy #4 of archive.db
/volume1/screenpipe/#recycle/Copy #5 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of db.sqlite
/volume1/screenpipe/#recycle/Copy #4 of db.sqlite
/volume1/screenpipe/#recycle/Copy #6 of archive.db
/volume1/screenpipe/#recycle/test.txt
/volume1/screenpipe/#recycle/Copy #7 of archive.db
/volume1/screenpipe/#recycle/Copy #8 of archive.db
/volume1/screenpipe/#recycle/archive.db-journal
/volume1/screenpipe/#recycle/Copy #1 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #2 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #3 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #4 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #6 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #7 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of db.sqlite
/volume1/screenpipe/pipes/.DS_Store
/volume1/screenpipe/app/.env
/volume1/screenpipe/app/cli.py
/volume1/screenpipe/app/.DS_Store
/volume1/screenpipe/app/db.py
/volume1/screenpipe/app/docker-compose.yml
/volume1/screenpipe/app/main.py
/volume1/screenpipe/app/requirements.txt
/volume1/screenpipe/app/Dockerfile
/volume1/screenpipe/data/.DS_Store
/volume1/screenpipe/.git/description
/volume1/screenpipe/.git/HEAD
/volume1/screenpipe/.git/index
/volume1/screenpipe/.git/COMMIT_EDITMSG
/volume1/screenpipe/#recycle/data/.DS_Store
---
app
app_settings.json
archive.db
data
db.sqlite
db.sqlite-shm
db.sqlite-wal
pipes
#recycle
screenpipe.db
screenpipe_sync.sh
Read
main.py
main.py
Bash
Check pipes directory and docker-compose
IN
ls /volume1/screenpipe/pipes/ && ls /volume1/screenpipe/app/ && cat /volume1/screenpipe/app/docker-compose.yml
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
cli.py
consumers
db.py
docker-compose.yml
Dockerfile
main.py
__pycache__
requirements.txt
static
services:
screenpipe-app:
build: .
container_name: screenpipe-app
restart: unless-stopped
ports:
- "8766:8000"
volumes:
- /volume1/screenpipe:/data
env_file:
- .env
environment:
TZ: Europe/Sofia
DB_PATH: /data/db.sqlite
sqlite-web-archive:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-archive
restart: unless-stopped
ports:
- "8767:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/archive.db"]
sqlite-web-live:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-live
restart: unless-stopped
ports:
- "8768:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/db.sqlite"]
Read
requirements.txt
requirements.txt
Bash
Inspect a pipe directory
IN
ls /volume1/screenpipe/pipes/day-recap/ && cat /volume1/screenpipe/pipes/day-recap/pipe.json 2>/dev/null || ls /volume1/screenpipe/pipes/day-recap/
Copy code to clipboard
OUT
pipe.md
pipe.md
Read
cli.py
cli.py
Bash
List all pipes and their contents
IN
ls /volume1/screenpipe/pipes/ && for d in /volume1/screenpipe/pipes/*/; do echo "=== $d ==="; ls "$d"; done
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
=== /volume1/screenpipe/pipes/ai-habits/ ===
pipe.md
=== /volume1/screenpipe/pipes/day-recap/ ===
pipe.md
=== /volume1/screenpipe/pipes/meeting-summary/ ===
pipe.md
=== /volume1/screenpipe/pipes/standup-update/ ===
pipe.md
=== /volume1/screenpipe/pipes/time-breakdown/ ===
pipe.md
=== /volume1/screenpipe/pipes/video-export/ ===
pipe.md
Bash
Read pipe markdown files
IN
cat /volume1/screenpipe/pipes/day-recap/pipe.md && echo "===" && cat /volume1/screenpipe/pipes/meeting-summary/pipe.md 2>/dev/null | head -50
Copy code to clipboard
OUT
---
schedule: manual
enabled: true
template: true
title: Day Recap
description: "Today's accomplishments, key moments, and unfinished work"
icon: "📋"
featured: true
---
Analyze my screen and audio recordings from today (last 16 hours only).
Read screenpipe skill first.
Use this exact format:
## Summary
One sentence: what I mainly did today.
## Accomplishments
- Top 3 things I finished, with timestamps (e.g. "2:30 PM")
- Name specific apps, files, or projects
## Key Moments
- Important things I saw, said, or heard — with timestamps
## Unfinished Work
- What I should continue tomorrow — name the app/file/task
## Patterns
- Apps I used most, topics that came up repeatedly
Only report what you can verify from the data. End with: "**Next step:** [most important thing to continue]"
===
---
schedule: manual
enabled: true
template: true
title: Meeting Summary
description: "Summarize meeting transcript with key takeaways and action items"
icon: "🤝"
featured: false
---
Summarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.
Read screenpipe skill first.
Use this exact format:
## Meeting Summary
One sentence: what this meeting was about.
## Key Takeaways
- Top 3-5 important points discussed
- Include who said what when relevant
## Action Items
- [ ] Task — assigned to whom, deadline if mentioned
- [ ] Task — assigned to whom
## Decisions Made
- List any decisions or agreements reached
## Open Questions
- Anything unresolved or needing follow-up
Keep it concise and actionable.
Thinking
Thinking
Bash
Read summary consumer
IN
ls /volume1/screenpipe/app/consumers/ && cat /volume1/screenpipe/app/consumers/summary.py
Copy code to clipboard
OUT
activity.py
audio.py
elements.py
__init__.py
interactions.py
ocr.py
__pycache__
report.py
summary.py
"""AI summary generator using Claude."""
import os
from datetime import date
from typing import Any
from consumers.activity import app_time, summary_stats, browser_urls, ui_event_summary
from consumers.ocr import deduplicated_text
from consumers.audio import formatted_transcript
SUMMARY_TYPES = {
"day_recap": {
"title": "Day Recap",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
## Audio/speech:
{audio}
Write a concise day recap using EXACTLY this format:
## Summary
One sentence: what I mainly worked on today.
## Accomplishments
- Top 3 things I finished, with approximate times
- Name specific apps, files, or projects
## Key Moments
- Important things seen or heard, with timestamps
## Unfinished Work
- What to continue tomorrow
## Patterns
- Apps used most, topics that came up repeatedly
Only report what you can verify from the data. End with:
**Next step:** [most important thing to continue]""",
},
"standup": {
"title": "Standup Update",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
## Audio/speech:
{audio}
Write a brief standup update:
**Yesterday:** What I worked on (2-3 bullets)
**Today:** What I plan to continue (1-2 bullets)
**Blockers:** Any issues observed (or "None")
Keep it under 150 words. Only report what's verifiable from the data.""",
},
"focus_time": {
"title": "Focus & Distraction Analysis",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
Analyze focus vs distraction patterns:
## Deep Work Periods
- When and how long were sustained focus sessions?
- What was being worked on?
## Distractions
- Which apps/sites were used recreationally?
- How much time was lost to context switching?
## Recommendations
- 2-3 concrete suggestions to improve focus tomorrow
Be specific with times and app names.""",
},
}
def _build_context(for_date: date) -> dict[str, str]:
apps = app_time(for_date)
app_lines = "\n".join(f"- {a['app_name']}: {a['minutes']} min" for a in apps[:20])
urls = browser_urls(for_date, limit=20)
url_lines = "\n".join(
f"- {u['browser_url'][:100]} ({u['minutes']} min)" for u in urls
)
ui_rows = ui_event_summary(for_date)
ui_lines = "\n".join(
f"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches"
for r in ui_rows[:15]
)
ocr_rows = deduplicated_text(for_date, chunk_minutes=5)
ocr_lines = "\n".join(
f"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}"
for r in ocr_rows[:100]
)
audio = formatted_transcript(for_date)
return {
"app_time": app_lines or "(no app data)",
"browser_urls": url_lines or "(no browser data)",
"ui_events": ui_lines or "(no UI event data)",
"ocr_text": ocr_lines or "(no screen data)",
"audio": audio[:3000] if len(audio) > 3000 else audio,
}
def generate(
summary_type: str = "day_recap",
for_date: date | None = None,
api_key: str | None = None,
) -> dict[str, Any]:
"""Generate an AI summary. Returns dict with 'title', 'content', 'date'."""
import anthropic
d = for_date or date.today()
key = api_key or os.environ.get("ANTHROPIC_API_KEY", "")
if not key:
return {
"title": "Error",
"content": "ANTHROPIC_API_KEY not set. Add it to your .env file.",
"date": str(d),
}
spec = SUMMARY_TYPES.get(summary_type)
if not spec:
return {"title": "Error", "content": f"Unknown summary type: {summary_type}", "date": str(d)}
stats = summary_stats(d)
if stats["total_frames"] == 0:
return {
"title": spec["title"],
"content": f"No screen data found for {d}.",
"date": str(d),
}
ctx = _build_context(d)
prompt = spec["prompt"].format(**ctx)
client = anthropic.Anthropic(api_key=key)
message = client.messages.create(
model="claude-haiku-4-5-20251001",
max_tokens=1024,
messages=[{"role": "user", "content": prompt}],
)
return {
"title": spec["title"],
"content": message.content[0].text,
"date": str(d),
"stats": stats,
}
Thinking
Thinking
Bash
Read all pipe.md files
IN
for f in /volume1/screenpipe/pipes/*/pipe.md; do echo "=== $f ==="; cat "$f"; echo; done
Copy code to clipboard
OUT
=== /volume1/screenpipe/pipes/ai-habits/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: AI Habits
description: "How you use AI tools — patterns and insights"
icon: "🤖"
featured: true
---
Search my recordings from the last 24 hours for AI tool usage. Use app_name filter for each tool separately: ChatGPT, Claude, Copilot, Cursor, Gemini, Perplexity. Use limit=5 per search, max 6 searches total.
Read screenpipe skill first.
Use this exact format:
## AI Tools Used
- List each tool with approximate time spent (e.g. "Claude: ~45min")
## What I Used Them For
- For each tool: coding, writing, research, or brainstorming
## Usage Patterns
- Do I switch between tools? Use them in bursts or steadily?
## Effectiveness
- Which tool appeared alongside completed work vs. abandoned attempts
If no AI usage is found, say so clearly. End with: "**Tip:** [one suggestion to use AI tools more effectively]"
=== /volume1/screenpipe/pipes/day-recap/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Day Recap
description: "Today's accomplishments, key moments, and unfinished work"
icon: "📋"
featured: true
---
Analyze my screen and audio recordings from today (last 16 hours only).
Read screenpipe skill first.
Use this exact format:
## Summary
One sentence: what I mainly did today.
## Accomplishments
- Top 3 things I finished, with timestamps (e.g. "2:30 PM")
- Name specific apps, files, or projects
## Key Moments
- Important things I saw, said, or heard — with timestamps
## Unfinished Work
- What I should continue tomorrow — name the app/file/task
## Patterns
- Apps I used most, topics that came up repeatedly
Only report what you can verify from the data. End with: "**Next step:** [most important thing to continue]"
=== /volume1/screenpipe/pipes/meeting-summary/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Meeting Summary
description: "Summarize meeting transcript with key takeaways and action items"
icon: "🤝"
featured: false
---
Summarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.
Read screenpipe skill first.
Use this exact format:
## Meeting Summary
One sentence: what this meeting was about.
## Key Takeaways
- Top 3-5 important points discussed
- Include who said what when relevant
## Action Items
- [ ] Task — assigned to whom, deadline if mentioned
- [ ] Task — assigned to whom
## Decisions Made
- List any decisions or agreements reached
## Open Questions
- Anything unresolved or needing follow-up
Keep it concise and actionable.
=== /volume1/screenpipe/pipes/standup-update/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Standup Update
description: "What you did, what's next, and any blockers"
icon: "🏢"
featured: true
---
Based on my recordings from the last 24 hours, generate a standup update. Use limit=10 per search, max 3 searches total.
Read screenpipe skill first.
Use this exact format:
## Yesterday
- What I worked on (name specific projects, files, tools, PRs)
## Today
- What I will work on next (based on unfinished tasks and recent activity)
## Blockers
- Issues I hit — errors, slow builds, waiting on someone
- If no blockers, write "None"
Keep it under 150 words. Copy-paste ready for a team standup.
=== /volume1/screenpipe/pipes/time-breakdown/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Time Breakdown
description: "Where your time went — by app, project, and category"
icon: "⏱"
featured: false
---
Analyze my app usage from today (last 12 hours). Use limit=10 per search, max 4 searches. Prefer /raw_sql with COUNT/GROUP BY queries.
Read screenpipe skill first.
Use this exact format with durations and percentages:
## By Application
- List each app with duration and percentage, sorted by time (e.g. "VS Code: 2h 15min (28%)")
## By Category
- Group into: coding, meetings, browsing, writing, communication, other
- Show hours and percentage per category
## By Project
- Group related activities by project/topic. Name specific repos or tasks.
## Productivity Score
- Calculate: focused_work_hours / total_hours as a percentage
- Focused = coding + writing. Unfocused = browsing + switching.
End with: "**Suggestion:** [one specific change to improve tomorrow's productivity]"
=== /volume1/screenpipe/pipes/video-export/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Export Video Clip
description: "Create a video of your recent screen activity"
icon: "🎬"
featured: false
---
Export a video of my screen activity from the last 5 minutes.
Read screenpipe skill first.
Use the POST /frames/export endpoint with the time range and fps=1.0. Then show me the exported video file path as an inline code block so I can watch it.
If the export is large, suggest a lower fps or shorter time range.
Thinking
Thinking
Now I have a clear picture. The pipes are markdown prompt templates in
/volume1/screenpipe/pipes/
, but there's no code to actually load and run them —
consumers/summary.py
has its own hardcoded prompts instead.
Here's what I'll implement:
consumers/pipes.py
— dynamically loads pipe.md files and runs them via Claude (data injected as system message, pipe body as user prompt)
main.py
— two new endpoints:
GET /api/pipes
and
POST /api/pipes/{pipe_id}/run
cli.py
— a
pipe
command to run pipes from the terminal
Let me build it:
Bash
Check browser_urls signature
IN
cat /volume1/screenpipe/app/consumers/activity.py | grep "def browser_urls" -A 5
Copy code to clipboard
OUT
def browser_urls(
for_date: date | None = None,
app_name: str | None = None,
ts_from: str | None = None,
ts_to: str | None = None,
limit: int = 30,
Write
pipes.py
pipes.py
143 lines
"""Dynamic pipe loader and runner."""
import os
import re
from datetime import date
from pathlib import Path
from typing import Any
def _parse_frontmatter(text: str) -> tuple[dict, str]:
if not text.startswith("---"):
return {}, text
try:
end = text.index("---", 3)
except ValueError:
return {}, text
fm_text = text[3:end].strip()
body = text[end + 3:].strip()
meta: dict = {}
for line in fm_text.splitlines():
if ":" in line:
k, _, v = line.partition(":")
meta[k.strip()] = v.strip().strip('"')
return meta, body
def load_pipes(pipes_dir: Path) -> list[dict]:
if not pipes_dir.exists():
return []
pipes = []
for pipe_dir in sorted(pipes_dir.iterdir()):
if not pipe_dir.is_dir() or pipe_dir.name.startswith("."):
continue
pipe_md = pipe_dir / "pipe.md"
if not pipe_md.exists():
continue
text = pipe_md.read_text(encoding="utf-8")
meta, body = _parse_frontmatter(text)
if meta.get("enabled", "true").lower() == "false":
continue
body = re.sub(r"Read screenpipe skill first\.?\n?", "", body).strip()
pipes.append({
"id": pipe_dir.name,
"title": meta.get("title", pipe_dir.name),
"description": meta.get("description", ""),
"icon": meta.get("icon", ""),
"schedule": meta.get("schedule", "manual"),
"featured": meta.get("featured", "false").lower() == "true",
"prompt": body,
})
return pipes
def _build_system(d: date, stats: dict) -> str:
from consumers.activity import app_time, browser_urls, ui_event_summary
from consumers.ocr import deduplicated_text
from consumers.audio import formatted_transcript
apps = app_time(d)
app_lines = "\n".join(f"- {a['app_name']}: {a['minutes']} min" for a in apps[:20])
urls = browser_urls(d, limit=20)
url_lines = "\n".join(f"- {u['browser_url'][:100]} ({u['minutes']} min)" for u in urls)
ui_rows = ui_event_summary(d)
ui_lines = "\n".join(
f"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches"
for r in ui_rows[:15]
)
ocr_rows = deduplicated_text(d, chunk_minutes=5)
ocr_lines = "\n".join(
f"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}"
for r in ocr_rows[:100]
)
audio = formatted_transcript(d)
if len(audio) > 3000:
audio = audio[:3000]
return f"""You are analyzing screenpipe data — recordings of a person's computer activity.
## App usage (minutes per app):
{app_lines or '(no app data)'}
## Browser URLs visited:
{url_lines or '(no browser data)'}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_lines or '(no UI event data)'}
## Screen content (sampled every 5 minutes):
{ocr_lines or '(no screen data)'}
## Audio / speech:
{audio or '(no audio data)'}
Date: {d}
Total frames recorded: {stats['total_frames']}"""
def run_pipe(
pipe_id: str,
for_date: date | None = None,
api_key: str | None = None,
pipes_dir: Path | None = None,
) -> dict[str, Any]:
import anthropic
from consumers.activity import summary_stats
d = for_date or date.today()
key = api_key or os.environ.get("ANTHROPIC_API_KEY", "")
if not key:
return {"title": "Error", "content": "ANTHROPIC_API_KEY not set.", "date": str(d)}
_pipes_dir = pipes_dir or Path(os.environ.get("PIPES_DIR", "/data/pipes"))
all_pipes = {p["id"]: p for p in load_pipes(_pipes_dir)}
if pipe_id not in all_pipes:
return {"title": "Error", "content": f"Pipe not found: {pipe_id}", "date": str(d)}
pipe = all_pipes[pipe_id]
stats = summary_stats(d)
if stats["total_frames"] == 0:
return {"title": pipe["title"], "content": f"No screen data found for {d}.", "date": str(d)}
system = _build_system(d, stats)
client = anthropic.Anthropic(api_key=key)
message = client.messages.create(
model="claude-haiku-4-5-20251001",
max_tokens=1024,
system=system,
messages=[{"role": "user", "content": pipe["prompt"]}],
)
return {
"title": pipe["title"],
"content": message.content[0].text,
"date": str(d),
"stats": stats,
}
Now add the API endpoints to
main.py
:
Edit
main.py
main.py
Added 1 line
Edit
main.py
main.py
Added 1 line
Now add the pipe endpoints at the end of main.py, before the closing summary section:
Edit
main.py
main.py
Added 14 lines
Now add the CLI command to
cli.py
cli.py
:
Edit
cli.py
cli.py
Added 40 lines
Done. Here's how to run pipes:
How to run pipes
How to run pipes
Via Docker (inside the running container):
Copy code to clipboard
docker exec -it screenpipe-app python cli.py pipe --list
docker exec -it screenpipe-app python cli.py pipe day-recap
docker exec -it screenpipe-app python cli.py pipe standup-update --date yesterday
Via the API
(once the container is running on port 8766):
Copy code to clipboard
# List pipes
curl http://localhost:8766/api/pipes
# Run a pipe
curl -X POST "http://localhost:8766/api/pipes/day-recap/run"
curl -X POST "http://localhost:8766/api/pipes/standup-update/run?d=2026-04-25"
Rebuild and restart
to pick up the changes:
Copy code to clipboard
cd /volume1/screenpipe/app
docker compose up --build -d
How it works:
Each
pipe.md
file is loaded dynamically — the frontmatter provides metadata and the body becomes the user prompt. Screenpipe data (app usage, browser URLs, OCR, audio) is injected as a Claude system message so the pipe prompt can reference it naturally. The "Read screenpipe skill first" line is stripped automatically.
The pipes directory inside Docker is
/data/pipes
(since
/volume1/screenpipe
→
/data
). You can override it with a
PIPES_DIR
env var if needed.
Message actions
pipe.md
pipe.md
where to place api key and can I use different keys
Thinking
Thinking
Bash
Read .env file
IN
cat /volume1/screenpipe/app/.env
Copy code to clipboard
OUT
[ENV_SECRET]
Where to place the key:
app/.env
app/.env
— replace
your_key_here
with your actual key:
Copy code to clipboard
[ENV_SECRET]
That file is loaded by
load_dotenv()
at startup and is excluded from git via
.gitignore
.
Can you use different keys per pipe?
Not currently — all pipes share the one key from
.env
. But you can add per-pipe key support by adding an
api_key
field to the pipe's frontmatter:
Copy code to clipboard
---
title: Meeting Summary
api_key_env: ANTHROPIC_KEY_MEETINGS
---
Then in
consumers/pipes.py
consumers/pipes.py
, read it in
_parse_frontmatter
and pass it through
run_pipe
. Want me to add that?
Message actions
pipe.md
pipe.md
can I use mistral or other llm? or is is build for antrophic only
Thinking
Thinking
Currently it's Anthropic-only — the code calls the
anthropic
SDK directly in both
consumers/pipes.py
consumers/pipes.py
and
consumers/summary.py
consumers/summary.py
.
Adding other providers is straightforward since Mistral, Ollama, OpenRouter, Groq, and most modern LLMs expose an OpenAI-compatible API. The cleanest approach: add the
openai
package and let you configure the provider via
.env
:...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
21068
|
920
|
4
|
2026-05-11T17:08:17.995607+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-11/1778 /Users/lukas/.screenpipe/data/data/2026-05-11/1778519297995_m1.jpg...
|
Code
|
Implement and run pipe l… — screenpipe [SSH: nas]
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧ Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py
M
db.py
docker-compose.yml
Dockerfile
M
main.py
M
requirements.txt
M
data
logs
pipes
.gitignore
app_settings.json
archive.db
archive.db-bak
U
db.sqlite
db.sqlite-shm
db.sqlite-wal
screenpipe_sync_updated.sh
U
screenpipe_sync.sh
screenpipe.db
Outline Section
OUTLINE
OUTLINE
Timeline Section
TIMELINE
TIMELINE
app_settings.json, Editor Group 1
screenpipe_sync.sh, Editor Group 1
pipe.md, Editor Group 1
.env, Editor Group 1
[ENV_SECRET]
[ENV_SECRET]
Implement and run pipe l…, Editor Group 2
Problems (⇧⌘M)
PROBLEMS
Output (⇧⌘U)
OUTPUT
Debug Console (⇧⌘Y)
DEBUG CONSOLE
Terminal (⌃`)
TERMINAL
Ports - 1 forwarded port
PORTS
1
remote SSH: nas
SSH: nas
screenpipe (Git) - master*, Checkout Branch/Tag...
master*
screenpipe (Git) - Synchronize Changes
No Problems
0
0
Forwarded Ports: 8766
1
Notifications
Sign In
Sign In
Info: Setting up SSH Host nas: Setting up SSH tunnel
Implement and run pipe logic
Session history
New session
Message actions
main.py
main.py
lets implement logic with pipes. how can I run it?
Thinking
Thinking
Let me look at the current project structure to understand what's already in place.
Bash
List project files
IN
find /volume1/screenpipe -type f | head -50 && echo "---" && ls /volume1/screenpipe
Copy code to clipboard
OUT
/volume1/screenpipe/.DS_Store
/volume1/screenpipe/screenpipe.db
/volume1/screenpipe/screenpipe_sync.sh
/volume1/screenpipe/app_settings.json
/volume1/screenpipe/.gitignore
/volume1/screenpipe/archive.db
/volume1/screenpipe/db.sqlite
/volume1/screenpipe/db.sqlite-wal
/volume1/screenpipe/db.sqlite-shm
/volume1/screenpipe/#recycle/desktop.ini
/volume1/screenpipe/#recycle/db.sqlite
/volume1/screenpipe/#recycle/Copy #1 of db.sqlite
/volume1/screenpipe/#recycle/.DS_Store
/volume1/screenpipe/#recycle/Copy #2 of db.sqlite
/volume1/screenpipe/#recycle/archive.db
/volume1/screenpipe/#recycle/Copy #1 of archive.db
/volume1/screenpipe/#recycle/Copy #2 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of archive.db
/volume1/screenpipe/#recycle/Copy #4 of archive.db
/volume1/screenpipe/#recycle/Copy #5 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of db.sqlite
/volume1/screenpipe/#recycle/Copy #4 of db.sqlite
/volume1/screenpipe/#recycle/Copy #6 of archive.db
/volume1/screenpipe/#recycle/test.txt
/volume1/screenpipe/#recycle/Copy #7 of archive.db
/volume1/screenpipe/#recycle/Copy #8 of archive.db
/volume1/screenpipe/#recycle/archive.db-journal
/volume1/screenpipe/#recycle/Copy #1 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #2 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #3 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #4 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #6 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #7 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of db.sqlite
/volume1/screenpipe/pipes/.DS_Store
/volume1/screenpipe/app/.env
/volume1/screenpipe/app/cli.py
/volume1/screenpipe/app/.DS_Store
/volume1/screenpipe/app/db.py
/volume1/screenpipe/app/docker-compose.yml
/volume1/screenpipe/app/main.py
/volume1/screenpipe/app/requirements.txt
/volume1/screenpipe/app/Dockerfile
/volume1/screenpipe/data/.DS_Store
/volume1/screenpipe/.git/description
/volume1/screenpipe/.git/HEAD
/volume1/screenpipe/.git/index
/volume1/screenpipe/.git/COMMIT_EDITMSG
/volume1/screenpipe/#recycle/data/.DS_Store
---
app
app_settings.json
archive.db
data
db.sqlite
db.sqlite-shm
db.sqlite-wal
pipes
#recycle
screenpipe.db
screenpipe_sync.sh
Read
main.py
main.py
Bash
Check pipes directory and docker-compose
IN
ls /volume1/screenpipe/pipes/ && ls /volume1/screenpipe/app/ && cat /volume1/screenpipe/app/docker-compose.yml
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
cli.py
consumers
db.py
docker-compose.yml
Dockerfile
main.py
__pycache__
requirements.txt
static
services:
screenpipe-app:
build: .
container_name: screenpipe-app
restart: unless-stopped
ports:
- "8766:8000"
volumes:
- /volume1/screenpipe:/data
env_file:
- .env
environment:
TZ: Europe/Sofia
DB_PATH: /data/db.sqlite
sqlite-web-archive:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-archive
restart: unless-stopped
ports:
- "8767:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/archive.db"]
sqlite-web-live:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-live
restart: unless-stopped
ports:
- "8768:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/db.sqlite"]
Read
requirements.txt
requirements.txt
Bash
Inspect a pipe directory
IN
ls /volume1/screenpipe/pipes/day-recap/ && cat /volume1/screenpipe/pipes/day-recap/pipe.json 2>/dev/null || ls /volume1/screenpipe/pipes/day-recap/
Copy code to clipboard
OUT
pipe.md
pipe.md
Read
cli.py
cli.py
Bash
List all pipes and their contents
IN
ls /volume1/screenpipe/pipes/ && for d in /volume1/screenpipe/pipes/*/; do echo "=== $d ==="; ls "$d"; done
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
=== /volume1/screenpipe/pipes/ai-habits/ ===
pipe.md
=== /volume1/screenpipe/pipes/day-recap/ ===
pipe.md
=== /volume1/screenpipe/pipes/meeting-summary/ ===
pipe.md
=== /volume1/screenpipe/pipes/standup-update/ ===
pipe.md
=== /volume1/screenpipe/pipes/time-breakdown/ ===
pipe.md
=== /volume1/screenpipe/pipes/video-export/ ===
pipe.md
Bash
Read pipe markdown files
IN
cat /volume1/screenpipe/pipes/day-recap/pipe.md && echo "===" && cat /volume1/screenpipe/pipes/meeting-summary/pipe.md 2>/dev/null | head -50
Copy code to clipboard
OUT
---
schedule: manual
enabled: true
template: true
title: Day Recap
description: "Today's accomplishments, key moments, and unfinished work"
icon: "📋"
featured: true
---
Analyze my screen and audio recordings from today (last 16 hours only).
Read screenpipe skill first.
Use this exact format:
## Summary
One sentence: what I mainly did today.
## Accomplishments
- Top 3 things I finished, with timestamps (e.g. "2:30 PM")
- Name specific apps, files, or projects
## Key Moments
- Important things I saw, said, or heard — with timestamps
## Unfinished Work
- What I should continue tomorrow — name the app/file/task
## Patterns
- Apps I used most, topics that came up repeatedly
Only report what you can verify from the data. End with: "**Next step:** [most important thing to continue]"
===
---
schedule: manual
enabled: true
template: true
title: Meeting Summary
description: "Summarize meeting transcript with key takeaways and action items"
icon: "🤝"
featured: false
---
Summarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.
Read screenpipe skill first.
Use this exact format:
## Meeting Summary
One sentence: what this meeting was about.
## Key Takeaways
- Top 3-5 important points discussed
- Include who said what when relevant
## Action Items
- [ ] Task — assigned to whom, deadline if mentioned
- [ ] Task — assigned to whom
## Decisions Made
- List any decisions or agreements reached
## Open Questions
- Anything unresolved or needing follow-up
Keep it concise and actionable.
Thinking
Thinking
Bash
Read summary consumer
IN
ls /volume1/screenpipe/app/consumers/ && cat /volume1/screenpipe/app/consumers/summary.py
Copy code to clipboard
OUT
activity.py
audio.py
elements.py
__init__.py
interactions.py
ocr.py
__pycache__
report.py
summary.py
"""AI summary generator using Claude."""
import os
from datetime import date
from typing import Any
from consumers.activity import app_time, summary_stats, browser_urls, ui_event_summary
from consumers.ocr import deduplicated_text
from consumers.audio import formatted_transcript
SUMMARY_TYPES = {
"day_recap": {
"title": "Day Recap",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
## Audio/speech:
{audio}
Write a concise day recap using EXACTLY this format:
## Summary
One sentence: what I mainly worked on today.
## Accomplishments
- Top 3 things I finished, with approximate times
- Name specific apps, files, or projects
## Key Moments
- Important things seen or heard, with timestamps
## Unfinished Work
- What to continue tomorrow
## Patterns
- Apps used most, topics that came up repeatedly
Only report what you can verify from the data. End with:
**Next step:** [most important thing to continue]""",
},
"standup": {
"title": "Standup Update",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
## Audio/speech:
{audio}
Write a brief standup update:
**Yesterday:** What I worked on (2-3 bullets)
**Today:** What I plan to continue (1-2 bullets)
**Blockers:** Any issues observed (or "None")
Keep it under 150 words. Only report what's verifiable from the data.""",
},
"focus_time": {
"title": "Focus & Distraction Analysis",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
Analyze focus vs distraction patterns:
## Deep Work Periods
- When and how long were sustained focus sessions?
- What was being worked on?
## Distractions
- Which apps/sites were used recreationally?
- How much time was lost to context switching?
## Recommendations
- 2-3 concrete suggestions to improve focus tomorrow
Be specific with times and app names.""",
},
}
def _build_context(for_date: date) -> dict[str, str]:
apps = app_time(for_date)
app_lines = "\n".join(f"- {a['app_name']}: {a['minutes']} min" for a in apps[:20])
urls = browser_urls(for_date, limit=20)
url_lines = "\n".join(
f"- {u['browser_url'][:100]} ({u['minutes']} min)" for u in urls
)
ui_rows = ui_event_summary(for_date)
ui_lines = "\n".join(
f"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches"
for r in ui_rows[:15]
)
ocr_rows = deduplicated_text(for_date, chunk_minutes=5)
ocr_lines = "\n".join(
f"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}"
for r in ocr_rows[:100]
)
audio = formatted_transcript(for_date)
return {
"app_time": app_lines or "(no app data)",
"browser_urls": url_lines or "(no browser data)",
"ui_events": ui_lines or "(no UI event data)",
"ocr_text": ocr_lines or "(no screen data)",
"audio": audio[:3000] if len(audio) > 3000 else audio,
}
def generate(
summary_type: str = "day_recap",
for_date: date | None = None,
api_key: str | None = None,
) -> dict[str, Any]:
"""Generate an AI summary. Returns dict with 'title', 'content', 'date'."""
import anthropic
d = for_date or date.today()
key = api_key or os.environ.get("ANTHROPIC_API_KEY", "")
if not key:
return {
"title": "Error",
"content": "ANTHROPIC_API_KEY not set. Add it to your .env file.",
"date": str(d),
}
spec = SUMMARY_TYPES.get(summary_type)
if not spec:
return {"title": "Error", "content": f"Unknown summary type: {summary_type}", "date": str(d)}
stats = summary_stats(d)
if stats["total_frames"] == 0:
return {
"title": spec["title"],
"content": f"No screen data found for {d}.",
"date": str(d),
}
ctx = _build_context(d)
prompt = spec["prompt"].format(**ctx)
client = anthropic.Anthropic(api_key=key)
message = client.messages.create(
model="claude-haiku-4-5-20251001",
max_tokens=1024,
messages=[{"role": "user", "content": prompt}],
)
return {
"title": spec["title"],
"content": message.content[0].text,
"date": str(d),
"stats": stats,
}
Thinking
Thinking
Bash
Read all pipe.md files
IN
for f in /volume1/screenpipe/pipes/*/pipe.md; do echo "=== $f ==="; cat "$f"; echo; done
Copy code to clipboard
OUT
=== /volume1/screenpipe/pipes/ai-habits/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: AI Habits
description: "How you use AI tools — patterns and insights"
icon: "🤖"
featured: true
---
Search my recordings from the last 24 hours for AI tool usage. Use app_name filter for each tool separately: ChatGPT, Claude, Copilot, Cursor, Gemini, Perplexity. Use limit=5 per search, max 6 searches total.
Read screenpipe skill first.
Use this exact format:
## AI Tools Used
- List each tool with approximate time spent (e.g. "Claude: ~45min")
## What I Used Them For
- For each tool: coding, writing, research, or brainstorming
## Usage Patterns
- Do I switch between tools? Use them in bursts or steadily?
## Effectiveness
- Which tool appeared alongside completed work vs. abandoned attempts
If no AI usage is found, say so clearly. End with: "**Tip:** [one suggestion to use AI tools more effectively]"
=== /volume1/screenpipe/pipes/day-recap/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Day Recap
description: "Today's accomplishments, key moments, and unfinished work"
icon: "📋"
featured: true
---
Analyze my screen and audio recordings from today (last 16 hours only).
Read screenpipe skill first.
Use this exact format:
## Summary
One sentence: what I mainly did today.
## Accomplishments
- Top 3 things I finished, with timestamps (e.g. "2:30 PM")
- Name specific apps, files, or projects
## Key Moments
- Important things I saw, said, or heard — with timestamps
## Unfinished Work
- What I should continue tomorrow — name the app/file/task
## Patterns
- Apps I used most, topics that came up repeatedly
Only report what you can verify from the data. End with: "**Next step:** [most important thing to continue]"
=== /volume1/screenpipe/pipes/meeting-summary/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Meeting Summary
description: "Summarize meeting transcript with key takeaways and action items"
icon: "🤝"
featured: false
---
Summarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.
Read screenpipe skill first.
Use this exact format:
## Meeting Summary
One sentence: what this meeting was about.
## Key Takeaways
- Top 3-5 important points discussed
- Include who said what when relevant
## Action Items
- [ ] Task — assigned to whom, deadline if mentioned
- [ ] Task — assigned to whom
## Decisions Made
- List any decisions or agreements reached
## Open Questions
- Anything unresolved or needing follow-up
Keep it concise and actionable.
=== /volume1/screenpipe/pipes/standup-update/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Standup Update
description: "What you did, what's next, and any blockers"
icon: "🏢"
featured: true
---
Based on my recordings from the last 24 hours, generate a standup update. Use limit=10 per search, max 3 searches total.
Read screenpipe skill first.
Use this exact format:
## Yesterday
- What I worked on (name specific projects, files, tools, PRs)
## Today
- What I will work on next (based on unfinished tasks and recent activity)
## Blockers
- Issues I hit — errors, slow builds, waiting on someone
- If no blockers, write "None"
Keep it under 150 words. Copy-paste ready for a team standup.
=== /volume1/screenpipe/pipes/time-breakdown/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Time Breakdown
description: "Where your time went — by app, project, and category"
icon: "⏱"
featured: false
---
Analyze my app usage from today (last 12 hours). Use limit=10 per search, max 4 searches. Prefer /raw_sql with COUNT/GROUP BY queries.
Read screenpipe skill first.
Use this exact format with durations and percentages:
## By Application
- List each app with duration and percentage, sorted by time (e.g. "VS Code: 2h 15min (28%)")
## By Category
- Group into: coding, meetings, browsing, writing, communication, other
- Show hours and percentage per category
## By Project
- Group related activities by project/topic. Name specific repos or tasks.
## Productivity Score
- Calculate: focused_work_hours / total_hours as a percentage
- Focused = coding + writing. Unfocused = browsing + switching.
End with: "**Suggestion:** [one specific change to improve tomorrow's productivity]"
=== /volume1/screenpipe/pipes/video-export/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Export Video Clip
description: "Create a video of your recent screen activity"
icon: "🎬"
featured: false
---
Export a video of my screen activity from the last 5 minutes.
Read screenpipe skill first.
Use the POST /frames/export endpoint with the time range and fps=1.0. Then show me the exported video file path as an inline code block so I can watch it.
If the export is large, suggest a lower fps or shorter time range.
Thinking
Thinking
Now I have a clear picture. The pipes are markdown prompt templates in
/volume1/screenpipe/pipes/
, but there's no code to actually load and run them —
consumers/summary.py
has its own hardcoded prompts instead.
Here's what I'll implement:
consumers/pipes.py
— dynamically loads pipe.md files and runs them via Claude (data injected as system message, pipe body as user prompt)
main.py
— two new endpoints:...
|
[{"role":"AXRadioButton","text [{"role":"AXRadioButton","text":"Explorer (⇧⌘E)","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":true},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Search (⇧⌘F)","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Source Control (⌃⇧G) - 10 pending changes","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"10","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Run and Debug (⇧⌘D)","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Remote Explorer","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Extensions (⇧⌘X) - 2 require update","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"2","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Claude Code","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"Containers","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXHeading","text":"EXPLORER","depth":17,"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"EXPLORER","depth":18,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Explorer Section: screenpipe [SSH: nas]","depth":21,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":true},{"role":"AXStaticText","text":"","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"Explorer Section: screenpipe [SSH: nas]","depth":22,"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"SCREENPIPE [SSH: NAS]","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"#recycle","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"app","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"__pycache__","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"consumers","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"static","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":".env","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"cli.py","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.py","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"docker-compose.yml","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Dockerfile","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"main.py","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"requirements.txt","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"data","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"logs","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"pipes","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":".gitignore","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"app_settings.json","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"archive.db","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"archive.db-bak","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"U","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite-shm","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite-wal","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe_sync_updated.sh","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"U","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe_sync.sh","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe.db","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Outline Section","depth":21,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"OUTLINE","depth":22,"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"OUTLINE","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Timeline Section","depth":21,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"TIMELINE","depth":22,"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"TIMELINE","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"app_settings.json, Editor Group 1","depth":28,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"screenpipe_sync.sh, Editor Group 1","depth":28,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"pipe.md, Editor Group 1","depth":28,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":".env, Editor Group 1","depth":28,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":false},{"role":"AXStaticText","text":"","depth":29,"on_screen":true,"role_description":"text"},{"role":"AXTextArea","text":"ANTHROPIC_API_KEY=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","depth":28,"on_screen":true,"value":"ANTHROPIC_API_KEY=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","role_description":"editor","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"ANTHROPIC_API_KEY=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","depth":29,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Implement and run pipe l…, Editor Group 2","depth":28,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":false},{"role":"AXRadioButton","text":"Problems (⇧⌘M)","depth":22,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"PROBLEMS","depth":24,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Output (⇧⌘U)","depth":22,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUTPUT","depth":24,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Debug Console (⇧⌘Y)","depth":22,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"DEBUG CONSOLE","depth":24,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Terminal (⌃`)","depth":22,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":true},{"role":"AXStaticText","text":"TERMINAL","depth":24,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Ports - 1 forwarded port","depth":22,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"PORTS","depth":24,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":25,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"remote SSH: nas","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"SSH: nas","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"screenpipe (Git) - master*, Checkout Branch/Tag...","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"master*","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"screenpipe (Git) - Synchronize Changes","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"No Problems","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"0","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"0","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Forwarded Ports: 8766","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Notifications","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sign In","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Sign In","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Info: Setting up SSH Host nas: Setting up SSH tunnel","depth":12,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Implement and run pipe logic","depth":19,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Session history","depth":19,"on_screen":true,"help_text":"Session history","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"New session","depth":19,"on_screen":true,"help_text":"New session","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Message actions","depth":24,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"main.py","depth":23,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"lets implement logic with pipes. how can I run it?","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Let me look at the current project structure to understand what's already in place.","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"List project files","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"find /volume1/screenpipe -type f | head -50 && echo \"---\" && ls /volume1/screenpipe","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"/volume1/screenpipe/.DS_Store\n/volume1/screenpipe/screenpipe.db\n/volume1/screenpipe/screenpipe_sync.sh\n/volume1/screenpipe/app_settings.json\n/volume1/screenpipe/.gitignore\n/volume1/screenpipe/archive.db\n/volume1/screenpipe/db.sqlite\n/volume1/screenpipe/db.sqlite-wal\n/volume1/screenpipe/db.sqlite-shm\n/volume1/screenpipe/#recycle/desktop.ini\n/volume1/screenpipe/#recycle/db.sqlite\n/volume1/screenpipe/#recycle/Copy #1 of db.sqlite\n/volume1/screenpipe/#recycle/.DS_Store\n/volume1/screenpipe/#recycle/Copy #2 of db.sqlite\n/volume1/screenpipe/#recycle/archive.db\n/volume1/screenpipe/#recycle/Copy #1 of archive.db\n/volume1/screenpipe/#recycle/Copy #2 of archive.db\n/volume1/screenpipe/#recycle/Copy #3 of archive.db\n/volume1/screenpipe/#recycle/Copy #4 of archive.db\n/volume1/screenpipe/#recycle/Copy #5 of archive.db\n/volume1/screenpipe/#recycle/Copy #3 of db.sqlite\n/volume1/screenpipe/#recycle/Copy #4 of db.sqlite\n/volume1/screenpipe/#recycle/Copy #6 of archive.db\n/volume1/screenpipe/#recycle/test.txt\n/volume1/screenpipe/#recycle/Copy #7 of archive.db\n/volume1/screenpipe/#recycle/Copy #8 of archive.db\n/volume1/screenpipe/#recycle/archive.db-journal\n/volume1/screenpipe/#recycle/Copy #1 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #2 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #3 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #4 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #5 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #6 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #7 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #5 of db.sqlite\n/volume1/screenpipe/pipes/.DS_Store\n/volume1/screenpipe/app/.env\n/volume1/screenpipe/app/cli.py\n/volume1/screenpipe/app/.DS_Store\n/volume1/screenpipe/app/db.py\n/volume1/screenpipe/app/docker-compose.yml\n/volume1/screenpipe/app/main.py\n/volume1/screenpipe/app/requirements.txt\n/volume1/screenpipe/app/Dockerfile\n/volume1/screenpipe/data/.DS_Store\n/volume1/screenpipe/.git/description\n/volume1/screenpipe/.git/HEAD\n/volume1/screenpipe/.git/index\n/volume1/screenpipe/.git/COMMIT_EDITMSG\n/volume1/screenpipe/#recycle/data/.DS_Store\n---\napp\napp_settings.json\narchive.db\ndata\ndb.sqlite\ndb.sqlite-shm\ndb.sqlite-wal\npipes\n#recycle\nscreenpipe.db\nscreenpipe_sync.sh","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"main.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Check pipes directory and docker-compose","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/pipes/ && ls /volume1/screenpipe/app/ && cat /volume1/screenpipe/app/docker-compose.yml","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ai-habits\nday-recap\nmeeting-summary\nstandup-update\ntime-breakdown\nvideo-export\ncli.py\nconsumers\ndb.py\ndocker-compose.yml\nDockerfile\nmain.py\n__pycache__\nrequirements.txt\nstatic\nservices:\n screenpipe-app:\n build: .\n container_name: screenpipe-app\n restart: unless-stopped\n ports:\n - \"8766:8000\"\n volumes:\n - /volume1/screenpipe:/data\n env_file:\n - .env\n environment:\n TZ: Europe/Sofia\n DB_PATH: /data/db.sqlite\n\n sqlite-web-archive:\n image: ghcr.io/coleifer/sqlite-web:latest\n container_name: screenpipe-sqlweb-archive\n restart: unless-stopped\n ports:\n - \"8767:8080\"\n volumes:\n - /volume1/screenpipe:/data\n command: [\"-H\", \"0.0.0.0\", \"-r\", \"/data/archive.db\"]\n\n sqlite-web-live:\n image: ghcr.io/coleifer/sqlite-web:latest\n container_name: screenpipe-sqlweb-live\n restart: unless-stopped\n ports:\n - \"8768:8080\"\n volumes:\n - /volume1/screenpipe:/data\n command: [\"-H\", \"0.0.0.0\", \"-r\", \"/data/db.sqlite\"]","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"requirements.txt","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"requirements.txt","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Inspect a pipe directory","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/pipes/day-recap/ && cat /volume1/screenpipe/pipes/day-recap/pipe.json 2>/dev/null || ls /volume1/screenpipe/pipes/day-recap/","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"pipe.md\npipe.md","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"cli.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"cli.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"List all pipes and their contents","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/pipes/ && for d in /volume1/screenpipe/pipes/*/; do echo \"=== $d ===\"; ls \"$d\"; done","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ai-habits\nday-recap\nmeeting-summary\nstandup-update\ntime-breakdown\nvideo-export\n=== /volume1/screenpipe/pipes/ai-habits/ ===\npipe.md\n=== /volume1/screenpipe/pipes/day-recap/ ===\npipe.md\n=== /volume1/screenpipe/pipes/meeting-summary/ ===\npipe.md\n=== /volume1/screenpipe/pipes/standup-update/ ===\npipe.md\n=== /volume1/screenpipe/pipes/time-breakdown/ ===\npipe.md\n=== /volume1/screenpipe/pipes/video-export/ ===\npipe.md","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read pipe markdown files","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"cat /volume1/screenpipe/pipes/day-recap/pipe.md && echo \"===\" && cat /volume1/screenpipe/pipes/meeting-summary/pipe.md 2>/dev/null | head -50","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Day Recap\ndescription: \"Today's accomplishments, key moments, and unfinished work\"\nicon: \"📋\"\nfeatured: true\n---\n\nAnalyze my screen and audio recordings from today (last 16 hours only). \n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Summary\nOne sentence: what I mainly did today.\n\n## Accomplishments\n- Top 3 things I finished, with timestamps (e.g. \"2:30 PM\")\n- Name specific apps, files, or projects\n\n## Key Moments\n- Important things I saw, said, or heard — with timestamps\n\n## Unfinished Work\n- What I should continue tomorrow — name the app/file/task\n\n## Patterns\n- Apps I used most, topics that came up repeatedly\n\nOnly report what you can verify from the data. End with: \"**Next step:** [most important thing to continue]\"\n===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Meeting Summary\ndescription: \"Summarize meeting transcript with key takeaways and action items\"\nicon: \"🤝\"\nfeatured: false\n---\n\nSummarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.\n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Meeting Summary\nOne sentence: what this meeting was about.\n\n## Key Takeaways\n- Top 3-5 important points discussed\n- Include who said what when relevant\n\n## Action Items\n- [ ] Task — assigned to whom, deadline if mentioned\n- [ ] Task — assigned to whom\n\n## Decisions Made\n- List any decisions or agreements reached\n\n## Open Questions\n- Anything unresolved or needing follow-up\n\nKeep it concise and actionable.","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read summary consumer","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/app/consumers/ && cat /volume1/screenpipe/app/consumers/summary.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"activity.py\naudio.py\nelements.py\n__init__.py\ninteractions.py\nocr.py\n__pycache__\nreport.py\nsummary.py\n\"\"\"AI summary generator using Claude.\"\"\"\nimport os\nfrom datetime import date\nfrom typing import Any\n\nfrom consumers.activity import app_time, summary_stats, browser_urls, ui_event_summary\nfrom consumers.ocr import deduplicated_text\nfrom consumers.audio import formatted_transcript\n\n\nSUMMARY_TYPES = {\n \"day_recap\": {\n \"title\": \"Day Recap\",\n \"prompt\": \"\"\"\\\nYou are analyzing a person's computer activity for the day.\n\n## App usage (minutes per app):\n{app_time}\n\n## Browser URLs visited:\n{browser_urls}\n\n## UI activity per app (clicks / keystrokes / app-switches):\n{ui_events}\n\n## Screen content (sampled every 5 minutes):\n{ocr_text}\n\n## Audio/speech:\n{audio}\n\nWrite a concise day recap using EXACTLY this format:\n\n## Summary\nOne sentence: what I mainly worked on today.\n\n## Accomplishments\n- Top 3 things I finished, with approximate times\n- Name specific apps, files, or projects\n\n## Key Moments\n- Important things seen or heard, with timestamps\n\n## Unfinished Work\n- What to continue tomorrow\n\n## Patterns\n- Apps used most, topics that came up repeatedly\n\nOnly report what you can verify from the data. End with:\n**Next step:** [most important thing to continue]\"\"\",\n },\n \"standup\": {\n \"title\": \"Standup Update\",\n \"prompt\": \"\"\"\\\nYou are analyzing a person's computer activity for the day.\n\n## App usage (minutes per app):\n{app_time}\n\n## Browser URLs visited:\n{browser_urls}\n\n## UI activity per app (clicks / keystrokes / app-switches):\n{ui_events}\n\n## Screen content (sampled every 5 minutes):\n{ocr_text}\n\n## Audio/speech:\n{audio}\n\nWrite a brief standup update:\n\n**Yesterday:** What I worked on (2-3 bullets)\n**Today:** What I plan to continue (1-2 bullets)\n**Blockers:** Any issues observed (or \"None\")\n\nKeep it under 150 words. Only report what's verifiable from the data.\"\"\",\n },\n \"focus_time\": {\n \"title\": \"Focus & Distraction Analysis\",\n \"prompt\": \"\"\"\\\nYou are analyzing a person's computer activity for the day.\n\n## App usage (minutes per app):\n{app_time}\n\n## Browser URLs visited:\n{browser_urls}\n\n## UI activity per app (clicks / keystrokes / app-switches):\n{ui_events}\n\n## Screen content (sampled every 5 minutes):\n{ocr_text}\n\nAnalyze focus vs distraction patterns:\n\n## Deep Work Periods\n- When and how long were sustained focus sessions?\n- What was being worked on?\n\n## Distractions\n- Which apps/sites were used recreationally?\n- How much time was lost to context switching?\n\n## Recommendations\n- 2-3 concrete suggestions to improve focus tomorrow\n\nBe specific with times and app names.\"\"\",\n },\n}\n\n\ndef _build_context(for_date: date) -> dict[str, str]:\n apps = app_time(for_date)\n app_lines = \"\\n\".join(f\"- {a['app_name']}: {a['minutes']} min\" for a in apps[:20])\n\n urls = browser_urls(for_date, limit=20)\n url_lines = \"\\n\".join(\n f\"- {u['browser_url'][:100]} ({u['minutes']} min)\" for u in urls\n )\n\n ui_rows = ui_event_summary(for_date)\n ui_lines = \"\\n\".join(\n f\"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches\"\n for r in ui_rows[:15]\n )\n\n ocr_rows = deduplicated_text(for_date, chunk_minutes=5)\n ocr_lines = \"\\n\".join(\n f\"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}\"\n for r in ocr_rows[:100]\n )\n\n audio = formatted_transcript(for_date)\n\n return {\n \"app_time\": app_lines or \"(no app data)\",\n \"browser_urls\": url_lines or \"(no browser data)\",\n \"ui_events\": ui_lines or \"(no UI event data)\",\n \"ocr_text\": ocr_lines or \"(no screen data)\",\n \"audio\": audio[:3000] if len(audio) > 3000 else audio,\n }\n\n\ndef generate(\n summary_type: str = \"day_recap\",\n for_date: date | None = None,\n api_key: str | None = None,\n) -> dict[str, Any]:\n \"\"\"Generate an AI summary. Returns dict with 'title', 'content', 'date'.\"\"\"\n import anthropic\n\n d = for_date or date.today()\n key = api_key or os.environ.get(\"ANTHROPIC_API_KEY\", \"\")\n if not key:\n return {\n \"title\": \"Error\",\n \"content\": \"ANTHROPIC_API_KEY not set. Add it to your .env file.\",\n \"date\": str(d),\n }\n\n spec = SUMMARY_TYPES.get(summary_type)\n if not spec:\n return {\"title\": \"Error\", \"content\": f\"Unknown summary type: {summary_type}\", \"date\": str(d)}\n\n stats = summary_stats(d)\n if stats[\"total_frames\"] == 0:\n return {\n \"title\": spec[\"title\"],\n \"content\": f\"No screen data found for {d}.\",\n \"date\": str(d),\n }\n\n ctx = _build_context(d)\n prompt = spec[\"prompt\"].format(**ctx)\n\n client = anthropic.Anthropic(api_key=key)\n message = client.messages.create(\n model=\"claude-haiku-4-5-20251001\",\n max_tokens=1024,\n messages=[{\"role\": \"user\", \"content\": prompt}],\n )\n\n return {\n \"title\": spec[\"title\"],\n \"content\": message.content[0].text,\n \"date\": str(d),\n \"stats\": stats,\n }","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read all pipe.md files","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"for f in /volume1/screenpipe/pipes/*/pipe.md; do echo \"=== $f ===\"; cat \"$f\"; echo; done","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"=== /volume1/screenpipe/pipes/ai-habits/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: AI Habits\ndescription: \"How you use AI tools — patterns and insights\"\nicon: \"🤖\"\nfeatured: true\n---\n\nSearch my recordings from the last 24 hours for AI tool usage. Use app_name filter for each tool separately: ChatGPT, Claude, Copilot, Cursor, Gemini, Perplexity. Use limit=5 per search, max 6 searches total.\n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## AI Tools Used\n- List each tool with approximate time spent (e.g. \"Claude: ~45min\")\n\n## What I Used Them For\n- For each tool: coding, writing, research, or brainstorming\n\n## Usage Patterns\n- Do I switch between tools? Use them in bursts or steadily?\n\n## Effectiveness\n- Which tool appeared alongside completed work vs. abandoned attempts\n\nIf no AI usage is found, say so clearly. End with: \"**Tip:** [one suggestion to use AI tools more effectively]\"\n\n=== /volume1/screenpipe/pipes/day-recap/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Day Recap\ndescription: \"Today's accomplishments, key moments, and unfinished work\"\nicon: \"📋\"\nfeatured: true\n---\n\nAnalyze my screen and audio recordings from today (last 16 hours only). \n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Summary\nOne sentence: what I mainly did today.\n\n## Accomplishments\n- Top 3 things I finished, with timestamps (e.g. \"2:30 PM\")\n- Name specific apps, files, or projects\n\n## Key Moments\n- Important things I saw, said, or heard — with timestamps\n\n## Unfinished Work\n- What I should continue tomorrow — name the app/file/task\n\n## Patterns\n- Apps I used most, topics that came up repeatedly\n\nOnly report what you can verify from the data. End with: \"**Next step:** [most important thing to continue]\"\n\n=== /volume1/screenpipe/pipes/meeting-summary/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Meeting Summary\ndescription: \"Summarize meeting transcript with key takeaways and action items\"\nicon: \"🤝\"\nfeatured: false\n---\n\nSummarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.\n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Meeting Summary\nOne sentence: what this meeting was about.\n\n## Key Takeaways\n- Top 3-5 important points discussed\n- Include who said what when relevant\n\n## Action Items\n- [ ] Task — assigned to whom, deadline if mentioned\n- [ ] Task — assigned to whom\n\n## Decisions Made\n- List any decisions or agreements reached\n\n## Open Questions\n- Anything unresolved or needing follow-up\n\nKeep it concise and actionable.\n\n=== /volume1/screenpipe/pipes/standup-update/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Standup Update\ndescription: \"What you did, what's next, and any blockers\"\nicon: \"🏢\"\nfeatured: true\n---\n\nBased on my recordings from the last 24 hours, generate a standup update. Use limit=10 per search, max 3 searches total.\n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Yesterday\n- What I worked on (name specific projects, files, tools, PRs)\n\n## Today\n- What I will work on next (based on unfinished tasks and recent activity)\n\n## Blockers\n- Issues I hit — errors, slow builds, waiting on someone\n- If no blockers, write \"None\"\n\nKeep it under 150 words. Copy-paste ready for a team standup.\n\n=== /volume1/screenpipe/pipes/time-breakdown/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Time Breakdown\ndescription: \"Where your time went — by app, project, and category\"\nicon: \"⏱\"\nfeatured: false\n---\n\nAnalyze my app usage from today (last 12 hours). Use limit=10 per search, max 4 searches. Prefer /raw_sql with COUNT/GROUP BY queries.\n\nRead screenpipe skill first.\n\nUse this exact format with durations and percentages:\n\n## By Application\n- List each app with duration and percentage, sorted by time (e.g. \"VS Code: 2h 15min (28%)\")\n\n## By Category\n- Group into: coding, meetings, browsing, writing, communication, other\n- Show hours and percentage per category\n\n## By Project\n- Group related activities by project/topic. Name specific repos or tasks.\n\n## Productivity Score\n- Calculate: focused_work_hours / total_hours as a percentage\n- Focused = coding + writing. Unfocused = browsing + switching.\n\nEnd with: \"**Suggestion:** [one specific change to improve tomorrow's productivity]\"\n\n=== /volume1/screenpipe/pipes/video-export/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Export Video Clip\ndescription: \"Create a video of your recent screen activity\"\nicon: \"🎬\"\nfeatured: false\n---\n\nExport a video of my screen activity from the last 5 minutes.\n\nRead screenpipe skill first.\n\nUse the POST /frames/export endpoint with the time range and fps=1.0. Then show me the exported video file path as an inline code block so I can watch it.\n\nIf the export is large, suggest a lower fps or shorter time range.","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Now I have a clear picture. The pipes are markdown prompt templates in","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"/volume1/screenpipe/pipes/","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":", but there's no code to actually load and run them —","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"consumers/summary.py","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"has its own hardcoded prompts instead.","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Here's what I'll implement:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"consumers/pipes.py","depth":26,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"— dynamically loads pipe.md files and runs them via Claude (data injected as system message, pipe body as user prompt)","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"main.py","depth":26,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"— two new endpoints:","depth":24,"on_screen":false,"role_description":"text"}]...
|
-4751573642779930658
|
-8907047231489583008
|
idle
|
accessibility
|
NULL
|
Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧ Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py
M
db.py
docker-compose.yml
Dockerfile
M
main.py
M
requirements.txt
M
data
logs
pipes
.gitignore
app_settings.json
archive.db
archive.db-bak
U
db.sqlite
db.sqlite-shm
db.sqlite-wal
screenpipe_sync_updated.sh
U
screenpipe_sync.sh
screenpipe.db
Outline Section
OUTLINE
OUTLINE
Timeline Section
TIMELINE
TIMELINE
app_settings.json, Editor Group 1
screenpipe_sync.sh, Editor Group 1
pipe.md, Editor Group 1
.env, Editor Group 1
[ENV_SECRET]
[ENV_SECRET]
Implement and run pipe l…, Editor Group 2
Problems (⇧⌘M)
PROBLEMS
Output (⇧⌘U)
OUTPUT
Debug Console (⇧⌘Y)
DEBUG CONSOLE
Terminal (⌃`)
TERMINAL
Ports - 1 forwarded port
PORTS
1
remote SSH: nas
SSH: nas
screenpipe (Git) - master*, Checkout Branch/Tag...
master*
screenpipe (Git) - Synchronize Changes
No Problems
0
0
Forwarded Ports: 8766
1
Notifications
Sign In
Sign In
Info: Setting up SSH Host nas: Setting up SSH tunnel
Implement and run pipe logic
Session history
New session
Message actions
main.py
main.py
lets implement logic with pipes. how can I run it?
Thinking
Thinking
Let me look at the current project structure to understand what's already in place.
Bash
List project files
IN
find /volume1/screenpipe -type f | head -50 && echo "---" && ls /volume1/screenpipe
Copy code to clipboard
OUT
/volume1/screenpipe/.DS_Store
/volume1/screenpipe/screenpipe.db
/volume1/screenpipe/screenpipe_sync.sh
/volume1/screenpipe/app_settings.json
/volume1/screenpipe/.gitignore
/volume1/screenpipe/archive.db
/volume1/screenpipe/db.sqlite
/volume1/screenpipe/db.sqlite-wal
/volume1/screenpipe/db.sqlite-shm
/volume1/screenpipe/#recycle/desktop.ini
/volume1/screenpipe/#recycle/db.sqlite
/volume1/screenpipe/#recycle/Copy #1 of db.sqlite
/volume1/screenpipe/#recycle/.DS_Store
/volume1/screenpipe/#recycle/Copy #2 of db.sqlite
/volume1/screenpipe/#recycle/archive.db
/volume1/screenpipe/#recycle/Copy #1 of archive.db
/volume1/screenpipe/#recycle/Copy #2 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of archive.db
/volume1/screenpipe/#recycle/Copy #4 of archive.db
/volume1/screenpipe/#recycle/Copy #5 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of db.sqlite
/volume1/screenpipe/#recycle/Copy #4 of db.sqlite
/volume1/screenpipe/#recycle/Copy #6 of archive.db
/volume1/screenpipe/#recycle/test.txt
/volume1/screenpipe/#recycle/Copy #7 of archive.db
/volume1/screenpipe/#recycle/Copy #8 of archive.db
/volume1/screenpipe/#recycle/archive.db-journal
/volume1/screenpipe/#recycle/Copy #1 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #2 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #3 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #4 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #6 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #7 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of db.sqlite
/volume1/screenpipe/pipes/.DS_Store
/volume1/screenpipe/app/.env
/volume1/screenpipe/app/cli.py
/volume1/screenpipe/app/.DS_Store
/volume1/screenpipe/app/db.py
/volume1/screenpipe/app/docker-compose.yml
/volume1/screenpipe/app/main.py
/volume1/screenpipe/app/requirements.txt
/volume1/screenpipe/app/Dockerfile
/volume1/screenpipe/data/.DS_Store
/volume1/screenpipe/.git/description
/volume1/screenpipe/.git/HEAD
/volume1/screenpipe/.git/index
/volume1/screenpipe/.git/COMMIT_EDITMSG
/volume1/screenpipe/#recycle/data/.DS_Store
---
app
app_settings.json
archive.db
data
db.sqlite
db.sqlite-shm
db.sqlite-wal
pipes
#recycle
screenpipe.db
screenpipe_sync.sh
Read
main.py
main.py
Bash
Check pipes directory and docker-compose
IN
ls /volume1/screenpipe/pipes/ && ls /volume1/screenpipe/app/ && cat /volume1/screenpipe/app/docker-compose.yml
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
cli.py
consumers
db.py
docker-compose.yml
Dockerfile
main.py
__pycache__
requirements.txt
static
services:
screenpipe-app:
build: .
container_name: screenpipe-app
restart: unless-stopped
ports:
- "8766:8000"
volumes:
- /volume1/screenpipe:/data
env_file:
- .env
environment:
TZ: Europe/Sofia
DB_PATH: /data/db.sqlite
sqlite-web-archive:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-archive
restart: unless-stopped
ports:
- "8767:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/archive.db"]
sqlite-web-live:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-live
restart: unless-stopped
ports:
- "8768:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/db.sqlite"]
Read
requirements.txt
requirements.txt
Bash
Inspect a pipe directory
IN
ls /volume1/screenpipe/pipes/day-recap/ && cat /volume1/screenpipe/pipes/day-recap/pipe.json 2>/dev/null || ls /volume1/screenpipe/pipes/day-recap/
Copy code to clipboard
OUT
pipe.md
pipe.md
Read
cli.py
cli.py
Bash
List all pipes and their contents
IN
ls /volume1/screenpipe/pipes/ && for d in /volume1/screenpipe/pipes/*/; do echo "=== $d ==="; ls "$d"; done
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
=== /volume1/screenpipe/pipes/ai-habits/ ===
pipe.md
=== /volume1/screenpipe/pipes/day-recap/ ===
pipe.md
=== /volume1/screenpipe/pipes/meeting-summary/ ===
pipe.md
=== /volume1/screenpipe/pipes/standup-update/ ===
pipe.md
=== /volume1/screenpipe/pipes/time-breakdown/ ===
pipe.md
=== /volume1/screenpipe/pipes/video-export/ ===
pipe.md
Bash
Read pipe markdown files
IN
cat /volume1/screenpipe/pipes/day-recap/pipe.md && echo "===" && cat /volume1/screenpipe/pipes/meeting-summary/pipe.md 2>/dev/null | head -50
Copy code to clipboard
OUT
---
schedule: manual
enabled: true
template: true
title: Day Recap
description: "Today's accomplishments, key moments, and unfinished work"
icon: "📋"
featured: true
---
Analyze my screen and audio recordings from today (last 16 hours only).
Read screenpipe skill first.
Use this exact format:
## Summary
One sentence: what I mainly did today.
## Accomplishments
- Top 3 things I finished, with timestamps (e.g. "2:30 PM")
- Name specific apps, files, or projects
## Key Moments
- Important things I saw, said, or heard — with timestamps
## Unfinished Work
- What I should continue tomorrow — name the app/file/task
## Patterns
- Apps I used most, topics that came up repeatedly
Only report what you can verify from the data. End with: "**Next step:** [most important thing to continue]"
===
---
schedule: manual
enabled: true
template: true
title: Meeting Summary
description: "Summarize meeting transcript with key takeaways and action items"
icon: "🤝"
featured: false
---
Summarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.
Read screenpipe skill first.
Use this exact format:
## Meeting Summary
One sentence: what this meeting was about.
## Key Takeaways
- Top 3-5 important points discussed
- Include who said what when relevant
## Action Items
- [ ] Task — assigned to whom, deadline if mentioned
- [ ] Task — assigned to whom
## Decisions Made
- List any decisions or agreements reached
## Open Questions
- Anything unresolved or needing follow-up
Keep it concise and actionable.
Thinking
Thinking
Bash
Read summary consumer
IN
ls /volume1/screenpipe/app/consumers/ && cat /volume1/screenpipe/app/consumers/summary.py
Copy code to clipboard
OUT
activity.py
audio.py
elements.py
__init__.py
interactions.py
ocr.py
__pycache__
report.py
summary.py
"""AI summary generator using Claude."""
import os
from datetime import date
from typing import Any
from consumers.activity import app_time, summary_stats, browser_urls, ui_event_summary
from consumers.ocr import deduplicated_text
from consumers.audio import formatted_transcript
SUMMARY_TYPES = {
"day_recap": {
"title": "Day Recap",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
## Audio/speech:
{audio}
Write a concise day recap using EXACTLY this format:
## Summary
One sentence: what I mainly worked on today.
## Accomplishments
- Top 3 things I finished, with approximate times
- Name specific apps, files, or projects
## Key Moments
- Important things seen or heard, with timestamps
## Unfinished Work
- What to continue tomorrow
## Patterns
- Apps used most, topics that came up repeatedly
Only report what you can verify from the data. End with:
**Next step:** [most important thing to continue]""",
},
"standup": {
"title": "Standup Update",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
## Audio/speech:
{audio}
Write a brief standup update:
**Yesterday:** What I worked on (2-3 bullets)
**Today:** What I plan to continue (1-2 bullets)
**Blockers:** Any issues observed (or "None")
Keep it under 150 words. Only report what's verifiable from the data.""",
},
"focus_time": {
"title": "Focus & Distraction Analysis",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
Analyze focus vs distraction patterns:
## Deep Work Periods
- When and how long were sustained focus sessions?
- What was being worked on?
## Distractions
- Which apps/sites were used recreationally?
- How much time was lost to context switching?
## Recommendations
- 2-3 concrete suggestions to improve focus tomorrow
Be specific with times and app names.""",
},
}
def _build_context(for_date: date) -> dict[str, str]:
apps = app_time(for_date)
app_lines = "\n".join(f"- {a['app_name']}: {a['minutes']} min" for a in apps[:20])
urls = browser_urls(for_date, limit=20)
url_lines = "\n".join(
f"- {u['browser_url'][:100]} ({u['minutes']} min)" for u in urls
)
ui_rows = ui_event_summary(for_date)
ui_lines = "\n".join(
f"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches"
for r in ui_rows[:15]
)
ocr_rows = deduplicated_text(for_date, chunk_minutes=5)
ocr_lines = "\n".join(
f"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}"
for r in ocr_rows[:100]
)
audio = formatted_transcript(for_date)
return {
"app_time": app_lines or "(no app data)",
"browser_urls": url_lines or "(no browser data)",
"ui_events": ui_lines or "(no UI event data)",
"ocr_text": ocr_lines or "(no screen data)",
"audio": audio[:3000] if len(audio) > 3000 else audio,
}
def generate(
summary_type: str = "day_recap",
for_date: date | None = None,
api_key: str | None = None,
) -> dict[str, Any]:
"""Generate an AI summary. Returns dict with 'title', 'content', 'date'."""
import anthropic
d = for_date or date.today()
key = api_key or os.environ.get("ANTHROPIC_API_KEY", "")
if not key:
return {
"title": "Error",
"content": "ANTHROPIC_API_KEY not set. Add it to your .env file.",
"date": str(d),
}
spec = SUMMARY_TYPES.get(summary_type)
if not spec:
return {"title": "Error", "content": f"Unknown summary type: {summary_type}", "date": str(d)}
stats = summary_stats(d)
if stats["total_frames"] == 0:
return {
"title": spec["title"],
"content": f"No screen data found for {d}.",
"date": str(d),
}
ctx = _build_context(d)
prompt = spec["prompt"].format(**ctx)
client = anthropic.Anthropic(api_key=key)
message = client.messages.create(
model="claude-haiku-4-5-20251001",
max_tokens=1024,
messages=[{"role": "user", "content": prompt}],
)
return {
"title": spec["title"],
"content": message.content[0].text,
"date": str(d),
"stats": stats,
}
Thinking
Thinking
Bash
Read all pipe.md files
IN
for f in /volume1/screenpipe/pipes/*/pipe.md; do echo "=== $f ==="; cat "$f"; echo; done
Copy code to clipboard
OUT
=== /volume1/screenpipe/pipes/ai-habits/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: AI Habits
description: "How you use AI tools — patterns and insights"
icon: "🤖"
featured: true
---
Search my recordings from the last 24 hours for AI tool usage. Use app_name filter for each tool separately: ChatGPT, Claude, Copilot, Cursor, Gemini, Perplexity. Use limit=5 per search, max 6 searches total.
Read screenpipe skill first.
Use this exact format:
## AI Tools Used
- List each tool with approximate time spent (e.g. "Claude: ~45min")
## What I Used Them For
- For each tool: coding, writing, research, or brainstorming
## Usage Patterns
- Do I switch between tools? Use them in bursts or steadily?
## Effectiveness
- Which tool appeared alongside completed work vs. abandoned attempts
If no AI usage is found, say so clearly. End with: "**Tip:** [one suggestion to use AI tools more effectively]"
=== /volume1/screenpipe/pipes/day-recap/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Day Recap
description: "Today's accomplishments, key moments, and unfinished work"
icon: "📋"
featured: true
---
Analyze my screen and audio recordings from today (last 16 hours only).
Read screenpipe skill first.
Use this exact format:
## Summary
One sentence: what I mainly did today.
## Accomplishments
- Top 3 things I finished, with timestamps (e.g. "2:30 PM")
- Name specific apps, files, or projects
## Key Moments
- Important things I saw, said, or heard — with timestamps
## Unfinished Work
- What I should continue tomorrow — name the app/file/task
## Patterns
- Apps I used most, topics that came up repeatedly
Only report what you can verify from the data. End with: "**Next step:** [most important thing to continue]"
=== /volume1/screenpipe/pipes/meeting-summary/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Meeting Summary
description: "Summarize meeting transcript with key takeaways and action items"
icon: "🤝"
featured: false
---
Summarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.
Read screenpipe skill first.
Use this exact format:
## Meeting Summary
One sentence: what this meeting was about.
## Key Takeaways
- Top 3-5 important points discussed
- Include who said what when relevant
## Action Items
- [ ] Task — assigned to whom, deadline if mentioned
- [ ] Task — assigned to whom
## Decisions Made
- List any decisions or agreements reached
## Open Questions
- Anything unresolved or needing follow-up
Keep it concise and actionable.
=== /volume1/screenpipe/pipes/standup-update/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Standup Update
description: "What you did, what's next, and any blockers"
icon: "🏢"
featured: true
---
Based on my recordings from the last 24 hours, generate a standup update. Use limit=10 per search, max 3 searches total.
Read screenpipe skill first.
Use this exact format:
## Yesterday
- What I worked on (name specific projects, files, tools, PRs)
## Today
- What I will work on next (based on unfinished tasks and recent activity)
## Blockers
- Issues I hit — errors, slow builds, waiting on someone
- If no blockers, write "None"
Keep it under 150 words. Copy-paste ready for a team standup.
=== /volume1/screenpipe/pipes/time-breakdown/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Time Breakdown
description: "Where your time went — by app, project, and category"
icon: "⏱"
featured: false
---
Analyze my app usage from today (last 12 hours). Use limit=10 per search, max 4 searches. Prefer /raw_sql with COUNT/GROUP BY queries.
Read screenpipe skill first.
Use this exact format with durations and percentages:
## By Application
- List each app with duration and percentage, sorted by time (e.g. "VS Code: 2h 15min (28%)")
## By Category
- Group into: coding, meetings, browsing, writing, communication, other
- Show hours and percentage per category
## By Project
- Group related activities by project/topic. Name specific repos or tasks.
## Productivity Score
- Calculate: focused_work_hours / total_hours as a percentage
- Focused = coding + writing. Unfocused = browsing + switching.
End with: "**Suggestion:** [one specific change to improve tomorrow's productivity]"
=== /volume1/screenpipe/pipes/video-export/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Export Video Clip
description: "Create a video of your recent screen activity"
icon: "🎬"
featured: false
---
Export a video of my screen activity from the last 5 minutes.
Read screenpipe skill first.
Use the POST /frames/export endpoint with the time range and fps=1.0. Then show me the exported video file path as an inline code block so I can watch it.
If the export is large, suggest a lower fps or shorter time range.
Thinking
Thinking
Now I have a clear picture. The pipes are markdown prompt templates in
/volume1/screenpipe/pipes/
, but there's no code to actually load and run them —
consumers/summary.py
has its own hardcoded prompts instead.
Here's what I'll implement:
consumers/pipes.py
— dynamically loads pipe.md files and runs them via Claude (data injected as system message, pipe body as user prompt)
main.py
— two new endpoints:...
|
21066
|
NULL
|
NULL
|
NULL
|
|
21069
|
921
|
5
|
2026-05-11T17:08:36.559641+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-11/1778 /Users/lukas/.screenpipe/data/data/2026-05-11/1778519316559_m2.jpg...
|
Code
|
Implement and run pipe l… — screenpipe [SSH: nas]
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧ Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py
M
db.py
docker-compose.yml
Dockerfile
M
main.py
M
requirements.txt
M
data
logs
pipes
.gitignore
app_settings.json
archive.db
archive.db-bak
U
db.sqlite
db.sqlite-shm
db.sqlite-wal
screenpipe_sync_updated.sh
U
screenpipe_sync.sh
screenpipe.db
Outline Section
OUTLINE
OUTLINE
Timeline Section
TIMELINE
TIMELINE
app_settings.json, Editor Group 1
screenpipe_sync.sh, Editor Group 1
pipe.md, Editor Group 1
.env, Editor Group 1
[ENV_SECRET]
[ENV_SECRET]
Implement and run pipe l…, Editor Group 2
Problems (⇧⌘M)
PROBLEMS
Output (⇧⌘U)
OUTPUT
Debug Console (⇧⌘Y)
DEBUG CONSOLE
Terminal (⌃`)
TERMINAL
Ports - 1 forwarded port
PORTS
1
remote SSH: nas
SSH: nas
screenpipe (Git) - master*, Checkout Branch/Tag...
master*
screenpipe (Git) - Synchronize Changes
No Problems
0
0
Forwarded Ports: 8766
1
Notifications
Sign In
Sign In
Info: Setting up SSH Host nas: Setting up SSH tunnel
Implement and run pipe logic
Session history
New session
Message actions
main.py
main.py
lets implement logic with pipes. how can I run it?
Thinking
Thinking
Let me look at the current project structure to understand what's already in place.
Bash
List project files
IN
find /volume1/screenpipe -type f | head -50 && echo "---" && ls /volume1/screenpipe
Copy code to clipboard
OUT
/volume1/screenpipe/.DS_Store
/volume1/screenpipe/screenpipe.db
/volume1/screenpipe/screenpipe_sync.sh
/volume1/screenpipe/app_settings.json
/volume1/screenpipe/.gitignore
/volume1/screenpipe/archive.db
/volume1/screenpipe/db.sqlite
/volume1/screenpipe/db.sqlite-wal
/volume1/screenpipe/db.sqlite-shm
/volume1/screenpipe/#recycle/desktop.ini
/volume1/screenpipe/#recycle/db.sqlite
/volume1/screenpipe/#recycle/Copy #1 of db.sqlite
/volume1/screenpipe/#recycle/.DS_Store
/volume1/screenpipe/#recycle/Copy #2 of db.sqlite
/volume1/screenpipe/#recycle/archive.db
/volume1/screenpipe/#recycle/Copy #1 of archive.db
/volume1/screenpipe/#recycle/Copy #2 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of archive.db
/volume1/screenpipe/#recycle/Copy #4 of archive.db
/volume1/screenpipe/#recycle/Copy #5 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of db.sqlite
/volume1/screenpipe/#recycle/Copy #4 of db.sqlite
/volume1/screenpipe/#recycle/Copy #6 of archive.db
/volume1/screenpipe/#recycle/test.txt
/volume1/screenpipe/#recycle/Copy #7 of archive.db
/volume1/screenpipe/#recycle/Copy #8 of archive.db
/volume1/screenpipe/#recycle/archive.db-journal
/volume1/screenpipe/#recycle/Copy #1 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #2 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #3 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #4 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #6 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #7 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of db.sqlite
/volume1/screenpipe/pipes/.DS_Store
/volume1/screenpipe/app/.env
/volume1/screenpipe/app/cli.py
/volume1/screenpipe/app/.DS_Store
/volume1/screenpipe/app/db.py
/volume1/screenpipe/app/docker-compose.yml
/volume1/screenpipe/app/main.py
/volume1/screenpipe/app/requirements.txt
/volume1/screenpipe/app/Dockerfile
/volume1/screenpipe/data/.DS_Store
/volume1/screenpipe/.git/description
/volume1/screenpipe/.git/HEAD
/volume1/screenpipe/.git/index
/volume1/screenpipe/.git/COMMIT_EDITMSG
/volume1/screenpipe/#recycle/data/.DS_Store
---
app
app_settings.json
archive.db
data
db.sqlite
db.sqlite-shm
db.sqlite-wal
pipes
#recycle
screenpipe.db
screenpipe_sync.sh
Read
main.py
main.py
Bash
Check pipes directory and docker-compose
IN
ls /volume1/screenpipe/pipes/ && ls /volume1/screenpipe/app/ && cat /volume1/screenpipe/app/docker-compose.yml
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
cli.py
consumers
db.py
docker-compose.yml
Dockerfile
main.py
__pycache__
requirements.txt
static
services:
screenpipe-app:
build: .
container_name: screenpipe-app
restart: unless-stopped
ports:
- "8766:8000"
volumes:
- /volume1/screenpipe:/data
env_file:
- .env
environment:
TZ: Europe/Sofia
DB_PATH: /data/db.sqlite
sqlite-web-archive:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-archive
restart: unless-stopped
ports:
- "8767:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/archive.db"]
sqlite-web-live:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-live
restart: unless-stopped
ports:
- "8768:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/db.sqlite"]
Read
requirements.txt...
|
[{"role":"AXRadioButton","text [{"role":"AXRadioButton","text":"Explorer (⇧⌘E)","depth":19,"bounds":{"left":0.0,"top":0.047885075,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":true},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.057462092,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Search (⇧⌘F)","depth":19,"bounds":{"left":0.0,"top":0.08619314,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.09577015,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Source Control (⌃⇧G) - 10 pending changes","depth":19,"bounds":{"left":0.0,"top":0.1245012,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.13407822,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"10","depth":22,"bounds":{"left":0.00831117,"top":0.1452514,"width":0.003656915,"height":0.008778931},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.00831117,"top":0.14604948,"width":0.0016622341,"height":0.007980846}},{"char_start":1,"char_count":1,"bounds":{"left":0.009973404,"top":0.14604948,"width":0.0023271276,"height":0.007980846}}],"role_description":"text"},{"role":"AXRadioButton","text":"Run and Debug (⇧⌘D)","depth":19,"bounds":{"left":0.0,"top":0.16280925,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.17238627,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Remote Explorer","depth":19,"bounds":{"left":0.0,"top":0.20111732,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.21069433,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Extensions (⇧⌘X) - 2 require update","depth":19,"bounds":{"left":0.0,"top":0.23942538,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.2490024,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"2","depth":22,"bounds":{"left":0.009640957,"top":0.2601756,"width":0.0019946808,"height":0.008778931},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Claude Code","depth":19,"bounds":{"left":0.0,"top":0.27773345,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"Containers","depth":19,"bounds":{"left":0.0,"top":0.3160415,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXHeading","text":"EXPLORER","depth":17,"bounds":{"left":0.022606382,"top":0.047885075,"width":0.018949468,"height":0.02793296},"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"EXPLORER","depth":18,"bounds":{"left":0.022606382,"top":0.056664005,"width":0.018949468,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.022606382,"top":0.056664005,"width":0.0023271276,"height":0.0103751}},{"char_start":1,"char_count":7,"bounds":{"left":0.024933511,"top":0.056664005,"width":0.01662234,"height":0.0103751}}],"role_description":"text"},{"role":"AXButton","text":"Explorer Section: screenpipe [SSH: nas]","depth":21,"bounds":{"left":0.015957447,"top":0.07581804,"width":0.09940159,"height":0.017557861},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":true},{"role":"AXStaticText","text":"","depth":23,"bounds":{"left":0.01662234,"top":0.07821229,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"Explorer Section: screenpipe [SSH: nas]","depth":22,"bounds":{"left":0.022606382,"top":0.07581804,"width":0.045877658,"height":0.017557861},"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"SCREENPIPE [SSH: NAS]","depth":23,"bounds":{"left":0.022606382,"top":0.079010375,"width":0.045877658,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.022606382,"top":0.07980846,"width":0.0026595744,"height":0.0103751}},{"char_start":1,"char_count":20,"bounds":{"left":0.025265958,"top":0.07980846,"width":0.043218084,"height":0.0103751}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.09577015,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"#recycle","depth":27,"bounds":{"left":0.025930852,"top":0.09577015,"width":0.017287234,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.096568234,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":7,"bounds":{"left":0.028590426,"top":0.096568234,"width":0.01462766,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.11332801,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"app","depth":27,"bounds":{"left":0.025930852,"top":0.11332801,"width":0.0076462766,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.11412609,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":2,"bounds":{"left":0.02825798,"top":0.11412609,"width":0.005319149,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.11412609,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.022273935,"top":0.13088587,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"__pycache__","depth":27,"bounds":{"left":0.028590426,"top":0.13088587,"width":0.026595745,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.13168396,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":10,"bounds":{"left":0.030917553,"top":0.13168396,"width":0.024268618,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.022273935,"top":0.14844373,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"consumers","depth":27,"bounds":{"left":0.028590426,"top":0.14844373,"width":0.022273935,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.14924182,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":8,"bounds":{"left":0.030917553,"top":0.14924182,"width":0.019946808,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.14924182,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.022273935,"top":0.1660016,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"static","depth":27,"bounds":{"left":0.028590426,"top":0.1660016,"width":0.010970744,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.16679968,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":5,"bounds":{"left":0.030917553,"top":0.16679968,"width":0.008976064,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.16679968,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.1819633,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":".env","depth":27,"bounds":{"left":0.028590426,"top":0.18355946,"width":0.00831117,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.18435754,"width":0.0013297872,"height":0.011971269}},{"char_start":1,"char_count":3,"bounds":{"left":0.029920213,"top":0.18435754,"width":0.006981383,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.19952115,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"cli.py","depth":27,"bounds":{"left":0.028590426,"top":0.20111732,"width":0.010638298,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.2019154,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":5,"bounds":{"left":0.030917553,"top":0.2019154,"width":0.00831117,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.2019154,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.21707901,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.py","depth":27,"bounds":{"left":0.028590426,"top":0.21867518,"width":0.011303191,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.21947326,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":4,"bounds":{"left":0.03125,"top":0.21947326,"width":0.008643617,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.23463687,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"docker-compose.yml","depth":27,"bounds":{"left":0.028590426,"top":0.23623304,"width":0.042220745,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.23703113,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":17,"bounds":{"left":0.03125,"top":0.23703113,"width":0.03956117,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.25219473,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Dockerfile","depth":27,"bounds":{"left":0.028590426,"top":0.25379092,"width":0.020611702,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.254589,"width":0.0033244682,"height":0.011971269}},{"char_start":1,"char_count":9,"bounds":{"left":0.031914894,"top":0.254589,"width":0.017287234,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.254589,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.2697526,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"main.py","depth":27,"bounds":{"left":0.028590426,"top":0.27134877,"width":0.015625,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.27214685,"width":0.003656915,"height":0.011971269}},{"char_start":1,"char_count":6,"bounds":{"left":0.032247342,"top":0.27214685,"width":0.012300532,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.27214685,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.28731045,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"requirements.txt","depth":27,"bounds":{"left":0.028590426,"top":0.28890663,"width":0.032912236,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.2897047,"width":0.0016622341,"height":0.011971269}},{"char_start":1,"char_count":15,"bounds":{"left":0.03025266,"top":0.2897047,"width":0.03158245,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.2897047,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.3064645,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"data","depth":27,"bounds":{"left":0.025930852,"top":0.3064645,"width":0.008976064,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.30726257,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":3,"bounds":{"left":0.028590426,"top":0.30726257,"width":0.0063164895,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.32402235,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"logs","depth":27,"bounds":{"left":0.025930852,"top":0.32402235,"width":0.00831117,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.32482043,"width":0.0009973404,"height":0.011971269}},{"char_start":1,"char_count":3,"bounds":{"left":0.026928192,"top":0.32482043,"width":0.0076462766,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.32482043,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.3415802,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"pipes","depth":27,"bounds":{"left":0.025930852,"top":0.3415802,"width":0.010970744,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.3423783,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":4,"bounds":{"left":0.028590426,"top":0.3423783,"width":0.00831117,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.3575419,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":".gitignore","depth":27,"bounds":{"left":0.025930852,"top":0.35913807,"width":0.018949468,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.35993615,"width":0.0013297872,"height":0.011971269}},{"char_start":1,"char_count":9,"bounds":{"left":0.027260639,"top":0.35993615,"width":0.017952127,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.37509975,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"app_settings.json","depth":27,"bounds":{"left":0.025930852,"top":0.37669593,"width":0.03557181,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.377494,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":16,"bounds":{"left":0.02825798,"top":0.377494,"width":0.03324468,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.3926576,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"archive.db","depth":27,"bounds":{"left":0.025930852,"top":0.3942538,"width":0.020944148,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.39505187,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":9,"bounds":{"left":0.02825798,"top":0.39505187,"width":0.01861702,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.4102155,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"archive.db-bak","depth":27,"bounds":{"left":0.025930852,"top":0.41181165,"width":0.03025266,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.41260973,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":13,"bounds":{"left":0.02825798,"top":0.41260973,"width":0.027925532,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"U","depth":27,"bounds":{"left":0.10704787,"top":0.41260973,"width":0.0029920214,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.42777336,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite","depth":27,"bounds":{"left":0.025930852,"top":0.4293695,"width":0.017287234,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.4301676,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":8,"bounds":{"left":0.028590426,"top":0.4301676,"width":0.014960106,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.44533122,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite-shm","depth":27,"bounds":{"left":0.025930852,"top":0.44692737,"width":0.027925532,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.44772545,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":12,"bounds":{"left":0.028590426,"top":0.44772545,"width":0.025265958,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.46288908,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite-wal","depth":27,"bounds":{"left":0.025930852,"top":0.46448523,"width":0.025930852,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.46528333,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":12,"bounds":{"left":0.028590426,"top":0.46528333,"width":0.023603724,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.48044693,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe_sync_updated.sh","depth":27,"bounds":{"left":0.025930852,"top":0.4820431,"width":0.059175532,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.4828412,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":25,"bounds":{"left":0.02825798,"top":0.4828412,"width":0.056848403,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"U","depth":27,"bounds":{"left":0.10704787,"top":0.4828412,"width":0.0029920214,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.4980048,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe_sync.sh","depth":27,"bounds":{"left":0.025930852,"top":0.49960095,"width":0.039893616,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.50039905,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":17,"bounds":{"left":0.02825798,"top":0.50039905,"width":0.037898935,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.51556265,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe.db","depth":27,"bounds":{"left":0.025930852,"top":0.5171588,"width":0.028590426,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.5179569,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":12,"bounds":{"left":0.02825798,"top":0.5179569,"width":0.026595745,"height":0.011971269}}],"role_description":"text"},{"role":"AXButton","text":"Outline Section","depth":21,"bounds":{"left":0.015957447,"top":0.9473264,"width":0.09940159,"height":0.017557861},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":23,"bounds":{"left":0.01662234,"top":0.9497207,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"OUTLINE","depth":22,"bounds":{"left":0.022606382,"top":0.9473264,"width":0.01662234,"height":0.017557861},"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"OUTLINE","depth":23,"bounds":{"left":0.022606382,"top":0.95131683,"width":0.01662234,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.022606382,"top":0.95131683,"width":0.0029920214,"height":0.0103751}},{"char_start":1,"char_count":6,"bounds":{"left":0.025598405,"top":0.95131683,"width":0.013630319,"height":0.0103751}}],"role_description":"text"},{"role":"AXButton","text":"Timeline Section","depth":21,"bounds":{"left":0.015957447,"top":0.9648843,"width":0.09940159,"height":0.017557861},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":23,"bounds":{"left":0.01662234,"top":0.96727854,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"TIMELINE","depth":22,"bounds":{"left":0.022606382,"top":0.9648843,"width":0.01761968,"height":0.017557861},"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"TIMELINE","depth":23,"bounds":{"left":0.022606382,"top":0.9688747,"width":0.01761968,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.022606382,"top":0.9688747,"width":0.0026595744,"height":0.0103751}},{"char_start":1,"char_count":7,"bounds":{"left":0.025265958,"top":0.9688747,"width":0.015292553,"height":0.0103751}}],"role_description":"text"},{"role":"AXRadioButton","text":"app_settings.json, Editor Group 1","depth":28,"bounds":{"left":0.11569149,"top":0.047885075,"width":0.055851065,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"screenpipe_sync.sh, Editor Group 1","depth":28,"bounds":{"left":0.17154256,"top":0.047885075,"width":0.06050532,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"pipe.md, Editor Group 1","depth":28,"bounds":{"left":0.23171543,"top":0.047885075,"width":0.040226065,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":".env, Editor Group 1","depth":28,"bounds":{"left":0.27194148,"top":0.047885075,"width":0.039893616,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":false},{"role":"AXStaticText","text":"","depth":29,"bounds":{"left":0.12832446,"top":0.07821229,"width":0.0056515955,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXTextArea","text":"ANTHROPIC_API_KEY=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","depth":28,"bounds":{"left":0.13763298,"top":0.10774142,"width":0.30285904,"height":0.014365523},"on_screen":true,"value":"ANTHROPIC_API_KEY=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","role_description":"editor","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"ANTHROPIC_API_KEY=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","depth":29,"bounds":{"left":0.13763298,"top":0.09497207,"width":0.30285904,"height":0.011173184},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.13763298,"top":0.09497207,"width":0.0023271276,"height":0.011173184}},{"char_start":1,"char_count":125,"bounds":{"left":0.13996011,"top":0.09497207,"width":0.30053192,"height":0.011173184}}],"role_description":"text"},{"role":"AXRadioButton","text":"Implement and run pipe l…, Editor Group 2","depth":28,"bounds":{"left":0.5578458,"top":0.047885075,"width":0.073803194,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":false},{"role":"AXRadioButton","text":"Problems (⇧⌘M)","depth":22,"bounds":{"left":0.118351065,"top":0.7278532,"width":0.027925532,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"PROBLEMS","depth":24,"bounds":{"left":0.122340426,"top":0.7366321,"width":0.019946808,"height":0.0103751},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Output (⇧⌘U)","depth":22,"bounds":{"left":0.14594415,"top":0.7278532,"width":0.023603724,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUTPUT","depth":24,"bounds":{"left":0.14993352,"top":0.7366321,"width":0.015625,"height":0.0103751},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Debug Console (⇧⌘Y)","depth":22,"bounds":{"left":0.16921543,"top":0.7278532,"width":0.039893616,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"DEBUG CONSOLE","depth":24,"bounds":{"left":0.1732048,"top":0.7366321,"width":0.031914894,"height":0.0103751},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Terminal (⌃`)","depth":22,"bounds":{"left":0.2087766,"top":0.7278532,"width":0.026595745,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":true},{"role":"AXStaticText","text":"TERMINAL","depth":24,"bounds":{"left":0.21276596,"top":0.7366321,"width":0.01861702,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.2130984,"top":0.73743016,"width":0.0023271276,"height":0.0103751}},{"char_start":1,"char_count":7,"bounds":{"left":0.21542554,"top":0.73743016,"width":0.016289894,"height":0.0103751}}],"role_description":"text"},{"role":"AXRadioButton","text":"Ports - 1 forwarded port","depth":22,"bounds":{"left":0.23537233,"top":0.7278532,"width":0.026263298,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"PORTS","depth":24,"bounds":{"left":0.2393617,"top":0.7366321,"width":0.012300532,"height":0.0103751},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":25,"bounds":{"left":0.25465426,"top":0.73743016,"width":0.0019946808,"height":0.008778931},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"remote SSH: nas","depth":16,"bounds":{"left":0.0006648936,"top":0.98244214,"width":0.028590426,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.0033244682,"top":0.9848364,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"SSH: nas","depth":17,"bounds":{"left":0.008643617,"top":0.9856345,"width":0.017952127,"height":0.011173184},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.008643617,"top":0.9856345,"width":0.0013297872,"height":0.011173184}},{"char_start":1,"char_count":7,"bounds":{"left":0.009973404,"top":0.9856345,"width":0.01462766,"height":0.011173184}}],"role_description":"text"},{"role":"AXButton","text":"screenpipe (Git) - master*, Checkout Branch/Tag...","depth":16,"bounds":{"left":0.030917553,"top":0.98244214,"width":0.023271276,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.031914894,"top":0.9848364,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"master*","depth":17,"bounds":{"left":0.03723404,"top":0.9856345,"width":0.015957447,"height":0.011173184},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.03723404,"top":0.9856345,"width":0.0013297872,"height":0.011173184}},{"char_start":1,"char_count":6,"bounds":{"left":0.03856383,"top":0.9856345,"width":0.012965426,"height":0.011173184}}],"role_description":"text"},{"role":"AXButton","text":"screenpipe (Git) - Synchronize Changes","depth":16,"bounds":{"left":0.05418883,"top":0.98244214,"width":0.00731383,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"No Problems","depth":16,"bounds":{"left":0.06416223,"top":0.98244214,"width":0.022606382,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.06582447,"top":0.9848364,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"0","depth":17,"bounds":{"left":0.07114362,"top":0.9856345,"width":0.004986702,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.07579787,"top":0.9848364,"width":0.0056515955,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"0","depth":17,"bounds":{"left":0.08111702,"top":0.9856345,"width":0.0039893617,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Forwarded Ports: 8766","depth":16,"bounds":{"left":0.08843085,"top":0.98244214,"width":0.012632979,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.09009308,"top":0.9848364,"width":0.0056515955,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":17,"bounds":{"left":0.09541223,"top":0.9856345,"width":0.0039893617,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Notifications","depth":16,"bounds":{"left":0.9886968,"top":0.98244214,"width":0.010638298,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sign In","depth":16,"bounds":{"left":0.9650931,"top":0.98244214,"width":0.022606382,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.96675533,"top":0.9848364,"width":0.0056515955,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Sign In","depth":17,"bounds":{"left":0.97207445,"top":0.9856345,"width":0.013962766,"height":0.011173184},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.97207445,"top":0.9856345,"width":0.0013297872,"height":0.011173184}},{"char_start":1,"char_count":6,"bounds":{"left":0.9734042,"top":0.9856345,"width":0.010638298,"height":0.011173184}}],"role_description":"text"},{"role":"AXStaticText","text":"Info: Setting up SSH Host nas: Setting up SSH tunnel","depth":12,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Implement and run pipe logic","depth":19,"bounds":{"left":0.56017286,"top":0.08060654,"width":0.07114362,"height":0.022346368},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Session history","depth":19,"bounds":{"left":0.9780585,"top":0.08060654,"width":0.00930851,"height":0.022346368},"on_screen":true,"help_text":"Session history","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"New session","depth":19,"bounds":{"left":0.9886968,"top":0.08060654,"width":0.00930851,"height":0.022346368},"on_screen":true,"help_text":"New session","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Message actions","depth":24,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"main.py","depth":23,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"lets implement logic with pipes. how can I run it?","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Let me look at the current project structure to understand what's already in place.","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"List project files","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"find /volume1/screenpipe -type f | head -50 && echo \"---\" && ls /volume1/screenpipe","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"/volume1/screenpipe/.DS_Store\n/volume1/screenpipe/screenpipe.db\n/volume1/screenpipe/screenpipe_sync.sh\n/volume1/screenpipe/app_settings.json\n/volume1/screenpipe/.gitignore\n/volume1/screenpipe/archive.db\n/volume1/screenpipe/db.sqlite\n/volume1/screenpipe/db.sqlite-wal\n/volume1/screenpipe/db.sqlite-shm\n/volume1/screenpipe/#recycle/desktop.ini\n/volume1/screenpipe/#recycle/db.sqlite\n/volume1/screenpipe/#recycle/Copy #1 of db.sqlite\n/volume1/screenpipe/#recycle/.DS_Store\n/volume1/screenpipe/#recycle/Copy #2 of db.sqlite\n/volume1/screenpipe/#recycle/archive.db\n/volume1/screenpipe/#recycle/Copy #1 of archive.db\n/volume1/screenpipe/#recycle/Copy #2 of archive.db\n/volume1/screenpipe/#recycle/Copy #3 of archive.db\n/volume1/screenpipe/#recycle/Copy #4 of archive.db\n/volume1/screenpipe/#recycle/Copy #5 of archive.db\n/volume1/screenpipe/#recycle/Copy #3 of db.sqlite\n/volume1/screenpipe/#recycle/Copy #4 of db.sqlite\n/volume1/screenpipe/#recycle/Copy #6 of archive.db\n/volume1/screenpipe/#recycle/test.txt\n/volume1/screenpipe/#recycle/Copy #7 of archive.db\n/volume1/screenpipe/#recycle/Copy #8 of archive.db\n/volume1/screenpipe/#recycle/archive.db-journal\n/volume1/screenpipe/#recycle/Copy #1 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #2 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #3 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #4 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #5 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #6 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #7 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #5 of db.sqlite\n/volume1/screenpipe/pipes/.DS_Store\n/volume1/screenpipe/app/.env\n/volume1/screenpipe/app/cli.py\n/volume1/screenpipe/app/.DS_Store\n/volume1/screenpipe/app/db.py\n/volume1/screenpipe/app/docker-compose.yml\n/volume1/screenpipe/app/main.py\n/volume1/screenpipe/app/requirements.txt\n/volume1/screenpipe/app/Dockerfile\n/volume1/screenpipe/data/.DS_Store\n/volume1/screenpipe/.git/description\n/volume1/screenpipe/.git/HEAD\n/volume1/screenpipe/.git/index\n/volume1/screenpipe/.git/COMMIT_EDITMSG\n/volume1/screenpipe/#recycle/data/.DS_Store\n---\napp\napp_settings.json\narchive.db\ndata\ndb.sqlite\ndb.sqlite-shm\ndb.sqlite-wal\npipes\n#recycle\nscreenpipe.db\nscreenpipe_sync.sh","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"main.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Check pipes directory and docker-compose","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/pipes/ && ls /volume1/screenpipe/app/ && cat /volume1/screenpipe/app/docker-compose.yml","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ai-habits\nday-recap\nmeeting-summary\nstandup-update\ntime-breakdown\nvideo-export\ncli.py\nconsumers\ndb.py\ndocker-compose.yml\nDockerfile\nmain.py\n__pycache__\nrequirements.txt\nstatic\nservices:\n screenpipe-app:\n build: .\n container_name: screenpipe-app\n restart: unless-stopped\n ports:\n - \"8766:8000\"\n volumes:\n - /volume1/screenpipe:/data\n env_file:\n - .env\n environment:\n TZ: Europe/Sofia\n DB_PATH: /data/db.sqlite\n\n sqlite-web-archive:\n image: ghcr.io/coleifer/sqlite-web:latest\n container_name: screenpipe-sqlweb-archive\n restart: unless-stopped\n ports:\n - \"8767:8080\"\n volumes:\n - /volume1/screenpipe:/data\n command: [\"-H\", \"0.0.0.0\", \"-r\", \"/data/archive.db\"]\n\n sqlite-web-live:\n image: ghcr.io/coleifer/sqlite-web:latest\n container_name: screenpipe-sqlweb-live\n restart: unless-stopped\n ports:\n - \"8768:8080\"\n volumes:\n - /volume1/screenpipe:/data\n command: [\"-H\", \"0.0.0.0\", \"-r\", \"/data/db.sqlite\"]","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"requirements.txt","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
-5968857123425162020
|
2774729678109247237
|
idle
|
accessibility
|
NULL
|
Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧ Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py
M
db.py
docker-compose.yml
Dockerfile
M
main.py
M
requirements.txt
M
data
logs
pipes
.gitignore
app_settings.json
archive.db
archive.db-bak
U
db.sqlite
db.sqlite-shm
db.sqlite-wal
screenpipe_sync_updated.sh
U
screenpipe_sync.sh
screenpipe.db
Outline Section
OUTLINE
OUTLINE
Timeline Section
TIMELINE
TIMELINE
app_settings.json, Editor Group 1
screenpipe_sync.sh, Editor Group 1
pipe.md, Editor Group 1
.env, Editor Group 1
[ENV_SECRET]
[ENV_SECRET]
Implement and run pipe l…, Editor Group 2
Problems (⇧⌘M)
PROBLEMS
Output (⇧⌘U)
OUTPUT
Debug Console (⇧⌘Y)
DEBUG CONSOLE
Terminal (⌃`)
TERMINAL
Ports - 1 forwarded port
PORTS
1
remote SSH: nas
SSH: nas
screenpipe (Git) - master*, Checkout Branch/Tag...
master*
screenpipe (Git) - Synchronize Changes
No Problems
0
0
Forwarded Ports: 8766
1
Notifications
Sign In
Sign In
Info: Setting up SSH Host nas: Setting up SSH tunnel
Implement and run pipe logic
Session history
New session
Message actions
main.py
main.py
lets implement logic with pipes. how can I run it?
Thinking
Thinking
Let me look at the current project structure to understand what's already in place.
Bash
List project files
IN
find /volume1/screenpipe -type f | head -50 && echo "---" && ls /volume1/screenpipe
Copy code to clipboard
OUT
/volume1/screenpipe/.DS_Store
/volume1/screenpipe/screenpipe.db
/volume1/screenpipe/screenpipe_sync.sh
/volume1/screenpipe/app_settings.json
/volume1/screenpipe/.gitignore
/volume1/screenpipe/archive.db
/volume1/screenpipe/db.sqlite
/volume1/screenpipe/db.sqlite-wal
/volume1/screenpipe/db.sqlite-shm
/volume1/screenpipe/#recycle/desktop.ini
/volume1/screenpipe/#recycle/db.sqlite
/volume1/screenpipe/#recycle/Copy #1 of db.sqlite
/volume1/screenpipe/#recycle/.DS_Store
/volume1/screenpipe/#recycle/Copy #2 of db.sqlite
/volume1/screenpipe/#recycle/archive.db
/volume1/screenpipe/#recycle/Copy #1 of archive.db
/volume1/screenpipe/#recycle/Copy #2 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of archive.db
/volume1/screenpipe/#recycle/Copy #4 of archive.db
/volume1/screenpipe/#recycle/Copy #5 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of db.sqlite
/volume1/screenpipe/#recycle/Copy #4 of db.sqlite
/volume1/screenpipe/#recycle/Copy #6 of archive.db
/volume1/screenpipe/#recycle/test.txt
/volume1/screenpipe/#recycle/Copy #7 of archive.db
/volume1/screenpipe/#recycle/Copy #8 of archive.db
/volume1/screenpipe/#recycle/archive.db-journal
/volume1/screenpipe/#recycle/Copy #1 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #2 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #3 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #4 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #6 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #7 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of db.sqlite
/volume1/screenpipe/pipes/.DS_Store
/volume1/screenpipe/app/.env
/volume1/screenpipe/app/cli.py
/volume1/screenpipe/app/.DS_Store
/volume1/screenpipe/app/db.py
/volume1/screenpipe/app/docker-compose.yml
/volume1/screenpipe/app/main.py
/volume1/screenpipe/app/requirements.txt
/volume1/screenpipe/app/Dockerfile
/volume1/screenpipe/data/.DS_Store
/volume1/screenpipe/.git/description
/volume1/screenpipe/.git/HEAD
/volume1/screenpipe/.git/index
/volume1/screenpipe/.git/COMMIT_EDITMSG
/volume1/screenpipe/#recycle/data/.DS_Store
---
app
app_settings.json
archive.db
data
db.sqlite
db.sqlite-shm
db.sqlite-wal
pipes
#recycle
screenpipe.db
screenpipe_sync.sh
Read
main.py
main.py
Bash
Check pipes directory and docker-compose
IN
ls /volume1/screenpipe/pipes/ && ls /volume1/screenpipe/app/ && cat /volume1/screenpipe/app/docker-compose.yml
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
cli.py
consumers
db.py
docker-compose.yml
Dockerfile
main.py
__pycache__
requirements.txt
static
services:
screenpipe-app:
build: .
container_name: screenpipe-app
restart: unless-stopped
ports:
- "8766:8000"
volumes:
- /volume1/screenpipe:/data
env_file:
- .env
environment:
TZ: Europe/Sofia
DB_PATH: /data/db.sqlite
sqlite-web-archive:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-archive
restart: unless-stopped
ports:
- "8767:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/archive.db"]
sqlite-web-live:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-live
restart: unless-stopped
ports:
- "8768:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/db.sqlite"]
Read
requirements.txt...
|
21067
|
NULL
|
NULL
|
NULL
|
|
21070
|
920
|
5
|
2026-05-11T17:08:48.337414+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-11/1778 /Users/lukas/.screenpipe/data/data/2026-05-11/1778519328337_m1.jpg...
|
Code
|
Implement and run pipe l… — screenpipe [SSH: nas]
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧ Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py
M
db.py
docker-compose.yml
Dockerfile
M
main.py
M
requirements.txt
M
data
logs
pipes
.gitignore
app_settings.json
archive.db
archive.db-bak
U
db.sqlite
db.sqlite-shm
db.sqlite-wal
screenpipe_sync_updated.sh
U
screenpipe_sync.sh
screenpipe.db
Outline Section
OUTLINE
OUTLINE
Timeline Section
TIMELINE
TIMELINE
app_settings.json, Editor Group 1
screenpipe_sync.sh, Editor Group 1
pipe.md, Editor Group 1
.env, Editor Group 1
[ENV_SECRET]
[ENV_SECRET]
Implement and run pipe l…, Editor Group 2
Problems (⇧⌘M)
PROBLEMS
Output (⇧⌘U)
OUTPUT
Debug Console (⇧⌘Y)
DEBUG CONSOLE
Terminal (⌃`)
TERMINAL
Ports - 1 forwarded port
PORTS
1
remote SSH: nas
SSH: nas
screenpipe (Git) - master*, Checkout Branch/Tag...
master*
screenpipe (Git) - Synchronize Changes
No Problems
0
0
Forwarded Ports: 8766
1
Notifications
Sign In
Sign In
Info: Setting up SSH Host nas: Setting up SSH tunnel
Implement and run pipe logic
Session history
New session
Message actions
main.py
main.py
lets implement logic with pipes. how can I run it?
Thinking
Thinking
Let me look at the current project structure to understand what's already in place.
Bash
List project files
IN
find /volume1/screenpipe -type f | head -50 && echo "---" && ls /volume1/screenpipe
Copy code to clipboard
OUT
/volume1/screenpipe/.DS_Store
/volume1/screenpipe/screenpipe.db
/volume1/screenpipe/screenpipe_sync.sh
/volume1/screenpipe/app_settings.json
/volume1/screenpipe/.gitignore
/volume1/screenpipe/archive.db
/volume1/screenpipe/db.sqlite
/volume1/screenpipe/db.sqlite-wal
/volume1/screenpipe/db.sqlite-shm
/volume1/screenpipe/#recycle/desktop.ini
/volume1/screenpipe/#recycle/db.sqlite
/volume1/screenpipe/#recycle/Copy #1 of db.sqlite
/volume1/screenpipe/#recycle/.DS_Store
/volume1/screenpipe/#recycle/Copy #2 of db.sqlite
/volume1/screenpipe/#recycle/archive.db
/volume1/screenpipe/#recycle/Copy #1 of archive.db
/volume1/screenpipe/#recycle/Copy #2 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of archive.db
/volume1/screenpipe/#recycle/Copy #4 of archive.db
/volume1/screenpipe/#recycle/Copy #5 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of db.sqlite
/volume1/screenpipe/#recycle/Copy #4 of db.sqlite
/volume1/screenpipe/#recycle/Copy #6 of archive.db
/volume1/screenpipe/#recycle/test.txt
/volume1/screenpipe/#recycle/Copy #7 of archive.db
/volume1/screenpipe/#recycle/Copy #8 of archive.db
/volume1/screenpipe/#recycle/archive.db-journal
/volume1/screenpipe/#recycle/Copy #1 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #2 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #3 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #4 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #6 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #7 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of db.sqlite
/volume1/screenpipe/pipes/.DS_Store
/volume1/screenpipe/app/.env
/volume1/screenpipe/app/cli.py
/volume1/screenpipe/app/.DS_Store
/volume1/screenpipe/app/db.py
/volume1/screenpipe/app/docker-compose.yml
/volume1/screenpipe/app/main.py
/volume1/screenpipe/app/requirements.txt
/volume1/screenpipe/app/Dockerfile
/volume1/screenpipe/data/.DS_Store
/volume1/screenpipe/.git/description
/volume1/screenpipe/.git/HEAD
/volume1/screenpipe/.git/index
/volume1/screenpipe/.git/COMMIT_EDITMSG
/volume1/screenpipe/#recycle/data/.DS_Store
---
app
app_settings.json
archive.db
data
db.sqlite
db.sqlite-shm
db.sqlite-wal
pipes
#recycle
screenpipe.db
screenpipe_sync.sh
Read
main.py
main.py
Bash
Check pipes directory and docker-compose
IN
ls /volume1/screenpipe/pipes/ && ls /volume1/screenpipe/app/ && cat /volume1/screenpipe/app/docker-compose.yml
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
cli.py
consumers
db.py
docker-compose.yml
Dockerfile
main.py
__pycache__
requirements.txt
static
services:
screenpipe-app:
build: .
container_name: screenpipe-app
restart: unless-stopped
ports:
- "8766:8000"
volumes:
- /volume1/screenpipe:/data
env_file:
- .env
environment:
TZ: Europe/Sofia
DB_PATH: /data/db.sqlite
sqlite-web-archive:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-archive
restart: unless-stopped
ports:
- "8767:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/archive.db"]
sqlite-web-live:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-live
restart: unless-stopped
ports:
- "8768:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/db.sqlite"]
Read
requirements.txt
requirements.txt
Bash
Inspect a pipe directory
IN
ls /volume1/screenpipe/pipes/day-recap/ && cat /volume1/screenpipe/pipes/day-recap/pipe.json 2>/dev/null || ls /volume1/screenpipe/pipes/day-recap/
Copy code to clipboard
OUT
pipe.md
pipe.md
Read
cli.py
cli.py
Bash
List all pipes and their contents
IN
ls /volume1/screenpipe/pipes/ && for d in /volume1/screenpipe/pipes/*/; do echo "=== $d ==="; ls "$d"; done
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
=== /volume1/screenpipe/pipes/ai-habits/ ===
pipe.md
=== /volume1/screenpipe/pipes/day-recap/ ===
pipe.md
=== /volume1/screenpipe/pipes/meeting-summary/ ===
pipe.md
=== /volume1/screenpipe/pipes/standup-update/ ===
pipe.md
=== /volume1/screenpipe/pipes/time-breakdown/ ===
pipe.md
=== /volume1/screenpipe/pipes/video-export/ ===
pipe.md
Bash...
|
[{"role":"AXRadioButton","text [{"role":"AXRadioButton","text":"Explorer (⇧⌘E)","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":true},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Search (⇧⌘F)","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Source Control (⌃⇧G) - 10 pending changes","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"10","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Run and Debug (⇧⌘D)","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Remote Explorer","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Extensions (⇧⌘X) - 2 require update","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"2","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Claude Code","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"Containers","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXHeading","text":"EXPLORER","depth":17,"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"EXPLORER","depth":18,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Explorer Section: screenpipe [SSH: nas]","depth":21,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":true},{"role":"AXStaticText","text":"","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"Explorer Section: screenpipe [SSH: nas]","depth":22,"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"SCREENPIPE [SSH: NAS]","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"#recycle","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"app","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"__pycache__","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"consumers","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"static","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":".env","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"cli.py","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.py","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"docker-compose.yml","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Dockerfile","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"main.py","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"requirements.txt","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"data","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"logs","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"pipes","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":".gitignore","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"app_settings.json","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"archive.db","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"archive.db-bak","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"U","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite-shm","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite-wal","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe_sync_updated.sh","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"U","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe_sync.sh","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe.db","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Outline Section","depth":21,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"OUTLINE","depth":22,"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"OUTLINE","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Timeline Section","depth":21,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"TIMELINE","depth":22,"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"TIMELINE","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"app_settings.json, Editor Group 1","depth":28,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"screenpipe_sync.sh, Editor Group 1","depth":28,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"pipe.md, Editor Group 1","depth":28,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":".env, Editor Group 1","depth":28,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":false},{"role":"AXStaticText","text":"","depth":29,"on_screen":true,"role_description":"text"},{"role":"AXTextArea","text":"ANTHROPIC_API_KEY=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","depth":28,"on_screen":true,"value":"ANTHROPIC_API_KEY=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","role_description":"editor","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"ANTHROPIC_API_KEY=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","depth":29,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Implement and run pipe l…, Editor Group 2","depth":28,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":false},{"role":"AXRadioButton","text":"Problems (⇧⌘M)","depth":22,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"PROBLEMS","depth":24,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Output (⇧⌘U)","depth":22,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUTPUT","depth":24,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Debug Console (⇧⌘Y)","depth":22,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"DEBUG CONSOLE","depth":24,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Terminal (⌃`)","depth":22,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":true},{"role":"AXStaticText","text":"TERMINAL","depth":24,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Ports - 1 forwarded port","depth":22,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"PORTS","depth":24,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":25,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"remote SSH: nas","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"SSH: nas","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"screenpipe (Git) - master*, Checkout Branch/Tag...","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"master*","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"screenpipe (Git) - Synchronize Changes","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"No Problems","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"0","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"0","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Forwarded Ports: 8766","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Notifications","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sign In","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Sign In","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Info: Setting up SSH Host nas: Setting up SSH tunnel","depth":12,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Implement and run pipe logic","depth":19,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Session history","depth":19,"on_screen":true,"help_text":"Session history","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"New session","depth":19,"on_screen":true,"help_text":"New session","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Message actions","depth":24,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"main.py","depth":23,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"lets implement logic with pipes. how can I run it?","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Let me look at the current project structure to understand what's already in place.","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"List project files","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"find /volume1/screenpipe -type f | head -50 && echo \"---\" && ls /volume1/screenpipe","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"/volume1/screenpipe/.DS_Store\n/volume1/screenpipe/screenpipe.db\n/volume1/screenpipe/screenpipe_sync.sh\n/volume1/screenpipe/app_settings.json\n/volume1/screenpipe/.gitignore\n/volume1/screenpipe/archive.db\n/volume1/screenpipe/db.sqlite\n/volume1/screenpipe/db.sqlite-wal\n/volume1/screenpipe/db.sqlite-shm\n/volume1/screenpipe/#recycle/desktop.ini\n/volume1/screenpipe/#recycle/db.sqlite\n/volume1/screenpipe/#recycle/Copy #1 of db.sqlite\n/volume1/screenpipe/#recycle/.DS_Store\n/volume1/screenpipe/#recycle/Copy #2 of db.sqlite\n/volume1/screenpipe/#recycle/archive.db\n/volume1/screenpipe/#recycle/Copy #1 of archive.db\n/volume1/screenpipe/#recycle/Copy #2 of archive.db\n/volume1/screenpipe/#recycle/Copy #3 of archive.db\n/volume1/screenpipe/#recycle/Copy #4 of archive.db\n/volume1/screenpipe/#recycle/Copy #5 of archive.db\n/volume1/screenpipe/#recycle/Copy #3 of db.sqlite\n/volume1/screenpipe/#recycle/Copy #4 of db.sqlite\n/volume1/screenpipe/#recycle/Copy #6 of archive.db\n/volume1/screenpipe/#recycle/test.txt\n/volume1/screenpipe/#recycle/Copy #7 of archive.db\n/volume1/screenpipe/#recycle/Copy #8 of archive.db\n/volume1/screenpipe/#recycle/archive.db-journal\n/volume1/screenpipe/#recycle/Copy #1 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #2 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #3 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #4 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #5 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #6 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #7 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #5 of db.sqlite\n/volume1/screenpipe/pipes/.DS_Store\n/volume1/screenpipe/app/.env\n/volume1/screenpipe/app/cli.py\n/volume1/screenpipe/app/.DS_Store\n/volume1/screenpipe/app/db.py\n/volume1/screenpipe/app/docker-compose.yml\n/volume1/screenpipe/app/main.py\n/volume1/screenpipe/app/requirements.txt\n/volume1/screenpipe/app/Dockerfile\n/volume1/screenpipe/data/.DS_Store\n/volume1/screenpipe/.git/description\n/volume1/screenpipe/.git/HEAD\n/volume1/screenpipe/.git/index\n/volume1/screenpipe/.git/COMMIT_EDITMSG\n/volume1/screenpipe/#recycle/data/.DS_Store\n---\napp\napp_settings.json\narchive.db\ndata\ndb.sqlite\ndb.sqlite-shm\ndb.sqlite-wal\npipes\n#recycle\nscreenpipe.db\nscreenpipe_sync.sh","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"main.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Check pipes directory and docker-compose","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/pipes/ && ls /volume1/screenpipe/app/ && cat /volume1/screenpipe/app/docker-compose.yml","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ai-habits\nday-recap\nmeeting-summary\nstandup-update\ntime-breakdown\nvideo-export\ncli.py\nconsumers\ndb.py\ndocker-compose.yml\nDockerfile\nmain.py\n__pycache__\nrequirements.txt\nstatic\nservices:\n screenpipe-app:\n build: .\n container_name: screenpipe-app\n restart: unless-stopped\n ports:\n - \"8766:8000\"\n volumes:\n - /volume1/screenpipe:/data\n env_file:\n - .env\n environment:\n TZ: Europe/Sofia\n DB_PATH: /data/db.sqlite\n\n sqlite-web-archive:\n image: ghcr.io/coleifer/sqlite-web:latest\n container_name: screenpipe-sqlweb-archive\n restart: unless-stopped\n ports:\n - \"8767:8080\"\n volumes:\n - /volume1/screenpipe:/data\n command: [\"-H\", \"0.0.0.0\", \"-r\", \"/data/archive.db\"]\n\n sqlite-web-live:\n image: ghcr.io/coleifer/sqlite-web:latest\n container_name: screenpipe-sqlweb-live\n restart: unless-stopped\n ports:\n - \"8768:8080\"\n volumes:\n - /volume1/screenpipe:/data\n command: [\"-H\", \"0.0.0.0\", \"-r\", \"/data/db.sqlite\"]","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"requirements.txt","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"requirements.txt","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Inspect a pipe directory","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/pipes/day-recap/ && cat /volume1/screenpipe/pipes/day-recap/pipe.json 2>/dev/null || ls /volume1/screenpipe/pipes/day-recap/","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"pipe.md\npipe.md","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"cli.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"cli.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"List all pipes and their contents","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/pipes/ && for d in /volume1/screenpipe/pipes/*/; do echo \"=== $d ===\"; ls \"$d\"; done","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ai-habits\nday-recap\nmeeting-summary\nstandup-update\ntime-breakdown\nvideo-export\n=== /volume1/screenpipe/pipes/ai-habits/ ===\npipe.md\n=== /volume1/screenpipe/pipes/day-recap/ ===\npipe.md\n=== /volume1/screenpipe/pipes/meeting-summary/ ===\npipe.md\n=== /volume1/screenpipe/pipes/standup-update/ ===\npipe.md\n=== /volume1/screenpipe/pipes/time-breakdown/ ===\npipe.md\n=== /volume1/screenpipe/pipes/video-export/ ===\npipe.md","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"}]...
|
-8437136971691210160
|
2643949388798334725
|
idle
|
accessibility
|
NULL
|
Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧ Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py
M
db.py
docker-compose.yml
Dockerfile
M
main.py
M
requirements.txt
M
data
logs
pipes
.gitignore
app_settings.json
archive.db
archive.db-bak
U
db.sqlite
db.sqlite-shm
db.sqlite-wal
screenpipe_sync_updated.sh
U
screenpipe_sync.sh
screenpipe.db
Outline Section
OUTLINE
OUTLINE
Timeline Section
TIMELINE
TIMELINE
app_settings.json, Editor Group 1
screenpipe_sync.sh, Editor Group 1
pipe.md, Editor Group 1
.env, Editor Group 1
[ENV_SECRET]
[ENV_SECRET]
Implement and run pipe l…, Editor Group 2
Problems (⇧⌘M)
PROBLEMS
Output (⇧⌘U)
OUTPUT
Debug Console (⇧⌘Y)
DEBUG CONSOLE
Terminal (⌃`)
TERMINAL
Ports - 1 forwarded port
PORTS
1
remote SSH: nas
SSH: nas
screenpipe (Git) - master*, Checkout Branch/Tag...
master*
screenpipe (Git) - Synchronize Changes
No Problems
0
0
Forwarded Ports: 8766
1
Notifications
Sign In
Sign In
Info: Setting up SSH Host nas: Setting up SSH tunnel
Implement and run pipe logic
Session history
New session
Message actions
main.py
main.py
lets implement logic with pipes. how can I run it?
Thinking
Thinking
Let me look at the current project structure to understand what's already in place.
Bash
List project files
IN
find /volume1/screenpipe -type f | head -50 && echo "---" && ls /volume1/screenpipe
Copy code to clipboard
OUT
/volume1/screenpipe/.DS_Store
/volume1/screenpipe/screenpipe.db
/volume1/screenpipe/screenpipe_sync.sh
/volume1/screenpipe/app_settings.json
/volume1/screenpipe/.gitignore
/volume1/screenpipe/archive.db
/volume1/screenpipe/db.sqlite
/volume1/screenpipe/db.sqlite-wal
/volume1/screenpipe/db.sqlite-shm
/volume1/screenpipe/#recycle/desktop.ini
/volume1/screenpipe/#recycle/db.sqlite
/volume1/screenpipe/#recycle/Copy #1 of db.sqlite
/volume1/screenpipe/#recycle/.DS_Store
/volume1/screenpipe/#recycle/Copy #2 of db.sqlite
/volume1/screenpipe/#recycle/archive.db
/volume1/screenpipe/#recycle/Copy #1 of archive.db
/volume1/screenpipe/#recycle/Copy #2 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of archive.db
/volume1/screenpipe/#recycle/Copy #4 of archive.db
/volume1/screenpipe/#recycle/Copy #5 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of db.sqlite
/volume1/screenpipe/#recycle/Copy #4 of db.sqlite
/volume1/screenpipe/#recycle/Copy #6 of archive.db
/volume1/screenpipe/#recycle/test.txt
/volume1/screenpipe/#recycle/Copy #7 of archive.db
/volume1/screenpipe/#recycle/Copy #8 of archive.db
/volume1/screenpipe/#recycle/archive.db-journal
/volume1/screenpipe/#recycle/Copy #1 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #2 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #3 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #4 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #6 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #7 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of db.sqlite
/volume1/screenpipe/pipes/.DS_Store
/volume1/screenpipe/app/.env
/volume1/screenpipe/app/cli.py
/volume1/screenpipe/app/.DS_Store
/volume1/screenpipe/app/db.py
/volume1/screenpipe/app/docker-compose.yml
/volume1/screenpipe/app/main.py
/volume1/screenpipe/app/requirements.txt
/volume1/screenpipe/app/Dockerfile
/volume1/screenpipe/data/.DS_Store
/volume1/screenpipe/.git/description
/volume1/screenpipe/.git/HEAD
/volume1/screenpipe/.git/index
/volume1/screenpipe/.git/COMMIT_EDITMSG
/volume1/screenpipe/#recycle/data/.DS_Store
---
app
app_settings.json
archive.db
data
db.sqlite
db.sqlite-shm
db.sqlite-wal
pipes
#recycle
screenpipe.db
screenpipe_sync.sh
Read
main.py
main.py
Bash
Check pipes directory and docker-compose
IN
ls /volume1/screenpipe/pipes/ && ls /volume1/screenpipe/app/ && cat /volume1/screenpipe/app/docker-compose.yml
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
cli.py
consumers
db.py
docker-compose.yml
Dockerfile
main.py
__pycache__
requirements.txt
static
services:
screenpipe-app:
build: .
container_name: screenpipe-app
restart: unless-stopped
ports:
- "8766:8000"
volumes:
- /volume1/screenpipe:/data
env_file:
- .env
environment:
TZ: Europe/Sofia
DB_PATH: /data/db.sqlite
sqlite-web-archive:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-archive
restart: unless-stopped
ports:
- "8767:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/archive.db"]
sqlite-web-live:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-live
restart: unless-stopped
ports:
- "8768:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/db.sqlite"]
Read
requirements.txt
requirements.txt
Bash
Inspect a pipe directory
IN
ls /volume1/screenpipe/pipes/day-recap/ && cat /volume1/screenpipe/pipes/day-recap/pipe.json 2>/dev/null || ls /volume1/screenpipe/pipes/day-recap/
Copy code to clipboard
OUT
pipe.md
pipe.md
Read
cli.py
cli.py
Bash
List all pipes and their contents
IN
ls /volume1/screenpipe/pipes/ && for d in /volume1/screenpipe/pipes/*/; do echo "=== $d ==="; ls "$d"; done
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
=== /volume1/screenpipe/pipes/ai-habits/ ===
pipe.md
=== /volume1/screenpipe/pipes/day-recap/ ===
pipe.md
=== /volume1/screenpipe/pipes/meeting-summary/ ===
pipe.md
=== /volume1/screenpipe/pipes/standup-update/ ===
pipe.md
=== /volume1/screenpipe/pipes/time-breakdown/ ===
pipe.md
=== /volume1/screenpipe/pipes/video-export/ ===
pipe.md
Bash...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
21071
|
921
|
6
|
2026-05-11T17:09:07.011215+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-11/1778 /Users/lukas/.screenpipe/data/data/2026-05-11/1778519347011_m2.jpg...
|
Code
|
Implement and run pipe l… — screenpipe [SSH: nas]
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧ Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py
M
db.py
docker-compose.yml
Dockerfile
M
main.py
M
requirements.txt
M
data
logs
pipes
.gitignore
app_settings.json
archive.db
archive.db-bak
U
db.sqlite
db.sqlite-shm
db.sqlite-wal
screenpipe_sync_updated.sh
U
screenpipe_sync.sh
screenpipe.db
Outline Section
OUTLINE
OUTLINE
Timeline Section
TIMELINE
TIMELINE
app_settings.json, Editor Group 1
screenpipe_sync.sh, Editor Group 1
pipe.md, Editor Group 1
.env, Editor Group 1
[ENV_SECRET]
[ENV_SECRET]
Implement and run pipe l…, Editor Group 2
Problems (⇧⌘M)
PROBLEMS
Output (⇧⌘U)
OUTPUT
Debug Console (⇧⌘Y)
DEBUG CONSOLE
Terminal (⌃`)
TERMINAL
Ports - 1 forwarded port
PORTS
1
remote SSH: nas
SSH: nas
screenpipe (Git) - master*, Checkout Branch/Tag...
master*
screenpipe (Git) - Synchronize Changes
No Problems
0
0
Forwarded Ports: 8766
1
Notifications
Sign In
Sign In
Info: Setting up SSH Host nas: Setting up SSH tunnel
Implement and run pipe logic
Session history
New session
Message actions
main.py
main.py
lets implement logic with pipes. how can I run it?
Thinking
Thinking
Let me look at the current project structure to understand what's already in place.
Bash
List project files
IN
find /volume1/screenpipe -type f | head -50 && echo "---" && ls /volume1/screenpipe
Copy code to clipboard
OUT
/volume1/screenpipe/.DS_Store
/volume1/screenpipe/screenpipe.db
/volume1/screenpipe/screenpipe_sync.sh
/volume1/screenpipe/app_settings.json
/volume1/screenpipe/.gitignore
/volume1/screenpipe/archive.db
/volume1/screenpipe/db.sqlite
/volume1/screenpipe/db.sqlite-wal
/volume1/screenpipe/db.sqlite-shm
/volume1/screenpipe/#recycle/desktop.ini
/volume1/screenpipe/#recycle/db.sqlite
/volume1/screenpipe/#recycle/Copy #1 of db.sqlite
/volume1/screenpipe/#recycle/.DS_Store
/volume1/screenpipe/#recycle/Copy #2 of db.sqlite
/volume1/screenpipe/#recycle/archive.db
/volume1/screenpipe/#recycle/Copy #1 of archive.db
/volume1/screenpipe/#recycle/Copy #2 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of archive.db
/volume1/screenpipe/#recycle/Copy #4 of archive.db
/volume1/screenpipe/#recycle/Copy #5 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of db.sqlite
/volume1/screenpipe/#recycle/Copy #4 of db.sqlite
/volume1/screenpipe/#recycle/Copy #6 of archive.db
/volume1/screenpipe/#recycle/test.txt
/volume1/screenpipe/#recycle/Copy #7 of archive.db
/volume1/screenpipe/#recycle/Copy #8 of archive.db
/volume1/screenpipe/#recycle/archive.db-journal
/volume1/screenpipe/#recycle/Copy #1 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #2 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #3 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #4 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #6 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #7 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of db.sqlite
/volume1/screenpipe/pipes/.DS_Store
/volume1/screenpipe/app/.env
/volume1/screenpipe/app/cli.py
/volume1/screenpipe/app/.DS_Store
/volume1/screenpipe/app/db.py
/volume1/screenpipe/app/docker-compose.yml
/volume1/screenpipe/app/main.py
/volume1/screenpipe/app/requirements.txt
/volume1/screenpipe/app/Dockerfile
/volume1/screenpipe/data/.DS_Store
/volume1/screenpipe/.git/description
/volume1/screenpipe/.git/HEAD
/volume1/screenpipe/.git/index
/volume1/screenpipe/.git/COMMIT_EDITMSG
/volume1/screenpipe/#recycle/data/.DS_Store
---
app
app_settings.json
archive.db
data
db.sqlite
db.sqlite-shm
db.sqlite-wal
pipes
#recycle
screenpipe.db
screenpipe_sync.sh
Read
main.py
main.py
Bash
Check pipes directory and docker-compose
IN
ls /volume1/screenpipe/pipes/ && ls /volume1/screenpipe/app/ && cat /volume1/screenpipe/app/docker-compose.yml
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
cli.py
consumers
db.py
docker-compose.yml
Dockerfile
main.py
__pycache__
requirements.txt
static
services:
screenpipe-app:
build: .
container_name: screenpipe-app
restart: unless-stopped
ports:
- "8766:8000"
volumes:
- /volume1/screenpipe:/data
env_file:
- .env
environment:
TZ: Europe/Sofia
DB_PATH: /data/db.sqlite
sqlite-web-archive:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-archive
restart: unless-stopped
ports:
- "8767:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/archive.db"]
sqlite-web-live:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-live
restart: unless-stopped
ports:
- "8768:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/db.sqlite"]
Read
requirements.txt
requirements.txt
Bash
Inspect a pipe directory
IN
ls /volume1/screenpipe/pipes/day-recap/ && cat /volume1/screenpipe/pipes/day-recap/pipe.json 2>/dev/null || ls /volume1/screenpipe/pipes/day-recap/
Copy code to clipboard
OUT
pipe.md
pipe.md
Read
cli.py
cli.py
Bash
List all pipes and their contents
IN
ls /volume1/screenpipe/pipes/ && for d in /volume1/screenpipe/pipes/*/; do echo "=== $d ==="; ls "$d"; done
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
=== /volume1/screenpipe/pipes/ai-habits/ ===
pipe.md
=== /volume1/screenpipe/pipes/day-recap/ ===
pipe.md
=== /volume1/screenpipe/pipes/meeting-summary/ ===
pipe.md
=== /volume1/screenpipe/pipes/standup-update/ ===
pipe.md
=== /volume1/screenpipe/pipes/time-breakdown/ ===
pipe.md
=== /volume1/screenpipe/pipes/video-export/ ===
pipe.md
Bash
Read pipe markdown files
IN
cat /volume1/screenpipe/pipes/day-recap/pipe.md && echo "===" && cat /volume1/screenpipe/pipes/meeting-summary/pipe.md 2>/dev/null | head -50
Copy code to clipboard
OUT
---
schedule: manual
enabled: true
template: true
title: Day Recap
description: "Today's accomplishments, key moments, and unfinished work"
icon: "📋"
featured: true
---
Analyze my screen and audio recordings from today (last 16 hours only).
Read screenpipe skill first.
Use this exact format:
## Summary
One sentence: what I mainly did today.
## Accomplishments
- Top 3 things I finished, with timestamps (e.g. "2:30 PM")
- Name specific apps, files, or projects
## Key Moments
- Important things I saw, said, or heard — with timestamps
## Unfinished Work
- What I should continue tomorrow — name the app/file/task
## Patterns
- Apps I used most, topics that came up repeatedly
Only report what you can verify from the data. End with: "**Next step:** [most important thing to continue]"
===
---
schedule: manual
enabled: true
template: true
title: Meeting Summary
description: "Summarize meeting transcript with key takeaways and action items"
icon: "🤝"
featured: false
---
Summarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.
Read screenpipe skill first.
Use this exact format:
## Meeting Summary
One sentence: what this meeting was about.
## Key Takeaways
- Top 3-5 important points discussed
- Include who said what when relevant
## Action Items
- [ ] Task — assigned to whom, deadline if mentioned
- [ ] Task — assigned to whom
## Decisions Made
- List any decisions or agreements reached
## Open Questions
- Anything unresolved or needing follow-up
Keep it concise and actionable.
Thinking
Thinking
Bash
Read summary consumer
IN
ls /volume1/screenpipe/app/consumers/ && cat /volume1/screenpipe/app/consumers/summary.py
Copy code to clipboard
OUT
activity.py
audio.py
elements.py
__init__.py
interactions.py
ocr.py
__pycache__
report.py
summary.py
"""AI summary generator using Claude."""
import os
from datetime import date
from typing import Any
from consumers.activity import app_time, summary_stats, browser_urls, ui_event_summary
from consumers.ocr import deduplicated_text
from consumers.audio import formatted_transcript
SUMMARY_TYPES = {
"day_recap": {
"title": "Day Recap",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
## Audio/speech:
{audio}
Write a concise day recap using EXACTLY this format:
## Summary
One sentence: what I mainly worked on today.
## Accomplishments
- Top 3 things I finished, with approximate times
- Name specific apps, files, or projects
## Key Moments
- Important things seen or heard, with timestamps
## Unfinished Work
- What to continue tomorrow
## Patterns
- Apps used most, topics that came up repeatedly
Only report what you can verify from the data. End with:
**Next step:** [most important thing to continue]""",
},
"standup": {
"title": "Standup Update",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
## Audio/speech:
{audio}
Write a brief standup update:
**Yesterday:** What I worked on (2-3 bullets)
**Today:** What I plan to continue (1-2 bullets)
**Blockers:** Any issues observed (or "None")
Keep it under 150 words. Only report what's verifiable from the data.""",
},
"focus_time": {
"title": "Focus & Distraction Analysis",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
Analyze focus vs distraction patterns:
## Deep Work Periods
- When and how long were sustained focus sessions?
- What was being worked on?
## Distractions
- Which apps/sites were used recreationally?
- How much time was lost to context switching?
## Recommendations
- 2-3 concrete suggestions to improve focus tomorrow
Be specific with times and app names.""",
},
}
def _build_context(for_date: date) -> dict[str, str]:
apps = app_time(for_date)
app_lines = "\n".join(f"- {a['app_name']}: {a['minutes']} min" for a in apps[:20])
urls = browser_urls(for_date, limit=20)
url_lines = "\n".join(
f"- {u['browser_url'][:100]} ({u['minutes']} min)" for u in urls
)
ui_rows = ui_event_summary(for_date)
ui_lines = "\n".join(
f"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches"
for r in ui_rows[:15]
)
ocr_rows = deduplicated_text(for_date, chunk_minutes=5)
ocr_lines = "\n".join(
f"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}"
for r in ocr_rows[:100]
)
audio = formatted_transcript(for_date)
return {
"app_time": app_lines or "(no app data)",
"browser_urls": url_lines or "(no browser data)",
"ui_events": ui_lines or "(no UI event data)",
"ocr_text": ocr_lines or "(no screen data)",
"audio": audio[:3000] if len(audio) > 3000 else audio,
}
def generate(
summary_type: str = "day_recap",
for_date: date | None = None,
api_key: str | None = None,
) -> dict[str, Any]:
"""Generate an AI summary. Returns dict with 'title', 'content', 'date'."""
import anthropic
d = for_date or date.today()
key = api_key or os.environ.get("ANTHROPIC_API_KEY", "")
if not key:
return {
"title": "Error",
"content": "ANTHROPIC_API_KEY not set. Add it to your .env file.",
"date": str(d),
}
spec = SUMMARY_TYPES.get(summary_type)
if not spec:
return {"title": "Error", "content": f"Unknown summary type: {summary_type}", "date": str(d)}
stats = summary_stats(d)
if stats["total_frames"] == 0:
return {
"title": spec["title"],
"content": f"No screen data found for {d}.",
"date": str(d),
}
ctx = _build_context(d)
prompt = spec["prompt"].format(**ctx)
client = anthropic.Anthropic(api_key=key)
message = client.messages.create(
model="claude-haiku-4-5-20251001",
max_tokens=1024,
messages=[{"role": "user", "content": prompt}],
)
return {
"title": spec["title"],
"content": message.content[0].text,
"date": str(d),
"stats": stats,
}
Thinking
Thinking
Bash
Read all pipe.md files
IN
for f in /volume1/screenpipe/pipes/*/pipe.md; do echo "=== $f ==="; cat "$f"; echo; done
Copy code to clipboard
OUT
=== /volume1/screenpipe/pipes/ai-habits/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: AI Habits
description: "How you use AI tools — patterns and insights"
icon: "🤖"
featured: true
---
Search my recordings from the last 24 hours for AI tool usage. Use app_name filter for each tool separately: ChatGPT, Claude, Copilot, Cursor, Gemini, Perplexity. Use limit=5 per search, max 6 searches total.
Read screenpipe skill first.
Use this exact format:
## AI Tools Used
- List each tool with approximate time spent (e.g. "Claude: ~45min")
## What I Used Them For
- For each tool: coding, writing, research, or brainstorming
## Usage Patterns
- Do I switch between tools? Use them in bursts or steadily?
## Effectiveness
- Which tool appeared alongside completed work vs. abandoned attempts
If no AI usage is found, say so clearly. End with: "**Tip:** [one suggestion to use AI tools more effectively]"
=== /volume1/screenpipe/pipes/day-recap/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Day Recap
description: "Today's accomplishments, key moments, and unfinished work"
icon: "📋"
featured: true
---
Analyze my screen and audio recordings from today (last 16 hours only).
Read screenpipe skill first.
Use this exact format:
## Summary
One sentence: what I mainly did today.
## Accomplishments
- Top 3 things I finished, with timestamps (e.g. "2:30 PM")
- Name specific apps, files, or projects
## Key Moments
- Important things I saw, said, or heard — with timestamps
## Unfinished Work
- What I should continue tomorrow — name the app/file/task
## Patterns
- Apps I used most, topics that came up repeatedly
Only report what you can verify from the data. End with: "**Next step:** [most important thing to continue]"
=== /volume1/screenpipe/pipes/meeting-summary/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Meeting Summary
description: "Summarize meeting transcript with key takeaways and action items"
icon: "🤝"
featured: false
---
Summarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.
Read screenpipe skill first.
Use this exact format:
## Meeting Summary
One sentence: what this meeting was about.
## Key Takeaways
- Top 3-5 important points discussed
- Include who said what when relevant
## Action Items
- [ ] Task — assigned to whom, deadline if mentioned
- [ ] Task — assigned to whom
## Decisions Made
- List any decisions or agreements reached
## Open Questions
- Anything unresolved or needing follow-up
Keep it concise and actionable.
=== /volume1/screenpipe/pipes/standup-update/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Standup Update
description: "What you did, what's next, and any blockers"
icon: "🏢"
featured: true
---
Based on my recordings from the last 24 hours, generate a standup update. Use limit=10 per search, max 3 searches total.
Read screenpipe skill first.
Use this exact format:
## Yesterday
- What I worked on (name specific projects, files, tools, PRs)
## Today
- What I will work on next (based on unfinished tasks and recent activity)
## Blockers
- Issues I hit — errors, slow builds, waiting on someone
- If no blockers, write "None"
Keep it under 150 words. Copy-paste ready for a team standup.
=== /volume1/screenpipe/pipes/time-breakdown/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Time Breakdown
description: "Where your time went — by app, project, and category"
icon: "⏱"
featured: false
---
Analyze my app usage from today (last 12 hours). Use limit=10 per search, max 4 searches. Prefer /raw_sql with COUNT/GROUP BY queries.
Read screenpipe skill first.
Use this exact format with durations and percentages:
## By Application
- List each app with duration and percentage, sorted by time (e.g. "VS Code: 2h 15min (28%)")
## By Category
- Group into: coding, meetings, browsing, writing, communication, other
- Show hours and percentage per category
## By Project
- Group related activities by project/topic. Name specific repos or tasks.
## Productivity Score
- Calculate: focused_work_hours / total_hours as a percentage
- Focused = coding + writing. Unfocused = browsing + switching.
End with: "**Suggestion:** [one specific change to improve tomorrow's productivity]"
=== /volume1/screenpipe/pipes/video-export/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Export Video Clip
description: "Create a video of your recent screen activity"
icon: "🎬"
featured: false
---
Export a video of my screen activity from the last 5 minutes.
Read screenpipe skill first.
Use the POST /frames/export endpoint with the time range and fps=1.0. Then show me the exported video file path as an inline code block so I can watch it.
If the export is large, suggest a lower fps or shorter time range.
Thinking
Thinking
Now I have a clear picture. The pipes are markdown prompt templates in
/volume1/screenpipe/pipes/
, but there's no code to actually load and run them —
consumers/summary.py
has its own hardcoded prompts instead.
Here's what I'll implement:
consumers/pipes.py
— dynamically loads pipe.md files and runs them via Claude (data injected as system message, pipe body as user prompt)
main.py
— two new endpoints:
GET /api/pipes
and
POST /api/pipes/{pipe_id}/run
cli.py
— a
pipe
command to run pipes from the terminal
Let me build it:
Bash
Check browser_urls signature
IN
cat /volume1/screenpipe/app/consumers/activity.py | grep "def browser_urls" -A 5
Copy code to clipboard
OUT
def browser_urls(
for_date: date | None = None,
app_name: str | None = None,
ts_from: str | None = None,
ts_to: str | None = None,
limit: int = 30,
Write
pipes.py
pipes.py
143 lines
"""Dynamic pipe loader and runner."""
import os
import re
from datetime import date
from pathlib import Path
from typing import Any
def _parse_frontmatter(text: str) -> tuple[dict, str]:
if not text.startswith("---"):
return {}, text
try:
end = text.index("---", 3)
except ValueError:
return {}, text
fm_text = text[3:end].strip()
body = text[end + 3:].strip()
meta: dict = {}
for line in fm_text.splitlines():
if ":" in line:
k, _, v = line.partition(":")
meta[k.strip()] = v.strip().strip('"')
return meta, body
def load_pipes(pipes_dir: Path) -> list[dict]:
if not pipes_dir.exists():
return []
pipes = []
for pipe_dir in sorted(pipes_dir.iterdir()):
if not pipe_dir.is_dir() or pipe_dir.name.startswith("."):
continue
pipe_md = pipe_dir / "pipe.md"
if not pipe_md.exists():
continue
text = pipe_md.read_text(encoding="utf-8")
meta, body = _parse_frontmatter(text)
if meta.get("enabled", "true").lower() == "false":
continue
body = re.sub(r"Read screenpipe skill first\.?\n?", "", body).strip()
pipes.append({
"id": pipe_dir.name,
"title": meta.get("title", pipe_dir.name),
"description": meta.get("description", ""),
"icon": meta.get("icon", ""),
"schedule": meta.get("schedule", "manual"),
"featured": meta.get("featured", "false").lower() == "true",
"prompt": body,
})
return pipes
def _build_system(d: date, stats: dict) -> str:
from consumers.activity import app_time, browser_urls, ui_event_summary
from consumers.ocr import deduplicated_text
from consumers.audio import formatted_transcript
apps = app_time(d)
app_lines = "\n".join(f"- {a['app_name']}: {a['minutes']} min" for a in apps[:20])
urls = browser_urls(d, limit=20)
url_lines = "\n".join(f"- {u['browser_url'][:100]} ({u['minutes']} min)" for u in urls)
ui_rows = ui_event_summary(d)
ui_lines = "\n".join(
f"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches"
for r in ui_rows[:15]
)
ocr_rows = deduplicated_text(d, chunk_minutes=5)
ocr_lines = "\n".join(
f"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}"
for r in ocr_rows[:100]
)
audio = formatted_transcript(d)
if len(audio) > 3000:
audio = audio[:3000]
return f"""You are analyzing screenpipe data — recordings of a person's computer activity.
## App usage (minutes per app):
{app_lines or '(no app data)'}
## Browser URLs visited:
{url_lines or '(no browser data)'}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_lines or '(no UI event data)'}
## Screen content (sampled every 5 minutes):
{ocr_lines or '(no screen data)'}
## Audio / speech:
{audio or '(no audio data)'}
Date: {d}
Total frames recorded: {stats['total_frames']}"""
def run_pipe(
pipe_id: str,
for_date: date | None = None,
api_key: str | None = None,
pipes_dir: Path | None = None,
) -> dict[str, Any]:
import anthropic
from consumers.activity import summary_stats
d = for_date or date.today()
key = api_key or os.environ.get("ANTHROPIC_API_KEY", "")
if not key:
return {"title": "Error", "content": "ANTHROPIC_API_KEY not set.", "date": str(d)}
_pipes_dir = pipes_dir or Path(os.environ.get("PIPES_DIR", "/data/pipes"))
all_pipes = {p["id"]: p for p in load_pipes(_pipes_dir)}
if pipe_id not in all_pipes:
return {"title": "Error", "content": f"Pipe not found: {pipe_id}", "date": str(d)}
pipe = all_pipes[pipe_id]
stats = summary_stats(d)
if stats["total_frames"] == 0:
return {"title": pipe["title"], "content": f"No screen data found for {d}.", "date": str(d)}
system = _build_system(d, stats)
client = anthropic.Anthropic(api_key=key)
message = client.messages.create(
model="claude-haiku-4-5-20251001",
max_tokens=1024,
system=system,
messages=[{"role": "user", "content": pipe["prompt"]}],
)
return {
"title": pipe["title"],
"content": message.content[0].text,
"date": str(d),
"stats": stats,
}
Now add the API endpoints to
main.py
:
Edit
main.py
main.py
Added 1 line
Edit
main.py
main.py
Added 1 line
Now add the pipe endpoints at the end of main.py, before the closing summary section:
Edit
main.py
main.py
Added 14 lines
Now add the CLI command to
cli.py
cli.py
:
Edit
cli.py
cli.py
Added 40 lines
Done. Here's how to run pipes:
How to run pipes
How to run pipes
Via Docker (inside the running container):
Copy code to clipboard
docker exec -it screenpipe-app python cli.py pipe --list
docker exec -it screenpipe-app python cli.py pipe day-recap
docker exec -it screenpipe-app python cli.py pipe standup-update --date yesterday
Via the API
(once the container is running on port 8766):
Copy code to clipboard
# List pipes
curl http://localhost:8766/api/pipes
# Run a pipe
curl -X POST "http://localhost:8766/api/pipes/day-recap/run"
curl -X POST "http://localhost:8766/api/pipes/standup-update/run?d=2026-04-25"
Rebuild and restart
to pick up the changes:
Copy code to clipboard
cd /volume1/screenpipe/app
docker compose up --build -d
How it works:
Each
pipe.md
file is loaded dynamically — the frontmatter provides metadata and the body becomes the user prompt. Screenpipe data (app usage, browser URLs, OCR, audio) is injected as a Claude system message so the pipe prompt can reference it naturally. The "Read screenpipe skill first" line is stripped automatically.
The pipes directory inside Docker is
/data/pipes
(since
/volume1/screenpipe
→
/data
). You can override it with a
PIPES_DIR
env var if needed.
Message actions
pipe.md
pipe.md
where to place api key and can I use different keys
Thinking
Thinking
Bash
Read .env file
IN
cat /volume1/screenpipe/app/.env
Copy code to clipboard
OUT
[ENV_SECRET]
Where to place the key:
app/.env
app/.env
— replace
your_key_here
with your actual key:
Copy code to clipboard
[ENV_SECRET]
That file is loaded by
load_dotenv()
at startup and is excluded from git via
.gitignore
.
Can you use different keys per pipe?
Not currently — all pipes share the one key from
.env
. But you can add per-pipe key support by adding an
api_key
field to the pipe's frontmatter:
Copy code to clipboard
---
title: Meeting Summary
api_key_env: ANTHROPIC_KEY_MEETINGS
---
Then in
consumers/pipes.py
consumers/pipes.py
, read it in
_parse_frontmatter
and pass it through
run_pipe
. Want me to add that?
Message actions
pipe.md
pipe.md
can I use mistral or other llm? or is is build for antrophic only
Thinking
Thinking
Currently it's Anthropic-only — the code calls the
anthropic
SDK directly in both
consumers/pipes.py
consumers/pipes.py
and
consumers/summary.py
consumers/summary.py
.
Adding other providers is straightforward since Mistral, Ollama, OpenRouter, Groq, and most modern LLMs expose an OpenAI-compatible API. The cleanest approach: add the...
|
[{"role":"AXRadioButton","text [{"role":"AXRadioButton","text":"Explorer (⇧⌘E)","depth":19,"bounds":{"left":0.0,"top":0.047885075,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":true},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.057462092,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Search (⇧⌘F)","depth":19,"bounds":{"left":0.0,"top":0.08619314,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.09577015,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Source Control (⌃⇧G) - 10 pending changes","depth":19,"bounds":{"left":0.0,"top":0.1245012,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.13407822,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"10","depth":22,"bounds":{"left":0.00831117,"top":0.1452514,"width":0.003656915,"height":0.008778931},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.00831117,"top":0.14604948,"width":0.0016622341,"height":0.007980846}},{"char_start":1,"char_count":1,"bounds":{"left":0.009973404,"top":0.14604948,"width":0.0023271276,"height":0.007980846}}],"role_description":"text"},{"role":"AXRadioButton","text":"Run and Debug (⇧⌘D)","depth":19,"bounds":{"left":0.0,"top":0.16280925,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.17238627,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Remote Explorer","depth":19,"bounds":{"left":0.0,"top":0.20111732,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.21069433,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Extensions (⇧⌘X) - 2 require update","depth":19,"bounds":{"left":0.0,"top":0.23942538,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.2490024,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"2","depth":22,"bounds":{"left":0.009640957,"top":0.2601756,"width":0.0019946808,"height":0.008778931},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Claude Code","depth":19,"bounds":{"left":0.0,"top":0.27773345,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"Containers","depth":19,"bounds":{"left":0.0,"top":0.3160415,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXHeading","text":"EXPLORER","depth":17,"bounds":{"left":0.022606382,"top":0.047885075,"width":0.018949468,"height":0.02793296},"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"EXPLORER","depth":18,"bounds":{"left":0.022606382,"top":0.056664005,"width":0.018949468,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.022606382,"top":0.056664005,"width":0.0023271276,"height":0.0103751}},{"char_start":1,"char_count":7,"bounds":{"left":0.024933511,"top":0.056664005,"width":0.01662234,"height":0.0103751}}],"role_description":"text"},{"role":"AXButton","text":"Explorer Section: screenpipe [SSH: nas]","depth":21,"bounds":{"left":0.015957447,"top":0.07581804,"width":0.09940159,"height":0.017557861},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":true},{"role":"AXStaticText","text":"","depth":23,"bounds":{"left":0.01662234,"top":0.07821229,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"Explorer Section: screenpipe [SSH: nas]","depth":22,"bounds":{"left":0.022606382,"top":0.07581804,"width":0.045877658,"height":0.017557861},"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"SCREENPIPE [SSH: NAS]","depth":23,"bounds":{"left":0.022606382,"top":0.079010375,"width":0.045877658,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.022606382,"top":0.07980846,"width":0.0026595744,"height":0.0103751}},{"char_start":1,"char_count":20,"bounds":{"left":0.025265958,"top":0.07980846,"width":0.043218084,"height":0.0103751}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.09577015,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"#recycle","depth":27,"bounds":{"left":0.025930852,"top":0.09577015,"width":0.017287234,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.096568234,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":7,"bounds":{"left":0.028590426,"top":0.096568234,"width":0.01462766,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.11332801,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"app","depth":27,"bounds":{"left":0.025930852,"top":0.11332801,"width":0.0076462766,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.11412609,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":2,"bounds":{"left":0.02825798,"top":0.11412609,"width":0.005319149,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.11412609,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.022273935,"top":0.13088587,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"__pycache__","depth":27,"bounds":{"left":0.028590426,"top":0.13088587,"width":0.026595745,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.13168396,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":10,"bounds":{"left":0.030917553,"top":0.13168396,"width":0.024268618,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.022273935,"top":0.14844373,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"consumers","depth":27,"bounds":{"left":0.028590426,"top":0.14844373,"width":0.022273935,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.14924182,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":8,"bounds":{"left":0.030917553,"top":0.14924182,"width":0.019946808,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.14924182,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.022273935,"top":0.1660016,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"static","depth":27,"bounds":{"left":0.028590426,"top":0.1660016,"width":0.010970744,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.16679968,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":5,"bounds":{"left":0.030917553,"top":0.16679968,"width":0.008976064,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.16679968,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.1819633,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":".env","depth":27,"bounds":{"left":0.028590426,"top":0.18355946,"width":0.00831117,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.18435754,"width":0.0013297872,"height":0.011971269}},{"char_start":1,"char_count":3,"bounds":{"left":0.029920213,"top":0.18435754,"width":0.006981383,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.19952115,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"cli.py","depth":27,"bounds":{"left":0.028590426,"top":0.20111732,"width":0.010638298,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.2019154,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":5,"bounds":{"left":0.030917553,"top":0.2019154,"width":0.00831117,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.2019154,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.21707901,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.py","depth":27,"bounds":{"left":0.028590426,"top":0.21867518,"width":0.011303191,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.21947326,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":4,"bounds":{"left":0.03125,"top":0.21947326,"width":0.008643617,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.23463687,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"docker-compose.yml","depth":27,"bounds":{"left":0.028590426,"top":0.23623304,"width":0.042220745,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.23703113,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":17,"bounds":{"left":0.03125,"top":0.23703113,"width":0.03956117,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.25219473,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Dockerfile","depth":27,"bounds":{"left":0.028590426,"top":0.25379092,"width":0.020611702,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.254589,"width":0.0033244682,"height":0.011971269}},{"char_start":1,"char_count":9,"bounds":{"left":0.031914894,"top":0.254589,"width":0.017287234,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.254589,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.2697526,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"main.py","depth":27,"bounds":{"left":0.028590426,"top":0.27134877,"width":0.015625,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.27214685,"width":0.003656915,"height":0.011971269}},{"char_start":1,"char_count":6,"bounds":{"left":0.032247342,"top":0.27214685,"width":0.012300532,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.27214685,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.28731045,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"requirements.txt","depth":27,"bounds":{"left":0.028590426,"top":0.28890663,"width":0.032912236,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.2897047,"width":0.0016622341,"height":0.011971269}},{"char_start":1,"char_count":15,"bounds":{"left":0.03025266,"top":0.2897047,"width":0.03158245,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.2897047,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.3064645,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"data","depth":27,"bounds":{"left":0.025930852,"top":0.3064645,"width":0.008976064,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.30726257,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":3,"bounds":{"left":0.028590426,"top":0.30726257,"width":0.0063164895,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.32402235,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"logs","depth":27,"bounds":{"left":0.025930852,"top":0.32402235,"width":0.00831117,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.32482043,"width":0.0009973404,"height":0.011971269}},{"char_start":1,"char_count":3,"bounds":{"left":0.026928192,"top":0.32482043,"width":0.0076462766,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.32482043,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.3415802,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"pipes","depth":27,"bounds":{"left":0.025930852,"top":0.3415802,"width":0.010970744,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.3423783,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":4,"bounds":{"left":0.028590426,"top":0.3423783,"width":0.00831117,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.3575419,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":".gitignore","depth":27,"bounds":{"left":0.025930852,"top":0.35913807,"width":0.018949468,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.35993615,"width":0.0013297872,"height":0.011971269}},{"char_start":1,"char_count":9,"bounds":{"left":0.027260639,"top":0.35993615,"width":0.017952127,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.37509975,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"app_settings.json","depth":27,"bounds":{"left":0.025930852,"top":0.37669593,"width":0.03557181,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.377494,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":16,"bounds":{"left":0.02825798,"top":0.377494,"width":0.03324468,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.3926576,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"archive.db","depth":27,"bounds":{"left":0.025930852,"top":0.3942538,"width":0.020944148,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.39505187,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":9,"bounds":{"left":0.02825798,"top":0.39505187,"width":0.01861702,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.4102155,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"archive.db-bak","depth":27,"bounds":{"left":0.025930852,"top":0.41181165,"width":0.03025266,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.41260973,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":13,"bounds":{"left":0.02825798,"top":0.41260973,"width":0.027925532,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"U","depth":27,"bounds":{"left":0.10704787,"top":0.41260973,"width":0.0029920214,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.42777336,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite","depth":27,"bounds":{"left":0.025930852,"top":0.4293695,"width":0.017287234,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.4301676,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":8,"bounds":{"left":0.028590426,"top":0.4301676,"width":0.014960106,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.44533122,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite-shm","depth":27,"bounds":{"left":0.025930852,"top":0.44692737,"width":0.027925532,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.44772545,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":12,"bounds":{"left":0.028590426,"top":0.44772545,"width":0.025265958,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.46288908,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite-wal","depth":27,"bounds":{"left":0.025930852,"top":0.46448523,"width":0.025930852,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.46528333,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":12,"bounds":{"left":0.028590426,"top":0.46528333,"width":0.023603724,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.48044693,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe_sync_updated.sh","depth":27,"bounds":{"left":0.025930852,"top":0.4820431,"width":0.059175532,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.4828412,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":25,"bounds":{"left":0.02825798,"top":0.4828412,"width":0.056848403,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"U","depth":27,"bounds":{"left":0.10704787,"top":0.4828412,"width":0.0029920214,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.4980048,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe_sync.sh","depth":27,"bounds":{"left":0.025930852,"top":0.49960095,"width":0.039893616,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.50039905,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":17,"bounds":{"left":0.02825798,"top":0.50039905,"width":0.037898935,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.51556265,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe.db","depth":27,"bounds":{"left":0.025930852,"top":0.5171588,"width":0.028590426,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.5179569,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":12,"bounds":{"left":0.02825798,"top":0.5179569,"width":0.026595745,"height":0.011971269}}],"role_description":"text"},{"role":"AXButton","text":"Outline Section","depth":21,"bounds":{"left":0.015957447,"top":0.9473264,"width":0.09940159,"height":0.017557861},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":23,"bounds":{"left":0.01662234,"top":0.9497207,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"OUTLINE","depth":22,"bounds":{"left":0.022606382,"top":0.9473264,"width":0.01662234,"height":0.017557861},"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"OUTLINE","depth":23,"bounds":{"left":0.022606382,"top":0.95131683,"width":0.01662234,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.022606382,"top":0.95131683,"width":0.0029920214,"height":0.0103751}},{"char_start":1,"char_count":6,"bounds":{"left":0.025598405,"top":0.95131683,"width":0.013630319,"height":0.0103751}}],"role_description":"text"},{"role":"AXButton","text":"Timeline Section","depth":21,"bounds":{"left":0.015957447,"top":0.9648843,"width":0.09940159,"height":0.017557861},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":23,"bounds":{"left":0.01662234,"top":0.96727854,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"TIMELINE","depth":22,"bounds":{"left":0.022606382,"top":0.9648843,"width":0.01761968,"height":0.017557861},"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"TIMELINE","depth":23,"bounds":{"left":0.022606382,"top":0.9688747,"width":0.01761968,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.022606382,"top":0.9688747,"width":0.0026595744,"height":0.0103751}},{"char_start":1,"char_count":7,"bounds":{"left":0.025265958,"top":0.9688747,"width":0.015292553,"height":0.0103751}}],"role_description":"text"},{"role":"AXRadioButton","text":"app_settings.json, Editor Group 1","depth":28,"bounds":{"left":0.11569149,"top":0.047885075,"width":0.055851065,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"screenpipe_sync.sh, Editor Group 1","depth":28,"bounds":{"left":0.17154256,"top":0.047885075,"width":0.06050532,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"pipe.md, Editor Group 1","depth":28,"bounds":{"left":0.23171543,"top":0.047885075,"width":0.040226065,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":".env, Editor Group 1","depth":28,"bounds":{"left":0.27194148,"top":0.047885075,"width":0.039893616,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":false},{"role":"AXStaticText","text":"","depth":29,"bounds":{"left":0.12832446,"top":0.07821229,"width":0.0056515955,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXTextArea","text":"ANTHROPIC_API_KEY=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","depth":28,"bounds":{"left":0.13763298,"top":0.10774142,"width":0.30285904,"height":0.014365523},"on_screen":true,"value":"ANTHROPIC_API_KEY=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","role_description":"editor","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"ANTHROPIC_API_KEY=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","depth":29,"bounds":{"left":0.13763298,"top":0.09497207,"width":0.30285904,"height":0.011173184},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.13763298,"top":0.09497207,"width":0.0023271276,"height":0.011173184}},{"char_start":1,"char_count":125,"bounds":{"left":0.13996011,"top":0.09497207,"width":0.30053192,"height":0.011173184}}],"role_description":"text"},{"role":"AXRadioButton","text":"Implement and run pipe l…, Editor Group 2","depth":28,"bounds":{"left":0.5578458,"top":0.047885075,"width":0.073803194,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":false},{"role":"AXRadioButton","text":"Problems (⇧⌘M)","depth":22,"bounds":{"left":0.118351065,"top":0.7278532,"width":0.027925532,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"PROBLEMS","depth":24,"bounds":{"left":0.122340426,"top":0.7366321,"width":0.019946808,"height":0.0103751},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Output (⇧⌘U)","depth":22,"bounds":{"left":0.14594415,"top":0.7278532,"width":0.023603724,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUTPUT","depth":24,"bounds":{"left":0.14993352,"top":0.7366321,"width":0.015625,"height":0.0103751},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Debug Console (⇧⌘Y)","depth":22,"bounds":{"left":0.16921543,"top":0.7278532,"width":0.039893616,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"DEBUG CONSOLE","depth":24,"bounds":{"left":0.1732048,"top":0.7366321,"width":0.031914894,"height":0.0103751},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Terminal (⌃`)","depth":22,"bounds":{"left":0.2087766,"top":0.7278532,"width":0.026595745,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":true},{"role":"AXStaticText","text":"TERMINAL","depth":24,"bounds":{"left":0.21276596,"top":0.7366321,"width":0.01861702,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.2130984,"top":0.73743016,"width":0.0023271276,"height":0.0103751}},{"char_start":1,"char_count":7,"bounds":{"left":0.21542554,"top":0.73743016,"width":0.016289894,"height":0.0103751}}],"role_description":"text"},{"role":"AXRadioButton","text":"Ports - 1 forwarded port","depth":22,"bounds":{"left":0.23537233,"top":0.7278532,"width":0.026263298,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"PORTS","depth":24,"bounds":{"left":0.2393617,"top":0.7366321,"width":0.012300532,"height":0.0103751},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":25,"bounds":{"left":0.25465426,"top":0.73743016,"width":0.0019946808,"height":0.008778931},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"remote SSH: nas","depth":16,"bounds":{"left":0.0006648936,"top":0.98244214,"width":0.028590426,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.0033244682,"top":0.9848364,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"SSH: nas","depth":17,"bounds":{"left":0.008643617,"top":0.9856345,"width":0.017952127,"height":0.011173184},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.008643617,"top":0.9856345,"width":0.0013297872,"height":0.011173184}},{"char_start":1,"char_count":7,"bounds":{"left":0.009973404,"top":0.9856345,"width":0.01462766,"height":0.011173184}}],"role_description":"text"},{"role":"AXButton","text":"screenpipe (Git) - master*, Checkout Branch/Tag...","depth":16,"bounds":{"left":0.030917553,"top":0.98244214,"width":0.023271276,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.031914894,"top":0.9848364,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"master*","depth":17,"bounds":{"left":0.03723404,"top":0.9856345,"width":0.015957447,"height":0.011173184},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.03723404,"top":0.9856345,"width":0.0013297872,"height":0.011173184}},{"char_start":1,"char_count":6,"bounds":{"left":0.03856383,"top":0.9856345,"width":0.012965426,"height":0.011173184}}],"role_description":"text"},{"role":"AXButton","text":"screenpipe (Git) - Synchronize Changes","depth":16,"bounds":{"left":0.05418883,"top":0.98244214,"width":0.00731383,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"No Problems","depth":16,"bounds":{"left":0.06416223,"top":0.98244214,"width":0.022606382,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.06582447,"top":0.9848364,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"0","depth":17,"bounds":{"left":0.07114362,"top":0.9856345,"width":0.004986702,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.07579787,"top":0.9848364,"width":0.0056515955,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"0","depth":17,"bounds":{"left":0.08111702,"top":0.9856345,"width":0.0039893617,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Forwarded Ports: 8766","depth":16,"bounds":{"left":0.08843085,"top":0.98244214,"width":0.012632979,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.09009308,"top":0.9848364,"width":0.0056515955,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":17,"bounds":{"left":0.09541223,"top":0.9856345,"width":0.0039893617,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Notifications","depth":16,"bounds":{"left":0.9886968,"top":0.98244214,"width":0.010638298,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sign In","depth":16,"bounds":{"left":0.9650931,"top":0.98244214,"width":0.022606382,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.96675533,"top":0.9848364,"width":0.0056515955,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Sign In","depth":17,"bounds":{"left":0.97207445,"top":0.9856345,"width":0.013962766,"height":0.011173184},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.97207445,"top":0.9856345,"width":0.0013297872,"height":0.011173184}},{"char_start":1,"char_count":6,"bounds":{"left":0.9734042,"top":0.9856345,"width":0.010638298,"height":0.011173184}}],"role_description":"text"},{"role":"AXStaticText","text":"Info: Setting up SSH Host nas: Setting up SSH tunnel","depth":12,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Implement and run pipe logic","depth":19,"bounds":{"left":0.56017286,"top":0.08060654,"width":0.07114362,"height":0.022346368},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Session history","depth":19,"bounds":{"left":0.9780585,"top":0.08060654,"width":0.00930851,"height":0.022346368},"on_screen":true,"help_text":"Session history","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"New session","depth":19,"bounds":{"left":0.9886968,"top":0.08060654,"width":0.00930851,"height":0.022346368},"on_screen":true,"help_text":"New session","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Message actions","depth":24,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"main.py","depth":23,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"lets implement logic with pipes. how can I run it?","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Let me look at the current project structure to understand what's already in place.","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"List project files","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"find /volume1/screenpipe -type f | head -50 && echo \"---\" && ls /volume1/screenpipe","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"/volume1/screenpipe/.DS_Store\n/volume1/screenpipe/screenpipe.db\n/volume1/screenpipe/screenpipe_sync.sh\n/volume1/screenpipe/app_settings.json\n/volume1/screenpipe/.gitignore\n/volume1/screenpipe/archive.db\n/volume1/screenpipe/db.sqlite\n/volume1/screenpipe/db.sqlite-wal\n/volume1/screenpipe/db.sqlite-shm\n/volume1/screenpipe/#recycle/desktop.ini\n/volume1/screenpipe/#recycle/db.sqlite\n/volume1/screenpipe/#recycle/Copy #1 of db.sqlite\n/volume1/screenpipe/#recycle/.DS_Store\n/volume1/screenpipe/#recycle/Copy #2 of db.sqlite\n/volume1/screenpipe/#recycle/archive.db\n/volume1/screenpipe/#recycle/Copy #1 of archive.db\n/volume1/screenpipe/#recycle/Copy #2 of archive.db\n/volume1/screenpipe/#recycle/Copy #3 of archive.db\n/volume1/screenpipe/#recycle/Copy #4 of archive.db\n/volume1/screenpipe/#recycle/Copy #5 of archive.db\n/volume1/screenpipe/#recycle/Copy #3 of db.sqlite\n/volume1/screenpipe/#recycle/Copy #4 of db.sqlite\n/volume1/screenpipe/#recycle/Copy #6 of archive.db\n/volume1/screenpipe/#recycle/test.txt\n/volume1/screenpipe/#recycle/Copy #7 of archive.db\n/volume1/screenpipe/#recycle/Copy #8 of archive.db\n/volume1/screenpipe/#recycle/archive.db-journal\n/volume1/screenpipe/#recycle/Copy #1 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #2 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #3 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #4 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #5 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #6 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #7 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #5 of db.sqlite\n/volume1/screenpipe/pipes/.DS_Store\n/volume1/screenpipe/app/.env\n/volume1/screenpipe/app/cli.py\n/volume1/screenpipe/app/.DS_Store\n/volume1/screenpipe/app/db.py\n/volume1/screenpipe/app/docker-compose.yml\n/volume1/screenpipe/app/main.py\n/volume1/screenpipe/app/requirements.txt\n/volume1/screenpipe/app/Dockerfile\n/volume1/screenpipe/data/.DS_Store\n/volume1/screenpipe/.git/description\n/volume1/screenpipe/.git/HEAD\n/volume1/screenpipe/.git/index\n/volume1/screenpipe/.git/COMMIT_EDITMSG\n/volume1/screenpipe/#recycle/data/.DS_Store\n---\napp\napp_settings.json\narchive.db\ndata\ndb.sqlite\ndb.sqlite-shm\ndb.sqlite-wal\npipes\n#recycle\nscreenpipe.db\nscreenpipe_sync.sh","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"main.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Check pipes directory and docker-compose","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/pipes/ && ls /volume1/screenpipe/app/ && cat /volume1/screenpipe/app/docker-compose.yml","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ai-habits\nday-recap\nmeeting-summary\nstandup-update\ntime-breakdown\nvideo-export\ncli.py\nconsumers\ndb.py\ndocker-compose.yml\nDockerfile\nmain.py\n__pycache__\nrequirements.txt\nstatic\nservices:\n screenpipe-app:\n build: .\n container_name: screenpipe-app\n restart: unless-stopped\n ports:\n - \"8766:8000\"\n volumes:\n - /volume1/screenpipe:/data\n env_file:\n - .env\n environment:\n TZ: Europe/Sofia\n DB_PATH: /data/db.sqlite\n\n sqlite-web-archive:\n image: ghcr.io/coleifer/sqlite-web:latest\n container_name: screenpipe-sqlweb-archive\n restart: unless-stopped\n ports:\n - \"8767:8080\"\n volumes:\n - /volume1/screenpipe:/data\n command: [\"-H\", \"0.0.0.0\", \"-r\", \"/data/archive.db\"]\n\n sqlite-web-live:\n image: ghcr.io/coleifer/sqlite-web:latest\n container_name: screenpipe-sqlweb-live\n restart: unless-stopped\n ports:\n - \"8768:8080\"\n volumes:\n - /volume1/screenpipe:/data\n command: [\"-H\", \"0.0.0.0\", \"-r\", \"/data/db.sqlite\"]","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"requirements.txt","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"requirements.txt","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Inspect a pipe directory","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/pipes/day-recap/ && cat /volume1/screenpipe/pipes/day-recap/pipe.json 2>/dev/null || ls /volume1/screenpipe/pipes/day-recap/","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"pipe.md\npipe.md","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"cli.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"cli.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"List all pipes and their contents","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/pipes/ && for d in /volume1/screenpipe/pipes/*/; do echo \"=== $d ===\"; ls \"$d\"; done","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ai-habits\nday-recap\nmeeting-summary\nstandup-update\ntime-breakdown\nvideo-export\n=== /volume1/screenpipe/pipes/ai-habits/ ===\npipe.md\n=== /volume1/screenpipe/pipes/day-recap/ ===\npipe.md\n=== /volume1/screenpipe/pipes/meeting-summary/ ===\npipe.md\n=== /volume1/screenpipe/pipes/standup-update/ ===\npipe.md\n=== /volume1/screenpipe/pipes/time-breakdown/ ===\npipe.md\n=== /volume1/screenpipe/pipes/video-export/ ===\npipe.md","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read pipe markdown files","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"cat /volume1/screenpipe/pipes/day-recap/pipe.md && echo \"===\" && cat /volume1/screenpipe/pipes/meeting-summary/pipe.md 2>/dev/null | head -50","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Day Recap\ndescription: \"Today's accomplishments, key moments, and unfinished work\"\nicon: \"📋\"\nfeatured: true\n---\n\nAnalyze my screen and audio recordings from today (last 16 hours only). \n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Summary\nOne sentence: what I mainly did today.\n\n## Accomplishments\n- Top 3 things I finished, with timestamps (e.g. \"2:30 PM\")\n- Name specific apps, files, or projects\n\n## Key Moments\n- Important things I saw, said, or heard — with timestamps\n\n## Unfinished Work\n- What I should continue tomorrow — name the app/file/task\n\n## Patterns\n- Apps I used most, topics that came up repeatedly\n\nOnly report what you can verify from the data. End with: \"**Next step:** [most important thing to continue]\"\n===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Meeting Summary\ndescription: \"Summarize meeting transcript with key takeaways and action items\"\nicon: \"🤝\"\nfeatured: false\n---\n\nSummarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.\n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Meeting Summary\nOne sentence: what this meeting was about.\n\n## Key Takeaways\n- Top 3-5 important points discussed\n- Include who said what when relevant\n\n## Action Items\n- [ ] Task — assigned to whom, deadline if mentioned\n- [ ] Task — assigned to whom\n\n## Decisions Made\n- List any decisions or agreements reached\n\n## Open Questions\n- Anything unresolved or needing follow-up\n\nKeep it concise and actionable.","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read summary consumer","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/app/consumers/ && cat /volume1/screenpipe/app/consumers/summary.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"activity.py\naudio.py\nelements.py\n__init__.py\ninteractions.py\nocr.py\n__pycache__\nreport.py\nsummary.py\n\"\"\"AI summary generator using Claude.\"\"\"\nimport os\nfrom datetime import date\nfrom typing import Any\n\nfrom consumers.activity import app_time, summary_stats, browser_urls, ui_event_summary\nfrom consumers.ocr import deduplicated_text\nfrom consumers.audio import formatted_transcript\n\n\nSUMMARY_TYPES = {\n \"day_recap\": {\n \"title\": \"Day Recap\",\n \"prompt\": \"\"\"\\\nYou are analyzing a person's computer activity for the day.\n\n## App usage (minutes per app):\n{app_time}\n\n## Browser URLs visited:\n{browser_urls}\n\n## UI activity per app (clicks / keystrokes / app-switches):\n{ui_events}\n\n## Screen content (sampled every 5 minutes):\n{ocr_text}\n\n## Audio/speech:\n{audio}\n\nWrite a concise day recap using EXACTLY this format:\n\n## Summary\nOne sentence: what I mainly worked on today.\n\n## Accomplishments\n- Top 3 things I finished, with approximate times\n- Name specific apps, files, or projects\n\n## Key Moments\n- Important things seen or heard, with timestamps\n\n## Unfinished Work\n- What to continue tomorrow\n\n## Patterns\n- Apps used most, topics that came up repeatedly\n\nOnly report what you can verify from the data. End with:\n**Next step:** [most important thing to continue]\"\"\",\n },\n \"standup\": {\n \"title\": \"Standup Update\",\n \"prompt\": \"\"\"\\\nYou are analyzing a person's computer activity for the day.\n\n## App usage (minutes per app):\n{app_time}\n\n## Browser URLs visited:\n{browser_urls}\n\n## UI activity per app (clicks / keystrokes / app-switches):\n{ui_events}\n\n## Screen content (sampled every 5 minutes):\n{ocr_text}\n\n## Audio/speech:\n{audio}\n\nWrite a brief standup update:\n\n**Yesterday:** What I worked on (2-3 bullets)\n**Today:** What I plan to continue (1-2 bullets)\n**Blockers:** Any issues observed (or \"None\")\n\nKeep it under 150 words. Only report what's verifiable from the data.\"\"\",\n },\n \"focus_time\": {\n \"title\": \"Focus & Distraction Analysis\",\n \"prompt\": \"\"\"\\\nYou are analyzing a person's computer activity for the day.\n\n## App usage (minutes per app):\n{app_time}\n\n## Browser URLs visited:\n{browser_urls}\n\n## UI activity per app (clicks / keystrokes / app-switches):\n{ui_events}\n\n## Screen content (sampled every 5 minutes):\n{ocr_text}\n\nAnalyze focus vs distraction patterns:\n\n## Deep Work Periods\n- When and how long were sustained focus sessions?\n- What was being worked on?\n\n## Distractions\n- Which apps/sites were used recreationally?\n- How much time was lost to context switching?\n\n## Recommendations\n- 2-3 concrete suggestions to improve focus tomorrow\n\nBe specific with times and app names.\"\"\",\n },\n}\n\n\ndef _build_context(for_date: date) -> dict[str, str]:\n apps = app_time(for_date)\n app_lines = \"\\n\".join(f\"- {a['app_name']}: {a['minutes']} min\" for a in apps[:20])\n\n urls = browser_urls(for_date, limit=20)\n url_lines = \"\\n\".join(\n f\"- {u['browser_url'][:100]} ({u['minutes']} min)\" for u in urls\n )\n\n ui_rows = ui_event_summary(for_date)\n ui_lines = \"\\n\".join(\n f\"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches\"\n for r in ui_rows[:15]\n )\n\n ocr_rows = deduplicated_text(for_date, chunk_minutes=5)\n ocr_lines = \"\\n\".join(\n f\"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}\"\n for r in ocr_rows[:100]\n )\n\n audio = formatted_transcript(for_date)\n\n return {\n \"app_time\": app_lines or \"(no app data)\",\n \"browser_urls\": url_lines or \"(no browser data)\",\n \"ui_events\": ui_lines or \"(no UI event data)\",\n \"ocr_text\": ocr_lines or \"(no screen data)\",\n \"audio\": audio[:3000] if len(audio) > 3000 else audio,\n }\n\n\ndef generate(\n summary_type: str = \"day_recap\",\n for_date: date | None = None,\n api_key: str | None = None,\n) -> dict[str, Any]:\n \"\"\"Generate an AI summary. Returns dict with 'title', 'content', 'date'.\"\"\"\n import anthropic\n\n d = for_date or date.today()\n key = api_key or os.environ.get(\"ANTHROPIC_API_KEY\", \"\")\n if not key:\n return {\n \"title\": \"Error\",\n \"content\": \"ANTHROPIC_API_KEY not set. Add it to your .env file.\",\n \"date\": str(d),\n }\n\n spec = SUMMARY_TYPES.get(summary_type)\n if not spec:\n return {\"title\": \"Error\", \"content\": f\"Unknown summary type: {summary_type}\", \"date\": str(d)}\n\n stats = summary_stats(d)\n if stats[\"total_frames\"] == 0:\n return {\n \"title\": spec[\"title\"],\n \"content\": f\"No screen data found for {d}.\",\n \"date\": str(d),\n }\n\n ctx = _build_context(d)\n prompt = spec[\"prompt\"].format(**ctx)\n\n client = anthropic.Anthropic(api_key=key)\n message = client.messages.create(\n model=\"claude-haiku-4-5-20251001\",\n max_tokens=1024,\n messages=[{\"role\": \"user\", \"content\": prompt}],\n )\n\n return {\n \"title\": spec[\"title\"],\n \"content\": message.content[0].text,\n \"date\": str(d),\n \"stats\": stats,\n }","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read all pipe.md files","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"for f in /volume1/screenpipe/pipes/*/pipe.md; do echo \"=== $f ===\"; cat \"$f\"; echo; done","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"=== /volume1/screenpipe/pipes/ai-habits/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: AI Habits\ndescription: \"How you use AI tools — patterns and insights\"\nicon: \"🤖\"\nfeatured: true\n---\n\nSearch my recordings from the last 24 hours for AI tool usage. Use app_name filter for each tool separately: ChatGPT, Claude, Copilot, Cursor, Gemini, Perplexity. Use limit=5 per search, max 6 searches total.\n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## AI Tools Used\n- List each tool with approximate time spent (e.g. \"Claude: ~45min\")\n\n## What I Used Them For\n- For each tool: coding, writing, research, or brainstorming\n\n## Usage Patterns\n- Do I switch between tools? Use them in bursts or steadily?\n\n## Effectiveness\n- Which tool appeared alongside completed work vs. abandoned attempts\n\nIf no AI usage is found, say so clearly. End with: \"**Tip:** [one suggestion to use AI tools more effectively]\"\n\n=== /volume1/screenpipe/pipes/day-recap/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Day Recap\ndescription: \"Today's accomplishments, key moments, and unfinished work\"\nicon: \"📋\"\nfeatured: true\n---\n\nAnalyze my screen and audio recordings from today (last 16 hours only). \n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Summary\nOne sentence: what I mainly did today.\n\n## Accomplishments\n- Top 3 things I finished, with timestamps (e.g. \"2:30 PM\")\n- Name specific apps, files, or projects\n\n## Key Moments\n- Important things I saw, said, or heard — with timestamps\n\n## Unfinished Work\n- What I should continue tomorrow — name the app/file/task\n\n## Patterns\n- Apps I used most, topics that came up repeatedly\n\nOnly report what you can verify from the data. End with: \"**Next step:** [most important thing to continue]\"\n\n=== /volume1/screenpipe/pipes/meeting-summary/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Meeting Summary\ndescription: \"Summarize meeting transcript with key takeaways and action items\"\nicon: \"🤝\"\nfeatured: false\n---\n\nSummarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.\n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Meeting Summary\nOne sentence: what this meeting was about.\n\n## Key Takeaways\n- Top 3-5 important points discussed\n- Include who said what when relevant\n\n## Action Items\n- [ ] Task — assigned to whom, deadline if mentioned\n- [ ] Task — assigned to whom\n\n## Decisions Made\n- List any decisions or agreements reached\n\n## Open Questions\n- Anything unresolved or needing follow-up\n\nKeep it concise and actionable.\n\n=== /volume1/screenpipe/pipes/standup-update/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Standup Update\ndescription: \"What you did, what's next, and any blockers\"\nicon: \"🏢\"\nfeatured: true\n---\n\nBased on my recordings from the last 24 hours, generate a standup update. Use limit=10 per search, max 3 searches total.\n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Yesterday\n- What I worked on (name specific projects, files, tools, PRs)\n\n## Today\n- What I will work on next (based on unfinished tasks and recent activity)\n\n## Blockers\n- Issues I hit — errors, slow builds, waiting on someone\n- If no blockers, write \"None\"\n\nKeep it under 150 words. Copy-paste ready for a team standup.\n\n=== /volume1/screenpipe/pipes/time-breakdown/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Time Breakdown\ndescription: \"Where your time went — by app, project, and category\"\nicon: \"⏱\"\nfeatured: false\n---\n\nAnalyze my app usage from today (last 12 hours). Use limit=10 per search, max 4 searches. Prefer /raw_sql with COUNT/GROUP BY queries.\n\nRead screenpipe skill first.\n\nUse this exact format with durations and percentages:\n\n## By Application\n- List each app with duration and percentage, sorted by time (e.g. \"VS Code: 2h 15min (28%)\")\n\n## By Category\n- Group into: coding, meetings, browsing, writing, communication, other\n- Show hours and percentage per category\n\n## By Project\n- Group related activities by project/topic. Name specific repos or tasks.\n\n## Productivity Score\n- Calculate: focused_work_hours / total_hours as a percentage\n- Focused = coding + writing. Unfocused = browsing + switching.\n\nEnd with: \"**Suggestion:** [one specific change to improve tomorrow's productivity]\"\n\n=== /volume1/screenpipe/pipes/video-export/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Export Video Clip\ndescription: \"Create a video of your recent screen activity\"\nicon: \"🎬\"\nfeatured: false\n---\n\nExport a video of my screen activity from the last 5 minutes.\n\nRead screenpipe skill first.\n\nUse the POST /frames/export endpoint with the time range and fps=1.0. Then show me the exported video file path as an inline code block so I can watch it.\n\nIf the export is large, suggest a lower fps or shorter time range.","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Now I have a clear picture. The pipes are markdown prompt templates in","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"/volume1/screenpipe/pipes/","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":", but there's no code to actually load and run them —","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"consumers/summary.py","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"has its own hardcoded prompts instead.","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Here's what I'll implement:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"consumers/pipes.py","depth":26,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"— dynamically loads pipe.md files and runs them via Claude (data injected as system message, pipe body as user prompt)","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"main.py","depth":26,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"— two new endpoints:","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"GET /api/pipes","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"and","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"POST /api/pipes/{pipe_id}/run","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"cli.py","depth":26,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"— a","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"pipe","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"command to run pipes from the terminal","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Let me build it:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Check browser_urls signature","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"cat /volume1/screenpipe/app/consumers/activity.py | grep \"def browser_urls\" -A 5","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"def browser_urls(\n for_date: date | None = None,\n app_name: str | None = None,\n ts_from: str | None = None,\n ts_to: str | None = None,\n limit: int = 30,","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Write","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"pipes.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"pipes.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"143 lines","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"\"\"\"Dynamic pipe loader and runner.\"\"\"\nimport os\nimport re\nfrom datetime import date\nfrom pathlib import Path\nfrom typing import Any\n\n\ndef _parse_frontmatter(text: str) -> tuple[dict, str]:\n if not text.startswith(\"---\"):\n return {}, text\n try:\n end = text.index(\"---\", 3)\n except ValueError:\n return {}, text\n fm_text = text[3:end].strip()\n body = text[end + 3:].strip()\n meta: dict = {}\n for line in fm_text.splitlines():\n if \":\" in line:\n k, _, v = line.partition(\":\")\n meta[k.strip()] = v.strip().strip('\"')\n return meta, body\n\n\ndef load_pipes(pipes_dir: Path) -> list[dict]:\n if not pipes_dir.exists():\n return []\n pipes = []\n for pipe_dir in sorted(pipes_dir.iterdir()):\n if not pipe_dir.is_dir() or pipe_dir.name.startswith(\".\"):\n continue\n pipe_md = pipe_dir / \"pipe.md\"\n if not pipe_md.exists():\n continue\n text = pipe_md.read_text(encoding=\"utf-8\")\n meta, body = _parse_frontmatter(text)\n if meta.get(\"enabled\", \"true\").lower() == \"false\":\n continue\n body = re.sub(r\"Read screenpipe skill first\\.?\\n?\", \"\", body).strip()\n pipes.append({\n \"id\": pipe_dir.name,\n \"title\": meta.get(\"title\", pipe_dir.name),\n \"description\": meta.get(\"description\", \"\"),\n \"icon\": meta.get(\"icon\", \"\"),\n \"schedule\": meta.get(\"schedule\", \"manual\"),\n \"featured\": meta.get(\"featured\", \"false\").lower() == \"true\",\n \"prompt\": body,\n })\n return pipes\n\n\ndef _build_system(d: date, stats: dict) -> str:\n from consumers.activity import app_time, browser_urls, ui_event_summary\n from consumers.ocr import deduplicated_text\n from consumers.audio import formatted_transcript\n\n apps = app_time(d)\n app_lines = \"\\n\".join(f\"- {a['app_name']}: {a['minutes']} min\" for a in apps[:20])\n\n urls = browser_urls(d, limit=20)\n url_lines = \"\\n\".join(f\"- {u['browser_url'][:100]} ({u['minutes']} min)\" for u in urls)\n\n ui_rows = ui_event_summary(d)\n ui_lines = \"\\n\".join(\n f\"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches\"\n for r in ui_rows[:15]\n )\n\n ocr_rows = deduplicated_text(d, chunk_minutes=5)\n ocr_lines = \"\\n\".join(\n f\"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}\"\n for r in ocr_rows[:100]\n )\n\n audio = formatted_transcript(d)\n if len(audio) > 3000:\n audio = audio[:3000]\n\n return f\"\"\"You are analyzing screenpipe data — recordings of a person's computer activity.\n\n## App usage (minutes per app):\n{app_lines or '(no app data)'}\n\n## Browser URLs visited:\n{url_lines or '(no browser data)'}\n\n## UI activity per app (clicks / keystrokes / app-switches):\n{ui_lines or '(no UI event data)'}\n\n## Screen content (sampled every 5 minutes):\n{ocr_lines or '(no screen data)'}\n\n## Audio / speech:\n{audio or '(no audio data)'}\n\nDate: {d}\nTotal frames recorded: {stats['total_frames']}\"\"\"\n\n\ndef run_pipe(\n pipe_id: str,\n for_date: date | None = None,\n api_key: str | None = None,\n pipes_dir: Path | None = None,\n) -> dict[str, Any]:\n import anthropic\n from consumers.activity import summary_stats\n\n d = for_date or date.today()\n key = api_key or os.environ.get(\"ANTHROPIC_API_KEY\", \"\")\n if not key:\n return {\"title\": \"Error\", \"content\": \"ANTHROPIC_API_KEY not set.\", \"date\": str(d)}\n\n _pipes_dir = pipes_dir or Path(os.environ.get(\"PIPES_DIR\", \"/data/pipes\"))\n all_pipes = {p[\"id\"]: p for p in load_pipes(_pipes_dir)}\n\n if pipe_id not in all_pipes:\n return {\"title\": \"Error\", \"content\": f\"Pipe not found: {pipe_id}\", \"date\": str(d)}\n\n pipe = all_pipes[pipe_id]\n stats = summary_stats(d)\n\n if stats[\"total_frames\"] == 0:\n return {\"title\": pipe[\"title\"], \"content\": f\"No screen data found for {d}.\", \"date\": str(d)}\n\n system = _build_system(d, stats)\n\n client = anthropic.Anthropic(api_key=key)\n message = client.messages.create(\n model=\"claude-haiku-4-5-20251001\",\n max_tokens=1024,\n system=system,\n messages=[{\"role\": \"user\", \"content\": pipe[\"prompt\"]}],\n )\n\n return {\n \"title\": pipe[\"title\"],\n \"content\": message.content[0].text,\n \"date\": str(d),\n \"stats\": stats,\n }","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Now add the API endpoints to","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"main.py","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":":","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Edit","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"main.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Added 1 line","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Edit","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"main.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Added 1 line","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Now add the pipe endpoints at the end of main.py, before the closing summary section:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Edit","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"main.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Added 14 lines","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Now add the CLI command to","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"cli.py","depth":23,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"cli.py","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":":","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Edit","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"cli.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"cli.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Added 40 lines","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Done. Here's how to run pipes:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXHeading","text":"How to run pipes","depth":22,"on_screen":false,"role_description":"heading"},{"role":"AXStaticText","text":"How to run pipes","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Via Docker (inside the running container):","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":23,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"docker exec -it screenpipe-app python cli.py pipe --list\ndocker exec -it screenpipe-app python cli.py pipe day-recap\ndocker exec -it screenpipe-app python cli.py pipe standup-update --date yesterday","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Via the API","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"(once the container is running on port 8766):","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":23,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"# List pipes\ncurl http://localhost:8766/api/pipes\n\n# Run a pipe\ncurl -X POST \"http://localhost:8766/api/pipes/day-recap/run\"\ncurl -X POST \"http://localhost:8766/api/pipes/standup-update/run?d=2026-04-25\"","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Rebuild and restart","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"to pick up the changes:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":23,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"cd /volume1/screenpipe/app\ndocker compose up --build -d","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"How it works:","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Each","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"pipe.md","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"file is loaded dynamically — the frontmatter provides metadata and the body becomes the user prompt. Screenpipe data (app usage, browser URLs, OCR, audio) is injected as a Claude system message so the pipe prompt can reference it naturally. The \"Read screenpipe skill first\" line is stripped automatically.","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"The pipes directory inside Docker is","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"/data/pipes","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"(since","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"/volume1/screenpipe","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"→","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"/data","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"). You can override it with a","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"PIPES_DIR","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"env var if needed.","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Message actions","depth":24,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"pipe.md","depth":23,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"pipe.md","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"where to place api key and can I use different keys","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read .env file","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"cat /volume1/screenpipe/app/.env","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ANTHROPIC_API_KEY=your_key_here","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Where to place the key:","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"app/.env","depth":23,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"app/.env","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"— replace","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"your_key_here","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"with your actual key:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":23,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"ANTHROPIC_API_KEY=sk-ant-...","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"That file is loaded by","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"load_dotenv()","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"at startup and is excluded from git via","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":".gitignore","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":".","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Can you use different keys per pipe?","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Not currently — all pipes share the one key from","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":".env","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":". But you can add per-pipe key support by adding an","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"api_key","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"field to the pipe's frontmatter:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":23,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"---\ntitle: Meeting Summary\napi_key_env: ANTHROPIC_KEY_MEETINGS\n---","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Then in","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"consumers/pipes.py","depth":23,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"consumers/pipes.py","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":", read it in","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"_parse_frontmatter","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"and pass it through","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"run_pipe","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":". Want me to add that?","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Message actions","depth":24,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"pipe.md","depth":23,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"pipe.md","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"can I use mistral or other llm? or is is build for antrophic only","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Currently it's Anthropic-only — the code calls the","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"anthropic","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"SDK directly in both","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"consumers/pipes.py","depth":23,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"consumers/pipes.py","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"and","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"consumers/summary.py","depth":23,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"consumers/summary.py","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":".","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Adding other providers is straightforward since Mistral, Ollama, OpenRouter, Groq, and most modern LLMs expose an OpenAI-compatible API. The cleanest approach: add the","depth":23,"on_screen":false,"role_description":"text"}]...
|
2382478734108606323
|
-8763776880662820632
|
idle
|
accessibility
|
NULL
|
Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧ Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py
M
db.py
docker-compose.yml
Dockerfile
M
main.py
M
requirements.txt
M
data
logs
pipes
.gitignore
app_settings.json
archive.db
archive.db-bak
U
db.sqlite
db.sqlite-shm
db.sqlite-wal
screenpipe_sync_updated.sh
U
screenpipe_sync.sh
screenpipe.db
Outline Section
OUTLINE
OUTLINE
Timeline Section
TIMELINE
TIMELINE
app_settings.json, Editor Group 1
screenpipe_sync.sh, Editor Group 1
pipe.md, Editor Group 1
.env, Editor Group 1
[ENV_SECRET]
[ENV_SECRET]
Implement and run pipe l…, Editor Group 2
Problems (⇧⌘M)
PROBLEMS
Output (⇧⌘U)
OUTPUT
Debug Console (⇧⌘Y)
DEBUG CONSOLE
Terminal (⌃`)
TERMINAL
Ports - 1 forwarded port
PORTS
1
remote SSH: nas
SSH: nas
screenpipe (Git) - master*, Checkout Branch/Tag...
master*
screenpipe (Git) - Synchronize Changes
No Problems
0
0
Forwarded Ports: 8766
1
Notifications
Sign In
Sign In
Info: Setting up SSH Host nas: Setting up SSH tunnel
Implement and run pipe logic
Session history
New session
Message actions
main.py
main.py
lets implement logic with pipes. how can I run it?
Thinking
Thinking
Let me look at the current project structure to understand what's already in place.
Bash
List project files
IN
find /volume1/screenpipe -type f | head -50 && echo "---" && ls /volume1/screenpipe
Copy code to clipboard
OUT
/volume1/screenpipe/.DS_Store
/volume1/screenpipe/screenpipe.db
/volume1/screenpipe/screenpipe_sync.sh
/volume1/screenpipe/app_settings.json
/volume1/screenpipe/.gitignore
/volume1/screenpipe/archive.db
/volume1/screenpipe/db.sqlite
/volume1/screenpipe/db.sqlite-wal
/volume1/screenpipe/db.sqlite-shm
/volume1/screenpipe/#recycle/desktop.ini
/volume1/screenpipe/#recycle/db.sqlite
/volume1/screenpipe/#recycle/Copy #1 of db.sqlite
/volume1/screenpipe/#recycle/.DS_Store
/volume1/screenpipe/#recycle/Copy #2 of db.sqlite
/volume1/screenpipe/#recycle/archive.db
/volume1/screenpipe/#recycle/Copy #1 of archive.db
/volume1/screenpipe/#recycle/Copy #2 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of archive.db
/volume1/screenpipe/#recycle/Copy #4 of archive.db
/volume1/screenpipe/#recycle/Copy #5 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of db.sqlite
/volume1/screenpipe/#recycle/Copy #4 of db.sqlite
/volume1/screenpipe/#recycle/Copy #6 of archive.db
/volume1/screenpipe/#recycle/test.txt
/volume1/screenpipe/#recycle/Copy #7 of archive.db
/volume1/screenpipe/#recycle/Copy #8 of archive.db
/volume1/screenpipe/#recycle/archive.db-journal
/volume1/screenpipe/#recycle/Copy #1 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #2 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #3 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #4 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #6 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #7 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of db.sqlite
/volume1/screenpipe/pipes/.DS_Store
/volume1/screenpipe/app/.env
/volume1/screenpipe/app/cli.py
/volume1/screenpipe/app/.DS_Store
/volume1/screenpipe/app/db.py
/volume1/screenpipe/app/docker-compose.yml
/volume1/screenpipe/app/main.py
/volume1/screenpipe/app/requirements.txt
/volume1/screenpipe/app/Dockerfile
/volume1/screenpipe/data/.DS_Store
/volume1/screenpipe/.git/description
/volume1/screenpipe/.git/HEAD
/volume1/screenpipe/.git/index
/volume1/screenpipe/.git/COMMIT_EDITMSG
/volume1/screenpipe/#recycle/data/.DS_Store
---
app
app_settings.json
archive.db
data
db.sqlite
db.sqlite-shm
db.sqlite-wal
pipes
#recycle
screenpipe.db
screenpipe_sync.sh
Read
main.py
main.py
Bash
Check pipes directory and docker-compose
IN
ls /volume1/screenpipe/pipes/ && ls /volume1/screenpipe/app/ && cat /volume1/screenpipe/app/docker-compose.yml
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
cli.py
consumers
db.py
docker-compose.yml
Dockerfile
main.py
__pycache__
requirements.txt
static
services:
screenpipe-app:
build: .
container_name: screenpipe-app
restart: unless-stopped
ports:
- "8766:8000"
volumes:
- /volume1/screenpipe:/data
env_file:
- .env
environment:
TZ: Europe/Sofia
DB_PATH: /data/db.sqlite
sqlite-web-archive:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-archive
restart: unless-stopped
ports:
- "8767:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/archive.db"]
sqlite-web-live:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-live
restart: unless-stopped
ports:
- "8768:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/db.sqlite"]
Read
requirements.txt
requirements.txt
Bash
Inspect a pipe directory
IN
ls /volume1/screenpipe/pipes/day-recap/ && cat /volume1/screenpipe/pipes/day-recap/pipe.json 2>/dev/null || ls /volume1/screenpipe/pipes/day-recap/
Copy code to clipboard
OUT
pipe.md
pipe.md
Read
cli.py
cli.py
Bash
List all pipes and their contents
IN
ls /volume1/screenpipe/pipes/ && for d in /volume1/screenpipe/pipes/*/; do echo "=== $d ==="; ls "$d"; done
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
=== /volume1/screenpipe/pipes/ai-habits/ ===
pipe.md
=== /volume1/screenpipe/pipes/day-recap/ ===
pipe.md
=== /volume1/screenpipe/pipes/meeting-summary/ ===
pipe.md
=== /volume1/screenpipe/pipes/standup-update/ ===
pipe.md
=== /volume1/screenpipe/pipes/time-breakdown/ ===
pipe.md
=== /volume1/screenpipe/pipes/video-export/ ===
pipe.md
Bash
Read pipe markdown files
IN
cat /volume1/screenpipe/pipes/day-recap/pipe.md && echo "===" && cat /volume1/screenpipe/pipes/meeting-summary/pipe.md 2>/dev/null | head -50
Copy code to clipboard
OUT
---
schedule: manual
enabled: true
template: true
title: Day Recap
description: "Today's accomplishments, key moments, and unfinished work"
icon: "📋"
featured: true
---
Analyze my screen and audio recordings from today (last 16 hours only).
Read screenpipe skill first.
Use this exact format:
## Summary
One sentence: what I mainly did today.
## Accomplishments
- Top 3 things I finished, with timestamps (e.g. "2:30 PM")
- Name specific apps, files, or projects
## Key Moments
- Important things I saw, said, or heard — with timestamps
## Unfinished Work
- What I should continue tomorrow — name the app/file/task
## Patterns
- Apps I used most, topics that came up repeatedly
Only report what you can verify from the data. End with: "**Next step:** [most important thing to continue]"
===
---
schedule: manual
enabled: true
template: true
title: Meeting Summary
description: "Summarize meeting transcript with key takeaways and action items"
icon: "🤝"
featured: false
---
Summarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.
Read screenpipe skill first.
Use this exact format:
## Meeting Summary
One sentence: what this meeting was about.
## Key Takeaways
- Top 3-5 important points discussed
- Include who said what when relevant
## Action Items
- [ ] Task — assigned to whom, deadline if mentioned
- [ ] Task — assigned to whom
## Decisions Made
- List any decisions or agreements reached
## Open Questions
- Anything unresolved or needing follow-up
Keep it concise and actionable.
Thinking
Thinking
Bash
Read summary consumer
IN
ls /volume1/screenpipe/app/consumers/ && cat /volume1/screenpipe/app/consumers/summary.py
Copy code to clipboard
OUT
activity.py
audio.py
elements.py
__init__.py
interactions.py
ocr.py
__pycache__
report.py
summary.py
"""AI summary generator using Claude."""
import os
from datetime import date
from typing import Any
from consumers.activity import app_time, summary_stats, browser_urls, ui_event_summary
from consumers.ocr import deduplicated_text
from consumers.audio import formatted_transcript
SUMMARY_TYPES = {
"day_recap": {
"title": "Day Recap",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
## Audio/speech:
{audio}
Write a concise day recap using EXACTLY this format:
## Summary
One sentence: what I mainly worked on today.
## Accomplishments
- Top 3 things I finished, with approximate times
- Name specific apps, files, or projects
## Key Moments
- Important things seen or heard, with timestamps
## Unfinished Work
- What to continue tomorrow
## Patterns
- Apps used most, topics that came up repeatedly
Only report what you can verify from the data. End with:
**Next step:** [most important thing to continue]""",
},
"standup": {
"title": "Standup Update",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
## Audio/speech:
{audio}
Write a brief standup update:
**Yesterday:** What I worked on (2-3 bullets)
**Today:** What I plan to continue (1-2 bullets)
**Blockers:** Any issues observed (or "None")
Keep it under 150 words. Only report what's verifiable from the data.""",
},
"focus_time": {
"title": "Focus & Distraction Analysis",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
Analyze focus vs distraction patterns:
## Deep Work Periods
- When and how long were sustained focus sessions?
- What was being worked on?
## Distractions
- Which apps/sites were used recreationally?
- How much time was lost to context switching?
## Recommendations
- 2-3 concrete suggestions to improve focus tomorrow
Be specific with times and app names.""",
},
}
def _build_context(for_date: date) -> dict[str, str]:
apps = app_time(for_date)
app_lines = "\n".join(f"- {a['app_name']}: {a['minutes']} min" for a in apps[:20])
urls = browser_urls(for_date, limit=20)
url_lines = "\n".join(
f"- {u['browser_url'][:100]} ({u['minutes']} min)" for u in urls
)
ui_rows = ui_event_summary(for_date)
ui_lines = "\n".join(
f"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches"
for r in ui_rows[:15]
)
ocr_rows = deduplicated_text(for_date, chunk_minutes=5)
ocr_lines = "\n".join(
f"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}"
for r in ocr_rows[:100]
)
audio = formatted_transcript(for_date)
return {
"app_time": app_lines or "(no app data)",
"browser_urls": url_lines or "(no browser data)",
"ui_events": ui_lines or "(no UI event data)",
"ocr_text": ocr_lines or "(no screen data)",
"audio": audio[:3000] if len(audio) > 3000 else audio,
}
def generate(
summary_type: str = "day_recap",
for_date: date | None = None,
api_key: str | None = None,
) -> dict[str, Any]:
"""Generate an AI summary. Returns dict with 'title', 'content', 'date'."""
import anthropic
d = for_date or date.today()
key = api_key or os.environ.get("ANTHROPIC_API_KEY", "")
if not key:
return {
"title": "Error",
"content": "ANTHROPIC_API_KEY not set. Add it to your .env file.",
"date": str(d),
}
spec = SUMMARY_TYPES.get(summary_type)
if not spec:
return {"title": "Error", "content": f"Unknown summary type: {summary_type}", "date": str(d)}
stats = summary_stats(d)
if stats["total_frames"] == 0:
return {
"title": spec["title"],
"content": f"No screen data found for {d}.",
"date": str(d),
}
ctx = _build_context(d)
prompt = spec["prompt"].format(**ctx)
client = anthropic.Anthropic(api_key=key)
message = client.messages.create(
model="claude-haiku-4-5-20251001",
max_tokens=1024,
messages=[{"role": "user", "content": prompt}],
)
return {
"title": spec["title"],
"content": message.content[0].text,
"date": str(d),
"stats": stats,
}
Thinking
Thinking
Bash
Read all pipe.md files
IN
for f in /volume1/screenpipe/pipes/*/pipe.md; do echo "=== $f ==="; cat "$f"; echo; done
Copy code to clipboard
OUT
=== /volume1/screenpipe/pipes/ai-habits/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: AI Habits
description: "How you use AI tools — patterns and insights"
icon: "🤖"
featured: true
---
Search my recordings from the last 24 hours for AI tool usage. Use app_name filter for each tool separately: ChatGPT, Claude, Copilot, Cursor, Gemini, Perplexity. Use limit=5 per search, max 6 searches total.
Read screenpipe skill first.
Use this exact format:
## AI Tools Used
- List each tool with approximate time spent (e.g. "Claude: ~45min")
## What I Used Them For
- For each tool: coding, writing, research, or brainstorming
## Usage Patterns
- Do I switch between tools? Use them in bursts or steadily?
## Effectiveness
- Which tool appeared alongside completed work vs. abandoned attempts
If no AI usage is found, say so clearly. End with: "**Tip:** [one suggestion to use AI tools more effectively]"
=== /volume1/screenpipe/pipes/day-recap/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Day Recap
description: "Today's accomplishments, key moments, and unfinished work"
icon: "📋"
featured: true
---
Analyze my screen and audio recordings from today (last 16 hours only).
Read screenpipe skill first.
Use this exact format:
## Summary
One sentence: what I mainly did today.
## Accomplishments
- Top 3 things I finished, with timestamps (e.g. "2:30 PM")
- Name specific apps, files, or projects
## Key Moments
- Important things I saw, said, or heard — with timestamps
## Unfinished Work
- What I should continue tomorrow — name the app/file/task
## Patterns
- Apps I used most, topics that came up repeatedly
Only report what you can verify from the data. End with: "**Next step:** [most important thing to continue]"
=== /volume1/screenpipe/pipes/meeting-summary/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Meeting Summary
description: "Summarize meeting transcript with key takeaways and action items"
icon: "🤝"
featured: false
---
Summarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.
Read screenpipe skill first.
Use this exact format:
## Meeting Summary
One sentence: what this meeting was about.
## Key Takeaways
- Top 3-5 important points discussed
- Include who said what when relevant
## Action Items
- [ ] Task — assigned to whom, deadline if mentioned
- [ ] Task — assigned to whom
## Decisions Made
- List any decisions or agreements reached
## Open Questions
- Anything unresolved or needing follow-up
Keep it concise and actionable.
=== /volume1/screenpipe/pipes/standup-update/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Standup Update
description: "What you did, what's next, and any blockers"
icon: "🏢"
featured: true
---
Based on my recordings from the last 24 hours, generate a standup update. Use limit=10 per search, max 3 searches total.
Read screenpipe skill first.
Use this exact format:
## Yesterday
- What I worked on (name specific projects, files, tools, PRs)
## Today
- What I will work on next (based on unfinished tasks and recent activity)
## Blockers
- Issues I hit — errors, slow builds, waiting on someone
- If no blockers, write "None"
Keep it under 150 words. Copy-paste ready for a team standup.
=== /volume1/screenpipe/pipes/time-breakdown/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Time Breakdown
description: "Where your time went — by app, project, and category"
icon: "⏱"
featured: false
---
Analyze my app usage from today (last 12 hours). Use limit=10 per search, max 4 searches. Prefer /raw_sql with COUNT/GROUP BY queries.
Read screenpipe skill first.
Use this exact format with durations and percentages:
## By Application
- List each app with duration and percentage, sorted by time (e.g. "VS Code: 2h 15min (28%)")
## By Category
- Group into: coding, meetings, browsing, writing, communication, other
- Show hours and percentage per category
## By Project
- Group related activities by project/topic. Name specific repos or tasks.
## Productivity Score
- Calculate: focused_work_hours / total_hours as a percentage
- Focused = coding + writing. Unfocused = browsing + switching.
End with: "**Suggestion:** [one specific change to improve tomorrow's productivity]"
=== /volume1/screenpipe/pipes/video-export/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Export Video Clip
description: "Create a video of your recent screen activity"
icon: "🎬"
featured: false
---
Export a video of my screen activity from the last 5 minutes.
Read screenpipe skill first.
Use the POST /frames/export endpoint with the time range and fps=1.0. Then show me the exported video file path as an inline code block so I can watch it.
If the export is large, suggest a lower fps or shorter time range.
Thinking
Thinking
Now I have a clear picture. The pipes are markdown prompt templates in
/volume1/screenpipe/pipes/
, but there's no code to actually load and run them —
consumers/summary.py
has its own hardcoded prompts instead.
Here's what I'll implement:
consumers/pipes.py
— dynamically loads pipe.md files and runs them via Claude (data injected as system message, pipe body as user prompt)
main.py
— two new endpoints:
GET /api/pipes
and
POST /api/pipes/{pipe_id}/run
cli.py
— a
pipe
command to run pipes from the terminal
Let me build it:
Bash
Check browser_urls signature
IN
cat /volume1/screenpipe/app/consumers/activity.py | grep "def browser_urls" -A 5
Copy code to clipboard
OUT
def browser_urls(
for_date: date | None = None,
app_name: str | None = None,
ts_from: str | None = None,
ts_to: str | None = None,
limit: int = 30,
Write
pipes.py
pipes.py
143 lines
"""Dynamic pipe loader and runner."""
import os
import re
from datetime import date
from pathlib import Path
from typing import Any
def _parse_frontmatter(text: str) -> tuple[dict, str]:
if not text.startswith("---"):
return {}, text
try:
end = text.index("---", 3)
except ValueError:
return {}, text
fm_text = text[3:end].strip()
body = text[end + 3:].strip()
meta: dict = {}
for line in fm_text.splitlines():
if ":" in line:
k, _, v = line.partition(":")
meta[k.strip()] = v.strip().strip('"')
return meta, body
def load_pipes(pipes_dir: Path) -> list[dict]:
if not pipes_dir.exists():
return []
pipes = []
for pipe_dir in sorted(pipes_dir.iterdir()):
if not pipe_dir.is_dir() or pipe_dir.name.startswith("."):
continue
pipe_md = pipe_dir / "pipe.md"
if not pipe_md.exists():
continue
text = pipe_md.read_text(encoding="utf-8")
meta, body = _parse_frontmatter(text)
if meta.get("enabled", "true").lower() == "false":
continue
body = re.sub(r"Read screenpipe skill first\.?\n?", "", body).strip()
pipes.append({
"id": pipe_dir.name,
"title": meta.get("title", pipe_dir.name),
"description": meta.get("description", ""),
"icon": meta.get("icon", ""),
"schedule": meta.get("schedule", "manual"),
"featured": meta.get("featured", "false").lower() == "true",
"prompt": body,
})
return pipes
def _build_system(d: date, stats: dict) -> str:
from consumers.activity import app_time, browser_urls, ui_event_summary
from consumers.ocr import deduplicated_text
from consumers.audio import formatted_transcript
apps = app_time(d)
app_lines = "\n".join(f"- {a['app_name']}: {a['minutes']} min" for a in apps[:20])
urls = browser_urls(d, limit=20)
url_lines = "\n".join(f"- {u['browser_url'][:100]} ({u['minutes']} min)" for u in urls)
ui_rows = ui_event_summary(d)
ui_lines = "\n".join(
f"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches"
for r in ui_rows[:15]
)
ocr_rows = deduplicated_text(d, chunk_minutes=5)
ocr_lines = "\n".join(
f"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}"
for r in ocr_rows[:100]
)
audio = formatted_transcript(d)
if len(audio) > 3000:
audio = audio[:3000]
return f"""You are analyzing screenpipe data — recordings of a person's computer activity.
## App usage (minutes per app):
{app_lines or '(no app data)'}
## Browser URLs visited:
{url_lines or '(no browser data)'}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_lines or '(no UI event data)'}
## Screen content (sampled every 5 minutes):
{ocr_lines or '(no screen data)'}
## Audio / speech:
{audio or '(no audio data)'}
Date: {d}
Total frames recorded: {stats['total_frames']}"""
def run_pipe(
pipe_id: str,
for_date: date | None = None,
api_key: str | None = None,
pipes_dir: Path | None = None,
) -> dict[str, Any]:
import anthropic
from consumers.activity import summary_stats
d = for_date or date.today()
key = api_key or os.environ.get("ANTHROPIC_API_KEY", "")
if not key:
return {"title": "Error", "content": "ANTHROPIC_API_KEY not set.", "date": str(d)}
_pipes_dir = pipes_dir or Path(os.environ.get("PIPES_DIR", "/data/pipes"))
all_pipes = {p["id"]: p for p in load_pipes(_pipes_dir)}
if pipe_id not in all_pipes:
return {"title": "Error", "content": f"Pipe not found: {pipe_id}", "date": str(d)}
pipe = all_pipes[pipe_id]
stats = summary_stats(d)
if stats["total_frames"] == 0:
return {"title": pipe["title"], "content": f"No screen data found for {d}.", "date": str(d)}
system = _build_system(d, stats)
client = anthropic.Anthropic(api_key=key)
message = client.messages.create(
model="claude-haiku-4-5-20251001",
max_tokens=1024,
system=system,
messages=[{"role": "user", "content": pipe["prompt"]}],
)
return {
"title": pipe["title"],
"content": message.content[0].text,
"date": str(d),
"stats": stats,
}
Now add the API endpoints to
main.py
:
Edit
main.py
main.py
Added 1 line
Edit
main.py
main.py
Added 1 line
Now add the pipe endpoints at the end of main.py, before the closing summary section:
Edit
main.py
main.py
Added 14 lines
Now add the CLI command to
cli.py
cli.py
:
Edit
cli.py
cli.py
Added 40 lines
Done. Here's how to run pipes:
How to run pipes
How to run pipes
Via Docker (inside the running container):
Copy code to clipboard
docker exec -it screenpipe-app python cli.py pipe --list
docker exec -it screenpipe-app python cli.py pipe day-recap
docker exec -it screenpipe-app python cli.py pipe standup-update --date yesterday
Via the API
(once the container is running on port 8766):
Copy code to clipboard
# List pipes
curl http://localhost:8766/api/pipes
# Run a pipe
curl -X POST "http://localhost:8766/api/pipes/day-recap/run"
curl -X POST "http://localhost:8766/api/pipes/standup-update/run?d=2026-04-25"
Rebuild and restart
to pick up the changes:
Copy code to clipboard
cd /volume1/screenpipe/app
docker compose up --build -d
How it works:
Each
pipe.md
file is loaded dynamically — the frontmatter provides metadata and the body becomes the user prompt. Screenpipe data (app usage, browser URLs, OCR, audio) is injected as a Claude system message so the pipe prompt can reference it naturally. The "Read screenpipe skill first" line is stripped automatically.
The pipes directory inside Docker is
/data/pipes
(since
/volume1/screenpipe
→
/data
). You can override it with a
PIPES_DIR
env var if needed.
Message actions
pipe.md
pipe.md
where to place api key and can I use different keys
Thinking
Thinking
Bash
Read .env file
IN
cat /volume1/screenpipe/app/.env
Copy code to clipboard
OUT
[ENV_SECRET]
Where to place the key:
app/.env
app/.env
— replace
your_key_here
with your actual key:
Copy code to clipboard
[ENV_SECRET]
That file is loaded by
load_dotenv()
at startup and is excluded from git via
.gitignore
.
Can you use different keys per pipe?
Not currently — all pipes share the one key from
.env
. But you can add per-pipe key support by adding an
api_key
field to the pipe's frontmatter:
Copy code to clipboard
---
title: Meeting Summary
api_key_env: ANTHROPIC_KEY_MEETINGS
---
Then in
consumers/pipes.py
consumers/pipes.py
, read it in
_parse_frontmatter
and pass it through
run_pipe
. Want me to add that?
Message actions
pipe.md
pipe.md
can I use mistral or other llm? or is is build for antrophic only
Thinking
Thinking
Currently it's Anthropic-only — the code calls the
anthropic
SDK directly in both
consumers/pipes.py
consumers/pipes.py
and
consumers/summary.py
consumers/summary.py
.
Adding other providers is straightforward since Mistral, Ollama, OpenRouter, Groq, and most modern LLMs expose an OpenAI-compatible API. The cleanest approach: add the...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
21072
|
920
|
6
|
2026-05-11T17:09:18.712171+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-11/1778 /Users/lukas/.screenpipe/data/data/2026-05-11/1778519358712_m1.jpg...
|
Code
|
Implement and run pipe l… — screenpipe [SSH: nas]
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧ Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py
M
db.py
docker-compose.yml
Dockerfile
M
main.py
M
requirements.txt
M
data
logs
pipes
.gitignore
app_settings.json
archive.db
archive.db-bak
U
db.sqlite
db.sqlite-shm
db.sqlite-wal
screenpipe_sync_updated.sh
U
screenpipe_sync.sh
screenpipe.db
Outline Section
OUTLINE
OUTLINE
Timeline Section
TIMELINE
TIMELINE
app_settings.json, Editor Group 1
screenpipe_sync.sh, Editor Group 1
pipe.md, Editor Group 1
.env, Editor Group 1
[ENV_SECRET]
[ENV_SECRET]
Implement and run pipe l…, Editor Group 2
Problems (⇧⌘M)
PROBLEMS
Output (⇧⌘U)
OUTPUT
Debug Console (⇧⌘Y)
DEBUG CONSOLE
Terminal (⌃`)
TERMINAL
Ports - 1 forwarded port
PORTS
1
remote SSH: nas
SSH: nas
screenpipe (Git) - master*, Checkout Branch/Tag...
master*
screenpipe (Git) - Synchronize Changes
No Problems
0
0
Forwarded Ports: 8766
1
Notifications
Sign In
Sign In
Info: Setting up SSH Host nas: Setting up SSH tunnel
Implement and run pipe logic
Session history
New session
Message actions
main.py
main.py
lets implement logic with pipes. how can I run it?
Thinking
Thinking
Let me look at the current project structure to understand what's already in place.
Bash
List project files
IN
find /volume1/screenpipe -type f | head -50 && echo "---" && ls /volume1/screenpipe
Copy code to clipboard
OUT
/volume1/screenpipe/.DS_Store
/volume1/screenpipe/screenpipe.db
/volume1/screenpipe/screenpipe_sync.sh
/volume1/screenpipe/app_settings.json
/volume1/screenpipe/.gitignore
/volume1/screenpipe/archive.db
/volume1/screenpipe/db.sqlite
/volume1/screenpipe/db.sqlite-wal
/volume1/screenpipe/db.sqlite-shm
/volume1/screenpipe/#recycle/desktop.ini
/volume1/screenpipe/#recycle/db.sqlite
/volume1/screenpipe/#recycle/Copy #1 of db.sqlite
/volume1/screenpipe/#recycle/.DS_Store
/volume1/screenpipe/#recycle/Copy #2 of db.sqlite
/volume1/screenpipe/#recycle/archive.db
/volume1/screenpipe/#recycle/Copy #1 of archive.db
/volume1/screenpipe/#recycle/Copy #2 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of archive.db
/volume1/screenpipe/#recycle/Copy #4 of archive.db
/volume1/screenpipe/#recycle/Copy #5 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of db.sqlite
/volume1/screenpipe/#recycle/Copy #4 of db.sqlite
/volume1/screenpipe/#recycle/Copy #6 of archive.db
/volume1/screenpipe/#recycle/test.txt
/volume1/screenpipe/#recycle/Copy #7 of archive.db
/volume1/screenpipe/#recycle/Copy #8 of archive.db
/volume1/screenpipe/#recycle/archive.db-journal
/volume1/screenpipe/#recycle/Copy #1 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #2 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #3 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #4 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #6 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #7 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of db.sqlite
/volume1/screenpipe/pipes/.DS_Store
/volume1/screenpipe/app/.env
/volume1/screenpipe/app/cli.py
/volume1/screenpipe/app/.DS_Store
/volume1/screenpipe/app/db.py
/volume1/screenpipe/app/docker-compose.yml
/volume1/screenpipe/app/main.py
/volume1/screenpipe/app/requirements.txt
/volume1/screenpipe/app/Dockerfile
/volume1/screenpipe/data/.DS_Store
/volume1/screenpipe/.git/description
/volume1/screenpipe/.git/HEAD
/volume1/screenpipe/.git/index
/volume1/screenpipe/.git/COMMIT_EDITMSG
/volume1/screenpipe/#recycle/data/.DS_Store
---
app
app_settings.json
archive.db
data
db.sqlite
db.sqlite-shm
db.sqlite-wal
pipes
#recycle
screenpipe.db
screenpipe_sync.sh
Read
main.py
main.py
Bash
Check pipes directory and docker-compose
IN
ls /volume1/screenpipe/pipes/ && ls /volume1/screenpipe/app/ && cat /volume1/screenpipe/app/docker-compose.yml
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
cli.py
consumers
db.py
docker-compose.yml
Dockerfile
main.py
__pycache__
requirements.txt
static
services:
screenpipe-app:
build: .
container_name: screenpipe-app
restart: unless-stopped
ports:
- "8766:8000"
volumes:
- /volume1/screenpipe:/data
env_file:
- .env
environment:
TZ: Europe/Sofia
DB_PATH: /data/db.sqlite
sqlite-web-archive:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-archive
restart: unless-stopped
ports:
- "8767:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/archive.db"]
sqlite-web-live:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-live
restart: unless-stopped
ports:
- "8768:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/db.sqlite"]
Read
requirements.txt
requirements.txt
Bash
Inspect a pipe directory
IN
ls /volume1/screenpipe/pipes/day-recap/ && cat /volume1/screenpipe/pipes/day-recap/pipe.json 2>/dev/null || ls /volume1/screenpipe/pipes/day-recap/
Copy code to clipboard
OUT
pipe.md
pipe.md
Read
cli.py
cli.py
Bash
List all pipes and their contents
IN
ls /volume1/screenpipe/pipes/ && for d in /volume1/screenpipe/pipes/*/; do echo "=== $d ==="; ls "$d"; done
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
=== /volume1/screenpipe/pipes/ai-habits/ ===
pipe.md
=== /volume1/screenpipe/pipes/day-recap/ ===
pipe.md
=== /volume1/screenpipe/pipes/meeting-summary/ ===
pipe.md
=== /volume1/screenpipe/pipes/standup-update/ ===
pipe.md
=== /volume1/screenpipe/pipes/time-breakdown/ ===
pipe.md
=== /volume1/screenpipe/pipes/video-export/ ===
pipe.md
Bash
Read pipe markdown files
IN
cat /volume1/screenpipe/pipes/day-recap/pipe.md && echo "===" && cat /volume1/screenpipe/pipes/meeting-summary/pipe.md 2>/dev/null | head -50
Copy code to clipboard
OUT
---
schedule: manual
enabled: true
template: true
title: Day Recap
description: "Today's accomplishments, key moments, and unfinished work"
icon: "📋"
featured: true
---
Analyze my screen and audio recordings from today (last 16 hours only).
Read screenpipe skill first.
Use this exact format:
## Summary
One sentence: what I mainly did today.
## Accomplishments
- Top 3 things I finished, with timestamps (e.g. "2:30 PM")
- Name specific apps, files, or projects
## Key Moments
- Important things I saw, said, or heard — with timestamps
## Unfinished Work
- What I should continue tomorrow — name the app/file/task
## Patterns
- Apps I used most, topics that came up repeatedly
Only report what you can verify from the data. End with: "**Next step:** [most important thing to continue]"
===
---
schedule: manual
enabled: true
template: true
title: Meeting Summary
description: "Summarize meeting transcript with key takeaways and action items"
icon: "🤝"
featured: false
---
Summarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.
Read screenpipe skill first.
Use this exact format:
## Meeting Summary
One sentence: what this meeting was about.
## Key Takeaways
- Top 3-5 important points discussed
- Include who said what when relevant
## Action Items
- [ ] Task — assigned to whom, deadline if mentioned
- [ ] Task — assigned to whom
## Decisions Made
- List any decisions or agreements reached
## Open Questions
- Anything unresolved or needing follow-up
Keep it concise and actionable.
Thinking
Thinking
Bash
Read summary consumer
IN
ls /volume1/screenpipe/app/consumers/ && cat /volume1/screenpipe/app/consumers/summary.py
Copy code to clipboard
OUT
activity.py
audio.py
elements.py
__init__.py
interactions.py
ocr.py
__pycache__
report.py
summary.py
"""AI summary generator using Claude."""
import os
from datetime import date
from typing import Any
from consumers.activity import app_time, summary_stats, browser_urls, ui_event_summary
from consumers.ocr import deduplicated_text
from consumers.audio import formatted_transcript
SUMMARY_TYPES = {
"day_recap": {
"title": "Day Recap",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
## Audio/speech:
{audio}
Write a concise day recap using EXACTLY this format:
## Summary
One sentence: what I mainly worked on today.
## Accomplishments
- Top 3 things I finished, with approximate times
- Name specific apps, files, or projects
## Key Moments
- Important things seen or heard, with timestamps
## Unfinished Work
- What to continue tomorrow
## Patterns
- Apps used most, topics that came up repeatedly
Only report what you can verify from the data. End with:
**Next step:** [most important thing to continue]""",
},
"standup": {
"title": "Standup Update",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
## Audio/speech:
{audio}
Write a brief standup update:
**Yesterday:** What I worked on (2-3 bullets)
**Today:** What I plan to continue (1-2 bullets)
**Blockers:** Any issues observed (or "None")
Keep it under 150 words. Only report what's verifiable from the data.""",
},
"focus_time": {
"title": "Focus & Distraction Analysis",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
Analyze focus vs distraction patterns:
## Deep Work Periods
- When and how long were sustained focus sessions?
- What was being worked on?
## Distractions
- Which apps/sites were used recreationally?
- How much time was lost to context switching?
## Recommendations
- 2-3 concrete suggestions to improve focus tomorrow
Be specific with times and app names.""",
},
}
def _build_context(for_date: date) -> dict[str, str]:
apps = app_time(for_date)
app_lines = "\n".join(f"- {a['app_name']}: {a['minutes']} min" for a in apps[:20])
urls = browser_urls(for_date, limit=20)
url_lines = "\n".join(
f"- {u['browser_url'][:100]} ({u['minutes']} min)" for u in urls
)
ui_rows = ui_event_summary(for_date)
ui_lines = "\n".join(
f"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches"
for r in ui_rows[:15]
)
ocr_rows = deduplicated_text(for_date, chunk_minutes=5)
ocr_lines = "\n".join(
f"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}"
for r in ocr_rows[:100]
)
audio = formatted_transcript(for_date)
return {
"app_time": app_lines or "(no app data)",
"browser_urls": url_lines or "(no browser data)",
"ui_events": ui_lines or "(no UI event data)",
"ocr_text": ocr_lines or "(no screen data)",
"audio": audio[:3000] if len(audio) > 3000 else audio,
}
def generate(
summary_type: str = "day_recap",
for_date: date | None = None,
api_key: str | None = None,
) -> dict[str, Any]:
"""Generate an AI summary. Returns dict with 'title', 'content', 'date'."""
import anthropic
d = for_date or date.today()
key = api_key or os.environ.get("ANTHROPIC_API_KEY", "")
if not key:
return {
"title": "Error",
"content": "ANTHROPIC_API_KEY not set. Add it to your .env file.",
"date": str(d),
}
spec = SUMMARY_TYPES.get(summary_type)
if not spec:
return {"title": "Error", "content": f"Unknown summary type: {summary_type}", "date": str(d)}
stats = summary_stats(d)
if stats["total_frames"] == 0:
return {
"title": spec["title"],
"content": f"No screen data found for {d}.",
"date": str(d),
}
ctx = _build_context(d)
prompt = spec["prompt"].format(**ctx)
client = anthropic.Anthropic(api_key=key)
message = client.messages.create(
model="claude-haiku-4-5-20251001",
max_tokens=1024,
messages=[{"role": "user", "content": prompt}],
)
return {
"title": spec["title"],
"content": message.content[0].text,
"date": str(d),
"stats": stats,
}
Thinking
Thinking
Bash
Read all pipe.md files
IN
for f in /volume1/screenpipe/pipes/*/pipe.md; do echo "=== $f ==="; cat "$f"; echo; done
Copy code to clipboard
OUT
=== /volume1/screenpipe/pipes/ai-habits/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: AI Habits
description: "How you use AI tools — patterns and insights"
icon: "🤖"
featured: true
---
Search my recordings from the last 24 hours for AI tool usage. Use app_name filter for each tool separately: ChatGPT, Claude, Copilot, Cursor, Gemini, Perplexity. Use limit=5 per search, max 6 searches total.
Read screenpipe skill first.
Use this exact format:
## AI Tools Used
- List each tool with approximate time spent (e.g. "Claude: ~45min")
## What I Used Them For
- For each tool: coding, writing, research, or brainstorming
## Usage Patterns
- Do I switch between tools? Use them in bursts or steadily?
## Effectiveness
- Which tool appeared alongside completed work vs. abandoned attempts
If no AI usage is found, say so clearly. End with: "**Tip:** [one suggestion to use AI tools more effectively]"
=== /volume1/screenpipe/pipes/day-recap/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Day Recap
description: "Today's accomplishments, key moments, and unfinished work"
icon: "📋"
featured: true
---
Analyze my screen and audio recordings from today (last 16 hours only).
Read screenpipe skill first.
Use this exact format:
## Summary
One sentence: what I mainly did today.
## Accomplishments
- Top 3 things I finished, with timestamps (e.g. "2:30 PM")
- Name specific apps, files, or projects
## Key Moments
- Important things I saw, said, or heard — with timestamps
## Unfinished Work
- What I should continue tomorrow — name the app/file/task
## Patterns
- Apps I used most, topics that came up repeatedly
Only report what you can verify from the data. End with: "**Next step:** [most important thing to continue]"
=== /volume1/screenpipe/pipes/meeting-summary/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Meeting Summary
description: "Summarize meeting transcript with key takeaways and action items"
icon: "🤝"
featured: false
---
Summarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.
Read screenpipe skill first.
Use this exact format:
## Meeting Summary
One sentence: what this meeting was about.
## Key Takeaways
- Top 3-5 important points discussed
- Include who said what when relevant
## Action Items
- [ ] Task — assigned to whom, deadline if mentioned
- [ ] Task — assigned to whom
## Decisions Made
- List any decisions or agreements reached
## Open Questions
- Anything unresolved or needing follow-up
Keep it concise and actionable.
=== /volume1/screenpipe/pipes/standup-update/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Standup Update
description: "What you did, what's next, and any blockers"
icon: "🏢"
featured: true
---
Based on my recordings from the last 24 hours, generate a standup update. Use limit=10 per search, max 3 searches total.
Read screenpipe skill first.
Use this exact format:
## Yesterday
- What I worked on (name specific projects, files, tools, PRs)
## Today
- What I will work on next (based on unfinished tasks and recent activity)
## Blockers
- Issues I hit — errors, slow builds, waiting on someone
- If no blockers, write "None"
Keep it under 150 words. Copy-paste ready for a team standup.
=== /volume1/screenpipe/pipes/time-breakdown/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Time Breakdown
description: "Where your time went — by app, project, and category"
icon: "⏱"
featured: false
---
Analyze my app usage from today (last 12 hours). Use limit=10 per search, max 4 searches. Prefer /raw_sql with COUNT/GROUP BY queries.
Read screenpipe skill first.
Use this exact format with durations and percentages:
## By Application
- List each app with duration and percentage, sorted by time (e.g. "VS Code: 2h 15min (28%)")
## By Category
- Group into: coding, meetings, browsing, writing, communication, other
- Show hours and percentage per category
## By Project
- Group related activities by project/topic. Name specific repos or tasks.
## Productivity Score
- Calculate: focused_work_hours / total_hours as a percentage
- Focused = coding + writing. Unfocused = browsing + switching.
End with: "**Suggestion:** [one specific change to improve tomorrow's productivity]"
=== /volume1/screenpipe/pipes/video-export/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Export Video Clip
description: "Create a video of your recent screen activity"
icon: "🎬"
featured: false
---
Export a video of my screen activity from the last 5 minutes.
Read screenpipe skill first.
Use the POST /frames/export endpoint with the time range and fps=1.0. Then show me the exported video file path as an inline code block so I can watch it.
If the export is large, suggest a lower fps or shorter time range.
Thinking
Thinking
Now I have a clear picture. The pipes are markdown prompt templates in
/volume1/screenpipe/pipes/
, but there's no code to actually load and run them —
consumers/summary.py
has its own hardcoded prompts instead.
Here's what I'll implement:
consumers/pipes.py
— dynamically loads pipe.md files and runs them via Claude (data injected as system message, pipe body as user prompt)
main.py
— two new endpoints:
GET /api/pipes
and
POST /api/pipes/{pipe_id}/run
cli.py
— a
pipe
command to run pipes from the terminal
Let me build it:
Bash
Check browser_urls signature
IN
cat /volume1/screenpipe/app/consumers/activity.py | grep "def browser_urls" -A 5
Copy code to clipboard
OUT
def browser_urls(
for_date: date | None = None,
app_name: str | None = None,
ts_from: str | None = None,
ts_to: str | None = None,
limit: int = 30,
Write
pipes.py
pipes.py
143 lines
"""Dynamic pipe loader and runner."""
import os
import re
from datetime import date
from pathlib import Path
from typing import Any
def _parse_frontmatter(text: str) -> tuple[dict, str]:
if not text.startswith("---"):
return {}, text
try:
end = text.index("---", 3)
except ValueError:
return {}, text
fm_text = text[3:end].strip()
body = text[end + 3:].strip()
meta: dict = {}
for line in fm_text.splitlines():
if ":" in line:
k, _, v = line.partition(":")
meta[k.strip()] = v.strip().strip('"')
return meta, body
def load_pipes(pipes_dir: Path) -> list[dict]:
if not pipes_dir.exists():
return []
pipes = []
for pipe_dir in sorted(pipes_dir.iterdir()):
if not pipe_dir.is_dir() or pipe_dir.name.startswith("."):
continue
pipe_md = pipe_dir / "pipe.md"
if not pipe_md.exists():
continue
text = pipe_md.read_text(encoding="utf-8")
meta, body = _parse_frontmatter(text)
if meta.get("enabled", "true").lower() == "false":
continue
body = re.sub(r"Read screenpipe skill first\.?\n?", "", body).strip()
pipes.append({
"id": pipe_dir.name,
"title": meta.get("title", pipe_dir.name),
"description": meta.get("description", ""),
"icon": meta.get("icon", ""),
"schedule": meta.get("schedule", "manual"),
"featured": meta.get("featured", "false").lower() == "true",
"prompt": body,
})
return pipes
def _build_system(d: date, stats: dict) -> str:
from consumers.activity import app_time, browser_urls, ui_event_summary
from consumers.ocr import deduplicated_text
from consumers.audio import formatted_transcript
apps = app_time(d)
app_lines = "\n".join(f"- {a['app_name']}: {a['minutes']} min" for a in apps[:20])
urls = browser_urls(d, limit=20)
url_lines = "\n".join(f"- {u['browser_url'][:100]} ({u['minutes']} min)" for u in urls)
ui_rows = ui_event_summary(d)
ui_lines = "\n".join(
f"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches"
for r in ui_rows[:15]
)
ocr_rows = deduplicated_text(d, chunk_minutes=5)
ocr_lines = "\n".join(
f"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}"
for r in ocr_rows[:100]
)
audio = formatted_transcript(d)
if len(audio) > 3000:
audio = audio[:3000]
return f"""You are analyzing screenpipe data — recordings of a person's computer activity.
## App usage (minutes per app):
{app_lines or '(no app data)'}
## Browser URLs visited:
{url_lines or '(no browser data)'}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_lines or '(no UI event data)'}
## Screen content (sampled every 5 minutes):
{ocr_lines or '(no screen data)'}
## Audio / speech:
{audio or '(no audio data)'}
Date: {d}
Total frames recorded: {stats['total_frames']}"""
def run_pipe(
pipe_id: str,
for_date: date | None = None,
api_key: str | None = None,
pipes_dir: Path | None = None,
) -> dict[str, Any]:
import anthropic
from consumers.activity import summary_stats
d = for_date or date.today()
key = api_key or os.environ.get("ANTHROPIC_API_KEY", "")
if not key:
return {"title": "Error", "content": "ANTHROPIC_API_KEY not set.", "date": str(d)}
_pipes_dir = pipes_dir or Path(os.environ.get("PIPES_DIR", "/data/pipes"))
all_pipes = {p["id"]: p for p in load_pipes(_pipes_dir)}
if pipe_id not in all_pipes:
return {"title": "Error", "content": f"Pipe not found: {pipe_id}", "date": str(d)}
pipe = all_pipes[pipe_id]
stats = summary_stats(d)
if stats["total_frames"] == 0:
return {"title": pipe["title"], "content": f"No screen data found for {d}.", "date": str(d)}
system = _build_system(d, stats)
client = anthropic.Anthropic(api_key=key)
message = client.messages.create(
model="claude-haiku-4-5-20251001",
max_tokens=1024,
system=system,
messages=[{"role": "user", "content": pipe["prompt"]}],
)
return {
"title": pipe["title"],
"content": message.content[0].text,
"date": str(d),
"stats": stats,
}
Now add the API endpoints to
main.py
:
Edit
main.py
main.py
Added 1 line
Edit
main.py
main.py
Added 1 line
Now add the pipe endpoints at the end of main.py, before the closing summary section:
Edit
main.py
main.py
Added 14 lines
Now add the CLI command to
cli.py
cli.py
:
Edit
cli.py
cli.py
Added 40 lines
Done. Here's how to run pipes:
How to run pipes
How to run pipes
Via Docker (inside the running container):
Copy code to clipboard
docker exec -it screenpipe-app python cli.py pipe --list
docker exec -it screenpipe-app python cli.py pipe day-recap
docker exec -it screenpipe-app python cli.py pipe standup-update --date yesterday
Via the API
(once the container is running on port 8766):
Copy code to clipboard
# List pipes
curl http://localhost:8766/api/pipes
# Run a pipe
curl -X POST "http://localhost:8766/api/pipes/day-recap/run"
curl -X POST "http://localhost:8766/api/pipes/standup-update/run?d=2026-04-25"
Rebuild and restart
to pick up the changes:
Copy code to clipboard...
|
[{"role":"AXRadioButton","text [{"role":"AXRadioButton","text":"Explorer (⇧⌘E)","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":true},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Search (⇧⌘F)","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Source Control (⌃⇧G) - 10 pending changes","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"10","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Run and Debug (⇧⌘D)","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Remote Explorer","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Extensions (⇧⌘X) - 2 require update","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"2","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Claude Code","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"Containers","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXHeading","text":"EXPLORER","depth":17,"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"EXPLORER","depth":18,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Explorer Section: screenpipe [SSH: nas]","depth":21,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":true},{"role":"AXStaticText","text":"","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"Explorer Section: screenpipe [SSH: nas]","depth":22,"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"SCREENPIPE [SSH: NAS]","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"#recycle","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"app","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"__pycache__","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"consumers","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"static","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":".env","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"cli.py","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.py","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"docker-compose.yml","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Dockerfile","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"main.py","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"requirements.txt","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"data","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"logs","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"pipes","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":".gitignore","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"app_settings.json","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"archive.db","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"archive.db-bak","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"U","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite-shm","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite-wal","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe_sync_updated.sh","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"U","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe_sync.sh","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe.db","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Outline Section","depth":21,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"OUTLINE","depth":22,"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"OUTLINE","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Timeline Section","depth":21,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"TIMELINE","depth":22,"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"TIMELINE","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"app_settings.json, Editor Group 1","depth":28,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"screenpipe_sync.sh, Editor Group 1","depth":28,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"pipe.md, Editor Group 1","depth":28,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":".env, Editor Group 1","depth":28,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":false},{"role":"AXStaticText","text":"","depth":29,"on_screen":true,"role_description":"text"},{"role":"AXTextArea","text":"ANTHROPIC_API_KEY=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","depth":28,"on_screen":true,"value":"ANTHROPIC_API_KEY=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","role_description":"editor","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"ANTHROPIC_API_KEY=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","depth":29,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Implement and run pipe l…, Editor Group 2","depth":28,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":false},{"role":"AXRadioButton","text":"Problems (⇧⌘M)","depth":22,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"PROBLEMS","depth":24,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Output (⇧⌘U)","depth":22,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUTPUT","depth":24,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Debug Console (⇧⌘Y)","depth":22,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"DEBUG CONSOLE","depth":24,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Terminal (⌃`)","depth":22,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":true},{"role":"AXStaticText","text":"TERMINAL","depth":24,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Ports - 1 forwarded port","depth":22,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"PORTS","depth":24,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":25,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"remote SSH: nas","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"SSH: nas","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"screenpipe (Git) - master*, Checkout Branch/Tag...","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"master*","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"screenpipe (Git) - Synchronize Changes","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"No Problems","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"0","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"0","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Forwarded Ports: 8766","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Notifications","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sign In","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Sign In","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Info: Setting up SSH Host nas: Setting up SSH tunnel","depth":12,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Implement and run pipe logic","depth":19,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Session history","depth":19,"on_screen":true,"help_text":"Session history","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"New session","depth":19,"on_screen":true,"help_text":"New session","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Message actions","depth":24,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"main.py","depth":23,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"lets implement logic with pipes. how can I run it?","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Let me look at the current project structure to understand what's already in place.","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"List project files","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"find /volume1/screenpipe -type f | head -50 && echo \"---\" && ls /volume1/screenpipe","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"/volume1/screenpipe/.DS_Store\n/volume1/screenpipe/screenpipe.db\n/volume1/screenpipe/screenpipe_sync.sh\n/volume1/screenpipe/app_settings.json\n/volume1/screenpipe/.gitignore\n/volume1/screenpipe/archive.db\n/volume1/screenpipe/db.sqlite\n/volume1/screenpipe/db.sqlite-wal\n/volume1/screenpipe/db.sqlite-shm\n/volume1/screenpipe/#recycle/desktop.ini\n/volume1/screenpipe/#recycle/db.sqlite\n/volume1/screenpipe/#recycle/Copy #1 of db.sqlite\n/volume1/screenpipe/#recycle/.DS_Store\n/volume1/screenpipe/#recycle/Copy #2 of db.sqlite\n/volume1/screenpipe/#recycle/archive.db\n/volume1/screenpipe/#recycle/Copy #1 of archive.db\n/volume1/screenpipe/#recycle/Copy #2 of archive.db\n/volume1/screenpipe/#recycle/Copy #3 of archive.db\n/volume1/screenpipe/#recycle/Copy #4 of archive.db\n/volume1/screenpipe/#recycle/Copy #5 of archive.db\n/volume1/screenpipe/#recycle/Copy #3 of db.sqlite\n/volume1/screenpipe/#recycle/Copy #4 of db.sqlite\n/volume1/screenpipe/#recycle/Copy #6 of archive.db\n/volume1/screenpipe/#recycle/test.txt\n/volume1/screenpipe/#recycle/Copy #7 of archive.db\n/volume1/screenpipe/#recycle/Copy #8 of archive.db\n/volume1/screenpipe/#recycle/archive.db-journal\n/volume1/screenpipe/#recycle/Copy #1 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #2 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #3 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #4 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #5 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #6 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #7 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #5 of db.sqlite\n/volume1/screenpipe/pipes/.DS_Store\n/volume1/screenpipe/app/.env\n/volume1/screenpipe/app/cli.py\n/volume1/screenpipe/app/.DS_Store\n/volume1/screenpipe/app/db.py\n/volume1/screenpipe/app/docker-compose.yml\n/volume1/screenpipe/app/main.py\n/volume1/screenpipe/app/requirements.txt\n/volume1/screenpipe/app/Dockerfile\n/volume1/screenpipe/data/.DS_Store\n/volume1/screenpipe/.git/description\n/volume1/screenpipe/.git/HEAD\n/volume1/screenpipe/.git/index\n/volume1/screenpipe/.git/COMMIT_EDITMSG\n/volume1/screenpipe/#recycle/data/.DS_Store\n---\napp\napp_settings.json\narchive.db\ndata\ndb.sqlite\ndb.sqlite-shm\ndb.sqlite-wal\npipes\n#recycle\nscreenpipe.db\nscreenpipe_sync.sh","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"main.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Check pipes directory and docker-compose","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/pipes/ && ls /volume1/screenpipe/app/ && cat /volume1/screenpipe/app/docker-compose.yml","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ai-habits\nday-recap\nmeeting-summary\nstandup-update\ntime-breakdown\nvideo-export\ncli.py\nconsumers\ndb.py\ndocker-compose.yml\nDockerfile\nmain.py\n__pycache__\nrequirements.txt\nstatic\nservices:\n screenpipe-app:\n build: .\n container_name: screenpipe-app\n restart: unless-stopped\n ports:\n - \"8766:8000\"\n volumes:\n - /volume1/screenpipe:/data\n env_file:\n - .env\n environment:\n TZ: Europe/Sofia\n DB_PATH: /data/db.sqlite\n\n sqlite-web-archive:\n image: ghcr.io/coleifer/sqlite-web:latest\n container_name: screenpipe-sqlweb-archive\n restart: unless-stopped\n ports:\n - \"8767:8080\"\n volumes:\n - /volume1/screenpipe:/data\n command: [\"-H\", \"0.0.0.0\", \"-r\", \"/data/archive.db\"]\n\n sqlite-web-live:\n image: ghcr.io/coleifer/sqlite-web:latest\n container_name: screenpipe-sqlweb-live\n restart: unless-stopped\n ports:\n - \"8768:8080\"\n volumes:\n - /volume1/screenpipe:/data\n command: [\"-H\", \"0.0.0.0\", \"-r\", \"/data/db.sqlite\"]","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"requirements.txt","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"requirements.txt","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Inspect a pipe directory","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/pipes/day-recap/ && cat /volume1/screenpipe/pipes/day-recap/pipe.json 2>/dev/null || ls /volume1/screenpipe/pipes/day-recap/","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"pipe.md\npipe.md","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"cli.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"cli.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"List all pipes and their contents","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/pipes/ && for d in /volume1/screenpipe/pipes/*/; do echo \"=== $d ===\"; ls \"$d\"; done","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ai-habits\nday-recap\nmeeting-summary\nstandup-update\ntime-breakdown\nvideo-export\n=== /volume1/screenpipe/pipes/ai-habits/ ===\npipe.md\n=== /volume1/screenpipe/pipes/day-recap/ ===\npipe.md\n=== /volume1/screenpipe/pipes/meeting-summary/ ===\npipe.md\n=== /volume1/screenpipe/pipes/standup-update/ ===\npipe.md\n=== /volume1/screenpipe/pipes/time-breakdown/ ===\npipe.md\n=== /volume1/screenpipe/pipes/video-export/ ===\npipe.md","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read pipe markdown files","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"cat /volume1/screenpipe/pipes/day-recap/pipe.md && echo \"===\" && cat /volume1/screenpipe/pipes/meeting-summary/pipe.md 2>/dev/null | head -50","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Day Recap\ndescription: \"Today's accomplishments, key moments, and unfinished work\"\nicon: \"📋\"\nfeatured: true\n---\n\nAnalyze my screen and audio recordings from today (last 16 hours only). \n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Summary\nOne sentence: what I mainly did today.\n\n## Accomplishments\n- Top 3 things I finished, with timestamps (e.g. \"2:30 PM\")\n- Name specific apps, files, or projects\n\n## Key Moments\n- Important things I saw, said, or heard — with timestamps\n\n## Unfinished Work\n- What I should continue tomorrow — name the app/file/task\n\n## Patterns\n- Apps I used most, topics that came up repeatedly\n\nOnly report what you can verify from the data. End with: \"**Next step:** [most important thing to continue]\"\n===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Meeting Summary\ndescription: \"Summarize meeting transcript with key takeaways and action items\"\nicon: \"🤝\"\nfeatured: false\n---\n\nSummarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.\n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Meeting Summary\nOne sentence: what this meeting was about.\n\n## Key Takeaways\n- Top 3-5 important points discussed\n- Include who said what when relevant\n\n## Action Items\n- [ ] Task — assigned to whom, deadline if mentioned\n- [ ] Task — assigned to whom\n\n## Decisions Made\n- List any decisions or agreements reached\n\n## Open Questions\n- Anything unresolved or needing follow-up\n\nKeep it concise and actionable.","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read summary consumer","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/app/consumers/ && cat /volume1/screenpipe/app/consumers/summary.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"activity.py\naudio.py\nelements.py\n__init__.py\ninteractions.py\nocr.py\n__pycache__\nreport.py\nsummary.py\n\"\"\"AI summary generator using Claude.\"\"\"\nimport os\nfrom datetime import date\nfrom typing import Any\n\nfrom consumers.activity import app_time, summary_stats, browser_urls, ui_event_summary\nfrom consumers.ocr import deduplicated_text\nfrom consumers.audio import formatted_transcript\n\n\nSUMMARY_TYPES = {\n \"day_recap\": {\n \"title\": \"Day Recap\",\n \"prompt\": \"\"\"\\\nYou are analyzing a person's computer activity for the day.\n\n## App usage (minutes per app):\n{app_time}\n\n## Browser URLs visited:\n{browser_urls}\n\n## UI activity per app (clicks / keystrokes / app-switches):\n{ui_events}\n\n## Screen content (sampled every 5 minutes):\n{ocr_text}\n\n## Audio/speech:\n{audio}\n\nWrite a concise day recap using EXACTLY this format:\n\n## Summary\nOne sentence: what I mainly worked on today.\n\n## Accomplishments\n- Top 3 things I finished, with approximate times\n- Name specific apps, files, or projects\n\n## Key Moments\n- Important things seen or heard, with timestamps\n\n## Unfinished Work\n- What to continue tomorrow\n\n## Patterns\n- Apps used most, topics that came up repeatedly\n\nOnly report what you can verify from the data. End with:\n**Next step:** [most important thing to continue]\"\"\",\n },\n \"standup\": {\n \"title\": \"Standup Update\",\n \"prompt\": \"\"\"\\\nYou are analyzing a person's computer activity for the day.\n\n## App usage (minutes per app):\n{app_time}\n\n## Browser URLs visited:\n{browser_urls}\n\n## UI activity per app (clicks / keystrokes / app-switches):\n{ui_events}\n\n## Screen content (sampled every 5 minutes):\n{ocr_text}\n\n## Audio/speech:\n{audio}\n\nWrite a brief standup update:\n\n**Yesterday:** What I worked on (2-3 bullets)\n**Today:** What I plan to continue (1-2 bullets)\n**Blockers:** Any issues observed (or \"None\")\n\nKeep it under 150 words. Only report what's verifiable from the data.\"\"\",\n },\n \"focus_time\": {\n \"title\": \"Focus & Distraction Analysis\",\n \"prompt\": \"\"\"\\\nYou are analyzing a person's computer activity for the day.\n\n## App usage (minutes per app):\n{app_time}\n\n## Browser URLs visited:\n{browser_urls}\n\n## UI activity per app (clicks / keystrokes / app-switches):\n{ui_events}\n\n## Screen content (sampled every 5 minutes):\n{ocr_text}\n\nAnalyze focus vs distraction patterns:\n\n## Deep Work Periods\n- When and how long were sustained focus sessions?\n- What was being worked on?\n\n## Distractions\n- Which apps/sites were used recreationally?\n- How much time was lost to context switching?\n\n## Recommendations\n- 2-3 concrete suggestions to improve focus tomorrow\n\nBe specific with times and app names.\"\"\",\n },\n}\n\n\ndef _build_context(for_date: date) -> dict[str, str]:\n apps = app_time(for_date)\n app_lines = \"\\n\".join(f\"- {a['app_name']}: {a['minutes']} min\" for a in apps[:20])\n\n urls = browser_urls(for_date, limit=20)\n url_lines = \"\\n\".join(\n f\"- {u['browser_url'][:100]} ({u['minutes']} min)\" for u in urls\n )\n\n ui_rows = ui_event_summary(for_date)\n ui_lines = \"\\n\".join(\n f\"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches\"\n for r in ui_rows[:15]\n )\n\n ocr_rows = deduplicated_text(for_date, chunk_minutes=5)\n ocr_lines = \"\\n\".join(\n f\"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}\"\n for r in ocr_rows[:100]\n )\n\n audio = formatted_transcript(for_date)\n\n return {\n \"app_time\": app_lines or \"(no app data)\",\n \"browser_urls\": url_lines or \"(no browser data)\",\n \"ui_events\": ui_lines or \"(no UI event data)\",\n \"ocr_text\": ocr_lines or \"(no screen data)\",\n \"audio\": audio[:3000] if len(audio) > 3000 else audio,\n }\n\n\ndef generate(\n summary_type: str = \"day_recap\",\n for_date: date | None = None,\n api_key: str | None = None,\n) -> dict[str, Any]:\n \"\"\"Generate an AI summary. Returns dict with 'title', 'content', 'date'.\"\"\"\n import anthropic\n\n d = for_date or date.today()\n key = api_key or os.environ.get(\"ANTHROPIC_API_KEY\", \"\")\n if not key:\n return {\n \"title\": \"Error\",\n \"content\": \"ANTHROPIC_API_KEY not set. Add it to your .env file.\",\n \"date\": str(d),\n }\n\n spec = SUMMARY_TYPES.get(summary_type)\n if not spec:\n return {\"title\": \"Error\", \"content\": f\"Unknown summary type: {summary_type}\", \"date\": str(d)}\n\n stats = summary_stats(d)\n if stats[\"total_frames\"] == 0:\n return {\n \"title\": spec[\"title\"],\n \"content\": f\"No screen data found for {d}.\",\n \"date\": str(d),\n }\n\n ctx = _build_context(d)\n prompt = spec[\"prompt\"].format(**ctx)\n\n client = anthropic.Anthropic(api_key=key)\n message = client.messages.create(\n model=\"claude-haiku-4-5-20251001\",\n max_tokens=1024,\n messages=[{\"role\": \"user\", \"content\": prompt}],\n )\n\n return {\n \"title\": spec[\"title\"],\n \"content\": message.content[0].text,\n \"date\": str(d),\n \"stats\": stats,\n }","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read all pipe.md files","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"for f in /volume1/screenpipe/pipes/*/pipe.md; do echo \"=== $f ===\"; cat \"$f\"; echo; done","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"=== /volume1/screenpipe/pipes/ai-habits/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: AI Habits\ndescription: \"How you use AI tools — patterns and insights\"\nicon: \"🤖\"\nfeatured: true\n---\n\nSearch my recordings from the last 24 hours for AI tool usage. Use app_name filter for each tool separately: ChatGPT, Claude, Copilot, Cursor, Gemini, Perplexity. Use limit=5 per search, max 6 searches total.\n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## AI Tools Used\n- List each tool with approximate time spent (e.g. \"Claude: ~45min\")\n\n## What I Used Them For\n- For each tool: coding, writing, research, or brainstorming\n\n## Usage Patterns\n- Do I switch between tools? Use them in bursts or steadily?\n\n## Effectiveness\n- Which tool appeared alongside completed work vs. abandoned attempts\n\nIf no AI usage is found, say so clearly. End with: \"**Tip:** [one suggestion to use AI tools more effectively]\"\n\n=== /volume1/screenpipe/pipes/day-recap/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Day Recap\ndescription: \"Today's accomplishments, key moments, and unfinished work\"\nicon: \"📋\"\nfeatured: true\n---\n\nAnalyze my screen and audio recordings from today (last 16 hours only). \n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Summary\nOne sentence: what I mainly did today.\n\n## Accomplishments\n- Top 3 things I finished, with timestamps (e.g. \"2:30 PM\")\n- Name specific apps, files, or projects\n\n## Key Moments\n- Important things I saw, said, or heard — with timestamps\n\n## Unfinished Work\n- What I should continue tomorrow — name the app/file/task\n\n## Patterns\n- Apps I used most, topics that came up repeatedly\n\nOnly report what you can verify from the data. End with: \"**Next step:** [most important thing to continue]\"\n\n=== /volume1/screenpipe/pipes/meeting-summary/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Meeting Summary\ndescription: \"Summarize meeting transcript with key takeaways and action items\"\nicon: \"🤝\"\nfeatured: false\n---\n\nSummarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.\n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Meeting Summary\nOne sentence: what this meeting was about.\n\n## Key Takeaways\n- Top 3-5 important points discussed\n- Include who said what when relevant\n\n## Action Items\n- [ ] Task — assigned to whom, deadline if mentioned\n- [ ] Task — assigned to whom\n\n## Decisions Made\n- List any decisions or agreements reached\n\n## Open Questions\n- Anything unresolved or needing follow-up\n\nKeep it concise and actionable.\n\n=== /volume1/screenpipe/pipes/standup-update/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Standup Update\ndescription: \"What you did, what's next, and any blockers\"\nicon: \"🏢\"\nfeatured: true\n---\n\nBased on my recordings from the last 24 hours, generate a standup update. Use limit=10 per search, max 3 searches total.\n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Yesterday\n- What I worked on (name specific projects, files, tools, PRs)\n\n## Today\n- What I will work on next (based on unfinished tasks and recent activity)\n\n## Blockers\n- Issues I hit — errors, slow builds, waiting on someone\n- If no blockers, write \"None\"\n\nKeep it under 150 words. Copy-paste ready for a team standup.\n\n=== /volume1/screenpipe/pipes/time-breakdown/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Time Breakdown\ndescription: \"Where your time went — by app, project, and category\"\nicon: \"⏱\"\nfeatured: false\n---\n\nAnalyze my app usage from today (last 12 hours). Use limit=10 per search, max 4 searches. Prefer /raw_sql with COUNT/GROUP BY queries.\n\nRead screenpipe skill first.\n\nUse this exact format with durations and percentages:\n\n## By Application\n- List each app with duration and percentage, sorted by time (e.g. \"VS Code: 2h 15min (28%)\")\n\n## By Category\n- Group into: coding, meetings, browsing, writing, communication, other\n- Show hours and percentage per category\n\n## By Project\n- Group related activities by project/topic. Name specific repos or tasks.\n\n## Productivity Score\n- Calculate: focused_work_hours / total_hours as a percentage\n- Focused = coding + writing. Unfocused = browsing + switching.\n\nEnd with: \"**Suggestion:** [one specific change to improve tomorrow's productivity]\"\n\n=== /volume1/screenpipe/pipes/video-export/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Export Video Clip\ndescription: \"Create a video of your recent screen activity\"\nicon: \"🎬\"\nfeatured: false\n---\n\nExport a video of my screen activity from the last 5 minutes.\n\nRead screenpipe skill first.\n\nUse the POST /frames/export endpoint with the time range and fps=1.0. Then show me the exported video file path as an inline code block so I can watch it.\n\nIf the export is large, suggest a lower fps or shorter time range.","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Now I have a clear picture. The pipes are markdown prompt templates in","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"/volume1/screenpipe/pipes/","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":", but there's no code to actually load and run them —","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"consumers/summary.py","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"has its own hardcoded prompts instead.","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Here's what I'll implement:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"consumers/pipes.py","depth":26,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"— dynamically loads pipe.md files and runs them via Claude (data injected as system message, pipe body as user prompt)","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"main.py","depth":26,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"— two new endpoints:","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"GET /api/pipes","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"and","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"POST /api/pipes/{pipe_id}/run","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"cli.py","depth":26,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"— a","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"pipe","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"command to run pipes from the terminal","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Let me build it:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Check browser_urls signature","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"cat /volume1/screenpipe/app/consumers/activity.py | grep \"def browser_urls\" -A 5","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"def browser_urls(\n for_date: date | None = None,\n app_name: str | None = None,\n ts_from: str | None = None,\n ts_to: str | None = None,\n limit: int = 30,","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Write","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"pipes.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"pipes.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"143 lines","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"\"\"\"Dynamic pipe loader and runner.\"\"\"\nimport os\nimport re\nfrom datetime import date\nfrom pathlib import Path\nfrom typing import Any\n\n\ndef _parse_frontmatter(text: str) -> tuple[dict, str]:\n if not text.startswith(\"---\"):\n return {}, text\n try:\n end = text.index(\"---\", 3)\n except ValueError:\n return {}, text\n fm_text = text[3:end].strip()\n body = text[end + 3:].strip()\n meta: dict = {}\n for line in fm_text.splitlines():\n if \":\" in line:\n k, _, v = line.partition(\":\")\n meta[k.strip()] = v.strip().strip('\"')\n return meta, body\n\n\ndef load_pipes(pipes_dir: Path) -> list[dict]:\n if not pipes_dir.exists():\n return []\n pipes = []\n for pipe_dir in sorted(pipes_dir.iterdir()):\n if not pipe_dir.is_dir() or pipe_dir.name.startswith(\".\"):\n continue\n pipe_md = pipe_dir / \"pipe.md\"\n if not pipe_md.exists():\n continue\n text = pipe_md.read_text(encoding=\"utf-8\")\n meta, body = _parse_frontmatter(text)\n if meta.get(\"enabled\", \"true\").lower() == \"false\":\n continue\n body = re.sub(r\"Read screenpipe skill first\\.?\\n?\", \"\", body).strip()\n pipes.append({\n \"id\": pipe_dir.name,\n \"title\": meta.get(\"title\", pipe_dir.name),\n \"description\": meta.get(\"description\", \"\"),\n \"icon\": meta.get(\"icon\", \"\"),\n \"schedule\": meta.get(\"schedule\", \"manual\"),\n \"featured\": meta.get(\"featured\", \"false\").lower() == \"true\",\n \"prompt\": body,\n })\n return pipes\n\n\ndef _build_system(d: date, stats: dict) -> str:\n from consumers.activity import app_time, browser_urls, ui_event_summary\n from consumers.ocr import deduplicated_text\n from consumers.audio import formatted_transcript\n\n apps = app_time(d)\n app_lines = \"\\n\".join(f\"- {a['app_name']}: {a['minutes']} min\" for a in apps[:20])\n\n urls = browser_urls(d, limit=20)\n url_lines = \"\\n\".join(f\"- {u['browser_url'][:100]} ({u['minutes']} min)\" for u in urls)\n\n ui_rows = ui_event_summary(d)\n ui_lines = \"\\n\".join(\n f\"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches\"\n for r in ui_rows[:15]\n )\n\n ocr_rows = deduplicated_text(d, chunk_minutes=5)\n ocr_lines = \"\\n\".join(\n f\"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}\"\n for r in ocr_rows[:100]\n )\n\n audio = formatted_transcript(d)\n if len(audio) > 3000:\n audio = audio[:3000]\n\n return f\"\"\"You are analyzing screenpipe data — recordings of a person's computer activity.\n\n## App usage (minutes per app):\n{app_lines or '(no app data)'}\n\n## Browser URLs visited:\n{url_lines or '(no browser data)'}\n\n## UI activity per app (clicks / keystrokes / app-switches):\n{ui_lines or '(no UI event data)'}\n\n## Screen content (sampled every 5 minutes):\n{ocr_lines or '(no screen data)'}\n\n## Audio / speech:\n{audio or '(no audio data)'}\n\nDate: {d}\nTotal frames recorded: {stats['total_frames']}\"\"\"\n\n\ndef run_pipe(\n pipe_id: str,\n for_date: date | None = None,\n api_key: str | None = None,\n pipes_dir: Path | None = None,\n) -> dict[str, Any]:\n import anthropic\n from consumers.activity import summary_stats\n\n d = for_date or date.today()\n key = api_key or os.environ.get(\"ANTHROPIC_API_KEY\", \"\")\n if not key:\n return {\"title\": \"Error\", \"content\": \"ANTHROPIC_API_KEY not set.\", \"date\": str(d)}\n\n _pipes_dir = pipes_dir or Path(os.environ.get(\"PIPES_DIR\", \"/data/pipes\"))\n all_pipes = {p[\"id\"]: p for p in load_pipes(_pipes_dir)}\n\n if pipe_id not in all_pipes:\n return {\"title\": \"Error\", \"content\": f\"Pipe not found: {pipe_id}\", \"date\": str(d)}\n\n pipe = all_pipes[pipe_id]\n stats = summary_stats(d)\n\n if stats[\"total_frames\"] == 0:\n return {\"title\": pipe[\"title\"], \"content\": f\"No screen data found for {d}.\", \"date\": str(d)}\n\n system = _build_system(d, stats)\n\n client = anthropic.Anthropic(api_key=key)\n message = client.messages.create(\n model=\"claude-haiku-4-5-20251001\",\n max_tokens=1024,\n system=system,\n messages=[{\"role\": \"user\", \"content\": pipe[\"prompt\"]}],\n )\n\n return {\n \"title\": pipe[\"title\"],\n \"content\": message.content[0].text,\n \"date\": str(d),\n \"stats\": stats,\n }","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Now add the API endpoints to","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"main.py","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":":","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Edit","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"main.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Added 1 line","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Edit","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"main.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Added 1 line","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Now add the pipe endpoints at the end of main.py, before the closing summary section:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Edit","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"main.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Added 14 lines","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Now add the CLI command to","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"cli.py","depth":23,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"cli.py","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":":","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Edit","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"cli.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"cli.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Added 40 lines","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Done. Here's how to run pipes:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXHeading","text":"How to run pipes","depth":22,"on_screen":false,"role_description":"heading"},{"role":"AXStaticText","text":"How to run pipes","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Via Docker (inside the running container):","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":23,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"docker exec -it screenpipe-app python cli.py pipe --list\ndocker exec -it screenpipe-app python cli.py pipe day-recap\ndocker exec -it screenpipe-app python cli.py pipe standup-update --date yesterday","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Via the API","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"(once the container is running on port 8766):","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":23,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"# List pipes\ncurl http://localhost:8766/api/pipes\n\n# Run a pipe\ncurl -X POST \"http://localhost:8766/api/pipes/day-recap/run\"\ncurl -X POST \"http://localhost:8766/api/pipes/standup-update/run?d=2026-04-25\"","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Rebuild and restart","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"to pick up the changes:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":23,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
3052796390275798323
|
-8691439186037733140
|
idle
|
accessibility
|
NULL
|
Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧ Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py
M
db.py
docker-compose.yml
Dockerfile
M
main.py
M
requirements.txt
M
data
logs
pipes
.gitignore
app_settings.json
archive.db
archive.db-bak
U
db.sqlite
db.sqlite-shm
db.sqlite-wal
screenpipe_sync_updated.sh
U
screenpipe_sync.sh
screenpipe.db
Outline Section
OUTLINE
OUTLINE
Timeline Section
TIMELINE
TIMELINE
app_settings.json, Editor Group 1
screenpipe_sync.sh, Editor Group 1
pipe.md, Editor Group 1
.env, Editor Group 1
[ENV_SECRET]
[ENV_SECRET]
Implement and run pipe l…, Editor Group 2
Problems (⇧⌘M)
PROBLEMS
Output (⇧⌘U)
OUTPUT
Debug Console (⇧⌘Y)
DEBUG CONSOLE
Terminal (⌃`)
TERMINAL
Ports - 1 forwarded port
PORTS
1
remote SSH: nas
SSH: nas
screenpipe (Git) - master*, Checkout Branch/Tag...
master*
screenpipe (Git) - Synchronize Changes
No Problems
0
0
Forwarded Ports: 8766
1
Notifications
Sign In
Sign In
Info: Setting up SSH Host nas: Setting up SSH tunnel
Implement and run pipe logic
Session history
New session
Message actions
main.py
main.py
lets implement logic with pipes. how can I run it?
Thinking
Thinking
Let me look at the current project structure to understand what's already in place.
Bash
List project files
IN
find /volume1/screenpipe -type f | head -50 && echo "---" && ls /volume1/screenpipe
Copy code to clipboard
OUT
/volume1/screenpipe/.DS_Store
/volume1/screenpipe/screenpipe.db
/volume1/screenpipe/screenpipe_sync.sh
/volume1/screenpipe/app_settings.json
/volume1/screenpipe/.gitignore
/volume1/screenpipe/archive.db
/volume1/screenpipe/db.sqlite
/volume1/screenpipe/db.sqlite-wal
/volume1/screenpipe/db.sqlite-shm
/volume1/screenpipe/#recycle/desktop.ini
/volume1/screenpipe/#recycle/db.sqlite
/volume1/screenpipe/#recycle/Copy #1 of db.sqlite
/volume1/screenpipe/#recycle/.DS_Store
/volume1/screenpipe/#recycle/Copy #2 of db.sqlite
/volume1/screenpipe/#recycle/archive.db
/volume1/screenpipe/#recycle/Copy #1 of archive.db
/volume1/screenpipe/#recycle/Copy #2 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of archive.db
/volume1/screenpipe/#recycle/Copy #4 of archive.db
/volume1/screenpipe/#recycle/Copy #5 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of db.sqlite
/volume1/screenpipe/#recycle/Copy #4 of db.sqlite
/volume1/screenpipe/#recycle/Copy #6 of archive.db
/volume1/screenpipe/#recycle/test.txt
/volume1/screenpipe/#recycle/Copy #7 of archive.db
/volume1/screenpipe/#recycle/Copy #8 of archive.db
/volume1/screenpipe/#recycle/archive.db-journal
/volume1/screenpipe/#recycle/Copy #1 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #2 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #3 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #4 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #6 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #7 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of db.sqlite
/volume1/screenpipe/pipes/.DS_Store
/volume1/screenpipe/app/.env
/volume1/screenpipe/app/cli.py
/volume1/screenpipe/app/.DS_Store
/volume1/screenpipe/app/db.py
/volume1/screenpipe/app/docker-compose.yml
/volume1/screenpipe/app/main.py
/volume1/screenpipe/app/requirements.txt
/volume1/screenpipe/app/Dockerfile
/volume1/screenpipe/data/.DS_Store
/volume1/screenpipe/.git/description
/volume1/screenpipe/.git/HEAD
/volume1/screenpipe/.git/index
/volume1/screenpipe/.git/COMMIT_EDITMSG
/volume1/screenpipe/#recycle/data/.DS_Store
---
app
app_settings.json
archive.db
data
db.sqlite
db.sqlite-shm
db.sqlite-wal
pipes
#recycle
screenpipe.db
screenpipe_sync.sh
Read
main.py
main.py
Bash
Check pipes directory and docker-compose
IN
ls /volume1/screenpipe/pipes/ && ls /volume1/screenpipe/app/ && cat /volume1/screenpipe/app/docker-compose.yml
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
cli.py
consumers
db.py
docker-compose.yml
Dockerfile
main.py
__pycache__
requirements.txt
static
services:
screenpipe-app:
build: .
container_name: screenpipe-app
restart: unless-stopped
ports:
- "8766:8000"
volumes:
- /volume1/screenpipe:/data
env_file:
- .env
environment:
TZ: Europe/Sofia
DB_PATH: /data/db.sqlite
sqlite-web-archive:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-archive
restart: unless-stopped
ports:
- "8767:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/archive.db"]
sqlite-web-live:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-live
restart: unless-stopped
ports:
- "8768:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/db.sqlite"]
Read
requirements.txt
requirements.txt
Bash
Inspect a pipe directory
IN
ls /volume1/screenpipe/pipes/day-recap/ && cat /volume1/screenpipe/pipes/day-recap/pipe.json 2>/dev/null || ls /volume1/screenpipe/pipes/day-recap/
Copy code to clipboard
OUT
pipe.md
pipe.md
Read
cli.py
cli.py
Bash
List all pipes and their contents
IN
ls /volume1/screenpipe/pipes/ && for d in /volume1/screenpipe/pipes/*/; do echo "=== $d ==="; ls "$d"; done
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
=== /volume1/screenpipe/pipes/ai-habits/ ===
pipe.md
=== /volume1/screenpipe/pipes/day-recap/ ===
pipe.md
=== /volume1/screenpipe/pipes/meeting-summary/ ===
pipe.md
=== /volume1/screenpipe/pipes/standup-update/ ===
pipe.md
=== /volume1/screenpipe/pipes/time-breakdown/ ===
pipe.md
=== /volume1/screenpipe/pipes/video-export/ ===
pipe.md
Bash
Read pipe markdown files
IN
cat /volume1/screenpipe/pipes/day-recap/pipe.md && echo "===" && cat /volume1/screenpipe/pipes/meeting-summary/pipe.md 2>/dev/null | head -50
Copy code to clipboard
OUT
---
schedule: manual
enabled: true
template: true
title: Day Recap
description: "Today's accomplishments, key moments, and unfinished work"
icon: "📋"
featured: true
---
Analyze my screen and audio recordings from today (last 16 hours only).
Read screenpipe skill first.
Use this exact format:
## Summary
One sentence: what I mainly did today.
## Accomplishments
- Top 3 things I finished, with timestamps (e.g. "2:30 PM")
- Name specific apps, files, or projects
## Key Moments
- Important things I saw, said, or heard — with timestamps
## Unfinished Work
- What I should continue tomorrow — name the app/file/task
## Patterns
- Apps I used most, topics that came up repeatedly
Only report what you can verify from the data. End with: "**Next step:** [most important thing to continue]"
===
---
schedule: manual
enabled: true
template: true
title: Meeting Summary
description: "Summarize meeting transcript with key takeaways and action items"
icon: "🤝"
featured: false
---
Summarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.
Read screenpipe skill first.
Use this exact format:
## Meeting Summary
One sentence: what this meeting was about.
## Key Takeaways
- Top 3-5 important points discussed
- Include who said what when relevant
## Action Items
- [ ] Task — assigned to whom, deadline if mentioned
- [ ] Task — assigned to whom
## Decisions Made
- List any decisions or agreements reached
## Open Questions
- Anything unresolved or needing follow-up
Keep it concise and actionable.
Thinking
Thinking
Bash
Read summary consumer
IN
ls /volume1/screenpipe/app/consumers/ && cat /volume1/screenpipe/app/consumers/summary.py
Copy code to clipboard
OUT
activity.py
audio.py
elements.py
__init__.py
interactions.py
ocr.py
__pycache__
report.py
summary.py
"""AI summary generator using Claude."""
import os
from datetime import date
from typing import Any
from consumers.activity import app_time, summary_stats, browser_urls, ui_event_summary
from consumers.ocr import deduplicated_text
from consumers.audio import formatted_transcript
SUMMARY_TYPES = {
"day_recap": {
"title": "Day Recap",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
## Audio/speech:
{audio}
Write a concise day recap using EXACTLY this format:
## Summary
One sentence: what I mainly worked on today.
## Accomplishments
- Top 3 things I finished, with approximate times
- Name specific apps, files, or projects
## Key Moments
- Important things seen or heard, with timestamps
## Unfinished Work
- What to continue tomorrow
## Patterns
- Apps used most, topics that came up repeatedly
Only report what you can verify from the data. End with:
**Next step:** [most important thing to continue]""",
},
"standup": {
"title": "Standup Update",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
## Audio/speech:
{audio}
Write a brief standup update:
**Yesterday:** What I worked on (2-3 bullets)
**Today:** What I plan to continue (1-2 bullets)
**Blockers:** Any issues observed (or "None")
Keep it under 150 words. Only report what's verifiable from the data.""",
},
"focus_time": {
"title": "Focus & Distraction Analysis",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
Analyze focus vs distraction patterns:
## Deep Work Periods
- When and how long were sustained focus sessions?
- What was being worked on?
## Distractions
- Which apps/sites were used recreationally?
- How much time was lost to context switching?
## Recommendations
- 2-3 concrete suggestions to improve focus tomorrow
Be specific with times and app names.""",
},
}
def _build_context(for_date: date) -> dict[str, str]:
apps = app_time(for_date)
app_lines = "\n".join(f"- {a['app_name']}: {a['minutes']} min" for a in apps[:20])
urls = browser_urls(for_date, limit=20)
url_lines = "\n".join(
f"- {u['browser_url'][:100]} ({u['minutes']} min)" for u in urls
)
ui_rows = ui_event_summary(for_date)
ui_lines = "\n".join(
f"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches"
for r in ui_rows[:15]
)
ocr_rows = deduplicated_text(for_date, chunk_minutes=5)
ocr_lines = "\n".join(
f"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}"
for r in ocr_rows[:100]
)
audio = formatted_transcript(for_date)
return {
"app_time": app_lines or "(no app data)",
"browser_urls": url_lines or "(no browser data)",
"ui_events": ui_lines or "(no UI event data)",
"ocr_text": ocr_lines or "(no screen data)",
"audio": audio[:3000] if len(audio) > 3000 else audio,
}
def generate(
summary_type: str = "day_recap",
for_date: date | None = None,
api_key: str | None = None,
) -> dict[str, Any]:
"""Generate an AI summary. Returns dict with 'title', 'content', 'date'."""
import anthropic
d = for_date or date.today()
key = api_key or os.environ.get("ANTHROPIC_API_KEY", "")
if not key:
return {
"title": "Error",
"content": "ANTHROPIC_API_KEY not set. Add it to your .env file.",
"date": str(d),
}
spec = SUMMARY_TYPES.get(summary_type)
if not spec:
return {"title": "Error", "content": f"Unknown summary type: {summary_type}", "date": str(d)}
stats = summary_stats(d)
if stats["total_frames"] == 0:
return {
"title": spec["title"],
"content": f"No screen data found for {d}.",
"date": str(d),
}
ctx = _build_context(d)
prompt = spec["prompt"].format(**ctx)
client = anthropic.Anthropic(api_key=key)
message = client.messages.create(
model="claude-haiku-4-5-20251001",
max_tokens=1024,
messages=[{"role": "user", "content": prompt}],
)
return {
"title": spec["title"],
"content": message.content[0].text,
"date": str(d),
"stats": stats,
}
Thinking
Thinking
Bash
Read all pipe.md files
IN
for f in /volume1/screenpipe/pipes/*/pipe.md; do echo "=== $f ==="; cat "$f"; echo; done
Copy code to clipboard
OUT
=== /volume1/screenpipe/pipes/ai-habits/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: AI Habits
description: "How you use AI tools — patterns and insights"
icon: "🤖"
featured: true
---
Search my recordings from the last 24 hours for AI tool usage. Use app_name filter for each tool separately: ChatGPT, Claude, Copilot, Cursor, Gemini, Perplexity. Use limit=5 per search, max 6 searches total.
Read screenpipe skill first.
Use this exact format:
## AI Tools Used
- List each tool with approximate time spent (e.g. "Claude: ~45min")
## What I Used Them For
- For each tool: coding, writing, research, or brainstorming
## Usage Patterns
- Do I switch between tools? Use them in bursts or steadily?
## Effectiveness
- Which tool appeared alongside completed work vs. abandoned attempts
If no AI usage is found, say so clearly. End with: "**Tip:** [one suggestion to use AI tools more effectively]"
=== /volume1/screenpipe/pipes/day-recap/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Day Recap
description: "Today's accomplishments, key moments, and unfinished work"
icon: "📋"
featured: true
---
Analyze my screen and audio recordings from today (last 16 hours only).
Read screenpipe skill first.
Use this exact format:
## Summary
One sentence: what I mainly did today.
## Accomplishments
- Top 3 things I finished, with timestamps (e.g. "2:30 PM")
- Name specific apps, files, or projects
## Key Moments
- Important things I saw, said, or heard — with timestamps
## Unfinished Work
- What I should continue tomorrow — name the app/file/task
## Patterns
- Apps I used most, topics that came up repeatedly
Only report what you can verify from the data. End with: "**Next step:** [most important thing to continue]"
=== /volume1/screenpipe/pipes/meeting-summary/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Meeting Summary
description: "Summarize meeting transcript with key takeaways and action items"
icon: "🤝"
featured: false
---
Summarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.
Read screenpipe skill first.
Use this exact format:
## Meeting Summary
One sentence: what this meeting was about.
## Key Takeaways
- Top 3-5 important points discussed
- Include who said what when relevant
## Action Items
- [ ] Task — assigned to whom, deadline if mentioned
- [ ] Task — assigned to whom
## Decisions Made
- List any decisions or agreements reached
## Open Questions
- Anything unresolved or needing follow-up
Keep it concise and actionable.
=== /volume1/screenpipe/pipes/standup-update/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Standup Update
description: "What you did, what's next, and any blockers"
icon: "🏢"
featured: true
---
Based on my recordings from the last 24 hours, generate a standup update. Use limit=10 per search, max 3 searches total.
Read screenpipe skill first.
Use this exact format:
## Yesterday
- What I worked on (name specific projects, files, tools, PRs)
## Today
- What I will work on next (based on unfinished tasks and recent activity)
## Blockers
- Issues I hit — errors, slow builds, waiting on someone
- If no blockers, write "None"
Keep it under 150 words. Copy-paste ready for a team standup.
=== /volume1/screenpipe/pipes/time-breakdown/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Time Breakdown
description: "Where your time went — by app, project, and category"
icon: "⏱"
featured: false
---
Analyze my app usage from today (last 12 hours). Use limit=10 per search, max 4 searches. Prefer /raw_sql with COUNT/GROUP BY queries.
Read screenpipe skill first.
Use this exact format with durations and percentages:
## By Application
- List each app with duration and percentage, sorted by time (e.g. "VS Code: 2h 15min (28%)")
## By Category
- Group into: coding, meetings, browsing, writing, communication, other
- Show hours and percentage per category
## By Project
- Group related activities by project/topic. Name specific repos or tasks.
## Productivity Score
- Calculate: focused_work_hours / total_hours as a percentage
- Focused = coding + writing. Unfocused = browsing + switching.
End with: "**Suggestion:** [one specific change to improve tomorrow's productivity]"
=== /volume1/screenpipe/pipes/video-export/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Export Video Clip
description: "Create a video of your recent screen activity"
icon: "🎬"
featured: false
---
Export a video of my screen activity from the last 5 minutes.
Read screenpipe skill first.
Use the POST /frames/export endpoint with the time range and fps=1.0. Then show me the exported video file path as an inline code block so I can watch it.
If the export is large, suggest a lower fps or shorter time range.
Thinking
Thinking
Now I have a clear picture. The pipes are markdown prompt templates in
/volume1/screenpipe/pipes/
, but there's no code to actually load and run them —
consumers/summary.py
has its own hardcoded prompts instead.
Here's what I'll implement:
consumers/pipes.py
— dynamically loads pipe.md files and runs them via Claude (data injected as system message, pipe body as user prompt)
main.py
— two new endpoints:
GET /api/pipes
and
POST /api/pipes/{pipe_id}/run
cli.py
— a
pipe
command to run pipes from the terminal
Let me build it:
Bash
Check browser_urls signature
IN
cat /volume1/screenpipe/app/consumers/activity.py | grep "def browser_urls" -A 5
Copy code to clipboard
OUT
def browser_urls(
for_date: date | None = None,
app_name: str | None = None,
ts_from: str | None = None,
ts_to: str | None = None,
limit: int = 30,
Write
pipes.py
pipes.py
143 lines
"""Dynamic pipe loader and runner."""
import os
import re
from datetime import date
from pathlib import Path
from typing import Any
def _parse_frontmatter(text: str) -> tuple[dict, str]:
if not text.startswith("---"):
return {}, text
try:
end = text.index("---", 3)
except ValueError:
return {}, text
fm_text = text[3:end].strip()
body = text[end + 3:].strip()
meta: dict = {}
for line in fm_text.splitlines():
if ":" in line:
k, _, v = line.partition(":")
meta[k.strip()] = v.strip().strip('"')
return meta, body
def load_pipes(pipes_dir: Path) -> list[dict]:
if not pipes_dir.exists():
return []
pipes = []
for pipe_dir in sorted(pipes_dir.iterdir()):
if not pipe_dir.is_dir() or pipe_dir.name.startswith("."):
continue
pipe_md = pipe_dir / "pipe.md"
if not pipe_md.exists():
continue
text = pipe_md.read_text(encoding="utf-8")
meta, body = _parse_frontmatter(text)
if meta.get("enabled", "true").lower() == "false":
continue
body = re.sub(r"Read screenpipe skill first\.?\n?", "", body).strip()
pipes.append({
"id": pipe_dir.name,
"title": meta.get("title", pipe_dir.name),
"description": meta.get("description", ""),
"icon": meta.get("icon", ""),
"schedule": meta.get("schedule", "manual"),
"featured": meta.get("featured", "false").lower() == "true",
"prompt": body,
})
return pipes
def _build_system(d: date, stats: dict) -> str:
from consumers.activity import app_time, browser_urls, ui_event_summary
from consumers.ocr import deduplicated_text
from consumers.audio import formatted_transcript
apps = app_time(d)
app_lines = "\n".join(f"- {a['app_name']}: {a['minutes']} min" for a in apps[:20])
urls = browser_urls(d, limit=20)
url_lines = "\n".join(f"- {u['browser_url'][:100]} ({u['minutes']} min)" for u in urls)
ui_rows = ui_event_summary(d)
ui_lines = "\n".join(
f"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches"
for r in ui_rows[:15]
)
ocr_rows = deduplicated_text(d, chunk_minutes=5)
ocr_lines = "\n".join(
f"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}"
for r in ocr_rows[:100]
)
audio = formatted_transcript(d)
if len(audio) > 3000:
audio = audio[:3000]
return f"""You are analyzing screenpipe data — recordings of a person's computer activity.
## App usage (minutes per app):
{app_lines or '(no app data)'}
## Browser URLs visited:
{url_lines or '(no browser data)'}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_lines or '(no UI event data)'}
## Screen content (sampled every 5 minutes):
{ocr_lines or '(no screen data)'}
## Audio / speech:
{audio or '(no audio data)'}
Date: {d}
Total frames recorded: {stats['total_frames']}"""
def run_pipe(
pipe_id: str,
for_date: date | None = None,
api_key: str | None = None,
pipes_dir: Path | None = None,
) -> dict[str, Any]:
import anthropic
from consumers.activity import summary_stats
d = for_date or date.today()
key = api_key or os.environ.get("ANTHROPIC_API_KEY", "")
if not key:
return {"title": "Error", "content": "ANTHROPIC_API_KEY not set.", "date": str(d)}
_pipes_dir = pipes_dir or Path(os.environ.get("PIPES_DIR", "/data/pipes"))
all_pipes = {p["id"]: p for p in load_pipes(_pipes_dir)}
if pipe_id not in all_pipes:
return {"title": "Error", "content": f"Pipe not found: {pipe_id}", "date": str(d)}
pipe = all_pipes[pipe_id]
stats = summary_stats(d)
if stats["total_frames"] == 0:
return {"title": pipe["title"], "content": f"No screen data found for {d}.", "date": str(d)}
system = _build_system(d, stats)
client = anthropic.Anthropic(api_key=key)
message = client.messages.create(
model="claude-haiku-4-5-20251001",
max_tokens=1024,
system=system,
messages=[{"role": "user", "content": pipe["prompt"]}],
)
return {
"title": pipe["title"],
"content": message.content[0].text,
"date": str(d),
"stats": stats,
}
Now add the API endpoints to
main.py
:
Edit
main.py
main.py
Added 1 line
Edit
main.py
main.py
Added 1 line
Now add the pipe endpoints at the end of main.py, before the closing summary section:
Edit
main.py
main.py
Added 14 lines
Now add the CLI command to
cli.py
cli.py
:
Edit
cli.py
cli.py
Added 40 lines
Done. Here's how to run pipes:
How to run pipes
How to run pipes
Via Docker (inside the running container):
Copy code to clipboard
docker exec -it screenpipe-app python cli.py pipe --list
docker exec -it screenpipe-app python cli.py pipe day-recap
docker exec -it screenpipe-app python cli.py pipe standup-update --date yesterday
Via the API
(once the container is running on port 8766):
Copy code to clipboard
# List pipes
curl http://localhost:8766/api/pipes
# Run a pipe
curl -X POST "http://localhost:8766/api/pipes/day-recap/run"
curl -X POST "http://localhost:8766/api/pipes/standup-update/run?d=2026-04-25"
Rebuild and restart
to pick up the changes:
Copy code to clipboard...
|
21070
|
NULL
|
NULL
|
NULL
|
|
21073
|
921
|
7
|
2026-05-11T17:09:37.404118+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-11/1778 /Users/lukas/.screenpipe/data/data/2026-05-11/1778519377404_m2.jpg...
|
Code
|
Implement and run pipe l… — screenpipe [SSH: nas]
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧ Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py
M
db.py
docker-compose.yml
Dockerfile
M
main.py
M
requirements.txt
M
data
logs
pipes
.gitignore
app_settings.json
archive.db
archive.db-bak
U
db.sqlite
db.sqlite-shm
db.sqlite-wal
screenpipe_sync_updated.sh
U
screenpipe_sync.sh
screenpipe.db
Outline Section
OUTLINE
OUTLINE
Timeline Section
TIMELINE
TIMELINE
app_settings.json, Editor Group 1
screenpipe_sync.sh, Editor Group 1
pipe.md, Editor Group 1
.env, Editor Group 1
[ENV_SECRET]
[ENV_SECRET]
Implement and run pipe l…, Editor Group 2
Problems (⇧⌘M)
PROBLEMS
Output (⇧⌘U)
OUTPUT
Debug Console (⇧⌘Y)
DEBUG CONSOLE
Terminal (⌃`)
TERMINAL
Ports - 1 forwarded port
PORTS
1
remote SSH: nas
SSH: nas
screenpipe (Git) - master*, Checkout Branch/Tag...
master*
screenpipe (Git) - Synchronize Changes
No Problems
0
0
Forwarded Ports: 8766
1
Notifications
Sign In
Sign In
Info: Setting up SSH Host nas: Setting up SSH tunnel
Implement and run pipe logic
Session history
New session
Message actions
main.py
main.py
lets implement logic with pipes. how can I run it?
Thinking
Thinking
Let me look at the current project structure to understand what's already in place.
Bash
List project files
IN
find /volume1/screenpipe -type f | head -50 && echo "---" && ls /volume1/screenpipe
Copy code to clipboard
OUT
/volume1/screenpipe/.DS_Store
/volume1/screenpipe/screenpipe.db
/volume1/screenpipe/screenpipe_sync.sh
/volume1/screenpipe/app_settings.json
/volume1/screenpipe/.gitignore
/volume1/screenpipe/archive.db
/volume1/screenpipe/db.sqlite
/volume1/screenpipe/db.sqlite-wal
/volume1/screenpipe/db.sqlite-shm
/volume1/screenpipe/#recycle/desktop.ini
/volume1/screenpipe/#recycle/db.sqlite
/volume1/screenpipe/#recycle/Copy #1 of db.sqlite
/volume1/screenpipe/#recycle/.DS_Store
/volume1/screenpipe/#recycle/Copy #2 of db.sqlite
/volume1/screenpipe/#recycle/archive.db
/volume1/screenpipe/#recycle/Copy #1 of archive.db
/volume1/screenpipe/#recycle/Copy #2 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of archive.db
/volume1/screenpipe/#recycle/Copy #4 of archive.db
/volume1/screenpipe/#recycle/Copy #5 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of db.sqlite
/volume1/screenpipe/#recycle/Copy #4 of db.sqlite
/volume1/screenpipe/#recycle/Copy #6 of archive.db
/volume1/screenpipe/#recycle/test.txt
/volume1/screenpipe/#recycle/Copy #7 of archive.db
/volume1/screenpipe/#recycle/Copy #8 of archive.db
/volume1/screenpipe/#recycle/archive.db-journal
/volume1/screenpipe/#recycle/Copy #1 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #2 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #3 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #4 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #6 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #7 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of db.sqlite
/volume1/screenpipe/pipes/.DS_Store
/volume1/screenpipe/app/.env
/volume1/screenpipe/app/cli.py
/volume1/screenpipe/app/.DS_Store
/volume1/screenpipe/app/db.py
/volume1/screenpipe/app/docker-compose.yml
/volume1/screenpipe/app/main.py
/volume1/screenpipe/app/requirements.txt
/volume1/screenpipe/app/Dockerfile
/volume1/screenpipe/data/.DS_Store
/volume1/screenpipe/.git/description
/volume1/screenpipe/.git/HEAD
/volume1/screenpipe/.git/index
/volume1/screenpipe/.git/COMMIT_EDITMSG
/volume1/screenpipe/#recycle/data/.DS_Store
---
app
app_settings.json
archive.db
data
db.sqlite
db.sqlite-shm
db.sqlite-wal
pipes
#recycle
screenpipe.db
screenpipe_sync.sh
Read
main.py
main.py
Bash
Check pipes directory and docker-compose
IN
ls /volume1/screenpipe/pipes/ && ls /volume1/screenpipe/app/ && cat /volume1/screenpipe/app/docker-compose.yml
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
cli.py
consumers
db.py
docker-compose.yml
Dockerfile
main.py
__pycache__
requirements.txt
static
services:
screenpipe-app:
build: .
container_name: screenpipe-app
restart: unless-stopped
ports:
- "8766:8000"
volumes:
- /volume1/screenpipe:/data
env_file:
- .env
environment:
TZ: Europe/Sofia
DB_PATH: /data/db.sqlite
sqlite-web-archive:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-archive
restart: unless-stopped
ports:
- "8767:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/archive.db"]
sqlite-web-live:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-live
restart: unless-stopped
ports:
- "8768:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/db.sqlite"]
Read
requirements.txt
requirements.txt
Bash
Inspect a pipe directory
IN
ls /volume1/screenpipe/pipes/day-recap/ && cat /volume1/screenpipe/pipes/day-recap/pipe.json 2>/dev/null || ls /volume1/screenpipe/pipes/day-recap/
Copy code to clipboard
OUT
pipe.md
pipe.md
Read
cli.py
cli.py
Bash
List all pipes and their contents
IN
ls /volume1/screenpipe/pipes/ && for d in /volume1/screenpipe/pipes/*/; do echo "=== $d ==="; ls "$d"; done
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
=== /volume1/screenpipe/pipes/ai-habits/ ===
pipe.md
=== /volume1/screenpipe/pipes/day-recap/ ===
pipe.md
=== /volume1/screenpipe/pipes/meeting-summary/ ===
pipe.md
=== /volume1/screenpipe/pipes/standup-update/ ===
pipe.md
=== /volume1/screenpipe/pipes/time-breakdown/ ===
pipe.md
=== /volume1/screenpipe/pipes/video-export/ ===
pipe.md
Bash
Read pipe markdown files
IN
cat /volume1/screenpipe/pipes/day-recap/pipe.md && echo "===" && cat /volume1/screenpipe/pipes/meeting-summary/pipe.md 2>/dev/null | head -50
Copy code to clipboard
OUT
---
schedule: manual
enabled: true
template: true
title: Day Recap
description: "Today's accomplishments, key moments, and unfinished work"
icon: "📋"
featured: true
---
Analyze my screen and audio recordings from today (last 16 hours only).
Read screenpipe skill first.
Use this exact format:
## Summary
One sentence: what I mainly did today.
## Accomplishments
- Top 3 things I finished, with timestamps (e.g. "2:30 PM")
- Name specific apps, files, or projects
## Key Moments
- Important things I saw, said, or heard — with timestamps
## Unfinished Work
- What I should continue tomorrow — name the app/file/task
## Patterns
- Apps I used most, topics that came up repeatedly
Only report what you can verify from the data. End with: "**Next step:** [most important thing to continue]"
===
---
schedule: manual
enabled: true
template: true
title: Meeting Summary
description: "Summarize meeting transcript with key takeaways and action items"
icon: "🤝"
featured: false
---
Summarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.
Read screenpipe skill first.
Use this exact format:
## Meeting Summary
One sentence: what this meeting was about.
## Key Takeaways
- Top 3-5 important points discussed
- Include who said what when relevant
## Action Items
- [ ] Task — assigned to whom, deadline if mentioned
- [ ] Task — assigned to whom
## Decisions Made
- List any decisions or agreements reached
## Open Questions
- Anything unresolved or needing follow-up
Keep it concise and actionable.
Thinking
Thinking
Bash
Read summary consumer
IN
ls /volume1/screenpipe/app/consumers/ && cat /volume1/screenpipe/app/consumers/summary.py
Copy code to clipboard
OUT
activity.py
audio.py
elements.py
__init__.py
interactions.py
ocr.py
__pycache__
report.py
summary.py
"""AI summary generator using Claude."""
import os
from datetime import date
from typing import Any
from consumers.activity import app_time, summary_stats, browser_urls, ui_event_summary
from consumers.ocr import deduplicated_text
from consumers.audio import formatted_transcript
SUMMARY_TYPES = {
"day_recap": {
"title": "Day Recap",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
## Audio/speech:
{audio}
Write a concise day recap using EXACTLY this format:
## Summary
One sentence: what I mainly worked on today.
## Accomplishments
- Top 3 things I finished, with approximate times
- Name specific apps, files, or projects
## Key Moments
- Important things seen or heard, with timestamps
## Unfinished Work
- What to continue tomorrow
## Patterns
- Apps used most, topics that came up repeatedly
Only report what you can verify from the data. End with:
**Next step:** [most important thing to continue]""",
},
"standup": {
"title": "Standup Update",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
## Audio/speech:
{audio}
Write a brief standup update:
**Yesterday:** What I worked on (2-3 bullets)
**Today:** What I plan to continue (1-2 bullets)
**Blockers:** Any issues observed (or "None")
Keep it under 150 words. Only report what's verifiable from the data.""",
},
"focus_time": {
"title": "Focus & Distraction Analysis",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
Analyze focus vs distraction patterns:
## Deep Work Periods
- When and how long were sustained focus sessions?
- What was being worked on?
## Distractions
- Which apps/sites were used recreationally?
- How much time was lost to context switching?
## Recommendations
- 2-3 concrete suggestions to improve focus tomorrow
Be specific with times and app names.""",
},
}
def _build_context(for_date: date) -> dict[str, str]:
apps = app_time(for_date)
app_lines = "\n".join(f"- {a['app_name']}: {a['minutes']} min" for a in apps[:20])
urls = browser_urls(for_date, limit=20)
url_lines = "\n".join(
f"- {u['browser_url'][:100]} ({u['minutes']} min)" for u in urls
)
ui_rows = ui_event_summary(for_date)
ui_lines = "\n".join(
f"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches"
for r in ui_rows[:15]
)
ocr_rows = deduplicated_text(for_date, chunk_minutes=5)
ocr_lines = "\n".join(
f"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}"
for r in ocr_rows[:100]
)
audio = formatted_transcript(for_date)
return {
"app_time": app_lines or "(no app data)",
"browser_urls": url_lines or "(no browser data)",
"ui_events": ui_lines or "(no UI event data)",
"ocr_text": ocr_lines or "(no screen data)",
"audio": audio[:3000] if len(audio) > 3000 else audio,
}
def generate(
summary_type: str = "day_recap",
for_date: date | None = None,
api_key: str | None = None,
) -> dict[str, Any]:
"""Generate an AI summary. Returns dict with 'title', 'content', 'date'."""
import anthropic
d = for_date or date.today()
key = api_key or os.environ.get("ANTHROPIC_API_KEY", "")
if not key:
return {
"title": "Error",
"content": "ANTHROPIC_API_KEY not set. Add it to your .env file.",
"date": str(d),
}
spec = SUMMARY_TYPES.get(summary_type)
if not spec:
return {"title": "Error", "content": f"Unknown summary type: {summary_type}", "date": str(d)}
stats = summary_stats(d)
if stats["total_frames"] == 0:
return {
"title": spec["title"],
"content": f"No screen data found for {d}.",
"date": str(d),
}
ctx = _build_context(d)
prompt = spec["prompt"].format(**ctx)
client = anthropic.Anthropic(api_key=key)
message = client.messages.create(
model="claude-haiku-4-5-20251001",
max_tokens=1024,
messages=[{"role": "user", "content": prompt}],
)
return {
"title": spec["title"],
"content": message.content[0].text,
"date": str(d),
"stats": stats,
}
Thinking
Thinking
Bash
Read all pipe.md files
IN
for f in /volume1/screenpipe/pipes/*/pipe.md; do echo "=== $f ==="; cat "$f"; echo; done
Copy code to clipboard
OUT
=== /volume1/screenpipe/pipes/ai-habits/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: AI Habits
description: "How you use AI tools — patterns and insights"
icon: "🤖"
featured: true
---
Search my recordings from the last 24 hours for AI tool usage. Use app_name filter for each tool separately: ChatGPT, Claude, Copilot, Cursor, Gemini, Perplexity. Use limit=5 per search, max 6 searches total.
Read screenpipe skill first.
Use this exact format:
## AI Tools Used
- List each tool with approximate time spent (e.g. "Claude: ~45min")
## What I Used Them For
- For each tool: coding, writing, research, or brainstorming
## Usage Patterns
- Do I switch between tools? Use them in bursts or steadily?
## Effectiveness
- Which tool appeared alongside completed work vs. abandoned attempts
If no AI usage is found, say so clearly. End with: "**Tip:** [one suggestion to use AI tools more effectively]"
=== /volume1/screenpipe/pipes/day-recap/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Day Recap
description: "Today's accomplishments, key moments, and unfinished work"
icon: "📋"
featured: true
---
Analyze my screen and audio recordings from today (last 16 hours only).
Read screenpipe skill first.
Use this exact format:
## Summary
One sentence: what I mainly did today.
## Accomplishments
- Top 3 things I finished, with timestamps (e.g. "2:30 PM")
- Name specific apps, files, or projects
## Key Moments
- Important things I saw, said, or heard — with timestamps
## Unfinished Work
- What I should continue tomorrow — name the app/file/task
## Patterns
- Apps I used most, topics that came up repeatedly
Only report what you can verify from the data. End with: "**Next step:** [most important thing to continue]"
=== /volume1/screenpipe/pipes/meeting-summary/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Meeting Summary
description: "Summarize meeting transcript with key takeaways and action items"
icon: "🤝"
featured: false
---
Summarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.
Read screenpipe skill first.
Use this exact format:
## Meeting Summary
One sentence: what this meeting was about.
## Key Takeaways
- Top 3-5 important points discussed
- Include who said what when relevant
## Action Items
- [ ] Task — assigned to whom, deadline if mentioned
- [ ] Task — assigned to whom
## Decisions Made
- List any decisions or agreements reached
## Open Questions
- Anything unresolved or needing follow-up
Keep it concise and actionable.
=== /volume1/screenpipe/pipes/standup-update/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Standup Update
description: "What you did, what's next, and any blockers"
icon: "🏢"
featured: true
---
Based on my recordings from the last 24 hours, generate a standup update. Use limit=10 per search, max 3 searches total.
Read screenpipe skill first.
Use this exact format:
## Yesterday
- What I worked on (name specific projects, files, tools, PRs)
## Today
- What I will work on next (based on unfinished tasks and recent activity)
## Blockers
- Issues I hit — errors, slow builds, waiting on someone
- If no blockers, write "None"
Keep it under 150 words. Copy-paste ready for a team standup.
=== /volume1/screenpipe/pipes/time-breakdown/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Time Breakdown
description: "Where your time went — by app, project, and category"
icon: "⏱"
featured: false
---
Analyze my app usage from today (last 12 hours). Use limit=10 per search, max 4 searches. Prefer /raw_sql with COUNT/GROUP BY queries.
Read screenpipe skill first.
Use this exact format with durations and percentages:
## By Application
- List each app with duration and percentage, sorted by time (e.g. "VS Code: 2h 15min (28%)")
## By Category
- Group into: coding, meetings, browsing, writing, communication, other
- Show hours and percentage per category
## By Project
- Group related activities by project/topic. Name specific repos or tasks.
## Productivity Score
- Calculate: focused_work_hours / total_hours as a percentage
- Focused = coding + writing. Unfocused = browsing + switching.
End with: "**Suggestion:** [one specific change to improve tomorrow's productivity]"
=== /volume1/screenpipe/pipes/video-export/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Export Video Clip
description: "Create a video of your recent screen activity"
icon: "🎬"
featured: false
---
Export a video of my screen activity from the last 5 minutes.
Read screenpipe skill first.
Use the POST /frames/export endpoint with the time range and fps=1.0. Then show me the exported video file path as an inline code block so I can watch it.
If the export is large, suggest a lower fps or shorter time range.
Thinking
Thinking
Now I have a clear picture. The pipes are markdown prompt templates in
/volume1/screenpipe/pipes/
, but there's no code to actually load and run them —
consumers/summary.py
has its own hardcoded prompts instead.
Here's what I'll implement:
consumers/pipes.py
— dynamically loads pipe.md files and runs them via Claude (data injected as system message, pipe body as user prompt)
main.py
— two new endpoints:
GET /api/pipes
and
POST /api/pipes/{pipe_id}/run
cli.py
— a
pipe
command to run pipes from the terminal
Let me build it:
Bash
Check browser_urls signature
IN
cat /volume1/screenpipe/app/consumers/activity.py | grep "def browser_urls" -A 5
Copy code to clipboard
OUT
def browser_urls(
for_date: date | None = None,
app_name: str | None = None,
ts_from: str | None = None,
ts_to: str | None = None,
limit: int = 30,
Write
pipes.py
pipes.py
143 lines
"""Dynamic pipe loader and runner."""
import os
import re
from datetime import date
from pathlib import Path
from typing import Any
def _parse_frontmatter(text: str) -> tuple[dict, str]:
if not text.startswith("---"):
return {}, text
try:
end = text.index("---", 3)
except ValueError:
return {}, text
fm_text = text[3:end].strip()
body = text[end + 3:].strip()
meta: dict = {}
for line in fm_text.splitlines():
if ":" in line:
k, _, v = line.partition(":")
meta[k.strip()] = v.strip().strip('"')
return meta, body
def load_pipes(pipes_dir: Path) -> list[dict]:
if not pipes_dir.exists():
return []
pipes = []
for pipe_dir in sorted(pipes_dir.iterdir()):
if not pipe_dir.is_dir() or pipe_dir.name.startswith("."):
continue
pipe_md = pipe_dir / "pipe.md"
if not pipe_md.exists():
continue
text = pipe_md.read_text(encoding="utf-8")
meta, body = _parse_frontmatter(text)
if meta.get("enabled", "true").lower() == "false":
continue
body = re.sub(r"Read screenpipe skill first\.?\n?", "", body).strip()
pipes.append({
"id": pipe_dir.name,
"title": meta.get("title", pipe_dir.name),
"description": meta.get("description", ""),
"icon": meta.get("icon", ""),
"schedule": meta.get("schedule", "manual"),
"featured": meta.get("featured", "false").lower() == "true",
"prompt": body,
})
return pipes
def _build_system(d: date, stats: dict) -> str:
from consumers.activity import app_time, browser_urls, ui_event_summary
from consumers.ocr import deduplicated_text
from consumers.audio import formatted_transcript
apps = app_time(d)
app_lines = "\n".join(f"- {a['app_name']}: {a['minutes']} min" for a in apps[:20])
urls = browser_urls(d, limit=20)
url_lines = "\n".join(f"- {u['browser_url'][:100]} ({u['minutes']} min)" for u in urls)
ui_rows = ui_event_summary(d)
ui_lines = "\n".join(
f"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches"
for r in ui_rows[:15]
)
ocr_rows = deduplicated_text(d, chunk_minutes=5)
ocr_lines = "\n".join(
f"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}"
for r in ocr_rows[:100]
)
audio = formatted_transcript(d)
if len(audio) > 3000:
audio = audio[:3000]
return f"""You are analyzing screenpipe data — recordings of a person's computer activity.
## App usage (minutes per app):
{app_lines or '(no app data)'}
## Browser URLs visited:
{url_lines or '(no browser data)'}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_lines or '(no UI event data)'}
## Screen content (sampled every 5 minutes):
{ocr_lines or '(no screen data)'}
## Audio / speech:
{audio or '(no audio data)'}
Date: {d}
Total frames recorded: {stats['total_frames']}"""
def run_pipe(
pipe_id: str,
for_date: date | None = None,
api_key: str | None = None,
pipes_dir: Path | None = None,
) -> dict[str, Any]:
import anthropic
from consumers.activity import summary_stats
d = for_date or date.today()
key = api_key or os.environ.get("ANTHROPIC_API_KEY", "")
if not key:
return {"title": "Error", "content": "ANTHROPIC_API_KEY not set.", "date": str(d)}
_pipes_dir = pipes_dir or Path(os.environ.get("PIPES_DIR", "/data/pipes"))
all_pipes = {p["id"]: p for p in load_pipes(_pipes_dir)}
if pipe_id not in all_pipes:
return {"title": "Error", "content": f"Pipe not found: {pipe_id}", "date": str(d)}
pipe = all_pipes[pipe_id]
stats = summary_stats(d)
if stats["total_frames"] == 0:
return {"title": pipe["title"], "content": f"No screen data found for {d}.", "date": str(d)}
system = _build_system(d, stats)
client = anthropic.Anthropic(api_key=key)
message = client.messages.create(
model="claude-haiku-4-5-20251001",
max_tokens=1024,
system=system,
messages=[{"role": "user", "content": pipe["prompt"]}],
)
return {
"title": pipe["title"],
"content": message.content[0].text,
"date": str(d),
"stats": stats,
}
Now add the API endpoints to
main.py
:
Edit
main.py
main.py
Added 1 line
Edit
main.py
main.py
Added 1 line
Now add the pipe endpoints at the end of main.py, before the closing summary section:
Edit
main.py
main.py
Added 14 lines
Now add the CLI command to
cli.py
cli.py
:
Edit
cli.py
cli.py
Added 40 lines
Done. Here's how to run pipes:
How to run pipes
How to run pipes
Via Docker (inside the running container):
Copy code to clipboard
docker exec -it screenpipe-app python cli.py pipe --list
docker exec -it screenpipe-app python cli.py pipe day-recap
docker exec -it screenpipe-app python cli.py pipe standup-update --date yesterday
Via the API
(once the container is running on port 8766):
Copy code to clipboard
# List pipes
curl http://localhost:8766/api/pipes
# Run a pipe
curl -X POST "http://localhost:8766/api/pipes/day-recap/run"
curl -X POST "http://localhost:8766/api/pipes/standup-update/run?d=2026-04-25"
Rebuild and restart
to pick up the changes:
Copy code to clipboard
cd /volume1/screenpipe/app
docker compose up --build -d
How it works:
Each
pipe.md
file is loaded dynamically — the frontmatter provides metadata and the body becomes the user prompt. Screenpipe data (app usage, browser URLs, OCR, audio) is injected as a Claude system message so the pipe prompt can reference it naturally. The "Read screenpipe skill first" line is stripped automatically.
The pipes directory inside Docker is
/data/pipes
(since
/volume1/screenpipe
→
/data
). You can override it with a
PIPES_DIR
env var if needed.
Message actions
pipe.md
pipe.md
where to place api key and can I use different keys
Thinking
Thinking
Bash
Read .env file
IN
cat /volume1/screenpipe/app/.env
Copy code to clipboard
OUT
[ENV_SECRET]
Where to place the key:
app/.env
app/.env
— replace
your_key_here
with your actual key:
Copy code to clipboard
[ENV_SECRET]
That file is loaded by
load_dotenv()
at startup and is excluded from git via
.gitignore
.
Can you use different keys per pipe?
Not currently — all pipes share the one key from
.env
. But you can add per-pipe key support by adding an
api_key
field to the pipe's frontmatter:
Copy code to clipboard
---
title: Meeting Summary
api_key_env: ANTHROPIC_KEY_MEETINGS
---
Then in
consumers/pipes.py
consumers/pipes.py
, read it in
_parse_frontmatter
and pass it through
run_pipe
. Want me to add that?
Message actions
pipe.md
pipe.md
can I use mistral or other llm? or is is build for antrophic only
Thinking
Thinking
Currently it's Anthropic-only — the code calls the
anthropic
SDK directly in both
consumers/pipes.py
consumers/pipes.py
and
consumers/summary.py
consumers/summary.py
.
Adding other providers is straightforward since Mistral, Ollama, OpenRouter, Groq, and most modern LLMs expose an OpenAI-compatible API. The cleanest approach: add the
openai
package and let you configure the provider via
.env
:
Copy code to clipboard
# Anthropic (default)
[ENV_SECRET]
# OR: any OpenAI-compatible provider
LLM_PROVIDER=openai-compatible
LLM_BASE_URL=https://api.mistral.ai/v1
[ENV_SECRET]
LLM_MODEL=mistral-small-latest
This would cover Mistral, Ollama (
http://localhost:11434/v1
), OpenRouter, Groq, etc. with one code path.
Want me to implement that? It's a small change — a
_call_llm(system, user_prompt)
helper in
pipes.py
that branches on
LLM_PROVIDER...
|
[{"role":"AXRadioButton","text [{"role":"AXRadioButton","text":"Explorer (⇧⌘E)","depth":19,"bounds":{"left":0.0,"top":0.047885075,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":true},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.057462092,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Search (⇧⌘F)","depth":19,"bounds":{"left":0.0,"top":0.08619314,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.09577015,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Source Control (⌃⇧G) - 10 pending changes","depth":19,"bounds":{"left":0.0,"top":0.1245012,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.13407822,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"10","depth":22,"bounds":{"left":0.00831117,"top":0.1452514,"width":0.003656915,"height":0.008778931},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.00831117,"top":0.14604948,"width":0.0016622341,"height":0.007980846}},{"char_start":1,"char_count":1,"bounds":{"left":0.009973404,"top":0.14604948,"width":0.0023271276,"height":0.007980846}}],"role_description":"text"},{"role":"AXRadioButton","text":"Run and Debug (⇧⌘D)","depth":19,"bounds":{"left":0.0,"top":0.16280925,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.17238627,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Remote Explorer","depth":19,"bounds":{"left":0.0,"top":0.20111732,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.21069433,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Extensions (⇧⌘X) - 2 require update","depth":19,"bounds":{"left":0.0,"top":0.23942538,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.2490024,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"2","depth":22,"bounds":{"left":0.009640957,"top":0.2601756,"width":0.0019946808,"height":0.008778931},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Claude Code","depth":19,"bounds":{"left":0.0,"top":0.27773345,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"Containers","depth":19,"bounds":{"left":0.0,"top":0.3160415,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXHeading","text":"EXPLORER","depth":17,"bounds":{"left":0.022606382,"top":0.047885075,"width":0.018949468,"height":0.02793296},"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"EXPLORER","depth":18,"bounds":{"left":0.022606382,"top":0.056664005,"width":0.018949468,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.022606382,"top":0.056664005,"width":0.0023271276,"height":0.0103751}},{"char_start":1,"char_count":7,"bounds":{"left":0.024933511,"top":0.056664005,"width":0.01662234,"height":0.0103751}}],"role_description":"text"},{"role":"AXButton","text":"Explorer Section: screenpipe [SSH: nas]","depth":21,"bounds":{"left":0.015957447,"top":0.07581804,"width":0.09940159,"height":0.017557861},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":true},{"role":"AXStaticText","text":"","depth":23,"bounds":{"left":0.01662234,"top":0.07821229,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"Explorer Section: screenpipe [SSH: nas]","depth":22,"bounds":{"left":0.022606382,"top":0.07581804,"width":0.045877658,"height":0.017557861},"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"SCREENPIPE [SSH: NAS]","depth":23,"bounds":{"left":0.022606382,"top":0.079010375,"width":0.045877658,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.022606382,"top":0.07980846,"width":0.0026595744,"height":0.0103751}},{"char_start":1,"char_count":20,"bounds":{"left":0.025265958,"top":0.07980846,"width":0.043218084,"height":0.0103751}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.09577015,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"#recycle","depth":27,"bounds":{"left":0.025930852,"top":0.09577015,"width":0.017287234,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.096568234,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":7,"bounds":{"left":0.028590426,"top":0.096568234,"width":0.01462766,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.11332801,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"app","depth":27,"bounds":{"left":0.025930852,"top":0.11332801,"width":0.0076462766,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.11412609,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":2,"bounds":{"left":0.02825798,"top":0.11412609,"width":0.005319149,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.11412609,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.022273935,"top":0.13088587,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"__pycache__","depth":27,"bounds":{"left":0.028590426,"top":0.13088587,"width":0.026595745,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.13168396,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":10,"bounds":{"left":0.030917553,"top":0.13168396,"width":0.024268618,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.022273935,"top":0.14844373,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"consumers","depth":27,"bounds":{"left":0.028590426,"top":0.14844373,"width":0.022273935,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.14924182,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":8,"bounds":{"left":0.030917553,"top":0.14924182,"width":0.019946808,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.14924182,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.022273935,"top":0.1660016,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"static","depth":27,"bounds":{"left":0.028590426,"top":0.1660016,"width":0.010970744,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.16679968,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":5,"bounds":{"left":0.030917553,"top":0.16679968,"width":0.008976064,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.16679968,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.1819633,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":".env","depth":27,"bounds":{"left":0.028590426,"top":0.18355946,"width":0.00831117,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.18435754,"width":0.0013297872,"height":0.011971269}},{"char_start":1,"char_count":3,"bounds":{"left":0.029920213,"top":0.18435754,"width":0.006981383,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.19952115,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"cli.py","depth":27,"bounds":{"left":0.028590426,"top":0.20111732,"width":0.010638298,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.2019154,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":5,"bounds":{"left":0.030917553,"top":0.2019154,"width":0.00831117,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.2019154,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.21707901,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.py","depth":27,"bounds":{"left":0.028590426,"top":0.21867518,"width":0.011303191,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.21947326,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":4,"bounds":{"left":0.03125,"top":0.21947326,"width":0.008643617,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.23463687,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"docker-compose.yml","depth":27,"bounds":{"left":0.028590426,"top":0.23623304,"width":0.042220745,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.23703113,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":17,"bounds":{"left":0.03125,"top":0.23703113,"width":0.03956117,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.25219473,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Dockerfile","depth":27,"bounds":{"left":0.028590426,"top":0.25379092,"width":0.020611702,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.254589,"width":0.0033244682,"height":0.011971269}},{"char_start":1,"char_count":9,"bounds":{"left":0.031914894,"top":0.254589,"width":0.017287234,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.254589,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.2697526,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"main.py","depth":27,"bounds":{"left":0.028590426,"top":0.27134877,"width":0.015625,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.27214685,"width":0.003656915,"height":0.011971269}},{"char_start":1,"char_count":6,"bounds":{"left":0.032247342,"top":0.27214685,"width":0.012300532,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.27214685,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.28731045,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"requirements.txt","depth":27,"bounds":{"left":0.028590426,"top":0.28890663,"width":0.032912236,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.2897047,"width":0.0016622341,"height":0.011971269}},{"char_start":1,"char_count":15,"bounds":{"left":0.03025266,"top":0.2897047,"width":0.03158245,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.2897047,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.3064645,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"data","depth":27,"bounds":{"left":0.025930852,"top":0.3064645,"width":0.008976064,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.30726257,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":3,"bounds":{"left":0.028590426,"top":0.30726257,"width":0.0063164895,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.32402235,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"logs","depth":27,"bounds":{"left":0.025930852,"top":0.32402235,"width":0.00831117,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.32482043,"width":0.0009973404,"height":0.011971269}},{"char_start":1,"char_count":3,"bounds":{"left":0.026928192,"top":0.32482043,"width":0.0076462766,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.32482043,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.3415802,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"pipes","depth":27,"bounds":{"left":0.025930852,"top":0.3415802,"width":0.010970744,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.3423783,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":4,"bounds":{"left":0.028590426,"top":0.3423783,"width":0.00831117,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.3575419,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":".gitignore","depth":27,"bounds":{"left":0.025930852,"top":0.35913807,"width":0.018949468,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.35993615,"width":0.0013297872,"height":0.011971269}},{"char_start":1,"char_count":9,"bounds":{"left":0.027260639,"top":0.35993615,"width":0.017952127,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.37509975,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"app_settings.json","depth":27,"bounds":{"left":0.025930852,"top":0.37669593,"width":0.03557181,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.377494,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":16,"bounds":{"left":0.02825798,"top":0.377494,"width":0.03324468,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.3926576,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"archive.db","depth":27,"bounds":{"left":0.025930852,"top":0.3942538,"width":0.020944148,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.39505187,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":9,"bounds":{"left":0.02825798,"top":0.39505187,"width":0.01861702,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.4102155,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"archive.db-bak","depth":27,"bounds":{"left":0.025930852,"top":0.41181165,"width":0.03025266,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.41260973,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":13,"bounds":{"left":0.02825798,"top":0.41260973,"width":0.027925532,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"U","depth":27,"bounds":{"left":0.10704787,"top":0.41260973,"width":0.0029920214,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.42777336,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite","depth":27,"bounds":{"left":0.025930852,"top":0.4293695,"width":0.017287234,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.4301676,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":8,"bounds":{"left":0.028590426,"top":0.4301676,"width":0.014960106,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.44533122,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite-shm","depth":27,"bounds":{"left":0.025930852,"top":0.44692737,"width":0.027925532,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.44772545,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":12,"bounds":{"left":0.028590426,"top":0.44772545,"width":0.025265958,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.46288908,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite-wal","depth":27,"bounds":{"left":0.025930852,"top":0.46448523,"width":0.025930852,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.46528333,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":12,"bounds":{"left":0.028590426,"top":0.46528333,"width":0.023603724,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.48044693,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe_sync_updated.sh","depth":27,"bounds":{"left":0.025930852,"top":0.4820431,"width":0.059175532,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.4828412,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":25,"bounds":{"left":0.02825798,"top":0.4828412,"width":0.056848403,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"U","depth":27,"bounds":{"left":0.10704787,"top":0.4828412,"width":0.0029920214,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.4980048,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe_sync.sh","depth":27,"bounds":{"left":0.025930852,"top":0.49960095,"width":0.039893616,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.50039905,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":17,"bounds":{"left":0.02825798,"top":0.50039905,"width":0.037898935,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.51556265,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe.db","depth":27,"bounds":{"left":0.025930852,"top":0.5171588,"width":0.028590426,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.5179569,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":12,"bounds":{"left":0.02825798,"top":0.5179569,"width":0.026595745,"height":0.011971269}}],"role_description":"text"},{"role":"AXButton","text":"Outline Section","depth":21,"bounds":{"left":0.015957447,"top":0.9473264,"width":0.09940159,"height":0.017557861},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":23,"bounds":{"left":0.01662234,"top":0.9497207,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"OUTLINE","depth":22,"bounds":{"left":0.022606382,"top":0.9473264,"width":0.01662234,"height":0.017557861},"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"OUTLINE","depth":23,"bounds":{"left":0.022606382,"top":0.95131683,"width":0.01662234,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.022606382,"top":0.95131683,"width":0.0029920214,"height":0.0103751}},{"char_start":1,"char_count":6,"bounds":{"left":0.025598405,"top":0.95131683,"width":0.013630319,"height":0.0103751}}],"role_description":"text"},{"role":"AXButton","text":"Timeline Section","depth":21,"bounds":{"left":0.015957447,"top":0.9648843,"width":0.09940159,"height":0.017557861},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":23,"bounds":{"left":0.01662234,"top":0.96727854,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"TIMELINE","depth":22,"bounds":{"left":0.022606382,"top":0.9648843,"width":0.01761968,"height":0.017557861},"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"TIMELINE","depth":23,"bounds":{"left":0.022606382,"top":0.9688747,"width":0.01761968,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.022606382,"top":0.9688747,"width":0.0026595744,"height":0.0103751}},{"char_start":1,"char_count":7,"bounds":{"left":0.025265958,"top":0.9688747,"width":0.015292553,"height":0.0103751}}],"role_description":"text"},{"role":"AXRadioButton","text":"app_settings.json, Editor Group 1","depth":28,"bounds":{"left":0.11569149,"top":0.047885075,"width":0.055851065,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"screenpipe_sync.sh, Editor Group 1","depth":28,"bounds":{"left":0.17154256,"top":0.047885075,"width":0.06050532,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"pipe.md, Editor Group 1","depth":28,"bounds":{"left":0.23171543,"top":0.047885075,"width":0.040226065,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":".env, Editor Group 1","depth":28,"bounds":{"left":0.27194148,"top":0.047885075,"width":0.039893616,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":false},{"role":"AXStaticText","text":"","depth":29,"bounds":{"left":0.12832446,"top":0.07821229,"width":0.0056515955,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXTextArea","text":"ANTHROPIC_API_KEY=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","depth":28,"bounds":{"left":0.13763298,"top":0.10774142,"width":0.30285904,"height":0.014365523},"on_screen":true,"value":"ANTHROPIC_API_KEY=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","role_description":"editor","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"ANTHROPIC_API_KEY=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","depth":29,"bounds":{"left":0.13763298,"top":0.09497207,"width":0.30285904,"height":0.011173184},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.13763298,"top":0.09497207,"width":0.0023271276,"height":0.011173184}},{"char_start":1,"char_count":125,"bounds":{"left":0.13996011,"top":0.09497207,"width":0.30053192,"height":0.011173184}}],"role_description":"text"},{"role":"AXRadioButton","text":"Implement and run pipe l…, Editor Group 2","depth":28,"bounds":{"left":0.5578458,"top":0.047885075,"width":0.073803194,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":false},{"role":"AXRadioButton","text":"Problems (⇧⌘M)","depth":22,"bounds":{"left":0.118351065,"top":0.7278532,"width":0.027925532,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"PROBLEMS","depth":24,"bounds":{"left":0.122340426,"top":0.7366321,"width":0.019946808,"height":0.0103751},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Output (⇧⌘U)","depth":22,"bounds":{"left":0.14594415,"top":0.7278532,"width":0.023603724,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUTPUT","depth":24,"bounds":{"left":0.14993352,"top":0.7366321,"width":0.015625,"height":0.0103751},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Debug Console (⇧⌘Y)","depth":22,"bounds":{"left":0.16921543,"top":0.7278532,"width":0.039893616,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"DEBUG CONSOLE","depth":24,"bounds":{"left":0.1732048,"top":0.7366321,"width":0.031914894,"height":0.0103751},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Terminal (⌃`)","depth":22,"bounds":{"left":0.2087766,"top":0.7278532,"width":0.026595745,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":true},{"role":"AXStaticText","text":"TERMINAL","depth":24,"bounds":{"left":0.21276596,"top":0.7366321,"width":0.01861702,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.2130984,"top":0.73743016,"width":0.0023271276,"height":0.0103751}},{"char_start":1,"char_count":7,"bounds":{"left":0.21542554,"top":0.73743016,"width":0.016289894,"height":0.0103751}}],"role_description":"text"},{"role":"AXRadioButton","text":"Ports - 1 forwarded port","depth":22,"bounds":{"left":0.23537233,"top":0.7278532,"width":0.026263298,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"PORTS","depth":24,"bounds":{"left":0.2393617,"top":0.7366321,"width":0.012300532,"height":0.0103751},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":25,"bounds":{"left":0.25465426,"top":0.73743016,"width":0.0019946808,"height":0.008778931},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"remote SSH: nas","depth":16,"bounds":{"left":0.0006648936,"top":0.98244214,"width":0.028590426,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.0033244682,"top":0.9848364,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"SSH: nas","depth":17,"bounds":{"left":0.008643617,"top":0.9856345,"width":0.017952127,"height":0.011173184},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.008643617,"top":0.9856345,"width":0.0013297872,"height":0.011173184}},{"char_start":1,"char_count":7,"bounds":{"left":0.009973404,"top":0.9856345,"width":0.01462766,"height":0.011173184}}],"role_description":"text"},{"role":"AXButton","text":"screenpipe (Git) - master*, Checkout Branch/Tag...","depth":16,"bounds":{"left":0.030917553,"top":0.98244214,"width":0.023271276,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.031914894,"top":0.9848364,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"master*","depth":17,"bounds":{"left":0.03723404,"top":0.9856345,"width":0.015957447,"height":0.011173184},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.03723404,"top":0.9856345,"width":0.0013297872,"height":0.011173184}},{"char_start":1,"char_count":6,"bounds":{"left":0.03856383,"top":0.9856345,"width":0.012965426,"height":0.011173184}}],"role_description":"text"},{"role":"AXButton","text":"screenpipe (Git) - Synchronize Changes","depth":16,"bounds":{"left":0.05418883,"top":0.98244214,"width":0.00731383,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"No Problems","depth":16,"bounds":{"left":0.06416223,"top":0.98244214,"width":0.022606382,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.06582447,"top":0.9848364,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"0","depth":17,"bounds":{"left":0.07114362,"top":0.9856345,"width":0.004986702,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.07579787,"top":0.9848364,"width":0.0056515955,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"0","depth":17,"bounds":{"left":0.08111702,"top":0.9856345,"width":0.0039893617,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Forwarded Ports: 8766","depth":16,"bounds":{"left":0.08843085,"top":0.98244214,"width":0.012632979,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.09009308,"top":0.9848364,"width":0.0056515955,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":17,"bounds":{"left":0.09541223,"top":0.9856345,"width":0.0039893617,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Notifications","depth":16,"bounds":{"left":0.9886968,"top":0.98244214,"width":0.010638298,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sign In","depth":16,"bounds":{"left":0.9650931,"top":0.98244214,"width":0.022606382,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.96675533,"top":0.9848364,"width":0.0056515955,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Sign In","depth":17,"bounds":{"left":0.97207445,"top":0.9856345,"width":0.013962766,"height":0.011173184},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.97207445,"top":0.9856345,"width":0.0013297872,"height":0.011173184}},{"char_start":1,"char_count":6,"bounds":{"left":0.9734042,"top":0.9856345,"width":0.010638298,"height":0.011173184}}],"role_description":"text"},{"role":"AXStaticText","text":"Info: Setting up SSH Host nas: Setting up SSH tunnel","depth":12,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Implement and run pipe logic","depth":19,"bounds":{"left":0.56017286,"top":0.08060654,"width":0.07114362,"height":0.022346368},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Session history","depth":19,"bounds":{"left":0.9780585,"top":0.08060654,"width":0.00930851,"height":0.022346368},"on_screen":true,"help_text":"Session history","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"New session","depth":19,"bounds":{"left":0.9886968,"top":0.08060654,"width":0.00930851,"height":0.022346368},"on_screen":true,"help_text":"New session","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Message actions","depth":24,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"main.py","depth":23,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"lets implement logic with pipes. how can I run it?","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Let me look at the current project structure to understand what's already in place.","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"List project files","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"find /volume1/screenpipe -type f | head -50 && echo \"---\" && ls /volume1/screenpipe","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"/volume1/screenpipe/.DS_Store\n/volume1/screenpipe/screenpipe.db\n/volume1/screenpipe/screenpipe_sync.sh\n/volume1/screenpipe/app_settings.json\n/volume1/screenpipe/.gitignore\n/volume1/screenpipe/archive.db\n/volume1/screenpipe/db.sqlite\n/volume1/screenpipe/db.sqlite-wal\n/volume1/screenpipe/db.sqlite-shm\n/volume1/screenpipe/#recycle/desktop.ini\n/volume1/screenpipe/#recycle/db.sqlite\n/volume1/screenpipe/#recycle/Copy #1 of db.sqlite\n/volume1/screenpipe/#recycle/.DS_Store\n/volume1/screenpipe/#recycle/Copy #2 of db.sqlite\n/volume1/screenpipe/#recycle/archive.db\n/volume1/screenpipe/#recycle/Copy #1 of archive.db\n/volume1/screenpipe/#recycle/Copy #2 of archive.db\n/volume1/screenpipe/#recycle/Copy #3 of archive.db\n/volume1/screenpipe/#recycle/Copy #4 of archive.db\n/volume1/screenpipe/#recycle/Copy #5 of archive.db\n/volume1/screenpipe/#recycle/Copy #3 of db.sqlite\n/volume1/screenpipe/#recycle/Copy #4 of db.sqlite\n/volume1/screenpipe/#recycle/Copy #6 of archive.db\n/volume1/screenpipe/#recycle/test.txt\n/volume1/screenpipe/#recycle/Copy #7 of archive.db\n/volume1/screenpipe/#recycle/Copy #8 of archive.db\n/volume1/screenpipe/#recycle/archive.db-journal\n/volume1/screenpipe/#recycle/Copy #1 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #2 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #3 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #4 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #5 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #6 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #7 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #5 of db.sqlite\n/volume1/screenpipe/pipes/.DS_Store\n/volume1/screenpipe/app/.env\n/volume1/screenpipe/app/cli.py\n/volume1/screenpipe/app/.DS_Store\n/volume1/screenpipe/app/db.py\n/volume1/screenpipe/app/docker-compose.yml\n/volume1/screenpipe/app/main.py\n/volume1/screenpipe/app/requirements.txt\n/volume1/screenpipe/app/Dockerfile\n/volume1/screenpipe/data/.DS_Store\n/volume1/screenpipe/.git/description\n/volume1/screenpipe/.git/HEAD\n/volume1/screenpipe/.git/index\n/volume1/screenpipe/.git/COMMIT_EDITMSG\n/volume1/screenpipe/#recycle/data/.DS_Store\n---\napp\napp_settings.json\narchive.db\ndata\ndb.sqlite\ndb.sqlite-shm\ndb.sqlite-wal\npipes\n#recycle\nscreenpipe.db\nscreenpipe_sync.sh","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"main.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Check pipes directory and docker-compose","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/pipes/ && ls /volume1/screenpipe/app/ && cat /volume1/screenpipe/app/docker-compose.yml","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ai-habits\nday-recap\nmeeting-summary\nstandup-update\ntime-breakdown\nvideo-export\ncli.py\nconsumers\ndb.py\ndocker-compose.yml\nDockerfile\nmain.py\n__pycache__\nrequirements.txt\nstatic\nservices:\n screenpipe-app:\n build: .\n container_name: screenpipe-app\n restart: unless-stopped\n ports:\n - \"8766:8000\"\n volumes:\n - /volume1/screenpipe:/data\n env_file:\n - .env\n environment:\n TZ: Europe/Sofia\n DB_PATH: /data/db.sqlite\n\n sqlite-web-archive:\n image: ghcr.io/coleifer/sqlite-web:latest\n container_name: screenpipe-sqlweb-archive\n restart: unless-stopped\n ports:\n - \"8767:8080\"\n volumes:\n - /volume1/screenpipe:/data\n command: [\"-H\", \"0.0.0.0\", \"-r\", \"/data/archive.db\"]\n\n sqlite-web-live:\n image: ghcr.io/coleifer/sqlite-web:latest\n container_name: screenpipe-sqlweb-live\n restart: unless-stopped\n ports:\n - \"8768:8080\"\n volumes:\n - /volume1/screenpipe:/data\n command: [\"-H\", \"0.0.0.0\", \"-r\", \"/data/db.sqlite\"]","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"requirements.txt","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"requirements.txt","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Inspect a pipe directory","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/pipes/day-recap/ && cat /volume1/screenpipe/pipes/day-recap/pipe.json 2>/dev/null || ls /volume1/screenpipe/pipes/day-recap/","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"pipe.md\npipe.md","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"cli.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"cli.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"List all pipes and their contents","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/pipes/ && for d in /volume1/screenpipe/pipes/*/; do echo \"=== $d ===\"; ls \"$d\"; done","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ai-habits\nday-recap\nmeeting-summary\nstandup-update\ntime-breakdown\nvideo-export\n=== /volume1/screenpipe/pipes/ai-habits/ ===\npipe.md\n=== /volume1/screenpipe/pipes/day-recap/ ===\npipe.md\n=== /volume1/screenpipe/pipes/meeting-summary/ ===\npipe.md\n=== /volume1/screenpipe/pipes/standup-update/ ===\npipe.md\n=== /volume1/screenpipe/pipes/time-breakdown/ ===\npipe.md\n=== /volume1/screenpipe/pipes/video-export/ ===\npipe.md","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read pipe markdown files","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"cat /volume1/screenpipe/pipes/day-recap/pipe.md && echo \"===\" && cat /volume1/screenpipe/pipes/meeting-summary/pipe.md 2>/dev/null | head -50","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Day Recap\ndescription: \"Today's accomplishments, key moments, and unfinished work\"\nicon: \"📋\"\nfeatured: true\n---\n\nAnalyze my screen and audio recordings from today (last 16 hours only). \n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Summary\nOne sentence: what I mainly did today.\n\n## Accomplishments\n- Top 3 things I finished, with timestamps (e.g. \"2:30 PM\")\n- Name specific apps, files, or projects\n\n## Key Moments\n- Important things I saw, said, or heard — with timestamps\n\n## Unfinished Work\n- What I should continue tomorrow — name the app/file/task\n\n## Patterns\n- Apps I used most, topics that came up repeatedly\n\nOnly report what you can verify from the data. End with: \"**Next step:** [most important thing to continue]\"\n===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Meeting Summary\ndescription: \"Summarize meeting transcript with key takeaways and action items\"\nicon: \"🤝\"\nfeatured: false\n---\n\nSummarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.\n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Meeting Summary\nOne sentence: what this meeting was about.\n\n## Key Takeaways\n- Top 3-5 important points discussed\n- Include who said what when relevant\n\n## Action Items\n- [ ] Task — assigned to whom, deadline if mentioned\n- [ ] Task — assigned to whom\n\n## Decisions Made\n- List any decisions or agreements reached\n\n## Open Questions\n- Anything unresolved or needing follow-up\n\nKeep it concise and actionable.","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read summary consumer","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/app/consumers/ && cat /volume1/screenpipe/app/consumers/summary.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"activity.py\naudio.py\nelements.py\n__init__.py\ninteractions.py\nocr.py\n__pycache__\nreport.py\nsummary.py\n\"\"\"AI summary generator using Claude.\"\"\"\nimport os\nfrom datetime import date\nfrom typing import Any\n\nfrom consumers.activity import app_time, summary_stats, browser_urls, ui_event_summary\nfrom consumers.ocr import deduplicated_text\nfrom consumers.audio import formatted_transcript\n\n\nSUMMARY_TYPES = {\n \"day_recap\": {\n \"title\": \"Day Recap\",\n \"prompt\": \"\"\"\\\nYou are analyzing a person's computer activity for the day.\n\n## App usage (minutes per app):\n{app_time}\n\n## Browser URLs visited:\n{browser_urls}\n\n## UI activity per app (clicks / keystrokes / app-switches):\n{ui_events}\n\n## Screen content (sampled every 5 minutes):\n{ocr_text}\n\n## Audio/speech:\n{audio}\n\nWrite a concise day recap using EXACTLY this format:\n\n## Summary\nOne sentence: what I mainly worked on today.\n\n## Accomplishments\n- Top 3 things I finished, with approximate times\n- Name specific apps, files, or projects\n\n## Key Moments\n- Important things seen or heard, with timestamps\n\n## Unfinished Work\n- What to continue tomorrow\n\n## Patterns\n- Apps used most, topics that came up repeatedly\n\nOnly report what you can verify from the data. End with:\n**Next step:** [most important thing to continue]\"\"\",\n },\n \"standup\": {\n \"title\": \"Standup Update\",\n \"prompt\": \"\"\"\\\nYou are analyzing a person's computer activity for the day.\n\n## App usage (minutes per app):\n{app_time}\n\n## Browser URLs visited:\n{browser_urls}\n\n## UI activity per app (clicks / keystrokes / app-switches):\n{ui_events}\n\n## Screen content (sampled every 5 minutes):\n{ocr_text}\n\n## Audio/speech:\n{audio}\n\nWrite a brief standup update:\n\n**Yesterday:** What I worked on (2-3 bullets)\n**Today:** What I plan to continue (1-2 bullets)\n**Blockers:** Any issues observed (or \"None\")\n\nKeep it under 150 words. Only report what's verifiable from the data.\"\"\",\n },\n \"focus_time\": {\n \"title\": \"Focus & Distraction Analysis\",\n \"prompt\": \"\"\"\\\nYou are analyzing a person's computer activity for the day.\n\n## App usage (minutes per app):\n{app_time}\n\n## Browser URLs visited:\n{browser_urls}\n\n## UI activity per app (clicks / keystrokes / app-switches):\n{ui_events}\n\n## Screen content (sampled every 5 minutes):\n{ocr_text}\n\nAnalyze focus vs distraction patterns:\n\n## Deep Work Periods\n- When and how long were sustained focus sessions?\n- What was being worked on?\n\n## Distractions\n- Which apps/sites were used recreationally?\n- How much time was lost to context switching?\n\n## Recommendations\n- 2-3 concrete suggestions to improve focus tomorrow\n\nBe specific with times and app names.\"\"\",\n },\n}\n\n\ndef _build_context(for_date: date) -> dict[str, str]:\n apps = app_time(for_date)\n app_lines = \"\\n\".join(f\"- {a['app_name']}: {a['minutes']} min\" for a in apps[:20])\n\n urls = browser_urls(for_date, limit=20)\n url_lines = \"\\n\".join(\n f\"- {u['browser_url'][:100]} ({u['minutes']} min)\" for u in urls\n )\n\n ui_rows = ui_event_summary(for_date)\n ui_lines = \"\\n\".join(\n f\"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches\"\n for r in ui_rows[:15]\n )\n\n ocr_rows = deduplicated_text(for_date, chunk_minutes=5)\n ocr_lines = \"\\n\".join(\n f\"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}\"\n for r in ocr_rows[:100]\n )\n\n audio = formatted_transcript(for_date)\n\n return {\n \"app_time\": app_lines or \"(no app data)\",\n \"browser_urls\": url_lines or \"(no browser data)\",\n \"ui_events\": ui_lines or \"(no UI event data)\",\n \"ocr_text\": ocr_lines or \"(no screen data)\",\n \"audio\": audio[:3000] if len(audio) > 3000 else audio,\n }\n\n\ndef generate(\n summary_type: str = \"day_recap\",\n for_date: date | None = None,\n api_key: str | None = None,\n) -> dict[str, Any]:\n \"\"\"Generate an AI summary. Returns dict with 'title', 'content', 'date'.\"\"\"\n import anthropic\n\n d = for_date or date.today()\n key = api_key or os.environ.get(\"ANTHROPIC_API_KEY\", \"\")\n if not key:\n return {\n \"title\": \"Error\",\n \"content\": \"ANTHROPIC_API_KEY not set. Add it to your .env file.\",\n \"date\": str(d),\n }\n\n spec = SUMMARY_TYPES.get(summary_type)\n if not spec:\n return {\"title\": \"Error\", \"content\": f\"Unknown summary type: {summary_type}\", \"date\": str(d)}\n\n stats = summary_stats(d)\n if stats[\"total_frames\"] == 0:\n return {\n \"title\": spec[\"title\"],\n \"content\": f\"No screen data found for {d}.\",\n \"date\": str(d),\n }\n\n ctx = _build_context(d)\n prompt = spec[\"prompt\"].format(**ctx)\n\n client = anthropic.Anthropic(api_key=key)\n message = client.messages.create(\n model=\"claude-haiku-4-5-20251001\",\n max_tokens=1024,\n messages=[{\"role\": \"user\", \"content\": prompt}],\n )\n\n return {\n \"title\": spec[\"title\"],\n \"content\": message.content[0].text,\n \"date\": str(d),\n \"stats\": stats,\n }","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read all pipe.md files","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"for f in /volume1/screenpipe/pipes/*/pipe.md; do echo \"=== $f ===\"; cat \"$f\"; echo; done","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"=== /volume1/screenpipe/pipes/ai-habits/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: AI Habits\ndescription: \"How you use AI tools — patterns and insights\"\nicon: \"🤖\"\nfeatured: true\n---\n\nSearch my recordings from the last 24 hours for AI tool usage. Use app_name filter for each tool separately: ChatGPT, Claude, Copilot, Cursor, Gemini, Perplexity. Use limit=5 per search, max 6 searches total.\n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## AI Tools Used\n- List each tool with approximate time spent (e.g. \"Claude: ~45min\")\n\n## What I Used Them For\n- For each tool: coding, writing, research, or brainstorming\n\n## Usage Patterns\n- Do I switch between tools? Use them in bursts or steadily?\n\n## Effectiveness\n- Which tool appeared alongside completed work vs. abandoned attempts\n\nIf no AI usage is found, say so clearly. End with: \"**Tip:** [one suggestion to use AI tools more effectively]\"\n\n=== /volume1/screenpipe/pipes/day-recap/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Day Recap\ndescription: \"Today's accomplishments, key moments, and unfinished work\"\nicon: \"📋\"\nfeatured: true\n---\n\nAnalyze my screen and audio recordings from today (last 16 hours only). \n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Summary\nOne sentence: what I mainly did today.\n\n## Accomplishments\n- Top 3 things I finished, with timestamps (e.g. \"2:30 PM\")\n- Name specific apps, files, or projects\n\n## Key Moments\n- Important things I saw, said, or heard — with timestamps\n\n## Unfinished Work\n- What I should continue tomorrow — name the app/file/task\n\n## Patterns\n- Apps I used most, topics that came up repeatedly\n\nOnly report what you can verify from the data. End with: \"**Next step:** [most important thing to continue]\"\n\n=== /volume1/screenpipe/pipes/meeting-summary/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Meeting Summary\ndescription: \"Summarize meeting transcript with key takeaways and action items\"\nicon: \"🤝\"\nfeatured: false\n---\n\nSummarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.\n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Meeting Summary\nOne sentence: what this meeting was about.\n\n## Key Takeaways\n- Top 3-5 important points discussed\n- Include who said what when relevant\n\n## Action Items\n- [ ] Task — assigned to whom, deadline if mentioned\n- [ ] Task — assigned to whom\n\n## Decisions Made\n- List any decisions or agreements reached\n\n## Open Questions\n- Anything unresolved or needing follow-up\n\nKeep it concise and actionable.\n\n=== /volume1/screenpipe/pipes/standup-update/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Standup Update\ndescription: \"What you did, what's next, and any blockers\"\nicon: \"🏢\"\nfeatured: true\n---\n\nBased on my recordings from the last 24 hours, generate a standup update. Use limit=10 per search, max 3 searches total.\n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Yesterday\n- What I worked on (name specific projects, files, tools, PRs)\n\n## Today\n- What I will work on next (based on unfinished tasks and recent activity)\n\n## Blockers\n- Issues I hit — errors, slow builds, waiting on someone\n- If no blockers, write \"None\"\n\nKeep it under 150 words. Copy-paste ready for a team standup.\n\n=== /volume1/screenpipe/pipes/time-breakdown/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Time Breakdown\ndescription: \"Where your time went — by app, project, and category\"\nicon: \"⏱\"\nfeatured: false\n---\n\nAnalyze my app usage from today (last 12 hours). Use limit=10 per search, max 4 searches. Prefer /raw_sql with COUNT/GROUP BY queries.\n\nRead screenpipe skill first.\n\nUse this exact format with durations and percentages:\n\n## By Application\n- List each app with duration and percentage, sorted by time (e.g. \"VS Code: 2h 15min (28%)\")\n\n## By Category\n- Group into: coding, meetings, browsing, writing, communication, other\n- Show hours and percentage per category\n\n## By Project\n- Group related activities by project/topic. Name specific repos or tasks.\n\n## Productivity Score\n- Calculate: focused_work_hours / total_hours as a percentage\n- Focused = coding + writing. Unfocused = browsing + switching.\n\nEnd with: \"**Suggestion:** [one specific change to improve tomorrow's productivity]\"\n\n=== /volume1/screenpipe/pipes/video-export/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Export Video Clip\ndescription: \"Create a video of your recent screen activity\"\nicon: \"🎬\"\nfeatured: false\n---\n\nExport a video of my screen activity from the last 5 minutes.\n\nRead screenpipe skill first.\n\nUse the POST /frames/export endpoint with the time range and fps=1.0. Then show me the exported video file path as an inline code block so I can watch it.\n\nIf the export is large, suggest a lower fps or shorter time range.","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Now I have a clear picture. The pipes are markdown prompt templates in","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"/volume1/screenpipe/pipes/","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":", but there's no code to actually load and run them —","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"consumers/summary.py","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"has its own hardcoded prompts instead.","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Here's what I'll implement:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"consumers/pipes.py","depth":26,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"— dynamically loads pipe.md files and runs them via Claude (data injected as system message, pipe body as user prompt)","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"main.py","depth":26,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"— two new endpoints:","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"GET /api/pipes","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"and","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"POST /api/pipes/{pipe_id}/run","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"cli.py","depth":26,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"— a","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"pipe","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"command to run pipes from the terminal","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Let me build it:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Check browser_urls signature","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"cat /volume1/screenpipe/app/consumers/activity.py | grep \"def browser_urls\" -A 5","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"def browser_urls(\n for_date: date | None = None,\n app_name: str | None = None,\n ts_from: str | None = None,\n ts_to: str | None = None,\n limit: int = 30,","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Write","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"pipes.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"pipes.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"143 lines","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"\"\"\"Dynamic pipe loader and runner.\"\"\"\nimport os\nimport re\nfrom datetime import date\nfrom pathlib import Path\nfrom typing import Any\n\n\ndef _parse_frontmatter(text: str) -> tuple[dict, str]:\n if not text.startswith(\"---\"):\n return {}, text\n try:\n end = text.index(\"---\", 3)\n except ValueError:\n return {}, text\n fm_text = text[3:end].strip()\n body = text[end + 3:].strip()\n meta: dict = {}\n for line in fm_text.splitlines():\n if \":\" in line:\n k, _, v = line.partition(\":\")\n meta[k.strip()] = v.strip().strip('\"')\n return meta, body\n\n\ndef load_pipes(pipes_dir: Path) -> list[dict]:\n if not pipes_dir.exists():\n return []\n pipes = []\n for pipe_dir in sorted(pipes_dir.iterdir()):\n if not pipe_dir.is_dir() or pipe_dir.name.startswith(\".\"):\n continue\n pipe_md = pipe_dir / \"pipe.md\"\n if not pipe_md.exists():\n continue\n text = pipe_md.read_text(encoding=\"utf-8\")\n meta, body = _parse_frontmatter(text)\n if meta.get(\"enabled\", \"true\").lower() == \"false\":\n continue\n body = re.sub(r\"Read screenpipe skill first\\.?\\n?\", \"\", body).strip()\n pipes.append({\n \"id\": pipe_dir.name,\n \"title\": meta.get(\"title\", pipe_dir.name),\n \"description\": meta.get(\"description\", \"\"),\n \"icon\": meta.get(\"icon\", \"\"),\n \"schedule\": meta.get(\"schedule\", \"manual\"),\n \"featured\": meta.get(\"featured\", \"false\").lower() == \"true\",\n \"prompt\": body,\n })\n return pipes\n\n\ndef _build_system(d: date, stats: dict) -> str:\n from consumers.activity import app_time, browser_urls, ui_event_summary\n from consumers.ocr import deduplicated_text\n from consumers.audio import formatted_transcript\n\n apps = app_time(d)\n app_lines = \"\\n\".join(f\"- {a['app_name']}: {a['minutes']} min\" for a in apps[:20])\n\n urls = browser_urls(d, limit=20)\n url_lines = \"\\n\".join(f\"- {u['browser_url'][:100]} ({u['minutes']} min)\" for u in urls)\n\n ui_rows = ui_event_summary(d)\n ui_lines = \"\\n\".join(\n f\"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches\"\n for r in ui_rows[:15]\n )\n\n ocr_rows = deduplicated_text(d, chunk_minutes=5)\n ocr_lines = \"\\n\".join(\n f\"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}\"\n for r in ocr_rows[:100]\n )\n\n audio = formatted_transcript(d)\n if len(audio) > 3000:\n audio = audio[:3000]\n\n return f\"\"\"You are analyzing screenpipe data — recordings of a person's computer activity.\n\n## App usage (minutes per app):\n{app_lines or '(no app data)'}\n\n## Browser URLs visited:\n{url_lines or '(no browser data)'}\n\n## UI activity per app (clicks / keystrokes / app-switches):\n{ui_lines or '(no UI event data)'}\n\n## Screen content (sampled every 5 minutes):\n{ocr_lines or '(no screen data)'}\n\n## Audio / speech:\n{audio or '(no audio data)'}\n\nDate: {d}\nTotal frames recorded: {stats['total_frames']}\"\"\"\n\n\ndef run_pipe(\n pipe_id: str,\n for_date: date | None = None,\n api_key: str | None = None,\n pipes_dir: Path | None = None,\n) -> dict[str, Any]:\n import anthropic\n from consumers.activity import summary_stats\n\n d = for_date or date.today()\n key = api_key or os.environ.get(\"ANTHROPIC_API_KEY\", \"\")\n if not key:\n return {\"title\": \"Error\", \"content\": \"ANTHROPIC_API_KEY not set.\", \"date\": str(d)}\n\n _pipes_dir = pipes_dir or Path(os.environ.get(\"PIPES_DIR\", \"/data/pipes\"))\n all_pipes = {p[\"id\"]: p for p in load_pipes(_pipes_dir)}\n\n if pipe_id not in all_pipes:\n return {\"title\": \"Error\", \"content\": f\"Pipe not found: {pipe_id}\", \"date\": str(d)}\n\n pipe = all_pipes[pipe_id]\n stats = summary_stats(d)\n\n if stats[\"total_frames\"] == 0:\n return {\"title\": pipe[\"title\"], \"content\": f\"No screen data found for {d}.\", \"date\": str(d)}\n\n system = _build_system(d, stats)\n\n client = anthropic.Anthropic(api_key=key)\n message = client.messages.create(\n model=\"claude-haiku-4-5-20251001\",\n max_tokens=1024,\n system=system,\n messages=[{\"role\": \"user\", \"content\": pipe[\"prompt\"]}],\n )\n\n return {\n \"title\": pipe[\"title\"],\n \"content\": message.content[0].text,\n \"date\": str(d),\n \"stats\": stats,\n }","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Now add the API endpoints to","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"main.py","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":":","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Edit","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"main.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Added 1 line","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Edit","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"main.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Added 1 line","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Now add the pipe endpoints at the end of main.py, before the closing summary section:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Edit","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"main.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Added 14 lines","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Now add the CLI command to","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"cli.py","depth":23,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"cli.py","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":":","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Edit","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"cli.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"cli.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Added 40 lines","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Done. Here's how to run pipes:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXHeading","text":"How to run pipes","depth":22,"on_screen":false,"role_description":"heading"},{"role":"AXStaticText","text":"How to run pipes","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Via Docker (inside the running container):","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":23,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"docker exec -it screenpipe-app python cli.py pipe --list\ndocker exec -it screenpipe-app python cli.py pipe day-recap\ndocker exec -it screenpipe-app python cli.py pipe standup-update --date yesterday","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Via the API","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"(once the container is running on port 8766):","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":23,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"# List pipes\ncurl http://localhost:8766/api/pipes\n\n# Run a pipe\ncurl -X POST \"http://localhost:8766/api/pipes/day-recap/run\"\ncurl -X POST \"http://localhost:8766/api/pipes/standup-update/run?d=2026-04-25\"","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Rebuild and restart","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"to pick up the changes:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":23,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"cd /volume1/screenpipe/app\ndocker compose up --build -d","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"How it works:","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Each","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"pipe.md","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"file is loaded dynamically — the frontmatter provides metadata and the body becomes the user prompt. Screenpipe data (app usage, browser URLs, OCR, audio) is injected as a Claude system message so the pipe prompt can reference it naturally. The \"Read screenpipe skill first\" line is stripped automatically.","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"The pipes directory inside Docker is","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"/data/pipes","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"(since","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"/volume1/screenpipe","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"→","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"/data","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"). You can override it with a","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"PIPES_DIR","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"env var if needed.","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Message actions","depth":24,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"pipe.md","depth":23,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"pipe.md","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"where to place api key and can I use different keys","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read .env file","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"cat /volume1/screenpipe/app/.env","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ANTHROPIC_API_KEY=your_key_here","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Where to place the key:","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"app/.env","depth":23,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"app/.env","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"— replace","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"your_key_here","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"with your actual key:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":23,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"ANTHROPIC_API_KEY=sk-ant-...","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"That file is loaded by","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"load_dotenv()","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"at startup and is excluded from git via","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":".gitignore","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":".","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Can you use different keys per pipe?","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Not currently — all pipes share the one key from","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":".env","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":". But you can add per-pipe key support by adding an","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"api_key","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"field to the pipe's frontmatter:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":23,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"---\ntitle: Meeting Summary\napi_key_env: ANTHROPIC_KEY_MEETINGS\n---","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Then in","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"consumers/pipes.py","depth":23,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"consumers/pipes.py","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":", read it in","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"_parse_frontmatter","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"and pass it through","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"run_pipe","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":". Want me to add that?","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Message actions","depth":24,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"pipe.md","depth":23,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"pipe.md","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"can I use mistral or other llm? or is is build for antrophic only","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Currently it's Anthropic-only — the code calls the","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"anthropic","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"SDK directly in both","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"consumers/pipes.py","depth":23,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"consumers/pipes.py","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"and","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"consumers/summary.py","depth":23,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"consumers/summary.py","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":".","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Adding other providers is straightforward since Mistral, Ollama, OpenRouter, Groq, and most modern LLMs expose an OpenAI-compatible API. The cleanest approach: add the","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"openai","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"package and let you configure the provider via","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":".env","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":":","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":23,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"# Anthropic (default)\nANTHROPIC_API_KEY=sk-ant-...\n\n# OR: any OpenAI-compatible provider\nLLM_PROVIDER=openai-compatible\nLLM_BASE_URL=https://api.mistral.ai/v1\nLLM_API_KEY=your-mistral-key\nLLM_MODEL=mistral-small-latest","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"This would cover Mistral, Ollama (","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"http://localhost:11434/v1","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"), OpenRouter, Groq, etc. with one code path.","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Want me to implement that? It's a small change — a","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"_call_llm(system, user_prompt)","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"helper in","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"pipes.py","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"that branches on","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"LLM_PROVIDER","depth":24,"on_screen":false,"role_description":"text"}]...
|
-1148353860164294662
|
-8196324427125765908
|
idle
|
accessibility
|
NULL
|
Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧ Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py
M
db.py
docker-compose.yml
Dockerfile
M
main.py
M
requirements.txt
M
data
logs
pipes
.gitignore
app_settings.json
archive.db
archive.db-bak
U
db.sqlite
db.sqlite-shm
db.sqlite-wal
screenpipe_sync_updated.sh
U
screenpipe_sync.sh
screenpipe.db
Outline Section
OUTLINE
OUTLINE
Timeline Section
TIMELINE
TIMELINE
app_settings.json, Editor Group 1
screenpipe_sync.sh, Editor Group 1
pipe.md, Editor Group 1
.env, Editor Group 1
[ENV_SECRET]
[ENV_SECRET]
Implement and run pipe l…, Editor Group 2
Problems (⇧⌘M)
PROBLEMS
Output (⇧⌘U)
OUTPUT
Debug Console (⇧⌘Y)
DEBUG CONSOLE
Terminal (⌃`)
TERMINAL
Ports - 1 forwarded port
PORTS
1
remote SSH: nas
SSH: nas
screenpipe (Git) - master*, Checkout Branch/Tag...
master*
screenpipe (Git) - Synchronize Changes
No Problems
0
0
Forwarded Ports: 8766
1
Notifications
Sign In
Sign In
Info: Setting up SSH Host nas: Setting up SSH tunnel
Implement and run pipe logic
Session history
New session
Message actions
main.py
main.py
lets implement logic with pipes. how can I run it?
Thinking
Thinking
Let me look at the current project structure to understand what's already in place.
Bash
List project files
IN
find /volume1/screenpipe -type f | head -50 && echo "---" && ls /volume1/screenpipe
Copy code to clipboard
OUT
/volume1/screenpipe/.DS_Store
/volume1/screenpipe/screenpipe.db
/volume1/screenpipe/screenpipe_sync.sh
/volume1/screenpipe/app_settings.json
/volume1/screenpipe/.gitignore
/volume1/screenpipe/archive.db
/volume1/screenpipe/db.sqlite
/volume1/screenpipe/db.sqlite-wal
/volume1/screenpipe/db.sqlite-shm
/volume1/screenpipe/#recycle/desktop.ini
/volume1/screenpipe/#recycle/db.sqlite
/volume1/screenpipe/#recycle/Copy #1 of db.sqlite
/volume1/screenpipe/#recycle/.DS_Store
/volume1/screenpipe/#recycle/Copy #2 of db.sqlite
/volume1/screenpipe/#recycle/archive.db
/volume1/screenpipe/#recycle/Copy #1 of archive.db
/volume1/screenpipe/#recycle/Copy #2 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of archive.db
/volume1/screenpipe/#recycle/Copy #4 of archive.db
/volume1/screenpipe/#recycle/Copy #5 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of db.sqlite
/volume1/screenpipe/#recycle/Copy #4 of db.sqlite
/volume1/screenpipe/#recycle/Copy #6 of archive.db
/volume1/screenpipe/#recycle/test.txt
/volume1/screenpipe/#recycle/Copy #7 of archive.db
/volume1/screenpipe/#recycle/Copy #8 of archive.db
/volume1/screenpipe/#recycle/archive.db-journal
/volume1/screenpipe/#recycle/Copy #1 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #2 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #3 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #4 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #6 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #7 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of db.sqlite
/volume1/screenpipe/pipes/.DS_Store
/volume1/screenpipe/app/.env
/volume1/screenpipe/app/cli.py
/volume1/screenpipe/app/.DS_Store
/volume1/screenpipe/app/db.py
/volume1/screenpipe/app/docker-compose.yml
/volume1/screenpipe/app/main.py
/volume1/screenpipe/app/requirements.txt
/volume1/screenpipe/app/Dockerfile
/volume1/screenpipe/data/.DS_Store
/volume1/screenpipe/.git/description
/volume1/screenpipe/.git/HEAD
/volume1/screenpipe/.git/index
/volume1/screenpipe/.git/COMMIT_EDITMSG
/volume1/screenpipe/#recycle/data/.DS_Store
---
app
app_settings.json
archive.db
data
db.sqlite
db.sqlite-shm
db.sqlite-wal
pipes
#recycle
screenpipe.db
screenpipe_sync.sh
Read
main.py
main.py
Bash
Check pipes directory and docker-compose
IN
ls /volume1/screenpipe/pipes/ && ls /volume1/screenpipe/app/ && cat /volume1/screenpipe/app/docker-compose.yml
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
cli.py
consumers
db.py
docker-compose.yml
Dockerfile
main.py
__pycache__
requirements.txt
static
services:
screenpipe-app:
build: .
container_name: screenpipe-app
restart: unless-stopped
ports:
- "8766:8000"
volumes:
- /volume1/screenpipe:/data
env_file:
- .env
environment:
TZ: Europe/Sofia
DB_PATH: /data/db.sqlite
sqlite-web-archive:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-archive
restart: unless-stopped
ports:
- "8767:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/archive.db"]
sqlite-web-live:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-live
restart: unless-stopped
ports:
- "8768:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/db.sqlite"]
Read
requirements.txt
requirements.txt
Bash
Inspect a pipe directory
IN
ls /volume1/screenpipe/pipes/day-recap/ && cat /volume1/screenpipe/pipes/day-recap/pipe.json 2>/dev/null || ls /volume1/screenpipe/pipes/day-recap/
Copy code to clipboard
OUT
pipe.md
pipe.md
Read
cli.py
cli.py
Bash
List all pipes and their contents
IN
ls /volume1/screenpipe/pipes/ && for d in /volume1/screenpipe/pipes/*/; do echo "=== $d ==="; ls "$d"; done
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
=== /volume1/screenpipe/pipes/ai-habits/ ===
pipe.md
=== /volume1/screenpipe/pipes/day-recap/ ===
pipe.md
=== /volume1/screenpipe/pipes/meeting-summary/ ===
pipe.md
=== /volume1/screenpipe/pipes/standup-update/ ===
pipe.md
=== /volume1/screenpipe/pipes/time-breakdown/ ===
pipe.md
=== /volume1/screenpipe/pipes/video-export/ ===
pipe.md
Bash
Read pipe markdown files
IN
cat /volume1/screenpipe/pipes/day-recap/pipe.md && echo "===" && cat /volume1/screenpipe/pipes/meeting-summary/pipe.md 2>/dev/null | head -50
Copy code to clipboard
OUT
---
schedule: manual
enabled: true
template: true
title: Day Recap
description: "Today's accomplishments, key moments, and unfinished work"
icon: "📋"
featured: true
---
Analyze my screen and audio recordings from today (last 16 hours only).
Read screenpipe skill first.
Use this exact format:
## Summary
One sentence: what I mainly did today.
## Accomplishments
- Top 3 things I finished, with timestamps (e.g. "2:30 PM")
- Name specific apps, files, or projects
## Key Moments
- Important things I saw, said, or heard — with timestamps
## Unfinished Work
- What I should continue tomorrow — name the app/file/task
## Patterns
- Apps I used most, topics that came up repeatedly
Only report what you can verify from the data. End with: "**Next step:** [most important thing to continue]"
===
---
schedule: manual
enabled: true
template: true
title: Meeting Summary
description: "Summarize meeting transcript with key takeaways and action items"
icon: "🤝"
featured: false
---
Summarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.
Read screenpipe skill first.
Use this exact format:
## Meeting Summary
One sentence: what this meeting was about.
## Key Takeaways
- Top 3-5 important points discussed
- Include who said what when relevant
## Action Items
- [ ] Task — assigned to whom, deadline if mentioned
- [ ] Task — assigned to whom
## Decisions Made
- List any decisions or agreements reached
## Open Questions
- Anything unresolved or needing follow-up
Keep it concise and actionable.
Thinking
Thinking
Bash
Read summary consumer
IN
ls /volume1/screenpipe/app/consumers/ && cat /volume1/screenpipe/app/consumers/summary.py
Copy code to clipboard
OUT
activity.py
audio.py
elements.py
__init__.py
interactions.py
ocr.py
__pycache__
report.py
summary.py
"""AI summary generator using Claude."""
import os
from datetime import date
from typing import Any
from consumers.activity import app_time, summary_stats, browser_urls, ui_event_summary
from consumers.ocr import deduplicated_text
from consumers.audio import formatted_transcript
SUMMARY_TYPES = {
"day_recap": {
"title": "Day Recap",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
## Audio/speech:
{audio}
Write a concise day recap using EXACTLY this format:
## Summary
One sentence: what I mainly worked on today.
## Accomplishments
- Top 3 things I finished, with approximate times
- Name specific apps, files, or projects
## Key Moments
- Important things seen or heard, with timestamps
## Unfinished Work
- What to continue tomorrow
## Patterns
- Apps used most, topics that came up repeatedly
Only report what you can verify from the data. End with:
**Next step:** [most important thing to continue]""",
},
"standup": {
"title": "Standup Update",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
## Audio/speech:
{audio}
Write a brief standup update:
**Yesterday:** What I worked on (2-3 bullets)
**Today:** What I plan to continue (1-2 bullets)
**Blockers:** Any issues observed (or "None")
Keep it under 150 words. Only report what's verifiable from the data.""",
},
"focus_time": {
"title": "Focus & Distraction Analysis",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
Analyze focus vs distraction patterns:
## Deep Work Periods
- When and how long were sustained focus sessions?
- What was being worked on?
## Distractions
- Which apps/sites were used recreationally?
- How much time was lost to context switching?
## Recommendations
- 2-3 concrete suggestions to improve focus tomorrow
Be specific with times and app names.""",
},
}
def _build_context(for_date: date) -> dict[str, str]:
apps = app_time(for_date)
app_lines = "\n".join(f"- {a['app_name']}: {a['minutes']} min" for a in apps[:20])
urls = browser_urls(for_date, limit=20)
url_lines = "\n".join(
f"- {u['browser_url'][:100]} ({u['minutes']} min)" for u in urls
)
ui_rows = ui_event_summary(for_date)
ui_lines = "\n".join(
f"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches"
for r in ui_rows[:15]
)
ocr_rows = deduplicated_text(for_date, chunk_minutes=5)
ocr_lines = "\n".join(
f"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}"
for r in ocr_rows[:100]
)
audio = formatted_transcript(for_date)
return {
"app_time": app_lines or "(no app data)",
"browser_urls": url_lines or "(no browser data)",
"ui_events": ui_lines or "(no UI event data)",
"ocr_text": ocr_lines or "(no screen data)",
"audio": audio[:3000] if len(audio) > 3000 else audio,
}
def generate(
summary_type: str = "day_recap",
for_date: date | None = None,
api_key: str | None = None,
) -> dict[str, Any]:
"""Generate an AI summary. Returns dict with 'title', 'content', 'date'."""
import anthropic
d = for_date or date.today()
key = api_key or os.environ.get("ANTHROPIC_API_KEY", "")
if not key:
return {
"title": "Error",
"content": "ANTHROPIC_API_KEY not set. Add it to your .env file.",
"date": str(d),
}
spec = SUMMARY_TYPES.get(summary_type)
if not spec:
return {"title": "Error", "content": f"Unknown summary type: {summary_type}", "date": str(d)}
stats = summary_stats(d)
if stats["total_frames"] == 0:
return {
"title": spec["title"],
"content": f"No screen data found for {d}.",
"date": str(d),
}
ctx = _build_context(d)
prompt = spec["prompt"].format(**ctx)
client = anthropic.Anthropic(api_key=key)
message = client.messages.create(
model="claude-haiku-4-5-20251001",
max_tokens=1024,
messages=[{"role": "user", "content": prompt}],
)
return {
"title": spec["title"],
"content": message.content[0].text,
"date": str(d),
"stats": stats,
}
Thinking
Thinking
Bash
Read all pipe.md files
IN
for f in /volume1/screenpipe/pipes/*/pipe.md; do echo "=== $f ==="; cat "$f"; echo; done
Copy code to clipboard
OUT
=== /volume1/screenpipe/pipes/ai-habits/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: AI Habits
description: "How you use AI tools — patterns and insights"
icon: "🤖"
featured: true
---
Search my recordings from the last 24 hours for AI tool usage. Use app_name filter for each tool separately: ChatGPT, Claude, Copilot, Cursor, Gemini, Perplexity. Use limit=5 per search, max 6 searches total.
Read screenpipe skill first.
Use this exact format:
## AI Tools Used
- List each tool with approximate time spent (e.g. "Claude: ~45min")
## What I Used Them For
- For each tool: coding, writing, research, or brainstorming
## Usage Patterns
- Do I switch between tools? Use them in bursts or steadily?
## Effectiveness
- Which tool appeared alongside completed work vs. abandoned attempts
If no AI usage is found, say so clearly. End with: "**Tip:** [one suggestion to use AI tools more effectively]"
=== /volume1/screenpipe/pipes/day-recap/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Day Recap
description: "Today's accomplishments, key moments, and unfinished work"
icon: "📋"
featured: true
---
Analyze my screen and audio recordings from today (last 16 hours only).
Read screenpipe skill first.
Use this exact format:
## Summary
One sentence: what I mainly did today.
## Accomplishments
- Top 3 things I finished, with timestamps (e.g. "2:30 PM")
- Name specific apps, files, or projects
## Key Moments
- Important things I saw, said, or heard — with timestamps
## Unfinished Work
- What I should continue tomorrow — name the app/file/task
## Patterns
- Apps I used most, topics that came up repeatedly
Only report what you can verify from the data. End with: "**Next step:** [most important thing to continue]"
=== /volume1/screenpipe/pipes/meeting-summary/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Meeting Summary
description: "Summarize meeting transcript with key takeaways and action items"
icon: "🤝"
featured: false
---
Summarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.
Read screenpipe skill first.
Use this exact format:
## Meeting Summary
One sentence: what this meeting was about.
## Key Takeaways
- Top 3-5 important points discussed
- Include who said what when relevant
## Action Items
- [ ] Task — assigned to whom, deadline if mentioned
- [ ] Task — assigned to whom
## Decisions Made
- List any decisions or agreements reached
## Open Questions
- Anything unresolved or needing follow-up
Keep it concise and actionable.
=== /volume1/screenpipe/pipes/standup-update/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Standup Update
description: "What you did, what's next, and any blockers"
icon: "🏢"
featured: true
---
Based on my recordings from the last 24 hours, generate a standup update. Use limit=10 per search, max 3 searches total.
Read screenpipe skill first.
Use this exact format:
## Yesterday
- What I worked on (name specific projects, files, tools, PRs)
## Today
- What I will work on next (based on unfinished tasks and recent activity)
## Blockers
- Issues I hit — errors, slow builds, waiting on someone
- If no blockers, write "None"
Keep it under 150 words. Copy-paste ready for a team standup.
=== /volume1/screenpipe/pipes/time-breakdown/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Time Breakdown
description: "Where your time went — by app, project, and category"
icon: "⏱"
featured: false
---
Analyze my app usage from today (last 12 hours). Use limit=10 per search, max 4 searches. Prefer /raw_sql with COUNT/GROUP BY queries.
Read screenpipe skill first.
Use this exact format with durations and percentages:
## By Application
- List each app with duration and percentage, sorted by time (e.g. "VS Code: 2h 15min (28%)")
## By Category
- Group into: coding, meetings, browsing, writing, communication, other
- Show hours and percentage per category
## By Project
- Group related activities by project/topic. Name specific repos or tasks.
## Productivity Score
- Calculate: focused_work_hours / total_hours as a percentage
- Focused = coding + writing. Unfocused = browsing + switching.
End with: "**Suggestion:** [one specific change to improve tomorrow's productivity]"
=== /volume1/screenpipe/pipes/video-export/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Export Video Clip
description: "Create a video of your recent screen activity"
icon: "🎬"
featured: false
---
Export a video of my screen activity from the last 5 minutes.
Read screenpipe skill first.
Use the POST /frames/export endpoint with the time range and fps=1.0. Then show me the exported video file path as an inline code block so I can watch it.
If the export is large, suggest a lower fps or shorter time range.
Thinking
Thinking
Now I have a clear picture. The pipes are markdown prompt templates in
/volume1/screenpipe/pipes/
, but there's no code to actually load and run them —
consumers/summary.py
has its own hardcoded prompts instead.
Here's what I'll implement:
consumers/pipes.py
— dynamically loads pipe.md files and runs them via Claude (data injected as system message, pipe body as user prompt)
main.py
— two new endpoints:
GET /api/pipes
and
POST /api/pipes/{pipe_id}/run
cli.py
— a
pipe
command to run pipes from the terminal
Let me build it:
Bash
Check browser_urls signature
IN
cat /volume1/screenpipe/app/consumers/activity.py | grep "def browser_urls" -A 5
Copy code to clipboard
OUT
def browser_urls(
for_date: date | None = None,
app_name: str | None = None,
ts_from: str | None = None,
ts_to: str | None = None,
limit: int = 30,
Write
pipes.py
pipes.py
143 lines
"""Dynamic pipe loader and runner."""
import os
import re
from datetime import date
from pathlib import Path
from typing import Any
def _parse_frontmatter(text: str) -> tuple[dict, str]:
if not text.startswith("---"):
return {}, text
try:
end = text.index("---", 3)
except ValueError:
return {}, text
fm_text = text[3:end].strip()
body = text[end + 3:].strip()
meta: dict = {}
for line in fm_text.splitlines():
if ":" in line:
k, _, v = line.partition(":")
meta[k.strip()] = v.strip().strip('"')
return meta, body
def load_pipes(pipes_dir: Path) -> list[dict]:
if not pipes_dir.exists():
return []
pipes = []
for pipe_dir in sorted(pipes_dir.iterdir()):
if not pipe_dir.is_dir() or pipe_dir.name.startswith("."):
continue
pipe_md = pipe_dir / "pipe.md"
if not pipe_md.exists():
continue
text = pipe_md.read_text(encoding="utf-8")
meta, body = _parse_frontmatter(text)
if meta.get("enabled", "true").lower() == "false":
continue
body = re.sub(r"Read screenpipe skill first\.?\n?", "", body).strip()
pipes.append({
"id": pipe_dir.name,
"title": meta.get("title", pipe_dir.name),
"description": meta.get("description", ""),
"icon": meta.get("icon", ""),
"schedule": meta.get("schedule", "manual"),
"featured": meta.get("featured", "false").lower() == "true",
"prompt": body,
})
return pipes
def _build_system(d: date, stats: dict) -> str:
from consumers.activity import app_time, browser_urls, ui_event_summary
from consumers.ocr import deduplicated_text
from consumers.audio import formatted_transcript
apps = app_time(d)
app_lines = "\n".join(f"- {a['app_name']}: {a['minutes']} min" for a in apps[:20])
urls = browser_urls(d, limit=20)
url_lines = "\n".join(f"- {u['browser_url'][:100]} ({u['minutes']} min)" for u in urls)
ui_rows = ui_event_summary(d)
ui_lines = "\n".join(
f"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches"
for r in ui_rows[:15]
)
ocr_rows = deduplicated_text(d, chunk_minutes=5)
ocr_lines = "\n".join(
f"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}"
for r in ocr_rows[:100]
)
audio = formatted_transcript(d)
if len(audio) > 3000:
audio = audio[:3000]
return f"""You are analyzing screenpipe data — recordings of a person's computer activity.
## App usage (minutes per app):
{app_lines or '(no app data)'}
## Browser URLs visited:
{url_lines or '(no browser data)'}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_lines or '(no UI event data)'}
## Screen content (sampled every 5 minutes):
{ocr_lines or '(no screen data)'}
## Audio / speech:
{audio or '(no audio data)'}
Date: {d}
Total frames recorded: {stats['total_frames']}"""
def run_pipe(
pipe_id: str,
for_date: date | None = None,
api_key: str | None = None,
pipes_dir: Path | None = None,
) -> dict[str, Any]:
import anthropic
from consumers.activity import summary_stats
d = for_date or date.today()
key = api_key or os.environ.get("ANTHROPIC_API_KEY", "")
if not key:
return {"title": "Error", "content": "ANTHROPIC_API_KEY not set.", "date": str(d)}
_pipes_dir = pipes_dir or Path(os.environ.get("PIPES_DIR", "/data/pipes"))
all_pipes = {p["id"]: p for p in load_pipes(_pipes_dir)}
if pipe_id not in all_pipes:
return {"title": "Error", "content": f"Pipe not found: {pipe_id}", "date": str(d)}
pipe = all_pipes[pipe_id]
stats = summary_stats(d)
if stats["total_frames"] == 0:
return {"title": pipe["title"], "content": f"No screen data found for {d}.", "date": str(d)}
system = _build_system(d, stats)
client = anthropic.Anthropic(api_key=key)
message = client.messages.create(
model="claude-haiku-4-5-20251001",
max_tokens=1024,
system=system,
messages=[{"role": "user", "content": pipe["prompt"]}],
)
return {
"title": pipe["title"],
"content": message.content[0].text,
"date": str(d),
"stats": stats,
}
Now add the API endpoints to
main.py
:
Edit
main.py
main.py
Added 1 line
Edit
main.py
main.py
Added 1 line
Now add the pipe endpoints at the end of main.py, before the closing summary section:
Edit
main.py
main.py
Added 14 lines
Now add the CLI command to
cli.py
cli.py
:
Edit
cli.py
cli.py
Added 40 lines
Done. Here's how to run pipes:
How to run pipes
How to run pipes
Via Docker (inside the running container):
Copy code to clipboard
docker exec -it screenpipe-app python cli.py pipe --list
docker exec -it screenpipe-app python cli.py pipe day-recap
docker exec -it screenpipe-app python cli.py pipe standup-update --date yesterday
Via the API
(once the container is running on port 8766):
Copy code to clipboard
# List pipes
curl http://localhost:8766/api/pipes
# Run a pipe
curl -X POST "http://localhost:8766/api/pipes/day-recap/run"
curl -X POST "http://localhost:8766/api/pipes/standup-update/run?d=2026-04-25"
Rebuild and restart
to pick up the changes:
Copy code to clipboard
cd /volume1/screenpipe/app
docker compose up --build -d
How it works:
Each
pipe.md
file is loaded dynamically — the frontmatter provides metadata and the body becomes the user prompt. Screenpipe data (app usage, browser URLs, OCR, audio) is injected as a Claude system message so the pipe prompt can reference it naturally. The "Read screenpipe skill first" line is stripped automatically.
The pipes directory inside Docker is
/data/pipes
(since
/volume1/screenpipe
→
/data
). You can override it with a
PIPES_DIR
env var if needed.
Message actions
pipe.md
pipe.md
where to place api key and can I use different keys
Thinking
Thinking
Bash
Read .env file
IN
cat /volume1/screenpipe/app/.env
Copy code to clipboard
OUT
[ENV_SECRET]
Where to place the key:
app/.env
app/.env
— replace
your_key_here
with your actual key:
Copy code to clipboard
[ENV_SECRET]
That file is loaded by
load_dotenv()
at startup and is excluded from git via
.gitignore
.
Can you use different keys per pipe?
Not currently — all pipes share the one key from
.env
. But you can add per-pipe key support by adding an
api_key
field to the pipe's frontmatter:
Copy code to clipboard
---
title: Meeting Summary
api_key_env: ANTHROPIC_KEY_MEETINGS
---
Then in
consumers/pipes.py
consumers/pipes.py
, read it in
_parse_frontmatter
and pass it through
run_pipe
. Want me to add that?
Message actions
pipe.md
pipe.md
can I use mistral or other llm? or is is build for antrophic only
Thinking
Thinking
Currently it's Anthropic-only — the code calls the
anthropic
SDK directly in both
consumers/pipes.py
consumers/pipes.py
and
consumers/summary.py
consumers/summary.py
.
Adding other providers is straightforward since Mistral, Ollama, OpenRouter, Groq, and most modern LLMs expose an OpenAI-compatible API. The cleanest approach: add the
openai
package and let you configure the provider via
.env
:
Copy code to clipboard
# Anthropic (default)
[ENV_SECRET]
# OR: any OpenAI-compatible provider
LLM_PROVIDER=openai-compatible
LLM_BASE_URL=https://api.mistral.ai/v1
[ENV_SECRET]
LLM_MODEL=mistral-small-latest
This would cover Mistral, Ollama (
http://localhost:11434/v1
), OpenRouter, Groq, etc. with one code path.
Want me to implement that? It's a small change — a
_call_llm(system, user_prompt)
helper in
pipes.py
that branches on
LLM_PROVIDER...
|
21071
|
NULL
|
NULL
|
NULL
|
|
21074
|
920
|
7
|
2026-05-11T17:09:49.076795+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-11/1778 /Users/lukas/.screenpipe/data/data/2026-05-11/1778519389076_m1.jpg...
|
Code
|
Implement and run pipe l… — screenpipe [SSH: nas]
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧ Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py
M
db.py
docker-compose.yml
Dockerfile
M
main.py
M
requirements.txt
M
data
logs
pipes
.gitignore
app_settings.json
archive.db
archive.db-bak
U
db.sqlite
db.sqlite-shm
db.sqlite-wal
screenpipe_sync_updated.sh
U
screenpipe_sync.sh
screenpipe.db
Outline Section
OUTLINE
OUTLINE
Timeline Section
TIMELINE
TIMELINE
app_settings.json, Editor Group 1
screenpipe_sync.sh, Editor Group 1
pipe.md, Editor Group 1
.env, Editor Group 1
[ENV_SECRET]
[ENV_SECRET]
Implement and run pipe l…, Editor Group 2
Problems (⇧⌘M)
PROBLEMS
Output (⇧⌘U)
OUTPUT
Debug Console (⇧⌘Y)
DEBUG CONSOLE
Terminal (⌃`)
TERMINAL
Ports - 1 forwarded port
PORTS
1
remote SSH: nas
SSH: nas
screenpipe (Git) - master*, Checkout Branch/Tag...
master*
screenpipe (Git) - Synchronize Changes
No Problems
0
0
Forwarded Ports: 8766
1
Notifications
Sign In
Sign In
Info: Setting up SSH Host nas: Setting up SSH tunnel
Implement and run pipe logic
Session history
New session
Message actions
main.py
main.py
lets implement logic with pipes. how can I run it?
Thinking
Thinking
Let me look at the current project structure to understand what's already in place.
Bash
List project files
IN
find /volume1/screenpipe -type f | head -50 && echo "---" && ls /volume1/screenpipe
Copy code to clipboard
OUT
/volume1/screenpipe/.DS_Store
/volume1/screenpipe/screenpipe.db
/volume1/screenpipe/screenpipe_sync.sh
/volume1/screenpipe/app_settings.json
/volume1/screenpipe/.gitignore
/volume1/screenpipe/archive.db
/volume1/screenpipe/db.sqlite
/volume1/screenpipe/db.sqlite-wal
/volume1/screenpipe/db.sqlite-shm
/volume1/screenpipe/#recycle/desktop.ini
/volume1/screenpipe/#recycle/db.sqlite
/volume1/screenpipe/#recycle/Copy #1 of db.sqlite
/volume1/screenpipe/#recycle/.DS_Store
/volume1/screenpipe/#recycle/Copy #2 of db.sqlite
/volume1/screenpipe/#recycle/archive.db
/volume1/screenpipe/#recycle/Copy #1 of archive.db
/volume1/screenpipe/#recycle/Copy #2 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of archive.db
/volume1/screenpipe/#recycle/Copy #4 of archive.db
/volume1/screenpipe/#recycle/Copy #5 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of db.sqlite
/volume1/screenpipe/#recycle/Copy #4 of db.sqlite
/volume1/screenpipe/#recycle/Copy #6 of archive.db
/volume1/screenpipe/#recycle/test.txt
/volume1/screenpipe/#recycle/Copy #7 of archive.db
/volume1/screenpipe/#recycle/Copy #8 of archive.db
/volume1/screenpipe/#recycle/archive.db-journal
/volume1/screenpipe/#recycle/Copy #1 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #2 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #3 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #4 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #6 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #7 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of db.sqlite
/volume1/screenpipe/pipes/.DS_Store
/volume1/screenpipe/app/.env
/volume1/screenpipe/app/cli.py
/volume1/screenpipe/app/.DS_Store
/volume1/screenpipe/app/db.py
/volume1/screenpipe/app/docker-compose.yml
/volume1/screenpipe/app/main.py
/volume1/screenpipe/app/requirements.txt
/volume1/screenpipe/app/Dockerfile
/volume1/screenpipe/data/.DS_Store
/volume1/screenpipe/.git/description
/volume1/screenpipe/.git/HEAD
/volume1/screenpipe/.git/index
/volume1/screenpipe/.git/COMMIT_EDITMSG
/volume1/screenpipe/#recycle/data/.DS_Store
---
app
app_settings.json
archive.db
data
db.sqlite
db.sqlite-shm
db.sqlite-wal
pipes
#recycle
screenpipe.db
screenpipe_sync.sh
Read
main.py
main.py
Bash
Check pipes directory and docker-compose
IN
ls /volume1/screenpipe/pipes/ && ls /volume1/screenpipe/app/ && cat /volume1/screenpipe/app/docker-compose.yml
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
cli.py
consumers
db.py
docker-compose.yml
Dockerfile
main.py
__pycache__
requirements.txt
static
services:
screenpipe-app:
build: .
container_name: screenpipe-app
restart: unless-stopped
ports:
- "8766:8000"
volumes:
- /volume1/screenpipe:/data
env_file:
- .env
environment:
TZ: Europe/Sofia
DB_PATH: /data/db.sqlite
sqlite-web-archive:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-archive
restart: unless-stopped
ports:
- "8767:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/archive.db"]
sqlite-web-live:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-live
restart: unless-stopped
ports:
- "8768:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/db.sqlite"]
Read
requirements.txt
requirements.txt
Bash
Inspect a pipe directory
IN
ls /volume1/screenpipe/pipes/day-recap/ && cat /volume1/screenpipe/pipes/day-recap/pipe.json 2>/dev/null || ls /volume1/screenpipe/pipes/day-recap/
Copy code to clipboard
OUT
pipe.md
pipe.md
Read
cli.py
cli.py
Bash
List all pipes and their contents
IN
ls /volume1/screenpipe/pipes/ && for d in /volume1/screenpipe/pipes/*/; do echo "=== $d ==="; ls "$d"; done
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
=== /volume1/screenpipe/pipes/ai-habits/ ===
pipe.md
=== /volume1/screenpipe/pipes/day-recap/ ===
pipe.md
=== /volume1/screenpipe/pipes/meeting-summary/ ===
pipe.md
=== /volume1/screenpipe/pipes/standup-update/ ===
pipe.md
=== /volume1/screenpipe/pipes/time-breakdown/ ===
pipe.md
=== /volume1/screenpipe/pipes/video-export/ ===
pipe.md
Bash
Read pipe markdown files
IN
cat /volume1/screenpipe/pipes/day-recap/pipe.md && echo "===" && cat /volume1/screenpipe/pipes/meeting-summary/pipe.md 2>/dev/null | head -50
Copy code to clipboard
OUT
---
schedule: manual
enabled: true
template: true
title: Day Recap
description: "Today's accomplishments, key moments, and unfinished work"
icon: "📋"
featured: true
---
Analyze my screen and audio recordings from today (last 16 hours only).
Read screenpipe skill first.
Use this exact format:
## Summary
One sentence: what I mainly did today.
## Accomplishments
- Top 3 things I finished, with timestamps (e.g. "2:30 PM")
- Name specific apps, files, or projects
## Key Moments
- Important things I saw, said, or heard — with timestamps
## Unfinished Work
- What I should continue tomorrow — name the app/file/task
## Patterns
- Apps I used most, topics that came up repeatedly
Only report what you can verify from the data. End with: "**Next step:** [most important thing to continue]"
===
---
schedule: manual
enabled: true
template: true
title: Meeting Summary
description: "Summarize meeting transcript with key takeaways and action items"
icon: "🤝"
featured: false
---
Summarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.
Read screenpipe skill first.
Use this exact format:
## Meeting Summary
One sentence: what this meeting was about.
## Key Takeaways
- Top 3-5 important points discussed
- Include who said what when relevant
## Action Items
- [ ] Task — assigned to whom, deadline if mentioned
- [ ] Task — assigned to whom
## Decisions Made
- List any decisions or agreements reached
## Open Questions
- Anything unresolved or needing follow-up
Keep it concise and actionable.
Thinking
Thinking
Bash
Read summary consumer
IN
ls /volume1/screenpipe/app/consumers/ && cat /volume1/screenpipe/app/consumers/summary.py
Copy code to clipboard
OUT
activity.py
audio.py
elements.py
__init__.py
interactions.py
ocr.py
__pycache__
report.py
summary.py
"""AI summary generator using Claude."""
import os
from datetime import date
from typing import Any
from consumers.activity import app_time, summary_stats, browser_urls, ui_event_summary
from consumers.ocr import deduplicated_text
from consumers.audio import formatted_transcript
SUMMARY_TYPES = {
"day_recap": {
"title": "Day Recap",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
## Audio/speech:
{audio}
Write a concise day recap using EXACTLY this format:
## Summary
One sentence: what I mainly worked on today.
## Accomplishments
- Top 3 things I finished, with approximate times
- Name specific apps, files, or projects
## Key Moments
- Important things seen or heard, with timestamps
## Unfinished Work
- What to continue tomorrow
## Patterns
- Apps used most, topics that came up repeatedly
Only report what you can verify from the data. End with:
**Next step:** [most important thing to continue]""",
},
"standup": {
"title": "Standup Update",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
## Audio/speech:
{audio}
Write a brief standup update:
**Yesterday:** What I worked on (2-3 bullets)
**Today:** What I plan to continue (1-2 bullets)
**Blockers:** Any issues observed (or "None")
Keep it under 150 words. Only report what's verifiable from the data.""",
},
"focus_time": {
"title": "Focus & Distraction Analysis",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
Analyze focus vs distraction patterns:
## Deep Work Periods
- When and how long were sustained focus sessions?
- What was being worked on?
## Distractions
- Which apps/sites were used recreationally?
- How much time was lost to context switching?
## Recommendations
- 2-3 concrete suggestions to improve focus tomorrow
Be specific with times and app names.""",
},
}
def _build_context(for_date: date) -> dict[str, str]:
apps = app_time(for_date)
app_lines = "\n".join(f"- {a['app_name']}: {a['minutes']} min" for a in apps[:20])
urls = browser_urls(for_date, limit=20)
url_lines = "\n".join(
f"- {u['browser_url'][:100]} ({u['minutes']} min)" for u in urls
)
ui_rows = ui_event_summary(for_date)
ui_lines = "\n".join(
f"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches"
for r in ui_rows[:15]
)
ocr_rows = deduplicated_text(for_date, chunk_minutes=5)
ocr_lines = "\n".join(
f"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}"
for r in ocr_rows[:100]
)
audio = formatted_transcript(for_date)
return {
"app_time": app_lines or "(no app data)",
"browser_urls": url_lines or "(no browser data)",
"ui_events": ui_lines or "(no UI event data)",
"ocr_text": ocr_lines or "(no screen data)",
"audio": audio[:3000] if len(audio) > 3000 else audio,
}
def generate(
summary_type: str = "day_recap",
for_date: date | None = None,
api_key: str | None = None,
) -> dict[str, Any]:
"""Generate an AI summary. Returns dict with 'title', 'content', 'date'."""
import anthropic
d = for_date or date.today()
key = api_key or os.environ.get("ANTHROPIC_API_KEY", "")
if not key:
return {
"title": "Error",
"content": "ANTHROPIC_API_KEY not set. Add it to your .env file.",
"date": str(d),
}
spec = SUMMARY_TYPES.get(summary_type)
if not spec:
return {"title": "Error", "content": f"Unknown summary type: {summary_type}", "date": str(d)}
stats = summary_stats(d)
if stats["total_frames"] == 0:
return {
"title": spec["title"],
"content": f"No screen data found for {d}.",
"date": str(d),
}
ctx = _build_context(d)
prompt = spec["prompt"].format(**ctx)
client = anthropic.Anthropic(api_key=key)
message = client.messages.create(
model="claude-haiku-4-5-20251001",
max_tokens=1024,
messages=[{"role": "user", "content": prompt}],
)
return {
"title": spec["title"],
"content": message.content[0].text,
"date": str(d),
"stats": stats,
}
Thinking
Thinking
Bash
Read all pipe.md files
IN
for f in /volume1/screenpipe/pipes/*/pipe.md; do echo "=== $f ==="; cat "$f"; echo; done
Copy code to clipboard
OUT
=== /volume1/screenpipe/pipes/ai-habits/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: AI Habits
description: "How you use AI tools — patterns and insights"
icon: "🤖"
featured: true
---
Search my recordings from the last 24 hours for AI tool usage. Use app_name filter for each tool separately: ChatGPT, Claude, Copilot, Cursor, Gemini, Perplexity. Use limit=5 per search, max 6 searches total.
Read screenpipe skill first.
Use this exact format:
## AI Tools Used
- List each tool with approximate time spent (e.g. "Claude: ~45min")
## What I Used Them For
- For each tool: coding, writing, research, or brainstorming
## Usage Patterns
- Do I switch between tools? Use them in bursts or steadily?
## Effectiveness
- Which tool appeared alongside completed work vs. abandoned attempts
If no AI usage is found, say so clearly. End with: "**Tip:** [one suggestion to use AI tools more effectively]"
=== /volume1/screenpipe/pipes/day-recap/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Day Recap
description: "Today's accomplishments, key moments, and unfinished work"
icon: "📋"
featured: true
---
Analyze my screen and audio recordings from today (last 16 hours only).
Read screenpipe skill first.
Use this exact format:
## Summary
One sentence: what I mainly did today.
## Accomplishments
- Top 3 things I finished, with timestamps (e.g. "2:30 PM")
- Name specific apps, files, or projects
## Key Moments
- Important things I saw, said, or heard — with timestamps
## Unfinished Work
- What I should continue tomorrow — name the app/file/task
## Patterns
- Apps I used most, topics that came up repeatedly
Only report what you can verify from the data. End with: "**Next step:** [most important thing to continue]"
=== /volume1/screenpipe/pipes/meeting-summary/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Meeting Summary
description: "Summarize meeting transcript with key takeaways and action items"
icon: "🤝"
featured: false
---
Summarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.
Read screenpipe skill first.
Use this exact format:
## Meeting Summary
One sentence: what this meeting was about.
## Key Takeaways
- Top 3-5 important points discussed
- Include who said what when relevant
## Action Items
- [ ] Task — assigned to whom, deadline if mentioned
- [ ] Task — assigned to whom
## Decisions Made
- List any decisions or agreements reached
## Open Questions
- Anything unresolved or needing follow-up
Keep it concise and actionable.
=== /volume1/screenpipe/pipes/standup-update/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Standup Update
description: "What you did, what's next, and any blockers"
icon: "🏢"
featured: true
---
Based on my recordings from the last 24 hours, generate a standup update. Use limit=10 per search, max 3 searches total.
Read screenpipe skill first.
Use this exact format:
## Yesterday
- What I worked on (name specific projects, files, tools, PRs)
## Today
- What I will work on next (based on unfinished tasks and recent activity)
## Blockers
- Issues I hit — errors, slow builds, waiting on someone
- If no blockers, write "None"
Keep it under 150 words. Copy-paste ready for a team standup.
=== /volume1/screenpipe/pipes/time-breakdown/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Time Breakdown
description: "Where your time went — by app, project, and category"
icon: "⏱"
featured: false
---
Analyze my app usage from today (last 12 hours). Use limit=10 per search, max 4 searches. Prefer /raw_sql with COUNT/GROUP BY queries.
Read screenpipe skill first.
Use this exact format with durations and percentages:
## By Application
- List each app with duration and percentage, sorted by time (e.g. "VS Code: 2h 15min (28%)")
## By Category
- Group into: coding, meetings, browsing, writing, communication, other
- Show hours and percentage per category
## By Project
- Group related activities by project/topic. Name specific repos or tasks.
## Productivity Score
- Calculate: focused_work_hours / total_hours as a percentage
- Focused = coding + writing. Unfocused = browsing + switching.
End with: "**Suggestion:** [one specific change to improve tomorrow's productivity]"
=== /volume1/screenpipe/pipes/video-export/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Export Video Clip
description: "Create a video of your recent screen activity"
icon: "🎬"
featured: false
---
Export a video of my screen activity from the last 5 minutes.
Read screenpipe skill first.
Use the POST /frames/export endpoint with the time range and fps=1.0. Then show me the exported video file path as an inline code block so I can watch it.
If the export is large, suggest a lower fps or shorter time range.
Thinking
Thinking
Now I have a clear picture. The pipes are markdown prompt templates in
/volume1/screenpipe/pipes/
, but there's no code to actually load and run them —
consumers/summary.py
has its own hardcoded prompts instead.
Here's what I'll implement:
consumers/pipes.py
— dynamically loads pipe.md files and runs them via Claude (data injected as system message, pipe body as user prompt)
main.py
— two new endpoints:
GET /api/pipes
and
POST /api/pipes/{pipe_id}/run
cli.py
— a
pipe
command to run pipes from the terminal
Let me build it:
Bash
Check browser_urls signature
IN
cat /volume1/screenpipe/app/consumers/activity.py | grep "def browser_urls" -A 5
Copy code to clipboard
OUT
def browser_urls(
for_date: date | None = None,
app_name: str | None = None,
ts_from: str | None = None,
ts_to: str | None = None,
limit: int = 30,
Write
pipes.py
pipes.py
143 lines
"""Dynamic pipe loader and runner."""
import os
import re
from datetime import date
from pathlib import Path
from typing import Any
def _parse_frontmatter(text: str) -> tuple[dict, str]:
if not text.startswith("---"):
return {}, text
try:
end = text.index("---", 3)
except ValueError:
return {}, text
fm_text = text[3:end].strip()
body = text[end + 3:].strip()
meta: dict = {}
for line in fm_text.splitlines():
if ":" in line:
k, _, v = line.partition(":")
meta[k.strip()] = v.strip().strip('"')
return meta, body
def load_pipes(pipes_dir: Path) -> list[dict]:
if not pipes_dir.exists():
return []
pipes = []
for pipe_dir in sorted(pipes_dir.iterdir()):
if not pipe_dir.is_dir() or pipe_dir.name.startswith("."):
continue
pipe_md = pipe_dir / "pipe.md"
if not pipe_md.exists():
continue
text = pipe_md.read_text(encoding="utf-8")
meta, body = _parse_frontmatter(text)
if meta.get("enabled", "true").lower() == "false":
continue
body = re.sub(r"Read screenpipe skill first\.?\n?", "", body).strip()
pipes.append({
"id": pipe_dir.name,
"title": meta.get("title", pipe_dir.name),
"description": meta.get("description", ""),
"icon": meta.get("icon", ""),
"schedule": meta.get("schedule", "manual"),
"featured": meta.get("featured", "false").lower() == "true",
"prompt": body,
})
return pipes
def _build_system(d: date, stats: dict) -> str:
from consumers.activity import app_time, browser_urls, ui_event_summary
from consumers.ocr import deduplicated_text
from consumers.audio import formatted_transcript
apps = app_time(d)
app_lines = "\n".join(f"- {a['app_name']}: {a['minutes']} min" for a in apps[:20])
urls = browser_urls(d, limit=20)
url_lines = "\n".join(f"- {u['browser_url'][:100]} ({u['minutes']} min)" for u in urls)
ui_rows = ui_event_summary(d)
ui_lines = "\n".join(
f"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches"
for r in ui_rows[:15]
)
ocr_rows = deduplicated_text(d, chunk_minutes=5)
ocr_lines = "\n".join(
f"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}"
for r in ocr_rows[:100]
)
audio = formatted_transcript(d)
if len(audio) > 3000:
audio = audio[:3000]
return f"""You are analyzing screenpipe data — recordings of a person's computer activity.
## App usage (minutes per app):
{app_lines or '(no app data)'}
## Browser URLs visited:
{url_lines or '(no browser data)'}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_lines or '(no UI event data)'}
## Screen content (sampled every 5 minutes):
{ocr_lines or '(no screen data)'}
## Audio / speech:
{audio or '(no audio data)'}
Date: {d}
Total frames recorded: {stats['total_frames']}"""
def run_pipe(
pipe_id: str,
for_date: date | None = None,
api_key: str | None = None,
pipes_dir: Path | None = None,
) -> dict[str, Any]:
import anthropic
from consumers.activity import summary_stats
d = for_date or date.today()
key = api_key or os.environ.get("ANTHROPIC_API_KEY", "")
if not key:
return {"title": "Error", "content": "ANTHROPIC_API_KEY not set.", "date": str(d)}
_pipes_dir = pipes_dir or Path(os.environ.get("PIPES_DIR", "/data/pipes"))
all_pipes = {p["id"]: p for p in load_pipes(_pipes_dir)}
if pipe_id not in all_pipes:
return {"title": "Error", "content": f"Pipe not found: {pipe_id}", "date": str(d)}
pipe = all_pipes[pipe_id]
stats = summary_stats(d)
if stats["total_frames"] == 0:
return {"title": pipe["title"], "content": f"No screen data found for {d}.", "date": str(d)}
system = _build_system(d, stats)
client = anthropic.Anthropic(api_key=key)
message = client.messages.create(
model="claude-haiku-4-5-20251001",
max_tokens=1024,
system=system,
messages=[{"role": "user", "content": pipe["prompt"]}],
)
return {
"title": pipe["title"],
"content": message.content[0].text,
"date": str(d),
"stats": stats,
}
Now add the API endpoints to
main.py
:
Edit
main.py
main.py
Added 1 line
Edit
main.py
main.py
Added 1 line
Now add the pipe endpoints at the end of main.py, before the closing summary section:
Edit
main.py
main.py
Added 14 lines
Now add the CLI command to
cli.py
cli.py
:
Edit
cli.py
cli.py
Added 40 lines
Done. Here's how to run pipes:
How to run pipes
How to run pipes
Via Docker (inside the running container):
Copy code to clipboard
docker exec -it screenpipe-app python cli.py pipe --list
docker exec -it screenpipe-app python cli.py pipe day-recap
docker exec -it screenpipe-app python cli.py pipe standup-update --date yesterday
Via the API
(once the container is running on port 8766):
Copy code to clipboard
# List pipes
curl http://localhost:8766/api/pipes
# Run a pipe
curl -X POST "http://localhost:8766/api/pipes/day-recap/run"
curl -X POST "http://localhost:8766/api/pipes/standup-update/run?d=2026-04-25"
Rebuild and restart
to pick up the changes:
Copy code to clipboard
cd /volume1/screenpipe/app
docker compose up --build -d
How it works:
Each
pipe.md
file is loaded dynamically — the frontmatter provides metadata and the body becomes the user prompt. Screenpipe data (app usage, browser URLs, OCR, audio) is injected as a Claude system message so the pipe prompt can reference it naturally. The "Read screenpipe skill first" line is stripped automatically.
The pipes directory inside Docker is
/data/pipes
(since
/volume1/screenpipe
→
/data
). You can override it with a
PIPES_DIR
env var if needed.
Message actions
pipe.md
pipe.md
where to place api key and can I use different keys
Thinking
Thinking
Bash
Read .env file
IN
cat /volume1/screenpipe/app/.env
Copy code to clipboard
OUT
[ENV_SECRET]
Where to place the key:
app/.env
app/.env
— replace
your_key_here
with your actual key:
Copy code to clipboard
[ENV_SECRET]
That file is loaded by
load_dotenv()
at startup and is excluded from git via
.gitignore
.
Can you use different keys per pipe?
Not currently — all pipes share the one key from
.env
. But you can add per-pipe key support by adding an
api_key
field to the pipe's frontmatter:
Copy code to clipboard
---
title: Meeting Summary
api_key_env: ANTHROPIC_KEY_MEETINGS
---
Then in
consumers/pipes.py
consumers/pipes.py
, read it in...
|
[{"role":"AXRadioButton","text [{"role":"AXRadioButton","text":"Explorer (⇧⌘E)","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":true},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Search (⇧⌘F)","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Source Control (⌃⇧G) - 10 pending changes","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"10","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Run and Debug (⇧⌘D)","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Remote Explorer","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Extensions (⇧⌘X) - 2 require update","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"2","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Claude Code","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"Containers","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXHeading","text":"EXPLORER","depth":17,"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"EXPLORER","depth":18,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Explorer Section: screenpipe [SSH: nas]","depth":21,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":true},{"role":"AXStaticText","text":"","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"Explorer Section: screenpipe [SSH: nas]","depth":22,"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"SCREENPIPE [SSH: NAS]","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"#recycle","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"app","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"__pycache__","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"consumers","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"static","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":".env","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"cli.py","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.py","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"docker-compose.yml","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Dockerfile","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"main.py","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"requirements.txt","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"data","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"logs","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"pipes","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":".gitignore","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"app_settings.json","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"archive.db","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"archive.db-bak","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"U","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite-shm","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite-wal","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe_sync_updated.sh","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"U","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe_sync.sh","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe.db","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Outline Section","depth":21,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"OUTLINE","depth":22,"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"OUTLINE","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Timeline Section","depth":21,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"TIMELINE","depth":22,"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"TIMELINE","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"app_settings.json, Editor Group 1","depth":28,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"screenpipe_sync.sh, Editor Group 1","depth":28,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"pipe.md, Editor Group 1","depth":28,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":".env, Editor Group 1","depth":28,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":false},{"role":"AXStaticText","text":"","depth":29,"on_screen":true,"role_description":"text"},{"role":"AXTextArea","text":"ANTHROPIC_API_KEY=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","depth":28,"on_screen":true,"value":"ANTHROPIC_API_KEY=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","role_description":"editor","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"ANTHROPIC_API_KEY=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","depth":29,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Implement and run pipe l…, Editor Group 2","depth":28,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":false},{"role":"AXRadioButton","text":"Problems (⇧⌘M)","depth":22,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"PROBLEMS","depth":24,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Output (⇧⌘U)","depth":22,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUTPUT","depth":24,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Debug Console (⇧⌘Y)","depth":22,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"DEBUG CONSOLE","depth":24,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Terminal (⌃`)","depth":22,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":true},{"role":"AXStaticText","text":"TERMINAL","depth":24,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Ports - 1 forwarded port","depth":22,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"PORTS","depth":24,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":25,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"remote SSH: nas","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"SSH: nas","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"screenpipe (Git) - master*, Checkout Branch/Tag...","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"master*","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"screenpipe (Git) - Synchronize Changes","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"No Problems","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"0","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"0","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Forwarded Ports: 8766","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Notifications","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sign In","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Sign In","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Info: Setting up SSH Host nas: Setting up SSH tunnel","depth":12,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Implement and run pipe logic","depth":19,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Session history","depth":19,"on_screen":true,"help_text":"Session history","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"New session","depth":19,"on_screen":true,"help_text":"New session","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Message actions","depth":24,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"main.py","depth":23,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"lets implement logic with pipes. how can I run it?","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Let me look at the current project structure to understand what's already in place.","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"List project files","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"find /volume1/screenpipe -type f | head -50 && echo \"---\" && ls /volume1/screenpipe","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"/volume1/screenpipe/.DS_Store\n/volume1/screenpipe/screenpipe.db\n/volume1/screenpipe/screenpipe_sync.sh\n/volume1/screenpipe/app_settings.json\n/volume1/screenpipe/.gitignore\n/volume1/screenpipe/archive.db\n/volume1/screenpipe/db.sqlite\n/volume1/screenpipe/db.sqlite-wal\n/volume1/screenpipe/db.sqlite-shm\n/volume1/screenpipe/#recycle/desktop.ini\n/volume1/screenpipe/#recycle/db.sqlite\n/volume1/screenpipe/#recycle/Copy #1 of db.sqlite\n/volume1/screenpipe/#recycle/.DS_Store\n/volume1/screenpipe/#recycle/Copy #2 of db.sqlite\n/volume1/screenpipe/#recycle/archive.db\n/volume1/screenpipe/#recycle/Copy #1 of archive.db\n/volume1/screenpipe/#recycle/Copy #2 of archive.db\n/volume1/screenpipe/#recycle/Copy #3 of archive.db\n/volume1/screenpipe/#recycle/Copy #4 of archive.db\n/volume1/screenpipe/#recycle/Copy #5 of archive.db\n/volume1/screenpipe/#recycle/Copy #3 of db.sqlite\n/volume1/screenpipe/#recycle/Copy #4 of db.sqlite\n/volume1/screenpipe/#recycle/Copy #6 of archive.db\n/volume1/screenpipe/#recycle/test.txt\n/volume1/screenpipe/#recycle/Copy #7 of archive.db\n/volume1/screenpipe/#recycle/Copy #8 of archive.db\n/volume1/screenpipe/#recycle/archive.db-journal\n/volume1/screenpipe/#recycle/Copy #1 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #2 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #3 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #4 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #5 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #6 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #7 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #5 of db.sqlite\n/volume1/screenpipe/pipes/.DS_Store\n/volume1/screenpipe/app/.env\n/volume1/screenpipe/app/cli.py\n/volume1/screenpipe/app/.DS_Store\n/volume1/screenpipe/app/db.py\n/volume1/screenpipe/app/docker-compose.yml\n/volume1/screenpipe/app/main.py\n/volume1/screenpipe/app/requirements.txt\n/volume1/screenpipe/app/Dockerfile\n/volume1/screenpipe/data/.DS_Store\n/volume1/screenpipe/.git/description\n/volume1/screenpipe/.git/HEAD\n/volume1/screenpipe/.git/index\n/volume1/screenpipe/.git/COMMIT_EDITMSG\n/volume1/screenpipe/#recycle/data/.DS_Store\n---\napp\napp_settings.json\narchive.db\ndata\ndb.sqlite\ndb.sqlite-shm\ndb.sqlite-wal\npipes\n#recycle\nscreenpipe.db\nscreenpipe_sync.sh","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"main.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Check pipes directory and docker-compose","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/pipes/ && ls /volume1/screenpipe/app/ && cat /volume1/screenpipe/app/docker-compose.yml","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ai-habits\nday-recap\nmeeting-summary\nstandup-update\ntime-breakdown\nvideo-export\ncli.py\nconsumers\ndb.py\ndocker-compose.yml\nDockerfile\nmain.py\n__pycache__\nrequirements.txt\nstatic\nservices:\n screenpipe-app:\n build: .\n container_name: screenpipe-app\n restart: unless-stopped\n ports:\n - \"8766:8000\"\n volumes:\n - /volume1/screenpipe:/data\n env_file:\n - .env\n environment:\n TZ: Europe/Sofia\n DB_PATH: /data/db.sqlite\n\n sqlite-web-archive:\n image: ghcr.io/coleifer/sqlite-web:latest\n container_name: screenpipe-sqlweb-archive\n restart: unless-stopped\n ports:\n - \"8767:8080\"\n volumes:\n - /volume1/screenpipe:/data\n command: [\"-H\", \"0.0.0.0\", \"-r\", \"/data/archive.db\"]\n\n sqlite-web-live:\n image: ghcr.io/coleifer/sqlite-web:latest\n container_name: screenpipe-sqlweb-live\n restart: unless-stopped\n ports:\n - \"8768:8080\"\n volumes:\n - /volume1/screenpipe:/data\n command: [\"-H\", \"0.0.0.0\", \"-r\", \"/data/db.sqlite\"]","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"requirements.txt","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"requirements.txt","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Inspect a pipe directory","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/pipes/day-recap/ && cat /volume1/screenpipe/pipes/day-recap/pipe.json 2>/dev/null || ls /volume1/screenpipe/pipes/day-recap/","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"pipe.md\npipe.md","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"cli.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"cli.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"List all pipes and their contents","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/pipes/ && for d in /volume1/screenpipe/pipes/*/; do echo \"=== $d ===\"; ls \"$d\"; done","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ai-habits\nday-recap\nmeeting-summary\nstandup-update\ntime-breakdown\nvideo-export\n=== /volume1/screenpipe/pipes/ai-habits/ ===\npipe.md\n=== /volume1/screenpipe/pipes/day-recap/ ===\npipe.md\n=== /volume1/screenpipe/pipes/meeting-summary/ ===\npipe.md\n=== /volume1/screenpipe/pipes/standup-update/ ===\npipe.md\n=== /volume1/screenpipe/pipes/time-breakdown/ ===\npipe.md\n=== /volume1/screenpipe/pipes/video-export/ ===\npipe.md","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read pipe markdown files","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"cat /volume1/screenpipe/pipes/day-recap/pipe.md && echo \"===\" && cat /volume1/screenpipe/pipes/meeting-summary/pipe.md 2>/dev/null | head -50","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Day Recap\ndescription: \"Today's accomplishments, key moments, and unfinished work\"\nicon: \"📋\"\nfeatured: true\n---\n\nAnalyze my screen and audio recordings from today (last 16 hours only). \n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Summary\nOne sentence: what I mainly did today.\n\n## Accomplishments\n- Top 3 things I finished, with timestamps (e.g. \"2:30 PM\")\n- Name specific apps, files, or projects\n\n## Key Moments\n- Important things I saw, said, or heard — with timestamps\n\n## Unfinished Work\n- What I should continue tomorrow — name the app/file/task\n\n## Patterns\n- Apps I used most, topics that came up repeatedly\n\nOnly report what you can verify from the data. End with: \"**Next step:** [most important thing to continue]\"\n===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Meeting Summary\ndescription: \"Summarize meeting transcript with key takeaways and action items\"\nicon: \"🤝\"\nfeatured: false\n---\n\nSummarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.\n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Meeting Summary\nOne sentence: what this meeting was about.\n\n## Key Takeaways\n- Top 3-5 important points discussed\n- Include who said what when relevant\n\n## Action Items\n- [ ] Task — assigned to whom, deadline if mentioned\n- [ ] Task — assigned to whom\n\n## Decisions Made\n- List any decisions or agreements reached\n\n## Open Questions\n- Anything unresolved or needing follow-up\n\nKeep it concise and actionable.","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read summary consumer","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/app/consumers/ && cat /volume1/screenpipe/app/consumers/summary.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"activity.py\naudio.py\nelements.py\n__init__.py\ninteractions.py\nocr.py\n__pycache__\nreport.py\nsummary.py\n\"\"\"AI summary generator using Claude.\"\"\"\nimport os\nfrom datetime import date\nfrom typing import Any\n\nfrom consumers.activity import app_time, summary_stats, browser_urls, ui_event_summary\nfrom consumers.ocr import deduplicated_text\nfrom consumers.audio import formatted_transcript\n\n\nSUMMARY_TYPES = {\n \"day_recap\": {\n \"title\": \"Day Recap\",\n \"prompt\": \"\"\"\\\nYou are analyzing a person's computer activity for the day.\n\n## App usage (minutes per app):\n{app_time}\n\n## Browser URLs visited:\n{browser_urls}\n\n## UI activity per app (clicks / keystrokes / app-switches):\n{ui_events}\n\n## Screen content (sampled every 5 minutes):\n{ocr_text}\n\n## Audio/speech:\n{audio}\n\nWrite a concise day recap using EXACTLY this format:\n\n## Summary\nOne sentence: what I mainly worked on today.\n\n## Accomplishments\n- Top 3 things I finished, with approximate times\n- Name specific apps, files, or projects\n\n## Key Moments\n- Important things seen or heard, with timestamps\n\n## Unfinished Work\n- What to continue tomorrow\n\n## Patterns\n- Apps used most, topics that came up repeatedly\n\nOnly report what you can verify from the data. End with:\n**Next step:** [most important thing to continue]\"\"\",\n },\n \"standup\": {\n \"title\": \"Standup Update\",\n \"prompt\": \"\"\"\\\nYou are analyzing a person's computer activity for the day.\n\n## App usage (minutes per app):\n{app_time}\n\n## Browser URLs visited:\n{browser_urls}\n\n## UI activity per app (clicks / keystrokes / app-switches):\n{ui_events}\n\n## Screen content (sampled every 5 minutes):\n{ocr_text}\n\n## Audio/speech:\n{audio}\n\nWrite a brief standup update:\n\n**Yesterday:** What I worked on (2-3 bullets)\n**Today:** What I plan to continue (1-2 bullets)\n**Blockers:** Any issues observed (or \"None\")\n\nKeep it under 150 words. Only report what's verifiable from the data.\"\"\",\n },\n \"focus_time\": {\n \"title\": \"Focus & Distraction Analysis\",\n \"prompt\": \"\"\"\\\nYou are analyzing a person's computer activity for the day.\n\n## App usage (minutes per app):\n{app_time}\n\n## Browser URLs visited:\n{browser_urls}\n\n## UI activity per app (clicks / keystrokes / app-switches):\n{ui_events}\n\n## Screen content (sampled every 5 minutes):\n{ocr_text}\n\nAnalyze focus vs distraction patterns:\n\n## Deep Work Periods\n- When and how long were sustained focus sessions?\n- What was being worked on?\n\n## Distractions\n- Which apps/sites were used recreationally?\n- How much time was lost to context switching?\n\n## Recommendations\n- 2-3 concrete suggestions to improve focus tomorrow\n\nBe specific with times and app names.\"\"\",\n },\n}\n\n\ndef _build_context(for_date: date) -> dict[str, str]:\n apps = app_time(for_date)\n app_lines = \"\\n\".join(f\"- {a['app_name']}: {a['minutes']} min\" for a in apps[:20])\n\n urls = browser_urls(for_date, limit=20)\n url_lines = \"\\n\".join(\n f\"- {u['browser_url'][:100]} ({u['minutes']} min)\" for u in urls\n )\n\n ui_rows = ui_event_summary(for_date)\n ui_lines = \"\\n\".join(\n f\"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches\"\n for r in ui_rows[:15]\n )\n\n ocr_rows = deduplicated_text(for_date, chunk_minutes=5)\n ocr_lines = \"\\n\".join(\n f\"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}\"\n for r in ocr_rows[:100]\n )\n\n audio = formatted_transcript(for_date)\n\n return {\n \"app_time\": app_lines or \"(no app data)\",\n \"browser_urls\": url_lines or \"(no browser data)\",\n \"ui_events\": ui_lines or \"(no UI event data)\",\n \"ocr_text\": ocr_lines or \"(no screen data)\",\n \"audio\": audio[:3000] if len(audio) > 3000 else audio,\n }\n\n\ndef generate(\n summary_type: str = \"day_recap\",\n for_date: date | None = None,\n api_key: str | None = None,\n) -> dict[str, Any]:\n \"\"\"Generate an AI summary. Returns dict with 'title', 'content', 'date'.\"\"\"\n import anthropic\n\n d = for_date or date.today()\n key = api_key or os.environ.get(\"ANTHROPIC_API_KEY\", \"\")\n if not key:\n return {\n \"title\": \"Error\",\n \"content\": \"ANTHROPIC_API_KEY not set. Add it to your .env file.\",\n \"date\": str(d),\n }\n\n spec = SUMMARY_TYPES.get(summary_type)\n if not spec:\n return {\"title\": \"Error\", \"content\": f\"Unknown summary type: {summary_type}\", \"date\": str(d)}\n\n stats = summary_stats(d)\n if stats[\"total_frames\"] == 0:\n return {\n \"title\": spec[\"title\"],\n \"content\": f\"No screen data found for {d}.\",\n \"date\": str(d),\n }\n\n ctx = _build_context(d)\n prompt = spec[\"prompt\"].format(**ctx)\n\n client = anthropic.Anthropic(api_key=key)\n message = client.messages.create(\n model=\"claude-haiku-4-5-20251001\",\n max_tokens=1024,\n messages=[{\"role\": \"user\", \"content\": prompt}],\n )\n\n return {\n \"title\": spec[\"title\"],\n \"content\": message.content[0].text,\n \"date\": str(d),\n \"stats\": stats,\n }","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read all pipe.md files","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"for f in /volume1/screenpipe/pipes/*/pipe.md; do echo \"=== $f ===\"; cat \"$f\"; echo; done","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"=== /volume1/screenpipe/pipes/ai-habits/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: AI Habits\ndescription: \"How you use AI tools — patterns and insights\"\nicon: \"🤖\"\nfeatured: true\n---\n\nSearch my recordings from the last 24 hours for AI tool usage. Use app_name filter for each tool separately: ChatGPT, Claude, Copilot, Cursor, Gemini, Perplexity. Use limit=5 per search, max 6 searches total.\n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## AI Tools Used\n- List each tool with approximate time spent (e.g. \"Claude: ~45min\")\n\n## What I Used Them For\n- For each tool: coding, writing, research, or brainstorming\n\n## Usage Patterns\n- Do I switch between tools? Use them in bursts or steadily?\n\n## Effectiveness\n- Which tool appeared alongside completed work vs. abandoned attempts\n\nIf no AI usage is found, say so clearly. End with: \"**Tip:** [one suggestion to use AI tools more effectively]\"\n\n=== /volume1/screenpipe/pipes/day-recap/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Day Recap\ndescription: \"Today's accomplishments, key moments, and unfinished work\"\nicon: \"📋\"\nfeatured: true\n---\n\nAnalyze my screen and audio recordings from today (last 16 hours only). \n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Summary\nOne sentence: what I mainly did today.\n\n## Accomplishments\n- Top 3 things I finished, with timestamps (e.g. \"2:30 PM\")\n- Name specific apps, files, or projects\n\n## Key Moments\n- Important things I saw, said, or heard — with timestamps\n\n## Unfinished Work\n- What I should continue tomorrow — name the app/file/task\n\n## Patterns\n- Apps I used most, topics that came up repeatedly\n\nOnly report what you can verify from the data. End with: \"**Next step:** [most important thing to continue]\"\n\n=== /volume1/screenpipe/pipes/meeting-summary/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Meeting Summary\ndescription: \"Summarize meeting transcript with key takeaways and action items\"\nicon: \"🤝\"\nfeatured: false\n---\n\nSummarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.\n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Meeting Summary\nOne sentence: what this meeting was about.\n\n## Key Takeaways\n- Top 3-5 important points discussed\n- Include who said what when relevant\n\n## Action Items\n- [ ] Task — assigned to whom, deadline if mentioned\n- [ ] Task — assigned to whom\n\n## Decisions Made\n- List any decisions or agreements reached\n\n## Open Questions\n- Anything unresolved or needing follow-up\n\nKeep it concise and actionable.\n\n=== /volume1/screenpipe/pipes/standup-update/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Standup Update\ndescription: \"What you did, what's next, and any blockers\"\nicon: \"🏢\"\nfeatured: true\n---\n\nBased on my recordings from the last 24 hours, generate a standup update. Use limit=10 per search, max 3 searches total.\n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Yesterday\n- What I worked on (name specific projects, files, tools, PRs)\n\n## Today\n- What I will work on next (based on unfinished tasks and recent activity)\n\n## Blockers\n- Issues I hit — errors, slow builds, waiting on someone\n- If no blockers, write \"None\"\n\nKeep it under 150 words. Copy-paste ready for a team standup.\n\n=== /volume1/screenpipe/pipes/time-breakdown/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Time Breakdown\ndescription: \"Where your time went — by app, project, and category\"\nicon: \"⏱\"\nfeatured: false\n---\n\nAnalyze my app usage from today (last 12 hours). Use limit=10 per search, max 4 searches. Prefer /raw_sql with COUNT/GROUP BY queries.\n\nRead screenpipe skill first.\n\nUse this exact format with durations and percentages:\n\n## By Application\n- List each app with duration and percentage, sorted by time (e.g. \"VS Code: 2h 15min (28%)\")\n\n## By Category\n- Group into: coding, meetings, browsing, writing, communication, other\n- Show hours and percentage per category\n\n## By Project\n- Group related activities by project/topic. Name specific repos or tasks.\n\n## Productivity Score\n- Calculate: focused_work_hours / total_hours as a percentage\n- Focused = coding + writing. Unfocused = browsing + switching.\n\nEnd with: \"**Suggestion:** [one specific change to improve tomorrow's productivity]\"\n\n=== /volume1/screenpipe/pipes/video-export/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Export Video Clip\ndescription: \"Create a video of your recent screen activity\"\nicon: \"🎬\"\nfeatured: false\n---\n\nExport a video of my screen activity from the last 5 minutes.\n\nRead screenpipe skill first.\n\nUse the POST /frames/export endpoint with the time range and fps=1.0. Then show me the exported video file path as an inline code block so I can watch it.\n\nIf the export is large, suggest a lower fps or shorter time range.","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Now I have a clear picture. The pipes are markdown prompt templates in","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"/volume1/screenpipe/pipes/","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":", but there's no code to actually load and run them —","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"consumers/summary.py","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"has its own hardcoded prompts instead.","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Here's what I'll implement:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"consumers/pipes.py","depth":26,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"— dynamically loads pipe.md files and runs them via Claude (data injected as system message, pipe body as user prompt)","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"main.py","depth":26,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"— two new endpoints:","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"GET /api/pipes","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"and","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"POST /api/pipes/{pipe_id}/run","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"cli.py","depth":26,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"— a","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"pipe","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"command to run pipes from the terminal","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Let me build it:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Check browser_urls signature","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"cat /volume1/screenpipe/app/consumers/activity.py | grep \"def browser_urls\" -A 5","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"def browser_urls(\n for_date: date | None = None,\n app_name: str | None = None,\n ts_from: str | None = None,\n ts_to: str | None = None,\n limit: int = 30,","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Write","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"pipes.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"pipes.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"143 lines","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"\"\"\"Dynamic pipe loader and runner.\"\"\"\nimport os\nimport re\nfrom datetime import date\nfrom pathlib import Path\nfrom typing import Any\n\n\ndef _parse_frontmatter(text: str) -> tuple[dict, str]:\n if not text.startswith(\"---\"):\n return {}, text\n try:\n end = text.index(\"---\", 3)\n except ValueError:\n return {}, text\n fm_text = text[3:end].strip()\n body = text[end + 3:].strip()\n meta: dict = {}\n for line in fm_text.splitlines():\n if \":\" in line:\n k, _, v = line.partition(\":\")\n meta[k.strip()] = v.strip().strip('\"')\n return meta, body\n\n\ndef load_pipes(pipes_dir: Path) -> list[dict]:\n if not pipes_dir.exists():\n return []\n pipes = []\n for pipe_dir in sorted(pipes_dir.iterdir()):\n if not pipe_dir.is_dir() or pipe_dir.name.startswith(\".\"):\n continue\n pipe_md = pipe_dir / \"pipe.md\"\n if not pipe_md.exists():\n continue\n text = pipe_md.read_text(encoding=\"utf-8\")\n meta, body = _parse_frontmatter(text)\n if meta.get(\"enabled\", \"true\").lower() == \"false\":\n continue\n body = re.sub(r\"Read screenpipe skill first\\.?\\n?\", \"\", body).strip()\n pipes.append({\n \"id\": pipe_dir.name,\n \"title\": meta.get(\"title\", pipe_dir.name),\n \"description\": meta.get(\"description\", \"\"),\n \"icon\": meta.get(\"icon\", \"\"),\n \"schedule\": meta.get(\"schedule\", \"manual\"),\n \"featured\": meta.get(\"featured\", \"false\").lower() == \"true\",\n \"prompt\": body,\n })\n return pipes\n\n\ndef _build_system(d: date, stats: dict) -> str:\n from consumers.activity import app_time, browser_urls, ui_event_summary\n from consumers.ocr import deduplicated_text\n from consumers.audio import formatted_transcript\n\n apps = app_time(d)\n app_lines = \"\\n\".join(f\"- {a['app_name']}: {a['minutes']} min\" for a in apps[:20])\n\n urls = browser_urls(d, limit=20)\n url_lines = \"\\n\".join(f\"- {u['browser_url'][:100]} ({u['minutes']} min)\" for u in urls)\n\n ui_rows = ui_event_summary(d)\n ui_lines = \"\\n\".join(\n f\"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches\"\n for r in ui_rows[:15]\n )\n\n ocr_rows = deduplicated_text(d, chunk_minutes=5)\n ocr_lines = \"\\n\".join(\n f\"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}\"\n for r in ocr_rows[:100]\n )\n\n audio = formatted_transcript(d)\n if len(audio) > 3000:\n audio = audio[:3000]\n\n return f\"\"\"You are analyzing screenpipe data — recordings of a person's computer activity.\n\n## App usage (minutes per app):\n{app_lines or '(no app data)'}\n\n## Browser URLs visited:\n{url_lines or '(no browser data)'}\n\n## UI activity per app (clicks / keystrokes / app-switches):\n{ui_lines or '(no UI event data)'}\n\n## Screen content (sampled every 5 minutes):\n{ocr_lines or '(no screen data)'}\n\n## Audio / speech:\n{audio or '(no audio data)'}\n\nDate: {d}\nTotal frames recorded: {stats['total_frames']}\"\"\"\n\n\ndef run_pipe(\n pipe_id: str,\n for_date: date | None = None,\n api_key: str | None = None,\n pipes_dir: Path | None = None,\n) -> dict[str, Any]:\n import anthropic\n from consumers.activity import summary_stats\n\n d = for_date or date.today()\n key = api_key or os.environ.get(\"ANTHROPIC_API_KEY\", \"\")\n if not key:\n return {\"title\": \"Error\", \"content\": \"ANTHROPIC_API_KEY not set.\", \"date\": str(d)}\n\n _pipes_dir = pipes_dir or Path(os.environ.get(\"PIPES_DIR\", \"/data/pipes\"))\n all_pipes = {p[\"id\"]: p for p in load_pipes(_pipes_dir)}\n\n if pipe_id not in all_pipes:\n return {\"title\": \"Error\", \"content\": f\"Pipe not found: {pipe_id}\", \"date\": str(d)}\n\n pipe = all_pipes[pipe_id]\n stats = summary_stats(d)\n\n if stats[\"total_frames\"] == 0:\n return {\"title\": pipe[\"title\"], \"content\": f\"No screen data found for {d}.\", \"date\": str(d)}\n\n system = _build_system(d, stats)\n\n client = anthropic.Anthropic(api_key=key)\n message = client.messages.create(\n model=\"claude-haiku-4-5-20251001\",\n max_tokens=1024,\n system=system,\n messages=[{\"role\": \"user\", \"content\": pipe[\"prompt\"]}],\n )\n\n return {\n \"title\": pipe[\"title\"],\n \"content\": message.content[0].text,\n \"date\": str(d),\n \"stats\": stats,\n }","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Now add the API endpoints to","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"main.py","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":":","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Edit","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"main.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Added 1 line","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Edit","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"main.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Added 1 line","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Now add the pipe endpoints at the end of main.py, before the closing summary section:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Edit","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"main.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Added 14 lines","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Now add the CLI command to","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"cli.py","depth":23,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"cli.py","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":":","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Edit","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"cli.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"cli.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Added 40 lines","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Done. Here's how to run pipes:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXHeading","text":"How to run pipes","depth":22,"on_screen":false,"role_description":"heading"},{"role":"AXStaticText","text":"How to run pipes","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Via Docker (inside the running container):","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":23,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"docker exec -it screenpipe-app python cli.py pipe --list\ndocker exec -it screenpipe-app python cli.py pipe day-recap\ndocker exec -it screenpipe-app python cli.py pipe standup-update --date yesterday","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Via the API","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"(once the container is running on port 8766):","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":23,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"# List pipes\ncurl http://localhost:8766/api/pipes\n\n# Run a pipe\ncurl -X POST \"http://localhost:8766/api/pipes/day-recap/run\"\ncurl -X POST \"http://localhost:8766/api/pipes/standup-update/run?d=2026-04-25\"","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Rebuild and restart","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"to pick up the changes:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":23,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"cd /volume1/screenpipe/app\ndocker compose up --build -d","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"How it works:","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Each","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"pipe.md","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"file is loaded dynamically — the frontmatter provides metadata and the body becomes the user prompt. Screenpipe data (app usage, browser URLs, OCR, audio) is injected as a Claude system message so the pipe prompt can reference it naturally. The \"Read screenpipe skill first\" line is stripped automatically.","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"The pipes directory inside Docker is","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"/data/pipes","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"(since","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"/volume1/screenpipe","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"→","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"/data","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"). You can override it with a","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"PIPES_DIR","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"env var if needed.","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Message actions","depth":24,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"pipe.md","depth":23,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"pipe.md","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"where to place api key and can I use different keys","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read .env file","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"cat /volume1/screenpipe/app/.env","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ANTHROPIC_API_KEY=your_key_here","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Where to place the key:","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"app/.env","depth":23,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"app/.env","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"— replace","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"your_key_here","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"with your actual key:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":23,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"ANTHROPIC_API_KEY=sk-ant-...","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"That file is loaded by","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"load_dotenv()","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"at startup and is excluded from git via","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":".gitignore","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":".","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Can you use different keys per pipe?","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Not currently — all pipes share the one key from","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":".env","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":". But you can add per-pipe key support by adding an","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"api_key","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"field to the pipe's frontmatter:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":23,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"---\ntitle: Meeting Summary\napi_key_env: ANTHROPIC_KEY_MEETINGS\n---","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Then in","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"consumers/pipes.py","depth":23,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"consumers/pipes.py","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":", read it in","depth":23,"on_screen":false,"role_description":"text"}]...
|
-1871827330026221506
|
-8763496496607803156
|
idle
|
accessibility
|
NULL
|
Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧ Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py
M
db.py
docker-compose.yml
Dockerfile
M
main.py
M
requirements.txt
M
data
logs
pipes
.gitignore
app_settings.json
archive.db
archive.db-bak
U
db.sqlite
db.sqlite-shm
db.sqlite-wal
screenpipe_sync_updated.sh
U
screenpipe_sync.sh
screenpipe.db
Outline Section
OUTLINE
OUTLINE
Timeline Section
TIMELINE
TIMELINE
app_settings.json, Editor Group 1
screenpipe_sync.sh, Editor Group 1
pipe.md, Editor Group 1
.env, Editor Group 1
[ENV_SECRET]
[ENV_SECRET]
Implement and run pipe l…, Editor Group 2
Problems (⇧⌘M)
PROBLEMS
Output (⇧⌘U)
OUTPUT
Debug Console (⇧⌘Y)
DEBUG CONSOLE
Terminal (⌃`)
TERMINAL
Ports - 1 forwarded port
PORTS
1
remote SSH: nas
SSH: nas
screenpipe (Git) - master*, Checkout Branch/Tag...
master*
screenpipe (Git) - Synchronize Changes
No Problems
0
0
Forwarded Ports: 8766
1
Notifications
Sign In
Sign In
Info: Setting up SSH Host nas: Setting up SSH tunnel
Implement and run pipe logic
Session history
New session
Message actions
main.py
main.py
lets implement logic with pipes. how can I run it?
Thinking
Thinking
Let me look at the current project structure to understand what's already in place.
Bash
List project files
IN
find /volume1/screenpipe -type f | head -50 && echo "---" && ls /volume1/screenpipe
Copy code to clipboard
OUT
/volume1/screenpipe/.DS_Store
/volume1/screenpipe/screenpipe.db
/volume1/screenpipe/screenpipe_sync.sh
/volume1/screenpipe/app_settings.json
/volume1/screenpipe/.gitignore
/volume1/screenpipe/archive.db
/volume1/screenpipe/db.sqlite
/volume1/screenpipe/db.sqlite-wal
/volume1/screenpipe/db.sqlite-shm
/volume1/screenpipe/#recycle/desktop.ini
/volume1/screenpipe/#recycle/db.sqlite
/volume1/screenpipe/#recycle/Copy #1 of db.sqlite
/volume1/screenpipe/#recycle/.DS_Store
/volume1/screenpipe/#recycle/Copy #2 of db.sqlite
/volume1/screenpipe/#recycle/archive.db
/volume1/screenpipe/#recycle/Copy #1 of archive.db
/volume1/screenpipe/#recycle/Copy #2 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of archive.db
/volume1/screenpipe/#recycle/Copy #4 of archive.db
/volume1/screenpipe/#recycle/Copy #5 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of db.sqlite
/volume1/screenpipe/#recycle/Copy #4 of db.sqlite
/volume1/screenpipe/#recycle/Copy #6 of archive.db
/volume1/screenpipe/#recycle/test.txt
/volume1/screenpipe/#recycle/Copy #7 of archive.db
/volume1/screenpipe/#recycle/Copy #8 of archive.db
/volume1/screenpipe/#recycle/archive.db-journal
/volume1/screenpipe/#recycle/Copy #1 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #2 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #3 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #4 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #6 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #7 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of db.sqlite
/volume1/screenpipe/pipes/.DS_Store
/volume1/screenpipe/app/.env
/volume1/screenpipe/app/cli.py
/volume1/screenpipe/app/.DS_Store
/volume1/screenpipe/app/db.py
/volume1/screenpipe/app/docker-compose.yml
/volume1/screenpipe/app/main.py
/volume1/screenpipe/app/requirements.txt
/volume1/screenpipe/app/Dockerfile
/volume1/screenpipe/data/.DS_Store
/volume1/screenpipe/.git/description
/volume1/screenpipe/.git/HEAD
/volume1/screenpipe/.git/index
/volume1/screenpipe/.git/COMMIT_EDITMSG
/volume1/screenpipe/#recycle/data/.DS_Store
---
app
app_settings.json
archive.db
data
db.sqlite
db.sqlite-shm
db.sqlite-wal
pipes
#recycle
screenpipe.db
screenpipe_sync.sh
Read
main.py
main.py
Bash
Check pipes directory and docker-compose
IN
ls /volume1/screenpipe/pipes/ && ls /volume1/screenpipe/app/ && cat /volume1/screenpipe/app/docker-compose.yml
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
cli.py
consumers
db.py
docker-compose.yml
Dockerfile
main.py
__pycache__
requirements.txt
static
services:
screenpipe-app:
build: .
container_name: screenpipe-app
restart: unless-stopped
ports:
- "8766:8000"
volumes:
- /volume1/screenpipe:/data
env_file:
- .env
environment:
TZ: Europe/Sofia
DB_PATH: /data/db.sqlite
sqlite-web-archive:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-archive
restart: unless-stopped
ports:
- "8767:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/archive.db"]
sqlite-web-live:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-live
restart: unless-stopped
ports:
- "8768:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/db.sqlite"]
Read
requirements.txt
requirements.txt
Bash
Inspect a pipe directory
IN
ls /volume1/screenpipe/pipes/day-recap/ && cat /volume1/screenpipe/pipes/day-recap/pipe.json 2>/dev/null || ls /volume1/screenpipe/pipes/day-recap/
Copy code to clipboard
OUT
pipe.md
pipe.md
Read
cli.py
cli.py
Bash
List all pipes and their contents
IN
ls /volume1/screenpipe/pipes/ && for d in /volume1/screenpipe/pipes/*/; do echo "=== $d ==="; ls "$d"; done
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
=== /volume1/screenpipe/pipes/ai-habits/ ===
pipe.md
=== /volume1/screenpipe/pipes/day-recap/ ===
pipe.md
=== /volume1/screenpipe/pipes/meeting-summary/ ===
pipe.md
=== /volume1/screenpipe/pipes/standup-update/ ===
pipe.md
=== /volume1/screenpipe/pipes/time-breakdown/ ===
pipe.md
=== /volume1/screenpipe/pipes/video-export/ ===
pipe.md
Bash
Read pipe markdown files
IN
cat /volume1/screenpipe/pipes/day-recap/pipe.md && echo "===" && cat /volume1/screenpipe/pipes/meeting-summary/pipe.md 2>/dev/null | head -50
Copy code to clipboard
OUT
---
schedule: manual
enabled: true
template: true
title: Day Recap
description: "Today's accomplishments, key moments, and unfinished work"
icon: "📋"
featured: true
---
Analyze my screen and audio recordings from today (last 16 hours only).
Read screenpipe skill first.
Use this exact format:
## Summary
One sentence: what I mainly did today.
## Accomplishments
- Top 3 things I finished, with timestamps (e.g. "2:30 PM")
- Name specific apps, files, or projects
## Key Moments
- Important things I saw, said, or heard — with timestamps
## Unfinished Work
- What I should continue tomorrow — name the app/file/task
## Patterns
- Apps I used most, topics that came up repeatedly
Only report what you can verify from the data. End with: "**Next step:** [most important thing to continue]"
===
---
schedule: manual
enabled: true
template: true
title: Meeting Summary
description: "Summarize meeting transcript with key takeaways and action items"
icon: "🤝"
featured: false
---
Summarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.
Read screenpipe skill first.
Use this exact format:
## Meeting Summary
One sentence: what this meeting was about.
## Key Takeaways
- Top 3-5 important points discussed
- Include who said what when relevant
## Action Items
- [ ] Task — assigned to whom, deadline if mentioned
- [ ] Task — assigned to whom
## Decisions Made
- List any decisions or agreements reached
## Open Questions
- Anything unresolved or needing follow-up
Keep it concise and actionable.
Thinking
Thinking
Bash
Read summary consumer
IN
ls /volume1/screenpipe/app/consumers/ && cat /volume1/screenpipe/app/consumers/summary.py
Copy code to clipboard
OUT
activity.py
audio.py
elements.py
__init__.py
interactions.py
ocr.py
__pycache__
report.py
summary.py
"""AI summary generator using Claude."""
import os
from datetime import date
from typing import Any
from consumers.activity import app_time, summary_stats, browser_urls, ui_event_summary
from consumers.ocr import deduplicated_text
from consumers.audio import formatted_transcript
SUMMARY_TYPES = {
"day_recap": {
"title": "Day Recap",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
## Audio/speech:
{audio}
Write a concise day recap using EXACTLY this format:
## Summary
One sentence: what I mainly worked on today.
## Accomplishments
- Top 3 things I finished, with approximate times
- Name specific apps, files, or projects
## Key Moments
- Important things seen or heard, with timestamps
## Unfinished Work
- What to continue tomorrow
## Patterns
- Apps used most, topics that came up repeatedly
Only report what you can verify from the data. End with:
**Next step:** [most important thing to continue]""",
},
"standup": {
"title": "Standup Update",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
## Audio/speech:
{audio}
Write a brief standup update:
**Yesterday:** What I worked on (2-3 bullets)
**Today:** What I plan to continue (1-2 bullets)
**Blockers:** Any issues observed (or "None")
Keep it under 150 words. Only report what's verifiable from the data.""",
},
"focus_time": {
"title": "Focus & Distraction Analysis",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
Analyze focus vs distraction patterns:
## Deep Work Periods
- When and how long were sustained focus sessions?
- What was being worked on?
## Distractions
- Which apps/sites were used recreationally?
- How much time was lost to context switching?
## Recommendations
- 2-3 concrete suggestions to improve focus tomorrow
Be specific with times and app names.""",
},
}
def _build_context(for_date: date) -> dict[str, str]:
apps = app_time(for_date)
app_lines = "\n".join(f"- {a['app_name']}: {a['minutes']} min" for a in apps[:20])
urls = browser_urls(for_date, limit=20)
url_lines = "\n".join(
f"- {u['browser_url'][:100]} ({u['minutes']} min)" for u in urls
)
ui_rows = ui_event_summary(for_date)
ui_lines = "\n".join(
f"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches"
for r in ui_rows[:15]
)
ocr_rows = deduplicated_text(for_date, chunk_minutes=5)
ocr_lines = "\n".join(
f"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}"
for r in ocr_rows[:100]
)
audio = formatted_transcript(for_date)
return {
"app_time": app_lines or "(no app data)",
"browser_urls": url_lines or "(no browser data)",
"ui_events": ui_lines or "(no UI event data)",
"ocr_text": ocr_lines or "(no screen data)",
"audio": audio[:3000] if len(audio) > 3000 else audio,
}
def generate(
summary_type: str = "day_recap",
for_date: date | None = None,
api_key: str | None = None,
) -> dict[str, Any]:
"""Generate an AI summary. Returns dict with 'title', 'content', 'date'."""
import anthropic
d = for_date or date.today()
key = api_key or os.environ.get("ANTHROPIC_API_KEY", "")
if not key:
return {
"title": "Error",
"content": "ANTHROPIC_API_KEY not set. Add it to your .env file.",
"date": str(d),
}
spec = SUMMARY_TYPES.get(summary_type)
if not spec:
return {"title": "Error", "content": f"Unknown summary type: {summary_type}", "date": str(d)}
stats = summary_stats(d)
if stats["total_frames"] == 0:
return {
"title": spec["title"],
"content": f"No screen data found for {d}.",
"date": str(d),
}
ctx = _build_context(d)
prompt = spec["prompt"].format(**ctx)
client = anthropic.Anthropic(api_key=key)
message = client.messages.create(
model="claude-haiku-4-5-20251001",
max_tokens=1024,
messages=[{"role": "user", "content": prompt}],
)
return {
"title": spec["title"],
"content": message.content[0].text,
"date": str(d),
"stats": stats,
}
Thinking
Thinking
Bash
Read all pipe.md files
IN
for f in /volume1/screenpipe/pipes/*/pipe.md; do echo "=== $f ==="; cat "$f"; echo; done
Copy code to clipboard
OUT
=== /volume1/screenpipe/pipes/ai-habits/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: AI Habits
description: "How you use AI tools — patterns and insights"
icon: "🤖"
featured: true
---
Search my recordings from the last 24 hours for AI tool usage. Use app_name filter for each tool separately: ChatGPT, Claude, Copilot, Cursor, Gemini, Perplexity. Use limit=5 per search, max 6 searches total.
Read screenpipe skill first.
Use this exact format:
## AI Tools Used
- List each tool with approximate time spent (e.g. "Claude: ~45min")
## What I Used Them For
- For each tool: coding, writing, research, or brainstorming
## Usage Patterns
- Do I switch between tools? Use them in bursts or steadily?
## Effectiveness
- Which tool appeared alongside completed work vs. abandoned attempts
If no AI usage is found, say so clearly. End with: "**Tip:** [one suggestion to use AI tools more effectively]"
=== /volume1/screenpipe/pipes/day-recap/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Day Recap
description: "Today's accomplishments, key moments, and unfinished work"
icon: "📋"
featured: true
---
Analyze my screen and audio recordings from today (last 16 hours only).
Read screenpipe skill first.
Use this exact format:
## Summary
One sentence: what I mainly did today.
## Accomplishments
- Top 3 things I finished, with timestamps (e.g. "2:30 PM")
- Name specific apps, files, or projects
## Key Moments
- Important things I saw, said, or heard — with timestamps
## Unfinished Work
- What I should continue tomorrow — name the app/file/task
## Patterns
- Apps I used most, topics that came up repeatedly
Only report what you can verify from the data. End with: "**Next step:** [most important thing to continue]"
=== /volume1/screenpipe/pipes/meeting-summary/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Meeting Summary
description: "Summarize meeting transcript with key takeaways and action items"
icon: "🤝"
featured: false
---
Summarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.
Read screenpipe skill first.
Use this exact format:
## Meeting Summary
One sentence: what this meeting was about.
## Key Takeaways
- Top 3-5 important points discussed
- Include who said what when relevant
## Action Items
- [ ] Task — assigned to whom, deadline if mentioned
- [ ] Task — assigned to whom
## Decisions Made
- List any decisions or agreements reached
## Open Questions
- Anything unresolved or needing follow-up
Keep it concise and actionable.
=== /volume1/screenpipe/pipes/standup-update/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Standup Update
description: "What you did, what's next, and any blockers"
icon: "🏢"
featured: true
---
Based on my recordings from the last 24 hours, generate a standup update. Use limit=10 per search, max 3 searches total.
Read screenpipe skill first.
Use this exact format:
## Yesterday
- What I worked on (name specific projects, files, tools, PRs)
## Today
- What I will work on next (based on unfinished tasks and recent activity)
## Blockers
- Issues I hit — errors, slow builds, waiting on someone
- If no blockers, write "None"
Keep it under 150 words. Copy-paste ready for a team standup.
=== /volume1/screenpipe/pipes/time-breakdown/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Time Breakdown
description: "Where your time went — by app, project, and category"
icon: "⏱"
featured: false
---
Analyze my app usage from today (last 12 hours). Use limit=10 per search, max 4 searches. Prefer /raw_sql with COUNT/GROUP BY queries.
Read screenpipe skill first.
Use this exact format with durations and percentages:
## By Application
- List each app with duration and percentage, sorted by time (e.g. "VS Code: 2h 15min (28%)")
## By Category
- Group into: coding, meetings, browsing, writing, communication, other
- Show hours and percentage per category
## By Project
- Group related activities by project/topic. Name specific repos or tasks.
## Productivity Score
- Calculate: focused_work_hours / total_hours as a percentage
- Focused = coding + writing. Unfocused = browsing + switching.
End with: "**Suggestion:** [one specific change to improve tomorrow's productivity]"
=== /volume1/screenpipe/pipes/video-export/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Export Video Clip
description: "Create a video of your recent screen activity"
icon: "🎬"
featured: false
---
Export a video of my screen activity from the last 5 minutes.
Read screenpipe skill first.
Use the POST /frames/export endpoint with the time range and fps=1.0. Then show me the exported video file path as an inline code block so I can watch it.
If the export is large, suggest a lower fps or shorter time range.
Thinking
Thinking
Now I have a clear picture. The pipes are markdown prompt templates in
/volume1/screenpipe/pipes/
, but there's no code to actually load and run them —
consumers/summary.py
has its own hardcoded prompts instead.
Here's what I'll implement:
consumers/pipes.py
— dynamically loads pipe.md files and runs them via Claude (data injected as system message, pipe body as user prompt)
main.py
— two new endpoints:
GET /api/pipes
and
POST /api/pipes/{pipe_id}/run
cli.py
— a
pipe
command to run pipes from the terminal
Let me build it:
Bash
Check browser_urls signature
IN
cat /volume1/screenpipe/app/consumers/activity.py | grep "def browser_urls" -A 5
Copy code to clipboard
OUT
def browser_urls(
for_date: date | None = None,
app_name: str | None = None,
ts_from: str | None = None,
ts_to: str | None = None,
limit: int = 30,
Write
pipes.py
pipes.py
143 lines
"""Dynamic pipe loader and runner."""
import os
import re
from datetime import date
from pathlib import Path
from typing import Any
def _parse_frontmatter(text: str) -> tuple[dict, str]:
if not text.startswith("---"):
return {}, text
try:
end = text.index("---", 3)
except ValueError:
return {}, text
fm_text = text[3:end].strip()
body = text[end + 3:].strip()
meta: dict = {}
for line in fm_text.splitlines():
if ":" in line:
k, _, v = line.partition(":")
meta[k.strip()] = v.strip().strip('"')
return meta, body
def load_pipes(pipes_dir: Path) -> list[dict]:
if not pipes_dir.exists():
return []
pipes = []
for pipe_dir in sorted(pipes_dir.iterdir()):
if not pipe_dir.is_dir() or pipe_dir.name.startswith("."):
continue
pipe_md = pipe_dir / "pipe.md"
if not pipe_md.exists():
continue
text = pipe_md.read_text(encoding="utf-8")
meta, body = _parse_frontmatter(text)
if meta.get("enabled", "true").lower() == "false":
continue
body = re.sub(r"Read screenpipe skill first\.?\n?", "", body).strip()
pipes.append({
"id": pipe_dir.name,
"title": meta.get("title", pipe_dir.name),
"description": meta.get("description", ""),
"icon": meta.get("icon", ""),
"schedule": meta.get("schedule", "manual"),
"featured": meta.get("featured", "false").lower() == "true",
"prompt": body,
})
return pipes
def _build_system(d: date, stats: dict) -> str:
from consumers.activity import app_time, browser_urls, ui_event_summary
from consumers.ocr import deduplicated_text
from consumers.audio import formatted_transcript
apps = app_time(d)
app_lines = "\n".join(f"- {a['app_name']}: {a['minutes']} min" for a in apps[:20])
urls = browser_urls(d, limit=20)
url_lines = "\n".join(f"- {u['browser_url'][:100]} ({u['minutes']} min)" for u in urls)
ui_rows = ui_event_summary(d)
ui_lines = "\n".join(
f"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches"
for r in ui_rows[:15]
)
ocr_rows = deduplicated_text(d, chunk_minutes=5)
ocr_lines = "\n".join(
f"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}"
for r in ocr_rows[:100]
)
audio = formatted_transcript(d)
if len(audio) > 3000:
audio = audio[:3000]
return f"""You are analyzing screenpipe data — recordings of a person's computer activity.
## App usage (minutes per app):
{app_lines or '(no app data)'}
## Browser URLs visited:
{url_lines or '(no browser data)'}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_lines or '(no UI event data)'}
## Screen content (sampled every 5 minutes):
{ocr_lines or '(no screen data)'}
## Audio / speech:
{audio or '(no audio data)'}
Date: {d}
Total frames recorded: {stats['total_frames']}"""
def run_pipe(
pipe_id: str,
for_date: date | None = None,
api_key: str | None = None,
pipes_dir: Path | None = None,
) -> dict[str, Any]:
import anthropic
from consumers.activity import summary_stats
d = for_date or date.today()
key = api_key or os.environ.get("ANTHROPIC_API_KEY", "")
if not key:
return {"title": "Error", "content": "ANTHROPIC_API_KEY not set.", "date": str(d)}
_pipes_dir = pipes_dir or Path(os.environ.get("PIPES_DIR", "/data/pipes"))
all_pipes = {p["id"]: p for p in load_pipes(_pipes_dir)}
if pipe_id not in all_pipes:
return {"title": "Error", "content": f"Pipe not found: {pipe_id}", "date": str(d)}
pipe = all_pipes[pipe_id]
stats = summary_stats(d)
if stats["total_frames"] == 0:
return {"title": pipe["title"], "content": f"No screen data found for {d}.", "date": str(d)}
system = _build_system(d, stats)
client = anthropic.Anthropic(api_key=key)
message = client.messages.create(
model="claude-haiku-4-5-20251001",
max_tokens=1024,
system=system,
messages=[{"role": "user", "content": pipe["prompt"]}],
)
return {
"title": pipe["title"],
"content": message.content[0].text,
"date": str(d),
"stats": stats,
}
Now add the API endpoints to
main.py
:
Edit
main.py
main.py
Added 1 line
Edit
main.py
main.py
Added 1 line
Now add the pipe endpoints at the end of main.py, before the closing summary section:
Edit
main.py
main.py
Added 14 lines
Now add the CLI command to
cli.py
cli.py
:
Edit
cli.py
cli.py
Added 40 lines
Done. Here's how to run pipes:
How to run pipes
How to run pipes
Via Docker (inside the running container):
Copy code to clipboard
docker exec -it screenpipe-app python cli.py pipe --list
docker exec -it screenpipe-app python cli.py pipe day-recap
docker exec -it screenpipe-app python cli.py pipe standup-update --date yesterday
Via the API
(once the container is running on port 8766):
Copy code to clipboard
# List pipes
curl http://localhost:8766/api/pipes
# Run a pipe
curl -X POST "http://localhost:8766/api/pipes/day-recap/run"
curl -X POST "http://localhost:8766/api/pipes/standup-update/run?d=2026-04-25"
Rebuild and restart
to pick up the changes:
Copy code to clipboard
cd /volume1/screenpipe/app
docker compose up --build -d
How it works:
Each
pipe.md
file is loaded dynamically — the frontmatter provides metadata and the body becomes the user prompt. Screenpipe data (app usage, browser URLs, OCR, audio) is injected as a Claude system message so the pipe prompt can reference it naturally. The "Read screenpipe skill first" line is stripped automatically.
The pipes directory inside Docker is
/data/pipes
(since
/volume1/screenpipe
→
/data
). You can override it with a
PIPES_DIR
env var if needed.
Message actions
pipe.md
pipe.md
where to place api key and can I use different keys
Thinking
Thinking
Bash
Read .env file
IN
cat /volume1/screenpipe/app/.env
Copy code to clipboard
OUT
[ENV_SECRET]
Where to place the key:
app/.env
app/.env
— replace
your_key_here
with your actual key:
Copy code to clipboard
[ENV_SECRET]
That file is loaded by
load_dotenv()
at startup and is excluded from git via
.gitignore
.
Can you use different keys per pipe?
Not currently — all pipes share the one key from
.env
. But you can add per-pipe key support by adding an
api_key
field to the pipe's frontmatter:
Copy code to clipboard
---
title: Meeting Summary
api_key_env: ANTHROPIC_KEY_MEETINGS
---
Then in
consumers/pipes.py
consumers/pipes.py
, read it in...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
21075
|
921
|
8
|
2026-05-11T17:10:07.803191+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-11/1778 /Users/lukas/.screenpipe/data/data/2026-05-11/1778519407803_m2.jpg...
|
Code
|
Implement and run pipe l… — screenpipe [SSH: nas]
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧ Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py
M
db.py
docker-compose.yml
Dockerfile
M
main.py
M
requirements.txt
M
data
logs
pipes
.gitignore
app_settings.json
archive.db
archive.db-bak
U
db.sqlite
db.sqlite-shm
db.sqlite-wal
screenpipe_sync_updated.sh
U
screenpipe_sync.sh
screenpipe.db
Outline Section
OUTLINE
OUTLINE
Timeline Section...
|
[{"role":"AXRadioButton","text [{"role":"AXRadioButton","text":"Explorer (⇧⌘E)","depth":19,"bounds":{"left":0.0,"top":0.047885075,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":true},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.057462092,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Search (⇧⌘F)","depth":19,"bounds":{"left":0.0,"top":0.08619314,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.09577015,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Source Control (⌃⇧G) - 10 pending changes","depth":19,"bounds":{"left":0.0,"top":0.1245012,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.13407822,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"10","depth":22,"bounds":{"left":0.00831117,"top":0.1452514,"width":0.003656915,"height":0.008778931},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.00831117,"top":0.14604948,"width":0.0016622341,"height":0.007980846}},{"char_start":1,"char_count":1,"bounds":{"left":0.009973404,"top":0.14604948,"width":0.0023271276,"height":0.007980846}}],"role_description":"text"},{"role":"AXRadioButton","text":"Run and Debug (⇧⌘D)","depth":19,"bounds":{"left":0.0,"top":0.16280925,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.17238627,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Remote Explorer","depth":19,"bounds":{"left":0.0,"top":0.20111732,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.21069433,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Extensions (⇧⌘X) - 2 require update","depth":19,"bounds":{"left":0.0,"top":0.23942538,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.2490024,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"2","depth":22,"bounds":{"left":0.009640957,"top":0.2601756,"width":0.0019946808,"height":0.008778931},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Claude Code","depth":19,"bounds":{"left":0.0,"top":0.27773345,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"Containers","depth":19,"bounds":{"left":0.0,"top":0.3160415,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXHeading","text":"EXPLORER","depth":17,"bounds":{"left":0.022606382,"top":0.047885075,"width":0.018949468,"height":0.02793296},"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"EXPLORER","depth":18,"bounds":{"left":0.022606382,"top":0.056664005,"width":0.018949468,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.022606382,"top":0.056664005,"width":0.0023271276,"height":0.0103751}},{"char_start":1,"char_count":7,"bounds":{"left":0.024933511,"top":0.056664005,"width":0.01662234,"height":0.0103751}}],"role_description":"text"},{"role":"AXButton","text":"Explorer Section: screenpipe [SSH: nas]","depth":21,"bounds":{"left":0.015957447,"top":0.07581804,"width":0.09940159,"height":0.017557861},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":true},{"role":"AXStaticText","text":"","depth":23,"bounds":{"left":0.01662234,"top":0.07821229,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"Explorer Section: screenpipe [SSH: nas]","depth":22,"bounds":{"left":0.022606382,"top":0.07581804,"width":0.045877658,"height":0.017557861},"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"SCREENPIPE [SSH: NAS]","depth":23,"bounds":{"left":0.022606382,"top":0.079010375,"width":0.045877658,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.022606382,"top":0.07980846,"width":0.0026595744,"height":0.0103751}},{"char_start":1,"char_count":20,"bounds":{"left":0.025265958,"top":0.07980846,"width":0.043218084,"height":0.0103751}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.09577015,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"#recycle","depth":27,"bounds":{"left":0.025930852,"top":0.09577015,"width":0.017287234,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.096568234,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":7,"bounds":{"left":0.028590426,"top":0.096568234,"width":0.01462766,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.11332801,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"app","depth":27,"bounds":{"left":0.025930852,"top":0.11332801,"width":0.0076462766,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.11412609,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":2,"bounds":{"left":0.02825798,"top":0.11412609,"width":0.005319149,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.11412609,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.022273935,"top":0.13088587,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"__pycache__","depth":27,"bounds":{"left":0.028590426,"top":0.13088587,"width":0.026595745,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.13168396,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":10,"bounds":{"left":0.030917553,"top":0.13168396,"width":0.024268618,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.022273935,"top":0.14844373,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"consumers","depth":27,"bounds":{"left":0.028590426,"top":0.14844373,"width":0.022273935,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.14924182,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":8,"bounds":{"left":0.030917553,"top":0.14924182,"width":0.019946808,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.14924182,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.022273935,"top":0.1660016,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"static","depth":27,"bounds":{"left":0.028590426,"top":0.1660016,"width":0.010970744,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.16679968,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":5,"bounds":{"left":0.030917553,"top":0.16679968,"width":0.008976064,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.16679968,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.1819633,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":".env","depth":27,"bounds":{"left":0.028590426,"top":0.18355946,"width":0.00831117,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.18435754,"width":0.0013297872,"height":0.011971269}},{"char_start":1,"char_count":3,"bounds":{"left":0.029920213,"top":0.18435754,"width":0.006981383,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.19952115,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"cli.py","depth":27,"bounds":{"left":0.028590426,"top":0.20111732,"width":0.010638298,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.2019154,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":5,"bounds":{"left":0.030917553,"top":0.2019154,"width":0.00831117,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.2019154,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.21707901,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.py","depth":27,"bounds":{"left":0.028590426,"top":0.21867518,"width":0.011303191,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.21947326,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":4,"bounds":{"left":0.03125,"top":0.21947326,"width":0.008643617,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.23463687,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"docker-compose.yml","depth":27,"bounds":{"left":0.028590426,"top":0.23623304,"width":0.042220745,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.23703113,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":17,"bounds":{"left":0.03125,"top":0.23703113,"width":0.03956117,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.25219473,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Dockerfile","depth":27,"bounds":{"left":0.028590426,"top":0.25379092,"width":0.020611702,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.254589,"width":0.0033244682,"height":0.011971269}},{"char_start":1,"char_count":9,"bounds":{"left":0.031914894,"top":0.254589,"width":0.017287234,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.254589,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.2697526,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"main.py","depth":27,"bounds":{"left":0.028590426,"top":0.27134877,"width":0.015625,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.27214685,"width":0.003656915,"height":0.011971269}},{"char_start":1,"char_count":6,"bounds":{"left":0.032247342,"top":0.27214685,"width":0.012300532,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.27214685,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.28731045,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"requirements.txt","depth":27,"bounds":{"left":0.028590426,"top":0.28890663,"width":0.032912236,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.2897047,"width":0.0016622341,"height":0.011971269}},{"char_start":1,"char_count":15,"bounds":{"left":0.03025266,"top":0.2897047,"width":0.03158245,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.2897047,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.3064645,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"data","depth":27,"bounds":{"left":0.025930852,"top":0.3064645,"width":0.008976064,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.30726257,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":3,"bounds":{"left":0.028590426,"top":0.30726257,"width":0.0063164895,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.32402235,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"logs","depth":27,"bounds":{"left":0.025930852,"top":0.32402235,"width":0.00831117,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.32482043,"width":0.0009973404,"height":0.011971269}},{"char_start":1,"char_count":3,"bounds":{"left":0.026928192,"top":0.32482043,"width":0.0076462766,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.32482043,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.3415802,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"pipes","depth":27,"bounds":{"left":0.025930852,"top":0.3415802,"width":0.010970744,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.3423783,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":4,"bounds":{"left":0.028590426,"top":0.3423783,"width":0.00831117,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.3575419,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":".gitignore","depth":27,"bounds":{"left":0.025930852,"top":0.35913807,"width":0.018949468,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.35993615,"width":0.0013297872,"height":0.011971269}},{"char_start":1,"char_count":9,"bounds":{"left":0.027260639,"top":0.35993615,"width":0.017952127,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.37509975,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"app_settings.json","depth":27,"bounds":{"left":0.025930852,"top":0.37669593,"width":0.03557181,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.377494,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":16,"bounds":{"left":0.02825798,"top":0.377494,"width":0.03324468,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.3926576,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"archive.db","depth":27,"bounds":{"left":0.025930852,"top":0.3942538,"width":0.020944148,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.39505187,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":9,"bounds":{"left":0.02825798,"top":0.39505187,"width":0.01861702,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.4102155,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"archive.db-bak","depth":27,"bounds":{"left":0.025930852,"top":0.41181165,"width":0.03025266,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.41260973,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":13,"bounds":{"left":0.02825798,"top":0.41260973,"width":0.027925532,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"U","depth":27,"bounds":{"left":0.10704787,"top":0.41260973,"width":0.0029920214,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.42777336,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite","depth":27,"bounds":{"left":0.025930852,"top":0.4293695,"width":0.017287234,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.4301676,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":8,"bounds":{"left":0.028590426,"top":0.4301676,"width":0.014960106,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.44533122,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite-shm","depth":27,"bounds":{"left":0.025930852,"top":0.44692737,"width":0.027925532,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.44772545,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":12,"bounds":{"left":0.028590426,"top":0.44772545,"width":0.025265958,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.46288908,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite-wal","depth":27,"bounds":{"left":0.025930852,"top":0.46448523,"width":0.025930852,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.46528333,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":12,"bounds":{"left":0.028590426,"top":0.46528333,"width":0.023603724,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.48044693,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe_sync_updated.sh","depth":27,"bounds":{"left":0.025930852,"top":0.4820431,"width":0.059175532,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.4828412,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":25,"bounds":{"left":0.02825798,"top":0.4828412,"width":0.056848403,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"U","depth":27,"bounds":{"left":0.10704787,"top":0.4828412,"width":0.0029920214,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.4980048,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe_sync.sh","depth":27,"bounds":{"left":0.025930852,"top":0.49960095,"width":0.039893616,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.50039905,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":17,"bounds":{"left":0.02825798,"top":0.50039905,"width":0.037898935,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.51556265,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe.db","depth":27,"bounds":{"left":0.025930852,"top":0.5171588,"width":0.028590426,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.5179569,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":12,"bounds":{"left":0.02825798,"top":0.5179569,"width":0.026595745,"height":0.011971269}}],"role_description":"text"},{"role":"AXButton","text":"Outline Section","depth":21,"bounds":{"left":0.015957447,"top":0.9473264,"width":0.09940159,"height":0.017557861},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":23,"bounds":{"left":0.01662234,"top":0.9497207,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"OUTLINE","depth":22,"bounds":{"left":0.022606382,"top":0.9473264,"width":0.01662234,"height":0.017557861},"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"OUTLINE","depth":23,"bounds":{"left":0.022606382,"top":0.95131683,"width":0.01662234,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.022606382,"top":0.95131683,"width":0.0029920214,"height":0.0103751}},{"char_start":1,"char_count":6,"bounds":{"left":0.025598405,"top":0.95131683,"width":0.013630319,"height":0.0103751}}],"role_description":"text"},{"role":"AXButton","text":"Timeline Section","depth":21,"bounds":{"left":0.015957447,"top":0.9648843,"width":0.09940159,"height":0.017557861},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
5052856627539010827
|
-5480260736288902784
|
idle
|
accessibility
|
NULL
|
Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧ Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py
M
db.py
docker-compose.yml
Dockerfile
M
main.py
M
requirements.txt
M
data
logs
pipes
.gitignore
app_settings.json
archive.db
archive.db-bak
U
db.sqlite
db.sqlite-shm
db.sqlite-wal
screenpipe_sync_updated.sh
U
screenpipe_sync.sh
screenpipe.db
Outline Section
OUTLINE
OUTLINE
Timeline Section...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
21076
|
920
|
8
|
2026-05-11T17:10:19.434338+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-11/1778 /Users/lukas/.screenpipe/data/data/2026-05-11/1778519419434_m1.jpg...
|
Code
|
Implement and run pipe l… — screenpipe [SSH: nas]
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧ Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py
M
db.py
docker-compose.yml
Dockerfile
M
main.py
M
requirements.txt
M
data
logs
pipes
.gitignore
app_settings.json
archive.db
archive.db-bak
U
db.sqlite
db.sqlite-shm
db.sqlite-wal
screenpipe_sync_updated.sh
U
screenpipe_sync.sh
screenpipe.db
Outline Section
OUTLINE
OUTLINE
Timeline Section
TIMELINE
TIMELINE
app_settings.json, Editor Group 1
screenpipe_sync.sh, Editor Group 1
pipe.md, Editor Group 1
.env, Editor Group 1
[ENV_SECRET]
[ENV_SECRET]
Implement and run pipe l…, Editor Group 2
Problems (⇧⌘M)
PROBLEMS
Output (⇧⌘U)
OUTPUT
Debug Console (⇧⌘Y)
DEBUG CONSOLE
Terminal (⌃`)
TERMINAL
Ports - 1 forwarded port
PORTS
1
remote SSH: nas
SSH: nas
screenpipe (Git) - master*, Checkout Branch/Tag...
master*
screenpipe (Git) - Synchronize Changes
No Problems
0
0
Forwarded Ports: 8766
1
Notifications
Sign In
Sign In
Info: Setting up SSH Host nas: Setting up SSH tunnel
Implement and run pipe logic
Session history
New session
Message actions
main.py
main.py
lets implement logic with pipes. how can I run it?
Thinking
Thinking
Let me look at the current project structure to understand what's already in place.
Bash
List project files
IN
find /volume1/screenpipe -type f | head -50 && echo "---" && ls /volume1/screenpipe
Copy code to clipboard
OUT
/volume1/screenpipe/.DS_Store
/volume1/screenpipe/screenpipe.db
/volume1/screenpipe/screenpipe_sync.sh
/volume1/screenpipe/app_settings.json
/volume1/screenpipe/.gitignore
/volume1/screenpipe/archive.db
/volume1/screenpipe/db.sqlite
/volume1/screenpipe/db.sqlite-wal
/volume1/screenpipe/db.sqlite-shm
/volume1/screenpipe/#recycle/desktop.ini
/volume1/screenpipe/#recycle/db.sqlite
/volume1/screenpipe/#recycle/Copy #1 of db.sqlite
/volume1/screenpipe/#recycle/.DS_Store
/volume1/screenpipe/#recycle/Copy #2 of db.sqlite
/volume1/screenpipe/#recycle/archive.db
/volume1/screenpipe/#recycle/Copy #1 of archive.db
/volume1/screenpipe/#recycle/Copy #2 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of archive.db
/volume1/screenpipe/#recycle/Copy #4 of archive.db
/volume1/screenpipe/#recycle/Copy #5 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of db.sqlite
/volume1/screenpipe/#recycle/Copy #4 of db.sqlite
/volume1/screenpipe/#recycle/Copy #6 of archive.db
/volume1/screenpipe/#recycle/test.txt
/volume1/screenpipe/#recycle/Copy #7 of archive.db
/volume1/screenpipe/#recycle/Copy #8 of archive.db
/volume1/screenpipe/#recycle/archive.db-journal
/volume1/screenpipe/#recycle/Copy #1 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #2 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #3 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #4 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #6 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #7 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of db.sqlite
/volume1/screenpipe/pipes/.DS_Store
/volume1/screenpipe/app/.env
/volume1/screenpipe/app/cli.py
/volume1/screenpipe/app/.DS_Store
/volume1/screenpipe/app/db.py
/volume1/screenpipe/app/docker-compose.yml
/volume1/screenpipe/app/main.py
/volume1/screenpipe/app/requirements.txt
/volume1/screenpipe/app/Dockerfile
/volume1/screenpipe/data/.DS_Store
/volume1/screenpipe/.git/description
/volume1/screenpipe/.git/HEAD
/volume1/screenpipe/.git/index
/volume1/screenpipe/.git/COMMIT_EDITMSG
/volume1/screenpipe/#recycle/data/.DS_Store
---
app
app_settings.json
archive.db
data
db.sqlite
db.sqlite-shm
db.sqlite-wal
pipes
#recycle
screenpipe.db
screenpipe_sync.sh
Read
main.py
main.py
Bash
Check pipes directory and docker-compose
IN
ls /volume1/screenpipe/pipes/ && ls /volume1/screenpipe/app/ && cat /volume1/screenpipe/app/docker-compose.yml
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
cli.py
consumers
db.py
docker-compose.yml
Dockerfile
main.py
__pycache__
requirements.txt
static
services:
screenpipe-app:
build: .
container_name: screenpipe-app
restart: unless-stopped
ports:
- "8766:8000"
volumes:
- /volume1/screenpipe:/data
env_file:
- .env
environment:
TZ: Europe/Sofia
DB_PATH: /data/db.sqlite
sqlite-web-archive:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-archive
restart: unless-stopped
ports:
- "8767:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/archive.db"]
sqlite-web-live:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-live
restart: unless-stopped
ports:
- "8768:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/db.sqlite"]
Read
requirements.txt
requirements.txt
Bash
Inspect a pipe directory
IN
ls /volume1/screenpipe/pipes/day-recap/ && cat /volume1/screenpipe/pipes/day-recap/pipe.json 2>/dev/null || ls /volume1/screenpipe/pipes/day-recap/
Copy code to clipboard
OUT
pipe.md
pipe.md
Read
cli.py
cli.py
Bash
List all pipes and their contents
IN
ls /volume1/screenpipe/pipes/ && for d in /volume1/screenpipe/pipes/*/; do echo "=== $d ==="; ls "$d"; done
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
=== /volume1/screenpipe/pipes/ai-habits/ ===
pipe.md
=== /volume1/screenpipe/pipes/day-recap/ ===
pipe.md
=== /volume1/screenpipe/pipes/meeting-summary/ ===
pipe.md
=== /volume1/screenpipe/pipes/standup-update/ ===
pipe.md
=== /volume1/screenpipe/pipes/time-breakdown/ ===
pipe.md
=== /volume1/screenpipe/pipes/video-export/ ===
pipe.md
Bash
Read pipe markdown files
IN
cat /volume1/screenpipe/pipes/day-recap/pipe.md && echo "===" && cat /volume1/screenpipe/pipes/meeting-summary/pipe.md 2>/dev/null | head -50
Copy code to clipboard
OUT
---
schedule: manual
enabled: true
template: true
title: Day Recap
description: "Today's accomplishments, key moments, and unfinished work"
icon: "📋"
featured: true
---
Analyze my screen and audio recordings from today (last 16 hours only).
Read screenpipe skill first.
Use this exact format:
## Summary
One sentence: what I mainly did today.
## Accomplishments
- Top 3 things I finished, with timestamps (e.g. "2:30 PM")
- Name specific apps, files, or projects
## Key Moments
- Important things I saw, said, or heard — with timestamps
## Unfinished Work
- What I should continue tomorrow — name the app/file/task
## Patterns
- Apps I used most, topics that came up repeatedly
Only report what you can verify from the data. End with: "**Next step:** [most important thing to continue]"
===
---
schedule: manual
enabled: true
template: true
title: Meeting Summary
description: "Summarize meeting transcript with key takeaways and action items"
icon: "🤝"
featured: false
---
Summarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.
Read screenpipe skill first.
Use this exact format:
## Meeting Summary
One sentence: what this meeting was about.
## Key Takeaways
- Top 3-5 important points discussed
- Include who said what when relevant
## Action Items
- [ ] Task — assigned to whom, deadline if mentioned
- [ ] Task — assigned to whom
## Decisions Made
- List any decisions or agreements reached
## Open Questions
- Anything unresolved or needing follow-up
Keep it concise and actionable.
Thinking
Thinking
Bash
Read summary consumer
IN
ls /volume1/screenpipe/app/consumers/ && cat /volume1/screenpipe/app/consumers/summary.py
Copy code to clipboard
OUT
activity.py
audio.py
elements.py
__init__.py
interactions.py
ocr.py
__pycache__
report.py
summary.py
"""AI summary generator using Claude."""
import os
from datetime import date
from typing import Any
from consumers.activity import app_time, summary_stats, browser_urls, ui_event_summary
from consumers.ocr import deduplicated_text
from consumers.audio import formatted_transcript
SUMMARY_TYPES = {
"day_recap": {
"title": "Day Recap",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
## Audio/speech:
{audio}
Write a concise day recap using EXACTLY this format:
## Summary
One sentence: what I mainly worked on today.
## Accomplishments
- Top 3 things I finished, with approximate times
- Name specific apps, files, or projects
## Key Moments
- Important things seen or heard, with timestamps
## Unfinished Work
- What to continue tomorrow
## Patterns
- Apps used most, topics that came up repeatedly
Only report what you can verify from the data. End with:
**Next step:** [most important thing to continue]""",
},
"standup": {
"title": "Standup Update",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
## Audio/speech:
{audio}
Write a brief standup update:
**Yesterday:** What I worked on (2-3 bullets)
**Today:** What I plan to continue (1-2 bullets)
**Blockers:** Any issues observed (or "None")
Keep it under 150 words. Only report what's verifiable from the data.""",
},
"focus_time": {
"title": "Focus & Distraction Analysis",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
Analyze focus vs distraction patterns:
## Deep Work Periods
- When and how long were sustained focus sessions?
- What was being worked on?
## Distractions
- Which apps/sites were used recreationally?
- How much time was lost to context switching?
## Recommendations
- 2-3 concrete suggestions to improve focus tomorrow
Be specific with times and app names.""",
},
}
def _build_context(for_date: date) -> dict[str, str]:
apps = app_time(for_date)
app_lines = "\n".join(f"- {a['app_name']}: {a['minutes']} min" for a in apps[:20])
urls = browser_urls(for_date, limit=20)
url_lines = "\n".join(
f"- {u['browser_url'][:100]} ({u['minutes']} min)" for u in urls
)
ui_rows = ui_event_summary(for_date)
ui_lines = "\n".join(
f"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches"
for r in ui_rows[:15]
)
ocr_rows = deduplicated_text(for_date, chunk_minutes=5)
ocr_lines = "\n".join(
f"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}"
for r in ocr_rows[:100]
)
audio = formatted_transcript(for_date)
return {
"app_time": app_lines or "(no app data)",
"browser_urls": url_lines or "(no browser data)",
"ui_events": ui_lines or "(no UI event data)",
"ocr_text": ocr_lines or "(no screen data)",
"audio": audio[:3000] if len(audio) > 3000 else audio,
}
def generate(
summary_type: str = "day_recap",
for_date: date | None = None,
api_key: str | None = None,
) -> dict[str, Any]:
"""Generate an AI summary. Returns dict with 'title', 'content', 'date'."""
import anthropic
d = for_date or date.today()
key = api_key or os.environ.get("ANTHROPIC_API_KEY", "")
if not key:
return {
"title": "Error",
"content": "ANTHROPIC_API_KEY not set. Add it to your .env file.",
"date": str(d),
}
spec = SUMMARY_TYPES.get(summary_type)
if not spec:
return {"title": "Error", "content": f"Unknown summary type: {summary_type}", "date": str(d)}
stats = summary_stats(d)
if stats["total_frames"] == 0:
return {
"title": spec["title"],
"content": f"No screen data found for {d}.",
"date": str(d),
}
ctx = _build_context(d)
prompt = spec["prompt"].format(**ctx)
client = anthropic.Anthropic(api_key=key)
message = client.messages.create(
model="claude-haiku-4-5-20251001",
max_tokens=1024,
messages=[{"role": "user", "content": prompt}],
)
return {
"title": spec["title"],
"content": message.content[0].text,
"date": str(d),
"stats": stats,
}
Thinking
Thinking
Bash
Read all pipe.md files
IN
for f in /volume1/screenpipe/pipes/*/pipe.md; do echo "=== $f ==="; cat "$f"; echo; done
Copy code to clipboard
OUT
=== /volume1/screenpipe/pipes/ai-habits/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: AI Habits
description: "How you use AI tools — patterns and insights"
icon: "🤖"
featured: true
---
Search my recordings from the last 24 hours for AI tool usage. Use app_name filter for each tool separately: ChatGPT, Claude, Copilot, Cursor, Gemini, Perplexity. Use limit=5 per search, max 6 searches total.
Read screenpipe skill first.
Use this exact format:
## AI Tools Used
- List each tool with approximate time spent (e.g. "Claude: ~45min")
## What I Used Them For
- For each tool: coding, writing, research, or brainstorming
## Usage Patterns
- Do I switch between tools? Use them in bursts or steadily?
## Effectiveness
- Which tool appeared alongside completed work vs. abandoned attempts
If no AI usage is found, say so clearly. End with: "**Tip:** [one suggestion to use AI tools more effectively]"
=== /volume1/screenpipe/pipes/day-recap/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Day Recap
description: "Today's accomplishments, key moments, and unfinished work"
icon: "📋"
featured: true
---
Analyze my screen and audio recordings from today (last 16 hours only).
Read screenpipe skill first.
Use this exact format:
## Summary
One sentence: what I mainly did today.
## Accomplishments
- Top 3 things I finished, with timestamps (e.g. "2:30 PM")
- Name specific apps, files, or projects
## Key Moments
- Important things I saw, said, or heard — with timestamps
## Unfinished Work
- What I should continue tomorrow — name the app/file/task
## Patterns
- Apps I used most, topics that came up repeatedly
Only report what you can verify from the data. End with: "**Next step:** [most important thing to continue]"
=== /volume1/screenpipe/pipes/meeting-summary/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Meeting Summary
description: "Summarize meeting transcript with key takeaways and action items"
icon: "🤝"
featured: false
---
Summarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.
Read screenpipe skill first.
Use this exact format:
## Meeting Summary
One sentence: what this meeting was about.
## Key Takeaways
- Top 3-5 important points discussed
- Include who said what when relevant
## Action Items
- [ ] Task — assigned to whom, deadline if mentioned
- [ ] Task — assigned to whom
## Decisions Made
- List any decisions or agreements reached
## Open Questions
- Anything unresolved or needing follow-up
Keep it concise and actionable.
=== /volume1/screenpipe/pipes/standup-update/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Standup Update
description: "What you did, what's next, and any blockers"
icon: "🏢"
featured: true
---
Based on my recordings from the last 24 hours, generate a standup update. Use limit=10 per search, max 3 searches total.
Read screenpipe skill first.
Use this exact format:
## Yesterday
- What I worked on (name specific projects, files, tools, PRs)
## Today
- What I will work on next (based on unfinished tasks and recent activity)
## Blockers
- Issues I hit — errors, slow builds, waiting on someone
- If no blockers, write "None"
Keep it under 150 words. Copy-paste ready for a team standup.
=== /volume1/screenpipe/pipes/time-breakdown/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Time Breakdown
description: "Where your time went — by app, project, and category"
icon: "⏱"
featured: false
---
Analyze my app usage from today (last 12 hours). Use limit=10 per search, max 4 searches. Prefer /raw_sql with COUNT/GROUP BY queries.
Read screenpipe skill first.
Use this exact format with durations and percentages:
## By Application
- List each app with duration and percentage, sorted by time (e.g. "VS Code: 2h 15min (28%)")
## By Category
- Group into: coding, meetings, browsing, writing, communication, other
- Show hours and percentage per category
## By Project
- Group related activities by project/topic. Name specific repos or tasks.
## Productivity Score
- Calculate: focused_work_hours / total_hours as a percentage
- Focused = coding + writing. Unfocused = browsing + switching.
End with: "**Suggestion:** [one specific change to improve tomorrow's productivity]"
=== /volume1/screenpipe/pipes/video-export/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Export Video Clip
description: "Create a video of your recent screen activity"
icon: "🎬"
featured: false
---
Export a video of my screen activity from the last 5 minutes.
Read screenpipe skill first.
Use the POST /frames/export endpoint with the time range and fps=1.0. Then show me the exported video file path as an inline code block so I can watch it.
If the export is large, suggest a lower fps or shorter time range.
Thinking
Thinking
Now I have a clear picture. The pipes are markdown prompt templates in
/volume1/screenpipe/pipes/
, but there's no code to actually load and run them —
consumers/summary.py
has its own hardcoded prompts instead.
Here's what I'll implement:
consumers/pipes.py
— dynamically loads pipe.md files and runs them via Claude (data injected as system message, pipe body as user prompt)
main.py
— two new endpoints:
GET /api/pipes
and
POST /api/pipes/{pipe_id}/run
cli.py
— a
pipe
command to run pipes from the terminal
Let me build it:
Bash
Check browser_urls signature
IN
cat /volume1/screenpipe/app/consumers/activity.py | grep "def browser_urls" -A 5
Copy code to clipboard
OUT
def browser_urls(
for_date: date | None = None,
app_name: str | None = None,
ts_from: str | None = None,
ts_to: str | None = None,
limit: int = 30,
Write
pipes.py
pipes.py
143 lines
"""Dynamic pipe loader and runner."""
import os
import re
from datetime import date
from pathlib import Path
from typing import Any
def _parse_frontmatter(text: str) -> tuple[dict, str]:
if not text.startswith("---"):
return {}, text
try:
end = text.index("---", 3)
except ValueError:
return {}, text
fm_text = text[3:end].strip()
body = text[end + 3:].strip()
meta: dict = {}
for line in fm_text.splitlines():
if ":" in line:
k, _, v = line.partition(":")
meta[k.strip()] = v.strip().strip('"')
return meta, body
def load_pipes(pipes_dir: Path) -> list[dict]:
if not pipes_dir.exists():
return []
pipes = []
for pipe_dir in sorted(pipes_dir.iterdir()):
if not pipe_dir.is_dir() or pipe_dir.name.startswith("."):
continue
pipe_md = pipe_dir / "pipe.md"
if not pipe_md.exists():
continue
text = pipe_md.read_text(encoding="utf-8")
meta, body = _parse_frontmatter(text)
if meta.get("enabled", "true").lower() == "false":
continue
body = re.sub(r"Read screenpipe skill first\.?\n?", "", body).strip()
pipes.append({
"id": pipe_dir.name,
"title": meta.get("title", pipe_dir.name),
"description": meta.get("description", ""),
"icon": meta.get("icon", ""),
"schedule": meta.get("schedule", "manual"),
"featured": meta.get("featured", "false").lower() == "true",
"prompt": body,
})
return pipes
def _build_system(d: date, stats: dict) -> str:
from consumers.activity import app_time, browser_urls, ui_event_summary
from consumers.ocr import deduplicated_text
from consumers.audio import formatted_transcript
apps = app_time(d)
app_lines = "\n".join(f"- {a['app_name']}: {a['minutes']} min" for a in apps[:20])
urls = browser_urls(d, limit=20)
url_lines = "\n".join(f"- {u['browser_url'][:100]} ({u['minutes']} min)" for u in urls)
ui_rows = ui_event_summary(d)
ui_lines = "\n".join(
f"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches"
for r in ui_rows[:15]
)
ocr_rows = deduplicated_text(d, chunk_minutes=5)
ocr_lines = "\n".join(
f"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}"
for r in ocr_rows[:100]
)
audio = formatted_transcript(d)
if len(audio) > 3000:
audio = audio[:3000]
return f"""You are analyzing screenpipe data — recordings of a person's computer activity.
## App usage (minutes per app):
{app_lines or '(no app data)'}
## Browser URLs visited:
{url_lines or '(no browser data)'}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_lines or '(no UI event data)'}
## Screen content (sampled every 5 minutes):
{ocr_lines or '(no screen data)'}
## Audio / speech:
{audio or '(no audio data)'}
Date: {d}
Total frames recorded: {stats['total_frames']}"""
def run_pipe(
pipe_id: str,
for_date: date | None = None,
api_key: str | None = None,
pipes_dir: Path | None = None,
) -> dict[str, Any]:
import anthropic
from consumers.activity import summary_stats
d = for_date or date.today()
key = api_key or os.environ.get("ANTHROPIC_API_KEY", "")
if not key:
return {"title": "Error", "content": "ANTHROPIC_API_KEY not set.", "date": str(d)}
_pipes_dir = pipes_dir or Path(os.environ.get("PIPES_DIR", "/data/pipes"))
all_pipes = {p["id"]: p for p in load_pipes(_pipes_dir)}
if pipe_id not in all_pipes:
return {"title": "Error", "content": f"Pipe not found: {pipe_id}", "date": str(d)}
pipe = all_pipes[pipe_id]
stats = summary_stats(d)
if stats["total_frames"] == 0:
return {"title": pipe["title"], "content": f"No screen data found for {d}.", "date": str(d)}
system = _build_system(d, stats)
client = anthropic.Anthropic(api_key=key)
message = client.messages.create(
model="claude-haiku-4-5-20251001",
max_tokens=1024,
system=system,
messages=[{"role": "user", "content": pipe["prompt"]}],
)
return {
"title": pipe["title"],
"content": message.content[0].text,
"date": str(d),
"stats": stats,
}
Now add the API endpoints to
main.py
:
Edit
main.py
main.py
Added 1 line
Edit
main.py
main.py
Added 1 line
Now add the pipe endpoints at the end of main.py, before the closing summary section:
Edit
main.py
main.py
Added 14 lines
Now add the CLI command to
cli.py
cli.py
:
Edit
cli.py
cli.py
Added 40 lines
Done. Here's how to run pipes:
How to run pipes
How to run pipes
Via Docker (inside the running container):
Copy code to clipboard
docker exec -it screenpipe-app python cli.py pipe --list
docker exec -it screenpipe-app python cli.py pipe day-recap
docker exec -it screenpipe-app python cli.py pipe standup-update --date yesterday
Via the API
(once the container is running on port 8766):
Copy code to clipboard
# List pipes
curl http://localhost:8766/api/pipes
# Run a pipe
curl -X POST "http://localhost:8766/api/pipes/day-recap/run"
curl -X POST "http://localhost:8766/api/pipes/standup-update/run?d=2026-04-25"
Rebuild and restart
to pick up the changes:
Copy code to clipboard
cd /volume1/screenpipe/app
docker compose up --build -d
How it works:
Each
pipe.md
file is loaded dynamically — the frontmatter provides metadata and the body becomes the user prompt. Screenpipe data (app usage, browser URLs, OCR, audio) is injected as a Claude system message so the pipe prompt can reference it naturally. The "Read screenpipe skill first" line is stripped automatically.
The pipes directory inside Docker is
/data/pipes
(since
/volume1/screenpipe
→
/data
). You can override it with a
PIPES_DIR
env var if needed.
Message actions
pipe.md
pipe.md
where to place api key and can I use different keys
Thinking
Thinking
Bash
Read .env file
IN
cat /volume1/screenpipe/app/.env
Copy code to clipboard
OUT
[ENV_SECRET]
Where to place the key:
app/.env
app/.env
— replace
your_key_here
with your actual key:
Copy code to clipboard
[ENV_SECRET]
That file is loaded by
load_dotenv()
at startup and is excluded from git via
.gitignore
.
Can you use different keys per pipe?
Not currently — all pipes share the one key from
.env
. But you can add per-pipe key support by adding an
api_key
field to the pipe's frontmatter:
Copy code to clipboard
---
title: Meeting Summary
api_key_env: ANTHROPIC_KEY_MEETINGS
---
Then in
consumers/pipes.py
consumers/pipes.py
, read it in
_parse_frontmatter
and pass it through
run_pipe
. Want me to add that?
Message actions
pipe.md
pipe.md
can I use mistral or other llm? or is is build for antrophic only
Thinking
Thinking
Currently it's Anthropic-only — the code calls the
anthropic
SDK directly in both
consumers/pipes.py
consumers/pipes.py
and
consumers/summary.py
consumers/summary.py
.
Adding other providers is straightforward since Mistral, Ollama, OpenRouter, Groq, and most modern LLMs expose an OpenAI-compatible API. The cleanest approach: add the
openai
package and let you configure the provider via
.env
:
Copy code to clipboard
# Anthropic (default)
[ENV_SECRET]
# OR: any OpenAI-compatible provider
LLM_PROVIDER=openai-compatible
LLM_BASE_URL=https://api.mistral.ai/v1
[ENV_SECRET]
LLM_MODEL=mistral-small-latest
This would cover Mistral, Ollama (
http://localhost:11434/v1
), OpenRouter, Groq, etc. with one code path.
Want me to implement that? It's a small change — a
_call_llm(system, user_prompt)
helper in
pipes.py
that branches on
LLM_PROVIDER
, and
openai
added to
requirements.txt
.
Message actions
lets test it with anthropic first, how to run pipe
Thinking
Thinking
Bash
Check if container is running
IN
cd /volume1/screenpipe/app && docker compose ps 2>/dev/null || docker ps --filter name=screenpipe
Copy code to clipboard
OUT
Exit code 1
permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get "http://%2Fvar%2Frun%2Fdocker.sock/v1.45/containers/json?filters=%7B%22name%22%3A%7B%22screenpipe%22%3Atrue%7D%7D": dial unix /var/run/docker.sock: connect: permission denied
I don't have Docker socket access, so you'll need to run these yourself. Here are your options:
Option A — via Docker (if container is already running):
Copy code to clipboard
# List available pipes
docker exec -it screenpipe-app python cli.py pipe --list
# Run a specific pipe
docker exec -it screenpipe-app python cli.py pipe day-recap
Option B — rebuild first (since we added new files), then run:
Copy code to clipboard
cd /volume1/screenpipe/app
docker compose up --build -d
docker exec -it screenpipe-app python cli.py pipe day-recap
Option C — via the API
(if container is up on port 8766):
Copy code to clipboard
# List pipes
curl http://localhost:8766/api/pipes
# Run a pipe
curl -X POST http://localhost:8766/api/pipes/day-recap/run
The...
|
[{"role":"AXRadioButton","text [{"role":"AXRadioButton","text":"Explorer (⇧⌘E)","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":true},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Search (⇧⌘F)","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Source Control (⌃⇧G) - 10 pending changes","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"10","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Run and Debug (⇧⌘D)","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Remote Explorer","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Extensions (⇧⌘X) - 2 require update","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"2","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Claude Code","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"Containers","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXHeading","text":"EXPLORER","depth":17,"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"EXPLORER","depth":18,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Explorer Section: screenpipe [SSH: nas]","depth":21,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":true},{"role":"AXStaticText","text":"","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"Explorer Section: screenpipe [SSH: nas]","depth":22,"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"SCREENPIPE [SSH: NAS]","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"#recycle","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"app","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"__pycache__","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"consumers","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"static","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":".env","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"cli.py","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.py","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"docker-compose.yml","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Dockerfile","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"main.py","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"requirements.txt","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"data","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"logs","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"pipes","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":".gitignore","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"app_settings.json","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"archive.db","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"archive.db-bak","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"U","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite-shm","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite-wal","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe_sync_updated.sh","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"U","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe_sync.sh","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe.db","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Outline Section","depth":21,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"OUTLINE","depth":22,"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"OUTLINE","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Timeline Section","depth":21,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"TIMELINE","depth":22,"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"TIMELINE","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"app_settings.json, Editor Group 1","depth":28,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"screenpipe_sync.sh, Editor Group 1","depth":28,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"pipe.md, Editor Group 1","depth":28,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":".env, Editor Group 1","depth":28,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":false},{"role":"AXStaticText","text":"","depth":29,"on_screen":true,"role_description":"text"},{"role":"AXTextArea","text":"ANTHROPIC_API_KEY=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","depth":28,"on_screen":true,"value":"ANTHROPIC_API_KEY=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","role_description":"editor","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"ANTHROPIC_API_KEY=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","depth":29,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Implement and run pipe l…, Editor Group 2","depth":28,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":false},{"role":"AXRadioButton","text":"Problems (⇧⌘M)","depth":22,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"PROBLEMS","depth":24,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Output (⇧⌘U)","depth":22,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUTPUT","depth":24,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Debug Console (⇧⌘Y)","depth":22,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"DEBUG CONSOLE","depth":24,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Terminal (⌃`)","depth":22,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":true},{"role":"AXStaticText","text":"TERMINAL","depth":24,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Ports - 1 forwarded port","depth":22,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"PORTS","depth":24,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":25,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"remote SSH: nas","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"SSH: nas","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"screenpipe (Git) - master*, Checkout Branch/Tag...","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"master*","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"screenpipe (Git) - Synchronize Changes","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"No Problems","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"0","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"0","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Forwarded Ports: 8766","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Notifications","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sign In","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Sign In","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Info: Setting up SSH Host nas: Setting up SSH tunnel","depth":12,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Implement and run pipe logic","depth":19,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Session history","depth":19,"on_screen":true,"help_text":"Session history","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"New session","depth":19,"on_screen":true,"help_text":"New session","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Message actions","depth":24,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"main.py","depth":23,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"lets implement logic with pipes. how can I run it?","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Let me look at the current project structure to understand what's already in place.","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"List project files","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"find /volume1/screenpipe -type f | head -50 && echo \"---\" && ls /volume1/screenpipe","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"/volume1/screenpipe/.DS_Store\n/volume1/screenpipe/screenpipe.db\n/volume1/screenpipe/screenpipe_sync.sh\n/volume1/screenpipe/app_settings.json\n/volume1/screenpipe/.gitignore\n/volume1/screenpipe/archive.db\n/volume1/screenpipe/db.sqlite\n/volume1/screenpipe/db.sqlite-wal\n/volume1/screenpipe/db.sqlite-shm\n/volume1/screenpipe/#recycle/desktop.ini\n/volume1/screenpipe/#recycle/db.sqlite\n/volume1/screenpipe/#recycle/Copy #1 of db.sqlite\n/volume1/screenpipe/#recycle/.DS_Store\n/volume1/screenpipe/#recycle/Copy #2 of db.sqlite\n/volume1/screenpipe/#recycle/archive.db\n/volume1/screenpipe/#recycle/Copy #1 of archive.db\n/volume1/screenpipe/#recycle/Copy #2 of archive.db\n/volume1/screenpipe/#recycle/Copy #3 of archive.db\n/volume1/screenpipe/#recycle/Copy #4 of archive.db\n/volume1/screenpipe/#recycle/Copy #5 of archive.db\n/volume1/screenpipe/#recycle/Copy #3 of db.sqlite\n/volume1/screenpipe/#recycle/Copy #4 of db.sqlite\n/volume1/screenpipe/#recycle/Copy #6 of archive.db\n/volume1/screenpipe/#recycle/test.txt\n/volume1/screenpipe/#recycle/Copy #7 of archive.db\n/volume1/screenpipe/#recycle/Copy #8 of archive.db\n/volume1/screenpipe/#recycle/archive.db-journal\n/volume1/screenpipe/#recycle/Copy #1 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #2 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #3 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #4 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #5 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #6 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #7 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #5 of db.sqlite\n/volume1/screenpipe/pipes/.DS_Store\n/volume1/screenpipe/app/.env\n/volume1/screenpipe/app/cli.py\n/volume1/screenpipe/app/.DS_Store\n/volume1/screenpipe/app/db.py\n/volume1/screenpipe/app/docker-compose.yml\n/volume1/screenpipe/app/main.py\n/volume1/screenpipe/app/requirements.txt\n/volume1/screenpipe/app/Dockerfile\n/volume1/screenpipe/data/.DS_Store\n/volume1/screenpipe/.git/description\n/volume1/screenpipe/.git/HEAD\n/volume1/screenpipe/.git/index\n/volume1/screenpipe/.git/COMMIT_EDITMSG\n/volume1/screenpipe/#recycle/data/.DS_Store\n---\napp\napp_settings.json\narchive.db\ndata\ndb.sqlite\ndb.sqlite-shm\ndb.sqlite-wal\npipes\n#recycle\nscreenpipe.db\nscreenpipe_sync.sh","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"main.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Check pipes directory and docker-compose","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/pipes/ && ls /volume1/screenpipe/app/ && cat /volume1/screenpipe/app/docker-compose.yml","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ai-habits\nday-recap\nmeeting-summary\nstandup-update\ntime-breakdown\nvideo-export\ncli.py\nconsumers\ndb.py\ndocker-compose.yml\nDockerfile\nmain.py\n__pycache__\nrequirements.txt\nstatic\nservices:\n screenpipe-app:\n build: .\n container_name: screenpipe-app\n restart: unless-stopped\n ports:\n - \"8766:8000\"\n volumes:\n - /volume1/screenpipe:/data\n env_file:\n - .env\n environment:\n TZ: Europe/Sofia\n DB_PATH: /data/db.sqlite\n\n sqlite-web-archive:\n image: ghcr.io/coleifer/sqlite-web:latest\n container_name: screenpipe-sqlweb-archive\n restart: unless-stopped\n ports:\n - \"8767:8080\"\n volumes:\n - /volume1/screenpipe:/data\n command: [\"-H\", \"0.0.0.0\", \"-r\", \"/data/archive.db\"]\n\n sqlite-web-live:\n image: ghcr.io/coleifer/sqlite-web:latest\n container_name: screenpipe-sqlweb-live\n restart: unless-stopped\n ports:\n - \"8768:8080\"\n volumes:\n - /volume1/screenpipe:/data\n command: [\"-H\", \"0.0.0.0\", \"-r\", \"/data/db.sqlite\"]","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"requirements.txt","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"requirements.txt","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Inspect a pipe directory","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/pipes/day-recap/ && cat /volume1/screenpipe/pipes/day-recap/pipe.json 2>/dev/null || ls /volume1/screenpipe/pipes/day-recap/","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"pipe.md\npipe.md","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"cli.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"cli.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"List all pipes and their contents","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/pipes/ && for d in /volume1/screenpipe/pipes/*/; do echo \"=== $d ===\"; ls \"$d\"; done","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ai-habits\nday-recap\nmeeting-summary\nstandup-update\ntime-breakdown\nvideo-export\n=== /volume1/screenpipe/pipes/ai-habits/ ===\npipe.md\n=== /volume1/screenpipe/pipes/day-recap/ ===\npipe.md\n=== /volume1/screenpipe/pipes/meeting-summary/ ===\npipe.md\n=== /volume1/screenpipe/pipes/standup-update/ ===\npipe.md\n=== /volume1/screenpipe/pipes/time-breakdown/ ===\npipe.md\n=== /volume1/screenpipe/pipes/video-export/ ===\npipe.md","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read pipe markdown files","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"cat /volume1/screenpipe/pipes/day-recap/pipe.md && echo \"===\" && cat /volume1/screenpipe/pipes/meeting-summary/pipe.md 2>/dev/null | head -50","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Day Recap\ndescription: \"Today's accomplishments, key moments, and unfinished work\"\nicon: \"📋\"\nfeatured: true\n---\n\nAnalyze my screen and audio recordings from today (last 16 hours only). \n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Summary\nOne sentence: what I mainly did today.\n\n## Accomplishments\n- Top 3 things I finished, with timestamps (e.g. \"2:30 PM\")\n- Name specific apps, files, or projects\n\n## Key Moments\n- Important things I saw, said, or heard — with timestamps\n\n## Unfinished Work\n- What I should continue tomorrow — name the app/file/task\n\n## Patterns\n- Apps I used most, topics that came up repeatedly\n\nOnly report what you can verify from the data. End with: \"**Next step:** [most important thing to continue]\"\n===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Meeting Summary\ndescription: \"Summarize meeting transcript with key takeaways and action items\"\nicon: \"🤝\"\nfeatured: false\n---\n\nSummarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.\n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Meeting Summary\nOne sentence: what this meeting was about.\n\n## Key Takeaways\n- Top 3-5 important points discussed\n- Include who said what when relevant\n\n## Action Items\n- [ ] Task — assigned to whom, deadline if mentioned\n- [ ] Task — assigned to whom\n\n## Decisions Made\n- List any decisions or agreements reached\n\n## Open Questions\n- Anything unresolved or needing follow-up\n\nKeep it concise and actionable.","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read summary consumer","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/app/consumers/ && cat /volume1/screenpipe/app/consumers/summary.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"activity.py\naudio.py\nelements.py\n__init__.py\ninteractions.py\nocr.py\n__pycache__\nreport.py\nsummary.py\n\"\"\"AI summary generator using Claude.\"\"\"\nimport os\nfrom datetime import date\nfrom typing import Any\n\nfrom consumers.activity import app_time, summary_stats, browser_urls, ui_event_summary\nfrom consumers.ocr import deduplicated_text\nfrom consumers.audio import formatted_transcript\n\n\nSUMMARY_TYPES = {\n \"day_recap\": {\n \"title\": \"Day Recap\",\n \"prompt\": \"\"\"\\\nYou are analyzing a person's computer activity for the day.\n\n## App usage (minutes per app):\n{app_time}\n\n## Browser URLs visited:\n{browser_urls}\n\n## UI activity per app (clicks / keystrokes / app-switches):\n{ui_events}\n\n## Screen content (sampled every 5 minutes):\n{ocr_text}\n\n## Audio/speech:\n{audio}\n\nWrite a concise day recap using EXACTLY this format:\n\n## Summary\nOne sentence: what I mainly worked on today.\n\n## Accomplishments\n- Top 3 things I finished, with approximate times\n- Name specific apps, files, or projects\n\n## Key Moments\n- Important things seen or heard, with timestamps\n\n## Unfinished Work\n- What to continue tomorrow\n\n## Patterns\n- Apps used most, topics that came up repeatedly\n\nOnly report what you can verify from the data. End with:\n**Next step:** [most important thing to continue]\"\"\",\n },\n \"standup\": {\n \"title\": \"Standup Update\",\n \"prompt\": \"\"\"\\\nYou are analyzing a person's computer activity for the day.\n\n## App usage (minutes per app):\n{app_time}\n\n## Browser URLs visited:\n{browser_urls}\n\n## UI activity per app (clicks / keystrokes / app-switches):\n{ui_events}\n\n## Screen content (sampled every 5 minutes):\n{ocr_text}\n\n## Audio/speech:\n{audio}\n\nWrite a brief standup update:\n\n**Yesterday:** What I worked on (2-3 bullets)\n**Today:** What I plan to continue (1-2 bullets)\n**Blockers:** Any issues observed (or \"None\")\n\nKeep it under 150 words. Only report what's verifiable from the data.\"\"\",\n },\n \"focus_time\": {\n \"title\": \"Focus & Distraction Analysis\",\n \"prompt\": \"\"\"\\\nYou are analyzing a person's computer activity for the day.\n\n## App usage (minutes per app):\n{app_time}\n\n## Browser URLs visited:\n{browser_urls}\n\n## UI activity per app (clicks / keystrokes / app-switches):\n{ui_events}\n\n## Screen content (sampled every 5 minutes):\n{ocr_text}\n\nAnalyze focus vs distraction patterns:\n\n## Deep Work Periods\n- When and how long were sustained focus sessions?\n- What was being worked on?\n\n## Distractions\n- Which apps/sites were used recreationally?\n- How much time was lost to context switching?\n\n## Recommendations\n- 2-3 concrete suggestions to improve focus tomorrow\n\nBe specific with times and app names.\"\"\",\n },\n}\n\n\ndef _build_context(for_date: date) -> dict[str, str]:\n apps = app_time(for_date)\n app_lines = \"\\n\".join(f\"- {a['app_name']}: {a['minutes']} min\" for a in apps[:20])\n\n urls = browser_urls(for_date, limit=20)\n url_lines = \"\\n\".join(\n f\"- {u['browser_url'][:100]} ({u['minutes']} min)\" for u in urls\n )\n\n ui_rows = ui_event_summary(for_date)\n ui_lines = \"\\n\".join(\n f\"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches\"\n for r in ui_rows[:15]\n )\n\n ocr_rows = deduplicated_text(for_date, chunk_minutes=5)\n ocr_lines = \"\\n\".join(\n f\"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}\"\n for r in ocr_rows[:100]\n )\n\n audio = formatted_transcript(for_date)\n\n return {\n \"app_time\": app_lines or \"(no app data)\",\n \"browser_urls\": url_lines or \"(no browser data)\",\n \"ui_events\": ui_lines or \"(no UI event data)\",\n \"ocr_text\": ocr_lines or \"(no screen data)\",\n \"audio\": audio[:3000] if len(audio) > 3000 else audio,\n }\n\n\ndef generate(\n summary_type: str = \"day_recap\",\n for_date: date | None = None,\n api_key: str | None = None,\n) -> dict[str, Any]:\n \"\"\"Generate an AI summary. Returns dict with 'title', 'content', 'date'.\"\"\"\n import anthropic\n\n d = for_date or date.today()\n key = api_key or os.environ.get(\"ANTHROPIC_API_KEY\", \"\")\n if not key:\n return {\n \"title\": \"Error\",\n \"content\": \"ANTHROPIC_API_KEY not set. Add it to your .env file.\",\n \"date\": str(d),\n }\n\n spec = SUMMARY_TYPES.get(summary_type)\n if not spec:\n return {\"title\": \"Error\", \"content\": f\"Unknown summary type: {summary_type}\", \"date\": str(d)}\n\n stats = summary_stats(d)\n if stats[\"total_frames\"] == 0:\n return {\n \"title\": spec[\"title\"],\n \"content\": f\"No screen data found for {d}.\",\n \"date\": str(d),\n }\n\n ctx = _build_context(d)\n prompt = spec[\"prompt\"].format(**ctx)\n\n client = anthropic.Anthropic(api_key=key)\n message = client.messages.create(\n model=\"claude-haiku-4-5-20251001\",\n max_tokens=1024,\n messages=[{\"role\": \"user\", \"content\": prompt}],\n )\n\n return {\n \"title\": spec[\"title\"],\n \"content\": message.content[0].text,\n \"date\": str(d),\n \"stats\": stats,\n }","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read all pipe.md files","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"for f in /volume1/screenpipe/pipes/*/pipe.md; do echo \"=== $f ===\"; cat \"$f\"; echo; done","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"=== /volume1/screenpipe/pipes/ai-habits/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: AI Habits\ndescription: \"How you use AI tools — patterns and insights\"\nicon: \"🤖\"\nfeatured: true\n---\n\nSearch my recordings from the last 24 hours for AI tool usage. Use app_name filter for each tool separately: ChatGPT, Claude, Copilot, Cursor, Gemini, Perplexity. Use limit=5 per search, max 6 searches total.\n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## AI Tools Used\n- List each tool with approximate time spent (e.g. \"Claude: ~45min\")\n\n## What I Used Them For\n- For each tool: coding, writing, research, or brainstorming\n\n## Usage Patterns\n- Do I switch between tools? Use them in bursts or steadily?\n\n## Effectiveness\n- Which tool appeared alongside completed work vs. abandoned attempts\n\nIf no AI usage is found, say so clearly. End with: \"**Tip:** [one suggestion to use AI tools more effectively]\"\n\n=== /volume1/screenpipe/pipes/day-recap/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Day Recap\ndescription: \"Today's accomplishments, key moments, and unfinished work\"\nicon: \"📋\"\nfeatured: true\n---\n\nAnalyze my screen and audio recordings from today (last 16 hours only). \n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Summary\nOne sentence: what I mainly did today.\n\n## Accomplishments\n- Top 3 things I finished, with timestamps (e.g. \"2:30 PM\")\n- Name specific apps, files, or projects\n\n## Key Moments\n- Important things I saw, said, or heard — with timestamps\n\n## Unfinished Work\n- What I should continue tomorrow — name the app/file/task\n\n## Patterns\n- Apps I used most, topics that came up repeatedly\n\nOnly report what you can verify from the data. End with: \"**Next step:** [most important thing to continue]\"\n\n=== /volume1/screenpipe/pipes/meeting-summary/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Meeting Summary\ndescription: \"Summarize meeting transcript with key takeaways and action items\"\nicon: \"🤝\"\nfeatured: false\n---\n\nSummarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.\n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Meeting Summary\nOne sentence: what this meeting was about.\n\n## Key Takeaways\n- Top 3-5 important points discussed\n- Include who said what when relevant\n\n## Action Items\n- [ ] Task — assigned to whom, deadline if mentioned\n- [ ] Task — assigned to whom\n\n## Decisions Made\n- List any decisions or agreements reached\n\n## Open Questions\n- Anything unresolved or needing follow-up\n\nKeep it concise and actionable.\n\n=== /volume1/screenpipe/pipes/standup-update/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Standup Update\ndescription: \"What you did, what's next, and any blockers\"\nicon: \"🏢\"\nfeatured: true\n---\n\nBased on my recordings from the last 24 hours, generate a standup update. Use limit=10 per search, max 3 searches total.\n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Yesterday\n- What I worked on (name specific projects, files, tools, PRs)\n\n## Today\n- What I will work on next (based on unfinished tasks and recent activity)\n\n## Blockers\n- Issues I hit — errors, slow builds, waiting on someone\n- If no blockers, write \"None\"\n\nKeep it under 150 words. Copy-paste ready for a team standup.\n\n=== /volume1/screenpipe/pipes/time-breakdown/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Time Breakdown\ndescription: \"Where your time went — by app, project, and category\"\nicon: \"⏱\"\nfeatured: false\n---\n\nAnalyze my app usage from today (last 12 hours). Use limit=10 per search, max 4 searches. Prefer /raw_sql with COUNT/GROUP BY queries.\n\nRead screenpipe skill first.\n\nUse this exact format with durations and percentages:\n\n## By Application\n- List each app with duration and percentage, sorted by time (e.g. \"VS Code: 2h 15min (28%)\")\n\n## By Category\n- Group into: coding, meetings, browsing, writing, communication, other\n- Show hours and percentage per category\n\n## By Project\n- Group related activities by project/topic. Name specific repos or tasks.\n\n## Productivity Score\n- Calculate: focused_work_hours / total_hours as a percentage\n- Focused = coding + writing. Unfocused = browsing + switching.\n\nEnd with: \"**Suggestion:** [one specific change to improve tomorrow's productivity]\"\n\n=== /volume1/screenpipe/pipes/video-export/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Export Video Clip\ndescription: \"Create a video of your recent screen activity\"\nicon: \"🎬\"\nfeatured: false\n---\n\nExport a video of my screen activity from the last 5 minutes.\n\nRead screenpipe skill first.\n\nUse the POST /frames/export endpoint with the time range and fps=1.0. Then show me the exported video file path as an inline code block so I can watch it.\n\nIf the export is large, suggest a lower fps or shorter time range.","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Now I have a clear picture. The pipes are markdown prompt templates in","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"/volume1/screenpipe/pipes/","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":", but there's no code to actually load and run them —","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"consumers/summary.py","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"has its own hardcoded prompts instead.","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Here's what I'll implement:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"consumers/pipes.py","depth":26,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"— dynamically loads pipe.md files and runs them via Claude (data injected as system message, pipe body as user prompt)","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"main.py","depth":26,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"— two new endpoints:","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"GET /api/pipes","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"and","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"POST /api/pipes/{pipe_id}/run","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"cli.py","depth":26,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"— a","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"pipe","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"command to run pipes from the terminal","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Let me build it:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Check browser_urls signature","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"cat /volume1/screenpipe/app/consumers/activity.py | grep \"def browser_urls\" -A 5","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"def browser_urls(\n for_date: date | None = None,\n app_name: str | None = None,\n ts_from: str | None = None,\n ts_to: str | None = None,\n limit: int = 30,","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Write","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"pipes.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"pipes.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"143 lines","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"\"\"\"Dynamic pipe loader and runner.\"\"\"\nimport os\nimport re\nfrom datetime import date\nfrom pathlib import Path\nfrom typing import Any\n\n\ndef _parse_frontmatter(text: str) -> tuple[dict, str]:\n if not text.startswith(\"---\"):\n return {}, text\n try:\n end = text.index(\"---\", 3)\n except ValueError:\n return {}, text\n fm_text = text[3:end].strip()\n body = text[end + 3:].strip()\n meta: dict = {}\n for line in fm_text.splitlines():\n if \":\" in line:\n k, _, v = line.partition(\":\")\n meta[k.strip()] = v.strip().strip('\"')\n return meta, body\n\n\ndef load_pipes(pipes_dir: Path) -> list[dict]:\n if not pipes_dir.exists():\n return []\n pipes = []\n for pipe_dir in sorted(pipes_dir.iterdir()):\n if not pipe_dir.is_dir() or pipe_dir.name.startswith(\".\"):\n continue\n pipe_md = pipe_dir / \"pipe.md\"\n if not pipe_md.exists():\n continue\n text = pipe_md.read_text(encoding=\"utf-8\")\n meta, body = _parse_frontmatter(text)\n if meta.get(\"enabled\", \"true\").lower() == \"false\":\n continue\n body = re.sub(r\"Read screenpipe skill first\\.?\\n?\", \"\", body).strip()\n pipes.append({\n \"id\": pipe_dir.name,\n \"title\": meta.get(\"title\", pipe_dir.name),\n \"description\": meta.get(\"description\", \"\"),\n \"icon\": meta.get(\"icon\", \"\"),\n \"schedule\": meta.get(\"schedule\", \"manual\"),\n \"featured\": meta.get(\"featured\", \"false\").lower() == \"true\",\n \"prompt\": body,\n })\n return pipes\n\n\ndef _build_system(d: date, stats: dict) -> str:\n from consumers.activity import app_time, browser_urls, ui_event_summary\n from consumers.ocr import deduplicated_text\n from consumers.audio import formatted_transcript\n\n apps = app_time(d)\n app_lines = \"\\n\".join(f\"- {a['app_name']}: {a['minutes']} min\" for a in apps[:20])\n\n urls = browser_urls(d, limit=20)\n url_lines = \"\\n\".join(f\"- {u['browser_url'][:100]} ({u['minutes']} min)\" for u in urls)\n\n ui_rows = ui_event_summary(d)\n ui_lines = \"\\n\".join(\n f\"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches\"\n for r in ui_rows[:15]\n )\n\n ocr_rows = deduplicated_text(d, chunk_minutes=5)\n ocr_lines = \"\\n\".join(\n f\"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}\"\n for r in ocr_rows[:100]\n )\n\n audio = formatted_transcript(d)\n if len(audio) > 3000:\n audio = audio[:3000]\n\n return f\"\"\"You are analyzing screenpipe data — recordings of a person's computer activity.\n\n## App usage (minutes per app):\n{app_lines or '(no app data)'}\n\n## Browser URLs visited:\n{url_lines or '(no browser data)'}\n\n## UI activity per app (clicks / keystrokes / app-switches):\n{ui_lines or '(no UI event data)'}\n\n## Screen content (sampled every 5 minutes):\n{ocr_lines or '(no screen data)'}\n\n## Audio / speech:\n{audio or '(no audio data)'}\n\nDate: {d}\nTotal frames recorded: {stats['total_frames']}\"\"\"\n\n\ndef run_pipe(\n pipe_id: str,\n for_date: date | None = None,\n api_key: str | None = None,\n pipes_dir: Path | None = None,\n) -> dict[str, Any]:\n import anthropic\n from consumers.activity import summary_stats\n\n d = for_date or date.today()\n key = api_key or os.environ.get(\"ANTHROPIC_API_KEY\", \"\")\n if not key:\n return {\"title\": \"Error\", \"content\": \"ANTHROPIC_API_KEY not set.\", \"date\": str(d)}\n\n _pipes_dir = pipes_dir or Path(os.environ.get(\"PIPES_DIR\", \"/data/pipes\"))\n all_pipes = {p[\"id\"]: p for p in load_pipes(_pipes_dir)}\n\n if pipe_id not in all_pipes:\n return {\"title\": \"Error\", \"content\": f\"Pipe not found: {pipe_id}\", \"date\": str(d)}\n\n pipe = all_pipes[pipe_id]\n stats = summary_stats(d)\n\n if stats[\"total_frames\"] == 0:\n return {\"title\": pipe[\"title\"], \"content\": f\"No screen data found for {d}.\", \"date\": str(d)}\n\n system = _build_system(d, stats)\n\n client = anthropic.Anthropic(api_key=key)\n message = client.messages.create(\n model=\"claude-haiku-4-5-20251001\",\n max_tokens=1024,\n system=system,\n messages=[{\"role\": \"user\", \"content\": pipe[\"prompt\"]}],\n )\n\n return {\n \"title\": pipe[\"title\"],\n \"content\": message.content[0].text,\n \"date\": str(d),\n \"stats\": stats,\n }","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Now add the API endpoints to","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"main.py","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":":","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Edit","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"main.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Added 1 line","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Edit","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"main.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Added 1 line","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Now add the pipe endpoints at the end of main.py, before the closing summary section:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Edit","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"main.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Added 14 lines","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Now add the CLI command to","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"cli.py","depth":23,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"cli.py","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":":","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Edit","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"cli.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"cli.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Added 40 lines","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Done. Here's how to run pipes:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXHeading","text":"How to run pipes","depth":22,"on_screen":false,"role_description":"heading"},{"role":"AXStaticText","text":"How to run pipes","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Via Docker (inside the running container):","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":23,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"docker exec -it screenpipe-app python cli.py pipe --list\ndocker exec -it screenpipe-app python cli.py pipe day-recap\ndocker exec -it screenpipe-app python cli.py pipe standup-update --date yesterday","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Via the API","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"(once the container is running on port 8766):","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":23,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"# List pipes\ncurl http://localhost:8766/api/pipes\n\n# Run a pipe\ncurl -X POST \"http://localhost:8766/api/pipes/day-recap/run\"\ncurl -X POST \"http://localhost:8766/api/pipes/standup-update/run?d=2026-04-25\"","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Rebuild and restart","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"to pick up the changes:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":23,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"cd /volume1/screenpipe/app\ndocker compose up --build -d","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"How it works:","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Each","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"pipe.md","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"file is loaded dynamically — the frontmatter provides metadata and the body becomes the user prompt. Screenpipe data (app usage, browser URLs, OCR, audio) is injected as a Claude system message so the pipe prompt can reference it naturally. The \"Read screenpipe skill first\" line is stripped automatically.","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"The pipes directory inside Docker is","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"/data/pipes","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"(since","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"/volume1/screenpipe","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"→","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"/data","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"). You can override it with a","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"PIPES_DIR","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"env var if needed.","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Message actions","depth":24,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"pipe.md","depth":23,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"pipe.md","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"where to place api key and can I use different keys","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read .env file","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"cat /volume1/screenpipe/app/.env","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ANTHROPIC_API_KEY=your_key_here","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Where to place the key:","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"app/.env","depth":23,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"app/.env","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"— replace","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"your_key_here","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"with your actual key:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":23,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"ANTHROPIC_API_KEY=sk-ant-...","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"That file is loaded by","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"load_dotenv()","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"at startup and is excluded from git via","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":".gitignore","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":".","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Can you use different keys per pipe?","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Not currently — all pipes share the one key from","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":".env","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":". But you can add per-pipe key support by adding an","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"api_key","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"field to the pipe's frontmatter:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":23,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"---\ntitle: Meeting Summary\napi_key_env: ANTHROPIC_KEY_MEETINGS\n---","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Then in","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"consumers/pipes.py","depth":23,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"consumers/pipes.py","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":", read it in","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"_parse_frontmatter","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"and pass it through","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"run_pipe","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":". Want me to add that?","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Message actions","depth":24,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"pipe.md","depth":23,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"pipe.md","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"can I use mistral or other llm? or is is build for antrophic only","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Currently it's Anthropic-only — the code calls the","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"anthropic","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"SDK directly in both","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"consumers/pipes.py","depth":23,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"consumers/pipes.py","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"and","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"consumers/summary.py","depth":23,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"consumers/summary.py","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":".","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Adding other providers is straightforward since Mistral, Ollama, OpenRouter, Groq, and most modern LLMs expose an OpenAI-compatible API. The cleanest approach: add the","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"openai","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"package and let you configure the provider via","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":".env","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":":","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":23,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"# Anthropic (default)\nANTHROPIC_API_KEY=sk-ant-...\n\n# OR: any OpenAI-compatible provider\nLLM_PROVIDER=openai-compatible\nLLM_BASE_URL=https://api.mistral.ai/v1\nLLM_API_KEY=your-mistral-key\nLLM_MODEL=mistral-small-latest","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"This would cover Mistral, Ollama (","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"http://localhost:11434/v1","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"), OpenRouter, Groq, etc. with one code path.","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Want me to implement that? It's a small change — a","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"_call_llm(system, user_prompt)","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"helper in","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"pipes.py","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"that branches on","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"LLM_PROVIDER","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":", and","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"openai","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"added to","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"requirements.txt","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":".","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Message actions","depth":24,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"lets test it with anthropic first, how to run pipe","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Check if container is running","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"cd /volume1/screenpipe/app && docker compose ps 2>/dev/null || docker ps --filter name=screenpipe","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Exit code 1\npermission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get \"http://%2Fvar%2Frun%2Fdocker.sock/v1.45/containers/json?filters=%7B%22name%22%3A%7B%22screenpipe%22%3Atrue%7D%7D\": dial unix /var/run/docker.sock: connect: permission denied","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"I don't have Docker socket access, so you'll need to run these yourself. Here are your options:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Option A — via Docker (if container is already running):","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":23,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"# List available pipes\ndocker exec -it screenpipe-app python cli.py pipe --list\n\n# Run a specific pipe\ndocker exec -it screenpipe-app python cli.py pipe day-recap","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Option B — rebuild first (since we added new files), then run:","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":23,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"cd /volume1/screenpipe/app\ndocker compose up --build -d\ndocker exec -it screenpipe-app python cli.py pipe day-recap","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Option C — via the API","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"(if container is up on port 8766):","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":23,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"# List pipes\ncurl http://localhost:8766/api/pipes\n\n# Run a pipe\ncurl -X POST http://localhost:8766/api/pipes/day-recap/run","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"The","depth":23,"on_screen":false,"role_description":"text"}]...
|
6323534583109777491
|
-8340439615201620792
|
idle
|
accessibility
|
NULL
|
Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧ Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py
M
db.py
docker-compose.yml
Dockerfile
M
main.py
M
requirements.txt
M
data
logs
pipes
.gitignore
app_settings.json
archive.db
archive.db-bak
U
db.sqlite
db.sqlite-shm
db.sqlite-wal
screenpipe_sync_updated.sh
U
screenpipe_sync.sh
screenpipe.db
Outline Section
OUTLINE
OUTLINE
Timeline Section
TIMELINE
TIMELINE
app_settings.json, Editor Group 1
screenpipe_sync.sh, Editor Group 1
pipe.md, Editor Group 1
.env, Editor Group 1
[ENV_SECRET]
[ENV_SECRET]
Implement and run pipe l…, Editor Group 2
Problems (⇧⌘M)
PROBLEMS
Output (⇧⌘U)
OUTPUT
Debug Console (⇧⌘Y)
DEBUG CONSOLE
Terminal (⌃`)
TERMINAL
Ports - 1 forwarded port
PORTS
1
remote SSH: nas
SSH: nas
screenpipe (Git) - master*, Checkout Branch/Tag...
master*
screenpipe (Git) - Synchronize Changes
No Problems
0
0
Forwarded Ports: 8766
1
Notifications
Sign In
Sign In
Info: Setting up SSH Host nas: Setting up SSH tunnel
Implement and run pipe logic
Session history
New session
Message actions
main.py
main.py
lets implement logic with pipes. how can I run it?
Thinking
Thinking
Let me look at the current project structure to understand what's already in place.
Bash
List project files
IN
find /volume1/screenpipe -type f | head -50 && echo "---" && ls /volume1/screenpipe
Copy code to clipboard
OUT
/volume1/screenpipe/.DS_Store
/volume1/screenpipe/screenpipe.db
/volume1/screenpipe/screenpipe_sync.sh
/volume1/screenpipe/app_settings.json
/volume1/screenpipe/.gitignore
/volume1/screenpipe/archive.db
/volume1/screenpipe/db.sqlite
/volume1/screenpipe/db.sqlite-wal
/volume1/screenpipe/db.sqlite-shm
/volume1/screenpipe/#recycle/desktop.ini
/volume1/screenpipe/#recycle/db.sqlite
/volume1/screenpipe/#recycle/Copy #1 of db.sqlite
/volume1/screenpipe/#recycle/.DS_Store
/volume1/screenpipe/#recycle/Copy #2 of db.sqlite
/volume1/screenpipe/#recycle/archive.db
/volume1/screenpipe/#recycle/Copy #1 of archive.db
/volume1/screenpipe/#recycle/Copy #2 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of archive.db
/volume1/screenpipe/#recycle/Copy #4 of archive.db
/volume1/screenpipe/#recycle/Copy #5 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of db.sqlite
/volume1/screenpipe/#recycle/Copy #4 of db.sqlite
/volume1/screenpipe/#recycle/Copy #6 of archive.db
/volume1/screenpipe/#recycle/test.txt
/volume1/screenpipe/#recycle/Copy #7 of archive.db
/volume1/screenpipe/#recycle/Copy #8 of archive.db
/volume1/screenpipe/#recycle/archive.db-journal
/volume1/screenpipe/#recycle/Copy #1 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #2 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #3 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #4 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #6 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #7 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of db.sqlite
/volume1/screenpipe/pipes/.DS_Store
/volume1/screenpipe/app/.env
/volume1/screenpipe/app/cli.py
/volume1/screenpipe/app/.DS_Store
/volume1/screenpipe/app/db.py
/volume1/screenpipe/app/docker-compose.yml
/volume1/screenpipe/app/main.py
/volume1/screenpipe/app/requirements.txt
/volume1/screenpipe/app/Dockerfile
/volume1/screenpipe/data/.DS_Store
/volume1/screenpipe/.git/description
/volume1/screenpipe/.git/HEAD
/volume1/screenpipe/.git/index
/volume1/screenpipe/.git/COMMIT_EDITMSG
/volume1/screenpipe/#recycle/data/.DS_Store
---
app
app_settings.json
archive.db
data
db.sqlite
db.sqlite-shm
db.sqlite-wal
pipes
#recycle
screenpipe.db
screenpipe_sync.sh
Read
main.py
main.py
Bash
Check pipes directory and docker-compose
IN
ls /volume1/screenpipe/pipes/ && ls /volume1/screenpipe/app/ && cat /volume1/screenpipe/app/docker-compose.yml
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
cli.py
consumers
db.py
docker-compose.yml
Dockerfile
main.py
__pycache__
requirements.txt
static
services:
screenpipe-app:
build: .
container_name: screenpipe-app
restart: unless-stopped
ports:
- "8766:8000"
volumes:
- /volume1/screenpipe:/data
env_file:
- .env
environment:
TZ: Europe/Sofia
DB_PATH: /data/db.sqlite
sqlite-web-archive:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-archive
restart: unless-stopped
ports:
- "8767:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/archive.db"]
sqlite-web-live:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-live
restart: unless-stopped
ports:
- "8768:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/db.sqlite"]
Read
requirements.txt
requirements.txt
Bash
Inspect a pipe directory
IN
ls /volume1/screenpipe/pipes/day-recap/ && cat /volume1/screenpipe/pipes/day-recap/pipe.json 2>/dev/null || ls /volume1/screenpipe/pipes/day-recap/
Copy code to clipboard
OUT
pipe.md
pipe.md
Read
cli.py
cli.py
Bash
List all pipes and their contents
IN
ls /volume1/screenpipe/pipes/ && for d in /volume1/screenpipe/pipes/*/; do echo "=== $d ==="; ls "$d"; done
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
=== /volume1/screenpipe/pipes/ai-habits/ ===
pipe.md
=== /volume1/screenpipe/pipes/day-recap/ ===
pipe.md
=== /volume1/screenpipe/pipes/meeting-summary/ ===
pipe.md
=== /volume1/screenpipe/pipes/standup-update/ ===
pipe.md
=== /volume1/screenpipe/pipes/time-breakdown/ ===
pipe.md
=== /volume1/screenpipe/pipes/video-export/ ===
pipe.md
Bash
Read pipe markdown files
IN
cat /volume1/screenpipe/pipes/day-recap/pipe.md && echo "===" && cat /volume1/screenpipe/pipes/meeting-summary/pipe.md 2>/dev/null | head -50
Copy code to clipboard
OUT
---
schedule: manual
enabled: true
template: true
title: Day Recap
description: "Today's accomplishments, key moments, and unfinished work"
icon: "📋"
featured: true
---
Analyze my screen and audio recordings from today (last 16 hours only).
Read screenpipe skill first.
Use this exact format:
## Summary
One sentence: what I mainly did today.
## Accomplishments
- Top 3 things I finished, with timestamps (e.g. "2:30 PM")
- Name specific apps, files, or projects
## Key Moments
- Important things I saw, said, or heard — with timestamps
## Unfinished Work
- What I should continue tomorrow — name the app/file/task
## Patterns
- Apps I used most, topics that came up repeatedly
Only report what you can verify from the data. End with: "**Next step:** [most important thing to continue]"
===
---
schedule: manual
enabled: true
template: true
title: Meeting Summary
description: "Summarize meeting transcript with key takeaways and action items"
icon: "🤝"
featured: false
---
Summarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.
Read screenpipe skill first.
Use this exact format:
## Meeting Summary
One sentence: what this meeting was about.
## Key Takeaways
- Top 3-5 important points discussed
- Include who said what when relevant
## Action Items
- [ ] Task — assigned to whom, deadline if mentioned
- [ ] Task — assigned to whom
## Decisions Made
- List any decisions or agreements reached
## Open Questions
- Anything unresolved or needing follow-up
Keep it concise and actionable.
Thinking
Thinking
Bash
Read summary consumer
IN
ls /volume1/screenpipe/app/consumers/ && cat /volume1/screenpipe/app/consumers/summary.py
Copy code to clipboard
OUT
activity.py
audio.py
elements.py
__init__.py
interactions.py
ocr.py
__pycache__
report.py
summary.py
"""AI summary generator using Claude."""
import os
from datetime import date
from typing import Any
from consumers.activity import app_time, summary_stats, browser_urls, ui_event_summary
from consumers.ocr import deduplicated_text
from consumers.audio import formatted_transcript
SUMMARY_TYPES = {
"day_recap": {
"title": "Day Recap",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
## Audio/speech:
{audio}
Write a concise day recap using EXACTLY this format:
## Summary
One sentence: what I mainly worked on today.
## Accomplishments
- Top 3 things I finished, with approximate times
- Name specific apps, files, or projects
## Key Moments
- Important things seen or heard, with timestamps
## Unfinished Work
- What to continue tomorrow
## Patterns
- Apps used most, topics that came up repeatedly
Only report what you can verify from the data. End with:
**Next step:** [most important thing to continue]""",
},
"standup": {
"title": "Standup Update",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
## Audio/speech:
{audio}
Write a brief standup update:
**Yesterday:** What I worked on (2-3 bullets)
**Today:** What I plan to continue (1-2 bullets)
**Blockers:** Any issues observed (or "None")
Keep it under 150 words. Only report what's verifiable from the data.""",
},
"focus_time": {
"title": "Focus & Distraction Analysis",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
Analyze focus vs distraction patterns:
## Deep Work Periods
- When and how long were sustained focus sessions?
- What was being worked on?
## Distractions
- Which apps/sites were used recreationally?
- How much time was lost to context switching?
## Recommendations
- 2-3 concrete suggestions to improve focus tomorrow
Be specific with times and app names.""",
},
}
def _build_context(for_date: date) -> dict[str, str]:
apps = app_time(for_date)
app_lines = "\n".join(f"- {a['app_name']}: {a['minutes']} min" for a in apps[:20])
urls = browser_urls(for_date, limit=20)
url_lines = "\n".join(
f"- {u['browser_url'][:100]} ({u['minutes']} min)" for u in urls
)
ui_rows = ui_event_summary(for_date)
ui_lines = "\n".join(
f"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches"
for r in ui_rows[:15]
)
ocr_rows = deduplicated_text(for_date, chunk_minutes=5)
ocr_lines = "\n".join(
f"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}"
for r in ocr_rows[:100]
)
audio = formatted_transcript(for_date)
return {
"app_time": app_lines or "(no app data)",
"browser_urls": url_lines or "(no browser data)",
"ui_events": ui_lines or "(no UI event data)",
"ocr_text": ocr_lines or "(no screen data)",
"audio": audio[:3000] if len(audio) > 3000 else audio,
}
def generate(
summary_type: str = "day_recap",
for_date: date | None = None,
api_key: str | None = None,
) -> dict[str, Any]:
"""Generate an AI summary. Returns dict with 'title', 'content', 'date'."""
import anthropic
d = for_date or date.today()
key = api_key or os.environ.get("ANTHROPIC_API_KEY", "")
if not key:
return {
"title": "Error",
"content": "ANTHROPIC_API_KEY not set. Add it to your .env file.",
"date": str(d),
}
spec = SUMMARY_TYPES.get(summary_type)
if not spec:
return {"title": "Error", "content": f"Unknown summary type: {summary_type}", "date": str(d)}
stats = summary_stats(d)
if stats["total_frames"] == 0:
return {
"title": spec["title"],
"content": f"No screen data found for {d}.",
"date": str(d),
}
ctx = _build_context(d)
prompt = spec["prompt"].format(**ctx)
client = anthropic.Anthropic(api_key=key)
message = client.messages.create(
model="claude-haiku-4-5-20251001",
max_tokens=1024,
messages=[{"role": "user", "content": prompt}],
)
return {
"title": spec["title"],
"content": message.content[0].text,
"date": str(d),
"stats": stats,
}
Thinking
Thinking
Bash
Read all pipe.md files
IN
for f in /volume1/screenpipe/pipes/*/pipe.md; do echo "=== $f ==="; cat "$f"; echo; done
Copy code to clipboard
OUT
=== /volume1/screenpipe/pipes/ai-habits/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: AI Habits
description: "How you use AI tools — patterns and insights"
icon: "🤖"
featured: true
---
Search my recordings from the last 24 hours for AI tool usage. Use app_name filter for each tool separately: ChatGPT, Claude, Copilot, Cursor, Gemini, Perplexity. Use limit=5 per search, max 6 searches total.
Read screenpipe skill first.
Use this exact format:
## AI Tools Used
- List each tool with approximate time spent (e.g. "Claude: ~45min")
## What I Used Them For
- For each tool: coding, writing, research, or brainstorming
## Usage Patterns
- Do I switch between tools? Use them in bursts or steadily?
## Effectiveness
- Which tool appeared alongside completed work vs. abandoned attempts
If no AI usage is found, say so clearly. End with: "**Tip:** [one suggestion to use AI tools more effectively]"
=== /volume1/screenpipe/pipes/day-recap/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Day Recap
description: "Today's accomplishments, key moments, and unfinished work"
icon: "📋"
featured: true
---
Analyze my screen and audio recordings from today (last 16 hours only).
Read screenpipe skill first.
Use this exact format:
## Summary
One sentence: what I mainly did today.
## Accomplishments
- Top 3 things I finished, with timestamps (e.g. "2:30 PM")
- Name specific apps, files, or projects
## Key Moments
- Important things I saw, said, or heard — with timestamps
## Unfinished Work
- What I should continue tomorrow — name the app/file/task
## Patterns
- Apps I used most, topics that came up repeatedly
Only report what you can verify from the data. End with: "**Next step:** [most important thing to continue]"
=== /volume1/screenpipe/pipes/meeting-summary/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Meeting Summary
description: "Summarize meeting transcript with key takeaways and action items"
icon: "🤝"
featured: false
---
Summarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.
Read screenpipe skill first.
Use this exact format:
## Meeting Summary
One sentence: what this meeting was about.
## Key Takeaways
- Top 3-5 important points discussed
- Include who said what when relevant
## Action Items
- [ ] Task — assigned to whom, deadline if mentioned
- [ ] Task — assigned to whom
## Decisions Made
- List any decisions or agreements reached
## Open Questions
- Anything unresolved or needing follow-up
Keep it concise and actionable.
=== /volume1/screenpipe/pipes/standup-update/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Standup Update
description: "What you did, what's next, and any blockers"
icon: "🏢"
featured: true
---
Based on my recordings from the last 24 hours, generate a standup update. Use limit=10 per search, max 3 searches total.
Read screenpipe skill first.
Use this exact format:
## Yesterday
- What I worked on (name specific projects, files, tools, PRs)
## Today
- What I will work on next (based on unfinished tasks and recent activity)
## Blockers
- Issues I hit — errors, slow builds, waiting on someone
- If no blockers, write "None"
Keep it under 150 words. Copy-paste ready for a team standup.
=== /volume1/screenpipe/pipes/time-breakdown/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Time Breakdown
description: "Where your time went — by app, project, and category"
icon: "⏱"
featured: false
---
Analyze my app usage from today (last 12 hours). Use limit=10 per search, max 4 searches. Prefer /raw_sql with COUNT/GROUP BY queries.
Read screenpipe skill first.
Use this exact format with durations and percentages:
## By Application
- List each app with duration and percentage, sorted by time (e.g. "VS Code: 2h 15min (28%)")
## By Category
- Group into: coding, meetings, browsing, writing, communication, other
- Show hours and percentage per category
## By Project
- Group related activities by project/topic. Name specific repos or tasks.
## Productivity Score
- Calculate: focused_work_hours / total_hours as a percentage
- Focused = coding + writing. Unfocused = browsing + switching.
End with: "**Suggestion:** [one specific change to improve tomorrow's productivity]"
=== /volume1/screenpipe/pipes/video-export/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Export Video Clip
description: "Create a video of your recent screen activity"
icon: "🎬"
featured: false
---
Export a video of my screen activity from the last 5 minutes.
Read screenpipe skill first.
Use the POST /frames/export endpoint with the time range and fps=1.0. Then show me the exported video file path as an inline code block so I can watch it.
If the export is large, suggest a lower fps or shorter time range.
Thinking
Thinking
Now I have a clear picture. The pipes are markdown prompt templates in
/volume1/screenpipe/pipes/
, but there's no code to actually load and run them —
consumers/summary.py
has its own hardcoded prompts instead.
Here's what I'll implement:
consumers/pipes.py
— dynamically loads pipe.md files and runs them via Claude (data injected as system message, pipe body as user prompt)
main.py
— two new endpoints:
GET /api/pipes
and
POST /api/pipes/{pipe_id}/run
cli.py
— a
pipe
command to run pipes from the terminal
Let me build it:
Bash
Check browser_urls signature
IN
cat /volume1/screenpipe/app/consumers/activity.py | grep "def browser_urls" -A 5
Copy code to clipboard
OUT
def browser_urls(
for_date: date | None = None,
app_name: str | None = None,
ts_from: str | None = None,
ts_to: str | None = None,
limit: int = 30,
Write
pipes.py
pipes.py
143 lines
"""Dynamic pipe loader and runner."""
import os
import re
from datetime import date
from pathlib import Path
from typing import Any
def _parse_frontmatter(text: str) -> tuple[dict, str]:
if not text.startswith("---"):
return {}, text
try:
end = text.index("---", 3)
except ValueError:
return {}, text
fm_text = text[3:end].strip()
body = text[end + 3:].strip()
meta: dict = {}
for line in fm_text.splitlines():
if ":" in line:
k, _, v = line.partition(":")
meta[k.strip()] = v.strip().strip('"')
return meta, body
def load_pipes(pipes_dir: Path) -> list[dict]:
if not pipes_dir.exists():
return []
pipes = []
for pipe_dir in sorted(pipes_dir.iterdir()):
if not pipe_dir.is_dir() or pipe_dir.name.startswith("."):
continue
pipe_md = pipe_dir / "pipe.md"
if not pipe_md.exists():
continue
text = pipe_md.read_text(encoding="utf-8")
meta, body = _parse_frontmatter(text)
if meta.get("enabled", "true").lower() == "false":
continue
body = re.sub(r"Read screenpipe skill first\.?\n?", "", body).strip()
pipes.append({
"id": pipe_dir.name,
"title": meta.get("title", pipe_dir.name),
"description": meta.get("description", ""),
"icon": meta.get("icon", ""),
"schedule": meta.get("schedule", "manual"),
"featured": meta.get("featured", "false").lower() == "true",
"prompt": body,
})
return pipes
def _build_system(d: date, stats: dict) -> str:
from consumers.activity import app_time, browser_urls, ui_event_summary
from consumers.ocr import deduplicated_text
from consumers.audio import formatted_transcript
apps = app_time(d)
app_lines = "\n".join(f"- {a['app_name']}: {a['minutes']} min" for a in apps[:20])
urls = browser_urls(d, limit=20)
url_lines = "\n".join(f"- {u['browser_url'][:100]} ({u['minutes']} min)" for u in urls)
ui_rows = ui_event_summary(d)
ui_lines = "\n".join(
f"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches"
for r in ui_rows[:15]
)
ocr_rows = deduplicated_text(d, chunk_minutes=5)
ocr_lines = "\n".join(
f"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}"
for r in ocr_rows[:100]
)
audio = formatted_transcript(d)
if len(audio) > 3000:
audio = audio[:3000]
return f"""You are analyzing screenpipe data — recordings of a person's computer activity.
## App usage (minutes per app):
{app_lines or '(no app data)'}
## Browser URLs visited:
{url_lines or '(no browser data)'}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_lines or '(no UI event data)'}
## Screen content (sampled every 5 minutes):
{ocr_lines or '(no screen data)'}
## Audio / speech:
{audio or '(no audio data)'}
Date: {d}
Total frames recorded: {stats['total_frames']}"""
def run_pipe(
pipe_id: str,
for_date: date | None = None,
api_key: str | None = None,
pipes_dir: Path | None = None,
) -> dict[str, Any]:
import anthropic
from consumers.activity import summary_stats
d = for_date or date.today()
key = api_key or os.environ.get("ANTHROPIC_API_KEY", "")
if not key:
return {"title": "Error", "content": "ANTHROPIC_API_KEY not set.", "date": str(d)}
_pipes_dir = pipes_dir or Path(os.environ.get("PIPES_DIR", "/data/pipes"))
all_pipes = {p["id"]: p for p in load_pipes(_pipes_dir)}
if pipe_id not in all_pipes:
return {"title": "Error", "content": f"Pipe not found: {pipe_id}", "date": str(d)}
pipe = all_pipes[pipe_id]
stats = summary_stats(d)
if stats["total_frames"] == 0:
return {"title": pipe["title"], "content": f"No screen data found for {d}.", "date": str(d)}
system = _build_system(d, stats)
client = anthropic.Anthropic(api_key=key)
message = client.messages.create(
model="claude-haiku-4-5-20251001",
max_tokens=1024,
system=system,
messages=[{"role": "user", "content": pipe["prompt"]}],
)
return {
"title": pipe["title"],
"content": message.content[0].text,
"date": str(d),
"stats": stats,
}
Now add the API endpoints to
main.py
:
Edit
main.py
main.py
Added 1 line
Edit
main.py
main.py
Added 1 line
Now add the pipe endpoints at the end of main.py, before the closing summary section:
Edit
main.py
main.py
Added 14 lines
Now add the CLI command to
cli.py
cli.py
:
Edit
cli.py
cli.py
Added 40 lines
Done. Here's how to run pipes:
How to run pipes
How to run pipes
Via Docker (inside the running container):
Copy code to clipboard
docker exec -it screenpipe-app python cli.py pipe --list
docker exec -it screenpipe-app python cli.py pipe day-recap
docker exec -it screenpipe-app python cli.py pipe standup-update --date yesterday
Via the API
(once the container is running on port 8766):
Copy code to clipboard
# List pipes
curl http://localhost:8766/api/pipes
# Run a pipe
curl -X POST "http://localhost:8766/api/pipes/day-recap/run"
curl -X POST "http://localhost:8766/api/pipes/standup-update/run?d=2026-04-25"
Rebuild and restart
to pick up the changes:
Copy code to clipboard
cd /volume1/screenpipe/app
docker compose up --build -d
How it works:
Each
pipe.md
file is loaded dynamically — the frontmatter provides metadata and the body becomes the user prompt. Screenpipe data (app usage, browser URLs, OCR, audio) is injected as a Claude system message so the pipe prompt can reference it naturally. The "Read screenpipe skill first" line is stripped automatically.
The pipes directory inside Docker is
/data/pipes
(since
/volume1/screenpipe
→
/data
). You can override it with a
PIPES_DIR
env var if needed.
Message actions
pipe.md
pipe.md
where to place api key and can I use different keys
Thinking
Thinking
Bash
Read .env file
IN
cat /volume1/screenpipe/app/.env
Copy code to clipboard
OUT
[ENV_SECRET]
Where to place the key:
app/.env
app/.env
— replace
your_key_here
with your actual key:
Copy code to clipboard
[ENV_SECRET]
That file is loaded by
load_dotenv()
at startup and is excluded from git via
.gitignore
.
Can you use different keys per pipe?
Not currently — all pipes share the one key from
.env
. But you can add per-pipe key support by adding an
api_key
field to the pipe's frontmatter:
Copy code to clipboard
---
title: Meeting Summary
api_key_env: ANTHROPIC_KEY_MEETINGS
---
Then in
consumers/pipes.py
consumers/pipes.py
, read it in
_parse_frontmatter
and pass it through
run_pipe
. Want me to add that?
Message actions
pipe.md
pipe.md
can I use mistral or other llm? or is is build for antrophic only
Thinking
Thinking
Currently it's Anthropic-only — the code calls the
anthropic
SDK directly in both
consumers/pipes.py
consumers/pipes.py
and
consumers/summary.py
consumers/summary.py
.
Adding other providers is straightforward since Mistral, Ollama, OpenRouter, Groq, and most modern LLMs expose an OpenAI-compatible API. The cleanest approach: add the
openai
package and let you configure the provider via
.env
:
Copy code to clipboard
# Anthropic (default)
[ENV_SECRET]
# OR: any OpenAI-compatible provider
LLM_PROVIDER=openai-compatible
LLM_BASE_URL=https://api.mistral.ai/v1
[ENV_SECRET]
LLM_MODEL=mistral-small-latest
This would cover Mistral, Ollama (
http://localhost:11434/v1
), OpenRouter, Groq, etc. with one code path.
Want me to implement that? It's a small change — a
_call_llm(system, user_prompt)
helper in
pipes.py
that branches on
LLM_PROVIDER
, and
openai
added to
requirements.txt
.
Message actions
lets test it with anthropic first, how to run pipe
Thinking
Thinking
Bash
Check if container is running
IN
cd /volume1/screenpipe/app && docker compose ps 2>/dev/null || docker ps --filter name=screenpipe
Copy code to clipboard
OUT
Exit code 1
permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get "http://%2Fvar%2Frun%2Fdocker.sock/v1.45/containers/json?filters=%7B%22name%22%3A%7B%22screenpipe%22%3Atrue%7D%7D": dial unix /var/run/docker.sock: connect: permission denied
I don't have Docker socket access, so you'll need to run these yourself. Here are your options:
Option A — via Docker (if container is already running):
Copy code to clipboard
# List available pipes
docker exec -it screenpipe-app python cli.py pipe --list
# Run a specific pipe
docker exec -it screenpipe-app python cli.py pipe day-recap
Option B — rebuild first (since we added new files), then run:
Copy code to clipboard
cd /volume1/screenpipe/app
docker compose up --build -d
docker exec -it screenpipe-app python cli.py pipe day-recap
Option C — via the API
(if container is up on port 8766):
Copy code to clipboard
# List pipes
curl http://localhost:8766/api/pipes
# Run a pipe
curl -X POST http://localhost:8766/api/pipes/day-recap/run
The...
|
21074
|
NULL
|
NULL
|
NULL
|
|
21077
|
NULL
|
0
|
2026-05-11T17:10:38.408095+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-11/1778 /Users/lukas/.screenpipe/data/data/2026-05-11/1778519438408_m2.jpg...
|
Code
|
Implement and run pipe l… — screenpipe [SSH: nas]
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧ Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py
M
db.py
docker-compose.yml
Dockerfile
M
main.py
M
requirements.txt
M
data
...
|
[{"role":"AXRadioButton","text [{"role":"AXRadioButton","text":"Explorer (⇧⌘E)","depth":19,"bounds":{"left":0.0,"top":0.047885075,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":true},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.057462092,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Search (⇧⌘F)","depth":19,"bounds":{"left":0.0,"top":0.08619314,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.09577015,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Source Control (⌃⇧G) - 10 pending changes","depth":19,"bounds":{"left":0.0,"top":0.1245012,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.13407822,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"10","depth":22,"bounds":{"left":0.00831117,"top":0.1452514,"width":0.003656915,"height":0.008778931},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.00831117,"top":0.14604948,"width":0.0016622341,"height":0.007980846}},{"char_start":1,"char_count":1,"bounds":{"left":0.009973404,"top":0.14604948,"width":0.0023271276,"height":0.007980846}}],"role_description":"text"},{"role":"AXRadioButton","text":"Run and Debug (⇧⌘D)","depth":19,"bounds":{"left":0.0,"top":0.16280925,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.17238627,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Remote Explorer","depth":19,"bounds":{"left":0.0,"top":0.20111732,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.21069433,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Extensions (⇧⌘X) - 2 require update","depth":19,"bounds":{"left":0.0,"top":0.23942538,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.2490024,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"2","depth":22,"bounds":{"left":0.009640957,"top":0.2601756,"width":0.0019946808,"height":0.008778931},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Claude Code","depth":19,"bounds":{"left":0.0,"top":0.27773345,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"Containers","depth":19,"bounds":{"left":0.0,"top":0.3160415,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXHeading","text":"EXPLORER","depth":17,"bounds":{"left":0.022606382,"top":0.047885075,"width":0.018949468,"height":0.02793296},"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"EXPLORER","depth":18,"bounds":{"left":0.022606382,"top":0.056664005,"width":0.018949468,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.022606382,"top":0.056664005,"width":0.0023271276,"height":0.0103751}},{"char_start":1,"char_count":7,"bounds":{"left":0.024933511,"top":0.056664005,"width":0.01662234,"height":0.0103751}}],"role_description":"text"},{"role":"AXButton","text":"Explorer Section: screenpipe [SSH: nas]","depth":21,"bounds":{"left":0.015957447,"top":0.07581804,"width":0.09940159,"height":0.017557861},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":true},{"role":"AXStaticText","text":"","depth":23,"bounds":{"left":0.01662234,"top":0.07821229,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"Explorer Section: screenpipe [SSH: nas]","depth":22,"bounds":{"left":0.022606382,"top":0.07581804,"width":0.045877658,"height":0.017557861},"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"SCREENPIPE [SSH: NAS]","depth":23,"bounds":{"left":0.022606382,"top":0.079010375,"width":0.045877658,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.022606382,"top":0.07980846,"width":0.0026595744,"height":0.0103751}},{"char_start":1,"char_count":20,"bounds":{"left":0.025265958,"top":0.07980846,"width":0.043218084,"height":0.0103751}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.09577015,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"#recycle","depth":27,"bounds":{"left":0.025930852,"top":0.09577015,"width":0.017287234,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.096568234,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":7,"bounds":{"left":0.028590426,"top":0.096568234,"width":0.01462766,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.11332801,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"app","depth":27,"bounds":{"left":0.025930852,"top":0.11332801,"width":0.0076462766,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.11412609,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":2,"bounds":{"left":0.02825798,"top":0.11412609,"width":0.005319149,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.11412609,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.022273935,"top":0.13088587,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"__pycache__","depth":27,"bounds":{"left":0.028590426,"top":0.13088587,"width":0.026595745,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.13168396,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":10,"bounds":{"left":0.030917553,"top":0.13168396,"width":0.024268618,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.022273935,"top":0.14844373,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"consumers","depth":27,"bounds":{"left":0.028590426,"top":0.14844373,"width":0.022273935,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.14924182,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":8,"bounds":{"left":0.030917553,"top":0.14924182,"width":0.019946808,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.14924182,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.022273935,"top":0.1660016,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"static","depth":27,"bounds":{"left":0.028590426,"top":0.1660016,"width":0.010970744,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.16679968,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":5,"bounds":{"left":0.030917553,"top":0.16679968,"width":0.008976064,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.16679968,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.1819633,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":".env","depth":27,"bounds":{"left":0.028590426,"top":0.18355946,"width":0.00831117,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.18435754,"width":0.0013297872,"height":0.011971269}},{"char_start":1,"char_count":3,"bounds":{"left":0.029920213,"top":0.18435754,"width":0.006981383,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.19952115,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"cli.py","depth":27,"bounds":{"left":0.028590426,"top":0.20111732,"width":0.010638298,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.2019154,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":5,"bounds":{"left":0.030917553,"top":0.2019154,"width":0.00831117,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.2019154,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.21707901,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.py","depth":27,"bounds":{"left":0.028590426,"top":0.21867518,"width":0.011303191,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.21947326,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":4,"bounds":{"left":0.03125,"top":0.21947326,"width":0.008643617,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.23463687,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"docker-compose.yml","depth":27,"bounds":{"left":0.028590426,"top":0.23623304,"width":0.042220745,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.23703113,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":17,"bounds":{"left":0.03125,"top":0.23703113,"width":0.03956117,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.25219473,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Dockerfile","depth":27,"bounds":{"left":0.028590426,"top":0.25379092,"width":0.020611702,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.254589,"width":0.0033244682,"height":0.011971269}},{"char_start":1,"char_count":9,"bounds":{"left":0.031914894,"top":0.254589,"width":0.017287234,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.254589,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.2697526,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"main.py","depth":27,"bounds":{"left":0.028590426,"top":0.27134877,"width":0.015625,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.27214685,"width":0.003656915,"height":0.011971269}},{"char_start":1,"char_count":6,"bounds":{"left":0.032247342,"top":0.27214685,"width":0.012300532,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.27214685,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.28731045,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"requirements.txt","depth":27,"bounds":{"left":0.028590426,"top":0.28890663,"width":0.032912236,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.2897047,"width":0.0016622341,"height":0.011971269}},{"char_start":1,"char_count":15,"bounds":{"left":0.03025266,"top":0.2897047,"width":0.03158245,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.2897047,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.3064645,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"data","depth":27,"bounds":{"left":0.025930852,"top":0.3064645,"width":0.008976064,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.30726257,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":3,"bounds":{"left":0.028590426,"top":0.30726257,"width":0.0063164895,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.32402235,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"}]...
|
-2091746111333324882
|
-5552032457270013556
|
idle
|
accessibility
|
NULL
|
Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧ Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py
M
db.py
docker-compose.yml
Dockerfile
M
main.py
M
requirements.txt
M
data
...
|
21075
|
NULL
|
NULL
|
NULL
|
|
21078
|
NULL
|
0
|
2026-05-11T17:10:49.805672+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-11/1778 /Users/lukas/.screenpipe/data/data/2026-05-11/1778519449805_m1.jpg...
|
Code
|
Implement and run pipe l… — screenpipe [SSH: nas]
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧ Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py
M
db.py
docker-compose.yml
Dockerfile
M
main.py
M
requirements.txt
M
data
logs
pipes
.gitignore
app_settings.json
archive.db
archive.db-bak
U
db.sqlite
db.sqlite-shm
db.sqlite-wal
screenpipe_sync_updated.sh
U
screenpipe_sync.sh
screenpipe.db
Outline Section
OUTLINE
OUTLINE
Timeline Section
TIMELINE
TIMELINE
app_settings.json, Editor Group 1
screenpipe_sync.sh, Editor Group 1
pipe.md, Editor Group 1
.env, Editor Group 1
[ENV_SECRET]
[ENV_SECRET]
Implement and run pipe l…, Editor Group 2
Problems (⇧⌘M)
PROBLEMS
Output (⇧⌘U)
OUTPUT
Debug Console (⇧⌘Y)
DEBUG CONSOLE
Terminal (⌃`)
TERMINAL
Ports - 1 forwarded port
PORTS
1
remote SSH: nas
SSH: nas
screenpipe (Git) - master*, Checkout Branch/Tag...
master*
screenpipe (Git) - Synchronize Changes
No Problems
0
0
Forwarded Ports: 8766
1
Notifications
Sign In
Sign In
Info: Setting up SSH Host nas: Setting up SSH tunnel
Implement and run pipe logic
Session history
New session
Message actions
main.py
main.py
lets implement logic with pipes. how can I run it?
Thinking
Thinking
Let me look at the current project structure to understand what's already in place.
Bash
List project files
IN
find /volume1/screenpipe -type f | head -50 && echo "---" && ls /volume1/screenpipe
Copy code to clipboard
OUT
/volume1/screenpipe/.DS_Store
/volume1/screenpipe/screenpipe.db
/volume1/screenpipe/screenpipe_sync.sh
/volume1/screenpipe/app_settings.json
/volume1/screenpipe/.gitignore
/volume1/screenpipe/archive.db
/volume1/screenpipe/db.sqlite
/volume1/screenpipe/db.sqlite-wal
/volume1/screenpipe/db.sqlite-shm
/volume1/screenpipe/#recycle/desktop.ini
/volume1/screenpipe/#recycle/db.sqlite
/volume1/screenpipe/#recycle/Copy #1 of db.sqlite
/volume1/screenpipe/#recycle/.DS_Store
/volume1/screenpipe/#recycle/Copy #2 of db.sqlite
/volume1/screenpipe/#recycle/archive.db
/volume1/screenpipe/#recycle/Copy #1 of archive.db
/volume1/screenpipe/#recycle/Copy #2 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of archive.db
/volume1/screenpipe/#recycle/Copy #4 of archive.db
/volume1/screenpipe/#recycle/Copy #5 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of db.sqlite
/volume1/screenpipe/#recycle/Copy #4 of db.sqlite
/volume1/screenpipe/#recycle/Copy #6 of archive.db
/volume1/screenpipe/#recycle/test.txt
/volume1/screenpipe/#recycle/Copy #7 of archive.db
/volume1/screenpipe/#recycle/Copy #8 of archive.db
/volume1/screenpipe/#recycle/archive.db-journal
/volume1/screenpipe/#recycle/Copy #1 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #2 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #3 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #4 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #6 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #7 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of db.sqlite
/volume1/screenpipe/pipes/.DS_Store
/volume1/screenpipe/app/.env
/volume1/screenpipe/app/cli.py
/volume1/screenpipe/app/.DS_Store
/volume1/screenpipe/app/db.py
/volume1/screenpipe/app/docker-compose.yml
/volume1/screenpipe/app/main.py
/volume1/screenpipe/app/requirements.txt
/volume1/screenpipe/app/Dockerfile
/volume1/screenpipe/data/.DS_Store
/volume1/screenpipe/.git/description
/volume1/screenpipe/.git/HEAD
/volume1/screenpipe/.git/index
/volume1/screenpipe/.git/COMMIT_EDITMSG
/volume1/screenpipe/#recycle/data/.DS_Store
---
app
app_settings.json
archive.db
data
db.sqlite
db.sqlite-shm
db.sqlite-wal
pipes
#recycle
screenpipe.db
screenpipe_sync.sh
Read
main.py
main.py
Bash
Check pipes directory and docker-compose
IN
ls /volume1/screenpipe/pipes/ && ls /volume1/screenpipe/app/ && cat /volume1/screenpipe/app/docker-compose.yml
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
cli.py
consumers
db.py
docker-compose.yml
Dockerfile
main.py
__pycache__
requirements.txt
static
services:
screenpipe-app:
build: .
container_name: screenpipe-app
restart: unless-stopped
ports:
- "8766:8000"
volumes:
- /volume1/screenpipe:/data
env_file:
- .env
environment:
TZ: Europe/Sofia
DB_PATH: /data/db.sqlite
sqlite-web-archive:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-archive
restart: unless-stopped
ports:
- "8767:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/archive.db"]
sqlite-web-live:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-live
restart: unless-stopped
ports:
- "8768:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/db.sqlite"]
Read
requirements.txt
requirements.txt
Bash
Inspect a pipe directory
IN
ls /volume1/screenpipe/pipes/day-recap/ && cat /volume1/screenpipe/pipes/day-recap/pipe.json 2>/dev/null || ls /volume1/screenpipe/pipes/day-recap/
Copy code to clipboard
OUT
pipe.md
pipe.md
Read
cli.py
cli.py
Bash
List all pipes and their contents
IN
ls /volume1/screenpipe/pipes/ && for d in /volume1/screenpipe/pipes/*/; do echo "=== $d ==="; ls "$d"; done
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
=== /volume1/screenpipe/pipes/ai-habits/ ===
pipe.md
=== /volume1/screenpipe/pipes/day-recap/ ===
pipe.md
=== /volume1/screenpipe/pipes/meeting-summary/ ===
pipe.md
=== /volume1/screenpipe/pipes/standup-update/ ===
pipe.md
=== /volume1/screenpipe/pipes/time-breakdown/ ===
pipe.md
=== /volume1/screenpipe/pipes/video-export/ ===
pipe.md
Bash
Read pipe markdown files
IN
cat /volume1/screenpipe/pipes/day-recap/pipe.md && echo "===" && cat /volume1/screenpipe/pipes/meeting-summary/pipe.md 2>/dev/null | head -50
Copy code to clipboard
OUT
---
schedule: manual
enabled: true
template: true
title: Day Recap
description: "Today's accomplishments, key moments, and unfinished work"
icon: "📋"
featured: true
---
Analyze my screen and audio recordings from today (last 16 hours only).
Read screenpipe skill first.
Use this exact format:
## Summary
One sentence: what I mainly did today.
## Accomplishments
- Top 3 things I finished, with timestamps (e.g. "2:30 PM")
- Name specific apps, files, or projects
## Key Moments
- Important things I saw, said, or heard — with timestamps
## Unfinished Work
- What I should continue tomorrow — name the app/file/task
## Patterns
- Apps I used most, topics that came up repeatedly
Only report what you can verify from the data. End with: "**Next step:** [most important thing to continue]"
===
---
schedule: manual
enabled: true
template: true
title: Meeting Summary
description: "Summarize meeting transcript with key takeaways and action items"
icon: "🤝"
featured: false
---
Summarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.
Read screenpipe skill first.
Use this exact format:
## Meeting Summary
One sentence: what this meeting was about.
## Key Takeaways
- Top 3-5 important points discussed
- Include who said what when relevant
## Action Items
- [ ] Task — assigned to whom, deadline if mentioned
- [ ] Task — assigned to whom
## Decisions Made
- List any decisions or agreements reached
## Open Questions
- Anything unresolved or needing follow-up
Keep it concise and actionable.
Thinking
Thinking
Bash
Read summary consumer
IN
ls /volume1/screenpipe/app/consumers/ && cat /volume1/screenpipe/app/consumers/summary.py
Copy code to clipboard
OUT
activity.py
audio.py
elements.py
__init__.py
interactions.py
ocr.py
__pycache__
report.py
summary.py
"""AI summary generator using Claude."""
import os
from datetime import date
from typing import Any
from consumers.activity import app_time, summary_stats, browser_urls, ui_event_summary
from consumers.ocr import deduplicated_text
from consumers.audio import formatted_transcript
SUMMARY_TYPES = {
"day_recap": {
"title": "Day Recap",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
## Audio/speech:
{audio}
Write a concise day recap using EXACTLY this format:
## Summary
One sentence: what I mainly worked on today.
## Accomplishments
- Top 3 things I finished, with approximate times
- Name specific apps, files, or projects
## Key Moments
- Important things seen or heard, with timestamps
## Unfinished Work
- What to continue tomorrow
## Patterns
- Apps used most, topics that came up repeatedly
Only report what you can verify from the data. End with:
**Next step:** [most important thing to continue]""",
},
"standup": {
"title": "Standup Update",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
## Audio/speech:
{audio}
Write a brief standup update:
**Yesterday:** What I worked on (2-3 bullets)
**Today:** What I plan to continue (1-2 bullets)
**Blockers:** Any issues observed (or "None")
Keep it under 150 words. Only report what's verifiable from the data.""",
},
"focus_time": {
"title": "Focus & Distraction Analysis",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
Analyze focus vs distraction patterns:
## Deep Work Periods
- When and how long were sustained focus sessions?
- What was being worked on?
## Distractions
- Which apps/sites were used recreationally?
- How much time was lost to context switching?
## Recommendations
- 2-3 concrete suggestions to improve focus tomorrow
Be specific with times and app names.""",
},
}
def _build_context(for_date: date) -> dict[str, str]:
apps = app_time(for_date)
app_lines = "\n".join(f"- {a['app_name']}: {a['minutes']} min" for a in apps[:20])
urls = browser_urls(for_date, limit=20)
url_lines = "\n".join(
f"- {u['browser_url'][:100]} ({u['minutes']} min)" for u in urls
)
ui_rows = ui_event_summary(for_date)
ui_lines = "\n".join(
f"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches"
for r in ui_rows[:15]
)
ocr_rows = deduplicated_text(for_date, chunk_minutes=5)
ocr_lines = "\n".join(
f"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}"
for r in ocr_rows[:100]
)
audio = formatted_transcript(for_date)
return {
"app_time": app_lines or "(no app data)",
"browser_urls": url_lines or "(no browser data)",
"ui_events": ui_lines or "(no UI event data)",
"ocr_text": ocr_lines or "(no screen data)",
"audio": audio[:3000] if len(audio) > 3000 else audio,
}
def generate(
summary_type: str = "day_recap",
for_date: date | None = None,
api_key: str | None = None,
) -> dict[str, Any]:
"""Generate an AI summary. Returns dict with 'title', 'content', 'date'."""
import anthropic
d = for_date or date.today()
key = api_key or os.environ.get("ANTHROPIC_API_KEY", "")
if not key:
return {
"title": "Error",
"content": "ANTHROPIC_API_KEY not set. Add it to your .env file.",
"date": str(d),
}
spec = SUMMARY_TYPES.get(summary_type)
if not spec:
return {"title": "Error", "content": f"Unknown summary type: {summary_type}", "date": str(d)}
stats = summary_stats(d)
if stats["total_frames"] == 0:
return {
"title": spec["title"],
"content": f"No screen data found for {d}.",
"date": str(d),
}
ctx = _build_context(d)
prompt = spec["prompt"].format(**ctx)
client = anthropic.Anthropic(api_key=key)
message = client.messages.create(
model="claude-haiku-4-5-20251001",
max_tokens=1024,
messages=[{"role": "user", "content": prompt}],
)
return {
"title": spec["title"],
"content": message.content[0].text,
"date": str(d),
"stats": stats,
}
Thinking
Thinking
Bash
Read all pipe.md files
IN
for f in /volume1/screenpipe/pipes/*/pipe.md; do echo "=== $f ==="; cat "$f"; echo; done
Copy code to clipboard
OUT
=== /volume1/screenpipe/pipes/ai-habits/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: AI Habits
description: "How you use AI tools — patterns and insights"
icon: "🤖"
featured: true
---
Search my recordings from the last 24 hours for AI tool usage. Use app_name filter for each tool separately: ChatGPT, Claude, Copilot, Cursor, Gemini, Perplexity. Use limit=5 per search, max 6 searches total.
Read screenpipe skill first.
Use this exact format:
## AI Tools Used
- List each tool with approximate time spent (e.g. "Claude: ~45min")
## What I Used Them For
- For each tool: coding, writing, research, or brainstorming
## Usage Patterns
- Do I switch between tools? Use them in bursts or steadily?
## Effectiveness
- Which tool appeared alongside completed work vs. abandoned attempts
If no AI usage is found, say so clearly. End with: "**Tip:** [one suggestion to use AI tools more effectively]"
=== /volume1/screenpipe/pipes/day-recap/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Day Recap
description: "Today's accomplishments, key moments, and unfinished work"
icon: "📋"
featured: true
---
Analyze my screen and audio recordings from today (last 16 hours only).
Read screenpipe skill first.
Use this exact format:
## Summary
One sentence: what I mainly did today.
## Accomplishments
- Top 3 things I finished, with timestamps (e.g. "2:30 PM")
- Name specific apps, files, or projects
## Key Moments
- Important things I saw, said, or heard — with timestamps
## Unfinished Work
- What I should continue tomorrow — name the app/file/task
## Patterns
- Apps I used most, topics that came up repeatedly
Only report what you can verify from the data. End with: "**Next step:** [most important thing to continue]"
=== /volume1/screenpipe/pipes/meeting-summary/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Meeting Summary
description: "Summarize meeting transcript with key takeaways and action items"
icon: "🤝"
featured: false
---
Summarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.
Read screenpipe skill first.
Use this exact format:
## Meeting Summary
One sentence: what this meeting was about.
## Key Takeaways
- Top 3-5 important points discussed
- Include who said what when relevant
## Action Items
- [ ] Task — assigned to whom, deadline if mentioned
- [ ] Task — assigned to whom
## Decisions Made
- List any decisions or agreements reached
## Open Questions
- Anything unresolved or needing follow-up
Keep it concise and actionable.
=== /volume1/screenpipe/pipes/standup-update/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Standup Update
description: "What you did, what's next, and any blockers"
icon: "🏢"
featured: true
---
Based on my recordings from the last 24 hours, generate a standup update. Use limit=10 per search, max 3 searches total.
Read screenpipe skill first.
Use this exact format:
## Yesterday
- What I worked on (name specific projects, files, tools, PRs)
## Today
- What I will work on next (based on unfinished tasks and recent activity)
## Blockers
- Issues I hit — errors, slow builds, waiting on someone
- If no blockers, write "None"
Keep it under 150 words. Copy-paste ready for a team standup.
=== /volume1/screenpipe/pipes/time-breakdown/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Time Breakdown
description: "Where your time went — by app, project, and category"
icon: "⏱"
featured: false
---
Analyze my app usage from today (last 12 hours). Use limit=10 per search, max 4 searches. Prefer /raw_sql with COUNT/GROUP BY queries.
Read screenpipe skill first.
Use this exact format with durations and percentages:
## By Application
- List each app with duration and percentage, sorted by time (e.g. "VS Code: 2h 15min (28%)")
## By Category
- Group into: coding, meetings, browsing, writing, communication, other
- Show hours and percentage per category
## By Project
- Group related activities by project/topic. Name specific repos or tasks.
## Productivity Score
- Calculate: focused_work_hours / total_hours as a percentage
- Focused = coding + writing. Unfocused = browsing + switching.
End with: "**Suggestion:** [one specific change to improve tomorrow's productivity]"
=== /volume1/screenpipe/pipes/video-export/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Export Video Clip
description: "Create a video of your recent screen activity"
icon: "🎬"
featured: false
---
Export a video of my screen activity from the last 5 minutes.
Read screenpipe skill first.
Use the POST /frames/export endpoint with the time range and fps=1.0. Then show me the exported video file path as an inline code block so I can watch it.
If the export is large, suggest a lower fps or shorter time range.
Thinking
Thinking
Now I have a clear picture. The pipes are markdown prompt templates in
/volume1/screenpipe/pipes/
, but there's no code to actually load and run them —
consumers/summary.py
has its own hardcoded prompts instead.
Here's what I'll implement:
consumers/pipes.py
— dynamically loads pipe.md files and runs them via Claude (data injected as system message, pipe body as user prompt)
main.py
— two new endpoints:
GET /api/pipes
and
POST /api/pipes/{pipe_id}/run
cli.py
— a
pipe
command to run pipes from the terminal
Let me build it:
Bash
Check browser_urls signature
IN
cat /volume1/screenpipe/app/consumers/activity.py | grep "def browser_urls" -A 5
Copy code to clipboard
OUT
def browser_urls(
for_date: date | None = None,
app_name: str | None = None,
ts_from: str | None = None,
ts_to: str | None = None,
limit: int = 30,
Write
pipes.py
pipes.py
143 lines
"""Dynamic pipe loader and runner."""
import os
import re
from datetime import date
from pathlib import Path
from typing import Any
def _parse_frontmatter(text: str) -> tuple[dict, str]:
if not text.startswith("---"):
return {}, text
try:
end = text.index("---", 3)
except ValueError:
return {}, text
fm_text = text[3:end].strip()
body = text[end + 3:].strip()
meta: dict = {}
for line in fm_text.splitlines():
if ":" in line:
k, _, v = line.partition(":")
meta[k.strip()] = v.strip().strip('"')
return meta, body
def load_pipes(pipes_dir: Path) -> list[dict]:
if not pipes_dir.exists():
return []
pipes = []
for pipe_dir in sorted(pipes_dir.iterdir()):
if not pipe_dir.is_dir() or pipe_dir.name.startswith("."):
continue
pipe_md = pipe_dir / "pipe.md"
if not pipe_md.exists():
continue
text = pipe_md.read_text(encoding="utf-8")
meta, body = _parse_frontmatter(text)
if meta.get("enabled", "true").lower() == "false":
continue
body = re.sub(r"Read screenpipe skill first\.?\n?", "", body).strip()
pipes.append({
"id": pipe_dir.name,
"title": meta.get("title", pipe_dir.name),
"description": meta.get("description", ""),
"icon": meta.get("icon", ""),
"schedule": meta.get("schedule", "manual"),
"featured": meta.get("featured", "false").lower() == "true",
"prompt": body,
})
return pipes
def _build_system(d: date, stats: dict) -> str:
from consumers.activity import app_time, browser_urls, ui_event_summary
from consumers.ocr import deduplicated_text
from consumers.audio import formatted_transcript
apps = app_time(d)
app_lines = "\n".join(f"- {a['app_name']}: {a['minutes']} min" for a in apps[:20])
urls = browser_urls(d, limit=20)
url_lines = "\n".join(f"- {u['browser_url'][:100]} ({u['minutes']} min)" for u in urls)
ui_rows = ui_event_summary(d)
ui_lines = "\n".join(
f"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches"
for r in ui_rows[:15]
)
ocr_rows = deduplicated_text(d, chunk_minutes=5)
ocr_lines = "\n".join(
f"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}"
for r in ocr_rows[:100]
)
audio = formatted_transcript(d)
if len(audio) > 3000:
audio = audio[:3000]
return f"""You are analyzing screenpipe data — recordings of a person's computer activity.
## App usage (minutes per app):
{app_lines or '(no app data)'}
## Browser URLs visited:
{url_lines or '(no browser data)'}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_lines or '(no UI event data)'}
## Screen content (sampled every 5 minutes):
{ocr_lines or '(no screen data)'}
## Audio / speech:
{audio or '(no audio data)'}
Date: {d}
Total frames recorded: {stats['total_frames']}"""
def run_pipe(
pipe_id: str,
for_date: date | None = None,
api_key: str | None = None,
pipes_dir: Path | None = None,
) -> dict[str, Any]:
import anthropic
from consumers.activity import summary_stats
d = for_date or date.today()
key = api_key or os.environ.get("ANTHROPIC_API_KEY", "")
if not key:
return {"title": "Error", "content": "ANTHROPIC_API_KEY not set.", "date": str(d)}
_pipes_dir = pipes_dir or Path(os.environ.get("PIPES_DIR", "/data/pipes"))
all_pipes = {p["id"]: p for p in load_pipes(_pipes_dir)}
if pipe_id not in all_pipes:
return {"title": "Error", "content": f"Pipe not found: {pipe_id}", "date": str(d)}
pipe = all_pipes[pipe_id]
stats = summary_stats(d)
if stats["total_frames"] == 0:
return {"title": pipe["title"], "content": f"No screen data found for {d}.", "date": str(d)}
system = _build_system(d, stats)
client = anthropic.Anthropic(api_key=key)
message = client.messages.create(
model="claude-haiku-4-5-20251001",
max_tokens=1024,
system=system,
messages=[{"role": "user", "content": pipe["prompt"]}],
)
return {
"title": pipe["title"],
"content": message.content[0].text,
"date": str(d),
"stats": stats,
}
Now add the API endpoints to
main.py
:
Edit
main.py
main.py
Added 1 line
Edit
main.py
main.py
Added 1 line
Now add the pipe endpoints at the end of main.py, before the closing summary section:
Edit
main.py
main.py
Added 14 lines
Now add the CLI command to
cli.py
cli.py
:
Edit
cli.py
cli.py
Added 40 lines
Done. Here's how to run pipes:
How to run pipes
How to run pipes
Via Docker (inside the running container):
Copy code to clipboard
docker exec -it screenpipe-app python cli.py pipe --list
docker exec -it screenpipe-app python cli.py pipe day-recap
docker exec -it screenpipe-app python cli.py pipe standup-update --date yesterday
Via the API
(once the container is running on port 8766):
Copy code to clipboard
# List pipes
curl http://localhost:8766/api/pipes
# Run a pipe
curl -X POST "http://localhost:8766/api/pipes/day-recap/run"
curl -X POST "http://localhost:8766/api/pipes/standup-update/run?d=2026-04-25"
Rebuild and restart
to pick up the changes:
Copy code to clipboard
cd /volume1/screenpipe/app
docker compose up --build -d
How it works:
Each
pipe.md
file is loaded dynamically — the frontmatter provides metadata and the body becomes the user prompt. Screenpipe data (app usage, browser URLs, OCR, audio) is injected as a Claude system message so the pipe prompt can reference it naturally. The "Read screenpipe skill first" line is stripped automatically.
The pipes directory inside Docker is
/data/pipes
(since
/volume1/screenpipe
→
/data
). You can override it with a
PIPES_DIR
env var if needed.
Message actions
pipe.md
pipe.md
where to place api key and can I use different keys
Thinking
Thinking
Bash
Read .env file
IN
cat /volume1/screenpipe/app/.env
Copy code to clipboard
OUT
[ENV_SECRET]
Where to place the key:
app/.env
app/.env
— replace
your_key_here
with your actual key:
Copy code to clipboard
[ENV_SECRET]
That file is loaded by
load_dotenv()
at startup and is excluded from git via
.gitignore
.
Can you use different keys per pipe?
Not currently — all pipes share the one key from
.env
. But you can add per-pipe key support by adding an
api_key
field to the pipe's frontmatter:
Copy code to clipboard
---
title: Meeting Summary
api_key_env: ANTHROPIC_KEY_MEETINGS
---
Then in
consumers/pipes.py
consumers/pipes.py
, read it in
_parse_frontmatter
and pass it through
run_pipe
. Want me to add that?
Message actions
pipe.md
pipe.md
can I use mistral or other llm? or is is build for antrophic only
Thinking
Thinking
Currently it's Anthropic-only — the code calls the
anthropic
SDK directly in both...
|
[{"role":"AXRadioButton","text [{"role":"AXRadioButton","text":"Explorer (⇧⌘E)","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":true},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Search (⇧⌘F)","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Source Control (⌃⇧G) - 10 pending changes","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"10","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Run and Debug (⇧⌘D)","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Remote Explorer","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Extensions (⇧⌘X) - 2 require update","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"2","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Claude Code","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"Containers","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXHeading","text":"EXPLORER","depth":17,"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"EXPLORER","depth":18,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Explorer Section: screenpipe [SSH: nas]","depth":21,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":true},{"role":"AXStaticText","text":"","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"Explorer Section: screenpipe [SSH: nas]","depth":22,"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"SCREENPIPE [SSH: NAS]","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"#recycle","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"app","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"__pycache__","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"consumers","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"static","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":".env","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"cli.py","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.py","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"docker-compose.yml","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Dockerfile","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"main.py","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"requirements.txt","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"data","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"logs","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"pipes","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":".gitignore","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"app_settings.json","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"archive.db","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"archive.db-bak","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"U","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite-shm","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite-wal","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe_sync_updated.sh","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"U","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe_sync.sh","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe.db","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Outline Section","depth":21,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"OUTLINE","depth":22,"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"OUTLINE","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Timeline Section","depth":21,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"TIMELINE","depth":22,"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"TIMELINE","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"app_settings.json, Editor Group 1","depth":28,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"screenpipe_sync.sh, Editor Group 1","depth":28,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"pipe.md, Editor Group 1","depth":28,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":".env, Editor Group 1","depth":28,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":false},{"role":"AXStaticText","text":"","depth":29,"on_screen":true,"role_description":"text"},{"role":"AXTextArea","text":"ANTHROPIC_API_KEY=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","depth":28,"on_screen":true,"value":"ANTHROPIC_API_KEY=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","role_description":"editor","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"ANTHROPIC_API_KEY=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","depth":29,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Implement and run pipe l…, Editor Group 2","depth":28,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":false},{"role":"AXRadioButton","text":"Problems (⇧⌘M)","depth":22,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"PROBLEMS","depth":24,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Output (⇧⌘U)","depth":22,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUTPUT","depth":24,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Debug Console (⇧⌘Y)","depth":22,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"DEBUG CONSOLE","depth":24,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Terminal (⌃`)","depth":22,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":true},{"role":"AXStaticText","text":"TERMINAL","depth":24,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Ports - 1 forwarded port","depth":22,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"PORTS","depth":24,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":25,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"remote SSH: nas","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"SSH: nas","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"screenpipe (Git) - master*, Checkout Branch/Tag...","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"master*","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"screenpipe (Git) - Synchronize Changes","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"No Problems","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"0","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"0","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Forwarded Ports: 8766","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Notifications","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sign In","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Sign In","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Info: Setting up SSH Host nas: Setting up SSH tunnel","depth":12,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Implement and run pipe logic","depth":19,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Session history","depth":19,"on_screen":true,"help_text":"Session history","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"New session","depth":19,"on_screen":true,"help_text":"New session","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Message actions","depth":24,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"main.py","depth":23,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"lets implement logic with pipes. how can I run it?","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Let me look at the current project structure to understand what's already in place.","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"List project files","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"find /volume1/screenpipe -type f | head -50 && echo \"---\" && ls /volume1/screenpipe","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"/volume1/screenpipe/.DS_Store\n/volume1/screenpipe/screenpipe.db\n/volume1/screenpipe/screenpipe_sync.sh\n/volume1/screenpipe/app_settings.json\n/volume1/screenpipe/.gitignore\n/volume1/screenpipe/archive.db\n/volume1/screenpipe/db.sqlite\n/volume1/screenpipe/db.sqlite-wal\n/volume1/screenpipe/db.sqlite-shm\n/volume1/screenpipe/#recycle/desktop.ini\n/volume1/screenpipe/#recycle/db.sqlite\n/volume1/screenpipe/#recycle/Copy #1 of db.sqlite\n/volume1/screenpipe/#recycle/.DS_Store\n/volume1/screenpipe/#recycle/Copy #2 of db.sqlite\n/volume1/screenpipe/#recycle/archive.db\n/volume1/screenpipe/#recycle/Copy #1 of archive.db\n/volume1/screenpipe/#recycle/Copy #2 of archive.db\n/volume1/screenpipe/#recycle/Copy #3 of archive.db\n/volume1/screenpipe/#recycle/Copy #4 of archive.db\n/volume1/screenpipe/#recycle/Copy #5 of archive.db\n/volume1/screenpipe/#recycle/Copy #3 of db.sqlite\n/volume1/screenpipe/#recycle/Copy #4 of db.sqlite\n/volume1/screenpipe/#recycle/Copy #6 of archive.db\n/volume1/screenpipe/#recycle/test.txt\n/volume1/screenpipe/#recycle/Copy #7 of archive.db\n/volume1/screenpipe/#recycle/Copy #8 of archive.db\n/volume1/screenpipe/#recycle/archive.db-journal\n/volume1/screenpipe/#recycle/Copy #1 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #2 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #3 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #4 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #5 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #6 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #7 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #5 of db.sqlite\n/volume1/screenpipe/pipes/.DS_Store\n/volume1/screenpipe/app/.env\n/volume1/screenpipe/app/cli.py\n/volume1/screenpipe/app/.DS_Store\n/volume1/screenpipe/app/db.py\n/volume1/screenpipe/app/docker-compose.yml\n/volume1/screenpipe/app/main.py\n/volume1/screenpipe/app/requirements.txt\n/volume1/screenpipe/app/Dockerfile\n/volume1/screenpipe/data/.DS_Store\n/volume1/screenpipe/.git/description\n/volume1/screenpipe/.git/HEAD\n/volume1/screenpipe/.git/index\n/volume1/screenpipe/.git/COMMIT_EDITMSG\n/volume1/screenpipe/#recycle/data/.DS_Store\n---\napp\napp_settings.json\narchive.db\ndata\ndb.sqlite\ndb.sqlite-shm\ndb.sqlite-wal\npipes\n#recycle\nscreenpipe.db\nscreenpipe_sync.sh","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"main.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Check pipes directory and docker-compose","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/pipes/ && ls /volume1/screenpipe/app/ && cat /volume1/screenpipe/app/docker-compose.yml","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ai-habits\nday-recap\nmeeting-summary\nstandup-update\ntime-breakdown\nvideo-export\ncli.py\nconsumers\ndb.py\ndocker-compose.yml\nDockerfile\nmain.py\n__pycache__\nrequirements.txt\nstatic\nservices:\n screenpipe-app:\n build: .\n container_name: screenpipe-app\n restart: unless-stopped\n ports:\n - \"8766:8000\"\n volumes:\n - /volume1/screenpipe:/data\n env_file:\n - .env\n environment:\n TZ: Europe/Sofia\n DB_PATH: /data/db.sqlite\n\n sqlite-web-archive:\n image: ghcr.io/coleifer/sqlite-web:latest\n container_name: screenpipe-sqlweb-archive\n restart: unless-stopped\n ports:\n - \"8767:8080\"\n volumes:\n - /volume1/screenpipe:/data\n command: [\"-H\", \"0.0.0.0\", \"-r\", \"/data/archive.db\"]\n\n sqlite-web-live:\n image: ghcr.io/coleifer/sqlite-web:latest\n container_name: screenpipe-sqlweb-live\n restart: unless-stopped\n ports:\n - \"8768:8080\"\n volumes:\n - /volume1/screenpipe:/data\n command: [\"-H\", \"0.0.0.0\", \"-r\", \"/data/db.sqlite\"]","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"requirements.txt","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"requirements.txt","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Inspect a pipe directory","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/pipes/day-recap/ && cat /volume1/screenpipe/pipes/day-recap/pipe.json 2>/dev/null || ls /volume1/screenpipe/pipes/day-recap/","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"pipe.md\npipe.md","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"cli.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"cli.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"List all pipes and their contents","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/pipes/ && for d in /volume1/screenpipe/pipes/*/; do echo \"=== $d ===\"; ls \"$d\"; done","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ai-habits\nday-recap\nmeeting-summary\nstandup-update\ntime-breakdown\nvideo-export\n=== /volume1/screenpipe/pipes/ai-habits/ ===\npipe.md\n=== /volume1/screenpipe/pipes/day-recap/ ===\npipe.md\n=== /volume1/screenpipe/pipes/meeting-summary/ ===\npipe.md\n=== /volume1/screenpipe/pipes/standup-update/ ===\npipe.md\n=== /volume1/screenpipe/pipes/time-breakdown/ ===\npipe.md\n=== /volume1/screenpipe/pipes/video-export/ ===\npipe.md","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read pipe markdown files","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"cat /volume1/screenpipe/pipes/day-recap/pipe.md && echo \"===\" && cat /volume1/screenpipe/pipes/meeting-summary/pipe.md 2>/dev/null | head -50","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Day Recap\ndescription: \"Today's accomplishments, key moments, and unfinished work\"\nicon: \"📋\"\nfeatured: true\n---\n\nAnalyze my screen and audio recordings from today (last 16 hours only). \n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Summary\nOne sentence: what I mainly did today.\n\n## Accomplishments\n- Top 3 things I finished, with timestamps (e.g. \"2:30 PM\")\n- Name specific apps, files, or projects\n\n## Key Moments\n- Important things I saw, said, or heard — with timestamps\n\n## Unfinished Work\n- What I should continue tomorrow — name the app/file/task\n\n## Patterns\n- Apps I used most, topics that came up repeatedly\n\nOnly report what you can verify from the data. End with: \"**Next step:** [most important thing to continue]\"\n===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Meeting Summary\ndescription: \"Summarize meeting transcript with key takeaways and action items\"\nicon: \"🤝\"\nfeatured: false\n---\n\nSummarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.\n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Meeting Summary\nOne sentence: what this meeting was about.\n\n## Key Takeaways\n- Top 3-5 important points discussed\n- Include who said what when relevant\n\n## Action Items\n- [ ] Task — assigned to whom, deadline if mentioned\n- [ ] Task — assigned to whom\n\n## Decisions Made\n- List any decisions or agreements reached\n\n## Open Questions\n- Anything unresolved or needing follow-up\n\nKeep it concise and actionable.","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read summary consumer","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/app/consumers/ && cat /volume1/screenpipe/app/consumers/summary.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"activity.py\naudio.py\nelements.py\n__init__.py\ninteractions.py\nocr.py\n__pycache__\nreport.py\nsummary.py\n\"\"\"AI summary generator using Claude.\"\"\"\nimport os\nfrom datetime import date\nfrom typing import Any\n\nfrom consumers.activity import app_time, summary_stats, browser_urls, ui_event_summary\nfrom consumers.ocr import deduplicated_text\nfrom consumers.audio import formatted_transcript\n\n\nSUMMARY_TYPES = {\n \"day_recap\": {\n \"title\": \"Day Recap\",\n \"prompt\": \"\"\"\\\nYou are analyzing a person's computer activity for the day.\n\n## App usage (minutes per app):\n{app_time}\n\n## Browser URLs visited:\n{browser_urls}\n\n## UI activity per app (clicks / keystrokes / app-switches):\n{ui_events}\n\n## Screen content (sampled every 5 minutes):\n{ocr_text}\n\n## Audio/speech:\n{audio}\n\nWrite a concise day recap using EXACTLY this format:\n\n## Summary\nOne sentence: what I mainly worked on today.\n\n## Accomplishments\n- Top 3 things I finished, with approximate times\n- Name specific apps, files, or projects\n\n## Key Moments\n- Important things seen or heard, with timestamps\n\n## Unfinished Work\n- What to continue tomorrow\n\n## Patterns\n- Apps used most, topics that came up repeatedly\n\nOnly report what you can verify from the data. End with:\n**Next step:** [most important thing to continue]\"\"\",\n },\n \"standup\": {\n \"title\": \"Standup Update\",\n \"prompt\": \"\"\"\\\nYou are analyzing a person's computer activity for the day.\n\n## App usage (minutes per app):\n{app_time}\n\n## Browser URLs visited:\n{browser_urls}\n\n## UI activity per app (clicks / keystrokes / app-switches):\n{ui_events}\n\n## Screen content (sampled every 5 minutes):\n{ocr_text}\n\n## Audio/speech:\n{audio}\n\nWrite a brief standup update:\n\n**Yesterday:** What I worked on (2-3 bullets)\n**Today:** What I plan to continue (1-2 bullets)\n**Blockers:** Any issues observed (or \"None\")\n\nKeep it under 150 words. Only report what's verifiable from the data.\"\"\",\n },\n \"focus_time\": {\n \"title\": \"Focus & Distraction Analysis\",\n \"prompt\": \"\"\"\\\nYou are analyzing a person's computer activity for the day.\n\n## App usage (minutes per app):\n{app_time}\n\n## Browser URLs visited:\n{browser_urls}\n\n## UI activity per app (clicks / keystrokes / app-switches):\n{ui_events}\n\n## Screen content (sampled every 5 minutes):\n{ocr_text}\n\nAnalyze focus vs distraction patterns:\n\n## Deep Work Periods\n- When and how long were sustained focus sessions?\n- What was being worked on?\n\n## Distractions\n- Which apps/sites were used recreationally?\n- How much time was lost to context switching?\n\n## Recommendations\n- 2-3 concrete suggestions to improve focus tomorrow\n\nBe specific with times and app names.\"\"\",\n },\n}\n\n\ndef _build_context(for_date: date) -> dict[str, str]:\n apps = app_time(for_date)\n app_lines = \"\\n\".join(f\"- {a['app_name']}: {a['minutes']} min\" for a in apps[:20])\n\n urls = browser_urls(for_date, limit=20)\n url_lines = \"\\n\".join(\n f\"- {u['browser_url'][:100]} ({u['minutes']} min)\" for u in urls\n )\n\n ui_rows = ui_event_summary(for_date)\n ui_lines = \"\\n\".join(\n f\"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches\"\n for r in ui_rows[:15]\n )\n\n ocr_rows = deduplicated_text(for_date, chunk_minutes=5)\n ocr_lines = \"\\n\".join(\n f\"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}\"\n for r in ocr_rows[:100]\n )\n\n audio = formatted_transcript(for_date)\n\n return {\n \"app_time\": app_lines or \"(no app data)\",\n \"browser_urls\": url_lines or \"(no browser data)\",\n \"ui_events\": ui_lines or \"(no UI event data)\",\n \"ocr_text\": ocr_lines or \"(no screen data)\",\n \"audio\": audio[:3000] if len(audio) > 3000 else audio,\n }\n\n\ndef generate(\n summary_type: str = \"day_recap\",\n for_date: date | None = None,\n api_key: str | None = None,\n) -> dict[str, Any]:\n \"\"\"Generate an AI summary. Returns dict with 'title', 'content', 'date'.\"\"\"\n import anthropic\n\n d = for_date or date.today()\n key = api_key or os.environ.get(\"ANTHROPIC_API_KEY\", \"\")\n if not key:\n return {\n \"title\": \"Error\",\n \"content\": \"ANTHROPIC_API_KEY not set. Add it to your .env file.\",\n \"date\": str(d),\n }\n\n spec = SUMMARY_TYPES.get(summary_type)\n if not spec:\n return {\"title\": \"Error\", \"content\": f\"Unknown summary type: {summary_type}\", \"date\": str(d)}\n\n stats = summary_stats(d)\n if stats[\"total_frames\"] == 0:\n return {\n \"title\": spec[\"title\"],\n \"content\": f\"No screen data found for {d}.\",\n \"date\": str(d),\n }\n\n ctx = _build_context(d)\n prompt = spec[\"prompt\"].format(**ctx)\n\n client = anthropic.Anthropic(api_key=key)\n message = client.messages.create(\n model=\"claude-haiku-4-5-20251001\",\n max_tokens=1024,\n messages=[{\"role\": \"user\", \"content\": prompt}],\n )\n\n return {\n \"title\": spec[\"title\"],\n \"content\": message.content[0].text,\n \"date\": str(d),\n \"stats\": stats,\n }","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read all pipe.md files","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"for f in /volume1/screenpipe/pipes/*/pipe.md; do echo \"=== $f ===\"; cat \"$f\"; echo; done","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"=== /volume1/screenpipe/pipes/ai-habits/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: AI Habits\ndescription: \"How you use AI tools — patterns and insights\"\nicon: \"🤖\"\nfeatured: true\n---\n\nSearch my recordings from the last 24 hours for AI tool usage. Use app_name filter for each tool separately: ChatGPT, Claude, Copilot, Cursor, Gemini, Perplexity. Use limit=5 per search, max 6 searches total.\n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## AI Tools Used\n- List each tool with approximate time spent (e.g. \"Claude: ~45min\")\n\n## What I Used Them For\n- For each tool: coding, writing, research, or brainstorming\n\n## Usage Patterns\n- Do I switch between tools? Use them in bursts or steadily?\n\n## Effectiveness\n- Which tool appeared alongside completed work vs. abandoned attempts\n\nIf no AI usage is found, say so clearly. End with: \"**Tip:** [one suggestion to use AI tools more effectively]\"\n\n=== /volume1/screenpipe/pipes/day-recap/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Day Recap\ndescription: \"Today's accomplishments, key moments, and unfinished work\"\nicon: \"📋\"\nfeatured: true\n---\n\nAnalyze my screen and audio recordings from today (last 16 hours only). \n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Summary\nOne sentence: what I mainly did today.\n\n## Accomplishments\n- Top 3 things I finished, with timestamps (e.g. \"2:30 PM\")\n- Name specific apps, files, or projects\n\n## Key Moments\n- Important things I saw, said, or heard — with timestamps\n\n## Unfinished Work\n- What I should continue tomorrow — name the app/file/task\n\n## Patterns\n- Apps I used most, topics that came up repeatedly\n\nOnly report what you can verify from the data. End with: \"**Next step:** [most important thing to continue]\"\n\n=== /volume1/screenpipe/pipes/meeting-summary/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Meeting Summary\ndescription: \"Summarize meeting transcript with key takeaways and action items\"\nicon: \"🤝\"\nfeatured: false\n---\n\nSummarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.\n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Meeting Summary\nOne sentence: what this meeting was about.\n\n## Key Takeaways\n- Top 3-5 important points discussed\n- Include who said what when relevant\n\n## Action Items\n- [ ] Task — assigned to whom, deadline if mentioned\n- [ ] Task — assigned to whom\n\n## Decisions Made\n- List any decisions or agreements reached\n\n## Open Questions\n- Anything unresolved or needing follow-up\n\nKeep it concise and actionable.\n\n=== /volume1/screenpipe/pipes/standup-update/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Standup Update\ndescription: \"What you did, what's next, and any blockers\"\nicon: \"🏢\"\nfeatured: true\n---\n\nBased on my recordings from the last 24 hours, generate a standup update. Use limit=10 per search, max 3 searches total.\n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Yesterday\n- What I worked on (name specific projects, files, tools, PRs)\n\n## Today\n- What I will work on next (based on unfinished tasks and recent activity)\n\n## Blockers\n- Issues I hit — errors, slow builds, waiting on someone\n- If no blockers, write \"None\"\n\nKeep it under 150 words. Copy-paste ready for a team standup.\n\n=== /volume1/screenpipe/pipes/time-breakdown/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Time Breakdown\ndescription: \"Where your time went — by app, project, and category\"\nicon: \"⏱\"\nfeatured: false\n---\n\nAnalyze my app usage from today (last 12 hours). Use limit=10 per search, max 4 searches. Prefer /raw_sql with COUNT/GROUP BY queries.\n\nRead screenpipe skill first.\n\nUse this exact format with durations and percentages:\n\n## By Application\n- List each app with duration and percentage, sorted by time (e.g. \"VS Code: 2h 15min (28%)\")\n\n## By Category\n- Group into: coding, meetings, browsing, writing, communication, other\n- Show hours and percentage per category\n\n## By Project\n- Group related activities by project/topic. Name specific repos or tasks.\n\n## Productivity Score\n- Calculate: focused_work_hours / total_hours as a percentage\n- Focused = coding + writing. Unfocused = browsing + switching.\n\nEnd with: \"**Suggestion:** [one specific change to improve tomorrow's productivity]\"\n\n=== /volume1/screenpipe/pipes/video-export/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Export Video Clip\ndescription: \"Create a video of your recent screen activity\"\nicon: \"🎬\"\nfeatured: false\n---\n\nExport a video of my screen activity from the last 5 minutes.\n\nRead screenpipe skill first.\n\nUse the POST /frames/export endpoint with the time range and fps=1.0. Then show me the exported video file path as an inline code block so I can watch it.\n\nIf the export is large, suggest a lower fps or shorter time range.","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Now I have a clear picture. The pipes are markdown prompt templates in","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"/volume1/screenpipe/pipes/","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":", but there's no code to actually load and run them —","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"consumers/summary.py","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"has its own hardcoded prompts instead.","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Here's what I'll implement:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"consumers/pipes.py","depth":26,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"— dynamically loads pipe.md files and runs them via Claude (data injected as system message, pipe body as user prompt)","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"main.py","depth":26,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"— two new endpoints:","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"GET /api/pipes","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"and","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"POST /api/pipes/{pipe_id}/run","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"cli.py","depth":26,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"— a","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"pipe","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"command to run pipes from the terminal","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Let me build it:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Check browser_urls signature","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"cat /volume1/screenpipe/app/consumers/activity.py | grep \"def browser_urls\" -A 5","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"def browser_urls(\n for_date: date | None = None,\n app_name: str | None = None,\n ts_from: str | None = None,\n ts_to: str | None = None,\n limit: int = 30,","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Write","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"pipes.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"pipes.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"143 lines","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"\"\"\"Dynamic pipe loader and runner.\"\"\"\nimport os\nimport re\nfrom datetime import date\nfrom pathlib import Path\nfrom typing import Any\n\n\ndef _parse_frontmatter(text: str) -> tuple[dict, str]:\n if not text.startswith(\"---\"):\n return {}, text\n try:\n end = text.index(\"---\", 3)\n except ValueError:\n return {}, text\n fm_text = text[3:end].strip()\n body = text[end + 3:].strip()\n meta: dict = {}\n for line in fm_text.splitlines():\n if \":\" in line:\n k, _, v = line.partition(\":\")\n meta[k.strip()] = v.strip().strip('\"')\n return meta, body\n\n\ndef load_pipes(pipes_dir: Path) -> list[dict]:\n if not pipes_dir.exists():\n return []\n pipes = []\n for pipe_dir in sorted(pipes_dir.iterdir()):\n if not pipe_dir.is_dir() or pipe_dir.name.startswith(\".\"):\n continue\n pipe_md = pipe_dir / \"pipe.md\"\n if not pipe_md.exists():\n continue\n text = pipe_md.read_text(encoding=\"utf-8\")\n meta, body = _parse_frontmatter(text)\n if meta.get(\"enabled\", \"true\").lower() == \"false\":\n continue\n body = re.sub(r\"Read screenpipe skill first\\.?\\n?\", \"\", body).strip()\n pipes.append({\n \"id\": pipe_dir.name,\n \"title\": meta.get(\"title\", pipe_dir.name),\n \"description\": meta.get(\"description\", \"\"),\n \"icon\": meta.get(\"icon\", \"\"),\n \"schedule\": meta.get(\"schedule\", \"manual\"),\n \"featured\": meta.get(\"featured\", \"false\").lower() == \"true\",\n \"prompt\": body,\n })\n return pipes\n\n\ndef _build_system(d: date, stats: dict) -> str:\n from consumers.activity import app_time, browser_urls, ui_event_summary\n from consumers.ocr import deduplicated_text\n from consumers.audio import formatted_transcript\n\n apps = app_time(d)\n app_lines = \"\\n\".join(f\"- {a['app_name']}: {a['minutes']} min\" for a in apps[:20])\n\n urls = browser_urls(d, limit=20)\n url_lines = \"\\n\".join(f\"- {u['browser_url'][:100]} ({u['minutes']} min)\" for u in urls)\n\n ui_rows = ui_event_summary(d)\n ui_lines = \"\\n\".join(\n f\"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches\"\n for r in ui_rows[:15]\n )\n\n ocr_rows = deduplicated_text(d, chunk_minutes=5)\n ocr_lines = \"\\n\".join(\n f\"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}\"\n for r in ocr_rows[:100]\n )\n\n audio = formatted_transcript(d)\n if len(audio) > 3000:\n audio = audio[:3000]\n\n return f\"\"\"You are analyzing screenpipe data — recordings of a person's computer activity.\n\n## App usage (minutes per app):\n{app_lines or '(no app data)'}\n\n## Browser URLs visited:\n{url_lines or '(no browser data)'}\n\n## UI activity per app (clicks / keystrokes / app-switches):\n{ui_lines or '(no UI event data)'}\n\n## Screen content (sampled every 5 minutes):\n{ocr_lines or '(no screen data)'}\n\n## Audio / speech:\n{audio or '(no audio data)'}\n\nDate: {d}\nTotal frames recorded: {stats['total_frames']}\"\"\"\n\n\ndef run_pipe(\n pipe_id: str,\n for_date: date | None = None,\n api_key: str | None = None,\n pipes_dir: Path | None = None,\n) -> dict[str, Any]:\n import anthropic\n from consumers.activity import summary_stats\n\n d = for_date or date.today()\n key = api_key or os.environ.get(\"ANTHROPIC_API_KEY\", \"\")\n if not key:\n return {\"title\": \"Error\", \"content\": \"ANTHROPIC_API_KEY not set.\", \"date\": str(d)}\n\n _pipes_dir = pipes_dir or Path(os.environ.get(\"PIPES_DIR\", \"/data/pipes\"))\n all_pipes = {p[\"id\"]: p for p in load_pipes(_pipes_dir)}\n\n if pipe_id not in all_pipes:\n return {\"title\": \"Error\", \"content\": f\"Pipe not found: {pipe_id}\", \"date\": str(d)}\n\n pipe = all_pipes[pipe_id]\n stats = summary_stats(d)\n\n if stats[\"total_frames\"] == 0:\n return {\"title\": pipe[\"title\"], \"content\": f\"No screen data found for {d}.\", \"date\": str(d)}\n\n system = _build_system(d, stats)\n\n client = anthropic.Anthropic(api_key=key)\n message = client.messages.create(\n model=\"claude-haiku-4-5-20251001\",\n max_tokens=1024,\n system=system,\n messages=[{\"role\": \"user\", \"content\": pipe[\"prompt\"]}],\n )\n\n return {\n \"title\": pipe[\"title\"],\n \"content\": message.content[0].text,\n \"date\": str(d),\n \"stats\": stats,\n }","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Now add the API endpoints to","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"main.py","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":":","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Edit","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"main.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Added 1 line","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Edit","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"main.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Added 1 line","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Now add the pipe endpoints at the end of main.py, before the closing summary section:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Edit","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"main.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Added 14 lines","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Now add the CLI command to","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"cli.py","depth":23,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"cli.py","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":":","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Edit","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"cli.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"cli.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Added 40 lines","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Done. Here's how to run pipes:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXHeading","text":"How to run pipes","depth":22,"on_screen":false,"role_description":"heading"},{"role":"AXStaticText","text":"How to run pipes","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Via Docker (inside the running container):","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":23,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"docker exec -it screenpipe-app python cli.py pipe --list\ndocker exec -it screenpipe-app python cli.py pipe day-recap\ndocker exec -it screenpipe-app python cli.py pipe standup-update --date yesterday","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Via the API","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"(once the container is running on port 8766):","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":23,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"# List pipes\ncurl http://localhost:8766/api/pipes\n\n# Run a pipe\ncurl -X POST \"http://localhost:8766/api/pipes/day-recap/run\"\ncurl -X POST \"http://localhost:8766/api/pipes/standup-update/run?d=2026-04-25\"","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Rebuild and restart","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"to pick up the changes:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":23,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"cd /volume1/screenpipe/app\ndocker compose up --build -d","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"How it works:","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Each","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"pipe.md","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"file is loaded dynamically — the frontmatter provides metadata and the body becomes the user prompt. Screenpipe data (app usage, browser URLs, OCR, audio) is injected as a Claude system message so the pipe prompt can reference it naturally. The \"Read screenpipe skill first\" line is stripped automatically.","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"The pipes directory inside Docker is","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"/data/pipes","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"(since","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"/volume1/screenpipe","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"→","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"/data","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"). You can override it with a","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"PIPES_DIR","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"env var if needed.","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Message actions","depth":24,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"pipe.md","depth":23,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"pipe.md","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"where to place api key and can I use different keys","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read .env file","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"cat /volume1/screenpipe/app/.env","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ANTHROPIC_API_KEY=your_key_here","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Where to place the key:","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"app/.env","depth":23,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"app/.env","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"— replace","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"your_key_here","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"with your actual key:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":23,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"ANTHROPIC_API_KEY=sk-ant-...","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"That file is loaded by","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"load_dotenv()","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"at startup and is excluded from git via","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":".gitignore","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":".","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Can you use different keys per pipe?","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Not currently — all pipes share the one key from","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":".env","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":". But you can add per-pipe key support by adding an","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"api_key","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"field to the pipe's frontmatter:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":23,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"---\ntitle: Meeting Summary\napi_key_env: ANTHROPIC_KEY_MEETINGS\n---","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Then in","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"consumers/pipes.py","depth":23,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"consumers/pipes.py","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":", read it in","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"_parse_frontmatter","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"and pass it through","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"run_pipe","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":". Want me to add that?","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Message actions","depth":24,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"pipe.md","depth":23,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"pipe.md","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"can I use mistral or other llm? or is is build for antrophic only","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Currently it's Anthropic-only — the code calls the","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"anthropic","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"SDK directly in both","depth":23,"on_screen":false,"role_description":"text"}]...
|
556607221063026044
|
-8763776880662820760
|
idle
|
accessibility
|
NULL
|
Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧ Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py
M
db.py
docker-compose.yml
Dockerfile
M
main.py
M
requirements.txt
M
data
logs
pipes
.gitignore
app_settings.json
archive.db
archive.db-bak
U
db.sqlite
db.sqlite-shm
db.sqlite-wal
screenpipe_sync_updated.sh
U
screenpipe_sync.sh
screenpipe.db
Outline Section
OUTLINE
OUTLINE
Timeline Section
TIMELINE
TIMELINE
app_settings.json, Editor Group 1
screenpipe_sync.sh, Editor Group 1
pipe.md, Editor Group 1
.env, Editor Group 1
[ENV_SECRET]
[ENV_SECRET]
Implement and run pipe l…, Editor Group 2
Problems (⇧⌘M)
PROBLEMS
Output (⇧⌘U)
OUTPUT
Debug Console (⇧⌘Y)
DEBUG CONSOLE
Terminal (⌃`)
TERMINAL
Ports - 1 forwarded port
PORTS
1
remote SSH: nas
SSH: nas
screenpipe (Git) - master*, Checkout Branch/Tag...
master*
screenpipe (Git) - Synchronize Changes
No Problems
0
0
Forwarded Ports: 8766
1
Notifications
Sign In
Sign In
Info: Setting up SSH Host nas: Setting up SSH tunnel
Implement and run pipe logic
Session history
New session
Message actions
main.py
main.py
lets implement logic with pipes. how can I run it?
Thinking
Thinking
Let me look at the current project structure to understand what's already in place.
Bash
List project files
IN
find /volume1/screenpipe -type f | head -50 && echo "---" && ls /volume1/screenpipe
Copy code to clipboard
OUT
/volume1/screenpipe/.DS_Store
/volume1/screenpipe/screenpipe.db
/volume1/screenpipe/screenpipe_sync.sh
/volume1/screenpipe/app_settings.json
/volume1/screenpipe/.gitignore
/volume1/screenpipe/archive.db
/volume1/screenpipe/db.sqlite
/volume1/screenpipe/db.sqlite-wal
/volume1/screenpipe/db.sqlite-shm
/volume1/screenpipe/#recycle/desktop.ini
/volume1/screenpipe/#recycle/db.sqlite
/volume1/screenpipe/#recycle/Copy #1 of db.sqlite
/volume1/screenpipe/#recycle/.DS_Store
/volume1/screenpipe/#recycle/Copy #2 of db.sqlite
/volume1/screenpipe/#recycle/archive.db
/volume1/screenpipe/#recycle/Copy #1 of archive.db
/volume1/screenpipe/#recycle/Copy #2 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of archive.db
/volume1/screenpipe/#recycle/Copy #4 of archive.db
/volume1/screenpipe/#recycle/Copy #5 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of db.sqlite
/volume1/screenpipe/#recycle/Copy #4 of db.sqlite
/volume1/screenpipe/#recycle/Copy #6 of archive.db
/volume1/screenpipe/#recycle/test.txt
/volume1/screenpipe/#recycle/Copy #7 of archive.db
/volume1/screenpipe/#recycle/Copy #8 of archive.db
/volume1/screenpipe/#recycle/archive.db-journal
/volume1/screenpipe/#recycle/Copy #1 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #2 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #3 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #4 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #6 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #7 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of db.sqlite
/volume1/screenpipe/pipes/.DS_Store
/volume1/screenpipe/app/.env
/volume1/screenpipe/app/cli.py
/volume1/screenpipe/app/.DS_Store
/volume1/screenpipe/app/db.py
/volume1/screenpipe/app/docker-compose.yml
/volume1/screenpipe/app/main.py
/volume1/screenpipe/app/requirements.txt
/volume1/screenpipe/app/Dockerfile
/volume1/screenpipe/data/.DS_Store
/volume1/screenpipe/.git/description
/volume1/screenpipe/.git/HEAD
/volume1/screenpipe/.git/index
/volume1/screenpipe/.git/COMMIT_EDITMSG
/volume1/screenpipe/#recycle/data/.DS_Store
---
app
app_settings.json
archive.db
data
db.sqlite
db.sqlite-shm
db.sqlite-wal
pipes
#recycle
screenpipe.db
screenpipe_sync.sh
Read
main.py
main.py
Bash
Check pipes directory and docker-compose
IN
ls /volume1/screenpipe/pipes/ && ls /volume1/screenpipe/app/ && cat /volume1/screenpipe/app/docker-compose.yml
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
cli.py
consumers
db.py
docker-compose.yml
Dockerfile
main.py
__pycache__
requirements.txt
static
services:
screenpipe-app:
build: .
container_name: screenpipe-app
restart: unless-stopped
ports:
- "8766:8000"
volumes:
- /volume1/screenpipe:/data
env_file:
- .env
environment:
TZ: Europe/Sofia
DB_PATH: /data/db.sqlite
sqlite-web-archive:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-archive
restart: unless-stopped
ports:
- "8767:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/archive.db"]
sqlite-web-live:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-live
restart: unless-stopped
ports:
- "8768:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/db.sqlite"]
Read
requirements.txt
requirements.txt
Bash
Inspect a pipe directory
IN
ls /volume1/screenpipe/pipes/day-recap/ && cat /volume1/screenpipe/pipes/day-recap/pipe.json 2>/dev/null || ls /volume1/screenpipe/pipes/day-recap/
Copy code to clipboard
OUT
pipe.md
pipe.md
Read
cli.py
cli.py
Bash
List all pipes and their contents
IN
ls /volume1/screenpipe/pipes/ && for d in /volume1/screenpipe/pipes/*/; do echo "=== $d ==="; ls "$d"; done
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
=== /volume1/screenpipe/pipes/ai-habits/ ===
pipe.md
=== /volume1/screenpipe/pipes/day-recap/ ===
pipe.md
=== /volume1/screenpipe/pipes/meeting-summary/ ===
pipe.md
=== /volume1/screenpipe/pipes/standup-update/ ===
pipe.md
=== /volume1/screenpipe/pipes/time-breakdown/ ===
pipe.md
=== /volume1/screenpipe/pipes/video-export/ ===
pipe.md
Bash
Read pipe markdown files
IN
cat /volume1/screenpipe/pipes/day-recap/pipe.md && echo "===" && cat /volume1/screenpipe/pipes/meeting-summary/pipe.md 2>/dev/null | head -50
Copy code to clipboard
OUT
---
schedule: manual
enabled: true
template: true
title: Day Recap
description: "Today's accomplishments, key moments, and unfinished work"
icon: "📋"
featured: true
---
Analyze my screen and audio recordings from today (last 16 hours only).
Read screenpipe skill first.
Use this exact format:
## Summary
One sentence: what I mainly did today.
## Accomplishments
- Top 3 things I finished, with timestamps (e.g. "2:30 PM")
- Name specific apps, files, or projects
## Key Moments
- Important things I saw, said, or heard — with timestamps
## Unfinished Work
- What I should continue tomorrow — name the app/file/task
## Patterns
- Apps I used most, topics that came up repeatedly
Only report what you can verify from the data. End with: "**Next step:** [most important thing to continue]"
===
---
schedule: manual
enabled: true
template: true
title: Meeting Summary
description: "Summarize meeting transcript with key takeaways and action items"
icon: "🤝"
featured: false
---
Summarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.
Read screenpipe skill first.
Use this exact format:
## Meeting Summary
One sentence: what this meeting was about.
## Key Takeaways
- Top 3-5 important points discussed
- Include who said what when relevant
## Action Items
- [ ] Task — assigned to whom, deadline if mentioned
- [ ] Task — assigned to whom
## Decisions Made
- List any decisions or agreements reached
## Open Questions
- Anything unresolved or needing follow-up
Keep it concise and actionable.
Thinking
Thinking
Bash
Read summary consumer
IN
ls /volume1/screenpipe/app/consumers/ && cat /volume1/screenpipe/app/consumers/summary.py
Copy code to clipboard
OUT
activity.py
audio.py
elements.py
__init__.py
interactions.py
ocr.py
__pycache__
report.py
summary.py
"""AI summary generator using Claude."""
import os
from datetime import date
from typing import Any
from consumers.activity import app_time, summary_stats, browser_urls, ui_event_summary
from consumers.ocr import deduplicated_text
from consumers.audio import formatted_transcript
SUMMARY_TYPES = {
"day_recap": {
"title": "Day Recap",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
## Audio/speech:
{audio}
Write a concise day recap using EXACTLY this format:
## Summary
One sentence: what I mainly worked on today.
## Accomplishments
- Top 3 things I finished, with approximate times
- Name specific apps, files, or projects
## Key Moments
- Important things seen or heard, with timestamps
## Unfinished Work
- What to continue tomorrow
## Patterns
- Apps used most, topics that came up repeatedly
Only report what you can verify from the data. End with:
**Next step:** [most important thing to continue]""",
},
"standup": {
"title": "Standup Update",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
## Audio/speech:
{audio}
Write a brief standup update:
**Yesterday:** What I worked on (2-3 bullets)
**Today:** What I plan to continue (1-2 bullets)
**Blockers:** Any issues observed (or "None")
Keep it under 150 words. Only report what's verifiable from the data.""",
},
"focus_time": {
"title": "Focus & Distraction Analysis",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
Analyze focus vs distraction patterns:
## Deep Work Periods
- When and how long were sustained focus sessions?
- What was being worked on?
## Distractions
- Which apps/sites were used recreationally?
- How much time was lost to context switching?
## Recommendations
- 2-3 concrete suggestions to improve focus tomorrow
Be specific with times and app names.""",
},
}
def _build_context(for_date: date) -> dict[str, str]:
apps = app_time(for_date)
app_lines = "\n".join(f"- {a['app_name']}: {a['minutes']} min" for a in apps[:20])
urls = browser_urls(for_date, limit=20)
url_lines = "\n".join(
f"- {u['browser_url'][:100]} ({u['minutes']} min)" for u in urls
)
ui_rows = ui_event_summary(for_date)
ui_lines = "\n".join(
f"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches"
for r in ui_rows[:15]
)
ocr_rows = deduplicated_text(for_date, chunk_minutes=5)
ocr_lines = "\n".join(
f"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}"
for r in ocr_rows[:100]
)
audio = formatted_transcript(for_date)
return {
"app_time": app_lines or "(no app data)",
"browser_urls": url_lines or "(no browser data)",
"ui_events": ui_lines or "(no UI event data)",
"ocr_text": ocr_lines or "(no screen data)",
"audio": audio[:3000] if len(audio) > 3000 else audio,
}
def generate(
summary_type: str = "day_recap",
for_date: date | None = None,
api_key: str | None = None,
) -> dict[str, Any]:
"""Generate an AI summary. Returns dict with 'title', 'content', 'date'."""
import anthropic
d = for_date or date.today()
key = api_key or os.environ.get("ANTHROPIC_API_KEY", "")
if not key:
return {
"title": "Error",
"content": "ANTHROPIC_API_KEY not set. Add it to your .env file.",
"date": str(d),
}
spec = SUMMARY_TYPES.get(summary_type)
if not spec:
return {"title": "Error", "content": f"Unknown summary type: {summary_type}", "date": str(d)}
stats = summary_stats(d)
if stats["total_frames"] == 0:
return {
"title": spec["title"],
"content": f"No screen data found for {d}.",
"date": str(d),
}
ctx = _build_context(d)
prompt = spec["prompt"].format(**ctx)
client = anthropic.Anthropic(api_key=key)
message = client.messages.create(
model="claude-haiku-4-5-20251001",
max_tokens=1024,
messages=[{"role": "user", "content": prompt}],
)
return {
"title": spec["title"],
"content": message.content[0].text,
"date": str(d),
"stats": stats,
}
Thinking
Thinking
Bash
Read all pipe.md files
IN
for f in /volume1/screenpipe/pipes/*/pipe.md; do echo "=== $f ==="; cat "$f"; echo; done
Copy code to clipboard
OUT
=== /volume1/screenpipe/pipes/ai-habits/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: AI Habits
description: "How you use AI tools — patterns and insights"
icon: "🤖"
featured: true
---
Search my recordings from the last 24 hours for AI tool usage. Use app_name filter for each tool separately: ChatGPT, Claude, Copilot, Cursor, Gemini, Perplexity. Use limit=5 per search, max 6 searches total.
Read screenpipe skill first.
Use this exact format:
## AI Tools Used
- List each tool with approximate time spent (e.g. "Claude: ~45min")
## What I Used Them For
- For each tool: coding, writing, research, or brainstorming
## Usage Patterns
- Do I switch between tools? Use them in bursts or steadily?
## Effectiveness
- Which tool appeared alongside completed work vs. abandoned attempts
If no AI usage is found, say so clearly. End with: "**Tip:** [one suggestion to use AI tools more effectively]"
=== /volume1/screenpipe/pipes/day-recap/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Day Recap
description: "Today's accomplishments, key moments, and unfinished work"
icon: "📋"
featured: true
---
Analyze my screen and audio recordings from today (last 16 hours only).
Read screenpipe skill first.
Use this exact format:
## Summary
One sentence: what I mainly did today.
## Accomplishments
- Top 3 things I finished, with timestamps (e.g. "2:30 PM")
- Name specific apps, files, or projects
## Key Moments
- Important things I saw, said, or heard — with timestamps
## Unfinished Work
- What I should continue tomorrow — name the app/file/task
## Patterns
- Apps I used most, topics that came up repeatedly
Only report what you can verify from the data. End with: "**Next step:** [most important thing to continue]"
=== /volume1/screenpipe/pipes/meeting-summary/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Meeting Summary
description: "Summarize meeting transcript with key takeaways and action items"
icon: "🤝"
featured: false
---
Summarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.
Read screenpipe skill first.
Use this exact format:
## Meeting Summary
One sentence: what this meeting was about.
## Key Takeaways
- Top 3-5 important points discussed
- Include who said what when relevant
## Action Items
- [ ] Task — assigned to whom, deadline if mentioned
- [ ] Task — assigned to whom
## Decisions Made
- List any decisions or agreements reached
## Open Questions
- Anything unresolved or needing follow-up
Keep it concise and actionable.
=== /volume1/screenpipe/pipes/standup-update/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Standup Update
description: "What you did, what's next, and any blockers"
icon: "🏢"
featured: true
---
Based on my recordings from the last 24 hours, generate a standup update. Use limit=10 per search, max 3 searches total.
Read screenpipe skill first.
Use this exact format:
## Yesterday
- What I worked on (name specific projects, files, tools, PRs)
## Today
- What I will work on next (based on unfinished tasks and recent activity)
## Blockers
- Issues I hit — errors, slow builds, waiting on someone
- If no blockers, write "None"
Keep it under 150 words. Copy-paste ready for a team standup.
=== /volume1/screenpipe/pipes/time-breakdown/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Time Breakdown
description: "Where your time went — by app, project, and category"
icon: "⏱"
featured: false
---
Analyze my app usage from today (last 12 hours). Use limit=10 per search, max 4 searches. Prefer /raw_sql with COUNT/GROUP BY queries.
Read screenpipe skill first.
Use this exact format with durations and percentages:
## By Application
- List each app with duration and percentage, sorted by time (e.g. "VS Code: 2h 15min (28%)")
## By Category
- Group into: coding, meetings, browsing, writing, communication, other
- Show hours and percentage per category
## By Project
- Group related activities by project/topic. Name specific repos or tasks.
## Productivity Score
- Calculate: focused_work_hours / total_hours as a percentage
- Focused = coding + writing. Unfocused = browsing + switching.
End with: "**Suggestion:** [one specific change to improve tomorrow's productivity]"
=== /volume1/screenpipe/pipes/video-export/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Export Video Clip
description: "Create a video of your recent screen activity"
icon: "🎬"
featured: false
---
Export a video of my screen activity from the last 5 minutes.
Read screenpipe skill first.
Use the POST /frames/export endpoint with the time range and fps=1.0. Then show me the exported video file path as an inline code block so I can watch it.
If the export is large, suggest a lower fps or shorter time range.
Thinking
Thinking
Now I have a clear picture. The pipes are markdown prompt templates in
/volume1/screenpipe/pipes/
, but there's no code to actually load and run them —
consumers/summary.py
has its own hardcoded prompts instead.
Here's what I'll implement:
consumers/pipes.py
— dynamically loads pipe.md files and runs them via Claude (data injected as system message, pipe body as user prompt)
main.py
— two new endpoints:
GET /api/pipes
and
POST /api/pipes/{pipe_id}/run
cli.py
— a
pipe
command to run pipes from the terminal
Let me build it:
Bash
Check browser_urls signature
IN
cat /volume1/screenpipe/app/consumers/activity.py | grep "def browser_urls" -A 5
Copy code to clipboard
OUT
def browser_urls(
for_date: date | None = None,
app_name: str | None = None,
ts_from: str | None = None,
ts_to: str | None = None,
limit: int = 30,
Write
pipes.py
pipes.py
143 lines
"""Dynamic pipe loader and runner."""
import os
import re
from datetime import date
from pathlib import Path
from typing import Any
def _parse_frontmatter(text: str) -> tuple[dict, str]:
if not text.startswith("---"):
return {}, text
try:
end = text.index("---", 3)
except ValueError:
return {}, text
fm_text = text[3:end].strip()
body = text[end + 3:].strip()
meta: dict = {}
for line in fm_text.splitlines():
if ":" in line:
k, _, v = line.partition(":")
meta[k.strip()] = v.strip().strip('"')
return meta, body
def load_pipes(pipes_dir: Path) -> list[dict]:
if not pipes_dir.exists():
return []
pipes = []
for pipe_dir in sorted(pipes_dir.iterdir()):
if not pipe_dir.is_dir() or pipe_dir.name.startswith("."):
continue
pipe_md = pipe_dir / "pipe.md"
if not pipe_md.exists():
continue
text = pipe_md.read_text(encoding="utf-8")
meta, body = _parse_frontmatter(text)
if meta.get("enabled", "true").lower() == "false":
continue
body = re.sub(r"Read screenpipe skill first\.?\n?", "", body).strip()
pipes.append({
"id": pipe_dir.name,
"title": meta.get("title", pipe_dir.name),
"description": meta.get("description", ""),
"icon": meta.get("icon", ""),
"schedule": meta.get("schedule", "manual"),
"featured": meta.get("featured", "false").lower() == "true",
"prompt": body,
})
return pipes
def _build_system(d: date, stats: dict) -> str:
from consumers.activity import app_time, browser_urls, ui_event_summary
from consumers.ocr import deduplicated_text
from consumers.audio import formatted_transcript
apps = app_time(d)
app_lines = "\n".join(f"- {a['app_name']}: {a['minutes']} min" for a in apps[:20])
urls = browser_urls(d, limit=20)
url_lines = "\n".join(f"- {u['browser_url'][:100]} ({u['minutes']} min)" for u in urls)
ui_rows = ui_event_summary(d)
ui_lines = "\n".join(
f"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches"
for r in ui_rows[:15]
)
ocr_rows = deduplicated_text(d, chunk_minutes=5)
ocr_lines = "\n".join(
f"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}"
for r in ocr_rows[:100]
)
audio = formatted_transcript(d)
if len(audio) > 3000:
audio = audio[:3000]
return f"""You are analyzing screenpipe data — recordings of a person's computer activity.
## App usage (minutes per app):
{app_lines or '(no app data)'}
## Browser URLs visited:
{url_lines or '(no browser data)'}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_lines or '(no UI event data)'}
## Screen content (sampled every 5 minutes):
{ocr_lines or '(no screen data)'}
## Audio / speech:
{audio or '(no audio data)'}
Date: {d}
Total frames recorded: {stats['total_frames']}"""
def run_pipe(
pipe_id: str,
for_date: date | None = None,
api_key: str | None = None,
pipes_dir: Path | None = None,
) -> dict[str, Any]:
import anthropic
from consumers.activity import summary_stats
d = for_date or date.today()
key = api_key or os.environ.get("ANTHROPIC_API_KEY", "")
if not key:
return {"title": "Error", "content": "ANTHROPIC_API_KEY not set.", "date": str(d)}
_pipes_dir = pipes_dir or Path(os.environ.get("PIPES_DIR", "/data/pipes"))
all_pipes = {p["id"]: p for p in load_pipes(_pipes_dir)}
if pipe_id not in all_pipes:
return {"title": "Error", "content": f"Pipe not found: {pipe_id}", "date": str(d)}
pipe = all_pipes[pipe_id]
stats = summary_stats(d)
if stats["total_frames"] == 0:
return {"title": pipe["title"], "content": f"No screen data found for {d}.", "date": str(d)}
system = _build_system(d, stats)
client = anthropic.Anthropic(api_key=key)
message = client.messages.create(
model="claude-haiku-4-5-20251001",
max_tokens=1024,
system=system,
messages=[{"role": "user", "content": pipe["prompt"]}],
)
return {
"title": pipe["title"],
"content": message.content[0].text,
"date": str(d),
"stats": stats,
}
Now add the API endpoints to
main.py
:
Edit
main.py
main.py
Added 1 line
Edit
main.py
main.py
Added 1 line
Now add the pipe endpoints at the end of main.py, before the closing summary section:
Edit
main.py
main.py
Added 14 lines
Now add the CLI command to
cli.py
cli.py
:
Edit
cli.py
cli.py
Added 40 lines
Done. Here's how to run pipes:
How to run pipes
How to run pipes
Via Docker (inside the running container):
Copy code to clipboard
docker exec -it screenpipe-app python cli.py pipe --list
docker exec -it screenpipe-app python cli.py pipe day-recap
docker exec -it screenpipe-app python cli.py pipe standup-update --date yesterday
Via the API
(once the container is running on port 8766):
Copy code to clipboard
# List pipes
curl http://localhost:8766/api/pipes
# Run a pipe
curl -X POST "http://localhost:8766/api/pipes/day-recap/run"
curl -X POST "http://localhost:8766/api/pipes/standup-update/run?d=2026-04-25"
Rebuild and restart
to pick up the changes:
Copy code to clipboard
cd /volume1/screenpipe/app
docker compose up --build -d
How it works:
Each
pipe.md
file is loaded dynamically — the frontmatter provides metadata and the body becomes the user prompt. Screenpipe data (app usage, browser URLs, OCR, audio) is injected as a Claude system message so the pipe prompt can reference it naturally. The "Read screenpipe skill first" line is stripped automatically.
The pipes directory inside Docker is
/data/pipes
(since
/volume1/screenpipe
→
/data
). You can override it with a
PIPES_DIR
env var if needed.
Message actions
pipe.md
pipe.md
where to place api key and can I use different keys
Thinking
Thinking
Bash
Read .env file
IN
cat /volume1/screenpipe/app/.env
Copy code to clipboard
OUT
[ENV_SECRET]
Where to place the key:
app/.env
app/.env
— replace
your_key_here
with your actual key:
Copy code to clipboard
[ENV_SECRET]
That file is loaded by
load_dotenv()
at startup and is excluded from git via
.gitignore
.
Can you use different keys per pipe?
Not currently — all pipes share the one key from
.env
. But you can add per-pipe key support by adding an
api_key
field to the pipe's frontmatter:
Copy code to clipboard
---
title: Meeting Summary
api_key_env: ANTHROPIC_KEY_MEETINGS
---
Then in
consumers/pipes.py
consumers/pipes.py
, read it in
_parse_frontmatter
and pass it through
run_pipe
. Want me to add that?
Message actions
pipe.md
pipe.md
can I use mistral or other llm? or is is build for antrophic only
Thinking
Thinking
Currently it's Anthropic-only — the code calls the
anthropic
SDK directly in both...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
21079
|
922
|
0
|
2026-05-11T17:11:05.837587+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-11/1778 /Users/lukas/.screenpipe/data/data/2026-05-11/1778519465837_m1.jpg...
|
Code
|
Implement and run pipe l… — screenpipe [SSH: nas]
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧ Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py
M
db.py
docker-compose.yml
Dockerfile
M
main.py
M
requirements.txt
M
data
logs
pipes
.gitignore
app_settings.json
archive.db
archive.db-bak
U
db.sqlite
db.sqlite-shm
db.sqlite-wal
screenpipe_sync_updated.sh
U
screenpipe_sync.sh
screenpipe.db
Outline Section
OUTLINE
OUTLINE
Timeline Section
TIMELINE
TIMELINE
app_settings.json, Editor Group 1
screenpipe_sync.sh, Editor Group 1
pipe.md, Editor Group 1
.env, Editor Group 1...
|
[{"role":"AXRadioButton","text [{"role":"AXRadioButton","text":"Explorer (⇧⌘E)","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":true},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Search (⇧⌘F)","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Source Control (⌃⇧G) - 10 pending changes","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"10","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Run and Debug (⇧⌘D)","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Remote Explorer","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Extensions (⇧⌘X) - 2 require update","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"2","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Claude Code","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"Containers","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXHeading","text":"EXPLORER","depth":17,"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"EXPLORER","depth":18,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Explorer Section: screenpipe [SSH: nas]","depth":21,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":true},{"role":"AXStaticText","text":"","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"Explorer Section: screenpipe [SSH: nas]","depth":22,"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"SCREENPIPE [SSH: NAS]","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"#recycle","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"app","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"__pycache__","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"consumers","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"static","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":".env","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"cli.py","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.py","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"docker-compose.yml","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Dockerfile","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"main.py","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"requirements.txt","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"data","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"logs","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"pipes","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":".gitignore","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"app_settings.json","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"archive.db","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"archive.db-bak","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"U","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite-shm","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite-wal","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe_sync_updated.sh","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"U","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe_sync.sh","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe.db","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Outline Section","depth":21,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"OUTLINE","depth":22,"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"OUTLINE","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Timeline Section","depth":21,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"TIMELINE","depth":22,"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"TIMELINE","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"app_settings.json, Editor Group 1","depth":28,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"screenpipe_sync.sh, Editor Group 1","depth":28,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":false},{"role":"AXRadioButton","text":"pipe.md, Editor Group 1","depth":28,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":".env, Editor Group 1","depth":28,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
-3227083228517830000
|
-5525294533514194047
|
click
|
accessibility
|
NULL
|
Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧ Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py
M
db.py
docker-compose.yml
Dockerfile
M
main.py
M
requirements.txt
M
data
logs
pipes
.gitignore
app_settings.json
archive.db
archive.db-bak
U
db.sqlite
db.sqlite-shm
db.sqlite-wal
screenpipe_sync_updated.sh
U
screenpipe_sync.sh
screenpipe.db
Outline Section
OUTLINE
OUTLINE
Timeline Section
TIMELINE
TIMELINE
app_settings.json, Editor Group 1
screenpipe_sync.sh, Editor Group 1
pipe.md, Editor Group 1
.env, Editor Group 1...
|
21078
|
NULL
|
NULL
|
NULL
|
|
21080
|
923
|
0
|
2026-05-11T17:11:05.837404+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-11/1778 /Users/lukas/.screenpipe/data/data/2026-05-11/1778519465837_m2.jpg...
|
Code
|
Implement and run pipe l… — screenpipe [SSH: nas]
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧ Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py
M
db.py
docker-compose.yml
Dockerfile
M
main.py
M
requirements.txt
M
data
logs
pipes
.gitignore
app_settings.json
archive.db
archive.db-bak
U
db.sqlite
db.sqlite-shm
db.sqlite-wal
screenpipe_sync_updated.sh
U
screenpipe_sync.sh
screenpipe.db
Outline Section...
|
[{"role":"AXRadioButton","text [{"role":"AXRadioButton","text":"Explorer (⇧⌘E)","depth":19,"bounds":{"left":0.0,"top":0.047885075,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":true},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.057462092,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Search (⇧⌘F)","depth":19,"bounds":{"left":0.0,"top":0.08619314,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.09577015,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Source Control (⌃⇧G) - 10 pending changes","depth":19,"bounds":{"left":0.0,"top":0.1245012,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.13407822,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"10","depth":22,"bounds":{"left":0.00831117,"top":0.1452514,"width":0.003656915,"height":0.008778931},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.00831117,"top":0.14604948,"width":0.0016622341,"height":0.007980846}},{"char_start":1,"char_count":1,"bounds":{"left":0.009973404,"top":0.14604948,"width":0.0023271276,"height":0.007980846}}],"role_description":"text"},{"role":"AXRadioButton","text":"Run and Debug (⇧⌘D)","depth":19,"bounds":{"left":0.0,"top":0.16280925,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.17238627,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Remote Explorer","depth":19,"bounds":{"left":0.0,"top":0.20111732,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.21069433,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Extensions (⇧⌘X) - 2 require update","depth":19,"bounds":{"left":0.0,"top":0.23942538,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.2490024,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"2","depth":22,"bounds":{"left":0.009640957,"top":0.2601756,"width":0.0019946808,"height":0.008778931},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Claude Code","depth":19,"bounds":{"left":0.0,"top":0.27773345,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"Containers","depth":19,"bounds":{"left":0.0,"top":0.3160415,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXHeading","text":"EXPLORER","depth":17,"bounds":{"left":0.022606382,"top":0.047885075,"width":0.018949468,"height":0.02793296},"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"EXPLORER","depth":18,"bounds":{"left":0.022606382,"top":0.056664005,"width":0.018949468,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.022606382,"top":0.056664005,"width":0.0023271276,"height":0.0103751}},{"char_start":1,"char_count":7,"bounds":{"left":0.024933511,"top":0.056664005,"width":0.01662234,"height":0.0103751}}],"role_description":"text"},{"role":"AXButton","text":"Explorer Section: screenpipe [SSH: nas]","depth":21,"bounds":{"left":0.015957447,"top":0.07581804,"width":0.09940159,"height":0.017557861},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":true},{"role":"AXStaticText","text":"","depth":23,"bounds":{"left":0.01662234,"top":0.07821229,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"Explorer Section: screenpipe [SSH: nas]","depth":22,"bounds":{"left":0.022606382,"top":0.07581804,"width":0.045877658,"height":0.017557861},"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"SCREENPIPE [SSH: NAS]","depth":23,"bounds":{"left":0.022606382,"top":0.079010375,"width":0.045877658,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.022606382,"top":0.07980846,"width":0.0026595744,"height":0.0103751}},{"char_start":1,"char_count":20,"bounds":{"left":0.025265958,"top":0.07980846,"width":0.043218084,"height":0.0103751}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.09577015,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"#recycle","depth":27,"bounds":{"left":0.025930852,"top":0.09577015,"width":0.017287234,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.096568234,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":7,"bounds":{"left":0.028590426,"top":0.096568234,"width":0.01462766,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.11332801,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"app","depth":27,"bounds":{"left":0.025930852,"top":0.11332801,"width":0.0076462766,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.11412609,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":2,"bounds":{"left":0.02825798,"top":0.11412609,"width":0.005319149,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.11412609,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.022273935,"top":0.13088587,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"__pycache__","depth":27,"bounds":{"left":0.028590426,"top":0.13088587,"width":0.026595745,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.13168396,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":10,"bounds":{"left":0.030917553,"top":0.13168396,"width":0.024268618,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.022273935,"top":0.14844373,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"consumers","depth":27,"bounds":{"left":0.028590426,"top":0.14844373,"width":0.022273935,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.14924182,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":8,"bounds":{"left":0.030917553,"top":0.14924182,"width":0.019946808,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.14924182,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.022273935,"top":0.1660016,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"static","depth":27,"bounds":{"left":0.028590426,"top":0.1660016,"width":0.010970744,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.16679968,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":5,"bounds":{"left":0.030917553,"top":0.16679968,"width":0.008976064,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.16679968,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.1819633,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":".env","depth":27,"bounds":{"left":0.028590426,"top":0.18355946,"width":0.00831117,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.18435754,"width":0.0013297872,"height":0.011971269}},{"char_start":1,"char_count":3,"bounds":{"left":0.029920213,"top":0.18435754,"width":0.006981383,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.19952115,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"cli.py","depth":27,"bounds":{"left":0.028590426,"top":0.20111732,"width":0.010638298,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.2019154,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":5,"bounds":{"left":0.030917553,"top":0.2019154,"width":0.00831117,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.2019154,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.21707901,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.py","depth":27,"bounds":{"left":0.028590426,"top":0.21867518,"width":0.011303191,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.21947326,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":4,"bounds":{"left":0.03125,"top":0.21947326,"width":0.008643617,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.23463687,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"docker-compose.yml","depth":27,"bounds":{"left":0.028590426,"top":0.23623304,"width":0.042220745,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.23703113,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":17,"bounds":{"left":0.03125,"top":0.23703113,"width":0.03956117,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.25219473,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Dockerfile","depth":27,"bounds":{"left":0.028590426,"top":0.25379092,"width":0.020611702,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.254589,"width":0.0033244682,"height":0.011971269}},{"char_start":1,"char_count":9,"bounds":{"left":0.031914894,"top":0.254589,"width":0.017287234,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.254589,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.2697526,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"main.py","depth":27,"bounds":{"left":0.028590426,"top":0.27134877,"width":0.015625,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.27214685,"width":0.003656915,"height":0.011971269}},{"char_start":1,"char_count":6,"bounds":{"left":0.032247342,"top":0.27214685,"width":0.012300532,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.27214685,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.28731045,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"requirements.txt","depth":27,"bounds":{"left":0.028590426,"top":0.28890663,"width":0.032912236,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.2897047,"width":0.0016622341,"height":0.011971269}},{"char_start":1,"char_count":15,"bounds":{"left":0.03025266,"top":0.2897047,"width":0.03158245,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.2897047,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.3064645,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"data","depth":27,"bounds":{"left":0.025930852,"top":0.3064645,"width":0.008976064,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.30726257,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":3,"bounds":{"left":0.028590426,"top":0.30726257,"width":0.0063164895,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.32402235,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"logs","depth":27,"bounds":{"left":0.025930852,"top":0.32402235,"width":0.00831117,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.32482043,"width":0.0009973404,"height":0.011971269}},{"char_start":1,"char_count":3,"bounds":{"left":0.026928192,"top":0.32482043,"width":0.0076462766,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.32482043,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.3415802,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"pipes","depth":27,"bounds":{"left":0.025930852,"top":0.3415802,"width":0.010970744,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.3423783,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":4,"bounds":{"left":0.028590426,"top":0.3423783,"width":0.00831117,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.3575419,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":".gitignore","depth":27,"bounds":{"left":0.025930852,"top":0.35913807,"width":0.018949468,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.35993615,"width":0.0013297872,"height":0.011971269}},{"char_start":1,"char_count":9,"bounds":{"left":0.027260639,"top":0.35993615,"width":0.017952127,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.37509975,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"app_settings.json","depth":27,"bounds":{"left":0.025930852,"top":0.37669593,"width":0.03557181,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.377494,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":16,"bounds":{"left":0.02825798,"top":0.377494,"width":0.03324468,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.3926576,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"archive.db","depth":27,"bounds":{"left":0.025930852,"top":0.3942538,"width":0.020944148,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.39505187,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":9,"bounds":{"left":0.02825798,"top":0.39505187,"width":0.01861702,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.4102155,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"archive.db-bak","depth":27,"bounds":{"left":0.025930852,"top":0.41181165,"width":0.03025266,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.41260973,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":13,"bounds":{"left":0.02825798,"top":0.41260973,"width":0.027925532,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"U","depth":27,"bounds":{"left":0.10704787,"top":0.41260973,"width":0.0029920214,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.42777336,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite","depth":27,"bounds":{"left":0.025930852,"top":0.4293695,"width":0.017287234,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.4301676,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":8,"bounds":{"left":0.028590426,"top":0.4301676,"width":0.014960106,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.44533122,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite-shm","depth":27,"bounds":{"left":0.025930852,"top":0.44692737,"width":0.027925532,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.44772545,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":12,"bounds":{"left":0.028590426,"top":0.44772545,"width":0.025265958,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.46288908,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite-wal","depth":27,"bounds":{"left":0.025930852,"top":0.46448523,"width":0.025930852,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.46528333,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":12,"bounds":{"left":0.028590426,"top":0.46528333,"width":0.023603724,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.48044693,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe_sync_updated.sh","depth":27,"bounds":{"left":0.025930852,"top":0.4820431,"width":0.059175532,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.4828412,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":25,"bounds":{"left":0.02825798,"top":0.4828412,"width":0.056848403,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"U","depth":27,"bounds":{"left":0.10704787,"top":0.4828412,"width":0.0029920214,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.4980048,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe_sync.sh","depth":27,"bounds":{"left":0.025930852,"top":0.49960095,"width":0.039893616,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.50039905,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":17,"bounds":{"left":0.02825798,"top":0.50039905,"width":0.037898935,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.51556265,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe.db","depth":27,"bounds":{"left":0.025930852,"top":0.5171588,"width":0.028590426,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.5179569,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":12,"bounds":{"left":0.02825798,"top":0.5179569,"width":0.026595745,"height":0.011971269}}],"role_description":"text"},{"role":"AXButton","text":"Outline Section","depth":21,"bounds":{"left":0.015957447,"top":0.9473264,"width":0.09940159,"height":0.017557861},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
7155496756450960787
|
-5552318330326838912
|
click
|
accessibility
|
NULL
|
Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧ Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py
M
db.py
docker-compose.yml
Dockerfile
M
main.py
M
requirements.txt
M
data
logs
pipes
.gitignore
app_settings.json
archive.db
archive.db-bak
U
db.sqlite
db.sqlite-shm
db.sqlite-wal
screenpipe_sync_updated.sh
U
screenpipe_sync.sh
screenpipe.db
Outline Section...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
21081
|
923
|
1
|
2026-05-11T17:11:06.573326+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-11/1778 /Users/lukas/.screenpipe/data/data/2026-05-11/1778519466573_m2.jpg...
|
Code
|
screenpipe_sync.sh — screenpipe [SSH: nas]
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧ Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py
M
db.py
docker-compose.yml
Dockerfile
M
main.py
M
requirements.txt
M
data
logs
pipes
.gitignore
app_settings.json
archive.db
archive.db-bak
U
db.sqlite
db.sqlite-shm
db.sqlite-wal
screenpipe_sync_updated.sh
U
screenpipe_sync.sh
screenpipe.db
Outline Section
OUTLINE
OUTLINE
Timeline Section
TIMELINE
TIMELINE
app_settings.json, Editor Group 1
screenpipe_sync.sh, Editor Group 1
pipe.md, Editor Group 1
.env, Editor Group 1
screenpipe_sync.sh, Editor Group 1
Implement and run pipe l…, Editor Group 2
Problems (⇧⌘M)
PROBLEMS
Output (⇧⌘U)
OUTPUT
Debug Console (⇧⌘Y)
DEBUG CONSOLE
Terminal (⌃`)
TERMINAL
Ports - 1 forwarded port
PORTS
1
remote SSH: nas
SSH: nas
screenpipe (Git) - master*, Checkout Branch/Tag...
master*
screenpipe (Git) - Synchronize Changes
No Problems
0
0
Forwarded Ports: 8766
1
Notifications
Sign In
Sign In
Shell Script
Editor Language Status: $(copilot) No inline suggestion available, Inline suggestions
LF
UTF-8
Spaces: 2
Ln 30, Col 2
git-commit Lukas Kovalik (2 weeks ago)
Lukas Kovalik (2 weeks ago)
Info: Setting up SSH Host nas: Setting up SSH tunnel
Implement and run pipe logic
Session history
New session
Message actions
main.py
main.py
lets implement logic with pipes. how can I run it?
Thinking
Thinking
Let me look at the current project structure to understand what's already in place.
Bash
List project files
IN
find /volume1/screenpipe -type f | head -50 && echo "---" && ls /volume1/screenpipe
Copy code to clipboard
OUT
/volume1/screenpipe/.DS_Store
/volume1/screenpipe/screenpipe.db
/volume1/screenpipe/screenpipe_sync.sh
/volume1/screenpipe/app_settings.json
/volume1/screenpipe/.gitignore
/volume1/screenpipe/archive.db
/volume1/screenpipe/db.sqlite
/volume1/screenpipe/db.sqlite-wal
/volume1/screenpipe/db.sqlite-shm
/volume1/screenpipe/#recycle/desktop.ini
/volume1/screenpipe/#recycle/db.sqlite
/volume1/screenpipe/#recycle/Copy #1 of db.sqlite
/volume1/screenpipe/#recycle/.DS_Store
/volume1/screenpipe/#recycle/Copy #2 of db.sqlite
/volume1/screenpipe/#recycle/archive.db
/volume1/screenpipe/#recycle/Copy #1 of archive.db
/volume1/screenpipe/#recycle/Copy #2 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of archive.db
/volume1/screenpipe/#recycle/Copy #4 of archive.db
/volume1/screenpipe/#recycle/Copy #5 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of db.sqlite
/volume1/screenpipe/#recycle/Copy #4 of db.sqlite
/volume1/screenpipe/#recycle/Copy #6 of archive.db
/volume1/screenpipe/#recycle/test.txt
/volume1/screenpipe/#recycle/Copy #7 of archive.db
/volume1/screenpipe/#recycle/Copy #8 of archive.db
/volume1/screenpipe/#recycle/archive.db-journal
/volume1/screenpipe/#recycle/Copy #1 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #2 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #3 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #4 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #6 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #7 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of db.sqlite
/volume1/screenpipe/pipes/.DS_Store
/volume1/screenpipe/app/.env
/volume1/screenpipe/app/cli.py
/volume1/screenpipe/app/.DS_Store
/volume1/screenpipe/app/db.py
/volume1/screenpipe/app/docker-compose.yml
/volume1/screenpipe/app/main.py
/volume1/screenpipe/app/requirements.txt
/volume1/screenpipe/app/Dockerfile
/volume1/screenpipe/data/.DS_Store
/volume1/screenpipe/.git/description
/volume1/screenpipe/.git/HEAD
/volume1/screenpipe/.git/index
/volume1/screenpipe/.git/COMMIT_EDITMSG
/volume1/screenpipe/#recycle/data/.DS_Store
---
app
app_settings.json
archive.db
data
db.sqlite
db.sqlite-shm
db.sqlite-wal
pipes
#recycle
screenpipe.db
screenpipe_sync.sh
Read
main.py
main.py
Bash
Check pipes directory and docker-compose
IN
ls /volume1/screenpipe/pipes/ && ls /volume1/screenpipe/app/ && cat /volume1/screenpipe/app/docker-compose.yml
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
cli.py
consumers
db.py
docker-compose.yml
Dockerfile
main.py
__pycache__
requirements.txt
static
services:
screenpipe-app:
build: .
container_name: screenpipe-app
restart: unless-stopped
ports:
- "8766:8000"
volumes:
- /volume1/screenpipe:/data
env_file:
- .env
environment:
TZ: Europe/Sofia
DB_PATH: /data/db.sqlite
sqlite-web-archive:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-archive
restart: unless-stopped
ports:
- "8767:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/archive.db"]
sqlite-web-live:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-live
restart: unless-stopped
ports:
- "8768:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/db.sqlite"]
Read
requirements.txt
requirements.txt
Bash
Inspect a pipe directory
IN
ls /volume1/screenpipe/pipes/day-recap/ && cat /volume1/screenpipe/pipes/day-recap/pipe.json 2>/dev/null || ls /volume1/screenpipe/pipes/day-recap/
Copy code to clipboard
OUT
pipe.md
pipe.md
Read
cli.py
cli.py
Bash
List all pipes and their contents
IN
ls /volume1/screenpipe/pipes/ && for d in /volume1/screenpipe/pipes/*/; do echo "=== $d ==="; ls "$d"; done
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
=== /volume1/screenpipe/pipes/ai-habits/ ===
pipe.md
=== /volume1/screenpipe/pipes/day-recap/ ===
pipe.md
=== /volume1/screenpipe/pipes/meeting-summary/ ===
pipe.md
=== /volume1/screenpipe/pipes/standup-update/ ===
pipe.md
=== /volume1/screenpipe/pipes/time-breakdown/ ===
pipe.md
=== /volume1/screenpipe/pipes/video-export/ ===
pipe.md
Bash
Read pipe markdown files
IN
cat /volume1/screenpipe/pipes/day-recap/pipe.md && echo "===" && cat /volume1/screenpipe/pipes/meeting-summary/pipe.md 2>/dev/null | head -50
Copy code to clipboard
OUT
---
schedule: manual
enabled: true
template: true
title: Day Recap
description: "Today's accomplishments, key moments, and unfinished work"
icon: "📋"
featured: true
---
Analyze my screen and audio recordings from today (last 16 hours only).
Read screenpipe skill first.
Use this exact format:
## Summary
One sentence: what I mainly did today.
## Accomplishments
- Top 3 things I finished, with timestamps (e.g. "2:30 PM")
- Name specific apps, files, or projects
## Key Moments
- Important things I saw, said, or heard — with timestamps
## Unfinished Work
- What I should continue tomorrow — name the app/file/task
## Patterns
- Apps I used most, topics that came up repeatedly
Only report what you can verify from the data. End with: "**Next step:** [most important thing to continue]"
===
---
schedule: manual
enabled: true
template: true
title: Meeting Summary
description: "Summarize meeting transcript with key takeaways and action items"
icon: "🤝"
featured: false
---
Summarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.
Read screenpipe skill first.
Use this exact format:
## Meeting Summary
One sentence: what this meeting was about.
## Key Takeaways
- Top 3-5 important points discussed
- Include who said what when relevant
## Action Items
- [ ] Task — assigned to whom, deadline if mentioned
- [ ] Task — assigned to whom
## Decisions Made
- List any decisions or agreements reached
## Open Questions
- Anything unresolved or needing follow-up
Keep it concise and actionable.
Thinking
Thinking
Bash
Read summary consumer
IN
ls /volume1/screenpipe/app/consumers/ && cat /volume1/screenpipe/app/consumers/summary.py
Copy code to clipboard
OUT
activity.py
audio.py
elements.py
__init__.py
interactions.py
ocr.py
__pycache__
report.py
summary.py
"""AI summary generator using Claude."""
import os
from datetime import date
from typing import Any
from consumers.activity import app_time, summary_stats, browser_urls, ui_event_summary
from consumers.ocr import deduplicated_text
from consumers.audio import formatted_transcript
SUMMARY_TYPES = {
"day_recap": {
"title": "Day Recap",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
## Audio/speech:
{audio}
Write a concise day recap using EXACTLY this format:
## Summary
One sentence: what I mainly worked on today.
## Accomplishments
- Top 3 things I finished, with approximate times
- Name specific apps, files, or projects
## Key Moments
- Important things seen or heard, with timestamps
## Unfinished Work
- What to continue tomorrow
## Patterns
- Apps used most, topics that came up repeatedly
Only report what you can verify from the data. End with:
**Next step:** [most important thing to continue]""",
},
"standup": {
"title": "Standup Update",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
## Audio/speech:
{audio}
Write a brief standup update:
**Yesterday:** What I worked on (2-3 bullets)
**Today:** What I plan to continue (1-2 bullets)
**Blockers:** Any issues observed (or "None")
Keep it under 150 words. Only report what's verifiable from the data.""",
},
"focus_time": {
"title": "Focus & Distraction Analysis",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
Analyze focus vs distraction patterns:
## Deep Work Periods
- When and how long were sustained focus sessions?
- What was being worked on?
## Distractions
- Which apps/sites were used recreationally?
- How much time was lost to context switching?
## Recommendations
- 2-3 concrete suggestions to improve focus tomorrow
Be specific with times and app names.""",
},
}
def _build_context(for_date: date) -> dict[str, str]:
apps = app_time(for_date)
app_lines = "\n".join(f"- {a['app_name']}: {a['minutes']} min" for a in apps[:20])
urls = browser_urls(for_date, limit=20)
url_lines = "\n".join(
f"- {u['browser_url'][:100]} ({u['minutes']} min)" for u in urls
)
ui_rows = ui_event_summary(for_date)
ui_lines = "\n".join(
f"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches"
for r in ui_rows[:15]
)
ocr_rows = deduplicated_text(for_date, chunk_minutes=5)
ocr_lines = "\n".join(
f"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}"
for r in ocr_rows[:100]
)
audio = formatted_transcript(for_date)
return {
"app_time": app_lines or "(no app data)",
"browser_urls": url_lines or "(no browser data)",
"ui_events": ui_lines or "(no UI event data)",
"ocr_text": ocr_lines or "(no screen data)",
"audio": audio[:3000] if len(audio) > 3000 else audio,
}
def generate(
summary_type: str = "day_recap",
for_date: date | None = None,
api_key: str | None = None,
) -> dict[str, Any]:
"""Generate an AI summary. Returns dict with 'title', 'content', 'date'."""
import anthropic
d = for_date or date.today()
key = api_key or os.environ.get("ANTHROPIC_API_KEY", "")
if not key:
return {
"title": "Error",
"content": "ANTHROPIC_API_KEY not set. Add it to your .env file.",
"date": str(d),
}
spec = SUMMARY_TYPES.get(summary_type)
if not spec:
return {"title": "Error", "content": f"Unknown summary type: {summary_type}", "date": str(d)}
stats = summary_stats(d)
if stats["total_frames"] == 0:
return {
"title": spec["title"],
"content": f"No screen data found for {d}.",
"date": str(d),
}
ctx = _build_context(d)
prompt = spec["prompt"].format(**ctx)
client = anthropic.Anthropic(api_key=key)
message = client.messages.create(
model="claude-haiku-4-5-20251001",
max_tokens=1024,
messages=[{"role": "user", "content": prompt}],
)
return {
"title": spec["title"],
"content": message.content[0].text,
"date": str(d),
"stats": stats,
}
Thinking
Thinking
Bash
Read all pipe.md files
IN
for f in /volume1/screenpipe/pipes/*/pipe.md; do echo "=== $f ==="; cat "$f"; echo; done
Copy code to clipboard
OUT
=== /volume1/screenpipe/pipes/ai-habits/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: AI Habits
description: "How you use AI tools — patterns and insights"
icon: "🤖"
featured: true
---
Search my recordings from the last 24 hours for AI tool usage. Use app_name filter for each tool separately: ChatGPT, Claude, Copilot, Cursor, Gemini, Perplexity. Use limit=5 per search, max 6 searches total.
Read screenpipe skill first.
Use this exact format:
## AI Tools Used
- List each tool with approximate time spent (e.g. "Claude: ~45min")
## What I Used Them For
- For each tool: coding, writing, research, or brainstorming
## Usage Patterns
- Do I switch between tools? Use them in bursts or steadily?
## Effectiveness
- Which tool appeared alongside completed work vs. abandoned attempts
If no AI usage is found, say so clearly. End with: "**Tip:** [one suggestion to use AI tools more effectively]"
=== /volume1/screenpipe/pipes/day-recap/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Day Recap
description: "Today's accomplishments, key moments, and unfinished work"
icon: "📋"
featured: true
---
Analyze my screen and audio recordings from today (last 16 hours only).
Read screenpipe skill first.
Use this exact format:
## Summary
One sentence: what I mainly did today.
## Accomplishments
- Top 3 things I finished, with timestamps (e.g. "2:30 PM")
- Name specific apps, files, or projects
## Key Moments
- Important things I saw, said, or heard — with timestamps
## Unfinished Work
- What I should continue tomorrow — name the app/file/task
## Patterns
- Apps I used most, topics that came up repeatedly
Only report what you can verify from the data. End with: "**Next step:** [most important thing to continue]"
=== /volume1/screenpipe/pipes/meeting-summary/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Meeting Summary
description: "Summarize meeting transcript with key takeaways and action items"
icon: "🤝"
featured: false
---
Summarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.
Read screenpipe skill first.
Use this exact format:
## Meeting Summary
One sentence: what this meeting was about.
## Key Takeaways
- Top 3-5 important points discussed
- Include who said what when relevant
## Action Items
- [ ] Task — assigned to whom, deadline if mentioned
- [ ] Task — assigned to whom
## Decisions Made
- List any decisions or agreements reached
## Open Questions
- Anything unresolved or needing follow-up
Keep it concise and actionable.
=== /volume1/screenpipe/pipes/standup-update/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Standup Update
description: "What you did, what's next, and any blockers"
icon: "🏢"
featured: true
---
Based on my recordings from the last 24 hours, generate a standup update. Use limit=10 per search, max 3 searches total.
Read screenpipe skill first.
Use this exact format:
## Yesterday
- What I worked on (name specific projects, files, tools, PRs)
## Today
- What I will work on next (based on unfinished tasks and recent activity)
## Blockers
- Issues I hit — errors, slow builds, waiting on someone
- If no blockers, write "None"
Keep it under 150 words. Copy-paste ready for a team standup.
=== /volume1/screenpipe/pipes/time-breakdown/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Time Breakdown
description: "Where your time went — by app, project, and category"
icon: "⏱"
featured: false
---
Analyze my app usage from today (last 12 hours). Use limit=10 per search, max 4 searches. Prefer /raw_sql with COUNT/GROUP BY queries.
Read screenpipe skill first.
Use this exact format with durations and percentages:
## By Application
- List each app with duration and percentage, sorted by time (e.g. "VS Code: 2h 15min (28%)")
## By Category
- Group into: coding, meetings, browsing, writing, communication, other
- Show hours and percentage per category
## By Project
- Group related activities by project/topic. Name specific repos or tasks.
## Productivity Score
- Calculate: focused_work_hours / total_hours as a percentage
- Focused = coding + writing. Unfocused = browsing + switching.
End with: "**Suggestion:** [one specific change to improve tomorrow's productivity]"
=== /volume1/screenpipe/pipes/video-export/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Export Video Clip
description: "Create a video of your recent screen activity"
icon: "🎬"
featured: false
---
Export a video of my screen activity from the last 5 minutes.
Read screenpipe skill first.
Use the POST /frames/export endpoint with the time range and fps=1.0. Then show me the exported video file path as an inline code block so I can watch it.
If the export is large, suggest a lower fps or shorter time range.
Thinking
Thinking
Now I have a clear picture. The pipes are markdown prompt templates in
/volume1/screenpipe/pipes/
, but there's no code to actually load and run them —
consumers/summary.py
has its own hardcoded prompts instead.
Here's what I'll implement:
consumers/pipes.py
— dynamically loads pipe.md files and runs them via Claude (data injected as system message, pipe body as user prompt)
main.py
— two new endpoints:
GET /api/pipes
and
POST /api/pipes/{pipe_id}/run
cli.py
— a
pipe
command to run pipes from the terminal
Let me build it:
Bash
Check browser_urls signature
IN
cat /volume1/screenpipe/app/consumers/activity.py | grep "def browser_urls" -A 5
Copy code to clipboard
OUT
def browser_urls(
for_date: date | None = None,
app_name: str | None = None,
ts_from: str | None = None,
ts_to: str | None = None,
limit: int = 30,
Write
pipes.py
pipes.py
143 lines
"""Dynamic pipe loader and runner."""
import os
import re
from datetime import date
from pathlib import Path
from typing import Any
def _parse_frontmatter(text: str) -> tuple[dict, str]:
if not text.startswith("---"):
return {}, text
try:
end = text.index("---", 3)
except ValueError:
return {}, text
fm_text = text[3:end].strip()
body = text[end + 3:].strip()
meta: dict = {}
for line in fm_text.splitlines():
if ":" in line:
k, _, v = line.partition(":")
meta[k.strip()] = v.strip().strip('"')
return meta, body
def load_pipes(pipes_dir: Path) -> list[dict]:
if not pipes_dir.exists():
return []
pipes = []
for pipe_dir in sorted(pipes_dir.iterdir()):
if not pipe_dir.is_dir() or pipe_dir.name.startswith("."):
continue
pipe_md = pipe_dir / "pipe.md"
if not pipe_md.exists():
continue
text = pipe_md.read_text(encoding="utf-8")
meta, body = _parse_frontmatter(text)
if meta.get("enabled", "true").lower() == "false":
continue
body = re.sub(r"Read screenpipe skill first\.?\n?", "", body).strip()
pipes.append({
"id": pipe_dir.name,
"title": meta.get("title", pipe_dir.name),
"description": meta.get("description", ""),
"icon": meta.get("icon", ""),
"schedule": meta.get("schedule", "manual"),
"featured": meta.get("featured", "false").lower() == "true",
"prompt": body,
})
return pipes
def _build_system(d: date, stats: dict) -> str:
from consumers.activity import app_time, browser_urls, ui_event_summary
from consumers.ocr import deduplicated_text
from consumers.audio import formatted_transcript
apps = app_time(d)
app_lines = "\n".join(f"- {a['app_name']}: {a['minutes']} min" for a in apps[:20])
urls = browser_urls(d, limit=20)
url_lines = "\n".join(f"- {u['browser_url'][:100]} ({u['minutes']} min)" for u in urls)
ui_rows = ui_event_summary(d)
ui_lines = "\n".join(
f"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches"
for r in ui_rows[:15]
)
ocr_rows = deduplicated_text(d, chunk_minutes=5)
ocr_lines = "\n".join(
f"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}"
for r in ocr_rows[:100]
)
audio = formatted_transcript(d)
if len(audio) > 3000:
audio = audio[:3000]
return f"""You are analyzing screenpipe data — recordings of a person's computer activity.
## App usage (minutes per app):
{app_lines or '(no app data)'}
## Browser URLs visited:
{url_lines or '(no browser data)'}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_lines or '(no UI event data)'}
## Screen content (sampled every 5 minutes):
{ocr_lines or '(no screen data)'}
## Audio / speech:
{audio or '(no audio data)'}
Date: {d}
Total frames recorded: {stats['total_frames']}"""
def run_pipe(
pipe_id: str,
for_date: date | None = None,
api_key: str | None = None,
pipes_dir: Path | None = None,
) -> dict[str, Any]:
import anthropic
from consumers.activity import summary_stats
d = for_date or date.today()
key = api_key or os.environ.get("ANTHROPIC_API_KEY", "")
if not key:
return {"title": "Error", "content": "ANTHROPIC_API_KEY not set.", "date": str(d)}
_pipes_dir = pipes_dir or Path(os.environ.get("PIPES_DIR", "/data/pipes"))
all_pipes = {p["id"]: p for p in load_pipes(_pipes_dir)}
if pipe_id not in all_pipes:
return {"title": "Error", "content": f"Pipe not found: {pipe_id}", "date": str(d)}
pipe = all_pipes[pipe_id]
stats = summary_stats(d)
if stats["total_frames"] == 0:
return {"title": pipe["title"], "content": f"No screen data found for {d}.", "date": str(d)}
system = _build_system(d, stats)
client = anthropic.Anthropic(api_key=key)
message = client.messages.create(
model="claude-haiku-4-5-20251001",
max_tokens=1024,
system=system,
messages=[{"role": "user", "content": pipe["prompt"]}],
)
return {
"title": pipe["title"],
"content": message.content[0].text,
"date": str(d),
"stats": stats,
}
Now add the API endpoints to
main.py
:
Edit
main.py
main.py
Added 1 line
Edit
main.py
main.py
Added 1 line
Now add the pipe endpoints at the end of main.py, before the closing summary section:
Edit
main.py
main.py
Added 14 lines
Now add the CLI command to
cli.py
cli.py
:
Edit
cli.py
cli.py
Added 40 lines
Done. Here's how to run pipes:
How to run pipes
How to run pipes
Via Docker (inside the running container):
Copy code to clipboard
docker exec -it screenpipe-app python cli.py pipe --list
docker exec -it screenpipe-app python cli.py pipe day-recap
docker exec -it screenpipe-app python cli.py pipe standup-update --date yesterday
Via the API
(once the container is running on port 8766):
Copy code to clipboard
# List pipes
curl http://localhost:8766/api/pipes
# Run a pipe
curl -X POST "http://localhost:8766/api/pipes/day-recap/run"
curl -X POST "http://localhost:8766/api/pipes/standup-update/run?d=2026-04-25"
Rebuild and restart
to pick up the changes:
Copy code to clipboard
cd /volume1/screenpipe/app
docker compose up --build -d
How it works:
Each
pipe.md
file is loaded dynamically — the frontmatter provides metadata and the body becomes the user prompt. Screenpipe data (app usage, browser URLs, OCR, audio) is injected as a Claude system message so the pipe prompt can reference it naturally. The "Read screenpipe skill first" line is stripped automatically.
The pipes directory inside Docker is
/data/pipes
(since
/volume1/screenpipe
→
/data
). You can override it with a
PIPES_DIR
env var if needed.
Message actions
pipe.md
pipe.md
where to place api key and can I use different keys
Thinking
Thinking
Bash
Read .env file
IN
cat /volume1/screenpipe/app/.env
Copy code to clipboard
OUT
[ENV_SECRET]...
|
[{"role":"AXRadioButton","text [{"role":"AXRadioButton","text":"Explorer (⇧⌘E)","depth":19,"bounds":{"left":0.0,"top":0.047885075,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":true},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.057462092,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Search (⇧⌘F)","depth":19,"bounds":{"left":0.0,"top":0.08619314,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.09577015,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Source Control (⌃⇧G) - 10 pending changes","depth":19,"bounds":{"left":0.0,"top":0.1245012,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.13407822,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"10","depth":22,"bounds":{"left":0.00831117,"top":0.1452514,"width":0.003656915,"height":0.008778931},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.00831117,"top":0.14604948,"width":0.0016622341,"height":0.007980846}},{"char_start":1,"char_count":1,"bounds":{"left":0.009973404,"top":0.14604948,"width":0.0023271276,"height":0.007980846}}],"role_description":"text"},{"role":"AXRadioButton","text":"Run and Debug (⇧⌘D)","depth":19,"bounds":{"left":0.0,"top":0.16280925,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.17238627,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Remote Explorer","depth":19,"bounds":{"left":0.0,"top":0.20111732,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.21069433,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Extensions (⇧⌘X) - 2 require update","depth":19,"bounds":{"left":0.0,"top":0.23942538,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.2490024,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"2","depth":22,"bounds":{"left":0.009640957,"top":0.2601756,"width":0.0019946808,"height":0.008778931},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Claude Code","depth":19,"bounds":{"left":0.0,"top":0.27773345,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"Containers","depth":19,"bounds":{"left":0.0,"top":0.3160415,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXHeading","text":"EXPLORER","depth":17,"bounds":{"left":0.022606382,"top":0.047885075,"width":0.018949468,"height":0.02793296},"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"EXPLORER","depth":18,"bounds":{"left":0.022606382,"top":0.056664005,"width":0.018949468,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.022606382,"top":0.056664005,"width":0.0023271276,"height":0.0103751}},{"char_start":1,"char_count":7,"bounds":{"left":0.024933511,"top":0.056664005,"width":0.01662234,"height":0.0103751}}],"role_description":"text"},{"role":"AXButton","text":"Explorer Section: screenpipe [SSH: nas]","depth":21,"bounds":{"left":0.015957447,"top":0.07581804,"width":0.09940159,"height":0.017557861},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":true},{"role":"AXStaticText","text":"","depth":23,"bounds":{"left":0.01662234,"top":0.07821229,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"Explorer Section: screenpipe [SSH: nas]","depth":22,"bounds":{"left":0.022606382,"top":0.07581804,"width":0.045877658,"height":0.017557861},"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"SCREENPIPE [SSH: NAS]","depth":23,"bounds":{"left":0.022606382,"top":0.079010375,"width":0.045877658,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.022606382,"top":0.07980846,"width":0.0026595744,"height":0.0103751}},{"char_start":1,"char_count":20,"bounds":{"left":0.025265958,"top":0.07980846,"width":0.043218084,"height":0.0103751}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.09577015,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"#recycle","depth":27,"bounds":{"left":0.025930852,"top":0.09577015,"width":0.017287234,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.096568234,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":7,"bounds":{"left":0.028590426,"top":0.096568234,"width":0.01462766,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.11332801,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"app","depth":27,"bounds":{"left":0.025930852,"top":0.11332801,"width":0.0076462766,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.11412609,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":2,"bounds":{"left":0.02825798,"top":0.11412609,"width":0.005319149,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.11412609,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.022273935,"top":0.13088587,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"__pycache__","depth":27,"bounds":{"left":0.028590426,"top":0.13088587,"width":0.026595745,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.13168396,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":10,"bounds":{"left":0.030917553,"top":0.13168396,"width":0.024268618,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.022273935,"top":0.14844373,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"consumers","depth":27,"bounds":{"left":0.028590426,"top":0.14844373,"width":0.022273935,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.14924182,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":8,"bounds":{"left":0.030917553,"top":0.14924182,"width":0.019946808,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.14924182,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.022273935,"top":0.1660016,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"static","depth":27,"bounds":{"left":0.028590426,"top":0.1660016,"width":0.010970744,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.16679968,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":5,"bounds":{"left":0.030917553,"top":0.16679968,"width":0.008976064,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.16679968,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.1819633,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":".env","depth":27,"bounds":{"left":0.028590426,"top":0.18355946,"width":0.00831117,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.18435754,"width":0.0013297872,"height":0.011971269}},{"char_start":1,"char_count":3,"bounds":{"left":0.029920213,"top":0.18435754,"width":0.006981383,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.19952115,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"cli.py","depth":27,"bounds":{"left":0.028590426,"top":0.20111732,"width":0.010638298,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.2019154,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":5,"bounds":{"left":0.030917553,"top":0.2019154,"width":0.00831117,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.2019154,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.21707901,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.py","depth":27,"bounds":{"left":0.028590426,"top":0.21867518,"width":0.011303191,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.21947326,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":4,"bounds":{"left":0.03125,"top":0.21947326,"width":0.008643617,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.23463687,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"docker-compose.yml","depth":27,"bounds":{"left":0.028590426,"top":0.23623304,"width":0.042220745,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.23703113,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":17,"bounds":{"left":0.03125,"top":0.23703113,"width":0.03956117,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.25219473,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Dockerfile","depth":27,"bounds":{"left":0.028590426,"top":0.25379092,"width":0.020611702,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.254589,"width":0.0033244682,"height":0.011971269}},{"char_start":1,"char_count":9,"bounds":{"left":0.031914894,"top":0.254589,"width":0.017287234,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.254589,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.2697526,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"main.py","depth":27,"bounds":{"left":0.028590426,"top":0.27134877,"width":0.015625,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.27214685,"width":0.003656915,"height":0.011971269}},{"char_start":1,"char_count":6,"bounds":{"left":0.032247342,"top":0.27214685,"width":0.012300532,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.27214685,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.28731045,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"requirements.txt","depth":27,"bounds":{"left":0.028590426,"top":0.28890663,"width":0.032912236,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.2897047,"width":0.0016622341,"height":0.011971269}},{"char_start":1,"char_count":15,"bounds":{"left":0.03025266,"top":0.2897047,"width":0.03158245,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.2897047,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.3064645,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"data","depth":27,"bounds":{"left":0.025930852,"top":0.3064645,"width":0.008976064,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.30726257,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":3,"bounds":{"left":0.028590426,"top":0.30726257,"width":0.0063164895,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.32402235,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"logs","depth":27,"bounds":{"left":0.025930852,"top":0.32402235,"width":0.00831117,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.32482043,"width":0.0009973404,"height":0.011971269}},{"char_start":1,"char_count":3,"bounds":{"left":0.026928192,"top":0.32482043,"width":0.0076462766,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.32482043,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.3415802,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"pipes","depth":27,"bounds":{"left":0.025930852,"top":0.3415802,"width":0.010970744,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.3423783,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":4,"bounds":{"left":0.028590426,"top":0.3423783,"width":0.00831117,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.3575419,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":".gitignore","depth":27,"bounds":{"left":0.025930852,"top":0.35913807,"width":0.018949468,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.35993615,"width":0.0013297872,"height":0.011971269}},{"char_start":1,"char_count":9,"bounds":{"left":0.027260639,"top":0.35993615,"width":0.017952127,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.37509975,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"app_settings.json","depth":27,"bounds":{"left":0.025930852,"top":0.37669593,"width":0.03557181,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.377494,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":16,"bounds":{"left":0.02825798,"top":0.377494,"width":0.03324468,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.3926576,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"archive.db","depth":27,"bounds":{"left":0.025930852,"top":0.3942538,"width":0.020944148,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.39505187,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":9,"bounds":{"left":0.02825798,"top":0.39505187,"width":0.01861702,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.4102155,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"archive.db-bak","depth":27,"bounds":{"left":0.025930852,"top":0.41181165,"width":0.03025266,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.41260973,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":13,"bounds":{"left":0.02825798,"top":0.41260973,"width":0.027925532,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"U","depth":27,"bounds":{"left":0.10704787,"top":0.41260973,"width":0.0029920214,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.42777336,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite","depth":27,"bounds":{"left":0.025930852,"top":0.4293695,"width":0.017287234,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.4301676,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":8,"bounds":{"left":0.028590426,"top":0.4301676,"width":0.014960106,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.44533122,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite-shm","depth":27,"bounds":{"left":0.025930852,"top":0.44692737,"width":0.027925532,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.44772545,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":12,"bounds":{"left":0.028590426,"top":0.44772545,"width":0.025265958,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.46288908,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite-wal","depth":27,"bounds":{"left":0.025930852,"top":0.46448523,"width":0.025930852,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.46528333,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":12,"bounds":{"left":0.028590426,"top":0.46528333,"width":0.023603724,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.48044693,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe_sync_updated.sh","depth":27,"bounds":{"left":0.025930852,"top":0.4820431,"width":0.059175532,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.4828412,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":25,"bounds":{"left":0.02825798,"top":0.4828412,"width":0.056848403,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"U","depth":27,"bounds":{"left":0.10704787,"top":0.4828412,"width":0.0029920214,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.4980048,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe_sync.sh","depth":27,"bounds":{"left":0.025930852,"top":0.49960095,"width":0.039893616,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.50039905,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":17,"bounds":{"left":0.02825798,"top":0.50039905,"width":0.037898935,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.51556265,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe.db","depth":27,"bounds":{"left":0.025930852,"top":0.5171588,"width":0.028590426,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.5179569,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":12,"bounds":{"left":0.02825798,"top":0.5179569,"width":0.026595745,"height":0.011971269}}],"role_description":"text"},{"role":"AXButton","text":"Outline Section","depth":21,"bounds":{"left":0.015957447,"top":0.9473264,"width":0.09940159,"height":0.017557861},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":23,"bounds":{"left":0.01662234,"top":0.9497207,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"OUTLINE","depth":22,"bounds":{"left":0.022606382,"top":0.9473264,"width":0.01662234,"height":0.017557861},"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"OUTLINE","depth":23,"bounds":{"left":0.022606382,"top":0.95131683,"width":0.01662234,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.022606382,"top":0.95131683,"width":0.0029920214,"height":0.0103751}},{"char_start":1,"char_count":6,"bounds":{"left":0.025598405,"top":0.95131683,"width":0.013630319,"height":0.0103751}}],"role_description":"text"},{"role":"AXButton","text":"Timeline Section","depth":21,"bounds":{"left":0.015957447,"top":0.9648843,"width":0.09940159,"height":0.017557861},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":23,"bounds":{"left":0.01662234,"top":0.96727854,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"TIMELINE","depth":22,"bounds":{"left":0.022606382,"top":0.9648843,"width":0.01761968,"height":0.017557861},"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"TIMELINE","depth":23,"bounds":{"left":0.022606382,"top":0.9688747,"width":0.01761968,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.022606382,"top":0.9688747,"width":0.0026595744,"height":0.0103751}},{"char_start":1,"char_count":7,"bounds":{"left":0.025265958,"top":0.9688747,"width":0.015292553,"height":0.0103751}}],"role_description":"text"},{"role":"AXRadioButton","text":"app_settings.json, Editor Group 1","depth":28,"bounds":{"left":0.11569149,"top":0.047885075,"width":0.055851065,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"screenpipe_sync.sh, Editor Group 1","depth":28,"bounds":{"left":0.17154256,"top":0.047885075,"width":0.06050532,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":false},{"role":"AXRadioButton","text":"pipe.md, Editor Group 1","depth":28,"bounds":{"left":0.23171543,"top":0.047885075,"width":0.040226065,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":".env, Editor Group 1","depth":28,"bounds":{"left":0.27194148,"top":0.047885075,"width":0.039893616,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"screenpipe_sync.sh, Editor Group 1","depth":28,"on_screen":false,"role_description":"editor","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"Implement and run pipe l…, Editor Group 2","depth":28,"bounds":{"left":0.5578458,"top":0.047885075,"width":0.073803194,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":false},{"role":"AXRadioButton","text":"Problems (⇧⌘M)","depth":22,"bounds":{"left":0.118351065,"top":0.7278532,"width":0.027925532,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"PROBLEMS","depth":24,"bounds":{"left":0.122340426,"top":0.7366321,"width":0.019946808,"height":0.0103751},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Output (⇧⌘U)","depth":22,"bounds":{"left":0.14594415,"top":0.7278532,"width":0.023603724,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUTPUT","depth":24,"bounds":{"left":0.14993352,"top":0.7366321,"width":0.015625,"height":0.0103751},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Debug Console (⇧⌘Y)","depth":22,"bounds":{"left":0.16921543,"top":0.7278532,"width":0.039893616,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"DEBUG CONSOLE","depth":24,"bounds":{"left":0.1732048,"top":0.7366321,"width":0.031914894,"height":0.0103751},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Terminal (⌃`)","depth":22,"bounds":{"left":0.2087766,"top":0.7278532,"width":0.026595745,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":true},{"role":"AXStaticText","text":"TERMINAL","depth":24,"bounds":{"left":0.21276596,"top":0.7366321,"width":0.01861702,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.2130984,"top":0.73743016,"width":0.0023271276,"height":0.0103751}},{"char_start":1,"char_count":7,"bounds":{"left":0.21542554,"top":0.73743016,"width":0.016289894,"height":0.0103751}}],"role_description":"text"},{"role":"AXRadioButton","text":"Ports - 1 forwarded port","depth":22,"bounds":{"left":0.23537233,"top":0.7278532,"width":0.026263298,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"PORTS","depth":24,"bounds":{"left":0.2393617,"top":0.7366321,"width":0.012300532,"height":0.0103751},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":25,"bounds":{"left":0.25465426,"top":0.73743016,"width":0.0019946808,"height":0.008778931},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"remote SSH: nas","depth":16,"bounds":{"left":0.0006648936,"top":0.98244214,"width":0.028590426,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.0033244682,"top":0.9848364,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"SSH: nas","depth":17,"bounds":{"left":0.008643617,"top":0.9856345,"width":0.017952127,"height":0.011173184},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.008643617,"top":0.9856345,"width":0.0013297872,"height":0.011173184}},{"char_start":1,"char_count":7,"bounds":{"left":0.009973404,"top":0.9856345,"width":0.01462766,"height":0.011173184}}],"role_description":"text"},{"role":"AXButton","text":"screenpipe (Git) - master*, Checkout Branch/Tag...","depth":16,"bounds":{"left":0.030917553,"top":0.98244214,"width":0.023271276,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.031914894,"top":0.9848364,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"master*","depth":17,"bounds":{"left":0.03723404,"top":0.9856345,"width":0.015957447,"height":0.011173184},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.03723404,"top":0.9856345,"width":0.0013297872,"height":0.011173184}},{"char_start":1,"char_count":6,"bounds":{"left":0.03856383,"top":0.9856345,"width":0.012965426,"height":0.011173184}}],"role_description":"text"},{"role":"AXButton","text":"screenpipe (Git) - Synchronize Changes","depth":16,"bounds":{"left":0.05418883,"top":0.98244214,"width":0.00731383,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"No Problems","depth":16,"bounds":{"left":0.06416223,"top":0.98244214,"width":0.022606382,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.06582447,"top":0.9848364,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"0","depth":17,"bounds":{"left":0.07114362,"top":0.9856345,"width":0.004986702,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.07579787,"top":0.9848364,"width":0.0056515955,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"0","depth":17,"bounds":{"left":0.08111702,"top":0.9856345,"width":0.0039893617,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Forwarded Ports: 8766","depth":16,"bounds":{"left":0.08843085,"top":0.98244214,"width":0.012632979,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.09009308,"top":0.9848364,"width":0.0056515955,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":17,"bounds":{"left":0.09541223,"top":0.9856345,"width":0.0039893617,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Notifications","depth":16,"bounds":{"left":0.9886968,"top":0.98244214,"width":0.010638298,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sign In","depth":16,"bounds":{"left":0.9650931,"top":0.98244214,"width":0.022606382,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.96675533,"top":0.9848364,"width":0.0056515955,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Sign In","depth":17,"bounds":{"left":0.97207445,"top":0.9856345,"width":0.013962766,"height":0.011173184},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.97207445,"top":0.9856345,"width":0.0013297872,"height":0.011173184}},{"char_start":1,"char_count":6,"bounds":{"left":0.9734042,"top":0.9856345,"width":0.010638298,"height":0.011173184}}],"role_description":"text"},{"role":"AXButton","text":"Shell Script","depth":16,"bounds":{"left":0.93916225,"top":0.98244214,"width":0.023603724,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Editor Language Status: $(copilot) No inline suggestion available, Inline suggestions","depth":16,"bounds":{"left":0.9318484,"top":0.98244214,"width":0.00731383,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"LF","depth":16,"bounds":{"left":0.9212101,"top":0.98244214,"width":0.007978723,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"UTF-8","depth":16,"bounds":{"left":0.90359044,"top":0.98244214,"width":0.015625,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Spaces: 2","depth":16,"bounds":{"left":0.8796542,"top":0.98244214,"width":0.022273935,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Ln 30, Col 2","depth":16,"bounds":{"left":0.85139626,"top":0.98244214,"width":0.026595745,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"git-commit Lukas Kovalik (2 weeks ago)","depth":16,"bounds":{"left":0.7869016,"top":0.98244214,"width":0.062832445,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.78856385,"top":0.9848364,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Lukas Kovalik (2 weeks ago)","depth":17,"bounds":{"left":0.79388297,"top":0.9856345,"width":0.05418883,"height":0.011173184},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.79388297,"top":0.9856345,"width":0.0013297872,"height":0.011173184}},{"char_start":1,"char_count":26,"bounds":{"left":0.79488033,"top":0.9856345,"width":0.051529255,"height":0.011173184}}],"role_description":"text"},{"role":"AXStaticText","text":"Info: Setting up SSH Host nas: Setting up SSH tunnel","depth":12,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Implement and run pipe logic","depth":19,"bounds":{"left":0.56017286,"top":0.08060654,"width":0.07114362,"height":0.022346368},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Session history","depth":19,"bounds":{"left":0.9780585,"top":0.08060654,"width":0.00930851,"height":0.022346368},"on_screen":true,"help_text":"Session history","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"New session","depth":19,"bounds":{"left":0.9886968,"top":0.08060654,"width":0.00930851,"height":0.022346368},"on_screen":true,"help_text":"New session","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Message actions","depth":24,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"main.py","depth":23,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"lets implement logic with pipes. how can I run it?","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Let me look at the current project structure to understand what's already in place.","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"List project files","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"find /volume1/screenpipe -type f | head -50 && echo \"---\" && ls /volume1/screenpipe","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"/volume1/screenpipe/.DS_Store\n/volume1/screenpipe/screenpipe.db\n/volume1/screenpipe/screenpipe_sync.sh\n/volume1/screenpipe/app_settings.json\n/volume1/screenpipe/.gitignore\n/volume1/screenpipe/archive.db\n/volume1/screenpipe/db.sqlite\n/volume1/screenpipe/db.sqlite-wal\n/volume1/screenpipe/db.sqlite-shm\n/volume1/screenpipe/#recycle/desktop.ini\n/volume1/screenpipe/#recycle/db.sqlite\n/volume1/screenpipe/#recycle/Copy #1 of db.sqlite\n/volume1/screenpipe/#recycle/.DS_Store\n/volume1/screenpipe/#recycle/Copy #2 of db.sqlite\n/volume1/screenpipe/#recycle/archive.db\n/volume1/screenpipe/#recycle/Copy #1 of archive.db\n/volume1/screenpipe/#recycle/Copy #2 of archive.db\n/volume1/screenpipe/#recycle/Copy #3 of archive.db\n/volume1/screenpipe/#recycle/Copy #4 of archive.db\n/volume1/screenpipe/#recycle/Copy #5 of archive.db\n/volume1/screenpipe/#recycle/Copy #3 of db.sqlite\n/volume1/screenpipe/#recycle/Copy #4 of db.sqlite\n/volume1/screenpipe/#recycle/Copy #6 of archive.db\n/volume1/screenpipe/#recycle/test.txt\n/volume1/screenpipe/#recycle/Copy #7 of archive.db\n/volume1/screenpipe/#recycle/Copy #8 of archive.db\n/volume1/screenpipe/#recycle/archive.db-journal\n/volume1/screenpipe/#recycle/Copy #1 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #2 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #3 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #4 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #5 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #6 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #7 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #5 of db.sqlite\n/volume1/screenpipe/pipes/.DS_Store\n/volume1/screenpipe/app/.env\n/volume1/screenpipe/app/cli.py\n/volume1/screenpipe/app/.DS_Store\n/volume1/screenpipe/app/db.py\n/volume1/screenpipe/app/docker-compose.yml\n/volume1/screenpipe/app/main.py\n/volume1/screenpipe/app/requirements.txt\n/volume1/screenpipe/app/Dockerfile\n/volume1/screenpipe/data/.DS_Store\n/volume1/screenpipe/.git/description\n/volume1/screenpipe/.git/HEAD\n/volume1/screenpipe/.git/index\n/volume1/screenpipe/.git/COMMIT_EDITMSG\n/volume1/screenpipe/#recycle/data/.DS_Store\n---\napp\napp_settings.json\narchive.db\ndata\ndb.sqlite\ndb.sqlite-shm\ndb.sqlite-wal\npipes\n#recycle\nscreenpipe.db\nscreenpipe_sync.sh","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"main.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Check pipes directory and docker-compose","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/pipes/ && ls /volume1/screenpipe/app/ && cat /volume1/screenpipe/app/docker-compose.yml","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ai-habits\nday-recap\nmeeting-summary\nstandup-update\ntime-breakdown\nvideo-export\ncli.py\nconsumers\ndb.py\ndocker-compose.yml\nDockerfile\nmain.py\n__pycache__\nrequirements.txt\nstatic\nservices:\n screenpipe-app:\n build: .\n container_name: screenpipe-app\n restart: unless-stopped\n ports:\n - \"8766:8000\"\n volumes:\n - /volume1/screenpipe:/data\n env_file:\n - .env\n environment:\n TZ: Europe/Sofia\n DB_PATH: /data/db.sqlite\n\n sqlite-web-archive:\n image: ghcr.io/coleifer/sqlite-web:latest\n container_name: screenpipe-sqlweb-archive\n restart: unless-stopped\n ports:\n - \"8767:8080\"\n volumes:\n - /volume1/screenpipe:/data\n command: [\"-H\", \"0.0.0.0\", \"-r\", \"/data/archive.db\"]\n\n sqlite-web-live:\n image: ghcr.io/coleifer/sqlite-web:latest\n container_name: screenpipe-sqlweb-live\n restart: unless-stopped\n ports:\n - \"8768:8080\"\n volumes:\n - /volume1/screenpipe:/data\n command: [\"-H\", \"0.0.0.0\", \"-r\", \"/data/db.sqlite\"]","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"requirements.txt","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"requirements.txt","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Inspect a pipe directory","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/pipes/day-recap/ && cat /volume1/screenpipe/pipes/day-recap/pipe.json 2>/dev/null || ls /volume1/screenpipe/pipes/day-recap/","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"pipe.md\npipe.md","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"cli.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"cli.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"List all pipes and their contents","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/pipes/ && for d in /volume1/screenpipe/pipes/*/; do echo \"=== $d ===\"; ls \"$d\"; done","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ai-habits\nday-recap\nmeeting-summary\nstandup-update\ntime-breakdown\nvideo-export\n=== /volume1/screenpipe/pipes/ai-habits/ ===\npipe.md\n=== /volume1/screenpipe/pipes/day-recap/ ===\npipe.md\n=== /volume1/screenpipe/pipes/meeting-summary/ ===\npipe.md\n=== /volume1/screenpipe/pipes/standup-update/ ===\npipe.md\n=== /volume1/screenpipe/pipes/time-breakdown/ ===\npipe.md\n=== /volume1/screenpipe/pipes/video-export/ ===\npipe.md","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read pipe markdown files","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"cat /volume1/screenpipe/pipes/day-recap/pipe.md && echo \"===\" && cat /volume1/screenpipe/pipes/meeting-summary/pipe.md 2>/dev/null | head -50","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Day Recap\ndescription: \"Today's accomplishments, key moments, and unfinished work\"\nicon: \"📋\"\nfeatured: true\n---\n\nAnalyze my screen and audio recordings from today (last 16 hours only). \n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Summary\nOne sentence: what I mainly did today.\n\n## Accomplishments\n- Top 3 things I finished, with timestamps (e.g. \"2:30 PM\")\n- Name specific apps, files, or projects\n\n## Key Moments\n- Important things I saw, said, or heard — with timestamps\n\n## Unfinished Work\n- What I should continue tomorrow — name the app/file/task\n\n## Patterns\n- Apps I used most, topics that came up repeatedly\n\nOnly report what you can verify from the data. End with: \"**Next step:** [most important thing to continue]\"\n===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Meeting Summary\ndescription: \"Summarize meeting transcript with key takeaways and action items\"\nicon: \"🤝\"\nfeatured: false\n---\n\nSummarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.\n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Meeting Summary\nOne sentence: what this meeting was about.\n\n## Key Takeaways\n- Top 3-5 important points discussed\n- Include who said what when relevant\n\n## Action Items\n- [ ] Task — assigned to whom, deadline if mentioned\n- [ ] Task — assigned to whom\n\n## Decisions Made\n- List any decisions or agreements reached\n\n## Open Questions\n- Anything unresolved or needing follow-up\n\nKeep it concise and actionable.","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read summary consumer","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/app/consumers/ && cat /volume1/screenpipe/app/consumers/summary.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"activity.py\naudio.py\nelements.py\n__init__.py\ninteractions.py\nocr.py\n__pycache__\nreport.py\nsummary.py\n\"\"\"AI summary generator using Claude.\"\"\"\nimport os\nfrom datetime import date\nfrom typing import Any\n\nfrom consumers.activity import app_time, summary_stats, browser_urls, ui_event_summary\nfrom consumers.ocr import deduplicated_text\nfrom consumers.audio import formatted_transcript\n\n\nSUMMARY_TYPES = {\n \"day_recap\": {\n \"title\": \"Day Recap\",\n \"prompt\": \"\"\"\\\nYou are analyzing a person's computer activity for the day.\n\n## App usage (minutes per app):\n{app_time}\n\n## Browser URLs visited:\n{browser_urls}\n\n## UI activity per app (clicks / keystrokes / app-switches):\n{ui_events}\n\n## Screen content (sampled every 5 minutes):\n{ocr_text}\n\n## Audio/speech:\n{audio}\n\nWrite a concise day recap using EXACTLY this format:\n\n## Summary\nOne sentence: what I mainly worked on today.\n\n## Accomplishments\n- Top 3 things I finished, with approximate times\n- Name specific apps, files, or projects\n\n## Key Moments\n- Important things seen or heard, with timestamps\n\n## Unfinished Work\n- What to continue tomorrow\n\n## Patterns\n- Apps used most, topics that came up repeatedly\n\nOnly report what you can verify from the data. End with:\n**Next step:** [most important thing to continue]\"\"\",\n },\n \"standup\": {\n \"title\": \"Standup Update\",\n \"prompt\": \"\"\"\\\nYou are analyzing a person's computer activity for the day.\n\n## App usage (minutes per app):\n{app_time}\n\n## Browser URLs visited:\n{browser_urls}\n\n## UI activity per app (clicks / keystrokes / app-switches):\n{ui_events}\n\n## Screen content (sampled every 5 minutes):\n{ocr_text}\n\n## Audio/speech:\n{audio}\n\nWrite a brief standup update:\n\n**Yesterday:** What I worked on (2-3 bullets)\n**Today:** What I plan to continue (1-2 bullets)\n**Blockers:** Any issues observed (or \"None\")\n\nKeep it under 150 words. Only report what's verifiable from the data.\"\"\",\n },\n \"focus_time\": {\n \"title\": \"Focus & Distraction Analysis\",\n \"prompt\": \"\"\"\\\nYou are analyzing a person's computer activity for the day.\n\n## App usage (minutes per app):\n{app_time}\n\n## Browser URLs visited:\n{browser_urls}\n\n## UI activity per app (clicks / keystrokes / app-switches):\n{ui_events}\n\n## Screen content (sampled every 5 minutes):\n{ocr_text}\n\nAnalyze focus vs distraction patterns:\n\n## Deep Work Periods\n- When and how long were sustained focus sessions?\n- What was being worked on?\n\n## Distractions\n- Which apps/sites were used recreationally?\n- How much time was lost to context switching?\n\n## Recommendations\n- 2-3 concrete suggestions to improve focus tomorrow\n\nBe specific with times and app names.\"\"\",\n },\n}\n\n\ndef _build_context(for_date: date) -> dict[str, str]:\n apps = app_time(for_date)\n app_lines = \"\\n\".join(f\"- {a['app_name']}: {a['minutes']} min\" for a in apps[:20])\n\n urls = browser_urls(for_date, limit=20)\n url_lines = \"\\n\".join(\n f\"- {u['browser_url'][:100]} ({u['minutes']} min)\" for u in urls\n )\n\n ui_rows = ui_event_summary(for_date)\n ui_lines = \"\\n\".join(\n f\"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches\"\n for r in ui_rows[:15]\n )\n\n ocr_rows = deduplicated_text(for_date, chunk_minutes=5)\n ocr_lines = \"\\n\".join(\n f\"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}\"\n for r in ocr_rows[:100]\n )\n\n audio = formatted_transcript(for_date)\n\n return {\n \"app_time\": app_lines or \"(no app data)\",\n \"browser_urls\": url_lines or \"(no browser data)\",\n \"ui_events\": ui_lines or \"(no UI event data)\",\n \"ocr_text\": ocr_lines or \"(no screen data)\",\n \"audio\": audio[:3000] if len(audio) > 3000 else audio,\n }\n\n\ndef generate(\n summary_type: str = \"day_recap\",\n for_date: date | None = None,\n api_key: str | None = None,\n) -> dict[str, Any]:\n \"\"\"Generate an AI summary. Returns dict with 'title', 'content', 'date'.\"\"\"\n import anthropic\n\n d = for_date or date.today()\n key = api_key or os.environ.get(\"ANTHROPIC_API_KEY\", \"\")\n if not key:\n return {\n \"title\": \"Error\",\n \"content\": \"ANTHROPIC_API_KEY not set. Add it to your .env file.\",\n \"date\": str(d),\n }\n\n spec = SUMMARY_TYPES.get(summary_type)\n if not spec:\n return {\"title\": \"Error\", \"content\": f\"Unknown summary type: {summary_type}\", \"date\": str(d)}\n\n stats = summary_stats(d)\n if stats[\"total_frames\"] == 0:\n return {\n \"title\": spec[\"title\"],\n \"content\": f\"No screen data found for {d}.\",\n \"date\": str(d),\n }\n\n ctx = _build_context(d)\n prompt = spec[\"prompt\"].format(**ctx)\n\n client = anthropic.Anthropic(api_key=key)\n message = client.messages.create(\n model=\"claude-haiku-4-5-20251001\",\n max_tokens=1024,\n messages=[{\"role\": \"user\", \"content\": prompt}],\n )\n\n return {\n \"title\": spec[\"title\"],\n \"content\": message.content[0].text,\n \"date\": str(d),\n \"stats\": stats,\n }","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read all pipe.md files","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"for f in /volume1/screenpipe/pipes/*/pipe.md; do echo \"=== $f ===\"; cat \"$f\"; echo; done","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"=== /volume1/screenpipe/pipes/ai-habits/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: AI Habits\ndescription: \"How you use AI tools — patterns and insights\"\nicon: \"🤖\"\nfeatured: true\n---\n\nSearch my recordings from the last 24 hours for AI tool usage. Use app_name filter for each tool separately: ChatGPT, Claude, Copilot, Cursor, Gemini, Perplexity. Use limit=5 per search, max 6 searches total.\n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## AI Tools Used\n- List each tool with approximate time spent (e.g. \"Claude: ~45min\")\n\n## What I Used Them For\n- For each tool: coding, writing, research, or brainstorming\n\n## Usage Patterns\n- Do I switch between tools? Use them in bursts or steadily?\n\n## Effectiveness\n- Which tool appeared alongside completed work vs. abandoned attempts\n\nIf no AI usage is found, say so clearly. End with: \"**Tip:** [one suggestion to use AI tools more effectively]\"\n\n=== /volume1/screenpipe/pipes/day-recap/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Day Recap\ndescription: \"Today's accomplishments, key moments, and unfinished work\"\nicon: \"📋\"\nfeatured: true\n---\n\nAnalyze my screen and audio recordings from today (last 16 hours only). \n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Summary\nOne sentence: what I mainly did today.\n\n## Accomplishments\n- Top 3 things I finished, with timestamps (e.g. \"2:30 PM\")\n- Name specific apps, files, or projects\n\n## Key Moments\n- Important things I saw, said, or heard — with timestamps\n\n## Unfinished Work\n- What I should continue tomorrow — name the app/file/task\n\n## Patterns\n- Apps I used most, topics that came up repeatedly\n\nOnly report what you can verify from the data. End with: \"**Next step:** [most important thing to continue]\"\n\n=== /volume1/screenpipe/pipes/meeting-summary/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Meeting Summary\ndescription: \"Summarize meeting transcript with key takeaways and action items\"\nicon: \"🤝\"\nfeatured: false\n---\n\nSummarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.\n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Meeting Summary\nOne sentence: what this meeting was about.\n\n## Key Takeaways\n- Top 3-5 important points discussed\n- Include who said what when relevant\n\n## Action Items\n- [ ] Task — assigned to whom, deadline if mentioned\n- [ ] Task — assigned to whom\n\n## Decisions Made\n- List any decisions or agreements reached\n\n## Open Questions\n- Anything unresolved or needing follow-up\n\nKeep it concise and actionable.\n\n=== /volume1/screenpipe/pipes/standup-update/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Standup Update\ndescription: \"What you did, what's next, and any blockers\"\nicon: \"🏢\"\nfeatured: true\n---\n\nBased on my recordings from the last 24 hours, generate a standup update. Use limit=10 per search, max 3 searches total.\n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Yesterday\n- What I worked on (name specific projects, files, tools, PRs)\n\n## Today\n- What I will work on next (based on unfinished tasks and recent activity)\n\n## Blockers\n- Issues I hit — errors, slow builds, waiting on someone\n- If no blockers, write \"None\"\n\nKeep it under 150 words. Copy-paste ready for a team standup.\n\n=== /volume1/screenpipe/pipes/time-breakdown/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Time Breakdown\ndescription: \"Where your time went — by app, project, and category\"\nicon: \"⏱\"\nfeatured: false\n---\n\nAnalyze my app usage from today (last 12 hours). Use limit=10 per search, max 4 searches. Prefer /raw_sql with COUNT/GROUP BY queries.\n\nRead screenpipe skill first.\n\nUse this exact format with durations and percentages:\n\n## By Application\n- List each app with duration and percentage, sorted by time (e.g. \"VS Code: 2h 15min (28%)\")\n\n## By Category\n- Group into: coding, meetings, browsing, writing, communication, other\n- Show hours and percentage per category\n\n## By Project\n- Group related activities by project/topic. Name specific repos or tasks.\n\n## Productivity Score\n- Calculate: focused_work_hours / total_hours as a percentage\n- Focused = coding + writing. Unfocused = browsing + switching.\n\nEnd with: \"**Suggestion:** [one specific change to improve tomorrow's productivity]\"\n\n=== /volume1/screenpipe/pipes/video-export/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Export Video Clip\ndescription: \"Create a video of your recent screen activity\"\nicon: \"🎬\"\nfeatured: false\n---\n\nExport a video of my screen activity from the last 5 minutes.\n\nRead screenpipe skill first.\n\nUse the POST /frames/export endpoint with the time range and fps=1.0. Then show me the exported video file path as an inline code block so I can watch it.\n\nIf the export is large, suggest a lower fps or shorter time range.","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Now I have a clear picture. The pipes are markdown prompt templates in","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"/volume1/screenpipe/pipes/","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":", but there's no code to actually load and run them —","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"consumers/summary.py","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"has its own hardcoded prompts instead.","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Here's what I'll implement:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"consumers/pipes.py","depth":26,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"— dynamically loads pipe.md files and runs them via Claude (data injected as system message, pipe body as user prompt)","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"main.py","depth":26,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"— two new endpoints:","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"GET /api/pipes","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"and","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"POST /api/pipes/{pipe_id}/run","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"cli.py","depth":26,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"— a","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"pipe","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"command to run pipes from the terminal","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Let me build it:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Check browser_urls signature","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"cat /volume1/screenpipe/app/consumers/activity.py | grep \"def browser_urls\" -A 5","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"def browser_urls(\n for_date: date | None = None,\n app_name: str | None = None,\n ts_from: str | None = None,\n ts_to: str | None = None,\n limit: int = 30,","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Write","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"pipes.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"pipes.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"143 lines","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"\"\"\"Dynamic pipe loader and runner.\"\"\"\nimport os\nimport re\nfrom datetime import date\nfrom pathlib import Path\nfrom typing import Any\n\n\ndef _parse_frontmatter(text: str) -> tuple[dict, str]:\n if not text.startswith(\"---\"):\n return {}, text\n try:\n end = text.index(\"---\", 3)\n except ValueError:\n return {}, text\n fm_text = text[3:end].strip()\n body = text[end + 3:].strip()\n meta: dict = {}\n for line in fm_text.splitlines():\n if \":\" in line:\n k, _, v = line.partition(\":\")\n meta[k.strip()] = v.strip().strip('\"')\n return meta, body\n\n\ndef load_pipes(pipes_dir: Path) -> list[dict]:\n if not pipes_dir.exists():\n return []\n pipes = []\n for pipe_dir in sorted(pipes_dir.iterdir()):\n if not pipe_dir.is_dir() or pipe_dir.name.startswith(\".\"):\n continue\n pipe_md = pipe_dir / \"pipe.md\"\n if not pipe_md.exists():\n continue\n text = pipe_md.read_text(encoding=\"utf-8\")\n meta, body = _parse_frontmatter(text)\n if meta.get(\"enabled\", \"true\").lower() == \"false\":\n continue\n body = re.sub(r\"Read screenpipe skill first\\.?\\n?\", \"\", body).strip()\n pipes.append({\n \"id\": pipe_dir.name,\n \"title\": meta.get(\"title\", pipe_dir.name),\n \"description\": meta.get(\"description\", \"\"),\n \"icon\": meta.get(\"icon\", \"\"),\n \"schedule\": meta.get(\"schedule\", \"manual\"),\n \"featured\": meta.get(\"featured\", \"false\").lower() == \"true\",\n \"prompt\": body,\n })\n return pipes\n\n\ndef _build_system(d: date, stats: dict) -> str:\n from consumers.activity import app_time, browser_urls, ui_event_summary\n from consumers.ocr import deduplicated_text\n from consumers.audio import formatted_transcript\n\n apps = app_time(d)\n app_lines = \"\\n\".join(f\"- {a['app_name']}: {a['minutes']} min\" for a in apps[:20])\n\n urls = browser_urls(d, limit=20)\n url_lines = \"\\n\".join(f\"- {u['browser_url'][:100]} ({u['minutes']} min)\" for u in urls)\n\n ui_rows = ui_event_summary(d)\n ui_lines = \"\\n\".join(\n f\"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches\"\n for r in ui_rows[:15]\n )\n\n ocr_rows = deduplicated_text(d, chunk_minutes=5)\n ocr_lines = \"\\n\".join(\n f\"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}\"\n for r in ocr_rows[:100]\n )\n\n audio = formatted_transcript(d)\n if len(audio) > 3000:\n audio = audio[:3000]\n\n return f\"\"\"You are analyzing screenpipe data — recordings of a person's computer activity.\n\n## App usage (minutes per app):\n{app_lines or '(no app data)'}\n\n## Browser URLs visited:\n{url_lines or '(no browser data)'}\n\n## UI activity per app (clicks / keystrokes / app-switches):\n{ui_lines or '(no UI event data)'}\n\n## Screen content (sampled every 5 minutes):\n{ocr_lines or '(no screen data)'}\n\n## Audio / speech:\n{audio or '(no audio data)'}\n\nDate: {d}\nTotal frames recorded: {stats['total_frames']}\"\"\"\n\n\ndef run_pipe(\n pipe_id: str,\n for_date: date | None = None,\n api_key: str | None = None,\n pipes_dir: Path | None = None,\n) -> dict[str, Any]:\n import anthropic\n from consumers.activity import summary_stats\n\n d = for_date or date.today()\n key = api_key or os.environ.get(\"ANTHROPIC_API_KEY\", \"\")\n if not key:\n return {\"title\": \"Error\", \"content\": \"ANTHROPIC_API_KEY not set.\", \"date\": str(d)}\n\n _pipes_dir = pipes_dir or Path(os.environ.get(\"PIPES_DIR\", \"/data/pipes\"))\n all_pipes = {p[\"id\"]: p for p in load_pipes(_pipes_dir)}\n\n if pipe_id not in all_pipes:\n return {\"title\": \"Error\", \"content\": f\"Pipe not found: {pipe_id}\", \"date\": str(d)}\n\n pipe = all_pipes[pipe_id]\n stats = summary_stats(d)\n\n if stats[\"total_frames\"] == 0:\n return {\"title\": pipe[\"title\"], \"content\": f\"No screen data found for {d}.\", \"date\": str(d)}\n\n system = _build_system(d, stats)\n\n client = anthropic.Anthropic(api_key=key)\n message = client.messages.create(\n model=\"claude-haiku-4-5-20251001\",\n max_tokens=1024,\n system=system,\n messages=[{\"role\": \"user\", \"content\": pipe[\"prompt\"]}],\n )\n\n return {\n \"title\": pipe[\"title\"],\n \"content\": message.content[0].text,\n \"date\": str(d),\n \"stats\": stats,\n }","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Now add the API endpoints to","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"main.py","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":":","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Edit","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"main.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Added 1 line","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Edit","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"main.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Added 1 line","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Now add the pipe endpoints at the end of main.py, before the closing summary section:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Edit","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"main.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Added 14 lines","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Now add the CLI command to","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"cli.py","depth":23,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"cli.py","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":":","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Edit","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"cli.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"cli.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Added 40 lines","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Done. Here's how to run pipes:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXHeading","text":"How to run pipes","depth":22,"on_screen":false,"role_description":"heading"},{"role":"AXStaticText","text":"How to run pipes","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Via Docker (inside the running container):","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":23,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"docker exec -it screenpipe-app python cli.py pipe --list\ndocker exec -it screenpipe-app python cli.py pipe day-recap\ndocker exec -it screenpipe-app python cli.py pipe standup-update --date yesterday","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Via the API","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"(once the container is running on port 8766):","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":23,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"# List pipes\ncurl http://localhost:8766/api/pipes\n\n# Run a pipe\ncurl -X POST \"http://localhost:8766/api/pipes/day-recap/run\"\ncurl -X POST \"http://localhost:8766/api/pipes/standup-update/run?d=2026-04-25\"","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Rebuild and restart","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"to pick up the changes:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":23,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"cd /volume1/screenpipe/app\ndocker compose up --build -d","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"How it works:","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Each","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"pipe.md","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"file is loaded dynamically — the frontmatter provides metadata and the body becomes the user prompt. Screenpipe data (app usage, browser URLs, OCR, audio) is injected as a Claude system message so the pipe prompt can reference it naturally. The \"Read screenpipe skill first\" line is stripped automatically.","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"The pipes directory inside Docker is","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"/data/pipes","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"(since","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"/volume1/screenpipe","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"→","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"/data","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"). You can override it with a","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"PIPES_DIR","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"env var if needed.","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Message actions","depth":24,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"pipe.md","depth":23,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"pipe.md","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"where to place api key and can I use different keys","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read .env file","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"cat /volume1/screenpipe/app/.env","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ANTHROPIC_API_KEY=your_key_here","depth":24,"on_screen":false,"role_description":"text"}]...
|
-3576203112056561664
|
-8691438911294027668
|
visual_change
|
accessibility
|
NULL
|
Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧ Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py
M
db.py
docker-compose.yml
Dockerfile
M
main.py
M
requirements.txt
M
data
logs
pipes
.gitignore
app_settings.json
archive.db
archive.db-bak
U
db.sqlite
db.sqlite-shm
db.sqlite-wal
screenpipe_sync_updated.sh
U
screenpipe_sync.sh
screenpipe.db
Outline Section
OUTLINE
OUTLINE
Timeline Section
TIMELINE
TIMELINE
app_settings.json, Editor Group 1
screenpipe_sync.sh, Editor Group 1
pipe.md, Editor Group 1
.env, Editor Group 1
screenpipe_sync.sh, Editor Group 1
Implement and run pipe l…, Editor Group 2
Problems (⇧⌘M)
PROBLEMS
Output (⇧⌘U)
OUTPUT
Debug Console (⇧⌘Y)
DEBUG CONSOLE
Terminal (⌃`)
TERMINAL
Ports - 1 forwarded port
PORTS
1
remote SSH: nas
SSH: nas
screenpipe (Git) - master*, Checkout Branch/Tag...
master*
screenpipe (Git) - Synchronize Changes
No Problems
0
0
Forwarded Ports: 8766
1
Notifications
Sign In
Sign In
Shell Script
Editor Language Status: $(copilot) No inline suggestion available, Inline suggestions
LF
UTF-8
Spaces: 2
Ln 30, Col 2
git-commit Lukas Kovalik (2 weeks ago)
Lukas Kovalik (2 weeks ago)
Info: Setting up SSH Host nas: Setting up SSH tunnel
Implement and run pipe logic
Session history
New session
Message actions
main.py
main.py
lets implement logic with pipes. how can I run it?
Thinking
Thinking
Let me look at the current project structure to understand what's already in place.
Bash
List project files
IN
find /volume1/screenpipe -type f | head -50 && echo "---" && ls /volume1/screenpipe
Copy code to clipboard
OUT
/volume1/screenpipe/.DS_Store
/volume1/screenpipe/screenpipe.db
/volume1/screenpipe/screenpipe_sync.sh
/volume1/screenpipe/app_settings.json
/volume1/screenpipe/.gitignore
/volume1/screenpipe/archive.db
/volume1/screenpipe/db.sqlite
/volume1/screenpipe/db.sqlite-wal
/volume1/screenpipe/db.sqlite-shm
/volume1/screenpipe/#recycle/desktop.ini
/volume1/screenpipe/#recycle/db.sqlite
/volume1/screenpipe/#recycle/Copy #1 of db.sqlite
/volume1/screenpipe/#recycle/.DS_Store
/volume1/screenpipe/#recycle/Copy #2 of db.sqlite
/volume1/screenpipe/#recycle/archive.db
/volume1/screenpipe/#recycle/Copy #1 of archive.db
/volume1/screenpipe/#recycle/Copy #2 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of archive.db
/volume1/screenpipe/#recycle/Copy #4 of archive.db
/volume1/screenpipe/#recycle/Copy #5 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of db.sqlite
/volume1/screenpipe/#recycle/Copy #4 of db.sqlite
/volume1/screenpipe/#recycle/Copy #6 of archive.db
/volume1/screenpipe/#recycle/test.txt
/volume1/screenpipe/#recycle/Copy #7 of archive.db
/volume1/screenpipe/#recycle/Copy #8 of archive.db
/volume1/screenpipe/#recycle/archive.db-journal
/volume1/screenpipe/#recycle/Copy #1 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #2 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #3 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #4 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #6 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #7 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of db.sqlite
/volume1/screenpipe/pipes/.DS_Store
/volume1/screenpipe/app/.env
/volume1/screenpipe/app/cli.py
/volume1/screenpipe/app/.DS_Store
/volume1/screenpipe/app/db.py
/volume1/screenpipe/app/docker-compose.yml
/volume1/screenpipe/app/main.py
/volume1/screenpipe/app/requirements.txt
/volume1/screenpipe/app/Dockerfile
/volume1/screenpipe/data/.DS_Store
/volume1/screenpipe/.git/description
/volume1/screenpipe/.git/HEAD
/volume1/screenpipe/.git/index
/volume1/screenpipe/.git/COMMIT_EDITMSG
/volume1/screenpipe/#recycle/data/.DS_Store
---
app
app_settings.json
archive.db
data
db.sqlite
db.sqlite-shm
db.sqlite-wal
pipes
#recycle
screenpipe.db
screenpipe_sync.sh
Read
main.py
main.py
Bash
Check pipes directory and docker-compose
IN
ls /volume1/screenpipe/pipes/ && ls /volume1/screenpipe/app/ && cat /volume1/screenpipe/app/docker-compose.yml
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
cli.py
consumers
db.py
docker-compose.yml
Dockerfile
main.py
__pycache__
requirements.txt
static
services:
screenpipe-app:
build: .
container_name: screenpipe-app
restart: unless-stopped
ports:
- "8766:8000"
volumes:
- /volume1/screenpipe:/data
env_file:
- .env
environment:
TZ: Europe/Sofia
DB_PATH: /data/db.sqlite
sqlite-web-archive:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-archive
restart: unless-stopped
ports:
- "8767:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/archive.db"]
sqlite-web-live:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-live
restart: unless-stopped
ports:
- "8768:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/db.sqlite"]
Read
requirements.txt
requirements.txt
Bash
Inspect a pipe directory
IN
ls /volume1/screenpipe/pipes/day-recap/ && cat /volume1/screenpipe/pipes/day-recap/pipe.json 2>/dev/null || ls /volume1/screenpipe/pipes/day-recap/
Copy code to clipboard
OUT
pipe.md
pipe.md
Read
cli.py
cli.py
Bash
List all pipes and their contents
IN
ls /volume1/screenpipe/pipes/ && for d in /volume1/screenpipe/pipes/*/; do echo "=== $d ==="; ls "$d"; done
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
=== /volume1/screenpipe/pipes/ai-habits/ ===
pipe.md
=== /volume1/screenpipe/pipes/day-recap/ ===
pipe.md
=== /volume1/screenpipe/pipes/meeting-summary/ ===
pipe.md
=== /volume1/screenpipe/pipes/standup-update/ ===
pipe.md
=== /volume1/screenpipe/pipes/time-breakdown/ ===
pipe.md
=== /volume1/screenpipe/pipes/video-export/ ===
pipe.md
Bash
Read pipe markdown files
IN
cat /volume1/screenpipe/pipes/day-recap/pipe.md && echo "===" && cat /volume1/screenpipe/pipes/meeting-summary/pipe.md 2>/dev/null | head -50
Copy code to clipboard
OUT
---
schedule: manual
enabled: true
template: true
title: Day Recap
description: "Today's accomplishments, key moments, and unfinished work"
icon: "📋"
featured: true
---
Analyze my screen and audio recordings from today (last 16 hours only).
Read screenpipe skill first.
Use this exact format:
## Summary
One sentence: what I mainly did today.
## Accomplishments
- Top 3 things I finished, with timestamps (e.g. "2:30 PM")
- Name specific apps, files, or projects
## Key Moments
- Important things I saw, said, or heard — with timestamps
## Unfinished Work
- What I should continue tomorrow — name the app/file/task
## Patterns
- Apps I used most, topics that came up repeatedly
Only report what you can verify from the data. End with: "**Next step:** [most important thing to continue]"
===
---
schedule: manual
enabled: true
template: true
title: Meeting Summary
description: "Summarize meeting transcript with key takeaways and action items"
icon: "🤝"
featured: false
---
Summarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.
Read screenpipe skill first.
Use this exact format:
## Meeting Summary
One sentence: what this meeting was about.
## Key Takeaways
- Top 3-5 important points discussed
- Include who said what when relevant
## Action Items
- [ ] Task — assigned to whom, deadline if mentioned
- [ ] Task — assigned to whom
## Decisions Made
- List any decisions or agreements reached
## Open Questions
- Anything unresolved or needing follow-up
Keep it concise and actionable.
Thinking
Thinking
Bash
Read summary consumer
IN
ls /volume1/screenpipe/app/consumers/ && cat /volume1/screenpipe/app/consumers/summary.py
Copy code to clipboard
OUT
activity.py
audio.py
elements.py
__init__.py
interactions.py
ocr.py
__pycache__
report.py
summary.py
"""AI summary generator using Claude."""
import os
from datetime import date
from typing import Any
from consumers.activity import app_time, summary_stats, browser_urls, ui_event_summary
from consumers.ocr import deduplicated_text
from consumers.audio import formatted_transcript
SUMMARY_TYPES = {
"day_recap": {
"title": "Day Recap",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
## Audio/speech:
{audio}
Write a concise day recap using EXACTLY this format:
## Summary
One sentence: what I mainly worked on today.
## Accomplishments
- Top 3 things I finished, with approximate times
- Name specific apps, files, or projects
## Key Moments
- Important things seen or heard, with timestamps
## Unfinished Work
- What to continue tomorrow
## Patterns
- Apps used most, topics that came up repeatedly
Only report what you can verify from the data. End with:
**Next step:** [most important thing to continue]""",
},
"standup": {
"title": "Standup Update",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
## Audio/speech:
{audio}
Write a brief standup update:
**Yesterday:** What I worked on (2-3 bullets)
**Today:** What I plan to continue (1-2 bullets)
**Blockers:** Any issues observed (or "None")
Keep it under 150 words. Only report what's verifiable from the data.""",
},
"focus_time": {
"title": "Focus & Distraction Analysis",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
Analyze focus vs distraction patterns:
## Deep Work Periods
- When and how long were sustained focus sessions?
- What was being worked on?
## Distractions
- Which apps/sites were used recreationally?
- How much time was lost to context switching?
## Recommendations
- 2-3 concrete suggestions to improve focus tomorrow
Be specific with times and app names.""",
},
}
def _build_context(for_date: date) -> dict[str, str]:
apps = app_time(for_date)
app_lines = "\n".join(f"- {a['app_name']}: {a['minutes']} min" for a in apps[:20])
urls = browser_urls(for_date, limit=20)
url_lines = "\n".join(
f"- {u['browser_url'][:100]} ({u['minutes']} min)" for u in urls
)
ui_rows = ui_event_summary(for_date)
ui_lines = "\n".join(
f"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches"
for r in ui_rows[:15]
)
ocr_rows = deduplicated_text(for_date, chunk_minutes=5)
ocr_lines = "\n".join(
f"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}"
for r in ocr_rows[:100]
)
audio = formatted_transcript(for_date)
return {
"app_time": app_lines or "(no app data)",
"browser_urls": url_lines or "(no browser data)",
"ui_events": ui_lines or "(no UI event data)",
"ocr_text": ocr_lines or "(no screen data)",
"audio": audio[:3000] if len(audio) > 3000 else audio,
}
def generate(
summary_type: str = "day_recap",
for_date: date | None = None,
api_key: str | None = None,
) -> dict[str, Any]:
"""Generate an AI summary. Returns dict with 'title', 'content', 'date'."""
import anthropic
d = for_date or date.today()
key = api_key or os.environ.get("ANTHROPIC_API_KEY", "")
if not key:
return {
"title": "Error",
"content": "ANTHROPIC_API_KEY not set. Add it to your .env file.",
"date": str(d),
}
spec = SUMMARY_TYPES.get(summary_type)
if not spec:
return {"title": "Error", "content": f"Unknown summary type: {summary_type}", "date": str(d)}
stats = summary_stats(d)
if stats["total_frames"] == 0:
return {
"title": spec["title"],
"content": f"No screen data found for {d}.",
"date": str(d),
}
ctx = _build_context(d)
prompt = spec["prompt"].format(**ctx)
client = anthropic.Anthropic(api_key=key)
message = client.messages.create(
model="claude-haiku-4-5-20251001",
max_tokens=1024,
messages=[{"role": "user", "content": prompt}],
)
return {
"title": spec["title"],
"content": message.content[0].text,
"date": str(d),
"stats": stats,
}
Thinking
Thinking
Bash
Read all pipe.md files
IN
for f in /volume1/screenpipe/pipes/*/pipe.md; do echo "=== $f ==="; cat "$f"; echo; done
Copy code to clipboard
OUT
=== /volume1/screenpipe/pipes/ai-habits/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: AI Habits
description: "How you use AI tools — patterns and insights"
icon: "🤖"
featured: true
---
Search my recordings from the last 24 hours for AI tool usage. Use app_name filter for each tool separately: ChatGPT, Claude, Copilot, Cursor, Gemini, Perplexity. Use limit=5 per search, max 6 searches total.
Read screenpipe skill first.
Use this exact format:
## AI Tools Used
- List each tool with approximate time spent (e.g. "Claude: ~45min")
## What I Used Them For
- For each tool: coding, writing, research, or brainstorming
## Usage Patterns
- Do I switch between tools? Use them in bursts or steadily?
## Effectiveness
- Which tool appeared alongside completed work vs. abandoned attempts
If no AI usage is found, say so clearly. End with: "**Tip:** [one suggestion to use AI tools more effectively]"
=== /volume1/screenpipe/pipes/day-recap/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Day Recap
description: "Today's accomplishments, key moments, and unfinished work"
icon: "📋"
featured: true
---
Analyze my screen and audio recordings from today (last 16 hours only).
Read screenpipe skill first.
Use this exact format:
## Summary
One sentence: what I mainly did today.
## Accomplishments
- Top 3 things I finished, with timestamps (e.g. "2:30 PM")
- Name specific apps, files, or projects
## Key Moments
- Important things I saw, said, or heard — with timestamps
## Unfinished Work
- What I should continue tomorrow — name the app/file/task
## Patterns
- Apps I used most, topics that came up repeatedly
Only report what you can verify from the data. End with: "**Next step:** [most important thing to continue]"
=== /volume1/screenpipe/pipes/meeting-summary/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Meeting Summary
description: "Summarize meeting transcript with key takeaways and action items"
icon: "🤝"
featured: false
---
Summarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.
Read screenpipe skill first.
Use this exact format:
## Meeting Summary
One sentence: what this meeting was about.
## Key Takeaways
- Top 3-5 important points discussed
- Include who said what when relevant
## Action Items
- [ ] Task — assigned to whom, deadline if mentioned
- [ ] Task — assigned to whom
## Decisions Made
- List any decisions or agreements reached
## Open Questions
- Anything unresolved or needing follow-up
Keep it concise and actionable.
=== /volume1/screenpipe/pipes/standup-update/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Standup Update
description: "What you did, what's next, and any blockers"
icon: "🏢"
featured: true
---
Based on my recordings from the last 24 hours, generate a standup update. Use limit=10 per search, max 3 searches total.
Read screenpipe skill first.
Use this exact format:
## Yesterday
- What I worked on (name specific projects, files, tools, PRs)
## Today
- What I will work on next (based on unfinished tasks and recent activity)
## Blockers
- Issues I hit — errors, slow builds, waiting on someone
- If no blockers, write "None"
Keep it under 150 words. Copy-paste ready for a team standup.
=== /volume1/screenpipe/pipes/time-breakdown/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Time Breakdown
description: "Where your time went — by app, project, and category"
icon: "⏱"
featured: false
---
Analyze my app usage from today (last 12 hours). Use limit=10 per search, max 4 searches. Prefer /raw_sql with COUNT/GROUP BY queries.
Read screenpipe skill first.
Use this exact format with durations and percentages:
## By Application
- List each app with duration and percentage, sorted by time (e.g. "VS Code: 2h 15min (28%)")
## By Category
- Group into: coding, meetings, browsing, writing, communication, other
- Show hours and percentage per category
## By Project
- Group related activities by project/topic. Name specific repos or tasks.
## Productivity Score
- Calculate: focused_work_hours / total_hours as a percentage
- Focused = coding + writing. Unfocused = browsing + switching.
End with: "**Suggestion:** [one specific change to improve tomorrow's productivity]"
=== /volume1/screenpipe/pipes/video-export/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Export Video Clip
description: "Create a video of your recent screen activity"
icon: "🎬"
featured: false
---
Export a video of my screen activity from the last 5 minutes.
Read screenpipe skill first.
Use the POST /frames/export endpoint with the time range and fps=1.0. Then show me the exported video file path as an inline code block so I can watch it.
If the export is large, suggest a lower fps or shorter time range.
Thinking
Thinking
Now I have a clear picture. The pipes are markdown prompt templates in
/volume1/screenpipe/pipes/
, but there's no code to actually load and run them —
consumers/summary.py
has its own hardcoded prompts instead.
Here's what I'll implement:
consumers/pipes.py
— dynamically loads pipe.md files and runs them via Claude (data injected as system message, pipe body as user prompt)
main.py
— two new endpoints:
GET /api/pipes
and
POST /api/pipes/{pipe_id}/run
cli.py
— a
pipe
command to run pipes from the terminal
Let me build it:
Bash
Check browser_urls signature
IN
cat /volume1/screenpipe/app/consumers/activity.py | grep "def browser_urls" -A 5
Copy code to clipboard
OUT
def browser_urls(
for_date: date | None = None,
app_name: str | None = None,
ts_from: str | None = None,
ts_to: str | None = None,
limit: int = 30,
Write
pipes.py
pipes.py
143 lines
"""Dynamic pipe loader and runner."""
import os
import re
from datetime import date
from pathlib import Path
from typing import Any
def _parse_frontmatter(text: str) -> tuple[dict, str]:
if not text.startswith("---"):
return {}, text
try:
end = text.index("---", 3)
except ValueError:
return {}, text
fm_text = text[3:end].strip()
body = text[end + 3:].strip()
meta: dict = {}
for line in fm_text.splitlines():
if ":" in line:
k, _, v = line.partition(":")
meta[k.strip()] = v.strip().strip('"')
return meta, body
def load_pipes(pipes_dir: Path) -> list[dict]:
if not pipes_dir.exists():
return []
pipes = []
for pipe_dir in sorted(pipes_dir.iterdir()):
if not pipe_dir.is_dir() or pipe_dir.name.startswith("."):
continue
pipe_md = pipe_dir / "pipe.md"
if not pipe_md.exists():
continue
text = pipe_md.read_text(encoding="utf-8")
meta, body = _parse_frontmatter(text)
if meta.get("enabled", "true").lower() == "false":
continue
body = re.sub(r"Read screenpipe skill first\.?\n?", "", body).strip()
pipes.append({
"id": pipe_dir.name,
"title": meta.get("title", pipe_dir.name),
"description": meta.get("description", ""),
"icon": meta.get("icon", ""),
"schedule": meta.get("schedule", "manual"),
"featured": meta.get("featured", "false").lower() == "true",
"prompt": body,
})
return pipes
def _build_system(d: date, stats: dict) -> str:
from consumers.activity import app_time, browser_urls, ui_event_summary
from consumers.ocr import deduplicated_text
from consumers.audio import formatted_transcript
apps = app_time(d)
app_lines = "\n".join(f"- {a['app_name']}: {a['minutes']} min" for a in apps[:20])
urls = browser_urls(d, limit=20)
url_lines = "\n".join(f"- {u['browser_url'][:100]} ({u['minutes']} min)" for u in urls)
ui_rows = ui_event_summary(d)
ui_lines = "\n".join(
f"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches"
for r in ui_rows[:15]
)
ocr_rows = deduplicated_text(d, chunk_minutes=5)
ocr_lines = "\n".join(
f"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}"
for r in ocr_rows[:100]
)
audio = formatted_transcript(d)
if len(audio) > 3000:
audio = audio[:3000]
return f"""You are analyzing screenpipe data — recordings of a person's computer activity.
## App usage (minutes per app):
{app_lines or '(no app data)'}
## Browser URLs visited:
{url_lines or '(no browser data)'}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_lines or '(no UI event data)'}
## Screen content (sampled every 5 minutes):
{ocr_lines or '(no screen data)'}
## Audio / speech:
{audio or '(no audio data)'}
Date: {d}
Total frames recorded: {stats['total_frames']}"""
def run_pipe(
pipe_id: str,
for_date: date | None = None,
api_key: str | None = None,
pipes_dir: Path | None = None,
) -> dict[str, Any]:
import anthropic
from consumers.activity import summary_stats
d = for_date or date.today()
key = api_key or os.environ.get("ANTHROPIC_API_KEY", "")
if not key:
return {"title": "Error", "content": "ANTHROPIC_API_KEY not set.", "date": str(d)}
_pipes_dir = pipes_dir or Path(os.environ.get("PIPES_DIR", "/data/pipes"))
all_pipes = {p["id"]: p for p in load_pipes(_pipes_dir)}
if pipe_id not in all_pipes:
return {"title": "Error", "content": f"Pipe not found: {pipe_id}", "date": str(d)}
pipe = all_pipes[pipe_id]
stats = summary_stats(d)
if stats["total_frames"] == 0:
return {"title": pipe["title"], "content": f"No screen data found for {d}.", "date": str(d)}
system = _build_system(d, stats)
client = anthropic.Anthropic(api_key=key)
message = client.messages.create(
model="claude-haiku-4-5-20251001",
max_tokens=1024,
system=system,
messages=[{"role": "user", "content": pipe["prompt"]}],
)
return {
"title": pipe["title"],
"content": message.content[0].text,
"date": str(d),
"stats": stats,
}
Now add the API endpoints to
main.py
:
Edit
main.py
main.py
Added 1 line
Edit
main.py
main.py
Added 1 line
Now add the pipe endpoints at the end of main.py, before the closing summary section:
Edit
main.py
main.py
Added 14 lines
Now add the CLI command to
cli.py
cli.py
:
Edit
cli.py
cli.py
Added 40 lines
Done. Here's how to run pipes:
How to run pipes
How to run pipes
Via Docker (inside the running container):
Copy code to clipboard
docker exec -it screenpipe-app python cli.py pipe --list
docker exec -it screenpipe-app python cli.py pipe day-recap
docker exec -it screenpipe-app python cli.py pipe standup-update --date yesterday
Via the API
(once the container is running on port 8766):
Copy code to clipboard
# List pipes
curl http://localhost:8766/api/pipes
# Run a pipe
curl -X POST "http://localhost:8766/api/pipes/day-recap/run"
curl -X POST "http://localhost:8766/api/pipes/standup-update/run?d=2026-04-25"
Rebuild and restart
to pick up the changes:
Copy code to clipboard
cd /volume1/screenpipe/app
docker compose up --build -d
How it works:
Each
pipe.md
file is loaded dynamically — the frontmatter provides metadata and the body becomes the user prompt. Screenpipe data (app usage, browser URLs, OCR, audio) is injected as a Claude system message so the pipe prompt can reference it naturally. The "Read screenpipe skill first" line is stripped automatically.
The pipes directory inside Docker is
/data/pipes
(since
/volume1/screenpipe
→
/data
). You can override it with a
PIPES_DIR
env var if needed.
Message actions
pipe.md
pipe.md
where to place api key and can I use different keys
Thinking
Thinking
Bash
Read .env file
IN
cat /volume1/screenpipe/app/.env
Copy code to clipboard
OUT
[ENV_SECRET]...
|
21080
|
NULL
|
NULL
|
NULL
|
|
21082
|
922
|
1
|
2026-05-11T17:11:08.411418+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-11/1778 /Users/lukas/.screenpipe/data/data/2026-05-11/1778519468411_m1.jpg...
|
Code
|
screenpipe_sync.sh — screenpipe [SSH: nas]
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧ Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py
M
db.py
docker-compose.yml
Dockerfile
M
...
|
[{"role":"AXRadioButton","text [{"role":"AXRadioButton","text":"Explorer (⇧⌘E)","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":true},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Search (⇧⌘F)","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Source Control (⌃⇧G) - 10 pending changes","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"10","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Run and Debug (⇧⌘D)","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Remote Explorer","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Extensions (⇧⌘X) - 2 require update","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"2","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Claude Code","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"Containers","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXHeading","text":"EXPLORER","depth":17,"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"EXPLORER","depth":18,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Explorer Section: screenpipe [SSH: nas]","depth":21,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":true},{"role":"AXStaticText","text":"","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"Explorer Section: screenpipe [SSH: nas]","depth":22,"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"SCREENPIPE [SSH: NAS]","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"#recycle","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"app","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"__pycache__","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"consumers","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"static","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":".env","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"cli.py","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.py","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"docker-compose.yml","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Dockerfile","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"}]...
|
-8829654875386564147
|
-5551997238571740788
|
click
|
accessibility
|
NULL
|
Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧ Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py
M
db.py
docker-compose.yml
Dockerfile
M
...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
21083
|
923
|
2
|
2026-05-11T17:11:08.410739+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-11/1778 /Users/lukas/.screenpipe/data/data/2026-05-11/1778519468410_m2.jpg...
|
Code
|
screenpipe_sync.sh — screenpipe [SSH: nas]
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧ Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle...
|
[{"role":"AXRadioButton","text [{"role":"AXRadioButton","text":"Explorer (⇧⌘E)","depth":19,"bounds":{"left":0.0,"top":0.047885075,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":true},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.057462092,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Search (⇧⌘F)","depth":19,"bounds":{"left":0.0,"top":0.08619314,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.09577015,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Source Control (⌃⇧G) - 10 pending changes","depth":19,"bounds":{"left":0.0,"top":0.1245012,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.13407822,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"10","depth":22,"bounds":{"left":0.00831117,"top":0.1452514,"width":0.003656915,"height":0.008778931},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.00831117,"top":0.14604948,"width":0.0016622341,"height":0.007980846}},{"char_start":1,"char_count":1,"bounds":{"left":0.009973404,"top":0.14604948,"width":0.0023271276,"height":0.007980846}}],"role_description":"text"},{"role":"AXRadioButton","text":"Run and Debug (⇧⌘D)","depth":19,"bounds":{"left":0.0,"top":0.16280925,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.17238627,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Remote Explorer","depth":19,"bounds":{"left":0.0,"top":0.20111732,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.21069433,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Extensions (⇧⌘X) - 2 require update","depth":19,"bounds":{"left":0.0,"top":0.23942538,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.2490024,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"2","depth":22,"bounds":{"left":0.009640957,"top":0.2601756,"width":0.0019946808,"height":0.008778931},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Claude Code","depth":19,"bounds":{"left":0.0,"top":0.27773345,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"Containers","depth":19,"bounds":{"left":0.0,"top":0.3160415,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXHeading","text":"EXPLORER","depth":17,"bounds":{"left":0.022606382,"top":0.047885075,"width":0.018949468,"height":0.02793296},"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"EXPLORER","depth":18,"bounds":{"left":0.022606382,"top":0.056664005,"width":0.018949468,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.022606382,"top":0.056664005,"width":0.0023271276,"height":0.0103751}},{"char_start":1,"char_count":7,"bounds":{"left":0.024933511,"top":0.056664005,"width":0.01662234,"height":0.0103751}}],"role_description":"text"},{"role":"AXButton","text":"Explorer Section: screenpipe [SSH: nas]","depth":21,"bounds":{"left":0.015957447,"top":0.07581804,"width":0.09940159,"height":0.017557861},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":true},{"role":"AXStaticText","text":"","depth":23,"bounds":{"left":0.01662234,"top":0.07821229,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"Explorer Section: screenpipe [SSH: nas]","depth":22,"bounds":{"left":0.022606382,"top":0.07581804,"width":0.045877658,"height":0.017557861},"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"SCREENPIPE [SSH: NAS]","depth":23,"bounds":{"left":0.022606382,"top":0.079010375,"width":0.045877658,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.022606382,"top":0.07980846,"width":0.0026595744,"height":0.0103751}},{"char_start":1,"char_count":20,"bounds":{"left":0.025265958,"top":0.07980846,"width":0.043218084,"height":0.0103751}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.09577015,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"#recycle","depth":27,"bounds":{"left":0.025930852,"top":0.09577015,"width":0.017287234,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.096568234,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":7,"bounds":{"left":0.028590426,"top":0.096568234,"width":0.01462766,"height":0.011971269}}],"role_description":"text"}]...
|
996310670335807839
|
-5588377913675525752
|
click
|
accessibility
|
NULL
|
Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧ Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
21094
|
922
|
8
|
2026-05-11T17:12:01.227815+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-11/1778 /Users/lukas/.screenpipe/data/data/2026-05-11/1778519521227_m1.jpg...
|
Code
|
screenpipe_sync.sh — screenpipe [SSH: nas]
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
iTerm2ShellEditViewSessionScriptsProfilesWindowHel iTerm2ShellEditViewSessionScriptsProfilesWindowHelp-zshDOCKER* *81DEV (docker)Last login: Sun May 10 21:10:26 on ttys013₴2APP (-zsh)883-zshPoetry could not find a pyproject.toml file in /Users/lukas or its parentsPoetry could not find a pyproject.toml file in /Users/lukas or its parentslukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~ $ cat ~/.screenpipe/screenpipe_sync.sh | pbcopylukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~$-zsh*5screenpipe"100% <47*8•Mon 11 May 20:12:01T81• ÷6-zshX7...
|
NULL
|
-3200564511080574302
|
NULL
|
click
|
ocr
|
NULL
|
iTerm2ShellEditViewSessionScriptsProfilesWindowHel iTerm2ShellEditViewSessionScriptsProfilesWindowHelp-zshDOCKER* *81DEV (docker)Last login: Sun May 10 21:10:26 on ttys013₴2APP (-zsh)883-zshPoetry could not find a pyproject.toml file in /Users/lukas or its parentsPoetry could not find a pyproject.toml file in /Users/lukas or its parentslukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~ $ cat ~/.screenpipe/screenpipe_sync.sh | pbcopylukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~$-zsh*5screenpipe"100% <47*8•Mon 11 May 20:12:01T81• ÷6-zshX7...
|
21093
|
NULL
|
NULL
|
NULL
|
|
21095
|
923
|
7
|
2026-05-11T17:12:01.227908+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-11/1778 /Users/lukas/.screenpipe/data/data/2026-05-11/1778519521227_m2.jpg...
|
Code
|
screenpipe_sync.sh — screenpipe [SSH: nas]
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
screenpipe sync.sh — screenpipe SSH: nas100% 12P• screenpipe sync.sh — screenpipe SSH: nas100% 12P• мon 11 May 20.12-0108000SioV SCREENPIPE ISSH: NASI> #recycleconsumers> static• .env& cli.py# db.pv•docker-compose.vmli# Dockertilemain.py=requirements.txt→data>logs→oinec• aitianore* aoo settinas.ison=archive.db=archive.db-bal= db salite= dh calite.chmE dh calite-wall$ screennine svnc undated shi$ screenpipe sync.snE screennine dhs apo settinas.isonNUANANN47$ screenpipe sync.sh X•pipe.md• .env* Syncs yesterday (derault)sh 2026-04-15screenpipe sync.sh today# syncs today so farat 3am0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh > /Users/lukas/.screenpipe/sync.log 2>&1-euo pipefailCONFIGDB SRC="S(SCREENPIPE DB:-SHOME/.screenpipe/db.salite}"NAS MOUNIE"SINAS MOUNT:- Volumes Test//screendioe?"NAS DB="<NAS MOUNT/archiive.db"NAS DATA-"CNAS MOUNT /data"LOG FILE="$HOME/.screenpipe/sync.log'SCRIPT_START=$(date +%)local msg="[$(date '+%Y-%m-%d %H:%M:&S')] $**ecno suse" ceend SLus relestep)local now=S(date +%s)]loca elaosedes now - SCRIPT START))Ilocal min=s( elansed ( 60)local sec=s( elansed % 60))printf "\n[+%02dm%02ds] • %s\n" "$min" "$sec" "$*" | tee -a "$LOG_FILE"run salite heredoc() {local startes date +%slprintf"9-26c " "clahel"sqLites"SDB SRC" <<< "$sql" &[PASSWORD_DOTS]g.•g.р*)PROBLEMSOUTPUTAdm1nanypAg00pi lIC_R55g: /volume1/ccreenninee* MI23 Implement and run pipe l..Implement and run oipe logleAamin@DXP4800PLUS-B5F8:/volumel//screenpipe/apps sudo docker exec -it screenpipe-app python cli.py pipe day-recap -=date 2026-04-20Running pipe 'day-recap' for 2026-04-20...• Thinking >• The container started before you updated the .env, so it's using the old placeholder key. Restart it to pick up the new one:ca /vo lumel/screenpipe/appsudo docker compose restart screenoine-aooThen try adain:sudo docker exec -it screenpipe-app python cli.py pipe day-recap --date 2026-04-20Adm1n@DXP4800PLUS-B5F8:/volume1/screenpipe/app$ sudo docker exec -it screenpipe-app python cli.py pipe day-recap --date 2026-04-20Runnina nine 'dav-recan' for 2026-04.20..key is there now but Admin@DXP4800PLUS-B5F8:/volume1/screenpipe/app$ sudo docker exec -it screenpipe-app python cli.py pipe day-recap --date 2026-04-20Runnina oioe 'dav-recao' for 2026-04-20.1• The kev works — it authenticated successfullv. The error is iust that vour Anthropic account has no credits. Go to console.anthropic.com → Plans & Billina and add some credits (a few dollars is enouah fotesting)Once topped up, rerun the same command and it should work.* Esc to focus or unfocus ClaudeM screenpipe_sync.sh€Ask before edit.bash +vO@•|sxOUTIING> TIMELINE*SSH: nas 8 master* ©@0A0 @10 Lukas Kovalik (2 weeks ago) Ln 26, Col 1 Spaces: 2 UTF-8 LF () Shell Script 8 Sign In...
|
NULL
|
-894213556336705329
|
NULL
|
click
|
ocr
|
NULL
|
screenpipe sync.sh — screenpipe SSH: nas100% 12P• screenpipe sync.sh — screenpipe SSH: nas100% 12P• мon 11 May 20.12-0108000SioV SCREENPIPE ISSH: NASI> #recycleconsumers> static• .env& cli.py# db.pv•docker-compose.vmli# Dockertilemain.py=requirements.txt→data>logs→oinec• aitianore* aoo settinas.ison=archive.db=archive.db-bal= db salite= dh calite.chmE dh calite-wall$ screennine svnc undated shi$ screenpipe sync.snE screennine dhs apo settinas.isonNUANANN47$ screenpipe sync.sh X•pipe.md• .env* Syncs yesterday (derault)sh 2026-04-15screenpipe sync.sh today# syncs today so farat 3am0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh > /Users/lukas/.screenpipe/sync.log 2>&1-euo pipefailCONFIGDB SRC="S(SCREENPIPE DB:-SHOME/.screenpipe/db.salite}"NAS MOUNIE"SINAS MOUNT:- Volumes Test//screendioe?"NAS DB="<NAS MOUNT/archiive.db"NAS DATA-"CNAS MOUNT /data"LOG FILE="$HOME/.screenpipe/sync.log'SCRIPT_START=$(date +%)local msg="[$(date '+%Y-%m-%d %H:%M:&S')] $**ecno suse" ceend SLus relestep)local now=S(date +%s)]loca elaosedes now - SCRIPT START))Ilocal min=s( elansed ( 60)local sec=s( elansed % 60))printf "\n[+%02dm%02ds] • %s\n" "$min" "$sec" "$*" | tee -a "$LOG_FILE"run salite heredoc() {local startes date +%slprintf"9-26c " "clahel"sqLites"SDB SRC" <<< "$sql" &[PASSWORD_DOTS]g.•g.р*)PROBLEMSOUTPUTAdm1nanypAg00pi lIC_R55g: /volume1/ccreenninee* MI23 Implement and run pipe l..Implement and run oipe logleAamin@DXP4800PLUS-B5F8:/volumel//screenpipe/apps sudo docker exec -it screenpipe-app python cli.py pipe day-recap -=date 2026-04-20Running pipe 'day-recap' for 2026-04-20...• Thinking >• The container started before you updated the .env, so it's using the old placeholder key. Restart it to pick up the new one:ca /vo lumel/screenpipe/appsudo docker compose restart screenoine-aooThen try adain:sudo docker exec -it screenpipe-app python cli.py pipe day-recap --date 2026-04-20Adm1n@DXP4800PLUS-B5F8:/volume1/screenpipe/app$ sudo docker exec -it screenpipe-app python cli.py pipe day-recap --date 2026-04-20Runnina nine 'dav-recan' for 2026-04.20..key is there now but Admin@DXP4800PLUS-B5F8:/volume1/screenpipe/app$ sudo docker exec -it screenpipe-app python cli.py pipe day-recap --date 2026-04-20Runnina oioe 'dav-recao' for 2026-04-20.1• The kev works — it authenticated successfullv. The error is iust that vour Anthropic account has no credits. Go to console.anthropic.com → Plans & Billina and add some credits (a few dollars is enouah fotesting)Once topped up, rerun the same command and it should work.* Esc to focus or unfocus ClaudeM screenpipe_sync.sh€Ask before edit.bash +vO@•|sxOUTIING> TIMELINE*SSH: nas 8 master* ©@0A0 @10 Lukas Kovalik (2 weeks ago) Ln 26, Col 1 Spaces: 2 UTF-8 LF () Shell Script 8 Sign In...
|
21092
|
NULL
|
NULL
|
NULL
|
|
21096
|
922
|
9
|
2026-05-11T17:12:03.530188+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-11/1778 /Users/lukas/.screenpipe/data/data/2026-05-11/1778519523530_m1.jpg...
|
Code
|
screenpipe_sync.sh — screenpipe [SSH: nas]
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧ Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py
M
db.py
docker-compose.yml
Dockerfile
M
main.py
M
requirements.txt
M
data
logs
pipes
.gitignore
app_settings.json
archive.db
archive.db-bak
U
db.sqlite
db.sqlite-shm
db.sqlite-wal
screenpipe_sync_updated.sh
U
screenpipe_sync.sh
screenpipe.db
Outline Section
OUTLINE
OUTLINE
Timeline Section
TIMELINE
TIMELINE
app_settings.json, Editor Group 1
screenpipe_sync.sh, Editor Group 1
pipe.md, Editor Group 1
.env, Editor Group 1
#!/bin/bash
# screenpipe_sync.sh
# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).
# Also copies the day's video/frame data folder to the NAS.
#
# Usage:
# ./screenpipe_sync.sh # syncs yesterday (default)
# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date
# ./screenpipe_sync.sh today # syncs today so far
#
# Cron example (runs at 3am daily):
# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1
set -euo pipefail
# ─── CONFIG ───────────────────────────────────────────────────────────────────
DB_SRC="${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}"
NAS_MOUNT="${NAS_MOUNT:-/Volumes/Test/screenpipe}"
NAS_DB="$NAS_MOUNT/archive.db"
NAS_DATA="$NAS_MOUNT/data"
LOG_FILE="$HOME/.screenpipe/sync.log"
# ──────────────────────────────────────────────────────────────────────────────
# ─── HELPERS ──────────────────────────────────────────────────────────────────
SCRIPT_START=$(date +%s)
log() {
local msg="[$(date '+%Y-%m-%d %H:%M:%S')] $*"
echo "$msg" | tee -a "$LOG_FILE"
}
step() {
local now=$(date +%s)
local elapsed=$(( now - SCRIPT_START ))
local min=$(( elapsed / 60 ))
local sec=$(( elapsed % 60 ))
printf "\n[+%02dm%02ds] ▶ %s\n" "$min" "$sec" "$*" | tee -a "$LOG_FILE"
}
run_sqlite_heredoc() {
local label="$1"
local sql="$2"
local start=$(date +%s)
printf " %-36s " "$label"
sqlite3 "$DB_SRC" <<< "$sql" &
local pid=$!
local spin=[PASSWORD] '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')
local i=0
while kill -0 "$pid" 2>/dev/null; do
printf "\r %-36s %s " "$label" "${spin[$i]}"
i=$(( (i + 1) % 10 ))
sleep 0.2
done
wait "$pid"
local rc=$?
if [ $rc -ne 0 ]; then
printf "\r %-36s ✗ FAILED\n" "$label" | tee -a "$LOG_FILE"
exit $rc
fi
local dur=$(( $(date +%s) - start ))
printf "\r %-36s ✓ %dm%02ds\n" "$label" "$(( dur / 60 ))" "$(( dur % 60 ))" | tee -a "$LOG_FILE"
}
check() {
local label="$1" got="$2" expected="$3"
if [ "$got" -eq "$expected" ]; then
printf " %-20s %s / %s ✓\n" "$label:" "$got" "$expected"
else
printf " %-20s %s / %s ✗ MISMATCH\n" "$label:" "$got" "$expected"
fi
}
# ──────────────────────────────────────────────────────────────────────────────
# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────
if [ "${1:-}" = "today" ]; then
TARGET_DATE=$(date +%Y-%m-%d)
elif [ -n "${1:-}" ]; then
TARGET_DATE="$1"
if ! [[ "$TARGET_DATE" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then
echo "ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday."
exit 1
fi
else
TARGET_DATE=$(date -v-1d +%Y-%m-%d)
fi
log "========================================"
log "Screenpipe sync starting for: $TARGET_DATE"
log "========================================"
# ─── PREFLIGHT ────────────────────────────────────────────────────────────────
step "Preflight checks"
if [ ! -f "$DB_SRC" ]; then
log "ERROR: Source DB not found at $DB_SRC"; exit 1
fi
printf " %-20s %s (%s)\n" "Source DB:" "OK" "$(du -sh "$DB_SRC" | cut -f1)"
if [ ! -d "$NAS_MOUNT" ]; then
log "ERROR: NAS not mounted at $NAS_MOUNT"; exit 1
fi
printf " %-20s %s\n" "NAS mount:" "OK $NAS_MOUNT"
# Check if DB already synced for this date
DB_ALREADY_SYNCED=false
if [ -f "$NAS_DB" ]; then
EXISTING=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';" 2>/dev/null || echo "0")
if [ "$EXISTING" -gt "0" ]; then
log "Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync"
DB_ALREADY_SYNCED=true
else
printf " %-20s %s (%s)\n" "Archive DB:" "exists" "$(du -sh "$NAS_DB" | cut -f1)"
fi
else
printf " %-20s %s\n" "Archive DB:" "will be created"
fi
# Source data dir for this date
DATA_SRC="$HOME/.screenpipe/data/data/$TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
DATA_SIZE=$(du -sh "$DATA_SRC" | cut -f1)
DATA_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
printf " %-20s %s (%s files, %s)\n" "Data dir:" "OK" "$DATA_FILES" "$DATA_SIZE"
else
printf " %-20s %s\n" "Data dir:" "not found — skipping file copy"
fi
# ─── DB SYNC ──────────────────────────────────────────────────────────────────
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────
step "Counting source rows for $TARGET_DATE"
SRC_FRAMES=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
SRC_ELEMENTS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_UI=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
SRC_OCR=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_MEETINGS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';")
printf " %-20s %s\n" "frames:" "$SRC_FRAMES"
printf " %-20s %s\n" "elements:" "$SRC_ELEMENTS"
printf " %-20s %s\n" "ui_events:" "$SRC_UI"
printf " %-20s %s\n" "ocr_text:" "$SRC_OCR"
printf " %-20s %s\n" "meetings:" "$SRC_MEETINGS"
if [ "$SRC_FRAMES" -eq "0" ]; then
log "No frames found for $TARGET_DATE — skipping DB sync"
DB_ALREADY_SYNCED=true
fi
fi
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── INIT TABLES ──────────────────────────────────────────────────────────
step "Initialising tables, indexes, FTS"
run_sqlite_heredoc "creating tables" "
ATTACH '$NAS_DB' AS nas;
CREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;
CREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;
CREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;
CREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;
DETACH nas;
"
run_sqlite_heredoc "creating indexes" "
ATTACH '$NAS_DB' AS nas;
CREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);
CREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);
DETACH nas;
"
run_sqlite_heredoc "creating FTS tables" "
ATTACH '$NAS_DB' AS nas;
CREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(
text, role, frame_id UNINDEXED,
content='elements', content_rowid='id', tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(
full_text, app_name, window_name, browser_url, id UNINDEXED,
tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(
text_content,
app_name,
window_title,
element_name,
content='ui_events',
content_rowid='id',
tokenize='unicode61'
);
DETACH nas;
"
# ─── SYNC DATA ────────────────────────────────────────────────────────────
step "Syncing data for $TARGET_DATE"
run_sqlite_heredoc "video_chunks" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.video_chunks
SELECT * FROM main.video_chunks
WHERE id IN (
SELECT DISTINCT video_chunk_id FROM main.frames
WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL
);
DETACH nas;
"
run_sqlite_heredoc "frames ($SRC_FRAMES rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.frames
SELECT * FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ocr_text ($SRC_OCR rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ocr_text
SELECT o.* FROM main.ocr_text o
JOIN main.frames f ON o.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ui_events ($SRC_UI rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ui_events
SELECT * FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "elements ($SRC_ELEMENTS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.elements
SELECT e.* FROM main.elements e
JOIN main.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "meetings ($SRC_MEETINGS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.meetings
SELECT * FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';
DETACH nas;
"
# ─── FTS UPDATE ───────────────────────────────────────────────────────────
step "Updating FTS indexes"
run_sqlite_heredoc "elements_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.elements_fts(rowid, text, role)
SELECT e.id, e.text, e.role
FROM nas.elements e
JOIN nas.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE'
AND e.text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "frames_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)
SELECT id, full_text, app_name, window_name, browser_url, id
FROM nas.frames
WHERE date(timestamp) = '$TARGET_DATE'
AND full_text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "ui_events_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)
SELECT id, text_content, app_name, window_title, element_name
FROM nas.ui_events
WHERE date(timestamp) = '$TARGET_DATE'
AND text_content IS NOT NULL;
DETACH nas;
"
# ─── VERIFY DB ────────────────────────────────────────────────────────────
step "Verifying DB"
V_FRAMES=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
V_ELEMENTS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_UI=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
V_OCR=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_MEETINGS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';")
check "frames" "$V_FRAMES" "$SRC_FRAMES"
check "elements" "$V_ELEMENTS" "$SRC_ELEMENTS"
check "ui_events" "$V_UI" "$SRC_UI"
check "ocr_text" "$V_OCR" "$SRC_OCR"
check "meetings" "$V_MEETINGS" "$SRC_MEETINGS"
fi
# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────
# Always runs regardless of DB sync status
step "Copying data folder for $TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
mkdir -p "$NAS_DATA/$TARGET_DATE"
RSYNC_START=$(date +%s)
printf " %-36s " "rsync $TARGET_DATE/ → NAS"
rsync -a --ignore-existing \
"$DATA_SRC/" \
"$NAS_DATA/$TARGET_DATE/" \
2>>"$LOG_FILE"
RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))
COPIED_FILES=$(ls "$NAS_DATA/$TARGET_DATE" | wc -l | tr -d ' ')
SRC_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
COPIED_SIZE=$(du -sh "$NAS_DATA/$TARGET_DATE" | cut -f1)
if [ "$COPIED_FILES" -eq "$SRC_FILES" ]; then
printf "\r %-36s ✓ %dm%02ds (%s files, %s)\n" \
"rsync $TARGET_DATE/ → NAS" \
"$(( RSYNC_DUR / 60 ))" "$(( RSYNC_DUR % 60 ))" \
"$COPIED_FILES" "$COPIED_SIZE" | tee -a "$LOG_FILE"
else
printf "\r %-36s ✗ %s / %s files\n" \
"rsync $TARGET_DATE/ → NAS" "$COPIED_FILES" "$SRC_FILES" | tee -a "$LOG_FILE"
fi
else
printf " %-36s %s\n" "rsync $TARGET_DATE/ → NAS" "skipped (no source dir)"
fi
# ─── SUMMARY ──────────────────────────────────────────────────────────────────
TOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))
DB_SIZE=$(du -sh "$NAS_DB" | cut -f1)
echo ""
log "Archive DB size: $DB_SIZE"
log "Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s"
log "Sync complete for $TARGET_DATE"
log "========================================"
#!/bin/bash
# screenpipe_sync.sh
# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).
# Also copies the day's video/frame data folder to the NAS.
#
# Usage:
# ./screenpipe_sync.sh # syncs yesterday (default)
# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date
# ./screenpipe_sync.sh today # syncs today so far
#
# Cron example (runs at 3am daily):
# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1
set -euo pipefail
# ─── CONFIG ───────────────────────────────────────────────────────────────────
DB_SRC="${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}"
NAS_MOUNT="${NAS_MOUNT:-/Volumes/Test/screenpipe}"
NAS_DB="$NAS_MOUNT/archive.db"
NAS_DATA="$NAS_MOUNT/data"
LOG_FILE="$HOME/.screenpipe/sync.log"
# ──────────────────────────────────────────────────────────────────────────────
# ─── HELPERS ──────────────────────────────────────────────────────────────────
SCRIPT_START=$(date +%s)
log() {
local msg="[$(date '+%Y-%m-%d %H:%M:%S')] $*"
echo "$msg" | tee -a "$LOG_FILE"
}
step() {
local now=$(date +%s)
local elapsed=$(( now - SCRIPT_START ))
local min=$(( elapsed / 60 ))
local sec=$(( elapsed % 60 ))
printf "\n[+%02dm%02ds] ▶ %s\n" "$min" "$sec" "$*" | tee -a "$LOG_FILE"
}
run_sqlite_heredoc() {
local label="$1"
local sql="$2"
local start=$(date +%s)
printf " %-36s " "$label"
sqlite3 "$DB_SRC" <<< "$sql" &
local pid=$!
local spin=[PASSWORD] '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')
local i=0
while kill -0 "$pid" 2>/dev/null; do
printf "\r %-36s %s " "$label" "${spin[$i]}"
i=$(( (i + 1) % 10 ))
sleep 0.2
done
wait "$pid"
local rc=$?
if [ $rc -ne 0 ]; then
printf "\r %-36s ✗ FAILED\n" "$label" | tee -a "$LOG_FILE"
exit $rc
fi
local dur=$(( $(date +%s) - start ))
printf "\r %-36s ✓ %dm%02ds\n" "$label" "$(( dur / 60 ))" "$(( dur % 60 ))" | tee -a "$LOG_FILE"
}
check() {
local label="$1" got="$2" expected="$3"
if [ "$got" -eq "$expected" ]; then
printf " %-20s %s / %s ✓\n" "$label:" "$got" "$expected"
else
printf " %-20s %s / %s ✗ MISMATCH\n" "$label:" "$got" "$expected"
fi
}
# ──────────────────────────────────────────────────────────────────────────────
# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────
if [ "${1:-}" = "today" ]; then
TARGET_DATE=$(date +%Y-%m-%d)
elif [ -n "${1:-}" ]; then
TARGET_DATE="$1"
if ! [[ "$TARGET_DATE" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then
echo "ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday."
exit 1
fi
else
TARGET_DATE=$(date -v-1d +%Y-%m-%d)
fi
log "========================================"
log "Screenpipe sync starting for: $TARGET_DATE"
log "========================================"
# ─── PREFLIGHT ────────────────────────────────────────────────────────────────
step "Preflight checks"
if [ ! -f "$DB_SRC" ]; then
log "ERROR: Source DB not found at $DB_SRC"; exit 1
fi
printf " %-20s %s (%s)\n" "Source DB:" "OK" "$(du -sh "$DB_SRC" | cut -f1)"
if [ ! -d "$NAS_MOUNT" ]; then
log "ERROR: NAS not mounted at $NAS_MOUNT"; exit 1
fi
printf " %-20s %s\n" "NAS mount:" "OK $NAS_MOUNT"
# Check if DB already synced for this date
DB_ALREADY_SYNCED=false
if [ -f "$NAS_DB" ]; then
EXISTING=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';" 2>/dev/null || echo "0")
if [ "$EXISTING" -gt "0" ]; then
log "Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync"
DB_ALREADY_SYNCED=true
else
printf " %-20s %s (%s)\n" "Archive DB:" "exists" "$(du -sh "$NAS_DB" | cut -f1)"
fi
else
printf " %-20s %s\n" "Archive DB:" "will be created"
fi
# Source data dir for this date
DATA_SRC="$HOME/.screenpipe/data/data/$TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
DATA_SIZE=$(du -sh "$DATA_SRC" | cut -f1)
DATA_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
printf " %-20s %s (%s files, %s)\n" "Data dir:" "OK" "$DATA_FILES" "$DATA_SIZE"
else
printf " %-20s %s\n" "Data dir:" "not found — skipping file copy"
fi
# ─── DB SYNC ──────────────────────────────────────────────────────────────────
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────
step "Counting source rows for $TARGET_DATE"
SRC_FRAMES=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
SRC_ELEMENTS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_UI=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
SRC_OCR=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_MEETINGS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';")
printf " %-20s %s\n" "frames:" "$SRC_FRAMES"
printf " %-20s %s\n" "elements:" "$SRC_ELEMENTS"
printf " %-20s %s\n" "ui_events:" "$SRC_UI"
printf " %-20s %s\n" "ocr_text:" "$SRC_OCR"
printf " %-20s %s\n" "meetings:" "$SRC_MEETINGS"
if [ "$SRC_FRAMES" -eq "0" ]; then
log "No frames found for $TARGET_DATE — skipping DB sync"
DB_ALREADY_SYNCED=true
fi
fi
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── INIT TABLES ──────────────────────────────────────────────────────────
step "Initialising tables, indexes, FTS"
run_sqlite_heredoc "creating tables" "
ATTACH '$NAS_DB' AS nas;
CREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;
CREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;
CREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;
CREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;
DETACH nas;
"
run_sqlite_heredoc "creating indexes" "
ATTACH '$NAS_DB' AS nas;
CREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);
CREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);
DETACH nas;
"
run_sqlite_heredoc "creating FTS tables" "
ATTACH '$NAS_DB' AS nas;
CREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(
text, role, frame_id UNINDEXED,
content='elements', content_rowid='id', tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(
full_text, app_name, window_name, browser_url, id UNINDEXED,
tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(
text_content,
app_name,
window_title,
element_name,
content='ui_events',
content_rowid='id',
tokenize='unicode61'
);
DETACH nas;
"
# ─── SYNC DATA ────────────────────────────────────────────────────────────
step "Syncing data for $TARGET_DATE"
run_sqlite_heredoc "video_chunks" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.video_chunks
SELECT * FROM main.video_chunks
WHERE id IN (
SELECT DISTINCT video_chunk_id FROM main.frames
WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL
);
DETACH nas;
"
run_sqlite_heredoc "frames ($SRC_FRAMES rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.frames
SELECT * FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ocr_text ($SRC_OCR rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ocr_text
SELECT o.* FROM main.ocr_text o
JOIN main.frames f ON o.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ui_events ($SRC_UI rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ui_events
SELECT * FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "elements ($SRC_ELEMENTS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.elements
SELECT e.* FROM main.elements e
JOIN main.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "meetings ($SRC_MEETINGS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.meetings
SELECT * FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';
DETACH nas;
"
# ─── FTS UPDATE ───────────────────────────────────────────────────────────
step "Updating FTS indexes"
run_sqlite_heredoc "elements_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.elements_fts(rowid, text, role)
SELECT e.id, e.text, e.role
FROM nas.elements e
JOIN nas.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE'
AND e.text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "frames_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)
SELECT id, full_text, app_name, window_name, browser_url, id
FROM nas.frames
WHERE date(timestamp) = '$TARGET_DATE'
AND full_text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "ui_events_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)
SELECT id, text_content, app_name, window_title, element_name
FROM nas.ui_events
WHERE date(timestamp) = '$TARGET_DATE'
AND text_content IS NOT NULL;
DETACH nas;
"
# ─── VERIFY DB ────────────────────────────────────────────────────────────
step "Verifying DB"
V_FRAMES=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
V_ELEMENTS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_UI=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
V_OCR=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_MEETINGS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';")
check "frames" "$V_FRAMES" "$SRC_FRAMES"
check "elements" "$V_ELEMENTS" "$SRC_ELEMENTS"
check "ui_events" "$V_UI" "$SRC_UI"
check "ocr_text" "$V_OCR" "$SRC_OCR"
check "meetings" "$V_MEETINGS" "$SRC_MEETINGS"
fi
# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────
# Always runs regardless of DB sync status
step "Copying data folder for $TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
mkdir -p "$NAS_DATA/$TARGET_DATE"
RSYNC_START=$(date +%s)
printf " %-36s " "rsync $TARGET_DATE/ → NAS"
rsync -a --ignore-existing \
"$DATA_SRC/" \
"$NAS_DATA/$TARGET_DATE/" \
2>>"$LOG_FILE"
RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))
COPIED_FILES=$(ls "$NAS_DATA/$TARGET_DATE" | wc -l | tr -d ' ')
SRC_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
COPIED_SIZE=$(du -sh "$NAS_DATA/$TARGET_DATE" | cut -f1)
if [ "$COPIED_FILES" -eq "$SRC_FILES" ]; then
printf "\r %-36s ✓ %dm%02ds (%s files, %s)\n" \
"rsync $TARGET_DATE/ → NAS" \
"$(( RSYNC_DUR / 60 ))" "$(( RSYNC_DUR % 60 ))" \
"$COPIED_FILES" "$COPIED_SIZE" | tee -a "$LOG_FILE"
else
printf "\r %-36s ✗ %s / %s files\n" \
"rsync $TARGET_DATE/ → NAS" "$COPIED_FILES" "$SRC_FILES" | tee -a "$LOG_FILE"
fi
else
printf " %-36s %s\n" "rsync $TARGET_DATE/ → NAS" "skipped (no source dir)"
fi
# ─── SUMMARY ──────────────────────────────────────────────────────────────────
TOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))
DB_SIZE=$(du -sh "$NAS_DB" | cut -f1)
echo ""
log "Archive DB size: $DB_SIZE"
log "Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s"
log "Sync complete for $TARGET_DATE"
log "========================================"
Implement and run pipe l…, Editor Group 2
Problems (⇧⌘M)
PROBLEMS
Output (⇧⌘U)
OUTPUT
Debug Console (⇧⌘Y)
DEBUG CONSOLE
Terminal (⌃`)
TERMINAL
Ports - 1 forwarded port
PORTS
1
remote SSH: nas
SSH: nas
screenpipe (Git) - master*, Checkout Branch/Tag...
master*
screenpipe (Git) - Synchronize Changes
No Problems
0
0
Forwarded Ports: 8766
1
Notifications
Sign In
Sign In
Shell Script
Editor Language Status: $(copilot) No inline suggestion available, Inline suggestions
LF
UTF-8
Spaces: 2
Ln 40, Col 23
git-commit Lukas Kovalik (2 weeks ago)
Lukas Kovalik (2 weeks ago)
Info: Setting up SSH Host nas: Setting up SSH tunnel
Implement and run pipe logic
Session history
New session
Message actions
main.py
main.py
lets implement logic with pipes. how can I run it?
Thinking
Thinking
Let me look at the current project structure to understand what's already in place.
Bash
List project files
IN
find /volume1/screenpipe -type f | head -50 && echo "---" && ls /volume1/screenpipe
Copy code to clipboard
OUT
/volume1/screenpipe/.DS_Store
/volume1/screenpipe/screenpipe.db
/volume1/screenpipe/screenpipe_sync.sh
/volume1/screenpipe/app_settings.json
/volume1/screenpipe/.gitignore
/volume1/screenpipe/archive.db
/volume1/screenpipe/db.sqlite
/volume1/screenpipe/db.sqlite-wal
/volume1/screenpipe/db.sqlite-shm
/volume1/screenpipe/#recycle/desktop.ini
/volume1/screenpipe/#recycle/db.sqlite
/volume1/screenpipe/#recycle/Copy #1 of db.sqlite
/volume1/screenpipe/#recycle/.DS_Store
/volume1/screenpipe/#recycle/Copy #2 of db.sqlite
/volume1/screenpipe/#recycle/archive.db
/volume1/screenpipe/#recycle/Copy #1 of archive.db
/volume1/screenpipe/#recycle/Copy #2 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of archive.db
/volume1/screenpipe/#recycle/Copy #4 of archive.db
/volume1/screenpipe/#recycle/Copy #5 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of db.sqlite
/volume1/screenpipe/#recycle/Copy #4 of db.sqlite
/volume1/screenpipe/#recycle/Copy #6 of archive.db
/volume1/screenpipe/#recycle/test.txt
/volume1/screenpipe/#recycle/Copy #7 of archive.db
/volume1/screenpipe/#recycle/Copy #8 of archive.db
/volume1/screenpipe/#recycle/archive.db-journal
/volume1/screenpipe/#recycle/Copy #1 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #2 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #3 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #4 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #6 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #7 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of db.sqlite
/volume1/screenpipe/pipes/.DS_Store
/volume1/screenpipe/app/.env
/volume1/screenpipe/app/cli.py
/volume1/screenpipe/app/.DS_Store
/volume1/screenpipe/app/db.py
/volume1/screenpipe/app/docker-compose.yml
/volume1/screenpipe/app/main.py
/volume1/screenpipe/app/requirements.txt
/volume1/screenpipe/app/Dockerfile
/volume1/screenpipe/data/.DS_Store
/volume1/screenpipe/.git/description
/volume1/screenpipe/.git/HEAD
/volume1/screenpipe/.git/index
/volume1/screenpipe/.git/COMMIT_EDITMSG
/volume1/screenpipe/#recycle/data/.DS_Store
---
app
app_settings.json
archive.db
data
db.sqlite
db.sqlite-shm
db.sqlite-wal
pipes
#recycle
screenpipe.db
screenpipe_sync.sh
Read
main.py
main.py
Bash
Check pipes directory and docker-compose
IN
ls /volume1/screenpipe/pipes/ && ls /volume1/screenpipe/app/ && cat /volume1/screenpipe/app/docker-compose.yml
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
cli.py
consumers
db.py
docker-compose.yml
Dockerfile
main.py
__pycache__
requirements.txt
static
services:
screenpipe-app:
build: .
container_name: screenpipe-app
restart: unless-stopped
ports:
- "8766:8000"
volumes:
- /volume1/screenpipe:/data
env_file:
- .env
environment:
TZ: Europe/Sofia
DB_PATH: /data/db.sqlite
sqlite-web-archive:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-archive
restart: unless-stopped
ports:
- "8767:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/archive.db"]
sqlite-web-live:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-live
restart: unless-stopped
ports:
- "8768:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/db.sqlite"]
Read
requirements.txt
requirements.txt
Bash
Inspect a pipe directory
IN
ls /volume1/screenpipe/pipes/day-recap/ && cat /volume1/screenpipe/pipes/day-recap/pipe.json 2>/dev/null || ls /volume1/screenpipe/pipes/day-recap/
Copy code to clipboard
OUT
pipe.md
pipe.md
Read
cli.py
cli.py
Bash
List all pipes and their contents
IN
ls /volume1/screenpipe/pipes/ && for d in /volume1/screenpipe/pipes/*/; do echo "=== $d ==="; ls "$d"; done
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
=== /volume1/screenpipe/pipes/ai-habits/ ===
pipe.md
=== /volume1/screenpipe/pipes/day-recap/ ===
pipe.md
=== /volume1/screenpipe/pipes/meeting-summary/ ===
pipe.md
=== /volume1/screenpipe/pipes/standup-update/ ===
pipe.md
=== /volume1/screenpipe/pipes/time-breakdown/ ===
pipe.md
=== /volume1/screenpipe/pipes/video-export/ ===
pipe.md
Bash
Read pipe markdown files
IN
cat /volume1/screenpipe/pipes/day-recap/pipe.md && echo "===" && cat /volume1/screenpipe/pipes/meeting-summary/pipe.md 2>/dev/null | head -50
Copy code to clipboard
OUT
---
schedule: manual
enabled: true
template: true
title: Day Recap
description: "Today's accomplishments, key moments, and unfinished work"
icon: "📋"
featured: true
---
Analyze my screen and audio recordings from today (last 16 hours only).
Read screenpipe skill first.
Use this exact format:
## Summary
One sentence: what I mainly did today.
## Accomplishments
- Top 3 things I finished, with timestamps (e.g. "2:30 PM")
- Name specific apps, files, or projects
## Key Moments
- Important things I saw, said, or heard — with timestamps
## Unfinished Work
- What I should continue tomorrow — name the app/file/task
## Patterns
- Apps I used most, topics that came up repeatedly
Only report what you can verify from the data. End with: "**Next step:** [most important thing to continue]"
===
---
schedule: manual
enabled: true
template: true
title: Meeting Summary
description: "Summarize meeting transcript with key takeaways and action items"
icon: "🤝"
featured: false
---
Summarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.
Read screenpipe skill first.
Use this exact format:
## Meeting Summary
One sentence: what this meeting was about.
## Key Takeaways
- Top 3-5 important points discussed
- Include who said what when relevant
## Action Items
- [ ] Task — assigned to whom, deadline if mentioned
- [ ] Task — assigned to whom
## Decisions Made
- List any decisions or agreements reached
## Open Questions
- Anything unresolved or needing follow-up
Keep it concise and actionable.
Thinking
Thinking
Bash
Read summary consumer
IN
ls /volume1/screenpipe/app/consumers/ && cat /volume1/screenpipe/app/consumers/summary.py
Copy code to clipboard
OUT
activity.py
audio.py
elements.py
__init__.py
interactions.py
ocr.py
__pycache__
report.py
summary.py
"""AI summary generator using Claude."""
import os
from datetime import date
from typing import Any
from consumers.activity import app_time, summary_stats, browser_urls, ui_event_summary
from consumers.ocr import deduplicated_text
from consumers.audio import formatted_transcript
SUMMARY_TYPES = {
"day_recap": {
"title": "Day Recap",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
## Audio/speech:
{audio}
Write a concise day recap using EXACTLY this format:
## Summary
One sentence: what I mainly worked on today.
## Accomplishments
- Top 3 things I finished, with approximate times
- Name specific apps, files, or projects
## Key Moments
- Important things seen or heard, with timestamps
## Unfinished Work
- What to continue tomorrow
## Patterns
- Apps used most, topics that came up repeatedly
Only report what you can verify from the data. End with:
**Next step:** [most important thing to continue]""",
},
"standup": {
"title": "Standup Update",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
## Audio/speech:
{audio}
Write a brief standup update:
**Yesterday:** What I worked on (2-3 bullets)
**Today:** What I plan to continue (1-2 bullets)
**Blockers:** Any issues observed (or "None")
Keep it under 150 words. Only report what's verifiable from the data.""",
},
"focus_time": {
"title": "Focus & Distraction Analysis",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
Analyze focus vs distraction patterns:
## Deep Work Periods
- When and how long were sustained focus sessions?
- What was being worked on?
## Distractions
- Which apps/sites were used recreationally?
- How much time was lost to context switching?
## Recommendations
- 2-3 concrete suggestions to improve focus tomorrow
Be specific with times and app names.""",
},
}
def _build_context(for_date: date) -> dict[str, str]:
apps = app_time(for_date)
app_lines = "\n".join(f"- {a['app_name']}: {a['minutes']} min" for a in apps[:20])
urls = browser_urls(for_date, limit=20)
url_lines = "\n".join(
f"- {u['browser_url'][:100]} ({u['minutes']} min)" for u in urls
)
ui_rows = ui_event_summary(for_date)
ui_lines = "\n".join(
f"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches"
for r in ui_rows[:15]
)
ocr_rows = deduplicated_text(for_date, chunk_minutes=5)
ocr_lines = "\n".join(
f"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}"
for r in ocr_rows[:100]
)
audio = formatted_transcript(for_date)
return {
"app_time": app_lines or "(no app data)",
"browser_urls": url_lines or "(no browser data)",
"ui_events": ui_lines or "(no UI event data)",
"ocr_text": ocr_lines or "(no screen data)",
"audio": audio[:3000] if len(audio) > 3000 else audio,
}
def generate(
summary_type: str = "day_recap",
for_date: date | None = None,
api_key: str | None = None,
) -> dict[str, Any]:
"""Generate an AI summary. Returns dict with 'title', 'content', 'date'."""
import anthropic
d = for_date or date.today()
key = api_key or os.environ.get("ANTHROPIC_API_KEY", "")
if not key:
return {
"title": "Error",
"content": "ANTHROPIC_API_KEY not set. Add it to your .env file.",
"date": str(d),
}
spec = SUMMARY_TYPES.get(summary_type)
if not spec:
return {"title": "Error", "content": f"Unknown summary type: {summary_type}", "date": str(d)}
stats = summary_stats(d)
if stats["total_frames"] == 0:
return {
"title": spec["title"],
"content": f"No screen data found for {d}.",
"date": str(d),
}
ctx = _build_context(d)
prompt = spec["prompt"].format(**ctx)
client = anthropic.Anthropic(api_key=key)
message = client.messages.create(
model="claude-haiku-4-5-20251001",
max_tokens=1024,
messages=[{"role": "user", "content": prompt}],
)
return {
"title": spec["title"],
"content": message.content[0].text,
"date": str(d),
"stats": stats,
}
Thinking
Thinking
Bash
Read all pipe.md files
IN
for f in /volume1/screenpipe/pipes/*/pipe.md; do echo "=== $f ==="; cat "$f"; echo; done
Copy code to clipboard
OUT
=== /volume1/screenpipe/pipes/ai-habits/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: AI Habits
description: "How you use AI tools — patterns and insights"
icon: "🤖"
featured: true
---
Search my recordings from the last 24 hours for AI tool usage. Use app_name filter for each tool separately: ChatGPT, Claude, Copilot, Cursor, Gemini, Perplexity. Use limit=5 per search, max 6 searches total.
Read screenpipe skill first.
Use this exact format:
## AI Tools Used
- List each tool with approximate time spent (e.g. "Claude: ~45min")
## What I Used Them For
- For each tool: coding, writing, research, or brainstorming
## Usage Patterns
- Do I switch between tools? Use them in bursts or steadily?
## Effectiveness
- Which tool appeared alongside completed work vs. abandoned attempts
If no AI usage is found, say so clearly. End with: "**Tip:** [one suggestion to use AI tools more effectively]"
=== /volume1/screenpipe/pipes/day-recap/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Day Recap
description: "Today's accomplishments, key moments, and unfinished work"
icon: "📋"
featured: true
---
Analyze my screen and audio recordings from today (last 16 hours only).
Read screenpipe skill first.
Use this exact format:
## Summary
One sentence: what I mainly did today.
## Accomplishments
- Top 3 things I finished, with timestamps (e.g. "2:30 PM")
- Name specific apps, files, or projects
## Key Moments
- Important things I saw, said, or heard — with timestamps
## Unfinished Work
- What I should continue tomorrow — name the app/file/task
## Patterns
- Apps I used most, topics that came up repeatedly
Only report what you can verify from the data. End with: "**Next step:** [most important thing to continue]"
=== /volume1/screenpipe/pipes/meeting-summary/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Meeting Summary
description: "Summarize meeting transcript with key takeaways and action items"
icon: "🤝"
featured: false
---
Summarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.
Read screenpipe skill first.
Use this exact format:
## Meeting Summary
One sentence: what this meeting was about.
## Key Takeaways
- Top 3-5 important points discussed
- Include who said what when relevant
## Action Items
- [ ] Task — assigned to whom, deadline if mentioned
- [ ] Task — assigned to whom
## Decisions Made
- List any decisions or agreements reached
## Open Questions
- Anything unresolved or needing follow-up
Keep it concise and actionable.
=== /volume1/screenpipe/pipes/standup-update/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Standup Update
description: "What you did, what's next, and any blockers"
icon: "🏢"
featured: true
---
Based on my recordings from the last 24 hours, generate a standup update. Use limit=10 per search, max 3 searches total.
Read screenpipe skill first.
Use this exact format:
## Yesterday
- What I worked on (name specific projects, files, tools, PRs)
## Today
- What I will work on next (based on unfinished tasks and recent activity)
## Blockers
- Issues I hit — errors, slow builds, waiting on someone
- If no blockers, write "None"
Keep it under 150 words. Copy-paste ready for a team standup.
=== /volume1/screenpipe/pipes/time-breakdown/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Time Breakdown
description: "Where your time went — by app, project, and category"
icon: "⏱"
featured: false
---
Analyze my app usage from today (last 12 hours). Use limit=10 per search, max 4 searches. Prefer /raw_sql with COUNT/GROUP BY queries.
Read screenpipe skill first.
Use this exact format with durations and percentages:
## By Application
- List each app with duration and percentage, sorted by time (e.g. "VS Code: 2h 15min (28%)")
## By Category
- Group into: coding, meetings, browsing, writing, communication, other
- Show hours and percentage per category
## By Project
- Group related activities by project/topic. Name specific repos or tasks.
## Productivity Score
- Calculate: focused_work_hours / total_hours as a percentage
- Focused = coding + writing. Unfocused = browsing + switching.
End with: "**Suggestion:** [one specific change to improve tomorrow's productivity]"
=== /volume1/screenpipe/pipes/video-export/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Export Video Clip
description: "Create a video of your recent screen activity"
icon: "🎬"
featured: false
---
Export a video of my screen activity from the last 5 minutes.
Read screenpipe skill first.
Use the POST /frames/export endpoint with the time range and fps=1.0. Then show me the exported video file path as an inline code block so I can watch it.
If the export is large, suggest a lower fps or shorter time range.
Thinking
Thinking
Now I have a clear picture. The pipes are markdown prompt templates in
/volume1/screenpipe/pipes/
, but there's no code to actually load and run them —
consumers/summary.py
has its own hardcoded prompts instead.
Here's what I'll implement:
consumers/pipes.py
— dynamically loads pipe.md files and runs them via Claude (data injected as system message, pipe body as user prompt)
main.py
— two new endpoints:
GET /api/pipes
and
POST /api/pipes/{pipe_id}/run
cli.py
— a
pipe
command to run pipes from the terminal
Let me build it:
Bash
Check browser_urls signature
IN
cat /volume1/screenpipe/app/consumers/activity.py | grep "def browser_urls" -A 5
Copy code to clipboard
OUT
def browser_urls(
for_date: date | None = None,
app_name: str | None = None,
ts_from: str | None = None,
ts_to: str | None = None,
limit: int = 30,
Write
pipes.py
pipes.py
143 lines
"""Dynamic pipe loader and runner."""
import os
import re
from datetime import date
from pathlib import Path
from typing import Any
def _parse_frontmatter(text: str) -> tuple[dict, str]:
if not text.startswith("---"):
return {}, text
try:
end = text.index("---", 3)
except ValueError:
return {}, text
fm_text = text[3:end].strip()
body = text[end + 3:].strip()
meta: dict = {}
for line in fm_text.splitlines():
if ":" in line:
k, _, v = line.parti...
|
[{"role":"AXRadioButton","text [{"role":"AXRadioButton","text":"Explorer (⇧⌘E)","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":true},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Search (⇧⌘F)","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Source Control (⌃⇧G) - 10 pending changes","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"10","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Run and Debug (⇧⌘D)","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Remote Explorer","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Extensions (⇧⌘X) - 2 require update","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"2","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Claude Code","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"Containers","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXHeading","text":"EXPLORER","depth":17,"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"EXPLORER","depth":18,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Explorer Section: screenpipe [SSH: nas]","depth":21,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":true},{"role":"AXStaticText","text":"","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"Explorer Section: screenpipe [SSH: nas]","depth":22,"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"SCREENPIPE [SSH: NAS]","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"#recycle","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"app","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"__pycache__","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"consumers","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"static","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":".env","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"cli.py","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.py","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"docker-compose.yml","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Dockerfile","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"main.py","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"requirements.txt","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"data","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"logs","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"pipes","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":".gitignore","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"app_settings.json","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"archive.db","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"archive.db-bak","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"U","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite-shm","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite-wal","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe_sync_updated.sh","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"U","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe_sync.sh","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe.db","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Outline Section","depth":21,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"OUTLINE","depth":22,"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"OUTLINE","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Timeline Section","depth":21,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"TIMELINE","depth":22,"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"TIMELINE","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"app_settings.json, Editor Group 1","depth":28,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"screenpipe_sync.sh, Editor Group 1","depth":28,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":false},{"role":"AXRadioButton","text":"pipe.md, Editor Group 1","depth":28,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":".env, Editor Group 1","depth":28,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"#!/bin/bash\n# screenpipe_sync.sh\n# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).\n# Also copies the day's video/frame data folder to the NAS.\n#\n# Usage:\n# ./screenpipe_sync.sh # syncs yesterday (default)\n# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date\n# ./screenpipe_sync.sh today # syncs today so far\n#\n# Cron example (runs at 3am daily):\n# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1\n\nset -euo pipefail\n\n# ─── CONFIG ───────────────────────────────────────────────────────────────────\nDB_SRC=\"${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}\"\nNAS_MOUNT=\"${NAS_MOUNT:-/Volumes/Test/screenpipe}\"\nNAS_DB=\"$NAS_MOUNT/archive.db\"\nNAS_DATA=\"$NAS_MOUNT/data\"\nLOG_FILE=\"$HOME/.screenpipe/sync.log\"\n# ──────────────────────────────────────────────────────────────────────────────\n\n# ─── HELPERS ──────────────────────────────────────────────────────────────────\nSCRIPT_START=$(date +%s)\n\nlog() {\n local msg=\"[$(date '+%Y-%m-%d %H:%M:%S')] $*\"\n echo \"$msg\" | tee -a \"$LOG_FILE\"\n}\n\nstep() {\n local now=$(date +%s)\n local elapsed=$(( now - SCRIPT_START ))\n local min=$(( elapsed / 60 ))\n local sec=$(( elapsed % 60 ))\n printf \"\\n[+%02dm%02ds] ▶ %s\\n\" \"$min\" \"$sec\" \"$*\" | tee -a \"$LOG_FILE\"\n}\n\nrun_sqlite_heredoc() {\n local label=\"$1\"\n local sql=\"$2\"\n local start=$(date +%s)\n\n printf \" %-36s \" \"$label\"\n\n sqlite3 \"$DB_SRC\" <<< \"$sql\" &\n local pid=$!\n local spin=('⠋' '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')\n local i=0\n while kill -0 \"$pid\" 2>/dev/null; do\n printf \"\\r %-36s %s \" \"$label\" \"${spin[$i]}\"\n i=$(( (i + 1) % 10 ))\n sleep 0.2\n done\n wait \"$pid\"\n local rc=$?\n if [ $rc -ne 0 ]; then\n printf \"\\r %-36s ✗ FAILED\\n\" \"$label\" | tee -a \"$LOG_FILE\"\n exit $rc\n fi\n\n local dur=$(( $(date +%s) - start ))\n printf \"\\r %-36s ✓ %dm%02ds\\n\" \"$label\" \"$(( dur / 60 ))\" \"$(( dur % 60 ))\" | tee -a \"$LOG_FILE\"\n}\n\ncheck() {\n local label=\"$1\" got=\"$2\" expected=\"$3\"\n if [ \"$got\" -eq \"$expected\" ]; then\n printf \" %-20s %s / %s ✓\\n\" \"$label:\" \"$got\" \"$expected\"\n else\n printf \" %-20s %s / %s ✗ MISMATCH\\n\" \"$label:\" \"$got\" \"$expected\"\n fi\n}\n# ──────────────────────────────────────────────────────────────────────────────\n\n# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────\nif [ \"${1:-}\" = \"today\" ]; then\n TARGET_DATE=$(date +%Y-%m-%d)\nelif [ -n \"${1:-}\" ]; then\n TARGET_DATE=\"$1\"\n if ! [[ \"$TARGET_DATE\" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then\n echo \"ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday.\"\n exit 1\n fi\nelse\n TARGET_DATE=$(date -v-1d +%Y-%m-%d)\nfi\n\nlog \"========================================\"\nlog \"Screenpipe sync starting for: $TARGET_DATE\"\nlog \"========================================\"\n\n# ─── PREFLIGHT ────────────────────────────────────────────────────────────────\nstep \"Preflight checks\"\n\nif [ ! -f \"$DB_SRC\" ]; then\n log \"ERROR: Source DB not found at $DB_SRC\"; exit 1\nfi\nprintf \" %-20s %s (%s)\\n\" \"Source DB:\" \"OK\" \"$(du -sh \"$DB_SRC\" | cut -f1)\"\n\nif [ ! -d \"$NAS_MOUNT\" ]; then\n log \"ERROR: NAS not mounted at $NAS_MOUNT\"; exit 1\nfi\nprintf \" %-20s %s\\n\" \"NAS mount:\" \"OK $NAS_MOUNT\"\n\n# Check if DB already synced for this date\nDB_ALREADY_SYNCED=false\nif [ -f \"$NAS_DB\" ]; then\n EXISTING=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\" 2>/dev/null || echo \"0\")\n if [ \"$EXISTING\" -gt \"0\" ]; then\n log \"Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync\"\n DB_ALREADY_SYNCED=true\n else\n printf \" %-20s %s (%s)\\n\" \"Archive DB:\" \"exists\" \"$(du -sh \"$NAS_DB\" | cut -f1)\"\n fi\nelse\n printf \" %-20s %s\\n\" \"Archive DB:\" \"will be created\"\nfi\n\n# Source data dir for this date\nDATA_SRC=\"$HOME/.screenpipe/data/data/$TARGET_DATE\"\nif [ -d \"$DATA_SRC\" ]; then\n DATA_SIZE=$(du -sh \"$DATA_SRC\" | cut -f1)\n DATA_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n printf \" %-20s %s (%s files, %s)\\n\" \"Data dir:\" \"OK\" \"$DATA_FILES\" \"$DATA_SIZE\"\nelse\n printf \" %-20s %s\\n\" \"Data dir:\" \"not found — skipping file copy\"\nfi\n\n# ─── DB SYNC ──────────────────────────────────────────────────────────────────\nif [ \"$DB_ALREADY_SYNCED\" = false ]; then\n\n # ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────\n step \"Counting source rows for $TARGET_DATE\"\n\n SRC_FRAMES=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\")\n SRC_ELEMENTS=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n SRC_UI=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';\")\n SRC_OCR=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n SRC_MEETINGS=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';\")\n\n printf \" %-20s %s\\n\" \"frames:\" \"$SRC_FRAMES\"\n printf \" %-20s %s\\n\" \"elements:\" \"$SRC_ELEMENTS\"\n printf \" %-20s %s\\n\" \"ui_events:\" \"$SRC_UI\"\n printf \" %-20s %s\\n\" \"ocr_text:\" \"$SRC_OCR\"\n printf \" %-20s %s\\n\" \"meetings:\" \"$SRC_MEETINGS\"\n\n if [ \"$SRC_FRAMES\" -eq \"0\" ]; then\n log \"No frames found for $TARGET_DATE — skipping DB sync\"\n DB_ALREADY_SYNCED=true\n fi\n\nfi\n\nif [ \"$DB_ALREADY_SYNCED\" = false ]; then\n\n # ─── INIT TABLES ──────────────────────────────────────────────────────────\n step \"Initialising tables, indexes, FTS\"\n\n run_sqlite_heredoc \"creating tables\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"creating indexes\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);\nCREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);\nCREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"creating FTS tables\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(\n text, role, frame_id UNINDEXED,\n content='elements', content_rowid='id', tokenize='unicode61'\n);\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(\n full_text, app_name, window_name, browser_url, id UNINDEXED,\n tokenize='unicode61'\n);\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(\n text_content,\n app_name,\n window_title,\n element_name,\n content='ui_events',\n content_rowid='id',\n tokenize='unicode61'\n);\nDETACH nas;\n\"\n\n # ─── SYNC DATA ────────────────────────────────────────────────────────────\n step \"Syncing data for $TARGET_DATE\"\n\n run_sqlite_heredoc \"video_chunks\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.video_chunks\n SELECT * FROM main.video_chunks\n WHERE id IN (\n SELECT DISTINCT video_chunk_id FROM main.frames\n WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL\n );\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames ($SRC_FRAMES rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.frames\n SELECT * FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ocr_text ($SRC_OCR rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ocr_text\n SELECT o.* FROM main.ocr_text o\n JOIN main.frames f ON o.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events ($SRC_UI rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ui_events\n SELECT * FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"elements ($SRC_ELEMENTS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.elements\n SELECT e.* FROM main.elements e\n JOIN main.frames f ON e.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"meetings ($SRC_MEETINGS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.meetings\n SELECT * FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n # ─── FTS UPDATE ───────────────────────────────────────────────────────────\n step \"Updating FTS indexes\"\n\n run_sqlite_heredoc \"elements_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.elements_fts(rowid, text, role)\n SELECT e.id, e.text, e.role\n FROM nas.elements e\n JOIN nas.frames f ON e.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE'\n AND e.text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)\n SELECT id, full_text, app_name, window_name, browser_url, id\n FROM nas.frames\n WHERE date(timestamp) = '$TARGET_DATE'\n AND full_text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)\n SELECT id, text_content, app_name, window_title, element_name\n FROM nas.ui_events\n WHERE date(timestamp) = '$TARGET_DATE'\n AND text_content IS NOT NULL;\nDETACH nas;\n\"\n\n # ─── VERIFY DB ────────────────────────────────────────────────────────────\n step \"Verifying DB\"\n\n V_FRAMES=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\")\n V_ELEMENTS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n V_UI=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';\")\n V_OCR=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n V_MEETINGS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';\")\n\n check \"frames\" \"$V_FRAMES\" \"$SRC_FRAMES\"\n check \"elements\" \"$V_ELEMENTS\" \"$SRC_ELEMENTS\"\n check \"ui_events\" \"$V_UI\" \"$SRC_UI\"\n check \"ocr_text\" \"$V_OCR\" \"$SRC_OCR\"\n check \"meetings\" \"$V_MEETINGS\" \"$SRC_MEETINGS\"\n\nfi\n\n# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────\n# Always runs regardless of DB sync status\nstep \"Copying data folder for $TARGET_DATE\"\n\nif [ -d \"$DATA_SRC\" ]; then\n mkdir -p \"$NAS_DATA/$TARGET_DATE\"\n RSYNC_START=$(date +%s)\n printf \" %-36s \" \"rsync $TARGET_DATE/ → NAS\"\n rsync -a --ignore-existing \\\n \"$DATA_SRC/\" \\\n \"$NAS_DATA/$TARGET_DATE/\" \\\n 2>>\"$LOG_FILE\"\n RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))\n COPIED_FILES=$(ls \"$NAS_DATA/$TARGET_DATE\" | wc -l | tr -d ' ')\n SRC_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n COPIED_SIZE=$(du -sh \"$NAS_DATA/$TARGET_DATE\" | cut -f1)\n if [ \"$COPIED_FILES\" -eq \"$SRC_FILES\" ]; then\n printf \"\\r %-36s ✓ %dm%02ds (%s files, %s)\\n\" \\\n \"rsync $TARGET_DATE/ → NAS\" \\\n \"$(( RSYNC_DUR / 60 ))\" \"$(( RSYNC_DUR % 60 ))\" \\\n \"$COPIED_FILES\" \"$COPIED_SIZE\" | tee -a \"$LOG_FILE\"\n else\n printf \"\\r %-36s ✗ %s / %s files\\n\" \\\n \"rsync $TARGET_DATE/ → NAS\" \"$COPIED_FILES\" \"$SRC_FILES\" | tee -a \"$LOG_FILE\"\n fi\nelse\n printf \" %-36s %s\\n\" \"rsync $TARGET_DATE/ → NAS\" \"skipped (no source dir)\"\nfi\n\n# ─── SUMMARY ──────────────────────────────────────────────────────────────────\nTOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))\nDB_SIZE=$(du -sh \"$NAS_DB\" | cut -f1)\n\necho \"\"\nlog \"Archive DB size: $DB_SIZE\"\nlog \"Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s\"\nlog \"Sync complete for $TARGET_DATE\"\nlog \"========================================\"","depth":28,"on_screen":true,"value":"#!/bin/bash\n# screenpipe_sync.sh\n# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).\n# Also copies the day's video/frame data folder to the NAS.\n#\n# Usage:\n# ./screenpipe_sync.sh # syncs yesterday (default)\n# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date\n# ./screenpipe_sync.sh today # syncs today so far\n#\n# Cron example (runs at 3am daily):\n# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1\n\nset -euo pipefail\n\n# ─── CONFIG ───────────────────────────────────────────────────────────────────\nDB_SRC=\"${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}\"\nNAS_MOUNT=\"${NAS_MOUNT:-/Volumes/Test/screenpipe}\"\nNAS_DB=\"$NAS_MOUNT/archive.db\"\nNAS_DATA=\"$NAS_MOUNT/data\"\nLOG_FILE=\"$HOME/.screenpipe/sync.log\"\n# ──────────────────────────────────────────────────────────────────────────────\n\n# ─── HELPERS ──────────────────────────────────────────────────────────────────\nSCRIPT_START=$(date +%s)\n\nlog() {\n local msg=\"[$(date '+%Y-%m-%d %H:%M:%S')] $*\"\n echo \"$msg\" | tee -a \"$LOG_FILE\"\n}\n\nstep() {\n local now=$(date +%s)\n local elapsed=$(( now - SCRIPT_START ))\n local min=$(( elapsed / 60 ))\n local sec=$(( elapsed % 60 ))\n printf \"\\n[+%02dm%02ds] ▶ %s\\n\" \"$min\" \"$sec\" \"$*\" | tee -a \"$LOG_FILE\"\n}\n\nrun_sqlite_heredoc() {\n local label=\"$1\"\n local sql=\"$2\"\n local start=$(date +%s)\n\n printf \" %-36s \" \"$label\"\n\n sqlite3 \"$DB_SRC\" <<< \"$sql\" &\n local pid=$!\n local spin=('⠋' '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')\n local i=0\n while kill -0 \"$pid\" 2>/dev/null; do\n printf \"\\r %-36s %s \" \"$label\" \"${spin[$i]}\"\n i=$(( (i + 1) % 10 ))\n sleep 0.2\n done\n wait \"$pid\"\n local rc=$?\n if [ $rc -ne 0 ]; then\n printf \"\\r %-36s ✗ FAILED\\n\" \"$label\" | tee -a \"$LOG_FILE\"\n exit $rc\n fi\n\n local dur=$(( $(date +%s) - start ))\n printf \"\\r %-36s ✓ %dm%02ds\\n\" \"$label\" \"$(( dur / 60 ))\" \"$(( dur % 60 ))\" | tee -a \"$LOG_FILE\"\n}\n\ncheck() {\n local label=\"$1\" got=\"$2\" expected=\"$3\"\n if [ \"$got\" -eq \"$expected\" ]; then\n printf \" %-20s %s / %s ✓\\n\" \"$label:\" \"$got\" \"$expected\"\n else\n printf \" %-20s %s / %s ✗ MISMATCH\\n\" \"$label:\" \"$got\" \"$expected\"\n fi\n}\n# ──────────────────────────────────────────────────────────────────────────────\n\n# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────\nif [ \"${1:-}\" = \"today\" ]; then\n TARGET_DATE=$(date +%Y-%m-%d)\nelif [ -n \"${1:-}\" ]; then\n TARGET_DATE=\"$1\"\n if ! [[ \"$TARGET_DATE\" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then\n echo \"ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday.\"\n exit 1\n fi\nelse\n TARGET_DATE=$(date -v-1d +%Y-%m-%d)\nfi\n\nlog \"========================================\"\nlog \"Screenpipe sync starting for: $TARGET_DATE\"\nlog \"========================================\"\n\n# ─── PREFLIGHT ────────────────────────────────────────────────────────────────\nstep \"Preflight checks\"\n\nif [ ! -f \"$DB_SRC\" ]; then\n log \"ERROR: Source DB not found at $DB_SRC\"; exit 1\nfi\nprintf \" %-20s %s (%s)\\n\" \"Source DB:\" \"OK\" \"$(du -sh \"$DB_SRC\" | cut -f1)\"\n\nif [ ! -d \"$NAS_MOUNT\" ]; then\n log \"ERROR: NAS not mounted at $NAS_MOUNT\"; exit 1\nfi\nprintf \" %-20s %s\\n\" \"NAS mount:\" \"OK $NAS_MOUNT\"\n\n# Check if DB already synced for this date\nDB_ALREADY_SYNCED=false\nif [ -f \"$NAS_DB\" ]; then\n EXISTING=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\" 2>/dev/null || echo \"0\")\n if [ \"$EXISTING\" -gt \"0\" ]; then\n log \"Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync\"\n DB_ALREADY_SYNCED=true\n else\n printf \" %-20s %s (%s)\\n\" \"Archive DB:\" \"exists\" \"$(du -sh \"$NAS_DB\" | cut -f1)\"\n fi\nelse\n printf \" %-20s %s\\n\" \"Archive DB:\" \"will be created\"\nfi\n\n# Source data dir for this date\nDATA_SRC=\"$HOME/.screenpipe/data/data/$TARGET_DATE\"\nif [ -d \"$DATA_SRC\" ]; then\n DATA_SIZE=$(du -sh \"$DATA_SRC\" | cut -f1)\n DATA_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n printf \" %-20s %s (%s files, %s)\\n\" \"Data dir:\" \"OK\" \"$DATA_FILES\" \"$DATA_SIZE\"\nelse\n printf \" %-20s %s\\n\" \"Data dir:\" \"not found — skipping file copy\"\nfi\n\n# ─── DB SYNC ──────────────────────────────────────────────────────────────────\nif [ \"$DB_ALREADY_SYNCED\" = false ]; then\n\n # ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────\n step \"Counting source rows for $TARGET_DATE\"\n\n SRC_FRAMES=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\")\n SRC_ELEMENTS=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n SRC_UI=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';\")\n SRC_OCR=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n SRC_MEETINGS=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';\")\n\n printf \" %-20s %s\\n\" \"frames:\" \"$SRC_FRAMES\"\n printf \" %-20s %s\\n\" \"elements:\" \"$SRC_ELEMENTS\"\n printf \" %-20s %s\\n\" \"ui_events:\" \"$SRC_UI\"\n printf \" %-20s %s\\n\" \"ocr_text:\" \"$SRC_OCR\"\n printf \" %-20s %s\\n\" \"meetings:\" \"$SRC_MEETINGS\"\n\n if [ \"$SRC_FRAMES\" -eq \"0\" ]; then\n log \"No frames found for $TARGET_DATE — skipping DB sync\"\n DB_ALREADY_SYNCED=true\n fi\n\nfi\n\nif [ \"$DB_ALREADY_SYNCED\" = false ]; then\n\n # ─── INIT TABLES ──────────────────────────────────────────────────────────\n step \"Initialising tables, indexes, FTS\"\n\n run_sqlite_heredoc \"creating tables\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"creating indexes\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);\nCREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);\nCREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"creating FTS tables\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(\n text, role, frame_id UNINDEXED,\n content='elements', content_rowid='id', tokenize='unicode61'\n);\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(\n full_text, app_name, window_name, browser_url, id UNINDEXED,\n tokenize='unicode61'\n);\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(\n text_content,\n app_name,\n window_title,\n element_name,\n content='ui_events',\n content_rowid='id',\n tokenize='unicode61'\n);\nDETACH nas;\n\"\n\n # ─── SYNC DATA ────────────────────────────────────────────────────────────\n step \"Syncing data for $TARGET_DATE\"\n\n run_sqlite_heredoc \"video_chunks\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.video_chunks\n SELECT * FROM main.video_chunks\n WHERE id IN (\n SELECT DISTINCT video_chunk_id FROM main.frames\n WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL\n );\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames ($SRC_FRAMES rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.frames\n SELECT * FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ocr_text ($SRC_OCR rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ocr_text\n SELECT o.* FROM main.ocr_text o\n JOIN main.frames f ON o.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events ($SRC_UI rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ui_events\n SELECT * FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"elements ($SRC_ELEMENTS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.elements\n SELECT e.* FROM main.elements e\n JOIN main.frames f ON e.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"meetings ($SRC_MEETINGS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.meetings\n SELECT * FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n # ─── FTS UPDATE ───────────────────────────────────────────────────────────\n step \"Updating FTS indexes\"\n\n run_sqlite_heredoc \"elements_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.elements_fts(rowid, text, role)\n SELECT e.id, e.text, e.role\n FROM nas.elements e\n JOIN nas.frames f ON e.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE'\n AND e.text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)\n SELECT id, full_text, app_name, window_name, browser_url, id\n FROM nas.frames\n WHERE date(timestamp) = '$TARGET_DATE'\n AND full_text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)\n SELECT id, text_content, app_name, window_title, element_name\n FROM nas.ui_events\n WHERE date(timestamp) = '$TARGET_DATE'\n AND text_content IS NOT NULL;\nDETACH nas;\n\"\n\n # ─── VERIFY DB ────────────────────────────────────────────────────────────\n step \"Verifying DB\"\n\n V_FRAMES=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\")\n V_ELEMENTS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n V_UI=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';\")\n V_OCR=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n V_MEETINGS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';\")\n\n check \"frames\" \"$V_FRAMES\" \"$SRC_FRAMES\"\n check \"elements\" \"$V_ELEMENTS\" \"$SRC_ELEMENTS\"\n check \"ui_events\" \"$V_UI\" \"$SRC_UI\"\n check \"ocr_text\" \"$V_OCR\" \"$SRC_OCR\"\n check \"meetings\" \"$V_MEETINGS\" \"$SRC_MEETINGS\"\n\nfi\n\n# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────\n# Always runs regardless of DB sync status\nstep \"Copying data folder for $TARGET_DATE\"\n\nif [ -d \"$DATA_SRC\" ]; then\n mkdir -p \"$NAS_DATA/$TARGET_DATE\"\n RSYNC_START=$(date +%s)\n printf \" %-36s \" \"rsync $TARGET_DATE/ → NAS\"\n rsync -a --ignore-existing \\\n \"$DATA_SRC/\" \\\n \"$NAS_DATA/$TARGET_DATE/\" \\\n 2>>\"$LOG_FILE\"\n RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))\n COPIED_FILES=$(ls \"$NAS_DATA/$TARGET_DATE\" | wc -l | tr -d ' ')\n SRC_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n COPIED_SIZE=$(du -sh \"$NAS_DATA/$TARGET_DATE\" | cut -f1)\n if [ \"$COPIED_FILES\" -eq \"$SRC_FILES\" ]; then\n printf \"\\r %-36s ✓ %dm%02ds (%s files, %s)\\n\" \\\n \"rsync $TARGET_DATE/ → NAS\" \\\n \"$(( RSYNC_DUR / 60 ))\" \"$(( RSYNC_DUR % 60 ))\" \\\n \"$COPIED_FILES\" \"$COPIED_SIZE\" | tee -a \"$LOG_FILE\"\n else\n printf \"\\r %-36s ✗ %s / %s files\\n\" \\\n \"rsync $TARGET_DATE/ → NAS\" \"$COPIED_FILES\" \"$SRC_FILES\" | tee -a \"$LOG_FILE\"\n fi\nelse\n printf \" %-36s %s\\n\" \"rsync $TARGET_DATE/ → NAS\" \"skipped (no source dir)\"\nfi\n\n# ─── SUMMARY ──────────────────────────────────────────────────────────────────\nTOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))\nDB_SIZE=$(du -sh \"$NAS_DB\" | cut -f1)\n\necho \"\"\nlog \"Archive DB size: $DB_SIZE\"\nlog \"Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s\"\nlog \"Sync complete for $TARGET_DATE\"\nlog \"========================================\"","role_description":"editor","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"#!/bin/bash\n# screenpipe_sync.sh\n# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).\n# Also copies the day's video/frame data folder to the NAS.\n#\n# Usage:\n# ./screenpipe_sync.sh # syncs yesterday (default)\n# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date\n# ./screenpipe_sync.sh today # syncs today so far\n#\n# Cron example (runs at 3am daily):\n# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1\n\nset -euo pipefail\n\n# ─── CONFIG ───────────────────────────────────────────────────────────────────\nDB_SRC=\"${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}\"\nNAS_MOUNT=\"${NAS_MOUNT:-/Volumes/Test/screenpipe}\"\nNAS_DB=\"$NAS_MOUNT/archive.db\"\nNAS_DATA=\"$NAS_MOUNT/data\"\nLOG_FILE=\"$HOME/.screenpipe/sync.log\"\n# ──────────────────────────────────────────────────────────────────────────────\n\n# ─── HELPERS ──────────────────────────────────────────────────────────────────\nSCRIPT_START=$(date +%s)\n\nlog() {\n local msg=\"[$(date '+%Y-%m-%d %H:%M:%S')] $*\"\n echo \"$msg\" | tee -a \"$LOG_FILE\"\n}\n\nstep() {\n local now=$(date +%s)\n local elapsed=$(( now - SCRIPT_START ))\n local min=$(( elapsed / 60 ))\n local sec=$(( elapsed % 60 ))\n printf \"\\n[+%02dm%02ds] ▶ %s\\n\" \"$min\" \"$sec\" \"$*\" | tee -a \"$LOG_FILE\"\n}\n\nrun_sqlite_heredoc() {\n local label=\"$1\"\n local sql=\"$2\"\n local start=$(date +%s)\n\n printf \" %-36s \" \"$label\"\n\n sqlite3 \"$DB_SRC\" <<< \"$sql\" &\n local pid=$!\n local spin=('⠋' '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')\n local i=0\n while kill -0 \"$pid\" 2>/dev/null; do\n printf \"\\r %-36s %s \" \"$label\" \"${spin[$i]}\"\n i=$(( (i + 1) % 10 ))\n sleep 0.2\n done\n wait \"$pid\"\n local rc=$?\n if [ $rc -ne 0 ]; then\n printf \"\\r %-36s ✗ FAILED\\n\" \"$label\" | tee -a \"$LOG_FILE\"\n exit $rc\n fi\n\n local dur=$(( $(date +%s) - start ))\n printf \"\\r %-36s ✓ %dm%02ds\\n\" \"$label\" \"$(( dur / 60 ))\" \"$(( dur % 60 ))\" | tee -a \"$LOG_FILE\"\n}\n\ncheck() {\n local label=\"$1\" got=\"$2\" expected=\"$3\"\n if [ \"$got\" -eq \"$expected\" ]; then\n printf \" %-20s %s / %s ✓\\n\" \"$label:\" \"$got\" \"$expected\"\n else\n printf \" %-20s %s / %s ✗ MISMATCH\\n\" \"$label:\" \"$got\" \"$expected\"\n fi\n}\n# ──────────────────────────────────────────────────────────────────────────────\n\n# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────\nif [ \"${1:-}\" = \"today\" ]; then\n TARGET_DATE=$(date +%Y-%m-%d)\nelif [ -n \"${1:-}\" ]; then\n TARGET_DATE=\"$1\"\n if ! [[ \"$TARGET_DATE\" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then\n echo \"ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday.\"\n exit 1\n fi\nelse\n TARGET_DATE=$(date -v-1d +%Y-%m-%d)\nfi\n\nlog \"========================================\"\nlog \"Screenpipe sync starting for: $TARGET_DATE\"\nlog \"========================================\"\n\n# ─── PREFLIGHT ────────────────────────────────────────────────────────────────\nstep \"Preflight checks\"\n\nif [ ! -f \"$DB_SRC\" ]; then\n log \"ERROR: Source DB not found at $DB_SRC\"; exit 1\nfi\nprintf \" %-20s %s (%s)\\n\" \"Source DB:\" \"OK\" \"$(du -sh \"$DB_SRC\" | cut -f1)\"\n\nif [ ! -d \"$NAS_MOUNT\" ]; then\n log \"ERROR: NAS not mounted at $NAS_MOUNT\"; exit 1\nfi\nprintf \" %-20s %s\\n\" \"NAS mount:\" \"OK $NAS_MOUNT\"\n\n# Check if DB already synced for this date\nDB_ALREADY_SYNCED=false\nif [ -f \"$NAS_DB\" ]; then\n EXISTING=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\" 2>/dev/null || echo \"0\")\n if [ \"$EXISTING\" -gt \"0\" ]; then\n log \"Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync\"\n DB_ALREADY_SYNCED=true\n else\n printf \" %-20s %s (%s)\\n\" \"Archive DB:\" \"exists\" \"$(du -sh \"$NAS_DB\" | cut -f1)\"\n fi\nelse\n printf \" %-20s %s\\n\" \"Archive DB:\" \"will be created\"\nfi\n\n# Source data dir for this date\nDATA_SRC=\"$HOME/.screenpipe/data/data/$TARGET_DATE\"\nif [ -d \"$DATA_SRC\" ]; then\n DATA_SIZE=$(du -sh \"$DATA_SRC\" | cut -f1)\n DATA_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n printf \" %-20s %s (%s files, %s)\\n\" \"Data dir:\" \"OK\" \"$DATA_FILES\" \"$DATA_SIZE\"\nelse\n printf \" %-20s %s\\n\" \"Data dir:\" \"not found — skipping file copy\"\nfi\n\n# ─── DB SYNC ──────────────────────────────────────────────────────────────────\nif [ \"$DB_ALREADY_SYNCED\" = false ]; then\n\n # ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────\n step \"Counting source rows for $TARGET_DATE\"\n\n SRC_FRAMES=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\")\n SRC_ELEMENTS=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n SRC_UI=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';\")\n SRC_OCR=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n SRC_MEETINGS=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';\")\n\n printf \" %-20s %s\\n\" \"frames:\" \"$SRC_FRAMES\"\n printf \" %-20s %s\\n\" \"elements:\" \"$SRC_ELEMENTS\"\n printf \" %-20s %s\\n\" \"ui_events:\" \"$SRC_UI\"\n printf \" %-20s %s\\n\" \"ocr_text:\" \"$SRC_OCR\"\n printf \" %-20s %s\\n\" \"meetings:\" \"$SRC_MEETINGS\"\n\n if [ \"$SRC_FRAMES\" -eq \"0\" ]; then\n log \"No frames found for $TARGET_DATE — skipping DB sync\"\n DB_ALREADY_SYNCED=true\n fi\n\nfi\n\nif [ \"$DB_ALREADY_SYNCED\" = false ]; then\n\n # ─── INIT TABLES ──────────────────────────────────────────────────────────\n step \"Initialising tables, indexes, FTS\"\n\n run_sqlite_heredoc \"creating tables\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"creating indexes\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);\nCREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);\nCREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"creating FTS tables\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(\n text, role, frame_id UNINDEXED,\n content='elements', content_rowid='id', tokenize='unicode61'\n);\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(\n full_text, app_name, window_name, browser_url, id UNINDEXED,\n tokenize='unicode61'\n);\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(\n text_content,\n app_name,\n window_title,\n element_name,\n content='ui_events',\n content_rowid='id',\n tokenize='unicode61'\n);\nDETACH nas;\n\"\n\n # ─── SYNC DATA ────────────────────────────────────────────────────────────\n step \"Syncing data for $TARGET_DATE\"\n\n run_sqlite_heredoc \"video_chunks\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.video_chunks\n SELECT * FROM main.video_chunks\n WHERE id IN (\n SELECT DISTINCT video_chunk_id FROM main.frames\n WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL\n );\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames ($SRC_FRAMES rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.frames\n SELECT * FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ocr_text ($SRC_OCR rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ocr_text\n SELECT o.* FROM main.ocr_text o\n JOIN main.frames f ON o.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events ($SRC_UI rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ui_events\n SELECT * FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"elements ($SRC_ELEMENTS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.elements\n SELECT e.* FROM main.elements e\n JOIN main.frames f ON e.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"meetings ($SRC_MEETINGS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.meetings\n SELECT * FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n # ─── FTS UPDATE ───────────────────────────────────────────────────────────\n step \"Updating FTS indexes\"\n\n run_sqlite_heredoc \"elements_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.elements_fts(rowid, text, role)\n SELECT e.id, e.text, e.role\n FROM nas.elements e\n JOIN nas.frames f ON e.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE'\n AND e.text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)\n SELECT id, full_text, app_name, window_name, browser_url, id\n FROM nas.frames\n WHERE date(timestamp) = '$TARGET_DATE'\n AND full_text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)\n SELECT id, text_content, app_name, window_title, element_name\n FROM nas.ui_events\n WHERE date(timestamp) = '$TARGET_DATE'\n AND text_content IS NOT NULL;\nDETACH nas;\n\"\n\n # ─── VERIFY DB ────────────────────────────────────────────────────────────\n step \"Verifying DB\"\n\n V_FRAMES=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\")\n V_ELEMENTS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n V_UI=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';\")\n V_OCR=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n V_MEETINGS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';\")\n\n check \"frames\" \"$V_FRAMES\" \"$SRC_FRAMES\"\n check \"elements\" \"$V_ELEMENTS\" \"$SRC_ELEMENTS\"\n check \"ui_events\" \"$V_UI\" \"$SRC_UI\"\n check \"ocr_text\" \"$V_OCR\" \"$SRC_OCR\"\n check \"meetings\" \"$V_MEETINGS\" \"$SRC_MEETINGS\"\n\nfi\n\n# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────\n# Always runs regardless of DB sync status\nstep \"Copying data folder for $TARGET_DATE\"\n\nif [ -d \"$DATA_SRC\" ]; then\n mkdir -p \"$NAS_DATA/$TARGET_DATE\"\n RSYNC_START=$(date +%s)\n printf \" %-36s \" \"rsync $TARGET_DATE/ → NAS\"\n rsync -a --ignore-existing \\\n \"$DATA_SRC/\" \\\n \"$NAS_DATA/$TARGET_DATE/\" \\\n 2>>\"$LOG_FILE\"\n RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))\n COPIED_FILES=$(ls \"$NAS_DATA/$TARGET_DATE\" | wc -l | tr -d ' ')\n SRC_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n COPIED_SIZE=$(du -sh \"$NAS_DATA/$TARGET_DATE\" | cut -f1)\n if [ \"$COPIED_FILES\" -eq \"$SRC_FILES\" ]; then\n printf \"\\r %-36s ✓ %dm%02ds (%s files, %s)\\n\" \\\n \"rsync $TARGET_DATE/ → NAS\" \\\n \"$(( RSYNC_DUR / 60 ))\" \"$(( RSYNC_DUR % 60 ))\" \\\n \"$COPIED_FILES\" \"$COPIED_SIZE\" | tee -a \"$LOG_FILE\"\n else\n printf \"\\r %-36s ✗ %s / %s files\\n\" \\\n \"rsync $TARGET_DATE/ → NAS\" \"$COPIED_FILES\" \"$SRC_FILES\" | tee -a \"$LOG_FILE\"\n fi\nelse\n printf \" %-36s %s\\n\" \"rsync $TARGET_DATE/ → NAS\" \"skipped (no source dir)\"\nfi\n\n# ─── SUMMARY ──────────────────────────────────────────────────────────────────\nTOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))\nDB_SIZE=$(du -sh \"$NAS_DB\" | cut -f1)\n\necho \"\"\nlog \"Archive DB size: $DB_SIZE\"\nlog \"Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s\"\nlog \"Sync complete for $TARGET_DATE\"\nlog \"========================================\"","depth":29,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Implement and run pipe l…, Editor Group 2","depth":28,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":false},{"role":"AXRadioButton","text":"Problems (⇧⌘M)","depth":22,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"PROBLEMS","depth":24,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Output (⇧⌘U)","depth":22,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUTPUT","depth":24,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Debug Console (⇧⌘Y)","depth":22,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"DEBUG CONSOLE","depth":24,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Terminal (⌃`)","depth":22,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":true},{"role":"AXStaticText","text":"TERMINAL","depth":24,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Ports - 1 forwarded port","depth":22,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"PORTS","depth":24,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":25,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"remote SSH: nas","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"SSH: nas","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"screenpipe (Git) - master*, Checkout Branch/Tag...","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"master*","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"screenpipe (Git) - Synchronize Changes","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"No Problems","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"0","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"0","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Forwarded Ports: 8766","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Notifications","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sign In","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Sign In","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Shell Script","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Editor Language Status: $(copilot) No inline suggestion available, Inline suggestions","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"LF","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"UTF-8","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Spaces: 2","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Ln 40, Col 23","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"git-commit Lukas Kovalik (2 weeks ago)","depth":16,"bounds":{"left":1.0,"top":0.0,"width":-0.07361114,"height":0.024444444},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":1.0,"top":0.0,"width":-0.07708335,"height":0.017777778},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Lukas Kovalik (2 weeks ago)","depth":17,"bounds":{"left":1.0,"top":0.0,"width":-0.08819449,"height":0.015555556},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Info: Setting up SSH Host nas: Setting up SSH tunnel","depth":12,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Implement and run pipe logic","depth":19,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Session history","depth":19,"on_screen":true,"help_text":"Session history","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"New session","depth":19,"on_screen":true,"help_text":"New session","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Message actions","depth":24,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"main.py","depth":23,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"lets implement logic with pipes. how can I run it?","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Let me look at the current project structure to understand what's already in place.","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"List project files","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"find /volume1/screenpipe -type f | head -50 && echo \"---\" && ls /volume1/screenpipe","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"/volume1/screenpipe/.DS_Store\n/volume1/screenpipe/screenpipe.db\n/volume1/screenpipe/screenpipe_sync.sh\n/volume1/screenpipe/app_settings.json\n/volume1/screenpipe/.gitignore\n/volume1/screenpipe/archive.db\n/volume1/screenpipe/db.sqlite\n/volume1/screenpipe/db.sqlite-wal\n/volume1/screenpipe/db.sqlite-shm\n/volume1/screenpipe/#recycle/desktop.ini\n/volume1/screenpipe/#recycle/db.sqlite\n/volume1/screenpipe/#recycle/Copy #1 of db.sqlite\n/volume1/screenpipe/#recycle/.DS_Store\n/volume1/screenpipe/#recycle/Copy #2 of db.sqlite\n/volume1/screenpipe/#recycle/archive.db\n/volume1/screenpipe/#recycle/Copy #1 of archive.db\n/volume1/screenpipe/#recycle/Copy #2 of archive.db\n/volume1/screenpipe/#recycle/Copy #3 of archive.db\n/volume1/screenpipe/#recycle/Copy #4 of archive.db\n/volume1/screenpipe/#recycle/Copy #5 of archive.db\n/volume1/screenpipe/#recycle/Copy #3 of db.sqlite\n/volume1/screenpipe/#recycle/Copy #4 of db.sqlite\n/volume1/screenpipe/#recycle/Copy #6 of archive.db\n/volume1/screenpipe/#recycle/test.txt\n/volume1/screenpipe/#recycle/Copy #7 of archive.db\n/volume1/screenpipe/#recycle/Copy #8 of archive.db\n/volume1/screenpipe/#recycle/archive.db-journal\n/volume1/screenpipe/#recycle/Copy #1 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #2 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #3 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #4 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #5 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #6 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #7 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #5 of db.sqlite\n/volume1/screenpipe/pipes/.DS_Store\n/volume1/screenpipe/app/.env\n/volume1/screenpipe/app/cli.py\n/volume1/screenpipe/app/.DS_Store\n/volume1/screenpipe/app/db.py\n/volume1/screenpipe/app/docker-compose.yml\n/volume1/screenpipe/app/main.py\n/volume1/screenpipe/app/requirements.txt\n/volume1/screenpipe/app/Dockerfile\n/volume1/screenpipe/data/.DS_Store\n/volume1/screenpipe/.git/description\n/volume1/screenpipe/.git/HEAD\n/volume1/screenpipe/.git/index\n/volume1/screenpipe/.git/COMMIT_EDITMSG\n/volume1/screenpipe/#recycle/data/.DS_Store\n---\napp\napp_settings.json\narchive.db\ndata\ndb.sqlite\ndb.sqlite-shm\ndb.sqlite-wal\npipes\n#recycle\nscreenpipe.db\nscreenpipe_sync.sh","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"main.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Check pipes directory and docker-compose","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/pipes/ && ls /volume1/screenpipe/app/ && cat /volume1/screenpipe/app/docker-compose.yml","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ai-habits\nday-recap\nmeeting-summary\nstandup-update\ntime-breakdown\nvideo-export\ncli.py\nconsumers\ndb.py\ndocker-compose.yml\nDockerfile\nmain.py\n__pycache__\nrequirements.txt\nstatic\nservices:\n screenpipe-app:\n build: .\n container_name: screenpipe-app\n restart: unless-stopped\n ports:\n - \"8766:8000\"\n volumes:\n - /volume1/screenpipe:/data\n env_file:\n - .env\n environment:\n TZ: Europe/Sofia\n DB_PATH: /data/db.sqlite\n\n sqlite-web-archive:\n image: ghcr.io/coleifer/sqlite-web:latest\n container_name: screenpipe-sqlweb-archive\n restart: unless-stopped\n ports:\n - \"8767:8080\"\n volumes:\n - /volume1/screenpipe:/data\n command: [\"-H\", \"0.0.0.0\", \"-r\", \"/data/archive.db\"]\n\n sqlite-web-live:\n image: ghcr.io/coleifer/sqlite-web:latest\n container_name: screenpipe-sqlweb-live\n restart: unless-stopped\n ports:\n - \"8768:8080\"\n volumes:\n - /volume1/screenpipe:/data\n command: [\"-H\", \"0.0.0.0\", \"-r\", \"/data/db.sqlite\"]","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"requirements.txt","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"requirements.txt","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Inspect a pipe directory","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/pipes/day-recap/ && cat /volume1/screenpipe/pipes/day-recap/pipe.json 2>/dev/null || ls /volume1/screenpipe/pipes/day-recap/","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"pipe.md\npipe.md","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"cli.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"cli.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"List all pipes and their contents","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/pipes/ && for d in /volume1/screenpipe/pipes/*/; do echo \"=== $d ===\"; ls \"$d\"; done","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ai-habits\nday-recap\nmeeting-summary\nstandup-update\ntime-breakdown\nvideo-export\n=== /volume1/screenpipe/pipes/ai-habits/ ===\npipe.md\n=== /volume1/screenpipe/pipes/day-recap/ ===\npipe.md\n=== /volume1/screenpipe/pipes/meeting-summary/ ===\npipe.md\n=== /volume1/screenpipe/pipes/standup-update/ ===\npipe.md\n=== /volume1/screenpipe/pipes/time-breakdown/ ===\npipe.md\n=== /volume1/screenpipe/pipes/video-export/ ===\npipe.md","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read pipe markdown files","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"cat /volume1/screenpipe/pipes/day-recap/pipe.md && echo \"===\" && cat /volume1/screenpipe/pipes/meeting-summary/pipe.md 2>/dev/null | head -50","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Day Recap\ndescription: \"Today's accomplishments, key moments, and unfinished work\"\nicon: \"📋\"\nfeatured: true\n---\n\nAnalyze my screen and audio recordings from today (last 16 hours only). \n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Summary\nOne sentence: what I mainly did today.\n\n## Accomplishments\n- Top 3 things I finished, with timestamps (e.g. \"2:30 PM\")\n- Name specific apps, files, or projects\n\n## Key Moments\n- Important things I saw, said, or heard — with timestamps\n\n## Unfinished Work\n- What I should continue tomorrow — name the app/file/task\n\n## Patterns\n- Apps I used most, topics that came up repeatedly\n\nOnly report what you can verify from the data. End with: \"**Next step:** [most important thing to continue]\"\n===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Meeting Summary\ndescription: \"Summarize meeting transcript with key takeaways and action items\"\nicon: \"🤝\"\nfeatured: false\n---\n\nSummarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.\n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Meeting Summary\nOne sentence: what this meeting was about.\n\n## Key Takeaways\n- Top 3-5 important points discussed\n- Include who said what when relevant\n\n## Action Items\n- [ ] Task — assigned to whom, deadline if mentioned\n- [ ] Task — assigned to whom\n\n## Decisions Made\n- List any decisions or agreements reached\n\n## Open Questions\n- Anything unresolved or needing follow-up\n\nKeep it concise and actionable.","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read summary consumer","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/app/consumers/ && cat /volume1/screenpipe/app/consumers/summary.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"activity.py\naudio.py\nelements.py\n__init__.py\ninteractions.py\nocr.py\n__pycache__\nreport.py\nsummary.py\n\"\"\"AI summary generator using Claude.\"\"\"\nimport os\nfrom datetime import date\nfrom typing import Any\n\nfrom consumers.activity import app_time, summary_stats, browser_urls, ui_event_summary\nfrom consumers.ocr import deduplicated_text\nfrom consumers.audio import formatted_transcript\n\n\nSUMMARY_TYPES = {\n \"day_recap\": {\n \"title\": \"Day Recap\",\n \"prompt\": \"\"\"\\\nYou are analyzing a person's computer activity for the day.\n\n## App usage (minutes per app):\n{app_time}\n\n## Browser URLs visited:\n{browser_urls}\n\n## UI activity per app (clicks / keystrokes / app-switches):\n{ui_events}\n\n## Screen content (sampled every 5 minutes):\n{ocr_text}\n\n## Audio/speech:\n{audio}\n\nWrite a concise day recap using EXACTLY this format:\n\n## Summary\nOne sentence: what I mainly worked on today.\n\n## Accomplishments\n- Top 3 things I finished, with approximate times\n- Name specific apps, files, or projects\n\n## Key Moments\n- Important things seen or heard, with timestamps\n\n## Unfinished Work\n- What to continue tomorrow\n\n## Patterns\n- Apps used most, topics that came up repeatedly\n\nOnly report what you can verify from the data. End with:\n**Next step:** [most important thing to continue]\"\"\",\n },\n \"standup\": {\n \"title\": \"Standup Update\",\n \"prompt\": \"\"\"\\\nYou are analyzing a person's computer activity for the day.\n\n## App usage (minutes per app):\n{app_time}\n\n## Browser URLs visited:\n{browser_urls}\n\n## UI activity per app (clicks / keystrokes / app-switches):\n{ui_events}\n\n## Screen content (sampled every 5 minutes):\n{ocr_text}\n\n## Audio/speech:\n{audio}\n\nWrite a brief standup update:\n\n**Yesterday:** What I worked on (2-3 bullets)\n**Today:** What I plan to continue (1-2 bullets)\n**Blockers:** Any issues observed (or \"None\")\n\nKeep it under 150 words. Only report what's verifiable from the data.\"\"\",\n },\n \"focus_time\": {\n \"title\": \"Focus & Distraction Analysis\",\n \"prompt\": \"\"\"\\\nYou are analyzing a person's computer activity for the day.\n\n## App usage (minutes per app):\n{app_time}\n\n## Browser URLs visited:\n{browser_urls}\n\n## UI activity per app (clicks / keystrokes / app-switches):\n{ui_events}\n\n## Screen content (sampled every 5 minutes):\n{ocr_text}\n\nAnalyze focus vs distraction patterns:\n\n## Deep Work Periods\n- When and how long were sustained focus sessions?\n- What was being worked on?\n\n## Distractions\n- Which apps/sites were used recreationally?\n- How much time was lost to context switching?\n\n## Recommendations\n- 2-3 concrete suggestions to improve focus tomorrow\n\nBe specific with times and app names.\"\"\",\n },\n}\n\n\ndef _build_context(for_date: date) -> dict[str, str]:\n apps = app_time(for_date)\n app_lines = \"\\n\".join(f\"- {a['app_name']}: {a['minutes']} min\" for a in apps[:20])\n\n urls = browser_urls(for_date, limit=20)\n url_lines = \"\\n\".join(\n f\"- {u['browser_url'][:100]} ({u['minutes']} min)\" for u in urls\n )\n\n ui_rows = ui_event_summary(for_date)\n ui_lines = \"\\n\".join(\n f\"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches\"\n for r in ui_rows[:15]\n )\n\n ocr_rows = deduplicated_text(for_date, chunk_minutes=5)\n ocr_lines = \"\\n\".join(\n f\"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}\"\n for r in ocr_rows[:100]\n )\n\n audio = formatted_transcript(for_date)\n\n return {\n \"app_time\": app_lines or \"(no app data)\",\n \"browser_urls\": url_lines or \"(no browser data)\",\n \"ui_events\": ui_lines or \"(no UI event data)\",\n \"ocr_text\": ocr_lines or \"(no screen data)\",\n \"audio\": audio[:3000] if len(audio) > 3000 else audio,\n }\n\n\ndef generate(\n summary_type: str = \"day_recap\",\n for_date: date | None = None,\n api_key: str | None = None,\n) -> dict[str, Any]:\n \"\"\"Generate an AI summary. Returns dict with 'title', 'content', 'date'.\"\"\"\n import anthropic\n\n d = for_date or date.today()\n key = api_key or os.environ.get(\"ANTHROPIC_API_KEY\", \"\")\n if not key:\n return {\n \"title\": \"Error\",\n \"content\": \"ANTHROPIC_API_KEY not set. Add it to your .env file.\",\n \"date\": str(d),\n }\n\n spec = SUMMARY_TYPES.get(summary_type)\n if not spec:\n return {\"title\": \"Error\", \"content\": f\"Unknown summary type: {summary_type}\", \"date\": str(d)}\n\n stats = summary_stats(d)\n if stats[\"total_frames\"] == 0:\n return {\n \"title\": spec[\"title\"],\n \"content\": f\"No screen data found for {d}.\",\n \"date\": str(d),\n }\n\n ctx = _build_context(d)\n prompt = spec[\"prompt\"].format(**ctx)\n\n client = anthropic.Anthropic(api_key=key)\n message = client.messages.create(\n model=\"claude-haiku-4-5-20251001\",\n max_tokens=1024,\n messages=[{\"role\": \"user\", \"content\": prompt}],\n )\n\n return {\n \"title\": spec[\"title\"],\n \"content\": message.content[0].text,\n \"date\": str(d),\n \"stats\": stats,\n }","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read all pipe.md files","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"for f in /volume1/screenpipe/pipes/*/pipe.md; do echo \"=== $f ===\"; cat \"$f\"; echo; done","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"=== /volume1/screenpipe/pipes/ai-habits/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: AI Habits\ndescription: \"How you use AI tools — patterns and insights\"\nicon: \"🤖\"\nfeatured: true\n---\n\nSearch my recordings from the last 24 hours for AI tool usage. Use app_name filter for each tool separately: ChatGPT, Claude, Copilot, Cursor, Gemini, Perplexity. Use limit=5 per search, max 6 searches total.\n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## AI Tools Used\n- List each tool with approximate time spent (e.g. \"Claude: ~45min\")\n\n## What I Used Them For\n- For each tool: coding, writing, research, or brainstorming\n\n## Usage Patterns\n- Do I switch between tools? Use them in bursts or steadily?\n\n## Effectiveness\n- Which tool appeared alongside completed work vs. abandoned attempts\n\nIf no AI usage is found, say so clearly. End with: \"**Tip:** [one suggestion to use AI tools more effectively]\"\n\n=== /volume1/screenpipe/pipes/day-recap/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Day Recap\ndescription: \"Today's accomplishments, key moments, and unfinished work\"\nicon: \"📋\"\nfeatured: true\n---\n\nAnalyze my screen and audio recordings from today (last 16 hours only). \n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Summary\nOne sentence: what I mainly did today.\n\n## Accomplishments\n- Top 3 things I finished, with timestamps (e.g. \"2:30 PM\")\n- Name specific apps, files, or projects\n\n## Key Moments\n- Important things I saw, said, or heard — with timestamps\n\n## Unfinished Work\n- What I should continue tomorrow — name the app/file/task\n\n## Patterns\n- Apps I used most, topics that came up repeatedly\n\nOnly report what you can verify from the data. End with: \"**Next step:** [most important thing to continue]\"\n\n=== /volume1/screenpipe/pipes/meeting-summary/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Meeting Summary\ndescription: \"Summarize meeting transcript with key takeaways and action items\"\nicon: \"🤝\"\nfeatured: false\n---\n\nSummarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.\n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Meeting Summary\nOne sentence: what this meeting was about.\n\n## Key Takeaways\n- Top 3-5 important points discussed\n- Include who said what when relevant\n\n## Action Items\n- [ ] Task — assigned to whom, deadline if mentioned\n- [ ] Task — assigned to whom\n\n## Decisions Made\n- List any decisions or agreements reached\n\n## Open Questions\n- Anything unresolved or needing follow-up\n\nKeep it concise and actionable.\n\n=== /volume1/screenpipe/pipes/standup-update/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Standup Update\ndescription: \"What you did, what's next, and any blockers\"\nicon: \"🏢\"\nfeatured: true\n---\n\nBased on my recordings from the last 24 hours, generate a standup update. Use limit=10 per search, max 3 searches total.\n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Yesterday\n- What I worked on (name specific projects, files, tools, PRs)\n\n## Today\n- What I will work on next (based on unfinished tasks and recent activity)\n\n## Blockers\n- Issues I hit — errors, slow builds, waiting on someone\n- If no blockers, write \"None\"\n\nKeep it under 150 words. Copy-paste ready for a team standup.\n\n=== /volume1/screenpipe/pipes/time-breakdown/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Time Breakdown\ndescription: \"Where your time went — by app, project, and category\"\nicon: \"⏱\"\nfeatured: false\n---\n\nAnalyze my app usage from today (last 12 hours). Use limit=10 per search, max 4 searches. Prefer /raw_sql with COUNT/GROUP BY queries.\n\nRead screenpipe skill first.\n\nUse this exact format with durations and percentages:\n\n## By Application\n- List each app with duration and percentage, sorted by time (e.g. \"VS Code: 2h 15min (28%)\")\n\n## By Category\n- Group into: coding, meetings, browsing, writing, communication, other\n- Show hours and percentage per category\n\n## By Project\n- Group related activities by project/topic. Name specific repos or tasks.\n\n## Productivity Score\n- Calculate: focused_work_hours / total_hours as a percentage\n- Focused = coding + writing. Unfocused = browsing + switching.\n\nEnd with: \"**Suggestion:** [one specific change to improve tomorrow's productivity]\"\n\n=== /volume1/screenpipe/pipes/video-export/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Export Video Clip\ndescription: \"Create a video of your recent screen activity\"\nicon: \"🎬\"\nfeatured: false\n---\n\nExport a video of my screen activity from the last 5 minutes.\n\nRead screenpipe skill first.\n\nUse the POST /frames/export endpoint with the time range and fps=1.0. Then show me the exported video file path as an inline code block so I can watch it.\n\nIf the export is large, suggest a lower fps or shorter time range.","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Now I have a clear picture. The pipes are markdown prompt templates in","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"/volume1/screenpipe/pipes/","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":", but there's no code to actually load and run them —","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"consumers/summary.py","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"has its own hardcoded prompts instead.","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Here's what I'll implement:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"consumers/pipes.py","depth":26,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"— dynamically loads pipe.md files and runs them via Claude (data injected as system message, pipe body as user prompt)","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"main.py","depth":26,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"— two new endpoints:","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"GET /api/pipes","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"and","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"POST /api/pipes/{pipe_id}/run","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"cli.py","depth":26,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"— a","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"pipe","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"command to run pipes from the terminal","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Let me build it:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Check browser_urls signature","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"cat /volume1/screenpipe/app/consumers/activity.py | grep \"def browser_urls\" -A 5","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"def browser_urls(\n for_date: date | None = None,\n app_name: str | None = None,\n ts_from: str | None = None,\n ts_to: str | None = None,\n limit: int = 30,","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Write","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"pipes.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"pipes.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"143 lines","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"\"\"\"Dynamic pipe loader and runner.\"\"\"\nimport os\nimport re\nfrom datetime import date\nfrom pathlib import Path\nfrom typing import Any\n\n\ndef _parse_frontmatter(text: str) -> tuple[dict, str]:\n if not text.startswith(\"---\"):\n return {}, text\n try:\n end = text.index(\"---\", 3)\n except ValueError:\n return {}, text\n fm_text = text[3:end].strip()\n body = text[end + 3:].strip()\n meta: dict = {}\n for line in fm_text.splitlines():\n if \":\" in line:\n k, _, v = line.partition(\":\")\n meta[k.strip()] = v.strip().strip('\"')\n return meta, body\n\n\ndef load_pipes(pipes_dir: Path) -> list[dict]:\n if not pipes_dir.exists():\n return []\n pipes = []\n for pipe_dir in sorted(pipes_dir.iterdir()):\n if not pipe_dir.is_dir() or pipe_dir.name.startswith(\".\"):\n continue\n pipe_md = pipe_dir / \"pipe.md\"\n if not pipe_md.exists():\n continue\n text = pipe_md.read_text(encoding=\"utf-8\")\n meta, body = _parse_frontmatter(text)\n if meta.get(\"enabled\", \"true\").lower() == \"false\":\n continue\n body = re.sub(r\"Read screenpipe skill first\\.?\\n?\", \"\", body).strip()\n pipes.append({\n \"id\": pipe_dir.name,\n \"title\": meta.get(\"title\", pipe_dir.name),\n \"description\": meta.get(\"description\", \"\"),\n \"icon\": meta.get(\"icon\", \"\"),\n \"schedule\": meta.get(\"schedule\", \"manual\"),\n \"featured\": meta.get(\"featured\", \"false\").lower() == \"true\",\n \"prompt\": body,\n })\n return pipes\n\n\ndef _build_system(d: date, stats: dict) -> str:\n from consumers.activity import app_time, browser_urls, ui_event_summary\n from consumers.ocr import deduplicated_text\n from consumers.audio import formatted_transcript\n\n apps = app_time(d)\n app_lines = \"\\n\".join(f\"- {a['app_name']}: {a['minutes']} min\" for a in apps[:20])\n\n urls = browser_urls(d, limit=20)\n url_lines = \"\\n\".join(f\"- {u['browser_url'][:100]} ({u['minutes']} min)\" for u in urls)\n\n ui_rows = ui_event_summary(d)\n ui_lines = \"\\n\".join(\n f\"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches\"\n for r in ui_rows[:15]\n )\n\n ocr_rows = deduplicated_text(d, chunk_minutes=5)\n ocr_lines = \"\\n\".join(\n f\"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}\"\n for r in ocr_rows[:100]\n )\n\n audio = formatted_transcript(d)\n if len(audio) > 3000:\n audio = audio[:3000]\n\n return f\"\"\"You are analyzing screenpipe data — recordings of a person's computer activity.\n\n## App usage (minutes per app):\n{app_lines or '(no app data)'}\n\n## Browser URLs visited:\n{url_lines or '(no browser data)'}\n\n## UI activity per app (clicks / keystrokes / app-switches):\n{ui_lines or '(no UI event data)'}\n\n## Screen content (sampled every 5 minutes):\n{ocr_lines or '(no screen data)'}\n\n## Audio / speech:\n{audio or '(no audio data)'}\n\nDate: {d}\nTotal frames recorded: {stats['total_frames']}\"\"\"\n\n\ndef run_pipe(\n pipe_id: str,\n for_date: date | None = None,\n api_key: str | None = None,\n pipes_dir: Path | None = None,\n) -> dict[str, Any]:\n import anthropic\n from consumers.activity import summary_stats\n\n d = for_date or date.today()\n key = api_key or os.environ.get(\"ANTHROPIC_API_KEY\", \"\")\n if not key:\n return {\"title\": \"Error\", \"content\": \"ANTHROPIC_API_KEY not set.\", \"date\": str(d)}\n\n _pipes_dir = pipes_dir or Path(os.environ.get(\"PIPES_DIR\", \"/data/pipes\"))\n all_pipes = {p[\"id\"]: p for p in load_pipes(_pipes_dir)}\n\n if pipe_id not in all_pipes:\n return {\"title\": \"Error\", \"content\": f\"Pipe not found: {pipe_id}\", \"date\": str(d)}\n\n pipe = all_pipes[pipe_id]\n stats = summary_stats(d)\n\n if stats[\"total_frames\"] == 0:\n return {\"title\": pipe[\"title\"], \"content\": f\"No screen data found for {d}.\", \"date\": str(d)}\n\n system = _build_system(d, stats)\n\n client = anthropic.Anthropic(api_key=key)\n message = client.messages.create(\n model=\"claude-haiku-4-5-20251001\",\n max_tokens=1024,\n system=system,\n messages=[{\"role\": \"user\", \"content\": pipe[\"prompt\"]}],\n )\n\n return {\n \"title\": pipe[\"title\"],\n \"content\": message.content[0].text,\n \"date\": str(d),\n \"stats\": stats,\n }","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Now add the API endpoints to","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"main.py","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":":","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Edit","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"main.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Added 1 line","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Edit","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"main.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Added 1 line","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Now add the pipe endpoints at the end of main.py, before the closing summary section:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Edit","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"main.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Added 14 lines","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Now add the CLI command to","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"cli.py","depth":23,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"cli.py","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":":","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Edit","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"cli.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"cli.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Added 40 lines","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Done. Here's how to run pipes:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXHeading","text":"How to run pipes","depth":22,"on_screen":false,"role_description":"heading"},{"role":"AXStaticText","text":"How to run pipes","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Via Docker (inside the running container):","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":23,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"docker exec -it screenpipe-app python cli.py pipe --list\ndocker exec -it screenpipe-app python cli.py pipe day-recap\ndocker exec -it screenpipe-app python cli.py pipe standup-update --date yesterday","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Via the API","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"(once the container is running on port 8766):","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":23,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"# List pipes\ncurl http://localhost:8766/api/pipes\n\n# Run a pipe\ncurl -X POST \"http://localhost:8766/api/pipes/day-recap/run\"\ncurl -X POST \"http://localhost:8766/api/pipes/standup-update/run?d=2026-04-25\"","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Rebuild and restart","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"to pick up the changes:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":23,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"cd /volume1/screenpipe/app\ndocker compose up --build -d","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"How it works:","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Each","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"pipe.md","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"file is loaded dynamically — the frontmatter provides metadata and the body becomes the user prompt. Screenpipe data (app usage, browser URLs, OCR, audio) is injected as a Claude system message so the pipe prompt can reference it naturally. The \"Read screenpipe skill first\" line is stripped automatically.","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"The pipes directory inside Docker is","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"/data/pipes","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"(since","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"/volume1/screenpipe","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"→","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"/data","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"). You can override it with a","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"PIPES_DIR","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"env var if needed.","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Message actions","depth":24,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"pipe.md","depth":23,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"pipe.md","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"where to place api key and can I use different keys","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read .env file","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"cat /volume1/screenpipe/app/.env","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ANTHROPIC_API_KEY=your_key_here","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Where to place the key:","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"app/.env","depth":23,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"app/.env","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"— replace","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"your_key_here","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"with your actual key:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":23,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"ANTHROPIC_API_KEY=sk-ant-...","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"That file is loaded by","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"load_dotenv()","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"at startup and is excluded from git via","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":".gitignore","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":".","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Can you use different keys per pipe?","depth":24,"on_screen":false,"role_description":"text"}]...
|
8444343821646516644
|
4472294119892815125
|
visual_change
|
accessibility
|
NULL
|
Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧ Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py
M
db.py
docker-compose.yml
Dockerfile
M
main.py
M
requirements.txt
M
data
logs
pipes
.gitignore
app_settings.json
archive.db
archive.db-bak
U
db.sqlite
db.sqlite-shm
db.sqlite-wal
screenpipe_sync_updated.sh
U
screenpipe_sync.sh
screenpipe.db
Outline Section
OUTLINE
OUTLINE
Timeline Section
TIMELINE
TIMELINE
app_settings.json, Editor Group 1
screenpipe_sync.sh, Editor Group 1
pipe.md, Editor Group 1
.env, Editor Group 1
#!/bin/bash
# screenpipe_sync.sh
# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).
# Also copies the day's video/frame data folder to the NAS.
#
# Usage:
# ./screenpipe_sync.sh # syncs yesterday (default)
# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date
# ./screenpipe_sync.sh today # syncs today so far
#
# Cron example (runs at 3am daily):
# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1
set -euo pipefail
# ─── CONFIG ───────────────────────────────────────────────────────────────────
DB_SRC="${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}"
NAS_MOUNT="${NAS_MOUNT:-/Volumes/Test/screenpipe}"
NAS_DB="$NAS_MOUNT/archive.db"
NAS_DATA="$NAS_MOUNT/data"
LOG_FILE="$HOME/.screenpipe/sync.log"
# ──────────────────────────────────────────────────────────────────────────────
# ─── HELPERS ──────────────────────────────────────────────────────────────────
SCRIPT_START=$(date +%s)
log() {
local msg="[$(date '+%Y-%m-%d %H:%M:%S')] $*"
echo "$msg" | tee -a "$LOG_FILE"
}
step() {
local now=$(date +%s)
local elapsed=$(( now - SCRIPT_START ))
local min=$(( elapsed / 60 ))
local sec=$(( elapsed % 60 ))
printf "\n[+%02dm%02ds] ▶ %s\n" "$min" "$sec" "$*" | tee -a "$LOG_FILE"
}
run_sqlite_heredoc() {
local label="$1"
local sql="$2"
local start=$(date +%s)
printf " %-36s " "$label"
sqlite3 "$DB_SRC" <<< "$sql" &
local pid=$!
local spin=[PASSWORD] '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')
local i=0
while kill -0 "$pid" 2>/dev/null; do
printf "\r %-36s %s " "$label" "${spin[$i]}"
i=$(( (i + 1) % 10 ))
sleep 0.2
done
wait "$pid"
local rc=$?
if [ $rc -ne 0 ]; then
printf "\r %-36s ✗ FAILED\n" "$label" | tee -a "$LOG_FILE"
exit $rc
fi
local dur=$(( $(date +%s) - start ))
printf "\r %-36s ✓ %dm%02ds\n" "$label" "$(( dur / 60 ))" "$(( dur % 60 ))" | tee -a "$LOG_FILE"
}
check() {
local label="$1" got="$2" expected="$3"
if [ "$got" -eq "$expected" ]; then
printf " %-20s %s / %s ✓\n" "$label:" "$got" "$expected"
else
printf " %-20s %s / %s ✗ MISMATCH\n" "$label:" "$got" "$expected"
fi
}
# ──────────────────────────────────────────────────────────────────────────────
# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────
if [ "${1:-}" = "today" ]; then
TARGET_DATE=$(date +%Y-%m-%d)
elif [ -n "${1:-}" ]; then
TARGET_DATE="$1"
if ! [[ "$TARGET_DATE" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then
echo "ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday."
exit 1
fi
else
TARGET_DATE=$(date -v-1d +%Y-%m-%d)
fi
log "========================================"
log "Screenpipe sync starting for: $TARGET_DATE"
log "========================================"
# ─── PREFLIGHT ────────────────────────────────────────────────────────────────
step "Preflight checks"
if [ ! -f "$DB_SRC" ]; then
log "ERROR: Source DB not found at $DB_SRC"; exit 1
fi
printf " %-20s %s (%s)\n" "Source DB:" "OK" "$(du -sh "$DB_SRC" | cut -f1)"
if [ ! -d "$NAS_MOUNT" ]; then
log "ERROR: NAS not mounted at $NAS_MOUNT"; exit 1
fi
printf " %-20s %s\n" "NAS mount:" "OK $NAS_MOUNT"
# Check if DB already synced for this date
DB_ALREADY_SYNCED=false
if [ -f "$NAS_DB" ]; then
EXISTING=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';" 2>/dev/null || echo "0")
if [ "$EXISTING" -gt "0" ]; then
log "Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync"
DB_ALREADY_SYNCED=true
else
printf " %-20s %s (%s)\n" "Archive DB:" "exists" "$(du -sh "$NAS_DB" | cut -f1)"
fi
else
printf " %-20s %s\n" "Archive DB:" "will be created"
fi
# Source data dir for this date
DATA_SRC="$HOME/.screenpipe/data/data/$TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
DATA_SIZE=$(du -sh "$DATA_SRC" | cut -f1)
DATA_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
printf " %-20s %s (%s files, %s)\n" "Data dir:" "OK" "$DATA_FILES" "$DATA_SIZE"
else
printf " %-20s %s\n" "Data dir:" "not found — skipping file copy"
fi
# ─── DB SYNC ──────────────────────────────────────────────────────────────────
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────
step "Counting source rows for $TARGET_DATE"
SRC_FRAMES=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
SRC_ELEMENTS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_UI=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
SRC_OCR=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_MEETINGS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';")
printf " %-20s %s\n" "frames:" "$SRC_FRAMES"
printf " %-20s %s\n" "elements:" "$SRC_ELEMENTS"
printf " %-20s %s\n" "ui_events:" "$SRC_UI"
printf " %-20s %s\n" "ocr_text:" "$SRC_OCR"
printf " %-20s %s\n" "meetings:" "$SRC_MEETINGS"
if [ "$SRC_FRAMES" -eq "0" ]; then
log "No frames found for $TARGET_DATE — skipping DB sync"
DB_ALREADY_SYNCED=true
fi
fi
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── INIT TABLES ──────────────────────────────────────────────────────────
step "Initialising tables, indexes, FTS"
run_sqlite_heredoc "creating tables" "
ATTACH '$NAS_DB' AS nas;
CREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;
CREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;
CREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;
CREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;
DETACH nas;
"
run_sqlite_heredoc "creating indexes" "
ATTACH '$NAS_DB' AS nas;
CREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);
CREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);
DETACH nas;
"
run_sqlite_heredoc "creating FTS tables" "
ATTACH '$NAS_DB' AS nas;
CREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(
text, role, frame_id UNINDEXED,
content='elements', content_rowid='id', tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(
full_text, app_name, window_name, browser_url, id UNINDEXED,
tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(
text_content,
app_name,
window_title,
element_name,
content='ui_events',
content_rowid='id',
tokenize='unicode61'
);
DETACH nas;
"
# ─── SYNC DATA ────────────────────────────────────────────────────────────
step "Syncing data for $TARGET_DATE"
run_sqlite_heredoc "video_chunks" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.video_chunks
SELECT * FROM main.video_chunks
WHERE id IN (
SELECT DISTINCT video_chunk_id FROM main.frames
WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL
);
DETACH nas;
"
run_sqlite_heredoc "frames ($SRC_FRAMES rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.frames
SELECT * FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ocr_text ($SRC_OCR rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ocr_text
SELECT o.* FROM main.ocr_text o
JOIN main.frames f ON o.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ui_events ($SRC_UI rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ui_events
SELECT * FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "elements ($SRC_ELEMENTS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.elements
SELECT e.* FROM main.elements e
JOIN main.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "meetings ($SRC_MEETINGS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.meetings
SELECT * FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';
DETACH nas;
"
# ─── FTS UPDATE ───────────────────────────────────────────────────────────
step "Updating FTS indexes"
run_sqlite_heredoc "elements_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.elements_fts(rowid, text, role)
SELECT e.id, e.text, e.role
FROM nas.elements e
JOIN nas.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE'
AND e.text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "frames_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)
SELECT id, full_text, app_name, window_name, browser_url, id
FROM nas.frames
WHERE date(timestamp) = '$TARGET_DATE'
AND full_text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "ui_events_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)
SELECT id, text_content, app_name, window_title, element_name
FROM nas.ui_events
WHERE date(timestamp) = '$TARGET_DATE'
AND text_content IS NOT NULL;
DETACH nas;
"
# ─── VERIFY DB ────────────────────────────────────────────────────────────
step "Verifying DB"
V_FRAMES=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
V_ELEMENTS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_UI=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
V_OCR=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_MEETINGS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';")
check "frames" "$V_FRAMES" "$SRC_FRAMES"
check "elements" "$V_ELEMENTS" "$SRC_ELEMENTS"
check "ui_events" "$V_UI" "$SRC_UI"
check "ocr_text" "$V_OCR" "$SRC_OCR"
check "meetings" "$V_MEETINGS" "$SRC_MEETINGS"
fi
# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────
# Always runs regardless of DB sync status
step "Copying data folder for $TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
mkdir -p "$NAS_DATA/$TARGET_DATE"
RSYNC_START=$(date +%s)
printf " %-36s " "rsync $TARGET_DATE/ → NAS"
rsync -a --ignore-existing \
"$DATA_SRC/" \
"$NAS_DATA/$TARGET_DATE/" \
2>>"$LOG_FILE"
RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))
COPIED_FILES=$(ls "$NAS_DATA/$TARGET_DATE" | wc -l | tr -d ' ')
SRC_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
COPIED_SIZE=$(du -sh "$NAS_DATA/$TARGET_DATE" | cut -f1)
if [ "$COPIED_FILES" -eq "$SRC_FILES" ]; then
printf "\r %-36s ✓ %dm%02ds (%s files, %s)\n" \
"rsync $TARGET_DATE/ → NAS" \
"$(( RSYNC_DUR / 60 ))" "$(( RSYNC_DUR % 60 ))" \
"$COPIED_FILES" "$COPIED_SIZE" | tee -a "$LOG_FILE"
else
printf "\r %-36s ✗ %s / %s files\n" \
"rsync $TARGET_DATE/ → NAS" "$COPIED_FILES" "$SRC_FILES" | tee -a "$LOG_FILE"
fi
else
printf " %-36s %s\n" "rsync $TARGET_DATE/ → NAS" "skipped (no source dir)"
fi
# ─── SUMMARY ──────────────────────────────────────────────────────────────────
TOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))
DB_SIZE=$(du -sh "$NAS_DB" | cut -f1)
echo ""
log "Archive DB size: $DB_SIZE"
log "Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s"
log "Sync complete for $TARGET_DATE"
log "========================================"
#!/bin/bash
# screenpipe_sync.sh
# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).
# Also copies the day's video/frame data folder to the NAS.
#
# Usage:
# ./screenpipe_sync.sh # syncs yesterday (default)
# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date
# ./screenpipe_sync.sh today # syncs today so far
#
# Cron example (runs at 3am daily):
# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1
set -euo pipefail
# ─── CONFIG ───────────────────────────────────────────────────────────────────
DB_SRC="${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}"
NAS_MOUNT="${NAS_MOUNT:-/Volumes/Test/screenpipe}"
NAS_DB="$NAS_MOUNT/archive.db"
NAS_DATA="$NAS_MOUNT/data"
LOG_FILE="$HOME/.screenpipe/sync.log"
# ──────────────────────────────────────────────────────────────────────────────
# ─── HELPERS ──────────────────────────────────────────────────────────────────
SCRIPT_START=$(date +%s)
log() {
local msg="[$(date '+%Y-%m-%d %H:%M:%S')] $*"
echo "$msg" | tee -a "$LOG_FILE"
}
step() {
local now=$(date +%s)
local elapsed=$(( now - SCRIPT_START ))
local min=$(( elapsed / 60 ))
local sec=$(( elapsed % 60 ))
printf "\n[+%02dm%02ds] ▶ %s\n" "$min" "$sec" "$*" | tee -a "$LOG_FILE"
}
run_sqlite_heredoc() {
local label="$1"
local sql="$2"
local start=$(date +%s)
printf " %-36s " "$label"
sqlite3 "$DB_SRC" <<< "$sql" &
local pid=$!
local spin=[PASSWORD] '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')
local i=0
while kill -0 "$pid" 2>/dev/null; do
printf "\r %-36s %s " "$label" "${spin[$i]}"
i=$(( (i + 1) % 10 ))
sleep 0.2
done
wait "$pid"
local rc=$?
if [ $rc -ne 0 ]; then
printf "\r %-36s ✗ FAILED\n" "$label" | tee -a "$LOG_FILE"
exit $rc
fi
local dur=$(( $(date +%s) - start ))
printf "\r %-36s ✓ %dm%02ds\n" "$label" "$(( dur / 60 ))" "$(( dur % 60 ))" | tee -a "$LOG_FILE"
}
check() {
local label="$1" got="$2" expected="$3"
if [ "$got" -eq "$expected" ]; then
printf " %-20s %s / %s ✓\n" "$label:" "$got" "$expected"
else
printf " %-20s %s / %s ✗ MISMATCH\n" "$label:" "$got" "$expected"
fi
}
# ──────────────────────────────────────────────────────────────────────────────
# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────
if [ "${1:-}" = "today" ]; then
TARGET_DATE=$(date +%Y-%m-%d)
elif [ -n "${1:-}" ]; then
TARGET_DATE="$1"
if ! [[ "$TARGET_DATE" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then
echo "ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday."
exit 1
fi
else
TARGET_DATE=$(date -v-1d +%Y-%m-%d)
fi
log "========================================"
log "Screenpipe sync starting for: $TARGET_DATE"
log "========================================"
# ─── PREFLIGHT ────────────────────────────────────────────────────────────────
step "Preflight checks"
if [ ! -f "$DB_SRC" ]; then
log "ERROR: Source DB not found at $DB_SRC"; exit 1
fi
printf " %-20s %s (%s)\n" "Source DB:" "OK" "$(du -sh "$DB_SRC" | cut -f1)"
if [ ! -d "$NAS_MOUNT" ]; then
log "ERROR: NAS not mounted at $NAS_MOUNT"; exit 1
fi
printf " %-20s %s\n" "NAS mount:" "OK $NAS_MOUNT"
# Check if DB already synced for this date
DB_ALREADY_SYNCED=false
if [ -f "$NAS_DB" ]; then
EXISTING=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';" 2>/dev/null || echo "0")
if [ "$EXISTING" -gt "0" ]; then
log "Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync"
DB_ALREADY_SYNCED=true
else
printf " %-20s %s (%s)\n" "Archive DB:" "exists" "$(du -sh "$NAS_DB" | cut -f1)"
fi
else
printf " %-20s %s\n" "Archive DB:" "will be created"
fi
# Source data dir for this date
DATA_SRC="$HOME/.screenpipe/data/data/$TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
DATA_SIZE=$(du -sh "$DATA_SRC" | cut -f1)
DATA_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
printf " %-20s %s (%s files, %s)\n" "Data dir:" "OK" "$DATA_FILES" "$DATA_SIZE"
else
printf " %-20s %s\n" "Data dir:" "not found — skipping file copy"
fi
# ─── DB SYNC ──────────────────────────────────────────────────────────────────
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────
step "Counting source rows for $TARGET_DATE"
SRC_FRAMES=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
SRC_ELEMENTS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_UI=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
SRC_OCR=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_MEETINGS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';")
printf " %-20s %s\n" "frames:" "$SRC_FRAMES"
printf " %-20s %s\n" "elements:" "$SRC_ELEMENTS"
printf " %-20s %s\n" "ui_events:" "$SRC_UI"
printf " %-20s %s\n" "ocr_text:" "$SRC_OCR"
printf " %-20s %s\n" "meetings:" "$SRC_MEETINGS"
if [ "$SRC_FRAMES" -eq "0" ]; then
log "No frames found for $TARGET_DATE — skipping DB sync"
DB_ALREADY_SYNCED=true
fi
fi
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── INIT TABLES ──────────────────────────────────────────────────────────
step "Initialising tables, indexes, FTS"
run_sqlite_heredoc "creating tables" "
ATTACH '$NAS_DB' AS nas;
CREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;
CREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;
CREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;
CREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;
DETACH nas;
"
run_sqlite_heredoc "creating indexes" "
ATTACH '$NAS_DB' AS nas;
CREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);
CREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);
DETACH nas;
"
run_sqlite_heredoc "creating FTS tables" "
ATTACH '$NAS_DB' AS nas;
CREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(
text, role, frame_id UNINDEXED,
content='elements', content_rowid='id', tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(
full_text, app_name, window_name, browser_url, id UNINDEXED,
tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(
text_content,
app_name,
window_title,
element_name,
content='ui_events',
content_rowid='id',
tokenize='unicode61'
);
DETACH nas;
"
# ─── SYNC DATA ────────────────────────────────────────────────────────────
step "Syncing data for $TARGET_DATE"
run_sqlite_heredoc "video_chunks" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.video_chunks
SELECT * FROM main.video_chunks
WHERE id IN (
SELECT DISTINCT video_chunk_id FROM main.frames
WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL
);
DETACH nas;
"
run_sqlite_heredoc "frames ($SRC_FRAMES rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.frames
SELECT * FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ocr_text ($SRC_OCR rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ocr_text
SELECT o.* FROM main.ocr_text o
JOIN main.frames f ON o.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ui_events ($SRC_UI rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ui_events
SELECT * FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "elements ($SRC_ELEMENTS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.elements
SELECT e.* FROM main.elements e
JOIN main.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "meetings ($SRC_MEETINGS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.meetings
SELECT * FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';
DETACH nas;
"
# ─── FTS UPDATE ───────────────────────────────────────────────────────────
step "Updating FTS indexes"
run_sqlite_heredoc "elements_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.elements_fts(rowid, text, role)
SELECT e.id, e.text, e.role
FROM nas.elements e
JOIN nas.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE'
AND e.text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "frames_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)
SELECT id, full_text, app_name, window_name, browser_url, id
FROM nas.frames
WHERE date(timestamp) = '$TARGET_DATE'
AND full_text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "ui_events_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)
SELECT id, text_content, app_name, window_title, element_name
FROM nas.ui_events
WHERE date(timestamp) = '$TARGET_DATE'
AND text_content IS NOT NULL;
DETACH nas;
"
# ─── VERIFY DB ────────────────────────────────────────────────────────────
step "Verifying DB"
V_FRAMES=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
V_ELEMENTS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_UI=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
V_OCR=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_MEETINGS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';")
check "frames" "$V_FRAMES" "$SRC_FRAMES"
check "elements" "$V_ELEMENTS" "$SRC_ELEMENTS"
check "ui_events" "$V_UI" "$SRC_UI"
check "ocr_text" "$V_OCR" "$SRC_OCR"
check "meetings" "$V_MEETINGS" "$SRC_MEETINGS"
fi
# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────
# Always runs regardless of DB sync status
step "Copying data folder for $TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
mkdir -p "$NAS_DATA/$TARGET_DATE"
RSYNC_START=$(date +%s)
printf " %-36s " "rsync $TARGET_DATE/ → NAS"
rsync -a --ignore-existing \
"$DATA_SRC/" \
"$NAS_DATA/$TARGET_DATE/" \
2>>"$LOG_FILE"
RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))
COPIED_FILES=$(ls "$NAS_DATA/$TARGET_DATE" | wc -l | tr -d ' ')
SRC_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
COPIED_SIZE=$(du -sh "$NAS_DATA/$TARGET_DATE" | cut -f1)
if [ "$COPIED_FILES" -eq "$SRC_FILES" ]; then
printf "\r %-36s ✓ %dm%02ds (%s files, %s)\n" \
"rsync $TARGET_DATE/ → NAS" \
"$(( RSYNC_DUR / 60 ))" "$(( RSYNC_DUR % 60 ))" \
"$COPIED_FILES" "$COPIED_SIZE" | tee -a "$LOG_FILE"
else
printf "\r %-36s ✗ %s / %s files\n" \
"rsync $TARGET_DATE/ → NAS" "$COPIED_FILES" "$SRC_FILES" | tee -a "$LOG_FILE"
fi
else
printf " %-36s %s\n" "rsync $TARGET_DATE/ → NAS" "skipped (no source dir)"
fi
# ─── SUMMARY ──────────────────────────────────────────────────────────────────
TOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))
DB_SIZE=$(du -sh "$NAS_DB" | cut -f1)
echo ""
log "Archive DB size: $DB_SIZE"
log "Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s"
log "Sync complete for $TARGET_DATE"
log "========================================"
Implement and run pipe l…, Editor Group 2
Problems (⇧⌘M)
PROBLEMS
Output (⇧⌘U)
OUTPUT
Debug Console (⇧⌘Y)
DEBUG CONSOLE
Terminal (⌃`)
TERMINAL
Ports - 1 forwarded port
PORTS
1
remote SSH: nas
SSH: nas
screenpipe (Git) - master*, Checkout Branch/Tag...
master*
screenpipe (Git) - Synchronize Changes
No Problems
0
0
Forwarded Ports: 8766
1
Notifications
Sign In
Sign In
Shell Script
Editor Language Status: $(copilot) No inline suggestion available, Inline suggestions
LF
UTF-8
Spaces: 2
Ln 40, Col 23
git-commit Lukas Kovalik (2 weeks ago)
Lukas Kovalik (2 weeks ago)
Info: Setting up SSH Host nas: Setting up SSH tunnel
Implement and run pipe logic
Session history
New session
Message actions
main.py
main.py
lets implement logic with pipes. how can I run it?
Thinking
Thinking
Let me look at the current project structure to understand what's already in place.
Bash
List project files
IN
find /volume1/screenpipe -type f | head -50 && echo "---" && ls /volume1/screenpipe
Copy code to clipboard
OUT
/volume1/screenpipe/.DS_Store
/volume1/screenpipe/screenpipe.db
/volume1/screenpipe/screenpipe_sync.sh
/volume1/screenpipe/app_settings.json
/volume1/screenpipe/.gitignore
/volume1/screenpipe/archive.db
/volume1/screenpipe/db.sqlite
/volume1/screenpipe/db.sqlite-wal
/volume1/screenpipe/db.sqlite-shm
/volume1/screenpipe/#recycle/desktop.ini
/volume1/screenpipe/#recycle/db.sqlite
/volume1/screenpipe/#recycle/Copy #1 of db.sqlite
/volume1/screenpipe/#recycle/.DS_Store
/volume1/screenpipe/#recycle/Copy #2 of db.sqlite
/volume1/screenpipe/#recycle/archive.db
/volume1/screenpipe/#recycle/Copy #1 of archive.db
/volume1/screenpipe/#recycle/Copy #2 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of archive.db
/volume1/screenpipe/#recycle/Copy #4 of archive.db
/volume1/screenpipe/#recycle/Copy #5 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of db.sqlite
/volume1/screenpipe/#recycle/Copy #4 of db.sqlite
/volume1/screenpipe/#recycle/Copy #6 of archive.db
/volume1/screenpipe/#recycle/test.txt
/volume1/screenpipe/#recycle/Copy #7 of archive.db
/volume1/screenpipe/#recycle/Copy #8 of archive.db
/volume1/screenpipe/#recycle/archive.db-journal
/volume1/screenpipe/#recycle/Copy #1 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #2 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #3 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #4 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #6 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #7 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of db.sqlite
/volume1/screenpipe/pipes/.DS_Store
/volume1/screenpipe/app/.env
/volume1/screenpipe/app/cli.py
/volume1/screenpipe/app/.DS_Store
/volume1/screenpipe/app/db.py
/volume1/screenpipe/app/docker-compose.yml
/volume1/screenpipe/app/main.py
/volume1/screenpipe/app/requirements.txt
/volume1/screenpipe/app/Dockerfile
/volume1/screenpipe/data/.DS_Store
/volume1/screenpipe/.git/description
/volume1/screenpipe/.git/HEAD
/volume1/screenpipe/.git/index
/volume1/screenpipe/.git/COMMIT_EDITMSG
/volume1/screenpipe/#recycle/data/.DS_Store
---
app
app_settings.json
archive.db
data
db.sqlite
db.sqlite-shm
db.sqlite-wal
pipes
#recycle
screenpipe.db
screenpipe_sync.sh
Read
main.py
main.py
Bash
Check pipes directory and docker-compose
IN
ls /volume1/screenpipe/pipes/ && ls /volume1/screenpipe/app/ && cat /volume1/screenpipe/app/docker-compose.yml
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
cli.py
consumers
db.py
docker-compose.yml
Dockerfile
main.py
__pycache__
requirements.txt
static
services:
screenpipe-app:
build: .
container_name: screenpipe-app
restart: unless-stopped
ports:
- "8766:8000"
volumes:
- /volume1/screenpipe:/data
env_file:
- .env
environment:
TZ: Europe/Sofia
DB_PATH: /data/db.sqlite
sqlite-web-archive:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-archive
restart: unless-stopped
ports:
- "8767:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/archive.db"]
sqlite-web-live:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-live
restart: unless-stopped
ports:
- "8768:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/db.sqlite"]
Read
requirements.txt
requirements.txt
Bash
Inspect a pipe directory
IN
ls /volume1/screenpipe/pipes/day-recap/ && cat /volume1/screenpipe/pipes/day-recap/pipe.json 2>/dev/null || ls /volume1/screenpipe/pipes/day-recap/
Copy code to clipboard
OUT
pipe.md
pipe.md
Read
cli.py
cli.py
Bash
List all pipes and their contents
IN
ls /volume1/screenpipe/pipes/ && for d in /volume1/screenpipe/pipes/*/; do echo "=== $d ==="; ls "$d"; done
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
=== /volume1/screenpipe/pipes/ai-habits/ ===
pipe.md
=== /volume1/screenpipe/pipes/day-recap/ ===
pipe.md
=== /volume1/screenpipe/pipes/meeting-summary/ ===
pipe.md
=== /volume1/screenpipe/pipes/standup-update/ ===
pipe.md
=== /volume1/screenpipe/pipes/time-breakdown/ ===
pipe.md
=== /volume1/screenpipe/pipes/video-export/ ===
pipe.md
Bash
Read pipe markdown files
IN
cat /volume1/screenpipe/pipes/day-recap/pipe.md && echo "===" && cat /volume1/screenpipe/pipes/meeting-summary/pipe.md 2>/dev/null | head -50
Copy code to clipboard
OUT
---
schedule: manual
enabled: true
template: true
title: Day Recap
description: "Today's accomplishments, key moments, and unfinished work"
icon: "📋"
featured: true
---
Analyze my screen and audio recordings from today (last 16 hours only).
Read screenpipe skill first.
Use this exact format:
## Summary
One sentence: what I mainly did today.
## Accomplishments
- Top 3 things I finished, with timestamps (e.g. "2:30 PM")
- Name specific apps, files, or projects
## Key Moments
- Important things I saw, said, or heard — with timestamps
## Unfinished Work
- What I should continue tomorrow — name the app/file/task
## Patterns
- Apps I used most, topics that came up repeatedly
Only report what you can verify from the data. End with: "**Next step:** [most important thing to continue]"
===
---
schedule: manual
enabled: true
template: true
title: Meeting Summary
description: "Summarize meeting transcript with key takeaways and action items"
icon: "🤝"
featured: false
---
Summarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.
Read screenpipe skill first.
Use this exact format:
## Meeting Summary
One sentence: what this meeting was about.
## Key Takeaways
- Top 3-5 important points discussed
- Include who said what when relevant
## Action Items
- [ ] Task — assigned to whom, deadline if mentioned
- [ ] Task — assigned to whom
## Decisions Made
- List any decisions or agreements reached
## Open Questions
- Anything unresolved or needing follow-up
Keep it concise and actionable.
Thinking
Thinking
Bash
Read summary consumer
IN
ls /volume1/screenpipe/app/consumers/ && cat /volume1/screenpipe/app/consumers/summary.py
Copy code to clipboard
OUT
activity.py
audio.py
elements.py
__init__.py
interactions.py
ocr.py
__pycache__
report.py
summary.py
"""AI summary generator using Claude."""
import os
from datetime import date
from typing import Any
from consumers.activity import app_time, summary_stats, browser_urls, ui_event_summary
from consumers.ocr import deduplicated_text
from consumers.audio import formatted_transcript
SUMMARY_TYPES = {
"day_recap": {
"title": "Day Recap",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
## Audio/speech:
{audio}
Write a concise day recap using EXACTLY this format:
## Summary
One sentence: what I mainly worked on today.
## Accomplishments
- Top 3 things I finished, with approximate times
- Name specific apps, files, or projects
## Key Moments
- Important things seen or heard, with timestamps
## Unfinished Work
- What to continue tomorrow
## Patterns
- Apps used most, topics that came up repeatedly
Only report what you can verify from the data. End with:
**Next step:** [most important thing to continue]""",
},
"standup": {
"title": "Standup Update",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
## Audio/speech:
{audio}
Write a brief standup update:
**Yesterday:** What I worked on (2-3 bullets)
**Today:** What I plan to continue (1-2 bullets)
**Blockers:** Any issues observed (or "None")
Keep it under 150 words. Only report what's verifiable from the data.""",
},
"focus_time": {
"title": "Focus & Distraction Analysis",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
Analyze focus vs distraction patterns:
## Deep Work Periods
- When and how long were sustained focus sessions?
- What was being worked on?
## Distractions
- Which apps/sites were used recreationally?
- How much time was lost to context switching?
## Recommendations
- 2-3 concrete suggestions to improve focus tomorrow
Be specific with times and app names.""",
},
}
def _build_context(for_date: date) -> dict[str, str]:
apps = app_time(for_date)
app_lines = "\n".join(f"- {a['app_name']}: {a['minutes']} min" for a in apps[:20])
urls = browser_urls(for_date, limit=20)
url_lines = "\n".join(
f"- {u['browser_url'][:100]} ({u['minutes']} min)" for u in urls
)
ui_rows = ui_event_summary(for_date)
ui_lines = "\n".join(
f"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches"
for r in ui_rows[:15]
)
ocr_rows = deduplicated_text(for_date, chunk_minutes=5)
ocr_lines = "\n".join(
f"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}"
for r in ocr_rows[:100]
)
audio = formatted_transcript(for_date)
return {
"app_time": app_lines or "(no app data)",
"browser_urls": url_lines or "(no browser data)",
"ui_events": ui_lines or "(no UI event data)",
"ocr_text": ocr_lines or "(no screen data)",
"audio": audio[:3000] if len(audio) > 3000 else audio,
}
def generate(
summary_type: str = "day_recap",
for_date: date | None = None,
api_key: str | None = None,
) -> dict[str, Any]:
"""Generate an AI summary. Returns dict with 'title', 'content', 'date'."""
import anthropic
d = for_date or date.today()
key = api_key or os.environ.get("ANTHROPIC_API_KEY", "")
if not key:
return {
"title": "Error",
"content": "ANTHROPIC_API_KEY not set. Add it to your .env file.",
"date": str(d),
}
spec = SUMMARY_TYPES.get(summary_type)
if not spec:
return {"title": "Error", "content": f"Unknown summary type: {summary_type}", "date": str(d)}
stats = summary_stats(d)
if stats["total_frames"] == 0:
return {
"title": spec["title"],
"content": f"No screen data found for {d}.",
"date": str(d),
}
ctx = _build_context(d)
prompt = spec["prompt"].format(**ctx)
client = anthropic.Anthropic(api_key=key)
message = client.messages.create(
model="claude-haiku-4-5-20251001",
max_tokens=1024,
messages=[{"role": "user", "content": prompt}],
)
return {
"title": spec["title"],
"content": message.content[0].text,
"date": str(d),
"stats": stats,
}
Thinking
Thinking
Bash
Read all pipe.md files
IN
for f in /volume1/screenpipe/pipes/*/pipe.md; do echo "=== $f ==="; cat "$f"; echo; done
Copy code to clipboard
OUT
=== /volume1/screenpipe/pipes/ai-habits/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: AI Habits
description: "How you use AI tools — patterns and insights"
icon: "🤖"
featured: true
---
Search my recordings from the last 24 hours for AI tool usage. Use app_name filter for each tool separately: ChatGPT, Claude, Copilot, Cursor, Gemini, Perplexity. Use limit=5 per search, max 6 searches total.
Read screenpipe skill first.
Use this exact format:
## AI Tools Used
- List each tool with approximate time spent (e.g. "Claude: ~45min")
## What I Used Them For
- For each tool: coding, writing, research, or brainstorming
## Usage Patterns
- Do I switch between tools? Use them in bursts or steadily?
## Effectiveness
- Which tool appeared alongside completed work vs. abandoned attempts
If no AI usage is found, say so clearly. End with: "**Tip:** [one suggestion to use AI tools more effectively]"
=== /volume1/screenpipe/pipes/day-recap/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Day Recap
description: "Today's accomplishments, key moments, and unfinished work"
icon: "📋"
featured: true
---
Analyze my screen and audio recordings from today (last 16 hours only).
Read screenpipe skill first.
Use this exact format:
## Summary
One sentence: what I mainly did today.
## Accomplishments
- Top 3 things I finished, with timestamps (e.g. "2:30 PM")
- Name specific apps, files, or projects
## Key Moments
- Important things I saw, said, or heard — with timestamps
## Unfinished Work
- What I should continue tomorrow — name the app/file/task
## Patterns
- Apps I used most, topics that came up repeatedly
Only report what you can verify from the data. End with: "**Next step:** [most important thing to continue]"
=== /volume1/screenpipe/pipes/meeting-summary/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Meeting Summary
description: "Summarize meeting transcript with key takeaways and action items"
icon: "🤝"
featured: false
---
Summarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.
Read screenpipe skill first.
Use this exact format:
## Meeting Summary
One sentence: what this meeting was about.
## Key Takeaways
- Top 3-5 important points discussed
- Include who said what when relevant
## Action Items
- [ ] Task — assigned to whom, deadline if mentioned
- [ ] Task — assigned to whom
## Decisions Made
- List any decisions or agreements reached
## Open Questions
- Anything unresolved or needing follow-up
Keep it concise and actionable.
=== /volume1/screenpipe/pipes/standup-update/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Standup Update
description: "What you did, what's next, and any blockers"
icon: "🏢"
featured: true
---
Based on my recordings from the last 24 hours, generate a standup update. Use limit=10 per search, max 3 searches total.
Read screenpipe skill first.
Use this exact format:
## Yesterday
- What I worked on (name specific projects, files, tools, PRs)
## Today
- What I will work on next (based on unfinished tasks and recent activity)
## Blockers
- Issues I hit — errors, slow builds, waiting on someone
- If no blockers, write "None"
Keep it under 150 words. Copy-paste ready for a team standup.
=== /volume1/screenpipe/pipes/time-breakdown/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Time Breakdown
description: "Where your time went — by app, project, and category"
icon: "⏱"
featured: false
---
Analyze my app usage from today (last 12 hours). Use limit=10 per search, max 4 searches. Prefer /raw_sql with COUNT/GROUP BY queries.
Read screenpipe skill first.
Use this exact format with durations and percentages:
## By Application
- List each app with duration and percentage, sorted by time (e.g. "VS Code: 2h 15min (28%)")
## By Category
- Group into: coding, meetings, browsing, writing, communication, other
- Show hours and percentage per category
## By Project
- Group related activities by project/topic. Name specific repos or tasks.
## Productivity Score
- Calculate: focused_work_hours / total_hours as a percentage
- Focused = coding + writing. Unfocused = browsing + switching.
End with: "**Suggestion:** [one specific change to improve tomorrow's productivity]"
=== /volume1/screenpipe/pipes/video-export/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Export Video Clip
description: "Create a video of your recent screen activity"
icon: "🎬"
featured: false
---
Export a video of my screen activity from the last 5 minutes.
Read screenpipe skill first.
Use the POST /frames/export endpoint with the time range and fps=1.0. Then show me the exported video file path as an inline code block so I can watch it.
If the export is large, suggest a lower fps or shorter time range.
Thinking
Thinking
Now I have a clear picture. The pipes are markdown prompt templates in
/volume1/screenpipe/pipes/
, but there's no code to actually load and run them —
consumers/summary.py
has its own hardcoded prompts instead.
Here's what I'll implement:
consumers/pipes.py
— dynamically loads pipe.md files and runs them via Claude (data injected as system message, pipe body as user prompt)
main.py
— two new endpoints:
GET /api/pipes
and
POST /api/pipes/{pipe_id}/run
cli.py
— a
pipe
command to run pipes from the terminal
Let me build it:
Bash
Check browser_urls signature
IN
cat /volume1/screenpipe/app/consumers/activity.py | grep "def browser_urls" -A 5
Copy code to clipboard
OUT
def browser_urls(
for_date: date | None = None,
app_name: str | None = None,
ts_from: str | None = None,
ts_to: str | None = None,
limit: int = 30,
Write
pipes.py
pipes.py
143 lines
"""Dynamic pipe loader and runner."""
import os
import re
from datetime import date
from pathlib import Path
from typing import Any
def _parse_frontmatter(text: str) -> tuple[dict, str]:
if not text.startswith("---"):
return {}, text
try:
end = text.index("---", 3)
except ValueError:
return {}, text
fm_text = text[3:end].strip()
body = text[end + 3:].strip()
meta: dict = {}
for line in fm_text.splitlines():
if ":" in line:
k, _, v = line.parti...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
21097
|
922
|
10
|
2026-05-11T17:12:04.515530+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-11/1778 /Users/lukas/.screenpipe/data/data/2026-05-11/1778519524515_m1.jpg...
|
Code
|
screenpipe_sync.sh — screenpipe [SSH: nas]
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧ Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py
M
db.py
docker-compose.yml
Dockerfile
M
main.py
M
requirements.txt
M
data
logs
pipes
.gitignore
app_settings.json
archive.db
archive.db-bak
U
db.sqlite
db.sqlite-shm
db.sqlite-wal
screenpipe_sync_updated.sh
U
screenpipe_sync.sh
screenpipe.db
Outline Section
OUTLINE
OUTLINE
Timeline Section
TIMELINE
TIMELINE
app_settings.json, Editor Group 1
screenpipe_sync.sh, Editor Group 1
pipe.md, Editor Group 1
.env, Editor Group 1
#!/bin/bash
# screenpipe_sync.sh
# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).
# Also copies the day's video/frame data folder to the NAS.
#
# Usage:
# ./screenpipe_sync.sh # syncs yesterday (default)
# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date
# ./screenpipe_sync.sh today # syncs today so far
#
# Cron example (runs at 3am daily):
# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1
set -euo pipefail
# ─── CONFIG ───────────────────────────────────────────────────────────────────
DB_SRC="${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}"
NAS_MOUNT="${NAS_MOUNT:-/Volumes/Test/screenpipe}"
NAS_DB="$NAS_MOUNT/archive.db"
NAS_DATA="$NAS_MOUNT/data"
LOG_FILE="$HOME/.screenpipe/sync.log"
# ──────────────────────────────────────────────────────────────────────────────
# ─── HELPERS ──────────────────────────────────────────────────────────────────
SCRIPT_START=$(date +%s)
log() {
local msg="[$(date '+%Y-%m-%d %H:%M:%S')] $*"
echo "$msg" | tee -a "$LOG_FILE"
}
step() {
local now=$(date +%s)
local elapsed=$(( now - SCRIPT_START ))
local min=$(( elapsed / 60 ))
local sec=$(( elapsed % 60 ))
printf "\n[+%02dm%02ds] ▶ %s\n" "$min" "$sec" "$*" | tee -a "$LOG_FILE"
}
run_sqlite_heredoc() {
local label="$1"
local sql="$2"
local start=$(date +%s)
printf " %-36s " "$label"
sqlite3 "$DB_SRC" <<< "$sql" &
local pid=$!
local spin=[PASSWORD] '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')
local i=0
while kill -0 "$pid" 2>/dev/null; do
printf "\r %-36s %s " "$label" "${spin[$i]}"
i=$(( (i + 1) % 10 ))
sleep 0.2
done
wait "$pid"
local rc=$?
if [ $rc -ne 0 ]; then
printf "\r %-36s ✗ FAILED\n" "$label" | tee -a "$LOG_FILE"
exit $rc
fi
local dur=$(( $(date +%s) - start ))
printf "\r %-36s ✓ %dm%02ds\n" "$label" "$(( dur / 60 ))" "$(( dur % 60 ))" | tee -a "$LOG_FILE"
}
check() {
local label="$1" got="$2" expected="$3"
if [ "$got" -eq "$expected" ]; then
printf " %-20s %s / %s ✓\n" "$label:" "$got" "$expected"
else
printf " %-20s %s / %s ✗ MISMATCH\n" "$label:" "$got" "$expected"
fi
}
# ──────────────────────────────────────────────────────────────────────────────
# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────
if [ "${1:-}" = "today" ]; then
TARGET_DATE=$(date +%Y-%m-%d)
elif [ -n "${1:-}" ]; then
TARGET_DATE="$1"
if ! [[ "$TARGET_DATE" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then
echo "ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday."
exit 1
fi
else
TARGET_DATE=$(date -v-1d +%Y-%m-%d)
fi
log "========================================"
log "Screenpipe sync starting for: $TARGET_DATE"
log "========================================"
# ─── PREFLIGHT ────────────────────────────────────────────────────────────────
step "Preflight checks"
if [ ! -f "$DB_SRC" ]; then
log "ERROR: Source DB not found at $DB_SRC"; exit 1
fi
printf " %-20s %s (%s)\n" "Source DB:" "OK" "$(du -sh "$DB_SRC" | cut -f1)"
if [ ! -d "$NAS_MOUNT" ]; then
log "ERROR: NAS not mounted at $NAS_MOUNT"; exit 1
fi
printf " %-20s %s\n" "NAS mount:" "OK $NAS_MOUNT"
# Check if DB already synced for this date
DB_ALREADY_SYNCED=false
if [ -f "$NAS_DB" ]; then
EXISTING=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';" 2>/dev/null || echo "0")
if [ "$EXISTING" -gt "0" ]; then
log "Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync"
DB_ALREADY_SYNCED=true
else
printf " %-20s %s (%s)\n" "Archive DB:" "exists" "$(du -sh "$NAS_DB" | cut -f1)"
fi
else
printf " %-20s %s\n" "Archive DB:" "will be created"
fi
# Source data dir for this date
DATA_SRC="$HOME/.screenpipe/data/data/$TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
DATA_SIZE=$(du -sh "$DATA_SRC" | cut -f1)
DATA_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
printf " %-20s %s (%s files, %s)\n" "Data dir:" "OK" "$DATA_FILES" "$DATA_SIZE"
else
printf " %-20s %s\n" "Data dir:" "not found — skipping file copy"
fi
# ─── DB SYNC ──────────────────────────────────────────────────────────────────
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────
step "Counting source rows for $TARGET_DATE"
SRC_FRAMES=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
SRC_ELEMENTS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_UI=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
SRC_OCR=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_MEETINGS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';")
printf " %-20s %s\n" "frames:" "$SRC_FRAMES"
printf " %-20s %s\n" "elements:" "$SRC_ELEMENTS"
printf " %-20s %s\n" "ui_events:" "$SRC_UI"
printf " %-20s %s\n" "ocr_text:" "$SRC_OCR"
printf " %-20s %s\n" "meetings:" "$SRC_MEETINGS"
if [ "$SRC_FRAMES" -eq "0" ]; then
log "No frames found for $TARGET_DATE — skipping DB sync"
DB_ALREADY_SYNCED=true
fi
fi
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── INIT TABLES ──────────────────────────────────────────────────────────
step "Initialising tables, indexes, FTS"
run_sqlite_heredoc "creating tables" "
ATTACH '$NAS_DB' AS nas;
CREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;
CREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;
CREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;
CREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;
DETACH nas;
"
run_sqlite_heredoc "creating indexes" "
ATTACH '$NAS_DB' AS nas;
CREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);
CREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);
DETACH nas;
"
run_sqlite_heredoc "creating FTS tables" "
ATTACH '$NAS_DB' AS nas;
CREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(
text, role, frame_id UNINDEXED,
content='elements', content_rowid='id', tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(
full_text, app_name, window_name, browser_url, id UNINDEXED,
tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(
text_content,
app_name,
window_title,
element_name,
content='ui_events',
content_rowid='id',
tokenize='unicode61'
);
DETACH nas;
"
# ─── SYNC DATA ────────────────────────────────────────────────────────────
step "Syncing data for $TARGET_DATE"
run_sqlite_heredoc "video_chunks" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.video_chunks
SELECT * FROM main.video_chunks
WHERE id IN (
SELECT DISTINCT video_chunk_id FROM main.frames
WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL
);
DETACH nas;
"
run_sqlite_heredoc "frames ($SRC_FRAMES rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.frames
SELECT * FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ocr_text ($SRC_OCR rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ocr_text
SELECT o.* FROM main.ocr_text o
JOIN main.frames f ON o.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ui_events ($SRC_UI rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ui_events
SELECT * FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "elements ($SRC_ELEMENTS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.elements
SELECT e.* FROM main.elements e
JOIN main.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "meetings ($SRC_MEETINGS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.meetings
SELECT * FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';
DETACH nas;
"
# ─── FTS UPDATE ───────────────────────────────────────────────────────────
step "Updating FTS indexes"
run_sqlite_heredoc "elements_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.elements_fts(rowid, text, role)
SELECT e.id, e.text, e.role
FROM nas.elements e
JOIN nas.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE'
AND e.text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "frames_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)
SELECT id, full_text, app_name, window_name, browser_url, id
FROM nas.frames
WHERE date(timestamp) = '$TARGET_DATE'
AND full_text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "ui_events_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)
SELECT id, text_content, app_name, window_title, element_name
FROM nas.ui_events
WHERE date(timestamp) = '$TARGET_DATE'
AND text_content IS NOT NULL;
DETACH nas;
"
# ─── VERIFY DB ────────────────────────────────────────────────────────────
step "Verifying DB"
V_FRAMES=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
V_ELEMENTS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_UI=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
V_OCR=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_MEETINGS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';")
check "frames" "$V_FRAMES" "$SRC_FRAMES"
check "elements" "$V_ELEMENTS" "$SRC_ELEMENTS"
check "ui_events" "$V_UI" "$SRC_UI"
check "ocr_text" "$V_OCR" "$SRC_OCR"
check "meetings" "$V_MEETINGS" "$SRC_MEETINGS"
fi
# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────
# Always runs regardless of DB sync status
step "Copying data folder for $TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
mkdir -p "$NAS_DATA/$TARGET_DATE"
RSYNC_START=$(date +%s)
printf " %-36s " "rsync $TARGET_DATE/ → NAS"
rsync -a --ignore-existing \
"$DATA_SRC/" \
"$NAS_DATA/$TARGET_DATE/" \
2>>"$LOG_FILE"
RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))
COPIED_FILES=$(ls "$NAS_DATA/$TARGET_DATE" | wc -l | tr -d ' ')
SRC_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
COPIED_SIZE=$(du -sh "$NAS_DATA/$TARGET_DATE" | cut -f1)
if [ "$COPIED_FILES" -eq "$SRC_FILES" ]; then
printf "\r %-36s ✓ %dm%02ds (%s files, %s)\n" \
"rsync $TARGET_DATE/ → NAS" \
"$(( RSYNC_DUR / 60 ))" "$(( RSYNC_DUR % 60 ))" \
"$COPIED_FILES" "$COPIED_SIZE" | tee -a "$LOG_FILE"
else
printf "\r %-36s ✗ %s / %s files\n" \
"rsync $TARGET_DATE/ → NAS" "$COPIED_FILES" "$SRC_FILES" | tee -a "$LOG_FILE"
fi
else
printf " %-36s %s\n" "rsync $TARGET_DATE/ → NAS" "skipped (no source dir)"
fi
# ─── SUMMARY ──────────────────────────────────────────────────────────────────
TOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))
DB_SIZE=$(du -sh "$NAS_DB" | cut -f1)
echo ""
log "Archive DB size: $DB_SIZE"
log "Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s"
log "Sync complete for $TARGET_DATE"
log "========================================"
#!/bin/bash
# screenpipe_sync.sh
# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).
# Also copies the day's video/frame data folder to the NAS.
#
# Usage:
# ./screenpipe_sync.sh # syncs yesterday (default)
# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date
# ./screenpipe_sync.sh today # syncs today so far
#
# Cron example (runs at 3am daily):
# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1
set -euo pipefail
# ─── CONFIG ───────────────────────────────────────────────────────────────────
DB_SRC="${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}"
NAS_MOUNT="${NAS_MOUNT:-/Volumes/Test/screenpipe}"
NAS_DB="$NAS_MOUNT/archive.db"
NAS_DATA="$NAS_MOUNT/data"
LOG_FILE="$HOME/.screenpipe/sync.log"
# ──────────────────────────────────────────────────────────────────────────────
# ─── HELPERS ──────────────────────────────────────────────────────────────────
SCRIPT_START=$(date +%s)
log() {
local msg="[$(date '+%Y-%m-%d %H:%M:%S')] $*"
echo "$msg" | tee -a "$LOG_FILE"
}
step() {
local now=$(date +%s)
local elapsed=$(( now - SCRIPT_START ))
local min=$(( elapsed / 60 ))
local sec=$(( elapsed % 60 ))
printf "\n[+%02dm%02ds] ▶ %s\n" "$min" "$sec" "$*" | tee -a "$LOG_FILE"
}
run_sqlite_heredoc() {
local label="$1"
local sql="$2"
local start=$(date +%s)
printf " %-36s " "$label"
sqlite3 "$DB_SRC" <<< "$sql" &
local pid=$!
local spin=[PASSWORD] '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')
local i=0
while kill -0 "$pid" 2>/dev/null; do
printf "\r %-36s %s " "$label" "${spin[$i]}"
i=$(( (i + 1) % 10 ))
sleep 0.2
done
wait "$pid"
local rc=$?
if [ $rc -ne 0 ]; then
printf "\r %-36s ✗ FAILED\n" "$label" | tee -a "$LOG_FILE"
exit $rc
fi
local dur=$(( $(date +%s) - start ))
printf "\r %-36s ✓ %dm%02ds\n" "$label" "$(( dur / 60 ))" "$(( dur % 60 ))" | tee -a "$LOG_FILE"
}
check() {
local label="$1" got="$2" expected="$3"
if [ "$got" -eq "$expected" ]; then
printf " %-20s %s / %s ✓\n" "$label:" "$got" "$expected"
else
printf " %-20s %s / %s ✗ MISMATCH\n" "$label:" "$got" "$expected"
fi
}
# ──────────────────────────────────────────────────────────────────────────────
# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────
if [ "${1:-}" = "today" ]; then
TARGET_DATE=$(date +%Y-%m-%d)
elif [ -n "${1:-}" ]; then
TARGET_DATE="$1"
if ! [[ "$TARGET_DATE" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then
echo "ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday."
exit 1
fi
else
TARGET_DATE=$(date -v-1d +%Y-%m-%d)
fi
log "========================================"
log "Screenpipe sync starting for: $TARGET_DATE"
log "========================================"
# ─── PREFLIGHT ────────────────────────────────────────────────────────────────
step "Preflight checks"
if [ ! -f "$DB_SRC" ]; then
log "ERROR: Source DB not found at $DB_SRC"; exit 1
fi
printf " %-20s %s (%s)\n" "Source DB:" "OK" "$(du -sh "$DB_SRC" | cut -f1)"
if [ ! -d "$NAS_MOUNT" ]; then
log "ERROR: NAS not mounted at $NAS_MOUNT"; exit 1
fi
printf " %-20s %s\n" "NAS mount:" "OK $NAS_MOUNT"
# Check if DB already synced for this date
DB_ALREADY_SYNCED=false
if [ -f "$NAS_DB" ]; then
EXISTING=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';" 2>/dev/null || echo "0")
if [ "$EXISTING" -gt "0" ]; then
log "Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync"
DB_ALREADY_SYNCED=true
else
printf " %-20s %s (%s)\n" "Archive DB:" "exists" "$(du -sh "$NAS_DB" | cut -f1)"
fi
else
printf " %-20s %s\n" "Archive DB:" "will be created"
fi
# Source data dir for this date
DATA_SRC="$HOME/.screenpipe/data/data/$TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
DATA_SIZE=$(du -sh "$DATA_SRC" | cut -f1)
DATA_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
printf " %-20s %s (%s files, %s)\n" "Data dir:" "OK" "$DATA_FILES" "$DATA_SIZE"
else
printf " %-20s %s\n" "Data dir:" "not found — skipping file copy"
fi
# ─── DB SYNC ──────────────────────────────────────────────────────────────────
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────
step "Counting source rows for $TARGET_DATE"
SRC_FRAMES=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
SRC_ELEMENTS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_UI=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
SRC_OCR=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_MEETINGS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';")
printf " %-20s %s\n" "frames:" "$SRC_FRAMES"
printf " %-20s %s\n" "elements:" "$SRC_ELEMENTS"
printf " %-20s %s\n" "ui_events:" "$SRC_UI"
printf " %-20s %s\n" "ocr_text:" "$SRC_OCR"
printf " %-20s %s\n" "meetings:" "$SRC_MEETINGS"
if [ "$SRC_FRAMES" -eq "0" ]; then
log "No frames found for $TARGET_DATE — skipping DB sync"
DB_ALREADY_SYNCED=true
fi
fi
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── INIT TABLES ──────────────────────────────────────────────────────────
step "Initialising tables, indexes, FTS"
run_sqlite_heredoc "creating tables" "
ATTACH '$NAS_DB' AS nas;
CREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;
CREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;
CREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;
CREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;
DETACH nas;
"
run_sqlite_heredoc "creating indexes" "
ATTACH '$NAS_DB' AS nas;
CREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);
CREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);
DETACH nas;
"
run_sqlite_heredoc "creating FTS tables" "
ATTACH '$NAS_DB' AS nas;
CREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(
text, role, frame_id UNINDEXED,
content='elements', content_rowid='id', tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(
full_text, app_name, window_name, browser_url, id UNINDEXED,
tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(
text_content,
app_name,
window_title,
element_name,
content='ui_events',
content_rowid='id',
tokenize='unicode61'
);
DETACH nas;
"
# ─── SYNC DATA ────────────────────────────────────────────────────────────
step "Syncing data for $TARGET_DATE"
run_sqlite_heredoc "video_chunks" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.video_chunks
SELECT * FROM main.video_chunks
WHERE id IN (
SELECT DISTINCT video_chunk_id FROM main.frames
WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL
);
DETACH nas;
"
run_sqlite_heredoc "frames ($SRC_FRAMES rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.frames
SELECT * FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ocr_text ($SRC_OCR rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ocr_text
SELECT o.* FROM main.ocr_text o
JOIN main.frames f ON o.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ui_events ($SRC_UI rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ui_events
SELECT * FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "elements ($SRC_ELEMENTS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.elements
SELECT e.* FROM main.elements e
JOIN main.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "meetings ($SRC_MEETINGS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.meetings
SELECT * FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';
DETACH nas;
"
# ─── FTS UPDATE ───────────────────────────────────────────────────────────
step "Updating FTS indexes"
run_sqlite_heredoc "elements_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.elements_fts(rowid, text, role)
SELECT e.id, e.text, e.role
FROM nas.elements e
JOIN nas.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE'
AND e.text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "frames_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)
SELECT id, full_text, app_name, window_name, browser_url, id
FROM nas.frames
WHERE date(timestamp) = '$TARGET_DATE'
AND full_text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "ui_events_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)
SELECT id, text_content, app_name, window_title, element_name
FROM nas.ui_events
WHERE date(timestamp) = '$TARGET_DATE'
AND text_content IS NOT NULL;
DETACH nas;
"
# ─── VERIFY DB ────────────────────────────────────────────────────────────
step "Verifying DB"
V_FRAMES=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
V_ELEMENTS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_UI=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
V_OCR=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_MEETINGS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';")
check "frames" "$V_FRAMES" "$SRC_FRAMES"
check "elements" "$V_ELEMENTS" "$SRC_ELEMENTS"
check "ui_events" "$V_UI" "$SRC_UI"
check "ocr_text" "$V_OCR" "$SRC_OCR"
check "meetings" "$V_MEETINGS" "$SRC_MEETINGS"
fi
# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────
# Always runs regardless of DB sync status
step "Copying data folder for $TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
mkdir -p "$NAS_DATA/$TARGET_DATE"
RSYNC_START=$(date +%s)
printf " %-36s " "rsync $TARGET_DATE/ → NAS"
rsync -a --ignore-existing \
"$DATA_SRC/" \
"$NAS_DATA/$TARGET_DATE/" \
2>>"$LOG_FILE"
RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))
COPIED_FILES=$(ls "$NAS_DATA/$TARGET_DATE" | wc -l | tr -d ' ')
SRC_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
COPIED_SIZE=$(du -sh "$NAS_DATA/$TARGET_DATE" | cut -f1)
if [ "$COPIED_FILES" -eq "$SRC_FILES" ]; then
printf "\r %-36s ✓ %dm%02ds (%s files, %s)\n" \
"rsync $TARGET_DATE/ → NAS" \
"$(( RSYNC_DUR / 60 ))" "$(( RSYNC_DUR % 60 ))" \
"$COPIED_FILES" "$COPIED_SIZE" | tee -a "$LOG_FILE"
else
printf "\r %-36s ✗ %s / %s files\n" \
"rsync $TARGET_DATE/ → NAS" "$COPIED_FILES" "$SRC_FILES" | tee -a "$LOG_FILE"
fi
else
printf " %-36s %s\n" "rsync $TARGET_DATE/ → NAS" "skipped (no source dir)"
fi
# ─── SUMMARY ──────────────────────────────────────────────────────────────────
TOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))
DB_SIZE=$(du -sh "$NAS_DB" | cut -f1)
echo ""
log "Archive DB size: $DB_SIZE"
log "Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s"
log "Sync complete for $TARGET_DATE"
log "========================================"
Implement and run pipe l…, Editor Group 2
Problems (⇧⌘M)
PROBLEMS
Output (⇧⌘U)
OUTPUT
Debug Console (⇧⌘Y)
DEBUG CONSOLE
Terminal (⌃`)
TERMINAL
Ports - 1 forwarded port
PORTS
1
remote SSH: nas
SSH: nas
screenpipe (Git) - master*, Checkout Branch/Tag...
master*
screenpipe (Git) - Synchronize Changes
No Problems
0
0
Forwarded Ports: 8766
1
Notifications
Sign In
Sign In
Shell Script
Editor Language Status: $(copilot) No inline suggestion available, Inline suggestions
LF
UTF-8
Spaces: 2
Ln 39, Col 1
git-commit Lukas Kovalik (2 weeks ago)
Lukas Kovalik (2 weeks ago)
Info: Setting up SSH Host nas: Setting up SSH tunnel
Implement and run pipe logic
Session history
New session
Message actions
main.py
main.py
lets implement logic with pipes. how can I run it?
Thinking
Thinking
Let me look at the current project structure to understand what's already in place.
Bash
List project files
IN
find /volume1/screenpipe -type f | head -50 && echo "---" && ls /volume1/screenpipe
Copy code to clipboard
OUT
/volume1/screenpipe/.DS_Store
/volume1/screenpipe/screenpipe.db
/volume1/screenpipe/screenpipe_sync.sh
/volume1/screenpipe/app_settings.json
/volume1/screenpipe/.gitignore
/volume1/screenpipe/archive.db
/volume1/screenpipe/db.sqlite
/volume1/screenpipe/db.sqlite-wal
/volume1/screenpipe/db.sqlite-shm
/volume1/screenpipe/#recycle/desktop.ini
/volume1/screenpipe/#recycle/db.sqlite
/volume1/screenpipe/#recycle/Copy #1 of db.sqlite
/volume1/screenpipe/#recycle/.DS_Store
/volume1/screenpipe/#recycle/Copy #2 of db.sqlite
/volume1/screenpipe/#recycle/archive.db
/volume1/screenpipe/#recycle/Copy #1 of archive.db
/volume1/screenpipe/#recycle/Copy #2 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of archive.db
/volume1/screenpipe/#recycle/Copy #4 of archive.db
/volume1/screenpipe/#recycle/Copy #5 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of db.sqlite
/volume1/screenpipe/#recycle/Copy #4 of db.sqlite
/volume1/screenpipe/#recycle/Copy #6 of archive.db
/volume1/screenpipe/#recycle/test.txt
/volume1/screenpipe/#recycle/Copy #7 of archive.db
/volume1/screenpipe/#recycle/Copy #8 of archive.db
/volume1/screenpipe/#recycle/archive.db-journal
/volume1/screenpipe/#recycle/Copy #1 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #2 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #3 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #4 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #6 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #7 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of db.sqlite
/volume1/screenpipe/pipes/.DS_Store
/volume1/screenpipe/app/.env
/volume1/screenpipe/app/cli.py
/volume1/screenpipe/app/.DS_Store
/volume1/screenpipe/app/db.py
/volume1/screenpipe/app/docker-compose.yml
/volume1/screenpipe/app/main.py
/volume1/screenpipe/app/requirements.txt
/volume1/screenpipe/app/Dockerfile
/volume1/screenpipe/data/.DS_Store
/volume1/screenpipe/.git/description
/volume1/screenpipe/.git/HEAD
/volume1/screenpipe/.git/index
/volume1/screenpipe/.git/COMMIT_EDITMSG
/volume1/screenpipe/#recycle/data/.DS_Store
---
app
app_settings.json
archive.db
data
db.sqlite
db.sqlite-shm
db.sqlite-wal
pipes
#recycle
screenpipe.db
screenpipe_sync.sh
Read
main.py
main.py
Bash
Check pipes directory and docker-compose
IN
ls /volume1/screenpipe/pipes/ && ls /volume1/screenpipe/app/ && cat /volume1/screenpipe/app/docker-compose.yml
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
cli.py
consumers
db.py
docker-compose.yml
Dockerfile
main.py
__pycache__
requirements.txt
static
services:
screenpipe-app:
build: .
container_name: screenpipe-app
restart: unless-stopped
ports:
- "8766:8000"
volumes:
- /volume1/screenpipe:/data
env_file:
- .env
environment:
TZ: Europe/Sofia
DB_PATH: /data/db.sqlite
sqlite-web-archive:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-archive
restart: unless-stopped
ports:
- "8767:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/archive.db"]
sqlite-web-live:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-live
restart: unless-stopped
ports:
- "8768:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/db.sqlite"]
Read
requirements.txt
requirements.txt
Bash
Inspect a pipe directory
IN
ls /volume1/screenpipe/pipes/day-recap/ && cat /volume1/screenpipe/pipes/day-recap/pipe.json 2>/dev/null || ls /volume1/screenpipe/pipes/day-recap/
Copy code to clipboard
OUT
pipe.md
pipe.md
Read
cli.py
cli.py
Bash
List all pipes and their contents
IN
ls /volume1/screenpipe/pipes/ && for d in /volume1/screenpipe/pipes/*/; do echo "=== $d ==="; ls "$d"; done
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
=== /volume1/screenpipe/pipes/ai-habits/ ===
pipe.md
=== /volume1/screenpipe/pipes/day-recap/ ===
pipe.md
=== /volume1/screenpipe/pipes/meeting-summary/ ===
pipe.md
=== /volume1/screenpipe/pipes/standup-update/ ===
pipe.md
=== /volume1/screenpipe/pipes/time-breakdown/ ===
pipe.md
=== /volume1/screenpipe/pipes/video-export/ ===
pipe.md
Bash
Read pipe markdown files
IN
cat /volume1/screenpipe/pipes/day-recap/pipe.md && echo "===" && cat /volume1/screenpipe/pipes/meeting-summary/pipe.md 2>/dev/null | head -50
Copy code to clipboard
OUT
---
schedule: manual
enabled: true
template: true
title: Day Recap
description: "Today's accomplishments, key moments, and unfinished work"
icon: "📋"
featured: true
---
Analyze my screen and audio recordings from today (last 16 hours only).
Read screenpipe skill first.
Use this exact format:
## Summary
One sentence: what I mainly did today.
## Accomplishments
- Top 3 things I finished, with timestamps (e.g. "2:30 PM")
- Name specific apps, files, or projects
## Key Moments
- Important things I saw, said, or heard — with timestamps
## Unfinished Work
- What I should continue tomorrow — name the app/file/task
## Patterns
- Apps I used most, topics that came up repeatedly
Only report what you can verify from the data. End with: "**Next step:** [most important thing to continue]"
===
---
schedule: manual
enabled: true
template: true
title: Meeting Summary
description: "Summarize meeting transcript with key takeaways and action items"
icon: "🤝"
featured: false
---
Summarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.
Read screenpipe skill first.
Use this exact format:
## Meeting Summary
One sentence: what this meeting was about.
## Key Takeaways
- Top 3-5 important points discussed
- Include who said what when relevant
## Action Items
- [ ] Task — assigned to whom, deadline if mentioned
- [ ] Task — assigned to whom
## Decisions Made
- List any decisions or agreements reached
## Open Questions
- Anything unresolved or needing follow-up
Keep it concise and actionable.
Thinking
Thinking
Bash
Read summary consumer
IN
ls /volume1/screenpipe/app/consumers/ && cat /volume1/screenpipe/app/consumers/summary.py
Copy code to clipboard
OUT
activity.py
audio.py
elements.py
__init__.py
interactions.py
ocr.py
__pycache__
report.py
summary.py
"""AI summary generator using Claude."""
import os
from datetime import date
from typing import Any
from consumers.activity import app_time, summary_stats, browser_urls, ui_event_summary
from consumers.ocr import deduplicated_text
from consumers.audio import formatted_transcript
SUMMARY_TYPES = {
"day_recap": {
"title": "Day Recap",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
## Audio/speech:
{audio}
Write a concise day recap using EXACTLY this format:
## Summary
One sentence: what I mainly worked on today.
## Accomplishments
- Top 3 things I finished, with approximate times
- Name specific apps, files, or projects
## Key Moments
- Important things seen or heard, with timestamps
## Unfinished Work
- What to continue tomorrow
## Patterns
- Apps used most, topics that came up repeatedly
Only report what you can verify from the data. End with:
**Next step:** [most important thing to continue]""",
},
"standup": {
"title": "Standup Update",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
## Audio/speech:
{audio}
Write a brief standup update:
**Yesterday:** What I worked on (2-3 bullets)
**Today:** What I plan to continue (1-2 bullets)
**Blockers:** Any issues observed (or "None")
Keep it under 150 words. Only report what's verifiable from the data.""",
},
"focus_time": {
"title": "Focus & Distraction Analysis",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
Analyze focus vs distraction patterns:
## Deep Work Periods
- When and how long were sustained focus sessions?
- What was being worked on?
## Distractions
- Which apps/sites were used recreationally?
- How much time was lost to context switching?
## Recommendations
- 2-3 concrete suggestions to improve focus tomorrow
Be specific with times and app names.""",
},
}
def _build_context(for_date: date) -> dict[str, str]:
apps = app_time(for_date)
app_lines = "\n".join(f"- {a['app_name']}: {a['minutes']} min" for a in apps[:20])
urls = browser_urls(for_date, limit=20)
url_lines = "\n".join(
f"- {u['browser_url'][:100]} ({u['minutes']} min)" for u in urls
)
ui_rows = ui_event_summary(for_date)
ui_lines = "\n".join(
f"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches"
for r in ui_rows[:15]
)
ocr_rows = deduplicated_text(for_date, chunk_minutes=5)
ocr_lines = "\n".join(
f"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}"
for r in ocr_rows[:100]
)
audio = formatted_transcript(for_date)
return {
"app_time": app_lines or "(no app data)",
"browser_urls": url_lines or "(no browser data)",
"ui_events": ui_lines or "(no UI event data)",
"ocr_text": ocr_lines or "(no screen data)",
"audio": audio[:3000] if len(audio) > 3000 else audio,
}
def generate(
summary_type: str = "day_recap",
for_date: date | None = None,
api_key: str | None = None,
) -> dict[str, Any]:
"""Generate an AI summary. Returns dict with 'title', 'content', 'date'."""
import anthropic
d = for_date or date.today()
key = api_key or os.environ.get("ANTHROPIC_API_KEY", "")
if not key:
return {
"title": "Error",
"content": "ANTHROPIC_API_KEY not set. Add it to your .env file.",
"date": str(d),
}
spec = SUMMARY_TYPES.get(summary_type)
if not spec:
return {"title": "Error", "content": f"Unknown summary type: {summary_type}", "date": str(d)}
stats = summary_stats(d)
if stats["total_frames"] == 0:
return {
"title": spec["title"],
"content": f"No screen data found for {d}.",
"date": str(d),
}
ctx = _build_context(d)
prompt = spec["prompt"].format(**ctx)
client = anthropic.Anthropic(api_key=key)
message = client.messages.create(
model="claude-haiku-4-5-20251001",
max_tokens=1024,
messages=[{"role": "user", "content": prompt}],
)
return {
"title": spec["title"],
"content": message.content[0].text,
"date": str(d),
"stats": stats,
}
Thinking
Thinking
Bash
Read all pipe.md files
IN
for f in /volume1/screenpipe/pipes/*/pipe.md; do echo "=== $f ==="; cat "$f"; echo; done
Copy code to clipboard
OUT
=== /volume1/screenpipe/pipes/ai-habits/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: AI Habits
description: "How you use AI tools — patterns and insights"
icon: "🤖"
featured: true
---
Search my recordings from the last 24 hours for AI tool usage. Use app_name filter for each tool separately: ChatGPT, Claude, Copilot, Cursor, Gemini, Perplexity. Use limit=5 per search, max 6 searches total.
Read screenpipe skill first.
Use this exact format:
## AI Tools Used
- List each tool with approximate time spent (e.g. "Claude: ~45min")
## What I Used Them For
- For each tool: coding, writing, research, or brainstorming
## Usage Patterns
- Do I switch between tools? Use them in bursts or steadily?
## Effectiveness
- Which tool appeared alongside completed work vs. abandoned attempts
If no AI usage is found, say so clearly. End with: "**Tip:** [one suggestion to use AI tools more effectively]"
=== /volume1/screenpipe/pipes/day-recap/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Day Recap
description: "Today's accomplishments, key moments, and unfinished work"
icon: "📋"
featured: true
---
Analyze my screen and audio recordings from today (last 16 hours only).
Read screenpipe skill first.
Use this exact format:
## Summary
One sentence: what I mainly did today.
## Accomplishments
- Top 3 things I finished, with timestamps (e.g. "2:30 PM")
- Name specific apps, files, or projects
## Key Moments
- Important things I saw, said, or heard — with timestamps
## Unfinished Work
- What I should continue tomorrow — name the app/file/task
## Patterns
- Apps I used most, topics that came up repeatedly
Only report what you can verify from the data. End with: "**Next step:** [most important thing to continue]"
=== /volume1/screenpipe/pipes/meeting-summary/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Meeting Summary
description: "Summarize meeting transcript with key takeaways and action items"
icon: "🤝"
featured: false
---
Summarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.
Read screenpipe skill first.
Use this exact format:
## Meeting Summary
One sentence: what this meeting was about.
## Key Takeaways
- Top 3-5 important points discussed
- Include who said what when relevant
## Action Items
- [ ] Task — assigned to whom, deadline if mentioned
- [ ] Task — assigned to whom
## Decisions Made
- List any decisions or agreements reached
## Open Questions
- Anything unresolved or needing follow-up
Keep it concise and actionable.
=== /volume1/screenpipe/pipes/standup-update/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Standup Update
description: "What you did, what's next, and any blockers"
icon: "🏢"
featured: true
---
Based on my recordings from the last 24 hours, generate a standup update. Use limit=10 per search, max 3 searches total.
Read screenpipe skill first.
Use this exact format:
## Yesterday
- What I worked on (name specific projects, files, tools, PRs)
## Today
- What I will work on next (based on unfinished tasks and recent activity)
## Blockers
- Issues I hit — errors, slow builds, waiting on someone
- If no blockers, write "None"
Keep it under 150 words. Copy-paste ready for a team standup.
=== /volume1/screenpipe/pipes/time-breakdown/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Time Breakdown
description: "Where your time went — by app, project, and category"
icon: "⏱"
featured: false
---
Analyze my app usage from today (last 12 hours). Use limit=10 per search, max 4 searches. Prefer /raw_sql with COUNT/GROUP BY queries.
Read screenpipe skill first.
Use this exact format with durations and percentages:
## By Application
- List each app with duration and percentage, sorted by time (e.g. "VS Code: 2h 15min (28%)")
## By Category
- Group into: coding, meetings, browsing, writing, communication, other
- Show hours and percentage per category
## By Project
- Group related activities by project/topic. Name specific repos or tasks.
## Productivity Score
- Calculate: focused_work_hours / total_hours as a percentage
- Focused = coding + writing. Unfocused = browsing + switching.
End with: "**Suggestion:** [one specific change to improve tomorrow's productivity]"
=== /volume1/screenpipe/pipes/video-export/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Export Video Clip
description: "Create a video of your recent screen activity"
icon: "🎬"
featured: false
---
Export a video of my screen activity from the last 5 minutes.
Read screenpipe skill first.
Use the POST /frames/export endpoint with the time range and fps=1.0. Then show me the exported video file path as an inline code block so I can watch it.
If the export is large, suggest a lower fps or shorter time range.
Thinking
Thinking
Now I have a clear picture. The pipes are markdown prompt templates in
/volume1/screenpipe/pipes/
, but there's no code to actually load and run them —
consumers/summary.py
has its own hardcoded prompts instead.
Here's what I'll implement:
consumers/pipes.py
— dynamically loads pipe.md files and runs them via Claude (data injected as system message, pipe body as user prompt)
main.py
— two new endpoints:
GET /api/pipes
and
POST /api/pipes/{pipe_id}/run
cli.py
— a
pipe
command to run pipes from the terminal
Let me build it:
Bash
Check browser_urls signature
IN
cat /volume1/screenpipe/app/consumers/activity.py | grep "def browser_urls" -A 5
Copy code to clipboard
OUT
def browser_urls(
for_date: date | None = None,
app_name: str | None = None,
ts_from: str | None = None,
ts_to: str | None = None,
limit: int = 30,
Write
pipes.py
pipes.py
143 lines
"""Dynamic pipe loader and runner."""
import os
import re
from datetime import date
from pathlib import Path
from typing import Any
def _parse_frontmatter(text: str) -> tuple[dict, str]:
if not text.startswith("---"):
return {}, text
try:
end = text.index("---", 3)
except ValueError:
return {}, text
fm_text = text[3:end].strip()
body = text[end + 3:].strip()
meta: dict = {}
for line in fm_text.splitlines():
if ":" in line:
k, _, v = line.partit...
|
[{"role":"AXRadioButton","text [{"role":"AXRadioButton","text":"Explorer (⇧⌘E)","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":true},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Search (⇧⌘F)","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Source Control (⌃⇧G) - 10 pending changes","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"10","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Run and Debug (⇧⌘D)","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Remote Explorer","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Extensions (⇧⌘X) - 2 require update","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"2","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Claude Code","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"Containers","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXHeading","text":"EXPLORER","depth":17,"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"EXPLORER","depth":18,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Explorer Section: screenpipe [SSH: nas]","depth":21,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":true},{"role":"AXStaticText","text":"","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"Explorer Section: screenpipe [SSH: nas]","depth":22,"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"SCREENPIPE [SSH: NAS]","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"#recycle","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"app","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"__pycache__","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"consumers","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"static","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":".env","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"cli.py","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.py","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"docker-compose.yml","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Dockerfile","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"main.py","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"requirements.txt","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"data","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"logs","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"pipes","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":".gitignore","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"app_settings.json","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"archive.db","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"archive.db-bak","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"U","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite-shm","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite-wal","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe_sync_updated.sh","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"U","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe_sync.sh","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe.db","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Outline Section","depth":21,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"OUTLINE","depth":22,"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"OUTLINE","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Timeline Section","depth":21,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"TIMELINE","depth":22,"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"TIMELINE","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"app_settings.json, Editor Group 1","depth":28,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"screenpipe_sync.sh, Editor Group 1","depth":28,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":false},{"role":"AXRadioButton","text":"pipe.md, Editor Group 1","depth":28,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":".env, Editor Group 1","depth":28,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"#!/bin/bash\n# screenpipe_sync.sh\n# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).\n# Also copies the day's video/frame data folder to the NAS.\n#\n# Usage:\n# ./screenpipe_sync.sh # syncs yesterday (default)\n# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date\n# ./screenpipe_sync.sh today # syncs today so far\n#\n# Cron example (runs at 3am daily):\n# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1\n\nset -euo pipefail\n\n# ─── CONFIG ───────────────────────────────────────────────────────────────────\nDB_SRC=\"${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}\"\nNAS_MOUNT=\"${NAS_MOUNT:-/Volumes/Test/screenpipe}\"\nNAS_DB=\"$NAS_MOUNT/archive.db\"\nNAS_DATA=\"$NAS_MOUNT/data\"\nLOG_FILE=\"$HOME/.screenpipe/sync.log\"\n# ──────────────────────────────────────────────────────────────────────────────\n\n# ─── HELPERS ──────────────────────────────────────────────────────────────────\nSCRIPT_START=$(date +%s)\n\nlog() {\n local msg=\"[$(date '+%Y-%m-%d %H:%M:%S')] $*\"\n echo \"$msg\" | tee -a \"$LOG_FILE\"\n}\n\nstep() {\n local now=$(date +%s)\n local elapsed=$(( now - SCRIPT_START ))\n local min=$(( elapsed / 60 ))\n local sec=$(( elapsed % 60 ))\n printf \"\\n[+%02dm%02ds] ▶ %s\\n\" \"$min\" \"$sec\" \"$*\" | tee -a \"$LOG_FILE\"\n}\n\nrun_sqlite_heredoc() {\n local label=\"$1\"\n local sql=\"$2\"\n local start=$(date +%s)\n\n printf \" %-36s \" \"$label\"\n\n sqlite3 \"$DB_SRC\" <<< \"$sql\" &\n local pid=$!\n local spin=('⠋' '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')\n local i=0\n while kill -0 \"$pid\" 2>/dev/null; do\n printf \"\\r %-36s %s \" \"$label\" \"${spin[$i]}\"\n i=$(( (i + 1) % 10 ))\n sleep 0.2\n done\n wait \"$pid\"\n local rc=$?\n if [ $rc -ne 0 ]; then\n printf \"\\r %-36s ✗ FAILED\\n\" \"$label\" | tee -a \"$LOG_FILE\"\n exit $rc\n fi\n\n local dur=$(( $(date +%s) - start ))\n printf \"\\r %-36s ✓ %dm%02ds\\n\" \"$label\" \"$(( dur / 60 ))\" \"$(( dur % 60 ))\" | tee -a \"$LOG_FILE\"\n}\n\ncheck() {\n local label=\"$1\" got=\"$2\" expected=\"$3\"\n if [ \"$got\" -eq \"$expected\" ]; then\n printf \" %-20s %s / %s ✓\\n\" \"$label:\" \"$got\" \"$expected\"\n else\n printf \" %-20s %s / %s ✗ MISMATCH\\n\" \"$label:\" \"$got\" \"$expected\"\n fi\n}\n# ──────────────────────────────────────────────────────────────────────────────\n\n# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────\nif [ \"${1:-}\" = \"today\" ]; then\n TARGET_DATE=$(date +%Y-%m-%d)\nelif [ -n \"${1:-}\" ]; then\n TARGET_DATE=\"$1\"\n if ! [[ \"$TARGET_DATE\" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then\n echo \"ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday.\"\n exit 1\n fi\nelse\n TARGET_DATE=$(date -v-1d +%Y-%m-%d)\nfi\n\nlog \"========================================\"\nlog \"Screenpipe sync starting for: $TARGET_DATE\"\nlog \"========================================\"\n\n# ─── PREFLIGHT ────────────────────────────────────────────────────────────────\nstep \"Preflight checks\"\n\nif [ ! -f \"$DB_SRC\" ]; then\n log \"ERROR: Source DB not found at $DB_SRC\"; exit 1\nfi\nprintf \" %-20s %s (%s)\\n\" \"Source DB:\" \"OK\" \"$(du -sh \"$DB_SRC\" | cut -f1)\"\n\nif [ ! -d \"$NAS_MOUNT\" ]; then\n log \"ERROR: NAS not mounted at $NAS_MOUNT\"; exit 1\nfi\nprintf \" %-20s %s\\n\" \"NAS mount:\" \"OK $NAS_MOUNT\"\n\n# Check if DB already synced for this date\nDB_ALREADY_SYNCED=false\nif [ -f \"$NAS_DB\" ]; then\n EXISTING=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\" 2>/dev/null || echo \"0\")\n if [ \"$EXISTING\" -gt \"0\" ]; then\n log \"Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync\"\n DB_ALREADY_SYNCED=true\n else\n printf \" %-20s %s (%s)\\n\" \"Archive DB:\" \"exists\" \"$(du -sh \"$NAS_DB\" | cut -f1)\"\n fi\nelse\n printf \" %-20s %s\\n\" \"Archive DB:\" \"will be created\"\nfi\n\n# Source data dir for this date\nDATA_SRC=\"$HOME/.screenpipe/data/data/$TARGET_DATE\"\nif [ -d \"$DATA_SRC\" ]; then\n DATA_SIZE=$(du -sh \"$DATA_SRC\" | cut -f1)\n DATA_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n printf \" %-20s %s (%s files, %s)\\n\" \"Data dir:\" \"OK\" \"$DATA_FILES\" \"$DATA_SIZE\"\nelse\n printf \" %-20s %s\\n\" \"Data dir:\" \"not found — skipping file copy\"\nfi\n\n# ─── DB SYNC ──────────────────────────────────────────────────────────────────\nif [ \"$DB_ALREADY_SYNCED\" = false ]; then\n\n # ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────\n step \"Counting source rows for $TARGET_DATE\"\n\n SRC_FRAMES=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\")\n SRC_ELEMENTS=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n SRC_UI=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';\")\n SRC_OCR=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n SRC_MEETINGS=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';\")\n\n printf \" %-20s %s\\n\" \"frames:\" \"$SRC_FRAMES\"\n printf \" %-20s %s\\n\" \"elements:\" \"$SRC_ELEMENTS\"\n printf \" %-20s %s\\n\" \"ui_events:\" \"$SRC_UI\"\n printf \" %-20s %s\\n\" \"ocr_text:\" \"$SRC_OCR\"\n printf \" %-20s %s\\n\" \"meetings:\" \"$SRC_MEETINGS\"\n\n if [ \"$SRC_FRAMES\" -eq \"0\" ]; then\n log \"No frames found for $TARGET_DATE — skipping DB sync\"\n DB_ALREADY_SYNCED=true\n fi\n\nfi\n\nif [ \"$DB_ALREADY_SYNCED\" = false ]; then\n\n # ─── INIT TABLES ──────────────────────────────────────────────────────────\n step \"Initialising tables, indexes, FTS\"\n\n run_sqlite_heredoc \"creating tables\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"creating indexes\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);\nCREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);\nCREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"creating FTS tables\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(\n text, role, frame_id UNINDEXED,\n content='elements', content_rowid='id', tokenize='unicode61'\n);\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(\n full_text, app_name, window_name, browser_url, id UNINDEXED,\n tokenize='unicode61'\n);\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(\n text_content,\n app_name,\n window_title,\n element_name,\n content='ui_events',\n content_rowid='id',\n tokenize='unicode61'\n);\nDETACH nas;\n\"\n\n # ─── SYNC DATA ────────────────────────────────────────────────────────────\n step \"Syncing data for $TARGET_DATE\"\n\n run_sqlite_heredoc \"video_chunks\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.video_chunks\n SELECT * FROM main.video_chunks\n WHERE id IN (\n SELECT DISTINCT video_chunk_id FROM main.frames\n WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL\n );\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames ($SRC_FRAMES rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.frames\n SELECT * FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ocr_text ($SRC_OCR rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ocr_text\n SELECT o.* FROM main.ocr_text o\n JOIN main.frames f ON o.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events ($SRC_UI rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ui_events\n SELECT * FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"elements ($SRC_ELEMENTS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.elements\n SELECT e.* FROM main.elements e\n JOIN main.frames f ON e.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"meetings ($SRC_MEETINGS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.meetings\n SELECT * FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n # ─── FTS UPDATE ───────────────────────────────────────────────────────────\n step \"Updating FTS indexes\"\n\n run_sqlite_heredoc \"elements_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.elements_fts(rowid, text, role)\n SELECT e.id, e.text, e.role\n FROM nas.elements e\n JOIN nas.frames f ON e.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE'\n AND e.text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)\n SELECT id, full_text, app_name, window_name, browser_url, id\n FROM nas.frames\n WHERE date(timestamp) = '$TARGET_DATE'\n AND full_text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)\n SELECT id, text_content, app_name, window_title, element_name\n FROM nas.ui_events\n WHERE date(timestamp) = '$TARGET_DATE'\n AND text_content IS NOT NULL;\nDETACH nas;\n\"\n\n # ─── VERIFY DB ────────────────────────────────────────────────────────────\n step \"Verifying DB\"\n\n V_FRAMES=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\")\n V_ELEMENTS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n V_UI=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';\")\n V_OCR=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n V_MEETINGS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';\")\n\n check \"frames\" \"$V_FRAMES\" \"$SRC_FRAMES\"\n check \"elements\" \"$V_ELEMENTS\" \"$SRC_ELEMENTS\"\n check \"ui_events\" \"$V_UI\" \"$SRC_UI\"\n check \"ocr_text\" \"$V_OCR\" \"$SRC_OCR\"\n check \"meetings\" \"$V_MEETINGS\" \"$SRC_MEETINGS\"\n\nfi\n\n# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────\n# Always runs regardless of DB sync status\nstep \"Copying data folder for $TARGET_DATE\"\n\nif [ -d \"$DATA_SRC\" ]; then\n mkdir -p \"$NAS_DATA/$TARGET_DATE\"\n RSYNC_START=$(date +%s)\n printf \" %-36s \" \"rsync $TARGET_DATE/ → NAS\"\n rsync -a --ignore-existing \\\n \"$DATA_SRC/\" \\\n \"$NAS_DATA/$TARGET_DATE/\" \\\n 2>>\"$LOG_FILE\"\n RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))\n COPIED_FILES=$(ls \"$NAS_DATA/$TARGET_DATE\" | wc -l | tr -d ' ')\n SRC_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n COPIED_SIZE=$(du -sh \"$NAS_DATA/$TARGET_DATE\" | cut -f1)\n if [ \"$COPIED_FILES\" -eq \"$SRC_FILES\" ]; then\n printf \"\\r %-36s ✓ %dm%02ds (%s files, %s)\\n\" \\\n \"rsync $TARGET_DATE/ → NAS\" \\\n \"$(( RSYNC_DUR / 60 ))\" \"$(( RSYNC_DUR % 60 ))\" \\\n \"$COPIED_FILES\" \"$COPIED_SIZE\" | tee -a \"$LOG_FILE\"\n else\n printf \"\\r %-36s ✗ %s / %s files\\n\" \\\n \"rsync $TARGET_DATE/ → NAS\" \"$COPIED_FILES\" \"$SRC_FILES\" | tee -a \"$LOG_FILE\"\n fi\nelse\n printf \" %-36s %s\\n\" \"rsync $TARGET_DATE/ → NAS\" \"skipped (no source dir)\"\nfi\n\n# ─── SUMMARY ──────────────────────────────────────────────────────────────────\nTOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))\nDB_SIZE=$(du -sh \"$NAS_DB\" | cut -f1)\n\necho \"\"\nlog \"Archive DB size: $DB_SIZE\"\nlog \"Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s\"\nlog \"Sync complete for $TARGET_DATE\"\nlog \"========================================\"","depth":28,"on_screen":true,"value":"#!/bin/bash\n# screenpipe_sync.sh\n# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).\n# Also copies the day's video/frame data folder to the NAS.\n#\n# Usage:\n# ./screenpipe_sync.sh # syncs yesterday (default)\n# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date\n# ./screenpipe_sync.sh today # syncs today so far\n#\n# Cron example (runs at 3am daily):\n# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1\n\nset -euo pipefail\n\n# ─── CONFIG ───────────────────────────────────────────────────────────────────\nDB_SRC=\"${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}\"\nNAS_MOUNT=\"${NAS_MOUNT:-/Volumes/Test/screenpipe}\"\nNAS_DB=\"$NAS_MOUNT/archive.db\"\nNAS_DATA=\"$NAS_MOUNT/data\"\nLOG_FILE=\"$HOME/.screenpipe/sync.log\"\n# ──────────────────────────────────────────────────────────────────────────────\n\n# ─── HELPERS ──────────────────────────────────────────────────────────────────\nSCRIPT_START=$(date +%s)\n\nlog() {\n local msg=\"[$(date '+%Y-%m-%d %H:%M:%S')] $*\"\n echo \"$msg\" | tee -a \"$LOG_FILE\"\n}\n\nstep() {\n local now=$(date +%s)\n local elapsed=$(( now - SCRIPT_START ))\n local min=$(( elapsed / 60 ))\n local sec=$(( elapsed % 60 ))\n printf \"\\n[+%02dm%02ds] ▶ %s\\n\" \"$min\" \"$sec\" \"$*\" | tee -a \"$LOG_FILE\"\n}\n\nrun_sqlite_heredoc() {\n local label=\"$1\"\n local sql=\"$2\"\n local start=$(date +%s)\n\n printf \" %-36s \" \"$label\"\n\n sqlite3 \"$DB_SRC\" <<< \"$sql\" &\n local pid=$!\n local spin=('⠋' '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')\n local i=0\n while kill -0 \"$pid\" 2>/dev/null; do\n printf \"\\r %-36s %s \" \"$label\" \"${spin[$i]}\"\n i=$(( (i + 1) % 10 ))\n sleep 0.2\n done\n wait \"$pid\"\n local rc=$?\n if [ $rc -ne 0 ]; then\n printf \"\\r %-36s ✗ FAILED\\n\" \"$label\" | tee -a \"$LOG_FILE\"\n exit $rc\n fi\n\n local dur=$(( $(date +%s) - start ))\n printf \"\\r %-36s ✓ %dm%02ds\\n\" \"$label\" \"$(( dur / 60 ))\" \"$(( dur % 60 ))\" | tee -a \"$LOG_FILE\"\n}\n\ncheck() {\n local label=\"$1\" got=\"$2\" expected=\"$3\"\n if [ \"$got\" -eq \"$expected\" ]; then\n printf \" %-20s %s / %s ✓\\n\" \"$label:\" \"$got\" \"$expected\"\n else\n printf \" %-20s %s / %s ✗ MISMATCH\\n\" \"$label:\" \"$got\" \"$expected\"\n fi\n}\n# ──────────────────────────────────────────────────────────────────────────────\n\n# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────\nif [ \"${1:-}\" = \"today\" ]; then\n TARGET_DATE=$(date +%Y-%m-%d)\nelif [ -n \"${1:-}\" ]; then\n TARGET_DATE=\"$1\"\n if ! [[ \"$TARGET_DATE\" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then\n echo \"ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday.\"\n exit 1\n fi\nelse\n TARGET_DATE=$(date -v-1d +%Y-%m-%d)\nfi\n\nlog \"========================================\"\nlog \"Screenpipe sync starting for: $TARGET_DATE\"\nlog \"========================================\"\n\n# ─── PREFLIGHT ────────────────────────────────────────────────────────────────\nstep \"Preflight checks\"\n\nif [ ! -f \"$DB_SRC\" ]; then\n log \"ERROR: Source DB not found at $DB_SRC\"; exit 1\nfi\nprintf \" %-20s %s (%s)\\n\" \"Source DB:\" \"OK\" \"$(du -sh \"$DB_SRC\" | cut -f1)\"\n\nif [ ! -d \"$NAS_MOUNT\" ]; then\n log \"ERROR: NAS not mounted at $NAS_MOUNT\"; exit 1\nfi\nprintf \" %-20s %s\\n\" \"NAS mount:\" \"OK $NAS_MOUNT\"\n\n# Check if DB already synced for this date\nDB_ALREADY_SYNCED=false\nif [ -f \"$NAS_DB\" ]; then\n EXISTING=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\" 2>/dev/null || echo \"0\")\n if [ \"$EXISTING\" -gt \"0\" ]; then\n log \"Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync\"\n DB_ALREADY_SYNCED=true\n else\n printf \" %-20s %s (%s)\\n\" \"Archive DB:\" \"exists\" \"$(du -sh \"$NAS_DB\" | cut -f1)\"\n fi\nelse\n printf \" %-20s %s\\n\" \"Archive DB:\" \"will be created\"\nfi\n\n# Source data dir for this date\nDATA_SRC=\"$HOME/.screenpipe/data/data/$TARGET_DATE\"\nif [ -d \"$DATA_SRC\" ]; then\n DATA_SIZE=$(du -sh \"$DATA_SRC\" | cut -f1)\n DATA_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n printf \" %-20s %s (%s files, %s)\\n\" \"Data dir:\" \"OK\" \"$DATA_FILES\" \"$DATA_SIZE\"\nelse\n printf \" %-20s %s\\n\" \"Data dir:\" \"not found — skipping file copy\"\nfi\n\n# ─── DB SYNC ──────────────────────────────────────────────────────────────────\nif [ \"$DB_ALREADY_SYNCED\" = false ]; then\n\n # ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────\n step \"Counting source rows for $TARGET_DATE\"\n\n SRC_FRAMES=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\")\n SRC_ELEMENTS=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n SRC_UI=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';\")\n SRC_OCR=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n SRC_MEETINGS=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';\")\n\n printf \" %-20s %s\\n\" \"frames:\" \"$SRC_FRAMES\"\n printf \" %-20s %s\\n\" \"elements:\" \"$SRC_ELEMENTS\"\n printf \" %-20s %s\\n\" \"ui_events:\" \"$SRC_UI\"\n printf \" %-20s %s\\n\" \"ocr_text:\" \"$SRC_OCR\"\n printf \" %-20s %s\\n\" \"meetings:\" \"$SRC_MEETINGS\"\n\n if [ \"$SRC_FRAMES\" -eq \"0\" ]; then\n log \"No frames found for $TARGET_DATE — skipping DB sync\"\n DB_ALREADY_SYNCED=true\n fi\n\nfi\n\nif [ \"$DB_ALREADY_SYNCED\" = false ]; then\n\n # ─── INIT TABLES ──────────────────────────────────────────────────────────\n step \"Initialising tables, indexes, FTS\"\n\n run_sqlite_heredoc \"creating tables\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"creating indexes\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);\nCREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);\nCREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"creating FTS tables\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(\n text, role, frame_id UNINDEXED,\n content='elements', content_rowid='id', tokenize='unicode61'\n);\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(\n full_text, app_name, window_name, browser_url, id UNINDEXED,\n tokenize='unicode61'\n);\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(\n text_content,\n app_name,\n window_title,\n element_name,\n content='ui_events',\n content_rowid='id',\n tokenize='unicode61'\n);\nDETACH nas;\n\"\n\n # ─── SYNC DATA ────────────────────────────────────────────────────────────\n step \"Syncing data for $TARGET_DATE\"\n\n run_sqlite_heredoc \"video_chunks\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.video_chunks\n SELECT * FROM main.video_chunks\n WHERE id IN (\n SELECT DISTINCT video_chunk_id FROM main.frames\n WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL\n );\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames ($SRC_FRAMES rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.frames\n SELECT * FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ocr_text ($SRC_OCR rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ocr_text\n SELECT o.* FROM main.ocr_text o\n JOIN main.frames f ON o.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events ($SRC_UI rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ui_events\n SELECT * FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"elements ($SRC_ELEMENTS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.elements\n SELECT e.* FROM main.elements e\n JOIN main.frames f ON e.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"meetings ($SRC_MEETINGS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.meetings\n SELECT * FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n # ─── FTS UPDATE ───────────────────────────────────────────────────────────\n step \"Updating FTS indexes\"\n\n run_sqlite_heredoc \"elements_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.elements_fts(rowid, text, role)\n SELECT e.id, e.text, e.role\n FROM nas.elements e\n JOIN nas.frames f ON e.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE'\n AND e.text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)\n SELECT id, full_text, app_name, window_name, browser_url, id\n FROM nas.frames\n WHERE date(timestamp) = '$TARGET_DATE'\n AND full_text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)\n SELECT id, text_content, app_name, window_title, element_name\n FROM nas.ui_events\n WHERE date(timestamp) = '$TARGET_DATE'\n AND text_content IS NOT NULL;\nDETACH nas;\n\"\n\n # ─── VERIFY DB ────────────────────────────────────────────────────────────\n step \"Verifying DB\"\n\n V_FRAMES=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\")\n V_ELEMENTS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n V_UI=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';\")\n V_OCR=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n V_MEETINGS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';\")\n\n check \"frames\" \"$V_FRAMES\" \"$SRC_FRAMES\"\n check \"elements\" \"$V_ELEMENTS\" \"$SRC_ELEMENTS\"\n check \"ui_events\" \"$V_UI\" \"$SRC_UI\"\n check \"ocr_text\" \"$V_OCR\" \"$SRC_OCR\"\n check \"meetings\" \"$V_MEETINGS\" \"$SRC_MEETINGS\"\n\nfi\n\n# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────\n# Always runs regardless of DB sync status\nstep \"Copying data folder for $TARGET_DATE\"\n\nif [ -d \"$DATA_SRC\" ]; then\n mkdir -p \"$NAS_DATA/$TARGET_DATE\"\n RSYNC_START=$(date +%s)\n printf \" %-36s \" \"rsync $TARGET_DATE/ → NAS\"\n rsync -a --ignore-existing \\\n \"$DATA_SRC/\" \\\n \"$NAS_DATA/$TARGET_DATE/\" \\\n 2>>\"$LOG_FILE\"\n RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))\n COPIED_FILES=$(ls \"$NAS_DATA/$TARGET_DATE\" | wc -l | tr -d ' ')\n SRC_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n COPIED_SIZE=$(du -sh \"$NAS_DATA/$TARGET_DATE\" | cut -f1)\n if [ \"$COPIED_FILES\" -eq \"$SRC_FILES\" ]; then\n printf \"\\r %-36s ✓ %dm%02ds (%s files, %s)\\n\" \\\n \"rsync $TARGET_DATE/ → NAS\" \\\n \"$(( RSYNC_DUR / 60 ))\" \"$(( RSYNC_DUR % 60 ))\" \\\n \"$COPIED_FILES\" \"$COPIED_SIZE\" | tee -a \"$LOG_FILE\"\n else\n printf \"\\r %-36s ✗ %s / %s files\\n\" \\\n \"rsync $TARGET_DATE/ → NAS\" \"$COPIED_FILES\" \"$SRC_FILES\" | tee -a \"$LOG_FILE\"\n fi\nelse\n printf \" %-36s %s\\n\" \"rsync $TARGET_DATE/ → NAS\" \"skipped (no source dir)\"\nfi\n\n# ─── SUMMARY ──────────────────────────────────────────────────────────────────\nTOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))\nDB_SIZE=$(du -sh \"$NAS_DB\" | cut -f1)\n\necho \"\"\nlog \"Archive DB size: $DB_SIZE\"\nlog \"Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s\"\nlog \"Sync complete for $TARGET_DATE\"\nlog \"========================================\"","role_description":"editor","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"#!/bin/bash\n# screenpipe_sync.sh\n# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).\n# Also copies the day's video/frame data folder to the NAS.\n#\n# Usage:\n# ./screenpipe_sync.sh # syncs yesterday (default)\n# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date\n# ./screenpipe_sync.sh today # syncs today so far\n#\n# Cron example (runs at 3am daily):\n# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1\n\nset -euo pipefail\n\n# ─── CONFIG ───────────────────────────────────────────────────────────────────\nDB_SRC=\"${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}\"\nNAS_MOUNT=\"${NAS_MOUNT:-/Volumes/Test/screenpipe}\"\nNAS_DB=\"$NAS_MOUNT/archive.db\"\nNAS_DATA=\"$NAS_MOUNT/data\"\nLOG_FILE=\"$HOME/.screenpipe/sync.log\"\n# ──────────────────────────────────────────────────────────────────────────────\n\n# ─── HELPERS ──────────────────────────────────────────────────────────────────\nSCRIPT_START=$(date +%s)\n\nlog() {\n local msg=\"[$(date '+%Y-%m-%d %H:%M:%S')] $*\"\n echo \"$msg\" | tee -a \"$LOG_FILE\"\n}\n\nstep() {\n local now=$(date +%s)\n local elapsed=$(( now - SCRIPT_START ))\n local min=$(( elapsed / 60 ))\n local sec=$(( elapsed % 60 ))\n printf \"\\n[+%02dm%02ds] ▶ %s\\n\" \"$min\" \"$sec\" \"$*\" | tee -a \"$LOG_FILE\"\n}\n\nrun_sqlite_heredoc() {\n local label=\"$1\"\n local sql=\"$2\"\n local start=$(date +%s)\n\n printf \" %-36s \" \"$label\"\n\n sqlite3 \"$DB_SRC\" <<< \"$sql\" &\n local pid=$!\n local spin=('⠋' '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')\n local i=0\n while kill -0 \"$pid\" 2>/dev/null; do\n printf \"\\r %-36s %s \" \"$label\" \"${spin[$i]}\"\n i=$(( (i + 1) % 10 ))\n sleep 0.2\n done\n wait \"$pid\"\n local rc=$?\n if [ $rc -ne 0 ]; then\n printf \"\\r %-36s ✗ FAILED\\n\" \"$label\" | tee -a \"$LOG_FILE\"\n exit $rc\n fi\n\n local dur=$(( $(date +%s) - start ))\n printf \"\\r %-36s ✓ %dm%02ds\\n\" \"$label\" \"$(( dur / 60 ))\" \"$(( dur % 60 ))\" | tee -a \"$LOG_FILE\"\n}\n\ncheck() {\n local label=\"$1\" got=\"$2\" expected=\"$3\"\n if [ \"$got\" -eq \"$expected\" ]; then\n printf \" %-20s %s / %s ✓\\n\" \"$label:\" \"$got\" \"$expected\"\n else\n printf \" %-20s %s / %s ✗ MISMATCH\\n\" \"$label:\" \"$got\" \"$expected\"\n fi\n}\n# ──────────────────────────────────────────────────────────────────────────────\n\n# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────\nif [ \"${1:-}\" = \"today\" ]; then\n TARGET_DATE=$(date +%Y-%m-%d)\nelif [ -n \"${1:-}\" ]; then\n TARGET_DATE=\"$1\"\n if ! [[ \"$TARGET_DATE\" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then\n echo \"ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday.\"\n exit 1\n fi\nelse\n TARGET_DATE=$(date -v-1d +%Y-%m-%d)\nfi\n\nlog \"========================================\"\nlog \"Screenpipe sync starting for: $TARGET_DATE\"\nlog \"========================================\"\n\n# ─── PREFLIGHT ────────────────────────────────────────────────────────────────\nstep \"Preflight checks\"\n\nif [ ! -f \"$DB_SRC\" ]; then\n log \"ERROR: Source DB not found at $DB_SRC\"; exit 1\nfi\nprintf \" %-20s %s (%s)\\n\" \"Source DB:\" \"OK\" \"$(du -sh \"$DB_SRC\" | cut -f1)\"\n\nif [ ! -d \"$NAS_MOUNT\" ]; then\n log \"ERROR: NAS not mounted at $NAS_MOUNT\"; exit 1\nfi\nprintf \" %-20s %s\\n\" \"NAS mount:\" \"OK $NAS_MOUNT\"\n\n# Check if DB already synced for this date\nDB_ALREADY_SYNCED=false\nif [ -f \"$NAS_DB\" ]; then\n EXISTING=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\" 2>/dev/null || echo \"0\")\n if [ \"$EXISTING\" -gt \"0\" ]; then\n log \"Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync\"\n DB_ALREADY_SYNCED=true\n else\n printf \" %-20s %s (%s)\\n\" \"Archive DB:\" \"exists\" \"$(du -sh \"$NAS_DB\" | cut -f1)\"\n fi\nelse\n printf \" %-20s %s\\n\" \"Archive DB:\" \"will be created\"\nfi\n\n# Source data dir for this date\nDATA_SRC=\"$HOME/.screenpipe/data/data/$TARGET_DATE\"\nif [ -d \"$DATA_SRC\" ]; then\n DATA_SIZE=$(du -sh \"$DATA_SRC\" | cut -f1)\n DATA_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n printf \" %-20s %s (%s files, %s)\\n\" \"Data dir:\" \"OK\" \"$DATA_FILES\" \"$DATA_SIZE\"\nelse\n printf \" %-20s %s\\n\" \"Data dir:\" \"not found — skipping file copy\"\nfi\n\n# ─── DB SYNC ──────────────────────────────────────────────────────────────────\nif [ \"$DB_ALREADY_SYNCED\" = false ]; then\n\n # ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────\n step \"Counting source rows for $TARGET_DATE\"\n\n SRC_FRAMES=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\")\n SRC_ELEMENTS=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n SRC_UI=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';\")\n SRC_OCR=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n SRC_MEETINGS=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';\")\n\n printf \" %-20s %s\\n\" \"frames:\" \"$SRC_FRAMES\"\n printf \" %-20s %s\\n\" \"elements:\" \"$SRC_ELEMENTS\"\n printf \" %-20s %s\\n\" \"ui_events:\" \"$SRC_UI\"\n printf \" %-20s %s\\n\" \"ocr_text:\" \"$SRC_OCR\"\n printf \" %-20s %s\\n\" \"meetings:\" \"$SRC_MEETINGS\"\n\n if [ \"$SRC_FRAMES\" -eq \"0\" ]; then\n log \"No frames found for $TARGET_DATE — skipping DB sync\"\n DB_ALREADY_SYNCED=true\n fi\n\nfi\n\nif [ \"$DB_ALREADY_SYNCED\" = false ]; then\n\n # ─── INIT TABLES ──────────────────────────────────────────────────────────\n step \"Initialising tables, indexes, FTS\"\n\n run_sqlite_heredoc \"creating tables\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"creating indexes\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);\nCREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);\nCREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"creating FTS tables\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(\n text, role, frame_id UNINDEXED,\n content='elements', content_rowid='id', tokenize='unicode61'\n);\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(\n full_text, app_name, window_name, browser_url, id UNINDEXED,\n tokenize='unicode61'\n);\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(\n text_content,\n app_name,\n window_title,\n element_name,\n content='ui_events',\n content_rowid='id',\n tokenize='unicode61'\n);\nDETACH nas;\n\"\n\n # ─── SYNC DATA ────────────────────────────────────────────────────────────\n step \"Syncing data for $TARGET_DATE\"\n\n run_sqlite_heredoc \"video_chunks\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.video_chunks\n SELECT * FROM main.video_chunks\n WHERE id IN (\n SELECT DISTINCT video_chunk_id FROM main.frames\n WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL\n );\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames ($SRC_FRAMES rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.frames\n SELECT * FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ocr_text ($SRC_OCR rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ocr_text\n SELECT o.* FROM main.ocr_text o\n JOIN main.frames f ON o.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events ($SRC_UI rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ui_events\n SELECT * FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"elements ($SRC_ELEMENTS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.elements\n SELECT e.* FROM main.elements e\n JOIN main.frames f ON e.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"meetings ($SRC_MEETINGS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.meetings\n SELECT * FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n # ─── FTS UPDATE ───────────────────────────────────────────────────────────\n step \"Updating FTS indexes\"\n\n run_sqlite_heredoc \"elements_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.elements_fts(rowid, text, role)\n SELECT e.id, e.text, e.role\n FROM nas.elements e\n JOIN nas.frames f ON e.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE'\n AND e.text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)\n SELECT id, full_text, app_name, window_name, browser_url, id\n FROM nas.frames\n WHERE date(timestamp) = '$TARGET_DATE'\n AND full_text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)\n SELECT id, text_content, app_name, window_title, element_name\n FROM nas.ui_events\n WHERE date(timestamp) = '$TARGET_DATE'\n AND text_content IS NOT NULL;\nDETACH nas;\n\"\n\n # ─── VERIFY DB ────────────────────────────────────────────────────────────\n step \"Verifying DB\"\n\n V_FRAMES=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\")\n V_ELEMENTS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n V_UI=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';\")\n V_OCR=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n V_MEETINGS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';\")\n\n check \"frames\" \"$V_FRAMES\" \"$SRC_FRAMES\"\n check \"elements\" \"$V_ELEMENTS\" \"$SRC_ELEMENTS\"\n check \"ui_events\" \"$V_UI\" \"$SRC_UI\"\n check \"ocr_text\" \"$V_OCR\" \"$SRC_OCR\"\n check \"meetings\" \"$V_MEETINGS\" \"$SRC_MEETINGS\"\n\nfi\n\n# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────\n# Always runs regardless of DB sync status\nstep \"Copying data folder for $TARGET_DATE\"\n\nif [ -d \"$DATA_SRC\" ]; then\n mkdir -p \"$NAS_DATA/$TARGET_DATE\"\n RSYNC_START=$(date +%s)\n printf \" %-36s \" \"rsync $TARGET_DATE/ → NAS\"\n rsync -a --ignore-existing \\\n \"$DATA_SRC/\" \\\n \"$NAS_DATA/$TARGET_DATE/\" \\\n 2>>\"$LOG_FILE\"\n RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))\n COPIED_FILES=$(ls \"$NAS_DATA/$TARGET_DATE\" | wc -l | tr -d ' ')\n SRC_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n COPIED_SIZE=$(du -sh \"$NAS_DATA/$TARGET_DATE\" | cut -f1)\n if [ \"$COPIED_FILES\" -eq \"$SRC_FILES\" ]; then\n printf \"\\r %-36s ✓ %dm%02ds (%s files, %s)\\n\" \\\n \"rsync $TARGET_DATE/ → NAS\" \\\n \"$(( RSYNC_DUR / 60 ))\" \"$(( RSYNC_DUR % 60 ))\" \\\n \"$COPIED_FILES\" \"$COPIED_SIZE\" | tee -a \"$LOG_FILE\"\n else\n printf \"\\r %-36s ✗ %s / %s files\\n\" \\\n \"rsync $TARGET_DATE/ → NAS\" \"$COPIED_FILES\" \"$SRC_FILES\" | tee -a \"$LOG_FILE\"\n fi\nelse\n printf \" %-36s %s\\n\" \"rsync $TARGET_DATE/ → NAS\" \"skipped (no source dir)\"\nfi\n\n# ─── SUMMARY ──────────────────────────────────────────────────────────────────\nTOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))\nDB_SIZE=$(du -sh \"$NAS_DB\" | cut -f1)\n\necho \"\"\nlog \"Archive DB size: $DB_SIZE\"\nlog \"Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s\"\nlog \"Sync complete for $TARGET_DATE\"\nlog \"========================================\"","depth":29,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Implement and run pipe l…, Editor Group 2","depth":28,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":false},{"role":"AXRadioButton","text":"Problems (⇧⌘M)","depth":22,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"PROBLEMS","depth":24,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Output (⇧⌘U)","depth":22,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUTPUT","depth":24,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Debug Console (⇧⌘Y)","depth":22,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"DEBUG CONSOLE","depth":24,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Terminal (⌃`)","depth":22,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":true},{"role":"AXStaticText","text":"TERMINAL","depth":24,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Ports - 1 forwarded port","depth":22,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"PORTS","depth":24,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":25,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"remote SSH: nas","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"SSH: nas","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"screenpipe (Git) - master*, Checkout Branch/Tag...","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"master*","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"screenpipe (Git) - Synchronize Changes","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"No Problems","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"0","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"0","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Forwarded Ports: 8766","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Notifications","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sign In","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Sign In","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Shell Script","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Editor Language Status: $(copilot) No inline suggestion available, Inline suggestions","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"LF","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"UTF-8","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Spaces: 2","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Ln 39, Col 1","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"git-commit Lukas Kovalik (2 weeks ago)","depth":16,"bounds":{"left":1.0,"top":0.0,"width":-0.07916665,"height":0.024444444},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":1.0,"top":0.0,"width":-0.08263886,"height":0.017777778},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Lukas Kovalik (2 weeks ago)","depth":17,"bounds":{"left":1.0,"top":0.0,"width":-0.09375,"height":0.015555556},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Info: Setting up SSH Host nas: Setting up SSH tunnel","depth":12,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Implement and run pipe logic","depth":19,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Session history","depth":19,"on_screen":true,"help_text":"Session history","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"New session","depth":19,"on_screen":true,"help_text":"New session","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Message actions","depth":24,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"main.py","depth":23,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"lets implement logic with pipes. how can I run it?","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Let me look at the current project structure to understand what's already in place.","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"List project files","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"find /volume1/screenpipe -type f | head -50 && echo \"---\" && ls /volume1/screenpipe","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"/volume1/screenpipe/.DS_Store\n/volume1/screenpipe/screenpipe.db\n/volume1/screenpipe/screenpipe_sync.sh\n/volume1/screenpipe/app_settings.json\n/volume1/screenpipe/.gitignore\n/volume1/screenpipe/archive.db\n/volume1/screenpipe/db.sqlite\n/volume1/screenpipe/db.sqlite-wal\n/volume1/screenpipe/db.sqlite-shm\n/volume1/screenpipe/#recycle/desktop.ini\n/volume1/screenpipe/#recycle/db.sqlite\n/volume1/screenpipe/#recycle/Copy #1 of db.sqlite\n/volume1/screenpipe/#recycle/.DS_Store\n/volume1/screenpipe/#recycle/Copy #2 of db.sqlite\n/volume1/screenpipe/#recycle/archive.db\n/volume1/screenpipe/#recycle/Copy #1 of archive.db\n/volume1/screenpipe/#recycle/Copy #2 of archive.db\n/volume1/screenpipe/#recycle/Copy #3 of archive.db\n/volume1/screenpipe/#recycle/Copy #4 of archive.db\n/volume1/screenpipe/#recycle/Copy #5 of archive.db\n/volume1/screenpipe/#recycle/Copy #3 of db.sqlite\n/volume1/screenpipe/#recycle/Copy #4 of db.sqlite\n/volume1/screenpipe/#recycle/Copy #6 of archive.db\n/volume1/screenpipe/#recycle/test.txt\n/volume1/screenpipe/#recycle/Copy #7 of archive.db\n/volume1/screenpipe/#recycle/Copy #8 of archive.db\n/volume1/screenpipe/#recycle/archive.db-journal\n/volume1/screenpipe/#recycle/Copy #1 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #2 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #3 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #4 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #5 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #6 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #7 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #5 of db.sqlite\n/volume1/screenpipe/pipes/.DS_Store\n/volume1/screenpipe/app/.env\n/volume1/screenpipe/app/cli.py\n/volume1/screenpipe/app/.DS_Store\n/volume1/screenpipe/app/db.py\n/volume1/screenpipe/app/docker-compose.yml\n/volume1/screenpipe/app/main.py\n/volume1/screenpipe/app/requirements.txt\n/volume1/screenpipe/app/Dockerfile\n/volume1/screenpipe/data/.DS_Store\n/volume1/screenpipe/.git/description\n/volume1/screenpipe/.git/HEAD\n/volume1/screenpipe/.git/index\n/volume1/screenpipe/.git/COMMIT_EDITMSG\n/volume1/screenpipe/#recycle/data/.DS_Store\n---\napp\napp_settings.json\narchive.db\ndata\ndb.sqlite\ndb.sqlite-shm\ndb.sqlite-wal\npipes\n#recycle\nscreenpipe.db\nscreenpipe_sync.sh","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"main.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Check pipes directory and docker-compose","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/pipes/ && ls /volume1/screenpipe/app/ && cat /volume1/screenpipe/app/docker-compose.yml","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ai-habits\nday-recap\nmeeting-summary\nstandup-update\ntime-breakdown\nvideo-export\ncli.py\nconsumers\ndb.py\ndocker-compose.yml\nDockerfile\nmain.py\n__pycache__\nrequirements.txt\nstatic\nservices:\n screenpipe-app:\n build: .\n container_name: screenpipe-app\n restart: unless-stopped\n ports:\n - \"8766:8000\"\n volumes:\n - /volume1/screenpipe:/data\n env_file:\n - .env\n environment:\n TZ: Europe/Sofia\n DB_PATH: /data/db.sqlite\n\n sqlite-web-archive:\n image: ghcr.io/coleifer/sqlite-web:latest\n container_name: screenpipe-sqlweb-archive\n restart: unless-stopped\n ports:\n - \"8767:8080\"\n volumes:\n - /volume1/screenpipe:/data\n command: [\"-H\", \"0.0.0.0\", \"-r\", \"/data/archive.db\"]\n\n sqlite-web-live:\n image: ghcr.io/coleifer/sqlite-web:latest\n container_name: screenpipe-sqlweb-live\n restart: unless-stopped\n ports:\n - \"8768:8080\"\n volumes:\n - /volume1/screenpipe:/data\n command: [\"-H\", \"0.0.0.0\", \"-r\", \"/data/db.sqlite\"]","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"requirements.txt","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"requirements.txt","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Inspect a pipe directory","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/pipes/day-recap/ && cat /volume1/screenpipe/pipes/day-recap/pipe.json 2>/dev/null || ls /volume1/screenpipe/pipes/day-recap/","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"pipe.md\npipe.md","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"cli.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"cli.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"List all pipes and their contents","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/pipes/ && for d in /volume1/screenpipe/pipes/*/; do echo \"=== $d ===\"; ls \"$d\"; done","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ai-habits\nday-recap\nmeeting-summary\nstandup-update\ntime-breakdown\nvideo-export\n=== /volume1/screenpipe/pipes/ai-habits/ ===\npipe.md\n=== /volume1/screenpipe/pipes/day-recap/ ===\npipe.md\n=== /volume1/screenpipe/pipes/meeting-summary/ ===\npipe.md\n=== /volume1/screenpipe/pipes/standup-update/ ===\npipe.md\n=== /volume1/screenpipe/pipes/time-breakdown/ ===\npipe.md\n=== /volume1/screenpipe/pipes/video-export/ ===\npipe.md","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read pipe markdown files","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"cat /volume1/screenpipe/pipes/day-recap/pipe.md && echo \"===\" && cat /volume1/screenpipe/pipes/meeting-summary/pipe.md 2>/dev/null | head -50","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Day Recap\ndescription: \"Today's accomplishments, key moments, and unfinished work\"\nicon: \"📋\"\nfeatured: true\n---\n\nAnalyze my screen and audio recordings from today (last 16 hours only). \n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Summary\nOne sentence: what I mainly did today.\n\n## Accomplishments\n- Top 3 things I finished, with timestamps (e.g. \"2:30 PM\")\n- Name specific apps, files, or projects\n\n## Key Moments\n- Important things I saw, said, or heard — with timestamps\n\n## Unfinished Work\n- What I should continue tomorrow — name the app/file/task\n\n## Patterns\n- Apps I used most, topics that came up repeatedly\n\nOnly report what you can verify from the data. End with: \"**Next step:** [most important thing to continue]\"\n===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Meeting Summary\ndescription: \"Summarize meeting transcript with key takeaways and action items\"\nicon: \"🤝\"\nfeatured: false\n---\n\nSummarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.\n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Meeting Summary\nOne sentence: what this meeting was about.\n\n## Key Takeaways\n- Top 3-5 important points discussed\n- Include who said what when relevant\n\n## Action Items\n- [ ] Task — assigned to whom, deadline if mentioned\n- [ ] Task — assigned to whom\n\n## Decisions Made\n- List any decisions or agreements reached\n\n## Open Questions\n- Anything unresolved or needing follow-up\n\nKeep it concise and actionable.","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read summary consumer","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/app/consumers/ && cat /volume1/screenpipe/app/consumers/summary.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"activity.py\naudio.py\nelements.py\n__init__.py\ninteractions.py\nocr.py\n__pycache__\nreport.py\nsummary.py\n\"\"\"AI summary generator using Claude.\"\"\"\nimport os\nfrom datetime import date\nfrom typing import Any\n\nfrom consumers.activity import app_time, summary_stats, browser_urls, ui_event_summary\nfrom consumers.ocr import deduplicated_text\nfrom consumers.audio import formatted_transcript\n\n\nSUMMARY_TYPES = {\n \"day_recap\": {\n \"title\": \"Day Recap\",\n \"prompt\": \"\"\"\\\nYou are analyzing a person's computer activity for the day.\n\n## App usage (minutes per app):\n{app_time}\n\n## Browser URLs visited:\n{browser_urls}\n\n## UI activity per app (clicks / keystrokes / app-switches):\n{ui_events}\n\n## Screen content (sampled every 5 minutes):\n{ocr_text}\n\n## Audio/speech:\n{audio}\n\nWrite a concise day recap using EXACTLY this format:\n\n## Summary\nOne sentence: what I mainly worked on today.\n\n## Accomplishments\n- Top 3 things I finished, with approximate times\n- Name specific apps, files, or projects\n\n## Key Moments\n- Important things seen or heard, with timestamps\n\n## Unfinished Work\n- What to continue tomorrow\n\n## Patterns\n- Apps used most, topics that came up repeatedly\n\nOnly report what you can verify from the data. End with:\n**Next step:** [most important thing to continue]\"\"\",\n },\n \"standup\": {\n \"title\": \"Standup Update\",\n \"prompt\": \"\"\"\\\nYou are analyzing a person's computer activity for the day.\n\n## App usage (minutes per app):\n{app_time}\n\n## Browser URLs visited:\n{browser_urls}\n\n## UI activity per app (clicks / keystrokes / app-switches):\n{ui_events}\n\n## Screen content (sampled every 5 minutes):\n{ocr_text}\n\n## Audio/speech:\n{audio}\n\nWrite a brief standup update:\n\n**Yesterday:** What I worked on (2-3 bullets)\n**Today:** What I plan to continue (1-2 bullets)\n**Blockers:** Any issues observed (or \"None\")\n\nKeep it under 150 words. Only report what's verifiable from the data.\"\"\",\n },\n \"focus_time\": {\n \"title\": \"Focus & Distraction Analysis\",\n \"prompt\": \"\"\"\\\nYou are analyzing a person's computer activity for the day.\n\n## App usage (minutes per app):\n{app_time}\n\n## Browser URLs visited:\n{browser_urls}\n\n## UI activity per app (clicks / keystrokes / app-switches):\n{ui_events}\n\n## Screen content (sampled every 5 minutes):\n{ocr_text}\n\nAnalyze focus vs distraction patterns:\n\n## Deep Work Periods\n- When and how long were sustained focus sessions?\n- What was being worked on?\n\n## Distractions\n- Which apps/sites were used recreationally?\n- How much time was lost to context switching?\n\n## Recommendations\n- 2-3 concrete suggestions to improve focus tomorrow\n\nBe specific with times and app names.\"\"\",\n },\n}\n\n\ndef _build_context(for_date: date) -> dict[str, str]:\n apps = app_time(for_date)\n app_lines = \"\\n\".join(f\"- {a['app_name']}: {a['minutes']} min\" for a in apps[:20])\n\n urls = browser_urls(for_date, limit=20)\n url_lines = \"\\n\".join(\n f\"- {u['browser_url'][:100]} ({u['minutes']} min)\" for u in urls\n )\n\n ui_rows = ui_event_summary(for_date)\n ui_lines = \"\\n\".join(\n f\"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches\"\n for r in ui_rows[:15]\n )\n\n ocr_rows = deduplicated_text(for_date, chunk_minutes=5)\n ocr_lines = \"\\n\".join(\n f\"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}\"\n for r in ocr_rows[:100]\n )\n\n audio = formatted_transcript(for_date)\n\n return {\n \"app_time\": app_lines or \"(no app data)\",\n \"browser_urls\": url_lines or \"(no browser data)\",\n \"ui_events\": ui_lines or \"(no UI event data)\",\n \"ocr_text\": ocr_lines or \"(no screen data)\",\n \"audio\": audio[:3000] if len(audio) > 3000 else audio,\n }\n\n\ndef generate(\n summary_type: str = \"day_recap\",\n for_date: date | None = None,\n api_key: str | None = None,\n) -> dict[str, Any]:\n \"\"\"Generate an AI summary. Returns dict with 'title', 'content', 'date'.\"\"\"\n import anthropic\n\n d = for_date or date.today()\n key = api_key or os.environ.get(\"ANTHROPIC_API_KEY\", \"\")\n if not key:\n return {\n \"title\": \"Error\",\n \"content\": \"ANTHROPIC_API_KEY not set. Add it to your .env file.\",\n \"date\": str(d),\n }\n\n spec = SUMMARY_TYPES.get(summary_type)\n if not spec:\n return {\"title\": \"Error\", \"content\": f\"Unknown summary type: {summary_type}\", \"date\": str(d)}\n\n stats = summary_stats(d)\n if stats[\"total_frames\"] == 0:\n return {\n \"title\": spec[\"title\"],\n \"content\": f\"No screen data found for {d}.\",\n \"date\": str(d),\n }\n\n ctx = _build_context(d)\n prompt = spec[\"prompt\"].format(**ctx)\n\n client = anthropic.Anthropic(api_key=key)\n message = client.messages.create(\n model=\"claude-haiku-4-5-20251001\",\n max_tokens=1024,\n messages=[{\"role\": \"user\", \"content\": prompt}],\n )\n\n return {\n \"title\": spec[\"title\"],\n \"content\": message.content[0].text,\n \"date\": str(d),\n \"stats\": stats,\n }","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read all pipe.md files","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"for f in /volume1/screenpipe/pipes/*/pipe.md; do echo \"=== $f ===\"; cat \"$f\"; echo; done","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"=== /volume1/screenpipe/pipes/ai-habits/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: AI Habits\ndescription: \"How you use AI tools — patterns and insights\"\nicon: \"🤖\"\nfeatured: true\n---\n\nSearch my recordings from the last 24 hours for AI tool usage. Use app_name filter for each tool separately: ChatGPT, Claude, Copilot, Cursor, Gemini, Perplexity. Use limit=5 per search, max 6 searches total.\n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## AI Tools Used\n- List each tool with approximate time spent (e.g. \"Claude: ~45min\")\n\n## What I Used Them For\n- For each tool: coding, writing, research, or brainstorming\n\n## Usage Patterns\n- Do I switch between tools? Use them in bursts or steadily?\n\n## Effectiveness\n- Which tool appeared alongside completed work vs. abandoned attempts\n\nIf no AI usage is found, say so clearly. End with: \"**Tip:** [one suggestion to use AI tools more effectively]\"\n\n=== /volume1/screenpipe/pipes/day-recap/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Day Recap\ndescription: \"Today's accomplishments, key moments, and unfinished work\"\nicon: \"📋\"\nfeatured: true\n---\n\nAnalyze my screen and audio recordings from today (last 16 hours only). \n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Summary\nOne sentence: what I mainly did today.\n\n## Accomplishments\n- Top 3 things I finished, with timestamps (e.g. \"2:30 PM\")\n- Name specific apps, files, or projects\n\n## Key Moments\n- Important things I saw, said, or heard — with timestamps\n\n## Unfinished Work\n- What I should continue tomorrow — name the app/file/task\n\n## Patterns\n- Apps I used most, topics that came up repeatedly\n\nOnly report what you can verify from the data. End with: \"**Next step:** [most important thing to continue]\"\n\n=== /volume1/screenpipe/pipes/meeting-summary/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Meeting Summary\ndescription: \"Summarize meeting transcript with key takeaways and action items\"\nicon: \"🤝\"\nfeatured: false\n---\n\nSummarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.\n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Meeting Summary\nOne sentence: what this meeting was about.\n\n## Key Takeaways\n- Top 3-5 important points discussed\n- Include who said what when relevant\n\n## Action Items\n- [ ] Task — assigned to whom, deadline if mentioned\n- [ ] Task — assigned to whom\n\n## Decisions Made\n- List any decisions or agreements reached\n\n## Open Questions\n- Anything unresolved or needing follow-up\n\nKeep it concise and actionable.\n\n=== /volume1/screenpipe/pipes/standup-update/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Standup Update\ndescription: \"What you did, what's next, and any blockers\"\nicon: \"🏢\"\nfeatured: true\n---\n\nBased on my recordings from the last 24 hours, generate a standup update. Use limit=10 per search, max 3 searches total.\n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Yesterday\n- What I worked on (name specific projects, files, tools, PRs)\n\n## Today\n- What I will work on next (based on unfinished tasks and recent activity)\n\n## Blockers\n- Issues I hit — errors, slow builds, waiting on someone\n- If no blockers, write \"None\"\n\nKeep it under 150 words. Copy-paste ready for a team standup.\n\n=== /volume1/screenpipe/pipes/time-breakdown/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Time Breakdown\ndescription: \"Where your time went — by app, project, and category\"\nicon: \"⏱\"\nfeatured: false\n---\n\nAnalyze my app usage from today (last 12 hours). Use limit=10 per search, max 4 searches. Prefer /raw_sql with COUNT/GROUP BY queries.\n\nRead screenpipe skill first.\n\nUse this exact format with durations and percentages:\n\n## By Application\n- List each app with duration and percentage, sorted by time (e.g. \"VS Code: 2h 15min (28%)\")\n\n## By Category\n- Group into: coding, meetings, browsing, writing, communication, other\n- Show hours and percentage per category\n\n## By Project\n- Group related activities by project/topic. Name specific repos or tasks.\n\n## Productivity Score\n- Calculate: focused_work_hours / total_hours as a percentage\n- Focused = coding + writing. Unfocused = browsing + switching.\n\nEnd with: \"**Suggestion:** [one specific change to improve tomorrow's productivity]\"\n\n=== /volume1/screenpipe/pipes/video-export/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Export Video Clip\ndescription: \"Create a video of your recent screen activity\"\nicon: \"🎬\"\nfeatured: false\n---\n\nExport a video of my screen activity from the last 5 minutes.\n\nRead screenpipe skill first.\n\nUse the POST /frames/export endpoint with the time range and fps=1.0. Then show me the exported video file path as an inline code block so I can watch it.\n\nIf the export is large, suggest a lower fps or shorter time range.","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Now I have a clear picture. The pipes are markdown prompt templates in","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"/volume1/screenpipe/pipes/","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":", but there's no code to actually load and run them —","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"consumers/summary.py","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"has its own hardcoded prompts instead.","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Here's what I'll implement:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"consumers/pipes.py","depth":26,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"— dynamically loads pipe.md files and runs them via Claude (data injected as system message, pipe body as user prompt)","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"main.py","depth":26,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"— two new endpoints:","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"GET /api/pipes","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"and","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"POST /api/pipes/{pipe_id}/run","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"cli.py","depth":26,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"— a","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"pipe","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"command to run pipes from the terminal","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Let me build it:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Check browser_urls signature","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"cat /volume1/screenpipe/app/consumers/activity.py | grep \"def browser_urls\" -A 5","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"def browser_urls(\n for_date: date | None = None,\n app_name: str | None = None,\n ts_from: str | None = None,\n ts_to: str | None = None,\n limit: int = 30,","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Write","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"pipes.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"pipes.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"143 lines","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"\"\"\"Dynamic pipe loader and runner.\"\"\"\nimport os\nimport re\nfrom datetime import date\nfrom pathlib import Path\nfrom typing import Any\n\n\ndef _parse_frontmatter(text: str) -> tuple[dict, str]:\n if not text.startswith(\"---\"):\n return {}, text\n try:\n end = text.index(\"---\", 3)\n except ValueError:\n return {}, text\n fm_text = text[3:end].strip()\n body = text[end + 3:].strip()\n meta: dict = {}\n for line in fm_text.splitlines():\n if \":\" in line:\n k, _, v = line.partition(\":\")\n meta[k.strip()] = v.strip().strip('\"')\n return meta, body\n\n\ndef load_pipes(pipes_dir: Path) -> list[dict]:\n if not pipes_dir.exists():\n return []\n pipes = []\n for pipe_dir in sorted(pipes_dir.iterdir()):\n if not pipe_dir.is_dir() or pipe_dir.name.startswith(\".\"):\n continue\n pipe_md = pipe_dir / \"pipe.md\"\n if not pipe_md.exists():\n continue\n text = pipe_md.read_text(encoding=\"utf-8\")\n meta, body = _parse_frontmatter(text)\n if meta.get(\"enabled\", \"true\").lower() == \"false\":\n continue\n body = re.sub(r\"Read screenpipe skill first\\.?\\n?\", \"\", body).strip()\n pipes.append({\n \"id\": pipe_dir.name,\n \"title\": meta.get(\"title\", pipe_dir.name),\n \"description\": meta.get(\"description\", \"\"),\n \"icon\": meta.get(\"icon\", \"\"),\n \"schedule\": meta.get(\"schedule\", \"manual\"),\n \"featured\": meta.get(\"featured\", \"false\").lower() == \"true\",\n \"prompt\": body,\n })\n return pipes\n\n\ndef _build_system(d: date, stats: dict) -> str:\n from consumers.activity import app_time, browser_urls, ui_event_summary\n from consumers.ocr import deduplicated_text\n from consumers.audio import formatted_transcript\n\n apps = app_time(d)\n app_lines = \"\\n\".join(f\"- {a['app_name']}: {a['minutes']} min\" for a in apps[:20])\n\n urls = browser_urls(d, limit=20)\n url_lines = \"\\n\".join(f\"- {u['browser_url'][:100]} ({u['minutes']} min)\" for u in urls)\n\n ui_rows = ui_event_summary(d)\n ui_lines = \"\\n\".join(\n f\"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches\"\n for r in ui_rows[:15]\n )\n\n ocr_rows = deduplicated_text(d, chunk_minutes=5)\n ocr_lines = \"\\n\".join(\n f\"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}\"\n for r in ocr_rows[:100]\n )\n\n audio = formatted_transcript(d)\n if len(audio) > 3000:\n audio = audio[:3000]\n\n return f\"\"\"You are analyzing screenpipe data — recordings of a person's computer activity.\n\n## App usage (minutes per app):\n{app_lines or '(no app data)'}\n\n## Browser URLs visited:\n{url_lines or '(no browser data)'}\n\n## UI activity per app (clicks / keystrokes / app-switches):\n{ui_lines or '(no UI event data)'}\n\n## Screen content (sampled every 5 minutes):\n{ocr_lines or '(no screen data)'}\n\n## Audio / speech:\n{audio or '(no audio data)'}\n\nDate: {d}\nTotal frames recorded: {stats['total_frames']}\"\"\"\n\n\ndef run_pipe(\n pipe_id: str,\n for_date: date | None = None,\n api_key: str | None = None,\n pipes_dir: Path | None = None,\n) -> dict[str, Any]:\n import anthropic\n from consumers.activity import summary_stats\n\n d = for_date or date.today()\n key = api_key or os.environ.get(\"ANTHROPIC_API_KEY\", \"\")\n if not key:\n return {\"title\": \"Error\", \"content\": \"ANTHROPIC_API_KEY not set.\", \"date\": str(d)}\n\n _pipes_dir = pipes_dir or Path(os.environ.get(\"PIPES_DIR\", \"/data/pipes\"))\n all_pipes = {p[\"id\"]: p for p in load_pipes(_pipes_dir)}\n\n if pipe_id not in all_pipes:\n return {\"title\": \"Error\", \"content\": f\"Pipe not found: {pipe_id}\", \"date\": str(d)}\n\n pipe = all_pipes[pipe_id]\n stats = summary_stats(d)\n\n if stats[\"total_frames\"] == 0:\n return {\"title\": pipe[\"title\"], \"content\": f\"No screen data found for {d}.\", \"date\": str(d)}\n\n system = _build_system(d, stats)\n\n client = anthropic.Anthropic(api_key=key)\n message = client.messages.create(\n model=\"claude-haiku-4-5-20251001\",\n max_tokens=1024,\n system=system,\n messages=[{\"role\": \"user\", \"content\": pipe[\"prompt\"]}],\n )\n\n return {\n \"title\": pipe[\"title\"],\n \"content\": message.content[0].text,\n \"date\": str(d),\n \"stats\": stats,\n }","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Now add the API endpoints to","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"main.py","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":":","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Edit","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"main.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
7967230859057505167
|
4472294119892815125
|
click
|
accessibility
|
NULL
|
Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧ Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py
M
db.py
docker-compose.yml
Dockerfile
M
main.py
M
requirements.txt
M
data
logs
pipes
.gitignore
app_settings.json
archive.db
archive.db-bak
U
db.sqlite
db.sqlite-shm
db.sqlite-wal
screenpipe_sync_updated.sh
U
screenpipe_sync.sh
screenpipe.db
Outline Section
OUTLINE
OUTLINE
Timeline Section
TIMELINE
TIMELINE
app_settings.json, Editor Group 1
screenpipe_sync.sh, Editor Group 1
pipe.md, Editor Group 1
.env, Editor Group 1
#!/bin/bash
# screenpipe_sync.sh
# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).
# Also copies the day's video/frame data folder to the NAS.
#
# Usage:
# ./screenpipe_sync.sh # syncs yesterday (default)
# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date
# ./screenpipe_sync.sh today # syncs today so far
#
# Cron example (runs at 3am daily):
# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1
set -euo pipefail
# ─── CONFIG ───────────────────────────────────────────────────────────────────
DB_SRC="${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}"
NAS_MOUNT="${NAS_MOUNT:-/Volumes/Test/screenpipe}"
NAS_DB="$NAS_MOUNT/archive.db"
NAS_DATA="$NAS_MOUNT/data"
LOG_FILE="$HOME/.screenpipe/sync.log"
# ──────────────────────────────────────────────────────────────────────────────
# ─── HELPERS ──────────────────────────────────────────────────────────────────
SCRIPT_START=$(date +%s)
log() {
local msg="[$(date '+%Y-%m-%d %H:%M:%S')] $*"
echo "$msg" | tee -a "$LOG_FILE"
}
step() {
local now=$(date +%s)
local elapsed=$(( now - SCRIPT_START ))
local min=$(( elapsed / 60 ))
local sec=$(( elapsed % 60 ))
printf "\n[+%02dm%02ds] ▶ %s\n" "$min" "$sec" "$*" | tee -a "$LOG_FILE"
}
run_sqlite_heredoc() {
local label="$1"
local sql="$2"
local start=$(date +%s)
printf " %-36s " "$label"
sqlite3 "$DB_SRC" <<< "$sql" &
local pid=$!
local spin=[PASSWORD] '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')
local i=0
while kill -0 "$pid" 2>/dev/null; do
printf "\r %-36s %s " "$label" "${spin[$i]}"
i=$(( (i + 1) % 10 ))
sleep 0.2
done
wait "$pid"
local rc=$?
if [ $rc -ne 0 ]; then
printf "\r %-36s ✗ FAILED\n" "$label" | tee -a "$LOG_FILE"
exit $rc
fi
local dur=$(( $(date +%s) - start ))
printf "\r %-36s ✓ %dm%02ds\n" "$label" "$(( dur / 60 ))" "$(( dur % 60 ))" | tee -a "$LOG_FILE"
}
check() {
local label="$1" got="$2" expected="$3"
if [ "$got" -eq "$expected" ]; then
printf " %-20s %s / %s ✓\n" "$label:" "$got" "$expected"
else
printf " %-20s %s / %s ✗ MISMATCH\n" "$label:" "$got" "$expected"
fi
}
# ──────────────────────────────────────────────────────────────────────────────
# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────
if [ "${1:-}" = "today" ]; then
TARGET_DATE=$(date +%Y-%m-%d)
elif [ -n "${1:-}" ]; then
TARGET_DATE="$1"
if ! [[ "$TARGET_DATE" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then
echo "ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday."
exit 1
fi
else
TARGET_DATE=$(date -v-1d +%Y-%m-%d)
fi
log "========================================"
log "Screenpipe sync starting for: $TARGET_DATE"
log "========================================"
# ─── PREFLIGHT ────────────────────────────────────────────────────────────────
step "Preflight checks"
if [ ! -f "$DB_SRC" ]; then
log "ERROR: Source DB not found at $DB_SRC"; exit 1
fi
printf " %-20s %s (%s)\n" "Source DB:" "OK" "$(du -sh "$DB_SRC" | cut -f1)"
if [ ! -d "$NAS_MOUNT" ]; then
log "ERROR: NAS not mounted at $NAS_MOUNT"; exit 1
fi
printf " %-20s %s\n" "NAS mount:" "OK $NAS_MOUNT"
# Check if DB already synced for this date
DB_ALREADY_SYNCED=false
if [ -f "$NAS_DB" ]; then
EXISTING=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';" 2>/dev/null || echo "0")
if [ "$EXISTING" -gt "0" ]; then
log "Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync"
DB_ALREADY_SYNCED=true
else
printf " %-20s %s (%s)\n" "Archive DB:" "exists" "$(du -sh "$NAS_DB" | cut -f1)"
fi
else
printf " %-20s %s\n" "Archive DB:" "will be created"
fi
# Source data dir for this date
DATA_SRC="$HOME/.screenpipe/data/data/$TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
DATA_SIZE=$(du -sh "$DATA_SRC" | cut -f1)
DATA_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
printf " %-20s %s (%s files, %s)\n" "Data dir:" "OK" "$DATA_FILES" "$DATA_SIZE"
else
printf " %-20s %s\n" "Data dir:" "not found — skipping file copy"
fi
# ─── DB SYNC ──────────────────────────────────────────────────────────────────
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────
step "Counting source rows for $TARGET_DATE"
SRC_FRAMES=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
SRC_ELEMENTS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_UI=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
SRC_OCR=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_MEETINGS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';")
printf " %-20s %s\n" "frames:" "$SRC_FRAMES"
printf " %-20s %s\n" "elements:" "$SRC_ELEMENTS"
printf " %-20s %s\n" "ui_events:" "$SRC_UI"
printf " %-20s %s\n" "ocr_text:" "$SRC_OCR"
printf " %-20s %s\n" "meetings:" "$SRC_MEETINGS"
if [ "$SRC_FRAMES" -eq "0" ]; then
log "No frames found for $TARGET_DATE — skipping DB sync"
DB_ALREADY_SYNCED=true
fi
fi
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── INIT TABLES ──────────────────────────────────────────────────────────
step "Initialising tables, indexes, FTS"
run_sqlite_heredoc "creating tables" "
ATTACH '$NAS_DB' AS nas;
CREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;
CREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;
CREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;
CREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;
DETACH nas;
"
run_sqlite_heredoc "creating indexes" "
ATTACH '$NAS_DB' AS nas;
CREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);
CREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);
DETACH nas;
"
run_sqlite_heredoc "creating FTS tables" "
ATTACH '$NAS_DB' AS nas;
CREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(
text, role, frame_id UNINDEXED,
content='elements', content_rowid='id', tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(
full_text, app_name, window_name, browser_url, id UNINDEXED,
tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(
text_content,
app_name,
window_title,
element_name,
content='ui_events',
content_rowid='id',
tokenize='unicode61'
);
DETACH nas;
"
# ─── SYNC DATA ────────────────────────────────────────────────────────────
step "Syncing data for $TARGET_DATE"
run_sqlite_heredoc "video_chunks" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.video_chunks
SELECT * FROM main.video_chunks
WHERE id IN (
SELECT DISTINCT video_chunk_id FROM main.frames
WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL
);
DETACH nas;
"
run_sqlite_heredoc "frames ($SRC_FRAMES rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.frames
SELECT * FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ocr_text ($SRC_OCR rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ocr_text
SELECT o.* FROM main.ocr_text o
JOIN main.frames f ON o.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ui_events ($SRC_UI rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ui_events
SELECT * FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "elements ($SRC_ELEMENTS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.elements
SELECT e.* FROM main.elements e
JOIN main.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "meetings ($SRC_MEETINGS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.meetings
SELECT * FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';
DETACH nas;
"
# ─── FTS UPDATE ───────────────────────────────────────────────────────────
step "Updating FTS indexes"
run_sqlite_heredoc "elements_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.elements_fts(rowid, text, role)
SELECT e.id, e.text, e.role
FROM nas.elements e
JOIN nas.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE'
AND e.text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "frames_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)
SELECT id, full_text, app_name, window_name, browser_url, id
FROM nas.frames
WHERE date(timestamp) = '$TARGET_DATE'
AND full_text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "ui_events_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)
SELECT id, text_content, app_name, window_title, element_name
FROM nas.ui_events
WHERE date(timestamp) = '$TARGET_DATE'
AND text_content IS NOT NULL;
DETACH nas;
"
# ─── VERIFY DB ────────────────────────────────────────────────────────────
step "Verifying DB"
V_FRAMES=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
V_ELEMENTS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_UI=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
V_OCR=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_MEETINGS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';")
check "frames" "$V_FRAMES" "$SRC_FRAMES"
check "elements" "$V_ELEMENTS" "$SRC_ELEMENTS"
check "ui_events" "$V_UI" "$SRC_UI"
check "ocr_text" "$V_OCR" "$SRC_OCR"
check "meetings" "$V_MEETINGS" "$SRC_MEETINGS"
fi
# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────
# Always runs regardless of DB sync status
step "Copying data folder for $TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
mkdir -p "$NAS_DATA/$TARGET_DATE"
RSYNC_START=$(date +%s)
printf " %-36s " "rsync $TARGET_DATE/ → NAS"
rsync -a --ignore-existing \
"$DATA_SRC/" \
"$NAS_DATA/$TARGET_DATE/" \
2>>"$LOG_FILE"
RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))
COPIED_FILES=$(ls "$NAS_DATA/$TARGET_DATE" | wc -l | tr -d ' ')
SRC_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
COPIED_SIZE=$(du -sh "$NAS_DATA/$TARGET_DATE" | cut -f1)
if [ "$COPIED_FILES" -eq "$SRC_FILES" ]; then
printf "\r %-36s ✓ %dm%02ds (%s files, %s)\n" \
"rsync $TARGET_DATE/ → NAS" \
"$(( RSYNC_DUR / 60 ))" "$(( RSYNC_DUR % 60 ))" \
"$COPIED_FILES" "$COPIED_SIZE" | tee -a "$LOG_FILE"
else
printf "\r %-36s ✗ %s / %s files\n" \
"rsync $TARGET_DATE/ → NAS" "$COPIED_FILES" "$SRC_FILES" | tee -a "$LOG_FILE"
fi
else
printf " %-36s %s\n" "rsync $TARGET_DATE/ → NAS" "skipped (no source dir)"
fi
# ─── SUMMARY ──────────────────────────────────────────────────────────────────
TOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))
DB_SIZE=$(du -sh "$NAS_DB" | cut -f1)
echo ""
log "Archive DB size: $DB_SIZE"
log "Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s"
log "Sync complete for $TARGET_DATE"
log "========================================"
#!/bin/bash
# screenpipe_sync.sh
# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).
# Also copies the day's video/frame data folder to the NAS.
#
# Usage:
# ./screenpipe_sync.sh # syncs yesterday (default)
# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date
# ./screenpipe_sync.sh today # syncs today so far
#
# Cron example (runs at 3am daily):
# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1
set -euo pipefail
# ─── CONFIG ───────────────────────────────────────────────────────────────────
DB_SRC="${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}"
NAS_MOUNT="${NAS_MOUNT:-/Volumes/Test/screenpipe}"
NAS_DB="$NAS_MOUNT/archive.db"
NAS_DATA="$NAS_MOUNT/data"
LOG_FILE="$HOME/.screenpipe/sync.log"
# ──────────────────────────────────────────────────────────────────────────────
# ─── HELPERS ──────────────────────────────────────────────────────────────────
SCRIPT_START=$(date +%s)
log() {
local msg="[$(date '+%Y-%m-%d %H:%M:%S')] $*"
echo "$msg" | tee -a "$LOG_FILE"
}
step() {
local now=$(date +%s)
local elapsed=$(( now - SCRIPT_START ))
local min=$(( elapsed / 60 ))
local sec=$(( elapsed % 60 ))
printf "\n[+%02dm%02ds] ▶ %s\n" "$min" "$sec" "$*" | tee -a "$LOG_FILE"
}
run_sqlite_heredoc() {
local label="$1"
local sql="$2"
local start=$(date +%s)
printf " %-36s " "$label"
sqlite3 "$DB_SRC" <<< "$sql" &
local pid=$!
local spin=[PASSWORD] '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')
local i=0
while kill -0 "$pid" 2>/dev/null; do
printf "\r %-36s %s " "$label" "${spin[$i]}"
i=$(( (i + 1) % 10 ))
sleep 0.2
done
wait "$pid"
local rc=$?
if [ $rc -ne 0 ]; then
printf "\r %-36s ✗ FAILED\n" "$label" | tee -a "$LOG_FILE"
exit $rc
fi
local dur=$(( $(date +%s) - start ))
printf "\r %-36s ✓ %dm%02ds\n" "$label" "$(( dur / 60 ))" "$(( dur % 60 ))" | tee -a "$LOG_FILE"
}
check() {
local label="$1" got="$2" expected="$3"
if [ "$got" -eq "$expected" ]; then
printf " %-20s %s / %s ✓\n" "$label:" "$got" "$expected"
else
printf " %-20s %s / %s ✗ MISMATCH\n" "$label:" "$got" "$expected"
fi
}
# ──────────────────────────────────────────────────────────────────────────────
# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────
if [ "${1:-}" = "today" ]; then
TARGET_DATE=$(date +%Y-%m-%d)
elif [ -n "${1:-}" ]; then
TARGET_DATE="$1"
if ! [[ "$TARGET_DATE" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then
echo "ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday."
exit 1
fi
else
TARGET_DATE=$(date -v-1d +%Y-%m-%d)
fi
log "========================================"
log "Screenpipe sync starting for: $TARGET_DATE"
log "========================================"
# ─── PREFLIGHT ────────────────────────────────────────────────────────────────
step "Preflight checks"
if [ ! -f "$DB_SRC" ]; then
log "ERROR: Source DB not found at $DB_SRC"; exit 1
fi
printf " %-20s %s (%s)\n" "Source DB:" "OK" "$(du -sh "$DB_SRC" | cut -f1)"
if [ ! -d "$NAS_MOUNT" ]; then
log "ERROR: NAS not mounted at $NAS_MOUNT"; exit 1
fi
printf " %-20s %s\n" "NAS mount:" "OK $NAS_MOUNT"
# Check if DB already synced for this date
DB_ALREADY_SYNCED=false
if [ -f "$NAS_DB" ]; then
EXISTING=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';" 2>/dev/null || echo "0")
if [ "$EXISTING" -gt "0" ]; then
log "Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync"
DB_ALREADY_SYNCED=true
else
printf " %-20s %s (%s)\n" "Archive DB:" "exists" "$(du -sh "$NAS_DB" | cut -f1)"
fi
else
printf " %-20s %s\n" "Archive DB:" "will be created"
fi
# Source data dir for this date
DATA_SRC="$HOME/.screenpipe/data/data/$TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
DATA_SIZE=$(du -sh "$DATA_SRC" | cut -f1)
DATA_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
printf " %-20s %s (%s files, %s)\n" "Data dir:" "OK" "$DATA_FILES" "$DATA_SIZE"
else
printf " %-20s %s\n" "Data dir:" "not found — skipping file copy"
fi
# ─── DB SYNC ──────────────────────────────────────────────────────────────────
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────
step "Counting source rows for $TARGET_DATE"
SRC_FRAMES=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
SRC_ELEMENTS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_UI=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
SRC_OCR=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_MEETINGS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';")
printf " %-20s %s\n" "frames:" "$SRC_FRAMES"
printf " %-20s %s\n" "elements:" "$SRC_ELEMENTS"
printf " %-20s %s\n" "ui_events:" "$SRC_UI"
printf " %-20s %s\n" "ocr_text:" "$SRC_OCR"
printf " %-20s %s\n" "meetings:" "$SRC_MEETINGS"
if [ "$SRC_FRAMES" -eq "0" ]; then
log "No frames found for $TARGET_DATE — skipping DB sync"
DB_ALREADY_SYNCED=true
fi
fi
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── INIT TABLES ──────────────────────────────────────────────────────────
step "Initialising tables, indexes, FTS"
run_sqlite_heredoc "creating tables" "
ATTACH '$NAS_DB' AS nas;
CREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;
CREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;
CREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;
CREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;
DETACH nas;
"
run_sqlite_heredoc "creating indexes" "
ATTACH '$NAS_DB' AS nas;
CREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);
CREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);
DETACH nas;
"
run_sqlite_heredoc "creating FTS tables" "
ATTACH '$NAS_DB' AS nas;
CREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(
text, role, frame_id UNINDEXED,
content='elements', content_rowid='id', tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(
full_text, app_name, window_name, browser_url, id UNINDEXED,
tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(
text_content,
app_name,
window_title,
element_name,
content='ui_events',
content_rowid='id',
tokenize='unicode61'
);
DETACH nas;
"
# ─── SYNC DATA ────────────────────────────────────────────────────────────
step "Syncing data for $TARGET_DATE"
run_sqlite_heredoc "video_chunks" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.video_chunks
SELECT * FROM main.video_chunks
WHERE id IN (
SELECT DISTINCT video_chunk_id FROM main.frames
WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL
);
DETACH nas;
"
run_sqlite_heredoc "frames ($SRC_FRAMES rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.frames
SELECT * FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ocr_text ($SRC_OCR rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ocr_text
SELECT o.* FROM main.ocr_text o
JOIN main.frames f ON o.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ui_events ($SRC_UI rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ui_events
SELECT * FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "elements ($SRC_ELEMENTS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.elements
SELECT e.* FROM main.elements e
JOIN main.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "meetings ($SRC_MEETINGS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.meetings
SELECT * FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';
DETACH nas;
"
# ─── FTS UPDATE ───────────────────────────────────────────────────────────
step "Updating FTS indexes"
run_sqlite_heredoc "elements_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.elements_fts(rowid, text, role)
SELECT e.id, e.text, e.role
FROM nas.elements e
JOIN nas.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE'
AND e.text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "frames_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)
SELECT id, full_text, app_name, window_name, browser_url, id
FROM nas.frames
WHERE date(timestamp) = '$TARGET_DATE'
AND full_text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "ui_events_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)
SELECT id, text_content, app_name, window_title, element_name
FROM nas.ui_events
WHERE date(timestamp) = '$TARGET_DATE'
AND text_content IS NOT NULL;
DETACH nas;
"
# ─── VERIFY DB ────────────────────────────────────────────────────────────
step "Verifying DB"
V_FRAMES=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
V_ELEMENTS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_UI=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
V_OCR=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_MEETINGS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';")
check "frames" "$V_FRAMES" "$SRC_FRAMES"
check "elements" "$V_ELEMENTS" "$SRC_ELEMENTS"
check "ui_events" "$V_UI" "$SRC_UI"
check "ocr_text" "$V_OCR" "$SRC_OCR"
check "meetings" "$V_MEETINGS" "$SRC_MEETINGS"
fi
# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────
# Always runs regardless of DB sync status
step "Copying data folder for $TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
mkdir -p "$NAS_DATA/$TARGET_DATE"
RSYNC_START=$(date +%s)
printf " %-36s " "rsync $TARGET_DATE/ → NAS"
rsync -a --ignore-existing \
"$DATA_SRC/" \
"$NAS_DATA/$TARGET_DATE/" \
2>>"$LOG_FILE"
RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))
COPIED_FILES=$(ls "$NAS_DATA/$TARGET_DATE" | wc -l | tr -d ' ')
SRC_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
COPIED_SIZE=$(du -sh "$NAS_DATA/$TARGET_DATE" | cut -f1)
if [ "$COPIED_FILES" -eq "$SRC_FILES" ]; then
printf "\r %-36s ✓ %dm%02ds (%s files, %s)\n" \
"rsync $TARGET_DATE/ → NAS" \
"$(( RSYNC_DUR / 60 ))" "$(( RSYNC_DUR % 60 ))" \
"$COPIED_FILES" "$COPIED_SIZE" | tee -a "$LOG_FILE"
else
printf "\r %-36s ✗ %s / %s files\n" \
"rsync $TARGET_DATE/ → NAS" "$COPIED_FILES" "$SRC_FILES" | tee -a "$LOG_FILE"
fi
else
printf " %-36s %s\n" "rsync $TARGET_DATE/ → NAS" "skipped (no source dir)"
fi
# ─── SUMMARY ──────────────────────────────────────────────────────────────────
TOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))
DB_SIZE=$(du -sh "$NAS_DB" | cut -f1)
echo ""
log "Archive DB size: $DB_SIZE"
log "Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s"
log "Sync complete for $TARGET_DATE"
log "========================================"
Implement and run pipe l…, Editor Group 2
Problems (⇧⌘M)
PROBLEMS
Output (⇧⌘U)
OUTPUT
Debug Console (⇧⌘Y)
DEBUG CONSOLE
Terminal (⌃`)
TERMINAL
Ports - 1 forwarded port
PORTS
1
remote SSH: nas
SSH: nas
screenpipe (Git) - master*, Checkout Branch/Tag...
master*
screenpipe (Git) - Synchronize Changes
No Problems
0
0
Forwarded Ports: 8766
1
Notifications
Sign In
Sign In
Shell Script
Editor Language Status: $(copilot) No inline suggestion available, Inline suggestions
LF
UTF-8
Spaces: 2
Ln 39, Col 1
git-commit Lukas Kovalik (2 weeks ago)
Lukas Kovalik (2 weeks ago)
Info: Setting up SSH Host nas: Setting up SSH tunnel
Implement and run pipe logic
Session history
New session
Message actions
main.py
main.py
lets implement logic with pipes. how can I run it?
Thinking
Thinking
Let me look at the current project structure to understand what's already in place.
Bash
List project files
IN
find /volume1/screenpipe -type f | head -50 && echo "---" && ls /volume1/screenpipe
Copy code to clipboard
OUT
/volume1/screenpipe/.DS_Store
/volume1/screenpipe/screenpipe.db
/volume1/screenpipe/screenpipe_sync.sh
/volume1/screenpipe/app_settings.json
/volume1/screenpipe/.gitignore
/volume1/screenpipe/archive.db
/volume1/screenpipe/db.sqlite
/volume1/screenpipe/db.sqlite-wal
/volume1/screenpipe/db.sqlite-shm
/volume1/screenpipe/#recycle/desktop.ini
/volume1/screenpipe/#recycle/db.sqlite
/volume1/screenpipe/#recycle/Copy #1 of db.sqlite
/volume1/screenpipe/#recycle/.DS_Store
/volume1/screenpipe/#recycle/Copy #2 of db.sqlite
/volume1/screenpipe/#recycle/archive.db
/volume1/screenpipe/#recycle/Copy #1 of archive.db
/volume1/screenpipe/#recycle/Copy #2 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of archive.db
/volume1/screenpipe/#recycle/Copy #4 of archive.db
/volume1/screenpipe/#recycle/Copy #5 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of db.sqlite
/volume1/screenpipe/#recycle/Copy #4 of db.sqlite
/volume1/screenpipe/#recycle/Copy #6 of archive.db
/volume1/screenpipe/#recycle/test.txt
/volume1/screenpipe/#recycle/Copy #7 of archive.db
/volume1/screenpipe/#recycle/Copy #8 of archive.db
/volume1/screenpipe/#recycle/archive.db-journal
/volume1/screenpipe/#recycle/Copy #1 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #2 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #3 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #4 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #6 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #7 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of db.sqlite
/volume1/screenpipe/pipes/.DS_Store
/volume1/screenpipe/app/.env
/volume1/screenpipe/app/cli.py
/volume1/screenpipe/app/.DS_Store
/volume1/screenpipe/app/db.py
/volume1/screenpipe/app/docker-compose.yml
/volume1/screenpipe/app/main.py
/volume1/screenpipe/app/requirements.txt
/volume1/screenpipe/app/Dockerfile
/volume1/screenpipe/data/.DS_Store
/volume1/screenpipe/.git/description
/volume1/screenpipe/.git/HEAD
/volume1/screenpipe/.git/index
/volume1/screenpipe/.git/COMMIT_EDITMSG
/volume1/screenpipe/#recycle/data/.DS_Store
---
app
app_settings.json
archive.db
data
db.sqlite
db.sqlite-shm
db.sqlite-wal
pipes
#recycle
screenpipe.db
screenpipe_sync.sh
Read
main.py
main.py
Bash
Check pipes directory and docker-compose
IN
ls /volume1/screenpipe/pipes/ && ls /volume1/screenpipe/app/ && cat /volume1/screenpipe/app/docker-compose.yml
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
cli.py
consumers
db.py
docker-compose.yml
Dockerfile
main.py
__pycache__
requirements.txt
static
services:
screenpipe-app:
build: .
container_name: screenpipe-app
restart: unless-stopped
ports:
- "8766:8000"
volumes:
- /volume1/screenpipe:/data
env_file:
- .env
environment:
TZ: Europe/Sofia
DB_PATH: /data/db.sqlite
sqlite-web-archive:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-archive
restart: unless-stopped
ports:
- "8767:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/archive.db"]
sqlite-web-live:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-live
restart: unless-stopped
ports:
- "8768:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/db.sqlite"]
Read
requirements.txt
requirements.txt
Bash
Inspect a pipe directory
IN
ls /volume1/screenpipe/pipes/day-recap/ && cat /volume1/screenpipe/pipes/day-recap/pipe.json 2>/dev/null || ls /volume1/screenpipe/pipes/day-recap/
Copy code to clipboard
OUT
pipe.md
pipe.md
Read
cli.py
cli.py
Bash
List all pipes and their contents
IN
ls /volume1/screenpipe/pipes/ && for d in /volume1/screenpipe/pipes/*/; do echo "=== $d ==="; ls "$d"; done
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
=== /volume1/screenpipe/pipes/ai-habits/ ===
pipe.md
=== /volume1/screenpipe/pipes/day-recap/ ===
pipe.md
=== /volume1/screenpipe/pipes/meeting-summary/ ===
pipe.md
=== /volume1/screenpipe/pipes/standup-update/ ===
pipe.md
=== /volume1/screenpipe/pipes/time-breakdown/ ===
pipe.md
=== /volume1/screenpipe/pipes/video-export/ ===
pipe.md
Bash
Read pipe markdown files
IN
cat /volume1/screenpipe/pipes/day-recap/pipe.md && echo "===" && cat /volume1/screenpipe/pipes/meeting-summary/pipe.md 2>/dev/null | head -50
Copy code to clipboard
OUT
---
schedule: manual
enabled: true
template: true
title: Day Recap
description: "Today's accomplishments, key moments, and unfinished work"
icon: "📋"
featured: true
---
Analyze my screen and audio recordings from today (last 16 hours only).
Read screenpipe skill first.
Use this exact format:
## Summary
One sentence: what I mainly did today.
## Accomplishments
- Top 3 things I finished, with timestamps (e.g. "2:30 PM")
- Name specific apps, files, or projects
## Key Moments
- Important things I saw, said, or heard — with timestamps
## Unfinished Work
- What I should continue tomorrow — name the app/file/task
## Patterns
- Apps I used most, topics that came up repeatedly
Only report what you can verify from the data. End with: "**Next step:** [most important thing to continue]"
===
---
schedule: manual
enabled: true
template: true
title: Meeting Summary
description: "Summarize meeting transcript with key takeaways and action items"
icon: "🤝"
featured: false
---
Summarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.
Read screenpipe skill first.
Use this exact format:
## Meeting Summary
One sentence: what this meeting was about.
## Key Takeaways
- Top 3-5 important points discussed
- Include who said what when relevant
## Action Items
- [ ] Task — assigned to whom, deadline if mentioned
- [ ] Task — assigned to whom
## Decisions Made
- List any decisions or agreements reached
## Open Questions
- Anything unresolved or needing follow-up
Keep it concise and actionable.
Thinking
Thinking
Bash
Read summary consumer
IN
ls /volume1/screenpipe/app/consumers/ && cat /volume1/screenpipe/app/consumers/summary.py
Copy code to clipboard
OUT
activity.py
audio.py
elements.py
__init__.py
interactions.py
ocr.py
__pycache__
report.py
summary.py
"""AI summary generator using Claude."""
import os
from datetime import date
from typing import Any
from consumers.activity import app_time, summary_stats, browser_urls, ui_event_summary
from consumers.ocr import deduplicated_text
from consumers.audio import formatted_transcript
SUMMARY_TYPES = {
"day_recap": {
"title": "Day Recap",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
## Audio/speech:
{audio}
Write a concise day recap using EXACTLY this format:
## Summary
One sentence: what I mainly worked on today.
## Accomplishments
- Top 3 things I finished, with approximate times
- Name specific apps, files, or projects
## Key Moments
- Important things seen or heard, with timestamps
## Unfinished Work
- What to continue tomorrow
## Patterns
- Apps used most, topics that came up repeatedly
Only report what you can verify from the data. End with:
**Next step:** [most important thing to continue]""",
},
"standup": {
"title": "Standup Update",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
## Audio/speech:
{audio}
Write a brief standup update:
**Yesterday:** What I worked on (2-3 bullets)
**Today:** What I plan to continue (1-2 bullets)
**Blockers:** Any issues observed (or "None")
Keep it under 150 words. Only report what's verifiable from the data.""",
},
"focus_time": {
"title": "Focus & Distraction Analysis",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
Analyze focus vs distraction patterns:
## Deep Work Periods
- When and how long were sustained focus sessions?
- What was being worked on?
## Distractions
- Which apps/sites were used recreationally?
- How much time was lost to context switching?
## Recommendations
- 2-3 concrete suggestions to improve focus tomorrow
Be specific with times and app names.""",
},
}
def _build_context(for_date: date) -> dict[str, str]:
apps = app_time(for_date)
app_lines = "\n".join(f"- {a['app_name']}: {a['minutes']} min" for a in apps[:20])
urls = browser_urls(for_date, limit=20)
url_lines = "\n".join(
f"- {u['browser_url'][:100]} ({u['minutes']} min)" for u in urls
)
ui_rows = ui_event_summary(for_date)
ui_lines = "\n".join(
f"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches"
for r in ui_rows[:15]
)
ocr_rows = deduplicated_text(for_date, chunk_minutes=5)
ocr_lines = "\n".join(
f"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}"
for r in ocr_rows[:100]
)
audio = formatted_transcript(for_date)
return {
"app_time": app_lines or "(no app data)",
"browser_urls": url_lines or "(no browser data)",
"ui_events": ui_lines or "(no UI event data)",
"ocr_text": ocr_lines or "(no screen data)",
"audio": audio[:3000] if len(audio) > 3000 else audio,
}
def generate(
summary_type: str = "day_recap",
for_date: date | None = None,
api_key: str | None = None,
) -> dict[str, Any]:
"""Generate an AI summary. Returns dict with 'title', 'content', 'date'."""
import anthropic
d = for_date or date.today()
key = api_key or os.environ.get("ANTHROPIC_API_KEY", "")
if not key:
return {
"title": "Error",
"content": "ANTHROPIC_API_KEY not set. Add it to your .env file.",
"date": str(d),
}
spec = SUMMARY_TYPES.get(summary_type)
if not spec:
return {"title": "Error", "content": f"Unknown summary type: {summary_type}", "date": str(d)}
stats = summary_stats(d)
if stats["total_frames"] == 0:
return {
"title": spec["title"],
"content": f"No screen data found for {d}.",
"date": str(d),
}
ctx = _build_context(d)
prompt = spec["prompt"].format(**ctx)
client = anthropic.Anthropic(api_key=key)
message = client.messages.create(
model="claude-haiku-4-5-20251001",
max_tokens=1024,
messages=[{"role": "user", "content": prompt}],
)
return {
"title": spec["title"],
"content": message.content[0].text,
"date": str(d),
"stats": stats,
}
Thinking
Thinking
Bash
Read all pipe.md files
IN
for f in /volume1/screenpipe/pipes/*/pipe.md; do echo "=== $f ==="; cat "$f"; echo; done
Copy code to clipboard
OUT
=== /volume1/screenpipe/pipes/ai-habits/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: AI Habits
description: "How you use AI tools — patterns and insights"
icon: "🤖"
featured: true
---
Search my recordings from the last 24 hours for AI tool usage. Use app_name filter for each tool separately: ChatGPT, Claude, Copilot, Cursor, Gemini, Perplexity. Use limit=5 per search, max 6 searches total.
Read screenpipe skill first.
Use this exact format:
## AI Tools Used
- List each tool with approximate time spent (e.g. "Claude: ~45min")
## What I Used Them For
- For each tool: coding, writing, research, or brainstorming
## Usage Patterns
- Do I switch between tools? Use them in bursts or steadily?
## Effectiveness
- Which tool appeared alongside completed work vs. abandoned attempts
If no AI usage is found, say so clearly. End with: "**Tip:** [one suggestion to use AI tools more effectively]"
=== /volume1/screenpipe/pipes/day-recap/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Day Recap
description: "Today's accomplishments, key moments, and unfinished work"
icon: "📋"
featured: true
---
Analyze my screen and audio recordings from today (last 16 hours only).
Read screenpipe skill first.
Use this exact format:
## Summary
One sentence: what I mainly did today.
## Accomplishments
- Top 3 things I finished, with timestamps (e.g. "2:30 PM")
- Name specific apps, files, or projects
## Key Moments
- Important things I saw, said, or heard — with timestamps
## Unfinished Work
- What I should continue tomorrow — name the app/file/task
## Patterns
- Apps I used most, topics that came up repeatedly
Only report what you can verify from the data. End with: "**Next step:** [most important thing to continue]"
=== /volume1/screenpipe/pipes/meeting-summary/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Meeting Summary
description: "Summarize meeting transcript with key takeaways and action items"
icon: "🤝"
featured: false
---
Summarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.
Read screenpipe skill first.
Use this exact format:
## Meeting Summary
One sentence: what this meeting was about.
## Key Takeaways
- Top 3-5 important points discussed
- Include who said what when relevant
## Action Items
- [ ] Task — assigned to whom, deadline if mentioned
- [ ] Task — assigned to whom
## Decisions Made
- List any decisions or agreements reached
## Open Questions
- Anything unresolved or needing follow-up
Keep it concise and actionable.
=== /volume1/screenpipe/pipes/standup-update/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Standup Update
description: "What you did, what's next, and any blockers"
icon: "🏢"
featured: true
---
Based on my recordings from the last 24 hours, generate a standup update. Use limit=10 per search, max 3 searches total.
Read screenpipe skill first.
Use this exact format:
## Yesterday
- What I worked on (name specific projects, files, tools, PRs)
## Today
- What I will work on next (based on unfinished tasks and recent activity)
## Blockers
- Issues I hit — errors, slow builds, waiting on someone
- If no blockers, write "None"
Keep it under 150 words. Copy-paste ready for a team standup.
=== /volume1/screenpipe/pipes/time-breakdown/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Time Breakdown
description: "Where your time went — by app, project, and category"
icon: "⏱"
featured: false
---
Analyze my app usage from today (last 12 hours). Use limit=10 per search, max 4 searches. Prefer /raw_sql with COUNT/GROUP BY queries.
Read screenpipe skill first.
Use this exact format with durations and percentages:
## By Application
- List each app with duration and percentage, sorted by time (e.g. "VS Code: 2h 15min (28%)")
## By Category
- Group into: coding, meetings, browsing, writing, communication, other
- Show hours and percentage per category
## By Project
- Group related activities by project/topic. Name specific repos or tasks.
## Productivity Score
- Calculate: focused_work_hours / total_hours as a percentage
- Focused = coding + writing. Unfocused = browsing + switching.
End with: "**Suggestion:** [one specific change to improve tomorrow's productivity]"
=== /volume1/screenpipe/pipes/video-export/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Export Video Clip
description: "Create a video of your recent screen activity"
icon: "🎬"
featured: false
---
Export a video of my screen activity from the last 5 minutes.
Read screenpipe skill first.
Use the POST /frames/export endpoint with the time range and fps=1.0. Then show me the exported video file path as an inline code block so I can watch it.
If the export is large, suggest a lower fps or shorter time range.
Thinking
Thinking
Now I have a clear picture. The pipes are markdown prompt templates in
/volume1/screenpipe/pipes/
, but there's no code to actually load and run them —
consumers/summary.py
has its own hardcoded prompts instead.
Here's what I'll implement:
consumers/pipes.py
— dynamically loads pipe.md files and runs them via Claude (data injected as system message, pipe body as user prompt)
main.py
— two new endpoints:
GET /api/pipes
and
POST /api/pipes/{pipe_id}/run
cli.py
— a
pipe
command to run pipes from the terminal
Let me build it:
Bash
Check browser_urls signature
IN
cat /volume1/screenpipe/app/consumers/activity.py | grep "def browser_urls" -A 5
Copy code to clipboard
OUT
def browser_urls(
for_date: date | None = None,
app_name: str | None = None,
ts_from: str | None = None,
ts_to: str | None = None,
limit: int = 30,
Write
pipes.py
pipes.py
143 lines
"""Dynamic pipe loader and runner."""
import os
import re
from datetime import date
from pathlib import Path
from typing import Any
def _parse_frontmatter(text: str) -> tuple[dict, str]:
if not text.startswith("---"):
return {}, text
try:
end = text.index("---", 3)
except ValueError:
return {}, text
fm_text = text[3:end].strip()
body = text[end + 3:].strip()
meta: dict = {}
for line in fm_text.splitlines():
if ":" in line:
k, _, v = line.partit...
|
21096
|
NULL
|
NULL
|
NULL
|
|
21098
|
923
|
8
|
2026-05-11T17:12:04.507254+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-11/1778 /Users/lukas/.screenpipe/data/data/2026-05-11/1778519524507_m2.jpg...
|
Code
|
screenpipe_sync.sh — screenpipe [SSH: nas]
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧ Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py
M
db.py
docker-compose.yml
Dockerfile
M
main.py
M
requirements.txt
M
data
logs
pipes
.gitignore
app_settings.json
archive.db
archive.db-bak
U
db.sqlite
db.sqlite-shm
db.sqlite-wal
screenpipe_sync_updated.sh
U
screenpipe_sync.sh
screenpipe.db
Outline Section
OUTLINE
OUTLINE
Timeline Section
TIMELINE
TIMELINE
app_settings.json, Editor Group 1
screenpipe_sync.sh, Editor Group 1
pipe.md, Editor Group 1
.env, Editor Group 1
#!/bin/bash
# screenpipe_sync.sh
# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).
# Also copies the day's video/frame data folder to the NAS.
#
# Usage:
# ./screenpipe_sync.sh # syncs yesterday (default)
# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date
# ./screenpipe_sync.sh today # syncs today so far
#
# Cron example (runs at 3am daily):
# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1
set -euo pipefail
# ─── CONFIG ───────────────────────────────────────────────────────────────────
DB_SRC="${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}"
NAS_MOUNT="${NAS_MOUNT:-/Volumes/Test/screenpipe}"
NAS_DB="$NAS_MOUNT/archive.db"
NAS_DATA="$NAS_MOUNT/data"
LOG_FILE="$HOME/.screenpipe/sync.log"
# ──────────────────────────────────────────────────────────────────────────────
# ─── HELPERS ──────────────────────────────────────────────────────────────────
SCRIPT_START=$(date +%s)
log() {
local msg="[$(date '+%Y-%m-%d %H:%M:%S')] $*"
echo "$msg" | tee -a "$LOG_FILE"
}
step() {
local now=$(date +%s)
local elapsed=$(( now - SCRIPT_START ))
local min=$(( elapsed / 60 ))
local sec=$(( elapsed % 60 ))
printf "\n[+%02dm%02ds] ▶ %s\n" "$min" "$sec" "$*" | tee -a "$LOG_FILE"
}
run_sqlite_heredoc() {
local label="$1"
local sql="$2"
local start=$(date +%s)
printf " %-36s " "$label"
sqlite3 "$DB_SRC" <<< "$sql" &
local pid=$!
local spin=[PASSWORD] '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')
local i=0
while kill -0 "$pid" 2>/dev/null; do
printf "\r %-36s %s " "$label" "${spin[$i]}"
i=$(( (i + 1) % 10 ))
sleep 0.2
done
wait "$pid"
local rc=$?
if [ $rc -ne 0 ]; then
printf "\r %-36s ✗ FAILED\n" "$label" | tee -a "$LOG_FILE"
exit $rc
fi
local dur=$(( $(date +%s) - start ))
printf "\r %-36s ✓ %dm%02ds\n" "$label" "$(( dur / 60 ))" "$(( dur % 60 ))" | tee -a "$LOG_FILE"
}
check() {
local label="$1" got="$2" expected="$3"
if [ "$got" -eq "$expected" ]; then
printf " %-20s %s / %s ✓\n" "$label:" "$got" "$expected"
else
printf " %-20s %s / %s ✗ MISMATCH\n" "$label:" "$got" "$expected"
fi
}
# ──────────────────────────────────────────────────────────────────────────────
# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────
if [ "${1:-}" = "today" ]; then
TARGET_DATE=$(date +%Y-%m-%d)
elif [ -n "${1:-}" ]; then
TARGET_DATE="$1"
if ! [[ "$TARGET_DATE" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then
echo "ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday."
exit 1
fi
else
TARGET_DATE=$(date -v-1d +%Y-%m-%d)
fi
log "========================================"
log "Screenpipe sync starting for: $TARGET_DATE"
log "========================================"
# ─── PREFLIGHT ────────────────────────────────────────────────────────────────
step "Preflight checks"
if [ ! -f "$DB_SRC" ]; then
log "ERROR: Source DB not found at $DB_SRC"; exit 1
fi
printf " %-20s %s (%s)\n" "Source DB:" "OK" "$(du -sh "$DB_SRC" | cut -f1)"
if [ ! -d "$NAS_MOUNT" ]; then
log "ERROR: NAS not mounted at $NAS_MOUNT"; exit 1
fi
printf " %-20s %s\n" "NAS mount:" "OK $NAS_MOUNT"
# Check if DB already synced for this date
DB_ALREADY_SYNCED=false
if [ -f "$NAS_DB" ]; then
EXISTING=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';" 2>/dev/null || echo "0")
if [ "$EXISTING" -gt "0" ]; then
log "Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync"
DB_ALREADY_SYNCED=true
else
printf " %-20s %s (%s)\n" "Archive DB:" "exists" "$(du -sh "$NAS_DB" | cut -f1)"
fi
else
printf " %-20s %s\n" "Archive DB:" "will be created"
fi
# Source data dir for this date
DATA_SRC="$HOME/.screenpipe/data/data/$TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
DATA_SIZE=$(du -sh "$DATA_SRC" | cut -f1)
DATA_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
printf " %-20s %s (%s files, %s)\n" "Data dir:" "OK" "$DATA_FILES" "$DATA_SIZE"
else
printf " %-20s %s\n" "Data dir:" "not found — skipping file copy"
fi
# ─── DB SYNC ──────────────────────────────────────────────────────────────────
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────
step "Counting source rows for $TARGET_DATE"
SRC_FRAMES=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
SRC_ELEMENTS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_UI=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
SRC_OCR=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_MEETINGS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';")
printf " %-20s %s\n" "frames:" "$SRC_FRAMES"
printf " %-20s %s\n" "elements:" "$SRC_ELEMENTS"
printf " %-20s %s\n" "ui_events:" "$SRC_UI"
printf " %-20s %s\n" "ocr_text:" "$SRC_OCR"
printf " %-20s %s\n" "meetings:" "$SRC_MEETINGS"
if [ "$SRC_FRAMES" -eq "0" ]; then
log "No frames found for $TARGET_DATE — skipping DB sync"
DB_ALREADY_SYNCED=true
fi
fi
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── INIT TABLES ──────────────────────────────────────────────────────────
step "Initialising tables, indexes, FTS"
run_sqlite_heredoc "creating tables" "
ATTACH '$NAS_DB' AS nas;
CREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;
CREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;
CREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;
CREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;
DETACH nas;
"
run_sqlite_heredoc "creating indexes" "
ATTACH '$NAS_DB' AS nas;
CREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);
CREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);
DETACH nas;
"
run_sqlite_heredoc "creating FTS tables" "
ATTACH '$NAS_DB' AS nas;
CREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(
text, role, frame_id UNINDEXED,
content='elements', content_rowid='id', tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(
full_text, app_name, window_name, browser_url, id UNINDEXED,
tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(
text_content,
app_name,
window_title,
element_name,
content='ui_events',
content_rowid='id',
tokenize='unicode61'
);
DETACH nas;
"
# ─── SYNC DATA ────────────────────────────────────────────────────────────
step "Syncing data for $TARGET_DATE"
run_sqlite_heredoc "video_chunks" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.video_chunks
SELECT * FROM main.video_chunks
WHERE id IN (
SELECT DISTINCT video_chunk_id FROM main.frames
WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL
);
DETACH nas;
"
run_sqlite_heredoc "frames ($SRC_FRAMES rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.frames
SELECT * FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ocr_text ($SRC_OCR rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ocr_text
SELECT o.* FROM main.ocr_text o
JOIN main.frames f ON o.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ui_events ($SRC_UI rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ui_events
SELECT * FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "elements ($SRC_ELEMENTS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.elements
SELECT e.* FROM main.elements e
JOIN main.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "meetings ($SRC_MEETINGS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.meetings
SELECT * FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';
DETACH nas;
"
# ─── FTS UPDATE ───────────────────────────────────────────────────────────
step "Updating FTS indexes"
run_sqlite_heredoc "elements_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.elements_fts(rowid, text, role)
SELECT e.id, e.text, e.role
FROM nas.elements e
JOIN nas.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE'
AND e.text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "frames_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)
SELECT id, full_text, app_name, window_name, browser_url, id
FROM nas.frames
WHERE date(timestamp) = '$TARGET_DATE'
AND full_text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "ui_events_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)
SELECT id, text_content, app_name, window_title, element_name
FROM nas.ui_events
WHERE date(timestamp) = '$TARGET_DATE'
AND text_content IS NOT NULL;
DETACH nas;
"
# ─── VERIFY DB ────────────────────────────────────────────────────────────
step "Verifying DB"
V_FRAMES=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
V_ELEMENTS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_UI=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
V_OCR=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_MEETINGS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';")
check "frames" "$V_FRAMES" "$SRC_FRAMES"
check "elements" "$V_ELEMENTS" "$SRC_ELEMENTS"
check "ui_events" "$V_UI" "$SRC_UI"
check "ocr_text" "$V_OCR" "$SRC_OCR"
check "meetings" "$V_MEETINGS" "$SRC_MEETINGS"
fi
# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────
# Always runs regardless of DB sync status
step "Copying data folder for $TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
mkdir -p "$NAS_DATA/$TARGET_DATE"
RSYNC_START=$(date +%s)
printf " %-36s " "rsync $TARGET_DATE/ → NAS"
rsync -a --ignore-existing \
"$DATA_SRC/" \
"$NAS_DATA/$TARGET_DATE/" \
2>>"$LOG_FILE"
RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))
COPIED_FILES=$(ls "$NAS_DATA/$TARGET_DATE" | wc -l | tr -d ' ')
SRC_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
COPIED_SIZE=$(du -sh "$NAS_DATA/$TARGET_DATE" | cut -f1)
if [ "$COPIED_FILES" -eq "$SRC_FILES" ]; then
printf "\r %-36s ✓ %dm%02ds (%s files, %s)\n" \
"rsync $TARGET_DATE/ → NAS" \
"$(( RSYNC_DUR / 60 ))" "$(( RSYNC_DUR % 60 ))" \
"$COPIED_FILES" "$COPIED_SIZE" | tee -a "$LOG_FILE"
else
printf "\r %-36s ✗ %s / %s files\n" \
"rsync $TARGET_DATE/ → NAS" "$COPIED_FILES" "$SRC_FILES" | tee -a "$LOG_FILE"
fi
else
printf " %-36s %s\n" "rsync $TARGET_DATE/ → NAS" "skipped (no source dir)"
fi
# ─── SUMMARY ──────────────────────────────────────────────────────────────────
TOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))
DB_SIZE=$(du -sh "$NAS_DB" | cut -f1)
echo ""
log "Archive DB size: $DB_SIZE"
log "Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s"
log "Sync complete for $TARGET_DATE"
log "========================================"
#!/bin/bash
# screenpipe_sync.sh
# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).
# Also copies the day's video/frame data folder to the NAS.
#
# Usage:
# ./screenpipe_sync.sh # syncs yesterday (default)
# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date
# ./screenpipe_sync.sh today # syncs today so far
#
# Cron example (runs at 3am daily):
# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1
set -euo pipefail
# ─── CONFIG ───────────────────────────────────────────────────────────────────
DB_SRC="${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}"
NAS_MOUNT="${NAS_MOUNT:-/Volumes/Test/screenpipe}"
NAS_DB="$NAS_MOUNT/archive.db"
NAS_DATA="$NAS_MOUNT/data"
LOG_FILE="$HOME/.screenpipe/sync.log"
# ──────────────────────────────────────────────────────────────────────────────
# ─── HELPERS ──────────────────────────────────────────────────────────────────
SCRIPT_START=$(date +%s)
log() {
local msg="[$(date '+%Y-%m-%d %H:%M:%S')] $*"
echo "$msg" | tee -a "$LOG_FILE"
}
step() {
local now=$(date +%s)
local elapsed=$(( now - SCRIPT_START ))
local min=$(( elapsed / 60 ))
local sec=$(( elapsed % 60 ))
printf "\n[+%02dm%02ds] ▶ %s\n" "$min" "$sec" "$*" | tee -a "$LOG_FILE"
}
run_sqlite_heredoc() {
local label="$1"
local sql="$2"
local start=$(date +%s)
printf " %-36s " "$label"
sqlite3 "$DB_SRC" <<< "$sql" &
local pid=$!
local spin=[PASSWORD] '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')
local i=0
while kill -0 "$pid" 2>/dev/null; do
printf "\r %-36s %s " "$label" "${spin[$i]}"
i=$(( (i + 1) % 10 ))
sleep 0.2
done
wait "$pid"
local rc=$?
if [ $rc -ne 0 ]; then
printf "\r %-36s ✗ FAILED\n" "$label" | tee -a "$LOG_FILE"
exit $rc
fi
local dur=$(( $(date +%s) - start ))
printf "\r %-36s ✓ %dm%02ds\n" "$label" "$(( dur / 60 ))" "$(( dur % 60 ))" | tee -a "$LOG_FILE"
}
check() {
local label="$1" got="$2" expected="$3"
if [ "$got" -eq "$expected" ]; then
printf " %-20s %s / %s ✓\n" "$label:" "$got" "$expected"
else
printf " %-20s %s / %s ✗ MISMATCH\n" "$label:" "$got" "$expected"
fi
}
# ──────────────────────────────────────────────────────────────────────────────
# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────
if [ "${1:-}" = "today" ]; then
TARGET_DATE=$(date +%Y-%m-%d)
elif [ -n "${1:-}" ]; then
TARGET_DATE="$1"
if ! [[ "$TARGET_DATE" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then
echo "ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday."
exit 1
fi
else
TARGET_DATE=$(date -v-1d +%Y-%m-%d)
fi
log "========================================"
log "Screenpipe sync starting for: $TARGET_DATE"
log "========================================"
# ─── PREFLIGHT ────────────────────────────────────────────────────────────────
step "Preflight checks"
if [ ! -f "$DB_SRC" ]; then
log "ERROR: Source DB not found at $DB_SRC"; exit 1
fi
printf " %-20s %s (%s)\n" "Source DB:" "OK" "$(du -sh "$DB_SRC" | cut -f1)"
if [ ! -d "$NAS_MOUNT" ]; then
log "ERROR: NAS not mounted at $NAS_MOUNT"; exit 1
fi
printf " %-20s %s\n" "NAS mount:" "OK $NAS_MOUNT"
# Check if DB already synced for this date
DB_ALREADY_SYNCED=false
if [ -f "$NAS_DB" ]; then
EXISTING=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';" 2>/dev/null || echo "0")
if [ "$EXISTING" -gt "0" ]; then
log "Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync"
DB_ALREADY_SYNCED=true
else
printf " %-20s %s (%s)\n" "Archive DB:" "exists" "$(du -sh "$NAS_DB" | cut -f1)"
fi
else
printf " %-20s %s\n" "Archive DB:" "will be created"
fi
# Source data dir for this date
DATA_SRC="$HOME/.screenpipe/data/data/$TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
DATA_SIZE=$(du -sh "$DATA_SRC" | cut -f1)
DATA_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
printf " %-20s %s (%s files, %s)\n" "Data dir:" "OK" "$DATA_FILES" "$DATA_SIZE"
else
printf " %-20s %s\n" "Data dir:" "not found — skipping file copy"
fi
# ─── DB SYNC ──────────────────────────────────────────────────────────────────
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────
step "Counting source rows for $TARGET_DATE"
SRC_FRAMES=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
SRC_ELEMENTS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_UI=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
SRC_OCR=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_MEETINGS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';")
printf " %-20s %s\n" "frames:" "$SRC_FRAMES"
printf " %-20s %s\n" "elements:" "$SRC_ELEMENTS"
printf " %-20s %s\n" "ui_events:" "$SRC_UI"
printf " %-20s %s\n" "ocr_text:" "$SRC_OCR"
printf " %-20s %s\n" "meetings:" "$SRC_MEETINGS"
if [ "$SRC_FRAMES" -eq "0" ]; then
log "No frames found for $TARGET_DATE — skipping DB sync"
DB_ALREADY_SYNCED=true
fi
fi
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── INIT TABLES ──────────────────────────────────────────────────────────
step "Initialising tables, indexes, FTS"
run_sqlite_heredoc "creating tables" "
ATTACH '$NAS_DB' AS nas;
CREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;
CREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;
CREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;
CREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;
DETACH nas;
"
run_sqlite_heredoc "creating indexes" "
ATTACH '$NAS_DB' AS nas;
CREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);
CREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);
DETACH nas;
"
run_sqlite_heredoc "creating FTS tables" "
ATTACH '$NAS_DB' AS nas;
CREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(
text, role, frame_id UNINDEXED,
content='elements', content_rowid='id', tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(
full_text, app_name, window_name, browser_url, id UNINDEXED,
tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(
text_content,
app_name,
window_title,
element_name,
content='ui_events',
content_rowid='id',
tokenize='unicode61'
);
DETACH nas;
"
# ─── SYNC DATA ────────────────────────────────────────────────────────────
step "Syncing data for $TARGET_DATE"
run_sqlite_heredoc "video_chunks" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.video_chunks
SELECT * FROM main.video_chunks
WHERE id IN (
SELECT DISTINCT video_chunk_id FROM main.frames
WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL
);
DETACH nas;
"
run_sqlite_heredoc "frames ($SRC_FRAMES rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.frames
SELECT * FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ocr_text ($SRC_OCR rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ocr_text
SELECT o.* FROM main.ocr_text o
JOIN main.frames f ON o.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ui_events ($SRC_UI rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ui_events
SELECT * FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "elements ($SRC_ELEMENTS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.elements
SELECT e.* FROM main.elements e
JOIN main.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "meetings ($SRC_MEETINGS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.meetings
SELECT * FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';
DETACH nas;
"
# ─── FTS UPDATE ───────────────────────────────────────────────────────────
step "Updating FTS indexes"
run_sqlite_heredoc "elements_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.elements_fts(rowid, text, role)
SELECT e.id, e.text, e.role
FROM nas.elements e
JOIN nas.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE'
AND e.text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "frames_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)
SELECT id, full_text, app_name, window_name, browser_url, id
FROM nas.frames
WHERE date(timestamp) = '$TARGET_DATE'
AND full_text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "ui_events_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)
SELECT id, text_content, app_name, window_title, element_name
FROM nas.ui_events
WHERE date(timestamp) = '$TARGET_DATE'
AND text_content IS NOT NULL;
DETACH nas;
"
# ─── VERIFY DB ────────────────────────────────────────────────────────────
step "Verifying DB"
V_FRAMES=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
V_ELEMENTS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_UI=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
V_OCR=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_MEETINGS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';")
check "frames" "$V_FRAMES" "$SRC_FRAMES"
check "elements" "$V_ELEMENTS" "$SRC_ELEMENTS"
check "ui_events" "$V_UI" "$SRC_UI"
check "ocr_text" "$V_OCR" "$SRC_OCR"
check "meetings" "$V_MEETINGS" "$SRC_MEETINGS"
fi
# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────
# Always runs regardless of DB sync status
step "Copying data folder for $TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
mkdir -p "$NAS_DATA/$TARGET_DATE"
RSYNC_START=$(date +%s)
printf " %-36s " "rsync $TARGET_DATE/ → NAS"
rsync -a --ignore-existing \
"$DATA_SRC/" \
"$NAS_DATA/$TARGET_DATE/" \
2>>"$LOG_FILE"
RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))
COPIED_FILES=$(ls "$NAS_DATA/$TARGET_DATE" | wc -l | tr -d ' ')
SRC_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
COPIED_SIZE=$(du -sh "$NAS_DATA/$TARGET_DATE" | cut -f1)
if [ "$COPIED_FILES" -eq "$SRC_FILES" ]; then
printf "\r %-36s ✓ %dm%02ds (%s files, %s)\n" \
"rsync $TARGET_DATE/ → NAS" \
"$(( RSYNC_DUR / 60 ))" "$(( RSYNC_DUR % 60 ))" \
"$COPIED_FILES" "$COPIED_SIZE" | tee -a "$LOG_FILE"
else
printf "\r %-36s ✗ %s / %s files\n" \
"rsync $TARGET_DATE/ → NAS" "$COPIED_FILES" "$SRC_FILES" | tee -a "$LOG_FILE"
fi
else
printf " %-36s %s\n" "rsync $TARGET_DATE/ → NAS" "skipped (no source dir)"
fi
# ─── SUMMARY ──────────────────────────────────────────────────────────────────
TOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))
DB_SIZE=$(du -sh "$NAS_DB" | cut -f1)
echo ""
log "Archive DB size: $DB_SIZE"
log "Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s"
log "Sync complete for $TARGET_DATE"
log "========================================"
Implement and run pipe l…, Editor Group 2
Problems (⇧⌘M)
PROBLEMS
Output (⇧⌘U)
OUTPUT
Debug Console (⇧⌘Y)
DEBUG CONSOLE
Terminal (⌃`)
TERMINAL
Ports - 1 forwarded port
PORTS
1
remote SSH: nas
SSH: nas
screenpipe (Git) - master*, Checkout Branch/Tag...
master*
screenpipe (Git) - Synchronize Changes
No Problems
0
0
Forwarded Ports: 8766
1
Notifications
Sign In
Sign In
Shell Script
Editor Language Status: $(copilot) No inline suggestion available, Inline suggestions
LF
UTF-8
Spaces: 2
Ln 39, Col 1
git-commit Lukas Kovalik (2 weeks ago)
Lukas Kovalik (2 weeks ago)
Info: Setting up SSH Host nas: Setting up SSH tunnel
Implement and run pipe logic
Session history
New session
Message actions
main.py
main.py
lets implement logic with pipes. how can I run it?
Thinking
Thinking
Let me look at the current project structure to understand what's already in place.
Bash
List project files
IN
find /volume1/screenpipe -type f | head -50 && echo "---" && ls /volume1/screenpipe
Copy code to clipboard
OUT
/volume1/screenpipe/.DS_Store
/volume1/screenpipe/screenpipe.db
/volume1/screenpipe/screenpipe_sync.sh
/volume1/screenpipe/app_settings.json
/volume1/screenpipe/.gitignore
/volume1/screenpipe/archive.db
/volume1/screenpipe/db.sqlite
/volume1/screenpipe/db.sqlite-wal
/volume1/screenpipe/db.sqlite-shm
/volume1/screenpipe/#recycle/desktop.ini
/volume1/screenpipe/#recycle/db.sqlite
/volume1/screenpipe/#recycle/Copy #1 of db.sqlite
/volume1/screenpipe/#recycle/.DS_Store
/volume1/screenpipe/#recycle/Copy #2 of db.sqlite
/volume1/screenpipe/#recycle/archive.db
/volume1/screenpipe/#recycle/Copy #1 of archive.db
/volume1/screenpipe/#recycle/Copy #2 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of archive.db
/volume1/screenpipe/#recycle/Copy #4 of archive.db
/volume1/screenpipe/#recycle/Copy #5 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of db.sqlite
/volume1/screenpipe/#recycle/Copy #4 of db.sqlite
/volume1/screenpipe/#recycle/Copy #6 of archive.db
/volume1/screenpipe/#recycle/test.txt
/volume1/screenpipe/#recycle/Copy #7 of archive.db
/volume1/screenpipe/#recycle/Copy #8 of archive.db
/volume1/screenpipe/#recycle/archive.db-journal
/volume1/screenpipe/#recycle/Copy #1 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #2 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #3 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #4 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #6 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #7 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of db.sqlite
/volume1/screenpipe/pipes/.DS_Store
/volume1/screenpipe/app/.env
/volume1/screenpipe/app/cli.py
/volume1/screenpipe/app/.DS_Store
/volume1/screenpipe/app/db.py
/volume1/screenpipe/app/docker-compose.yml
/volume1/screenpipe/app/main.py
/volume1/screenpipe/app/requirements.txt
/volume1/screenpipe/app/Dockerfile
/volume1/screenpipe/data/.DS_Store
/volume1/screenpipe/.git/description
/volume1/screenpipe/.git/HEAD
/volume1/screenpipe/.git/index
/volume1/screenpipe/.git/COMMIT_EDITMSG
/volume1/screenpipe/#recycle/data/.DS_Store
---
app
app_settings.json
archive.db
data
db.sqlite
db.sqlite-shm
db.sqlite-wal
pipes
#recycle
screenpipe.db
screenpipe_sync.sh
Read
main.py
main.py
Bash
Check pipes directory and docker-compose
IN
ls /volume1/screenpipe/pipes/ && ls /volume1/screenpipe/app/ && cat /volume1/screenpipe/app/docker-compose.yml
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
cli.py
consumers
db.py
docker-compose.yml
Dockerfile
main.py
__pycache__
requirements.txt
static
services:
screenpipe-app:
build: .
container_name: screenpipe-app
restart: unless-stopped
ports:
- "8766:8000"
volumes:
- /volume1/screenpipe:/data
env_file:
- .env
environment:
TZ: Europe/Sofia
DB_PATH: /data/db.sqlite
sqlite-web-archive:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-archive
restart: unless-stopped
ports:
- "8767:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/archive.db"]
sqlite-web-live:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-live
restart: unless-stopped
ports:
- "8768:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/db.sqlite"]
Read
requirements.txt
requirements.txt
Bash
Inspect a pipe directory
IN
ls /volume1/screenpipe/pipes/day-recap/ && cat /volume1/screenpipe/pipes/day-recap/pipe.json 2>/dev/null || ls /volume1/screenpipe/pipes/day-recap/
Copy code to clipboard
OUT
pipe.md
pipe.md
Read
cli.py
cli.py
Bash
List all pipes and their contents
IN
ls /volume1/screenpipe/pipes/ && for d in /volume1/screenpipe/pipes/*/; do echo "=== $d ==="; ls "$d"; done
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
=== /volume1/screenpipe/pipes/ai-habits/ ===
pipe.md
=== /volume1/screenpipe/pipes/day-recap/ ===
pipe.md
=== /volume1/screenpipe/pipes/meeting-summary/ ===
pipe.md
=== /volume1/screenpipe/pipes/standup-update/ ===
pipe.md
=== /volume1/screenpipe/pipes/time-breakdown/ ===
pipe.md
=== /volume1/screenpipe/pipes/video-export/ ===
pipe.md
Bash
Read pipe markdown files
IN
cat /volume1/screenpipe/pipes/day-recap/pipe.md && echo "===" && cat /volume1/screenpipe/pipes/meeting-summary/pipe.md 2>/dev/null | head -50
Copy code to clipboard
OUT
---
schedule: manual
enabled: true
template: true
title: Day Recap
description: "Today's accomplishments, key moments, and unfinished work"
icon: "📋"
featured: true
---
Analyze my screen and audio recordings from today (last 16 hours only).
Read screenpipe skill first.
Use this exact format:
## Summary
One sentence: what I mainly did today.
## Accomplishments
- Top 3 things I finished, with timestamps (e.g. "2:30 PM")
- Name specific apps, files, or projects
## Key Moments
- Important things I saw, said, or heard — with timestamps
## Unfinished Work
- What I should continue tomorrow — name the app/file/task
## Patterns
- Apps I used most, topics that came up repeatedly
Only report what you can verify from the data. End with: "**Next step:** [most important thing to continue]"
===
---
schedule: manual
enabled: true
template: true
title: Meeting Summary
description: "Summarize meeting transcript with key takeaways and action items"
icon: "🤝"
featured: false
---
Summarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.
Read screenpipe skill first.
Use this exact format:
## Meeting Summary
One sentence: what this meeting was about.
## Key Takeaways
- Top 3-5 important points discussed
- Include who said what when relevant
## Action Items
- [ ] Task — assigned to whom, deadline if mentioned
- [ ] Task — assigned to whom
## Decisions Made
- List any decisions or agreements reached
## Open Questions
- Anything unresolved or needing follow-up
Keep it concise and actionable.
Thinking
Thinking
Bash
Read summary consumer
IN
ls /volume1/screenpipe/app/consumers/ && cat /volume1/screenpipe/app/consumers/summary.py
Copy code to clipboard
OUT
activity.py
audio.py
elements.py
__init__.py
interactions.py
ocr.py
__pycache__
report.py
summary.py
"""AI summary generator using Claude."""
import os
from datetime import date
from typing import Any
from consumers.activity import app_time, summary_stats, browser_urls, ui_event_summary
from consumers.ocr import deduplicated_text
from consumers.audio import formatted_transcript
SUMMARY_TYPES = {
"day_recap": {
"title": "Day Recap",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
## Audio/speech:
{audio}
Write a concise day recap using EXACTLY this format:
## Summary
One sentence: what I mainly worked on today.
## Accomplishments
- Top 3 things I finished, with approximate times
- Name specific apps, files, or projects
## Key Moments
- Important things seen or heard, with timestamps
## Unfinished Work
- What to continue tomorrow
## Patterns
- Apps used most, topics that came up repeatedly
Only report what you can verify from the data. End with:
**Next step:** [most important thing to continue]""",
},
"standup": {
"title": "Standup Update",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
## Audio/speech:
{audio}
Write a brief standup update:
**Yesterday:** What I worked on (2-3 bullets)
**Today:** What I plan to continue (1-2 bullets)
**Blockers:** Any issues observed (or "None")
Keep it under 150 words. Only report what's verifiable from the data.""",
},
"focus_time": {
"title": "Focus & Distraction Analysis",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
Analyze focus vs distraction patterns:
## Deep Work Periods
- When and how long were sustained focus sessions?
- What was being worked on?
## Distractions
- Which apps/sites were used recreationally?
- How much time was lost to context switching?
## Recommendations
- 2-3 concrete suggestions to improve focus tomorrow
Be specific with times and app names.""",
},
}
def _build_context(for_date: date) -> dict[str, str]:
apps = app_time(for_date)
app_lines = "\n".join(f"- {a['app_name']}: {a['minutes']} min" for a in apps[:20])
urls = browser_urls(for_date, limit=20)
url_lines = "\n".join(
f"- {u['browser_url'][:100]} ({u['minutes']} min)" for u in urls
)
ui_rows = ui_event_summary(for_date)
ui_lines = "\n".join(
f"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches"
for r in ui_rows[:15]
)
ocr_rows = deduplicated_text(for_date, chunk_minutes=5)
ocr_lines = "\n".join(
f"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}"
for r in ocr_rows[:100]
)
audio = formatted_transcript(for_date)
return {
"app_time": app_lines or "(no app data)",
"browser_urls": url_lines or "(no browser data)",
"ui_events": ui_lines or "(no UI event data)",
"ocr_text": ocr_lines or "(no screen data)",
"audio": audio[:3000] if len(audio) > 3000 else audio,
}
def generate(
summary_type: str = "day_recap",
for_date: date | None = None,
api_key: str | None = None,
) -> dict[str, Any]:
"""Generate an AI summary. Returns dict with 'title', 'content', 'date'."""
import anthropic
d = for_date or date.today()
key = api_key or os.environ.get("ANTHROPIC_API_KEY", "")
if not key:
return {
"title": "Error",
"content": "ANTHROPIC_API_KEY not set. Add it to your .env file.",
"date": str(d),
}
spec = SUMMARY_TYPES.get(summary_type)
if not spec:
return {"title": "Error", "content": f"Unknown summary type: {summary_type}", "date": str(d)}
stats = summary_stats(d)
if stats["total_frames"] == 0:
return {
"title": spec["title"],
"content": f"No screen data found for {d}.",
"date": str(d),
}
ctx = _build_context(d)
prompt = spec["prompt"].format(**ctx)
client = anthropic.Anthropic(api_key=key)
message = client.messages.create(
model="claude-haiku-4-5-20251001",
max_tokens=1024,
messages=[{"role": "user", "content": prompt}],
)
return {
"title": spec["title"],
"content": message.content[0].text,
"date": str(d),
"stats": stats,
}
Thinking
Thinking
Bash
Read all pipe.md files
IN
for f in /volume1/screenpipe/pipes/*/pipe.md; do echo "=== $f ==="; cat "$f"; echo; done
Copy code to clipboard
OUT
=== /volume1/screenpipe/pipes/ai-habits/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: AI Habits
description: "How you use AI tools — patterns and insights"
icon: "🤖"
featured: true
---
Search my recordings from the last 24 hours for AI tool usage. Use app_name filter for each tool separately: ChatGPT, Claude, Copilot, Cursor, Gemini, Perplexity. Use limit=5 per search, max 6 searches total.
Read screenpipe skill first.
Use this exact format:
## AI Tools Used
- List each tool with approximate time spent (e.g. "Claude: ~45min")
## What I Used Them For
- For each tool: coding, writing, research, or brainstorming
## Usage Patterns
- Do I switch between tools? Use them in bursts or steadily?
## Effectiveness
- Which tool appeared alongside completed work vs. abandoned attempts
If no AI usage is found, say so clearly. End with: "**Tip:** [one suggestion to use AI tools more effectively]"
=== /volume1/screenpipe/pipes/day-recap/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Day Recap
description: "Today's accomplishments, key moments, and unfinished work"
icon: "📋"
featured: true
---
Analyze my screen and audio recordings from today (last 16 hours only).
Read screenpipe skill first.
Use this exact format:
## Summary
One sentence: what I mainly did today.
## Accomplishments
- Top 3 things I finished, with timestamps (e.g. "2:30 PM")
- Name specific apps, files, or projects
## Key Moments
- Important things I saw, said, or heard — with timestamps
## Unfinished Work
- What I should continue tomorrow — name the app/file/task
## Patterns
- Apps I used most, topics that came up repeatedly
Only report what you can verify from the data. End with: "**Next step:** [most important thing to continue]"
=== /volume1/screenpipe/pipes/meeting-summary/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Meeting Summary
description: "Summarize meeting transcript with key takeaways and action items"
icon: "🤝"
featured: false
---
Summarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.
Read screenpipe skill first.
Use this exact format:
## Meeting Summary
One sentence: what this meeting was about.
## Key Takeaways
- Top 3-5 important points discussed
- Include who said what when relevant
## Action Items
- [ ] Task — assigned to whom, deadline if mentioned
- [ ] Task — assigned to whom
## Decisions Made
- List any decisions or agreements reached
## Open Questions
- Anything unresolved or needing follow-up
Keep it concise and actionable.
=== /volume1/screenpipe/pipes/standup-update/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Standup Update
description: "What you did, what's next, and any blockers"
icon: "🏢"
featured: true
---
Based on my recordings from the last 24 hours, generate a standup update. Use limit=10 per search, max 3 searches total.
Read screenpipe skill first.
Use this exact format:
## Yesterday
- What I worked on (name specific projects, files, tools, PRs)
## Today
- What I will work on next (based on unfinished tasks and recent activity)
## Blockers
- Issues I hit — errors, slow builds, waiting on someone
- If no blockers, write "None"
Keep it under 150 words. Copy-paste ready for a team standup.
=== /volume1/screenpipe/pipes/time-breakdown/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Time Breakdown
description: "Where your time went — by app, project, and category"
icon: "⏱"
featured: false
---
Analyze my app usage from today (last 12 hours). Use limit=10 per search, max 4 searches. Prefer /raw_sql with COUNT/GROUP BY queries.
Read screenpipe skill first.
Use this exact format with durations and percentages:
## By Application
- List each app with duration and percentage, sorted by time (e.g. "VS Code: 2h 15min (28%)")
## By Category
- Group into: coding, meetings, browsing, writing, communication, other
- Show hours and percentage per category
## By Project
- Group related activities by project/topic. Name specific repos or tasks.
## Productivity Score
- Calculate: focused_work_hours / total_hours as a percentage
- Focused = coding + writing. Unfocused = browsing + switching.
End with: "**Suggestion:** [one specific change to improve tomorrow's productivity]"
=== /volume1/screenpipe/pipes/video-export/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Export Video Clip
description: "Create a video of your recent screen activity"
icon: "🎬"
featured: false
---
Export a video of my screen activity from the last 5 minutes.
Read screenpipe skill first.
Use the POST /frames/export endpoint with the time range and fps=1.0. Then show me the exported video file path as an inline code block so I can watch it.
If the export is large, suggest a lower fps or shorter time range....
|
[{"role":"AXRadioButton","text [{"role":"AXRadioButton","text":"Explorer (⇧⌘E)","depth":19,"bounds":{"left":0.0,"top":0.047885075,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":true},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.057462092,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Search (⇧⌘F)","depth":19,"bounds":{"left":0.0,"top":0.08619314,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.09577015,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Source Control (⌃⇧G) - 10 pending changes","depth":19,"bounds":{"left":0.0,"top":0.1245012,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.13407822,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"10","depth":22,"bounds":{"left":0.00831117,"top":0.1452514,"width":0.003656915,"height":0.008778931},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.00831117,"top":0.14604948,"width":0.0016622341,"height":0.007980846}},{"char_start":1,"char_count":1,"bounds":{"left":0.009973404,"top":0.14604948,"width":0.0023271276,"height":0.007980846}}],"role_description":"text"},{"role":"AXRadioButton","text":"Run and Debug (⇧⌘D)","depth":19,"bounds":{"left":0.0,"top":0.16280925,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.17238627,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Remote Explorer","depth":19,"bounds":{"left":0.0,"top":0.20111732,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.21069433,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Extensions (⇧⌘X) - 2 require update","depth":19,"bounds":{"left":0.0,"top":0.23942538,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.2490024,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"2","depth":22,"bounds":{"left":0.009640957,"top":0.2601756,"width":0.0019946808,"height":0.008778931},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Claude Code","depth":19,"bounds":{"left":0.0,"top":0.27773345,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"Containers","depth":19,"bounds":{"left":0.0,"top":0.3160415,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXHeading","text":"EXPLORER","depth":17,"bounds":{"left":0.022606382,"top":0.047885075,"width":0.018949468,"height":0.02793296},"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"EXPLORER","depth":18,"bounds":{"left":0.022606382,"top":0.056664005,"width":0.018949468,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.022606382,"top":0.056664005,"width":0.0023271276,"height":0.0103751}},{"char_start":1,"char_count":7,"bounds":{"left":0.024933511,"top":0.056664005,"width":0.01662234,"height":0.0103751}}],"role_description":"text"},{"role":"AXButton","text":"Explorer Section: screenpipe [SSH: nas]","depth":21,"bounds":{"left":0.015957447,"top":0.07581804,"width":0.09940159,"height":0.017557861},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":true},{"role":"AXStaticText","text":"","depth":23,"bounds":{"left":0.01662234,"top":0.07821229,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"Explorer Section: screenpipe [SSH: nas]","depth":22,"bounds":{"left":0.022606382,"top":0.07581804,"width":0.045877658,"height":0.017557861},"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"SCREENPIPE [SSH: NAS]","depth":23,"bounds":{"left":0.022606382,"top":0.079010375,"width":0.045877658,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.022606382,"top":0.07980846,"width":0.0026595744,"height":0.0103751}},{"char_start":1,"char_count":20,"bounds":{"left":0.025265958,"top":0.07980846,"width":0.043218084,"height":0.0103751}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.09577015,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"#recycle","depth":27,"bounds":{"left":0.025930852,"top":0.09577015,"width":0.017287234,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.096568234,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":7,"bounds":{"left":0.028590426,"top":0.096568234,"width":0.01462766,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.11332801,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"app","depth":27,"bounds":{"left":0.025930852,"top":0.11332801,"width":0.0076462766,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.11412609,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":2,"bounds":{"left":0.02825798,"top":0.11412609,"width":0.005319149,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.11412609,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.022273935,"top":0.13088587,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"__pycache__","depth":27,"bounds":{"left":0.028590426,"top":0.13088587,"width":0.026595745,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.13168396,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":10,"bounds":{"left":0.030917553,"top":0.13168396,"width":0.024268618,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.022273935,"top":0.14844373,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"consumers","depth":27,"bounds":{"left":0.028590426,"top":0.14844373,"width":0.022273935,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.14924182,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":8,"bounds":{"left":0.030917553,"top":0.14924182,"width":0.019946808,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.14924182,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.022273935,"top":0.1660016,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"static","depth":27,"bounds":{"left":0.028590426,"top":0.1660016,"width":0.010970744,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.16679968,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":5,"bounds":{"left":0.030917553,"top":0.16679968,"width":0.008976064,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.16679968,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.1819633,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":".env","depth":27,"bounds":{"left":0.028590426,"top":0.18355946,"width":0.00831117,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.18435754,"width":0.0013297872,"height":0.011971269}},{"char_start":1,"char_count":3,"bounds":{"left":0.029920213,"top":0.18435754,"width":0.006981383,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.19952115,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"cli.py","depth":27,"bounds":{"left":0.028590426,"top":0.20111732,"width":0.010638298,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.2019154,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":5,"bounds":{"left":0.030917553,"top":0.2019154,"width":0.00831117,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.2019154,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.21707901,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.py","depth":27,"bounds":{"left":0.028590426,"top":0.21867518,"width":0.011303191,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.21947326,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":4,"bounds":{"left":0.03125,"top":0.21947326,"width":0.008643617,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.23463687,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"docker-compose.yml","depth":27,"bounds":{"left":0.028590426,"top":0.23623304,"width":0.042220745,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.23703113,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":17,"bounds":{"left":0.03125,"top":0.23703113,"width":0.03956117,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.25219473,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Dockerfile","depth":27,"bounds":{"left":0.028590426,"top":0.25379092,"width":0.020611702,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.254589,"width":0.0033244682,"height":0.011971269}},{"char_start":1,"char_count":9,"bounds":{"left":0.031914894,"top":0.254589,"width":0.017287234,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.254589,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.2697526,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"main.py","depth":27,"bounds":{"left":0.028590426,"top":0.27134877,"width":0.015625,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.27214685,"width":0.003656915,"height":0.011971269}},{"char_start":1,"char_count":6,"bounds":{"left":0.032247342,"top":0.27214685,"width":0.012300532,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.27214685,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.28731045,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"requirements.txt","depth":27,"bounds":{"left":0.028590426,"top":0.28890663,"width":0.032912236,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.2897047,"width":0.0016622341,"height":0.011971269}},{"char_start":1,"char_count":15,"bounds":{"left":0.03025266,"top":0.2897047,"width":0.03158245,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.2897047,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.3064645,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"data","depth":27,"bounds":{"left":0.025930852,"top":0.3064645,"width":0.008976064,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.30726257,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":3,"bounds":{"left":0.028590426,"top":0.30726257,"width":0.0063164895,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.32402235,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"logs","depth":27,"bounds":{"left":0.025930852,"top":0.32402235,"width":0.00831117,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.32482043,"width":0.0009973404,"height":0.011971269}},{"char_start":1,"char_count":3,"bounds":{"left":0.026928192,"top":0.32482043,"width":0.0076462766,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.32482043,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.3415802,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"pipes","depth":27,"bounds":{"left":0.025930852,"top":0.3415802,"width":0.010970744,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.3423783,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":4,"bounds":{"left":0.028590426,"top":0.3423783,"width":0.00831117,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.3575419,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":".gitignore","depth":27,"bounds":{"left":0.025930852,"top":0.35913807,"width":0.018949468,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.35993615,"width":0.0013297872,"height":0.011971269}},{"char_start":1,"char_count":9,"bounds":{"left":0.027260639,"top":0.35993615,"width":0.017952127,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.37509975,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"app_settings.json","depth":27,"bounds":{"left":0.025930852,"top":0.37669593,"width":0.03557181,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.377494,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":16,"bounds":{"left":0.02825798,"top":0.377494,"width":0.03324468,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.3926576,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"archive.db","depth":27,"bounds":{"left":0.025930852,"top":0.3942538,"width":0.020944148,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.39505187,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":9,"bounds":{"left":0.02825798,"top":0.39505187,"width":0.01861702,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.4102155,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"archive.db-bak","depth":27,"bounds":{"left":0.025930852,"top":0.41181165,"width":0.03025266,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.41260973,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":13,"bounds":{"left":0.02825798,"top":0.41260973,"width":0.027925532,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"U","depth":27,"bounds":{"left":0.10704787,"top":0.41260973,"width":0.0029920214,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.42777336,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite","depth":27,"bounds":{"left":0.025930852,"top":0.4293695,"width":0.017287234,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.4301676,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":8,"bounds":{"left":0.028590426,"top":0.4301676,"width":0.014960106,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.44533122,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite-shm","depth":27,"bounds":{"left":0.025930852,"top":0.44692737,"width":0.027925532,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.44772545,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":12,"bounds":{"left":0.028590426,"top":0.44772545,"width":0.025265958,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.46288908,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite-wal","depth":27,"bounds":{"left":0.025930852,"top":0.46448523,"width":0.025930852,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.46528333,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":12,"bounds":{"left":0.028590426,"top":0.46528333,"width":0.023603724,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.48044693,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe_sync_updated.sh","depth":27,"bounds":{"left":0.025930852,"top":0.4820431,"width":0.059175532,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.4828412,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":25,"bounds":{"left":0.02825798,"top":0.4828412,"width":0.056848403,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"U","depth":27,"bounds":{"left":0.10704787,"top":0.4828412,"width":0.0029920214,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.4980048,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe_sync.sh","depth":27,"bounds":{"left":0.025930852,"top":0.49960095,"width":0.039893616,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.50039905,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":17,"bounds":{"left":0.02825798,"top":0.50039905,"width":0.037898935,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.51556265,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe.db","depth":27,"bounds":{"left":0.025930852,"top":0.5171588,"width":0.028590426,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.5179569,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":12,"bounds":{"left":0.02825798,"top":0.5179569,"width":0.026595745,"height":0.011971269}}],"role_description":"text"},{"role":"AXButton","text":"Outline Section","depth":21,"bounds":{"left":0.015957447,"top":0.9473264,"width":0.09940159,"height":0.017557861},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":23,"bounds":{"left":0.01662234,"top":0.9497207,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"OUTLINE","depth":22,"bounds":{"left":0.022606382,"top":0.9473264,"width":0.01662234,"height":0.017557861},"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"OUTLINE","depth":23,"bounds":{"left":0.022606382,"top":0.95131683,"width":0.01662234,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.022606382,"top":0.95131683,"width":0.0029920214,"height":0.0103751}},{"char_start":1,"char_count":6,"bounds":{"left":0.025598405,"top":0.95131683,"width":0.013630319,"height":0.0103751}}],"role_description":"text"},{"role":"AXButton","text":"Timeline Section","depth":21,"bounds":{"left":0.015957447,"top":0.9648843,"width":0.09940159,"height":0.017557861},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":23,"bounds":{"left":0.01662234,"top":0.96727854,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"TIMELINE","depth":22,"bounds":{"left":0.022606382,"top":0.9648843,"width":0.01761968,"height":0.017557861},"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"TIMELINE","depth":23,"bounds":{"left":0.022606382,"top":0.9688747,"width":0.01761968,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.022606382,"top":0.9688747,"width":0.0026595744,"height":0.0103751}},{"char_start":1,"char_count":7,"bounds":{"left":0.025265958,"top":0.9688747,"width":0.015292553,"height":0.0103751}}],"role_description":"text"},{"role":"AXRadioButton","text":"app_settings.json, Editor Group 1","depth":28,"bounds":{"left":0.11569149,"top":0.047885075,"width":0.055851065,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"screenpipe_sync.sh, Editor Group 1","depth":28,"bounds":{"left":0.17154256,"top":0.047885075,"width":0.06050532,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":false},{"role":"AXRadioButton","text":"pipe.md, Editor Group 1","depth":28,"bounds":{"left":0.23171543,"top":0.047885075,"width":0.040226065,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":".env, Editor Group 1","depth":28,"bounds":{"left":0.27194148,"top":0.047885075,"width":0.039893616,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"#!/bin/bash\n# screenpipe_sync.sh\n# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).\n# Also copies the day's video/frame data folder to the NAS.\n#\n# Usage:\n# ./screenpipe_sync.sh # syncs yesterday (default)\n# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date\n# ./screenpipe_sync.sh today # syncs today so far\n#\n# Cron example (runs at 3am daily):\n# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1\n\nset -euo pipefail\n\n# ─── CONFIG ───────────────────────────────────────────────────────────────────\nDB_SRC=\"${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}\"\nNAS_MOUNT=\"${NAS_MOUNT:-/Volumes/Test/screenpipe}\"\nNAS_DB=\"$NAS_MOUNT/archive.db\"\nNAS_DATA=\"$NAS_MOUNT/data\"\nLOG_FILE=\"$HOME/.screenpipe/sync.log\"\n# ──────────────────────────────────────────────────────────────────────────────\n\n# ─── HELPERS ──────────────────────────────────────────────────────────────────\nSCRIPT_START=$(date +%s)\n\nlog() {\n local msg=\"[$(date '+%Y-%m-%d %H:%M:%S')] $*\"\n echo \"$msg\" | tee -a \"$LOG_FILE\"\n}\n\nstep() {\n local now=$(date +%s)\n local elapsed=$(( now - SCRIPT_START ))\n local min=$(( elapsed / 60 ))\n local sec=$(( elapsed % 60 ))\n printf \"\\n[+%02dm%02ds] ▶ %s\\n\" \"$min\" \"$sec\" \"$*\" | tee -a \"$LOG_FILE\"\n}\n\nrun_sqlite_heredoc() {\n local label=\"$1\"\n local sql=\"$2\"\n local start=$(date +%s)\n\n printf \" %-36s \" \"$label\"\n\n sqlite3 \"$DB_SRC\" <<< \"$sql\" &\n local pid=$!\n local spin=('⠋' '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')\n local i=0\n while kill -0 \"$pid\" 2>/dev/null; do\n printf \"\\r %-36s %s \" \"$label\" \"${spin[$i]}\"\n i=$(( (i + 1) % 10 ))\n sleep 0.2\n done\n wait \"$pid\"\n local rc=$?\n if [ $rc -ne 0 ]; then\n printf \"\\r %-36s ✗ FAILED\\n\" \"$label\" | tee -a \"$LOG_FILE\"\n exit $rc\n fi\n\n local dur=$(( $(date +%s) - start ))\n printf \"\\r %-36s ✓ %dm%02ds\\n\" \"$label\" \"$(( dur / 60 ))\" \"$(( dur % 60 ))\" | tee -a \"$LOG_FILE\"\n}\n\ncheck() {\n local label=\"$1\" got=\"$2\" expected=\"$3\"\n if [ \"$got\" -eq \"$expected\" ]; then\n printf \" %-20s %s / %s ✓\\n\" \"$label:\" \"$got\" \"$expected\"\n else\n printf \" %-20s %s / %s ✗ MISMATCH\\n\" \"$label:\" \"$got\" \"$expected\"\n fi\n}\n# ──────────────────────────────────────────────────────────────────────────────\n\n# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────\nif [ \"${1:-}\" = \"today\" ]; then\n TARGET_DATE=$(date +%Y-%m-%d)\nelif [ -n \"${1:-}\" ]; then\n TARGET_DATE=\"$1\"\n if ! [[ \"$TARGET_DATE\" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then\n echo \"ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday.\"\n exit 1\n fi\nelse\n TARGET_DATE=$(date -v-1d +%Y-%m-%d)\nfi\n\nlog \"========================================\"\nlog \"Screenpipe sync starting for: $TARGET_DATE\"\nlog \"========================================\"\n\n# ─── PREFLIGHT ────────────────────────────────────────────────────────────────\nstep \"Preflight checks\"\n\nif [ ! -f \"$DB_SRC\" ]; then\n log \"ERROR: Source DB not found at $DB_SRC\"; exit 1\nfi\nprintf \" %-20s %s (%s)\\n\" \"Source DB:\" \"OK\" \"$(du -sh \"$DB_SRC\" | cut -f1)\"\n\nif [ ! -d \"$NAS_MOUNT\" ]; then\n log \"ERROR: NAS not mounted at $NAS_MOUNT\"; exit 1\nfi\nprintf \" %-20s %s\\n\" \"NAS mount:\" \"OK $NAS_MOUNT\"\n\n# Check if DB already synced for this date\nDB_ALREADY_SYNCED=false\nif [ -f \"$NAS_DB\" ]; then\n EXISTING=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\" 2>/dev/null || echo \"0\")\n if [ \"$EXISTING\" -gt \"0\" ]; then\n log \"Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync\"\n DB_ALREADY_SYNCED=true\n else\n printf \" %-20s %s (%s)\\n\" \"Archive DB:\" \"exists\" \"$(du -sh \"$NAS_DB\" | cut -f1)\"\n fi\nelse\n printf \" %-20s %s\\n\" \"Archive DB:\" \"will be created\"\nfi\n\n# Source data dir for this date\nDATA_SRC=\"$HOME/.screenpipe/data/data/$TARGET_DATE\"\nif [ -d \"$DATA_SRC\" ]; then\n DATA_SIZE=$(du -sh \"$DATA_SRC\" | cut -f1)\n DATA_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n printf \" %-20s %s (%s files, %s)\\n\" \"Data dir:\" \"OK\" \"$DATA_FILES\" \"$DATA_SIZE\"\nelse\n printf \" %-20s %s\\n\" \"Data dir:\" \"not found — skipping file copy\"\nfi\n\n# ─── DB SYNC ──────────────────────────────────────────────────────────────────\nif [ \"$DB_ALREADY_SYNCED\" = false ]; then\n\n # ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────\n step \"Counting source rows for $TARGET_DATE\"\n\n SRC_FRAMES=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\")\n SRC_ELEMENTS=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n SRC_UI=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';\")\n SRC_OCR=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n SRC_MEETINGS=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';\")\n\n printf \" %-20s %s\\n\" \"frames:\" \"$SRC_FRAMES\"\n printf \" %-20s %s\\n\" \"elements:\" \"$SRC_ELEMENTS\"\n printf \" %-20s %s\\n\" \"ui_events:\" \"$SRC_UI\"\n printf \" %-20s %s\\n\" \"ocr_text:\" \"$SRC_OCR\"\n printf \" %-20s %s\\n\" \"meetings:\" \"$SRC_MEETINGS\"\n\n if [ \"$SRC_FRAMES\" -eq \"0\" ]; then\n log \"No frames found for $TARGET_DATE — skipping DB sync\"\n DB_ALREADY_SYNCED=true\n fi\n\nfi\n\nif [ \"$DB_ALREADY_SYNCED\" = false ]; then\n\n # ─── INIT TABLES ──────────────────────────────────────────────────────────\n step \"Initialising tables, indexes, FTS\"\n\n run_sqlite_heredoc \"creating tables\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"creating indexes\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);\nCREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);\nCREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"creating FTS tables\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(\n text, role, frame_id UNINDEXED,\n content='elements', content_rowid='id', tokenize='unicode61'\n);\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(\n full_text, app_name, window_name, browser_url, id UNINDEXED,\n tokenize='unicode61'\n);\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(\n text_content,\n app_name,\n window_title,\n element_name,\n content='ui_events',\n content_rowid='id',\n tokenize='unicode61'\n);\nDETACH nas;\n\"\n\n # ─── SYNC DATA ────────────────────────────────────────────────────────────\n step \"Syncing data for $TARGET_DATE\"\n\n run_sqlite_heredoc \"video_chunks\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.video_chunks\n SELECT * FROM main.video_chunks\n WHERE id IN (\n SELECT DISTINCT video_chunk_id FROM main.frames\n WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL\n );\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames ($SRC_FRAMES rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.frames\n SELECT * FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ocr_text ($SRC_OCR rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ocr_text\n SELECT o.* FROM main.ocr_text o\n JOIN main.frames f ON o.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events ($SRC_UI rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ui_events\n SELECT * FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"elements ($SRC_ELEMENTS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.elements\n SELECT e.* FROM main.elements e\n JOIN main.frames f ON e.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"meetings ($SRC_MEETINGS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.meetings\n SELECT * FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n # ─── FTS UPDATE ───────────────────────────────────────────────────────────\n step \"Updating FTS indexes\"\n\n run_sqlite_heredoc \"elements_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.elements_fts(rowid, text, role)\n SELECT e.id, e.text, e.role\n FROM nas.elements e\n JOIN nas.frames f ON e.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE'\n AND e.text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)\n SELECT id, full_text, app_name, window_name, browser_url, id\n FROM nas.frames\n WHERE date(timestamp) = '$TARGET_DATE'\n AND full_text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)\n SELECT id, text_content, app_name, window_title, element_name\n FROM nas.ui_events\n WHERE date(timestamp) = '$TARGET_DATE'\n AND text_content IS NOT NULL;\nDETACH nas;\n\"\n\n # ─── VERIFY DB ────────────────────────────────────────────────────────────\n step \"Verifying DB\"\n\n V_FRAMES=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\")\n V_ELEMENTS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n V_UI=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';\")\n V_OCR=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n V_MEETINGS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';\")\n\n check \"frames\" \"$V_FRAMES\" \"$SRC_FRAMES\"\n check \"elements\" \"$V_ELEMENTS\" \"$SRC_ELEMENTS\"\n check \"ui_events\" \"$V_UI\" \"$SRC_UI\"\n check \"ocr_text\" \"$V_OCR\" \"$SRC_OCR\"\n check \"meetings\" \"$V_MEETINGS\" \"$SRC_MEETINGS\"\n\nfi\n\n# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────\n# Always runs regardless of DB sync status\nstep \"Copying data folder for $TARGET_DATE\"\n\nif [ -d \"$DATA_SRC\" ]; then\n mkdir -p \"$NAS_DATA/$TARGET_DATE\"\n RSYNC_START=$(date +%s)\n printf \" %-36s \" \"rsync $TARGET_DATE/ → NAS\"\n rsync -a --ignore-existing \\\n \"$DATA_SRC/\" \\\n \"$NAS_DATA/$TARGET_DATE/\" \\\n 2>>\"$LOG_FILE\"\n RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))\n COPIED_FILES=$(ls \"$NAS_DATA/$TARGET_DATE\" | wc -l | tr -d ' ')\n SRC_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n COPIED_SIZE=$(du -sh \"$NAS_DATA/$TARGET_DATE\" | cut -f1)\n if [ \"$COPIED_FILES\" -eq \"$SRC_FILES\" ]; then\n printf \"\\r %-36s ✓ %dm%02ds (%s files, %s)\\n\" \\\n \"rsync $TARGET_DATE/ → NAS\" \\\n \"$(( RSYNC_DUR / 60 ))\" \"$(( RSYNC_DUR % 60 ))\" \\\n \"$COPIED_FILES\" \"$COPIED_SIZE\" | tee -a \"$LOG_FILE\"\n else\n printf \"\\r %-36s ✗ %s / %s files\\n\" \\\n \"rsync $TARGET_DATE/ → NAS\" \"$COPIED_FILES\" \"$SRC_FILES\" | tee -a \"$LOG_FILE\"\n fi\nelse\n printf \" %-36s %s\\n\" \"rsync $TARGET_DATE/ → NAS\" \"skipped (no source dir)\"\nfi\n\n# ─── SUMMARY ──────────────────────────────────────────────────────────────────\nTOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))\nDB_SIZE=$(du -sh \"$NAS_DB\" | cut -f1)\n\necho \"\"\nlog \"Archive DB size: $DB_SIZE\"\nlog \"Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s\"\nlog \"Sync complete for $TARGET_DATE\"\nlog \"========================================\"","depth":28,"bounds":{"left":0.13763298,"top":0.5490822,"width":0.35804522,"height":0.014365523},"on_screen":true,"value":"#!/bin/bash\n# screenpipe_sync.sh\n# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).\n# Also copies the day's video/frame data folder to the NAS.\n#\n# Usage:\n# ./screenpipe_sync.sh # syncs yesterday (default)\n# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date\n# ./screenpipe_sync.sh today # syncs today so far\n#\n# Cron example (runs at 3am daily):\n# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1\n\nset -euo pipefail\n\n# ─── CONFIG ───────────────────────────────────────────────────────────────────\nDB_SRC=\"${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}\"\nNAS_MOUNT=\"${NAS_MOUNT:-/Volumes/Test/screenpipe}\"\nNAS_DB=\"$NAS_MOUNT/archive.db\"\nNAS_DATA=\"$NAS_MOUNT/data\"\nLOG_FILE=\"$HOME/.screenpipe/sync.log\"\n# ──────────────────────────────────────────────────────────────────────────────\n\n# ─── HELPERS ──────────────────────────────────────────────────────────────────\nSCRIPT_START=$(date +%s)\n\nlog() {\n local msg=\"[$(date '+%Y-%m-%d %H:%M:%S')] $*\"\n echo \"$msg\" | tee -a \"$LOG_FILE\"\n}\n\nstep() {\n local now=$(date +%s)\n local elapsed=$(( now - SCRIPT_START ))\n local min=$(( elapsed / 60 ))\n local sec=$(( elapsed % 60 ))\n printf \"\\n[+%02dm%02ds] ▶ %s\\n\" \"$min\" \"$sec\" \"$*\" | tee -a \"$LOG_FILE\"\n}\n\nrun_sqlite_heredoc() {\n local label=\"$1\"\n local sql=\"$2\"\n local start=$(date +%s)\n\n printf \" %-36s \" \"$label\"\n\n sqlite3 \"$DB_SRC\" <<< \"$sql\" &\n local pid=$!\n local spin=('⠋' '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')\n local i=0\n while kill -0 \"$pid\" 2>/dev/null; do\n printf \"\\r %-36s %s \" \"$label\" \"${spin[$i]}\"\n i=$(( (i + 1) % 10 ))\n sleep 0.2\n done\n wait \"$pid\"\n local rc=$?\n if [ $rc -ne 0 ]; then\n printf \"\\r %-36s ✗ FAILED\\n\" \"$label\" | tee -a \"$LOG_FILE\"\n exit $rc\n fi\n\n local dur=$(( $(date +%s) - start ))\n printf \"\\r %-36s ✓ %dm%02ds\\n\" \"$label\" \"$(( dur / 60 ))\" \"$(( dur % 60 ))\" | tee -a \"$LOG_FILE\"\n}\n\ncheck() {\n local label=\"$1\" got=\"$2\" expected=\"$3\"\n if [ \"$got\" -eq \"$expected\" ]; then\n printf \" %-20s %s / %s ✓\\n\" \"$label:\" \"$got\" \"$expected\"\n else\n printf \" %-20s %s / %s ✗ MISMATCH\\n\" \"$label:\" \"$got\" \"$expected\"\n fi\n}\n# ──────────────────────────────────────────────────────────────────────────────\n\n# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────\nif [ \"${1:-}\" = \"today\" ]; then\n TARGET_DATE=$(date +%Y-%m-%d)\nelif [ -n \"${1:-}\" ]; then\n TARGET_DATE=\"$1\"\n if ! [[ \"$TARGET_DATE\" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then\n echo \"ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday.\"\n exit 1\n fi\nelse\n TARGET_DATE=$(date -v-1d +%Y-%m-%d)\nfi\n\nlog \"========================================\"\nlog \"Screenpipe sync starting for: $TARGET_DATE\"\nlog \"========================================\"\n\n# ─── PREFLIGHT ────────────────────────────────────────────────────────────────\nstep \"Preflight checks\"\n\nif [ ! -f \"$DB_SRC\" ]; then\n log \"ERROR: Source DB not found at $DB_SRC\"; exit 1\nfi\nprintf \" %-20s %s (%s)\\n\" \"Source DB:\" \"OK\" \"$(du -sh \"$DB_SRC\" | cut -f1)\"\n\nif [ ! -d \"$NAS_MOUNT\" ]; then\n log \"ERROR: NAS not mounted at $NAS_MOUNT\"; exit 1\nfi\nprintf \" %-20s %s\\n\" \"NAS mount:\" \"OK $NAS_MOUNT\"\n\n# Check if DB already synced for this date\nDB_ALREADY_SYNCED=false\nif [ -f \"$NAS_DB\" ]; then\n EXISTING=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\" 2>/dev/null || echo \"0\")\n if [ \"$EXISTING\" -gt \"0\" ]; then\n log \"Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync\"\n DB_ALREADY_SYNCED=true\n else\n printf \" %-20s %s (%s)\\n\" \"Archive DB:\" \"exists\" \"$(du -sh \"$NAS_DB\" | cut -f1)\"\n fi\nelse\n printf \" %-20s %s\\n\" \"Archive DB:\" \"will be created\"\nfi\n\n# Source data dir for this date\nDATA_SRC=\"$HOME/.screenpipe/data/data/$TARGET_DATE\"\nif [ -d \"$DATA_SRC\" ]; then\n DATA_SIZE=$(du -sh \"$DATA_SRC\" | cut -f1)\n DATA_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n printf \" %-20s %s (%s files, %s)\\n\" \"Data dir:\" \"OK\" \"$DATA_FILES\" \"$DATA_SIZE\"\nelse\n printf \" %-20s %s\\n\" \"Data dir:\" \"not found — skipping file copy\"\nfi\n\n# ─── DB SYNC ──────────────────────────────────────────────────────────────────\nif [ \"$DB_ALREADY_SYNCED\" = false ]; then\n\n # ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────\n step \"Counting source rows for $TARGET_DATE\"\n\n SRC_FRAMES=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\")\n SRC_ELEMENTS=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n SRC_UI=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';\")\n SRC_OCR=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n SRC_MEETINGS=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';\")\n\n printf \" %-20s %s\\n\" \"frames:\" \"$SRC_FRAMES\"\n printf \" %-20s %s\\n\" \"elements:\" \"$SRC_ELEMENTS\"\n printf \" %-20s %s\\n\" \"ui_events:\" \"$SRC_UI\"\n printf \" %-20s %s\\n\" \"ocr_text:\" \"$SRC_OCR\"\n printf \" %-20s %s\\n\" \"meetings:\" \"$SRC_MEETINGS\"\n\n if [ \"$SRC_FRAMES\" -eq \"0\" ]; then\n log \"No frames found for $TARGET_DATE — skipping DB sync\"\n DB_ALREADY_SYNCED=true\n fi\n\nfi\n\nif [ \"$DB_ALREADY_SYNCED\" = false ]; then\n\n # ─── INIT TABLES ──────────────────────────────────────────────────────────\n step \"Initialising tables, indexes, FTS\"\n\n run_sqlite_heredoc \"creating tables\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"creating indexes\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);\nCREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);\nCREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"creating FTS tables\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(\n text, role, frame_id UNINDEXED,\n content='elements', content_rowid='id', tokenize='unicode61'\n);\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(\n full_text, app_name, window_name, browser_url, id UNINDEXED,\n tokenize='unicode61'\n);\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(\n text_content,\n app_name,\n window_title,\n element_name,\n content='ui_events',\n content_rowid='id',\n tokenize='unicode61'\n);\nDETACH nas;\n\"\n\n # ─── SYNC DATA ────────────────────────────────────────────────────────────\n step \"Syncing data for $TARGET_DATE\"\n\n run_sqlite_heredoc \"video_chunks\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.video_chunks\n SELECT * FROM main.video_chunks\n WHERE id IN (\n SELECT DISTINCT video_chunk_id FROM main.frames\n WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL\n );\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames ($SRC_FRAMES rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.frames\n SELECT * FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ocr_text ($SRC_OCR rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ocr_text\n SELECT o.* FROM main.ocr_text o\n JOIN main.frames f ON o.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events ($SRC_UI rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ui_events\n SELECT * FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"elements ($SRC_ELEMENTS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.elements\n SELECT e.* FROM main.elements e\n JOIN main.frames f ON e.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"meetings ($SRC_MEETINGS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.meetings\n SELECT * FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n # ─── FTS UPDATE ───────────────────────────────────────────────────────────\n step \"Updating FTS indexes\"\n\n run_sqlite_heredoc \"elements_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.elements_fts(rowid, text, role)\n SELECT e.id, e.text, e.role\n FROM nas.elements e\n JOIN nas.frames f ON e.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE'\n AND e.text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)\n SELECT id, full_text, app_name, window_name, browser_url, id\n FROM nas.frames\n WHERE date(timestamp) = '$TARGET_DATE'\n AND full_text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)\n SELECT id, text_content, app_name, window_title, element_name\n FROM nas.ui_events\n WHERE date(timestamp) = '$TARGET_DATE'\n AND text_content IS NOT NULL;\nDETACH nas;\n\"\n\n # ─── VERIFY DB ────────────────────────────────────────────────────────────\n step \"Verifying DB\"\n\n V_FRAMES=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\")\n V_ELEMENTS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n V_UI=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';\")\n V_OCR=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n V_MEETINGS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';\")\n\n check \"frames\" \"$V_FRAMES\" \"$SRC_FRAMES\"\n check \"elements\" \"$V_ELEMENTS\" \"$SRC_ELEMENTS\"\n check \"ui_events\" \"$V_UI\" \"$SRC_UI\"\n check \"ocr_text\" \"$V_OCR\" \"$SRC_OCR\"\n check \"meetings\" \"$V_MEETINGS\" \"$SRC_MEETINGS\"\n\nfi\n\n# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────\n# Always runs regardless of DB sync status\nstep \"Copying data folder for $TARGET_DATE\"\n\nif [ -d \"$DATA_SRC\" ]; then\n mkdir -p \"$NAS_DATA/$TARGET_DATE\"\n RSYNC_START=$(date +%s)\n printf \" %-36s \" \"rsync $TARGET_DATE/ → NAS\"\n rsync -a --ignore-existing \\\n \"$DATA_SRC/\" \\\n \"$NAS_DATA/$TARGET_DATE/\" \\\n 2>>\"$LOG_FILE\"\n RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))\n COPIED_FILES=$(ls \"$NAS_DATA/$TARGET_DATE\" | wc -l | tr -d ' ')\n SRC_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n COPIED_SIZE=$(du -sh \"$NAS_DATA/$TARGET_DATE\" | cut -f1)\n if [ \"$COPIED_FILES\" -eq \"$SRC_FILES\" ]; then\n printf \"\\r %-36s ✓ %dm%02ds (%s files, %s)\\n\" \\\n \"rsync $TARGET_DATE/ → NAS\" \\\n \"$(( RSYNC_DUR / 60 ))\" \"$(( RSYNC_DUR % 60 ))\" \\\n \"$COPIED_FILES\" \"$COPIED_SIZE\" | tee -a \"$LOG_FILE\"\n else\n printf \"\\r %-36s ✗ %s / %s files\\n\" \\\n \"rsync $TARGET_DATE/ → NAS\" \"$COPIED_FILES\" \"$SRC_FILES\" | tee -a \"$LOG_FILE\"\n fi\nelse\n printf \" %-36s %s\\n\" \"rsync $TARGET_DATE/ → NAS\" \"skipped (no source dir)\"\nfi\n\n# ─── SUMMARY ──────────────────────────────────────────────────────────────────\nTOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))\nDB_SIZE=$(du -sh \"$NAS_DB\" | cut -f1)\n\necho \"\"\nlog \"Archive DB size: $DB_SIZE\"\nlog \"Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s\"\nlog \"Sync complete for $TARGET_DATE\"\nlog \"========================================\"","role_description":"editor","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"#!/bin/bash\n# screenpipe_sync.sh\n# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).\n# Also copies the day's video/frame data folder to the NAS.\n#\n# Usage:\n# ./screenpipe_sync.sh # syncs yesterday (default)\n# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date\n# ./screenpipe_sync.sh today # syncs today so far\n#\n# Cron example (runs at 3am daily):\n# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1\n\nset -euo pipefail\n\n# ─── CONFIG ───────────────────────────────────────────────────────────────────\nDB_SRC=\"${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}\"\nNAS_MOUNT=\"${NAS_MOUNT:-/Volumes/Test/screenpipe}\"\nNAS_DB=\"$NAS_MOUNT/archive.db\"\nNAS_DATA=\"$NAS_MOUNT/data\"\nLOG_FILE=\"$HOME/.screenpipe/sync.log\"\n# ──────────────────────────────────────────────────────────────────────────────\n\n# ─── HELPERS ──────────────────────────────────────────────────────────────────\nSCRIPT_START=$(date +%s)\n\nlog() {\n local msg=\"[$(date '+%Y-%m-%d %H:%M:%S')] $*\"\n echo \"$msg\" | tee -a \"$LOG_FILE\"\n}\n\nstep() {\n local now=$(date +%s)\n local elapsed=$(( now - SCRIPT_START ))\n local min=$(( elapsed / 60 ))\n local sec=$(( elapsed % 60 ))\n printf \"\\n[+%02dm%02ds] ▶ %s\\n\" \"$min\" \"$sec\" \"$*\" | tee -a \"$LOG_FILE\"\n}\n\nrun_sqlite_heredoc() {\n local label=\"$1\"\n local sql=\"$2\"\n local start=$(date +%s)\n\n printf \" %-36s \" \"$label\"\n\n sqlite3 \"$DB_SRC\" <<< \"$sql\" &\n local pid=$!\n local spin=('⠋' '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')\n local i=0\n while kill -0 \"$pid\" 2>/dev/null; do\n printf \"\\r %-36s %s \" \"$label\" \"${spin[$i]}\"\n i=$(( (i + 1) % 10 ))\n sleep 0.2\n done\n wait \"$pid\"\n local rc=$?\n if [ $rc -ne 0 ]; then\n printf \"\\r %-36s ✗ FAILED\\n\" \"$label\" | tee -a \"$LOG_FILE\"\n exit $rc\n fi\n\n local dur=$(( $(date +%s) - start ))\n printf \"\\r %-36s ✓ %dm%02ds\\n\" \"$label\" \"$(( dur / 60 ))\" \"$(( dur % 60 ))\" | tee -a \"$LOG_FILE\"\n}\n\ncheck() {\n local label=\"$1\" got=\"$2\" expected=\"$3\"\n if [ \"$got\" -eq \"$expected\" ]; then\n printf \" %-20s %s / %s ✓\\n\" \"$label:\" \"$got\" \"$expected\"\n else\n printf \" %-20s %s / %s ✗ MISMATCH\\n\" \"$label:\" \"$got\" \"$expected\"\n fi\n}\n# ──────────────────────────────────────────────────────────────────────────────\n\n# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────\nif [ \"${1:-}\" = \"today\" ]; then\n TARGET_DATE=$(date +%Y-%m-%d)\nelif [ -n \"${1:-}\" ]; then\n TARGET_DATE=\"$1\"\n if ! [[ \"$TARGET_DATE\" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then\n echo \"ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday.\"\n exit 1\n fi\nelse\n TARGET_DATE=$(date -v-1d +%Y-%m-%d)\nfi\n\nlog \"========================================\"\nlog \"Screenpipe sync starting for: $TARGET_DATE\"\nlog \"========================================\"\n\n# ─── PREFLIGHT ────────────────────────────────────────────────────────────────\nstep \"Preflight checks\"\n\nif [ ! -f \"$DB_SRC\" ]; then\n log \"ERROR: Source DB not found at $DB_SRC\"; exit 1\nfi\nprintf \" %-20s %s (%s)\\n\" \"Source DB:\" \"OK\" \"$(du -sh \"$DB_SRC\" | cut -f1)\"\n\nif [ ! -d \"$NAS_MOUNT\" ]; then\n log \"ERROR: NAS not mounted at $NAS_MOUNT\"; exit 1\nfi\nprintf \" %-20s %s\\n\" \"NAS mount:\" \"OK $NAS_MOUNT\"\n\n# Check if DB already synced for this date\nDB_ALREADY_SYNCED=false\nif [ -f \"$NAS_DB\" ]; then\n EXISTING=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\" 2>/dev/null || echo \"0\")\n if [ \"$EXISTING\" -gt \"0\" ]; then\n log \"Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync\"\n DB_ALREADY_SYNCED=true\n else\n printf \" %-20s %s (%s)\\n\" \"Archive DB:\" \"exists\" \"$(du -sh \"$NAS_DB\" | cut -f1)\"\n fi\nelse\n printf \" %-20s %s\\n\" \"Archive DB:\" \"will be created\"\nfi\n\n# Source data dir for this date\nDATA_SRC=\"$HOME/.screenpipe/data/data/$TARGET_DATE\"\nif [ -d \"$DATA_SRC\" ]; then\n DATA_SIZE=$(du -sh \"$DATA_SRC\" | cut -f1)\n DATA_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n printf \" %-20s %s (%s files, %s)\\n\" \"Data dir:\" \"OK\" \"$DATA_FILES\" \"$DATA_SIZE\"\nelse\n printf \" %-20s %s\\n\" \"Data dir:\" \"not found — skipping file copy\"\nfi\n\n# ─── DB SYNC ──────────────────────────────────────────────────────────────────\nif [ \"$DB_ALREADY_SYNCED\" = false ]; then\n\n # ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────\n step \"Counting source rows for $TARGET_DATE\"\n\n SRC_FRAMES=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\")\n SRC_ELEMENTS=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n SRC_UI=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';\")\n SRC_OCR=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n SRC_MEETINGS=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';\")\n\n printf \" %-20s %s\\n\" \"frames:\" \"$SRC_FRAMES\"\n printf \" %-20s %s\\n\" \"elements:\" \"$SRC_ELEMENTS\"\n printf \" %-20s %s\\n\" \"ui_events:\" \"$SRC_UI\"\n printf \" %-20s %s\\n\" \"ocr_text:\" \"$SRC_OCR\"\n printf \" %-20s %s\\n\" \"meetings:\" \"$SRC_MEETINGS\"\n\n if [ \"$SRC_FRAMES\" -eq \"0\" ]; then\n log \"No frames found for $TARGET_DATE — skipping DB sync\"\n DB_ALREADY_SYNCED=true\n fi\n\nfi\n\nif [ \"$DB_ALREADY_SYNCED\" = false ]; then\n\n # ─── INIT TABLES ──────────────────────────────────────────────────────────\n step \"Initialising tables, indexes, FTS\"\n\n run_sqlite_heredoc \"creating tables\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"creating indexes\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);\nCREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);\nCREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"creating FTS tables\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(\n text, role, frame_id UNINDEXED,\n content='elements', content_rowid='id', tokenize='unicode61'\n);\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(\n full_text, app_name, window_name, browser_url, id UNINDEXED,\n tokenize='unicode61'\n);\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(\n text_content,\n app_name,\n window_title,\n element_name,\n content='ui_events',\n content_rowid='id',\n tokenize='unicode61'\n);\nDETACH nas;\n\"\n\n # ─── SYNC DATA ────────────────────────────────────────────────────────────\n step \"Syncing data for $TARGET_DATE\"\n\n run_sqlite_heredoc \"video_chunks\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.video_chunks\n SELECT * FROM main.video_chunks\n WHERE id IN (\n SELECT DISTINCT video_chunk_id FROM main.frames\n WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL\n );\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames ($SRC_FRAMES rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.frames\n SELECT * FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ocr_text ($SRC_OCR rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ocr_text\n SELECT o.* FROM main.ocr_text o\n JOIN main.frames f ON o.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events ($SRC_UI rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ui_events\n SELECT * FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"elements ($SRC_ELEMENTS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.elements\n SELECT e.* FROM main.elements e\n JOIN main.frames f ON e.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"meetings ($SRC_MEETINGS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.meetings\n SELECT * FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n # ─── FTS UPDATE ───────────────────────────────────────────────────────────\n step \"Updating FTS indexes\"\n\n run_sqlite_heredoc \"elements_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.elements_fts(rowid, text, role)\n SELECT e.id, e.text, e.role\n FROM nas.elements e\n JOIN nas.frames f ON e.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE'\n AND e.text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)\n SELECT id, full_text, app_name, window_name, browser_url, id\n FROM nas.frames\n WHERE date(timestamp) = '$TARGET_DATE'\n AND full_text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)\n SELECT id, text_content, app_name, window_title, element_name\n FROM nas.ui_events\n WHERE date(timestamp) = '$TARGET_DATE'\n AND text_content IS NOT NULL;\nDETACH nas;\n\"\n\n # ─── VERIFY DB ────────────────────────────────────────────────────────────\n step \"Verifying DB\"\n\n V_FRAMES=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\")\n V_ELEMENTS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n V_UI=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';\")\n V_OCR=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n V_MEETINGS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';\")\n\n check \"frames\" \"$V_FRAMES\" \"$SRC_FRAMES\"\n check \"elements\" \"$V_ELEMENTS\" \"$SRC_ELEMENTS\"\n check \"ui_events\" \"$V_UI\" \"$SRC_UI\"\n check \"ocr_text\" \"$V_OCR\" \"$SRC_OCR\"\n check \"meetings\" \"$V_MEETINGS\" \"$SRC_MEETINGS\"\n\nfi\n\n# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────\n# Always runs regardless of DB sync status\nstep \"Copying data folder for $TARGET_DATE\"\n\nif [ -d \"$DATA_SRC\" ]; then\n mkdir -p \"$NAS_DATA/$TARGET_DATE\"\n RSYNC_START=$(date +%s)\n printf \" %-36s \" \"rsync $TARGET_DATE/ → NAS\"\n rsync -a --ignore-existing \\\n \"$DATA_SRC/\" \\\n \"$NAS_DATA/$TARGET_DATE/\" \\\n 2>>\"$LOG_FILE\"\n RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))\n COPIED_FILES=$(ls \"$NAS_DATA/$TARGET_DATE\" | wc -l | tr -d ' ')\n SRC_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n COPIED_SIZE=$(du -sh \"$NAS_DATA/$TARGET_DATE\" | cut -f1)\n if [ \"$COPIED_FILES\" -eq \"$SRC_FILES\" ]; then\n printf \"\\r %-36s ✓ %dm%02ds (%s files, %s)\\n\" \\\n \"rsync $TARGET_DATE/ → NAS\" \\\n \"$(( RSYNC_DUR / 60 ))\" \"$(( RSYNC_DUR % 60 ))\" \\\n \"$COPIED_FILES\" \"$COPIED_SIZE\" | tee -a \"$LOG_FILE\"\n else\n printf \"\\r %-36s ✗ %s / %s files\\n\" \\\n \"rsync $TARGET_DATE/ → NAS\" \"$COPIED_FILES\" \"$SRC_FILES\" | tee -a \"$LOG_FILE\"\n fi\nelse\n printf \" %-36s %s\\n\" \"rsync $TARGET_DATE/ → NAS\" \"skipped (no source dir)\"\nfi\n\n# ─── SUMMARY ──────────────────────────────────────────────────────────────────\nTOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))\nDB_SIZE=$(du -sh \"$NAS_DB\" | cut -f1)\n\necho \"\"\nlog \"Archive DB size: $DB_SIZE\"\nlog \"Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s\"\nlog \"Sync complete for $TARGET_DATE\"\nlog \"========================================\"","depth":29,"bounds":{"left":0.13763298,"top":0.5490822,"width":0.35804522,"height":0.014365523},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Implement and run pipe l…, Editor Group 2","depth":28,"bounds":{"left":0.5578458,"top":0.047885075,"width":0.073803194,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":false},{"role":"AXRadioButton","text":"Problems (⇧⌘M)","depth":22,"bounds":{"left":0.118351065,"top":0.7278532,"width":0.027925532,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"PROBLEMS","depth":24,"bounds":{"left":0.122340426,"top":0.7366321,"width":0.019946808,"height":0.0103751},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Output (⇧⌘U)","depth":22,"bounds":{"left":0.14594415,"top":0.7278532,"width":0.023603724,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUTPUT","depth":24,"bounds":{"left":0.14993352,"top":0.7366321,"width":0.015625,"height":0.0103751},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Debug Console (⇧⌘Y)","depth":22,"bounds":{"left":0.16921543,"top":0.7278532,"width":0.039893616,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"DEBUG CONSOLE","depth":24,"bounds":{"left":0.1732048,"top":0.7366321,"width":0.031914894,"height":0.0103751},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Terminal (⌃`)","depth":22,"bounds":{"left":0.2087766,"top":0.7278532,"width":0.026595745,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":true},{"role":"AXStaticText","text":"TERMINAL","depth":24,"bounds":{"left":0.21276596,"top":0.7366321,"width":0.01861702,"height":0.0103751},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Ports - 1 forwarded port","depth":22,"bounds":{"left":0.23537233,"top":0.7278532,"width":0.026263298,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"PORTS","depth":24,"bounds":{"left":0.2393617,"top":0.7366321,"width":0.012300532,"height":0.0103751},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":25,"bounds":{"left":0.25465426,"top":0.73743016,"width":0.0019946808,"height":0.008778931},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"remote SSH: nas","depth":16,"bounds":{"left":0.0006648936,"top":0.98244214,"width":0.028590426,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.0033244682,"top":0.9848364,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"SSH: nas","depth":17,"bounds":{"left":0.008643617,"top":0.9856345,"width":0.017952127,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"screenpipe (Git) - master*, Checkout Branch/Tag...","depth":16,"bounds":{"left":0.030917553,"top":0.98244214,"width":0.023271276,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.031914894,"top":0.9848364,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"master*","depth":17,"bounds":{"left":0.03723404,"top":0.9856345,"width":0.015957447,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"screenpipe (Git) - Synchronize Changes","depth":16,"bounds":{"left":0.05418883,"top":0.98244214,"width":0.00731383,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"No Problems","depth":16,"bounds":{"left":0.06416223,"top":0.98244214,"width":0.022606382,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.06582447,"top":0.9848364,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"0","depth":17,"bounds":{"left":0.07114362,"top":0.9856345,"width":0.004986702,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.07579787,"top":0.9848364,"width":0.0056515955,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"0","depth":17,"bounds":{"left":0.08111702,"top":0.9856345,"width":0.0039893617,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Forwarded Ports: 8766","depth":16,"bounds":{"left":0.08843085,"top":0.98244214,"width":0.012632979,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.09009308,"top":0.9848364,"width":0.0056515955,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":17,"bounds":{"left":0.09541223,"top":0.9856345,"width":0.0039893617,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Notifications","depth":16,"bounds":{"left":0.9886968,"top":0.98244214,"width":0.010638298,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sign In","depth":16,"bounds":{"left":0.9650931,"top":0.98244214,"width":0.022606382,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.96675533,"top":0.9848364,"width":0.0056515955,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Sign In","depth":17,"bounds":{"left":0.97207445,"top":0.9856345,"width":0.013962766,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Shell Script","depth":16,"bounds":{"left":0.93916225,"top":0.98244214,"width":0.023603724,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Editor Language Status: $(copilot) No inline suggestion available, Inline suggestions","depth":16,"bounds":{"left":0.9318484,"top":0.98244214,"width":0.00731383,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"LF","depth":16,"bounds":{"left":0.9212101,"top":0.98244214,"width":0.007978723,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"UTF-8","depth":16,"bounds":{"left":0.90359044,"top":0.98244214,"width":0.015625,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Spaces: 2","depth":16,"bounds":{"left":0.8796542,"top":0.98244214,"width":0.022273935,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Ln 39, Col 1","depth":16,"bounds":{"left":0.85139626,"top":0.98244214,"width":0.026595745,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"git-commit Lukas Kovalik (2 weeks ago)","depth":16,"bounds":{"left":0.7869016,"top":0.98244214,"width":0.062832445,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.78856385,"top":0.9848364,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Lukas Kovalik (2 weeks ago)","depth":17,"bounds":{"left":0.79388297,"top":0.9856345,"width":0.05418883,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Info: Setting up SSH Host nas: Setting up SSH tunnel","depth":12,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Implement and run pipe logic","depth":19,"bounds":{"left":0.56017286,"top":0.08060654,"width":0.07114362,"height":0.022346368},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Session history","depth":19,"bounds":{"left":0.9780585,"top":0.08060654,"width":0.00930851,"height":0.022346368},"on_screen":true,"help_text":"Session history","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"New session","depth":19,"bounds":{"left":0.9886968,"top":0.08060654,"width":0.00930851,"height":0.022346368},"on_screen":true,"help_text":"New session","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Message actions","depth":24,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"main.py","depth":23,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"lets implement logic with pipes. how can I run it?","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Let me look at the current project structure to understand what's already in place.","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"List project files","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"find /volume1/screenpipe -type f | head -50 && echo \"---\" && ls /volume1/screenpipe","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"/volume1/screenpipe/.DS_Store\n/volume1/screenpipe/screenpipe.db\n/volume1/screenpipe/screenpipe_sync.sh\n/volume1/screenpipe/app_settings.json\n/volume1/screenpipe/.gitignore\n/volume1/screenpipe/archive.db\n/volume1/screenpipe/db.sqlite\n/volume1/screenpipe/db.sqlite-wal\n/volume1/screenpipe/db.sqlite-shm\n/volume1/screenpipe/#recycle/desktop.ini\n/volume1/screenpipe/#recycle/db.sqlite\n/volume1/screenpipe/#recycle/Copy #1 of db.sqlite\n/volume1/screenpipe/#recycle/.DS_Store\n/volume1/screenpipe/#recycle/Copy #2 of db.sqlite\n/volume1/screenpipe/#recycle/archive.db\n/volume1/screenpipe/#recycle/Copy #1 of archive.db\n/volume1/screenpipe/#recycle/Copy #2 of archive.db\n/volume1/screenpipe/#recycle/Copy #3 of archive.db\n/volume1/screenpipe/#recycle/Copy #4 of archive.db\n/volume1/screenpipe/#recycle/Copy #5 of archive.db\n/volume1/screenpipe/#recycle/Copy #3 of db.sqlite\n/volume1/screenpipe/#recycle/Copy #4 of db.sqlite\n/volume1/screenpipe/#recycle/Copy #6 of archive.db\n/volume1/screenpipe/#recycle/test.txt\n/volume1/screenpipe/#recycle/Copy #7 of archive.db\n/volume1/screenpipe/#recycle/Copy #8 of archive.db\n/volume1/screenpipe/#recycle/archive.db-journal\n/volume1/screenpipe/#recycle/Copy #1 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #2 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #3 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #4 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #5 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #6 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #7 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #5 of db.sqlite\n/volume1/screenpipe/pipes/.DS_Store\n/volume1/screenpipe/app/.env\n/volume1/screenpipe/app/cli.py\n/volume1/screenpipe/app/.DS_Store\n/volume1/screenpipe/app/db.py\n/volume1/screenpipe/app/docker-compose.yml\n/volume1/screenpipe/app/main.py\n/volume1/screenpipe/app/requirements.txt\n/volume1/screenpipe/app/Dockerfile\n/volume1/screenpipe/data/.DS_Store\n/volume1/screenpipe/.git/description\n/volume1/screenpipe/.git/HEAD\n/volume1/screenpipe/.git/index\n/volume1/screenpipe/.git/COMMIT_EDITMSG\n/volume1/screenpipe/#recycle/data/.DS_Store\n---\napp\napp_settings.json\narchive.db\ndata\ndb.sqlite\ndb.sqlite-shm\ndb.sqlite-wal\npipes\n#recycle\nscreenpipe.db\nscreenpipe_sync.sh","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"main.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Check pipes directory and docker-compose","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/pipes/ && ls /volume1/screenpipe/app/ && cat /volume1/screenpipe/app/docker-compose.yml","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ai-habits\nday-recap\nmeeting-summary\nstandup-update\ntime-breakdown\nvideo-export\ncli.py\nconsumers\ndb.py\ndocker-compose.yml\nDockerfile\nmain.py\n__pycache__\nrequirements.txt\nstatic\nservices:\n screenpipe-app:\n build: .\n container_name: screenpipe-app\n restart: unless-stopped\n ports:\n - \"8766:8000\"\n volumes:\n - /volume1/screenpipe:/data\n env_file:\n - .env\n environment:\n TZ: Europe/Sofia\n DB_PATH: /data/db.sqlite\n\n sqlite-web-archive:\n image: ghcr.io/coleifer/sqlite-web:latest\n container_name: screenpipe-sqlweb-archive\n restart: unless-stopped\n ports:\n - \"8767:8080\"\n volumes:\n - /volume1/screenpipe:/data\n command: [\"-H\", \"0.0.0.0\", \"-r\", \"/data/archive.db\"]\n\n sqlite-web-live:\n image: ghcr.io/coleifer/sqlite-web:latest\n container_name: screenpipe-sqlweb-live\n restart: unless-stopped\n ports:\n - \"8768:8080\"\n volumes:\n - /volume1/screenpipe:/data\n command: [\"-H\", \"0.0.0.0\", \"-r\", \"/data/db.sqlite\"]","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"requirements.txt","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"requirements.txt","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Inspect a pipe directory","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/pipes/day-recap/ && cat /volume1/screenpipe/pipes/day-recap/pipe.json 2>/dev/null || ls /volume1/screenpipe/pipes/day-recap/","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"pipe.md\npipe.md","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"cli.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"cli.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"List all pipes and their contents","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/pipes/ && for d in /volume1/screenpipe/pipes/*/; do echo \"=== $d ===\"; ls \"$d\"; done","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ai-habits\nday-recap\nmeeting-summary\nstandup-update\ntime-breakdown\nvideo-export\n=== /volume1/screenpipe/pipes/ai-habits/ ===\npipe.md\n=== /volume1/screenpipe/pipes/day-recap/ ===\npipe.md\n=== /volume1/screenpipe/pipes/meeting-summary/ ===\npipe.md\n=== /volume1/screenpipe/pipes/standup-update/ ===\npipe.md\n=== /volume1/screenpipe/pipes/time-breakdown/ ===\npipe.md\n=== /volume1/screenpipe/pipes/video-export/ ===\npipe.md","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read pipe markdown files","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"cat /volume1/screenpipe/pipes/day-recap/pipe.md && echo \"===\" && cat /volume1/screenpipe/pipes/meeting-summary/pipe.md 2>/dev/null | head -50","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Day Recap\ndescription: \"Today's accomplishments, key moments, and unfinished work\"\nicon: \"📋\"\nfeatured: true\n---\n\nAnalyze my screen and audio recordings from today (last 16 hours only). \n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Summary\nOne sentence: what I mainly did today.\n\n## Accomplishments\n- Top 3 things I finished, with timestamps (e.g. \"2:30 PM\")\n- Name specific apps, files, or projects\n\n## Key Moments\n- Important things I saw, said, or heard — with timestamps\n\n## Unfinished Work\n- What I should continue tomorrow — name the app/file/task\n\n## Patterns\n- Apps I used most, topics that came up repeatedly\n\nOnly report what you can verify from the data. End with: \"**Next step:** [most important thing to continue]\"\n===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Meeting Summary\ndescription: \"Summarize meeting transcript with key takeaways and action items\"\nicon: \"🤝\"\nfeatured: false\n---\n\nSummarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.\n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Meeting Summary\nOne sentence: what this meeting was about.\n\n## Key Takeaways\n- Top 3-5 important points discussed\n- Include who said what when relevant\n\n## Action Items\n- [ ] Task — assigned to whom, deadline if mentioned\n- [ ] Task — assigned to whom\n\n## Decisions Made\n- List any decisions or agreements reached\n\n## Open Questions\n- Anything unresolved or needing follow-up\n\nKeep it concise and actionable.","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read summary consumer","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/app/consumers/ && cat /volume1/screenpipe/app/consumers/summary.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"activity.py\naudio.py\nelements.py\n__init__.py\ninteractions.py\nocr.py\n__pycache__\nreport.py\nsummary.py\n\"\"\"AI summary generator using Claude.\"\"\"\nimport os\nfrom datetime import date\nfrom typing import Any\n\nfrom consumers.activity import app_time, summary_stats, browser_urls, ui_event_summary\nfrom consumers.ocr import deduplicated_text\nfrom consumers.audio import formatted_transcript\n\n\nSUMMARY_TYPES = {\n \"day_recap\": {\n \"title\": \"Day Recap\",\n \"prompt\": \"\"\"\\\nYou are analyzing a person's computer activity for the day.\n\n## App usage (minutes per app):\n{app_time}\n\n## Browser URLs visited:\n{browser_urls}\n\n## UI activity per app (clicks / keystrokes / app-switches):\n{ui_events}\n\n## Screen content (sampled every 5 minutes):\n{ocr_text}\n\n## Audio/speech:\n{audio}\n\nWrite a concise day recap using EXACTLY this format:\n\n## Summary\nOne sentence: what I mainly worked on today.\n\n## Accomplishments\n- Top 3 things I finished, with approximate times\n- Name specific apps, files, or projects\n\n## Key Moments\n- Important things seen or heard, with timestamps\n\n## Unfinished Work\n- What to continue tomorrow\n\n## Patterns\n- Apps used most, topics that came up repeatedly\n\nOnly report what you can verify from the data. End with:\n**Next step:** [most important thing to continue]\"\"\",\n },\n \"standup\": {\n \"title\": \"Standup Update\",\n \"prompt\": \"\"\"\\\nYou are analyzing a person's computer activity for the day.\n\n## App usage (minutes per app):\n{app_time}\n\n## Browser URLs visited:\n{browser_urls}\n\n## UI activity per app (clicks / keystrokes / app-switches):\n{ui_events}\n\n## Screen content (sampled every 5 minutes):\n{ocr_text}\n\n## Audio/speech:\n{audio}\n\nWrite a brief standup update:\n\n**Yesterday:** What I worked on (2-3 bullets)\n**Today:** What I plan to continue (1-2 bullets)\n**Blockers:** Any issues observed (or \"None\")\n\nKeep it under 150 words. Only report what's verifiable from the data.\"\"\",\n },\n \"focus_time\": {\n \"title\": \"Focus & Distraction Analysis\",\n \"prompt\": \"\"\"\\\nYou are analyzing a person's computer activity for the day.\n\n## App usage (minutes per app):\n{app_time}\n\n## Browser URLs visited:\n{browser_urls}\n\n## UI activity per app (clicks / keystrokes / app-switches):\n{ui_events}\n\n## Screen content (sampled every 5 minutes):\n{ocr_text}\n\nAnalyze focus vs distraction patterns:\n\n## Deep Work Periods\n- When and how long were sustained focus sessions?\n- What was being worked on?\n\n## Distractions\n- Which apps/sites were used recreationally?\n- How much time was lost to context switching?\n\n## Recommendations\n- 2-3 concrete suggestions to improve focus tomorrow\n\nBe specific with times and app names.\"\"\",\n },\n}\n\n\ndef _build_context(for_date: date) -> dict[str, str]:\n apps = app_time(for_date)\n app_lines = \"\\n\".join(f\"- {a['app_name']}: {a['minutes']} min\" for a in apps[:20])\n\n urls = browser_urls(for_date, limit=20)\n url_lines = \"\\n\".join(\n f\"- {u['browser_url'][:100]} ({u['minutes']} min)\" for u in urls\n )\n\n ui_rows = ui_event_summary(for_date)\n ui_lines = \"\\n\".join(\n f\"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches\"\n for r in ui_rows[:15]\n )\n\n ocr_rows = deduplicated_text(for_date, chunk_minutes=5)\n ocr_lines = \"\\n\".join(\n f\"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}\"\n for r in ocr_rows[:100]\n )\n\n audio = formatted_transcript(for_date)\n\n return {\n \"app_time\": app_lines or \"(no app data)\",\n \"browser_urls\": url_lines or \"(no browser data)\",\n \"ui_events\": ui_lines or \"(no UI event data)\",\n \"ocr_text\": ocr_lines or \"(no screen data)\",\n \"audio\": audio[:3000] if len(audio) > 3000 else audio,\n }\n\n\ndef generate(\n summary_type: str = \"day_recap\",\n for_date: date | None = None,\n api_key: str | None = None,\n) -> dict[str, Any]:\n \"\"\"Generate an AI summary. Returns dict with 'title', 'content', 'date'.\"\"\"\n import anthropic\n\n d = for_date or date.today()\n key = api_key or os.environ.get(\"ANTHROPIC_API_KEY\", \"\")\n if not key:\n return {\n \"title\": \"Error\",\n \"content\": \"ANTHROPIC_API_KEY not set. Add it to your .env file.\",\n \"date\": str(d),\n }\n\n spec = SUMMARY_TYPES.get(summary_type)\n if not spec:\n return {\"title\": \"Error\", \"content\": f\"Unknown summary type: {summary_type}\", \"date\": str(d)}\n\n stats = summary_stats(d)\n if stats[\"total_frames\"] == 0:\n return {\n \"title\": spec[\"title\"],\n \"content\": f\"No screen data found for {d}.\",\n \"date\": str(d),\n }\n\n ctx = _build_context(d)\n prompt = spec[\"prompt\"].format(**ctx)\n\n client = anthropic.Anthropic(api_key=key)\n message = client.messages.create(\n model=\"claude-haiku-4-5-20251001\",\n max_tokens=1024,\n messages=[{\"role\": \"user\", \"content\": prompt}],\n )\n\n return {\n \"title\": spec[\"title\"],\n \"content\": message.content[0].text,\n \"date\": str(d),\n \"stats\": stats,\n }","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read all pipe.md files","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"for f in /volume1/screenpipe/pipes/*/pipe.md; do echo \"=== $f ===\"; cat \"$f\"; echo; done","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"=== /volume1/screenpipe/pipes/ai-habits/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: AI Habits\ndescription: \"How you use AI tools — patterns and insights\"\nicon: \"🤖\"\nfeatured: true\n---\n\nSearch my recordings from the last 24 hours for AI tool usage. Use app_name filter for each tool separately: ChatGPT, Claude, Copilot, Cursor, Gemini, Perplexity. Use limit=5 per search, max 6 searches total.\n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## AI Tools Used\n- List each tool with approximate time spent (e.g. \"Claude: ~45min\")\n\n## What I Used Them For\n- For each tool: coding, writing, research, or brainstorming\n\n## Usage Patterns\n- Do I switch between tools? Use them in bursts or steadily?\n\n## Effectiveness\n- Which tool appeared alongside completed work vs. abandoned attempts\n\nIf no AI usage is found, say so clearly. End with: \"**Tip:** [one suggestion to use AI tools more effectively]\"\n\n=== /volume1/screenpipe/pipes/day-recap/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Day Recap\ndescription: \"Today's accomplishments, key moments, and unfinished work\"\nicon: \"📋\"\nfeatured: true\n---\n\nAnalyze my screen and audio recordings from today (last 16 hours only). \n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Summary\nOne sentence: what I mainly did today.\n\n## Accomplishments\n- Top 3 things I finished, with timestamps (e.g. \"2:30 PM\")\n- Name specific apps, files, or projects\n\n## Key Moments\n- Important things I saw, said, or heard — with timestamps\n\n## Unfinished Work\n- What I should continue tomorrow — name the app/file/task\n\n## Patterns\n- Apps I used most, topics that came up repeatedly\n\nOnly report what you can verify from the data. End with: \"**Next step:** [most important thing to continue]\"\n\n=== /volume1/screenpipe/pipes/meeting-summary/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Meeting Summary\ndescription: \"Summarize meeting transcript with key takeaways and action items\"\nicon: \"🤝\"\nfeatured: false\n---\n\nSummarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.\n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Meeting Summary\nOne sentence: what this meeting was about.\n\n## Key Takeaways\n- Top 3-5 important points discussed\n- Include who said what when relevant\n\n## Action Items\n- [ ] Task — assigned to whom, deadline if mentioned\n- [ ] Task — assigned to whom\n\n## Decisions Made\n- List any decisions or agreements reached\n\n## Open Questions\n- Anything unresolved or needing follow-up\n\nKeep it concise and actionable.\n\n=== /volume1/screenpipe/pipes/standup-update/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Standup Update\ndescription: \"What you did, what's next, and any blockers\"\nicon: \"🏢\"\nfeatured: true\n---\n\nBased on my recordings from the last 24 hours, generate a standup update. Use limit=10 per search, max 3 searches total.\n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Yesterday\n- What I worked on (name specific projects, files, tools, PRs)\n\n## Today\n- What I will work on next (based on unfinished tasks and recent activity)\n\n## Blockers\n- Issues I hit — errors, slow builds, waiting on someone\n- If no blockers, write \"None\"\n\nKeep it under 150 words. Copy-paste ready for a team standup.\n\n=== /volume1/screenpipe/pipes/time-breakdown/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Time Breakdown\ndescription: \"Where your time went — by app, project, and category\"\nicon: \"⏱\"\nfeatured: false\n---\n\nAnalyze my app usage from today (last 12 hours). Use limit=10 per search, max 4 searches. Prefer /raw_sql with COUNT/GROUP BY queries.\n\nRead screenpipe skill first.\n\nUse this exact format with durations and percentages:\n\n## By Application\n- List each app with duration and percentage, sorted by time (e.g. \"VS Code: 2h 15min (28%)\")\n\n## By Category\n- Group into: coding, meetings, browsing, writing, communication, other\n- Show hours and percentage per category\n\n## By Project\n- Group related activities by project/topic. Name specific repos or tasks.\n\n## Productivity Score\n- Calculate: focused_work_hours / total_hours as a percentage\n- Focused = coding + writing. Unfocused = browsing + switching.\n\nEnd with: \"**Suggestion:** [one specific change to improve tomorrow's productivity]\"\n\n=== /volume1/screenpipe/pipes/video-export/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Export Video Clip\ndescription: \"Create a video of your recent screen activity\"\nicon: \"🎬\"\nfeatured: false\n---\n\nExport a video of my screen activity from the last 5 minutes.\n\nRead screenpipe skill first.\n\nUse the POST /frames/export endpoint with the time range and fps=1.0. Then show me the exported video file path as an inline code block so I can watch it.\n\nIf the export is large, suggest a lower fps or shorter time range.","depth":25,"on_screen":false,"role_description":"text"}]...
|
3392067718020890191
|
3895833367589391637
|
click
|
accessibility
|
NULL
|
Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧ Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py
M
db.py
docker-compose.yml
Dockerfile
M
main.py
M
requirements.txt
M
data
logs
pipes
.gitignore
app_settings.json
archive.db
archive.db-bak
U
db.sqlite
db.sqlite-shm
db.sqlite-wal
screenpipe_sync_updated.sh
U
screenpipe_sync.sh
screenpipe.db
Outline Section
OUTLINE
OUTLINE
Timeline Section
TIMELINE
TIMELINE
app_settings.json, Editor Group 1
screenpipe_sync.sh, Editor Group 1
pipe.md, Editor Group 1
.env, Editor Group 1
#!/bin/bash
# screenpipe_sync.sh
# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).
# Also copies the day's video/frame data folder to the NAS.
#
# Usage:
# ./screenpipe_sync.sh # syncs yesterday (default)
# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date
# ./screenpipe_sync.sh today # syncs today so far
#
# Cron example (runs at 3am daily):
# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1
set -euo pipefail
# ─── CONFIG ───────────────────────────────────────────────────────────────────
DB_SRC="${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}"
NAS_MOUNT="${NAS_MOUNT:-/Volumes/Test/screenpipe}"
NAS_DB="$NAS_MOUNT/archive.db"
NAS_DATA="$NAS_MOUNT/data"
LOG_FILE="$HOME/.screenpipe/sync.log"
# ──────────────────────────────────────────────────────────────────────────────
# ─── HELPERS ──────────────────────────────────────────────────────────────────
SCRIPT_START=$(date +%s)
log() {
local msg="[$(date '+%Y-%m-%d %H:%M:%S')] $*"
echo "$msg" | tee -a "$LOG_FILE"
}
step() {
local now=$(date +%s)
local elapsed=$(( now - SCRIPT_START ))
local min=$(( elapsed / 60 ))
local sec=$(( elapsed % 60 ))
printf "\n[+%02dm%02ds] ▶ %s\n" "$min" "$sec" "$*" | tee -a "$LOG_FILE"
}
run_sqlite_heredoc() {
local label="$1"
local sql="$2"
local start=$(date +%s)
printf " %-36s " "$label"
sqlite3 "$DB_SRC" <<< "$sql" &
local pid=$!
local spin=[PASSWORD] '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')
local i=0
while kill -0 "$pid" 2>/dev/null; do
printf "\r %-36s %s " "$label" "${spin[$i]}"
i=$(( (i + 1) % 10 ))
sleep 0.2
done
wait "$pid"
local rc=$?
if [ $rc -ne 0 ]; then
printf "\r %-36s ✗ FAILED\n" "$label" | tee -a "$LOG_FILE"
exit $rc
fi
local dur=$(( $(date +%s) - start ))
printf "\r %-36s ✓ %dm%02ds\n" "$label" "$(( dur / 60 ))" "$(( dur % 60 ))" | tee -a "$LOG_FILE"
}
check() {
local label="$1" got="$2" expected="$3"
if [ "$got" -eq "$expected" ]; then
printf " %-20s %s / %s ✓\n" "$label:" "$got" "$expected"
else
printf " %-20s %s / %s ✗ MISMATCH\n" "$label:" "$got" "$expected"
fi
}
# ──────────────────────────────────────────────────────────────────────────────
# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────
if [ "${1:-}" = "today" ]; then
TARGET_DATE=$(date +%Y-%m-%d)
elif [ -n "${1:-}" ]; then
TARGET_DATE="$1"
if ! [[ "$TARGET_DATE" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then
echo "ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday."
exit 1
fi
else
TARGET_DATE=$(date -v-1d +%Y-%m-%d)
fi
log "========================================"
log "Screenpipe sync starting for: $TARGET_DATE"
log "========================================"
# ─── PREFLIGHT ────────────────────────────────────────────────────────────────
step "Preflight checks"
if [ ! -f "$DB_SRC" ]; then
log "ERROR: Source DB not found at $DB_SRC"; exit 1
fi
printf " %-20s %s (%s)\n" "Source DB:" "OK" "$(du -sh "$DB_SRC" | cut -f1)"
if [ ! -d "$NAS_MOUNT" ]; then
log "ERROR: NAS not mounted at $NAS_MOUNT"; exit 1
fi
printf " %-20s %s\n" "NAS mount:" "OK $NAS_MOUNT"
# Check if DB already synced for this date
DB_ALREADY_SYNCED=false
if [ -f "$NAS_DB" ]; then
EXISTING=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';" 2>/dev/null || echo "0")
if [ "$EXISTING" -gt "0" ]; then
log "Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync"
DB_ALREADY_SYNCED=true
else
printf " %-20s %s (%s)\n" "Archive DB:" "exists" "$(du -sh "$NAS_DB" | cut -f1)"
fi
else
printf " %-20s %s\n" "Archive DB:" "will be created"
fi
# Source data dir for this date
DATA_SRC="$HOME/.screenpipe/data/data/$TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
DATA_SIZE=$(du -sh "$DATA_SRC" | cut -f1)
DATA_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
printf " %-20s %s (%s files, %s)\n" "Data dir:" "OK" "$DATA_FILES" "$DATA_SIZE"
else
printf " %-20s %s\n" "Data dir:" "not found — skipping file copy"
fi
# ─── DB SYNC ──────────────────────────────────────────────────────────────────
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────
step "Counting source rows for $TARGET_DATE"
SRC_FRAMES=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
SRC_ELEMENTS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_UI=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
SRC_OCR=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_MEETINGS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';")
printf " %-20s %s\n" "frames:" "$SRC_FRAMES"
printf " %-20s %s\n" "elements:" "$SRC_ELEMENTS"
printf " %-20s %s\n" "ui_events:" "$SRC_UI"
printf " %-20s %s\n" "ocr_text:" "$SRC_OCR"
printf " %-20s %s\n" "meetings:" "$SRC_MEETINGS"
if [ "$SRC_FRAMES" -eq "0" ]; then
log "No frames found for $TARGET_DATE — skipping DB sync"
DB_ALREADY_SYNCED=true
fi
fi
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── INIT TABLES ──────────────────────────────────────────────────────────
step "Initialising tables, indexes, FTS"
run_sqlite_heredoc "creating tables" "
ATTACH '$NAS_DB' AS nas;
CREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;
CREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;
CREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;
CREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;
DETACH nas;
"
run_sqlite_heredoc "creating indexes" "
ATTACH '$NAS_DB' AS nas;
CREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);
CREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);
DETACH nas;
"
run_sqlite_heredoc "creating FTS tables" "
ATTACH '$NAS_DB' AS nas;
CREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(
text, role, frame_id UNINDEXED,
content='elements', content_rowid='id', tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(
full_text, app_name, window_name, browser_url, id UNINDEXED,
tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(
text_content,
app_name,
window_title,
element_name,
content='ui_events',
content_rowid='id',
tokenize='unicode61'
);
DETACH nas;
"
# ─── SYNC DATA ────────────────────────────────────────────────────────────
step "Syncing data for $TARGET_DATE"
run_sqlite_heredoc "video_chunks" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.video_chunks
SELECT * FROM main.video_chunks
WHERE id IN (
SELECT DISTINCT video_chunk_id FROM main.frames
WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL
);
DETACH nas;
"
run_sqlite_heredoc "frames ($SRC_FRAMES rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.frames
SELECT * FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ocr_text ($SRC_OCR rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ocr_text
SELECT o.* FROM main.ocr_text o
JOIN main.frames f ON o.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ui_events ($SRC_UI rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ui_events
SELECT * FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "elements ($SRC_ELEMENTS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.elements
SELECT e.* FROM main.elements e
JOIN main.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "meetings ($SRC_MEETINGS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.meetings
SELECT * FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';
DETACH nas;
"
# ─── FTS UPDATE ───────────────────────────────────────────────────────────
step "Updating FTS indexes"
run_sqlite_heredoc "elements_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.elements_fts(rowid, text, role)
SELECT e.id, e.text, e.role
FROM nas.elements e
JOIN nas.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE'
AND e.text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "frames_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)
SELECT id, full_text, app_name, window_name, browser_url, id
FROM nas.frames
WHERE date(timestamp) = '$TARGET_DATE'
AND full_text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "ui_events_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)
SELECT id, text_content, app_name, window_title, element_name
FROM nas.ui_events
WHERE date(timestamp) = '$TARGET_DATE'
AND text_content IS NOT NULL;
DETACH nas;
"
# ─── VERIFY DB ────────────────────────────────────────────────────────────
step "Verifying DB"
V_FRAMES=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
V_ELEMENTS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_UI=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
V_OCR=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_MEETINGS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';")
check "frames" "$V_FRAMES" "$SRC_FRAMES"
check "elements" "$V_ELEMENTS" "$SRC_ELEMENTS"
check "ui_events" "$V_UI" "$SRC_UI"
check "ocr_text" "$V_OCR" "$SRC_OCR"
check "meetings" "$V_MEETINGS" "$SRC_MEETINGS"
fi
# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────
# Always runs regardless of DB sync status
step "Copying data folder for $TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
mkdir -p "$NAS_DATA/$TARGET_DATE"
RSYNC_START=$(date +%s)
printf " %-36s " "rsync $TARGET_DATE/ → NAS"
rsync -a --ignore-existing \
"$DATA_SRC/" \
"$NAS_DATA/$TARGET_DATE/" \
2>>"$LOG_FILE"
RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))
COPIED_FILES=$(ls "$NAS_DATA/$TARGET_DATE" | wc -l | tr -d ' ')
SRC_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
COPIED_SIZE=$(du -sh "$NAS_DATA/$TARGET_DATE" | cut -f1)
if [ "$COPIED_FILES" -eq "$SRC_FILES" ]; then
printf "\r %-36s ✓ %dm%02ds (%s files, %s)\n" \
"rsync $TARGET_DATE/ → NAS" \
"$(( RSYNC_DUR / 60 ))" "$(( RSYNC_DUR % 60 ))" \
"$COPIED_FILES" "$COPIED_SIZE" | tee -a "$LOG_FILE"
else
printf "\r %-36s ✗ %s / %s files\n" \
"rsync $TARGET_DATE/ → NAS" "$COPIED_FILES" "$SRC_FILES" | tee -a "$LOG_FILE"
fi
else
printf " %-36s %s\n" "rsync $TARGET_DATE/ → NAS" "skipped (no source dir)"
fi
# ─── SUMMARY ──────────────────────────────────────────────────────────────────
TOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))
DB_SIZE=$(du -sh "$NAS_DB" | cut -f1)
echo ""
log "Archive DB size: $DB_SIZE"
log "Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s"
log "Sync complete for $TARGET_DATE"
log "========================================"
#!/bin/bash
# screenpipe_sync.sh
# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).
# Also copies the day's video/frame data folder to the NAS.
#
# Usage:
# ./screenpipe_sync.sh # syncs yesterday (default)
# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date
# ./screenpipe_sync.sh today # syncs today so far
#
# Cron example (runs at 3am daily):
# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1
set -euo pipefail
# ─── CONFIG ───────────────────────────────────────────────────────────────────
DB_SRC="${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}"
NAS_MOUNT="${NAS_MOUNT:-/Volumes/Test/screenpipe}"
NAS_DB="$NAS_MOUNT/archive.db"
NAS_DATA="$NAS_MOUNT/data"
LOG_FILE="$HOME/.screenpipe/sync.log"
# ──────────────────────────────────────────────────────────────────────────────
# ─── HELPERS ──────────────────────────────────────────────────────────────────
SCRIPT_START=$(date +%s)
log() {
local msg="[$(date '+%Y-%m-%d %H:%M:%S')] $*"
echo "$msg" | tee -a "$LOG_FILE"
}
step() {
local now=$(date +%s)
local elapsed=$(( now - SCRIPT_START ))
local min=$(( elapsed / 60 ))
local sec=$(( elapsed % 60 ))
printf "\n[+%02dm%02ds] ▶ %s\n" "$min" "$sec" "$*" | tee -a "$LOG_FILE"
}
run_sqlite_heredoc() {
local label="$1"
local sql="$2"
local start=$(date +%s)
printf " %-36s " "$label"
sqlite3 "$DB_SRC" <<< "$sql" &
local pid=$!
local spin=[PASSWORD] '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')
local i=0
while kill -0 "$pid" 2>/dev/null; do
printf "\r %-36s %s " "$label" "${spin[$i]}"
i=$(( (i + 1) % 10 ))
sleep 0.2
done
wait "$pid"
local rc=$?
if [ $rc -ne 0 ]; then
printf "\r %-36s ✗ FAILED\n" "$label" | tee -a "$LOG_FILE"
exit $rc
fi
local dur=$(( $(date +%s) - start ))
printf "\r %-36s ✓ %dm%02ds\n" "$label" "$(( dur / 60 ))" "$(( dur % 60 ))" | tee -a "$LOG_FILE"
}
check() {
local label="$1" got="$2" expected="$3"
if [ "$got" -eq "$expected" ]; then
printf " %-20s %s / %s ✓\n" "$label:" "$got" "$expected"
else
printf " %-20s %s / %s ✗ MISMATCH\n" "$label:" "$got" "$expected"
fi
}
# ──────────────────────────────────────────────────────────────────────────────
# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────
if [ "${1:-}" = "today" ]; then
TARGET_DATE=$(date +%Y-%m-%d)
elif [ -n "${1:-}" ]; then
TARGET_DATE="$1"
if ! [[ "$TARGET_DATE" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then
echo "ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday."
exit 1
fi
else
TARGET_DATE=$(date -v-1d +%Y-%m-%d)
fi
log "========================================"
log "Screenpipe sync starting for: $TARGET_DATE"
log "========================================"
# ─── PREFLIGHT ────────────────────────────────────────────────────────────────
step "Preflight checks"
if [ ! -f "$DB_SRC" ]; then
log "ERROR: Source DB not found at $DB_SRC"; exit 1
fi
printf " %-20s %s (%s)\n" "Source DB:" "OK" "$(du -sh "$DB_SRC" | cut -f1)"
if [ ! -d "$NAS_MOUNT" ]; then
log "ERROR: NAS not mounted at $NAS_MOUNT"; exit 1
fi
printf " %-20s %s\n" "NAS mount:" "OK $NAS_MOUNT"
# Check if DB already synced for this date
DB_ALREADY_SYNCED=false
if [ -f "$NAS_DB" ]; then
EXISTING=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';" 2>/dev/null || echo "0")
if [ "$EXISTING" -gt "0" ]; then
log "Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync"
DB_ALREADY_SYNCED=true
else
printf " %-20s %s (%s)\n" "Archive DB:" "exists" "$(du -sh "$NAS_DB" | cut -f1)"
fi
else
printf " %-20s %s\n" "Archive DB:" "will be created"
fi
# Source data dir for this date
DATA_SRC="$HOME/.screenpipe/data/data/$TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
DATA_SIZE=$(du -sh "$DATA_SRC" | cut -f1)
DATA_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
printf " %-20s %s (%s files, %s)\n" "Data dir:" "OK" "$DATA_FILES" "$DATA_SIZE"
else
printf " %-20s %s\n" "Data dir:" "not found — skipping file copy"
fi
# ─── DB SYNC ──────────────────────────────────────────────────────────────────
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────
step "Counting source rows for $TARGET_DATE"
SRC_FRAMES=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
SRC_ELEMENTS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_UI=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
SRC_OCR=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_MEETINGS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';")
printf " %-20s %s\n" "frames:" "$SRC_FRAMES"
printf " %-20s %s\n" "elements:" "$SRC_ELEMENTS"
printf " %-20s %s\n" "ui_events:" "$SRC_UI"
printf " %-20s %s\n" "ocr_text:" "$SRC_OCR"
printf " %-20s %s\n" "meetings:" "$SRC_MEETINGS"
if [ "$SRC_FRAMES" -eq "0" ]; then
log "No frames found for $TARGET_DATE — skipping DB sync"
DB_ALREADY_SYNCED=true
fi
fi
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── INIT TABLES ──────────────────────────────────────────────────────────
step "Initialising tables, indexes, FTS"
run_sqlite_heredoc "creating tables" "
ATTACH '$NAS_DB' AS nas;
CREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;
CREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;
CREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;
CREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;
DETACH nas;
"
run_sqlite_heredoc "creating indexes" "
ATTACH '$NAS_DB' AS nas;
CREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);
CREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);
DETACH nas;
"
run_sqlite_heredoc "creating FTS tables" "
ATTACH '$NAS_DB' AS nas;
CREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(
text, role, frame_id UNINDEXED,
content='elements', content_rowid='id', tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(
full_text, app_name, window_name, browser_url, id UNINDEXED,
tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(
text_content,
app_name,
window_title,
element_name,
content='ui_events',
content_rowid='id',
tokenize='unicode61'
);
DETACH nas;
"
# ─── SYNC DATA ────────────────────────────────────────────────────────────
step "Syncing data for $TARGET_DATE"
run_sqlite_heredoc "video_chunks" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.video_chunks
SELECT * FROM main.video_chunks
WHERE id IN (
SELECT DISTINCT video_chunk_id FROM main.frames
WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL
);
DETACH nas;
"
run_sqlite_heredoc "frames ($SRC_FRAMES rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.frames
SELECT * FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ocr_text ($SRC_OCR rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ocr_text
SELECT o.* FROM main.ocr_text o
JOIN main.frames f ON o.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ui_events ($SRC_UI rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ui_events
SELECT * FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "elements ($SRC_ELEMENTS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.elements
SELECT e.* FROM main.elements e
JOIN main.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "meetings ($SRC_MEETINGS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.meetings
SELECT * FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';
DETACH nas;
"
# ─── FTS UPDATE ───────────────────────────────────────────────────────────
step "Updating FTS indexes"
run_sqlite_heredoc "elements_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.elements_fts(rowid, text, role)
SELECT e.id, e.text, e.role
FROM nas.elements e
JOIN nas.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE'
AND e.text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "frames_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)
SELECT id, full_text, app_name, window_name, browser_url, id
FROM nas.frames
WHERE date(timestamp) = '$TARGET_DATE'
AND full_text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "ui_events_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)
SELECT id, text_content, app_name, window_title, element_name
FROM nas.ui_events
WHERE date(timestamp) = '$TARGET_DATE'
AND text_content IS NOT NULL;
DETACH nas;
"
# ─── VERIFY DB ────────────────────────────────────────────────────────────
step "Verifying DB"
V_FRAMES=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
V_ELEMENTS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_UI=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
V_OCR=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_MEETINGS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';")
check "frames" "$V_FRAMES" "$SRC_FRAMES"
check "elements" "$V_ELEMENTS" "$SRC_ELEMENTS"
check "ui_events" "$V_UI" "$SRC_UI"
check "ocr_text" "$V_OCR" "$SRC_OCR"
check "meetings" "$V_MEETINGS" "$SRC_MEETINGS"
fi
# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────
# Always runs regardless of DB sync status
step "Copying data folder for $TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
mkdir -p "$NAS_DATA/$TARGET_DATE"
RSYNC_START=$(date +%s)
printf " %-36s " "rsync $TARGET_DATE/ → NAS"
rsync -a --ignore-existing \
"$DATA_SRC/" \
"$NAS_DATA/$TARGET_DATE/" \
2>>"$LOG_FILE"
RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))
COPIED_FILES=$(ls "$NAS_DATA/$TARGET_DATE" | wc -l | tr -d ' ')
SRC_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
COPIED_SIZE=$(du -sh "$NAS_DATA/$TARGET_DATE" | cut -f1)
if [ "$COPIED_FILES" -eq "$SRC_FILES" ]; then
printf "\r %-36s ✓ %dm%02ds (%s files, %s)\n" \
"rsync $TARGET_DATE/ → NAS" \
"$(( RSYNC_DUR / 60 ))" "$(( RSYNC_DUR % 60 ))" \
"$COPIED_FILES" "$COPIED_SIZE" | tee -a "$LOG_FILE"
else
printf "\r %-36s ✗ %s / %s files\n" \
"rsync $TARGET_DATE/ → NAS" "$COPIED_FILES" "$SRC_FILES" | tee -a "$LOG_FILE"
fi
else
printf " %-36s %s\n" "rsync $TARGET_DATE/ → NAS" "skipped (no source dir)"
fi
# ─── SUMMARY ──────────────────────────────────────────────────────────────────
TOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))
DB_SIZE=$(du -sh "$NAS_DB" | cut -f1)
echo ""
log "Archive DB size: $DB_SIZE"
log "Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s"
log "Sync complete for $TARGET_DATE"
log "========================================"
Implement and run pipe l…, Editor Group 2
Problems (⇧⌘M)
PROBLEMS
Output (⇧⌘U)
OUTPUT
Debug Console (⇧⌘Y)
DEBUG CONSOLE
Terminal (⌃`)
TERMINAL
Ports - 1 forwarded port
PORTS
1
remote SSH: nas
SSH: nas
screenpipe (Git) - master*, Checkout Branch/Tag...
master*
screenpipe (Git) - Synchronize Changes
No Problems
0
0
Forwarded Ports: 8766
1
Notifications
Sign In
Sign In
Shell Script
Editor Language Status: $(copilot) No inline suggestion available, Inline suggestions
LF
UTF-8
Spaces: 2
Ln 39, Col 1
git-commit Lukas Kovalik (2 weeks ago)
Lukas Kovalik (2 weeks ago)
Info: Setting up SSH Host nas: Setting up SSH tunnel
Implement and run pipe logic
Session history
New session
Message actions
main.py
main.py
lets implement logic with pipes. how can I run it?
Thinking
Thinking
Let me look at the current project structure to understand what's already in place.
Bash
List project files
IN
find /volume1/screenpipe -type f | head -50 && echo "---" && ls /volume1/screenpipe
Copy code to clipboard
OUT
/volume1/screenpipe/.DS_Store
/volume1/screenpipe/screenpipe.db
/volume1/screenpipe/screenpipe_sync.sh
/volume1/screenpipe/app_settings.json
/volume1/screenpipe/.gitignore
/volume1/screenpipe/archive.db
/volume1/screenpipe/db.sqlite
/volume1/screenpipe/db.sqlite-wal
/volume1/screenpipe/db.sqlite-shm
/volume1/screenpipe/#recycle/desktop.ini
/volume1/screenpipe/#recycle/db.sqlite
/volume1/screenpipe/#recycle/Copy #1 of db.sqlite
/volume1/screenpipe/#recycle/.DS_Store
/volume1/screenpipe/#recycle/Copy #2 of db.sqlite
/volume1/screenpipe/#recycle/archive.db
/volume1/screenpipe/#recycle/Copy #1 of archive.db
/volume1/screenpipe/#recycle/Copy #2 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of archive.db
/volume1/screenpipe/#recycle/Copy #4 of archive.db
/volume1/screenpipe/#recycle/Copy #5 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of db.sqlite
/volume1/screenpipe/#recycle/Copy #4 of db.sqlite
/volume1/screenpipe/#recycle/Copy #6 of archive.db
/volume1/screenpipe/#recycle/test.txt
/volume1/screenpipe/#recycle/Copy #7 of archive.db
/volume1/screenpipe/#recycle/Copy #8 of archive.db
/volume1/screenpipe/#recycle/archive.db-journal
/volume1/screenpipe/#recycle/Copy #1 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #2 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #3 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #4 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #6 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #7 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of db.sqlite
/volume1/screenpipe/pipes/.DS_Store
/volume1/screenpipe/app/.env
/volume1/screenpipe/app/cli.py
/volume1/screenpipe/app/.DS_Store
/volume1/screenpipe/app/db.py
/volume1/screenpipe/app/docker-compose.yml
/volume1/screenpipe/app/main.py
/volume1/screenpipe/app/requirements.txt
/volume1/screenpipe/app/Dockerfile
/volume1/screenpipe/data/.DS_Store
/volume1/screenpipe/.git/description
/volume1/screenpipe/.git/HEAD
/volume1/screenpipe/.git/index
/volume1/screenpipe/.git/COMMIT_EDITMSG
/volume1/screenpipe/#recycle/data/.DS_Store
---
app
app_settings.json
archive.db
data
db.sqlite
db.sqlite-shm
db.sqlite-wal
pipes
#recycle
screenpipe.db
screenpipe_sync.sh
Read
main.py
main.py
Bash
Check pipes directory and docker-compose
IN
ls /volume1/screenpipe/pipes/ && ls /volume1/screenpipe/app/ && cat /volume1/screenpipe/app/docker-compose.yml
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
cli.py
consumers
db.py
docker-compose.yml
Dockerfile
main.py
__pycache__
requirements.txt
static
services:
screenpipe-app:
build: .
container_name: screenpipe-app
restart: unless-stopped
ports:
- "8766:8000"
volumes:
- /volume1/screenpipe:/data
env_file:
- .env
environment:
TZ: Europe/Sofia
DB_PATH: /data/db.sqlite
sqlite-web-archive:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-archive
restart: unless-stopped
ports:
- "8767:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/archive.db"]
sqlite-web-live:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-live
restart: unless-stopped
ports:
- "8768:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/db.sqlite"]
Read
requirements.txt
requirements.txt
Bash
Inspect a pipe directory
IN
ls /volume1/screenpipe/pipes/day-recap/ && cat /volume1/screenpipe/pipes/day-recap/pipe.json 2>/dev/null || ls /volume1/screenpipe/pipes/day-recap/
Copy code to clipboard
OUT
pipe.md
pipe.md
Read
cli.py
cli.py
Bash
List all pipes and their contents
IN
ls /volume1/screenpipe/pipes/ && for d in /volume1/screenpipe/pipes/*/; do echo "=== $d ==="; ls "$d"; done
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
=== /volume1/screenpipe/pipes/ai-habits/ ===
pipe.md
=== /volume1/screenpipe/pipes/day-recap/ ===
pipe.md
=== /volume1/screenpipe/pipes/meeting-summary/ ===
pipe.md
=== /volume1/screenpipe/pipes/standup-update/ ===
pipe.md
=== /volume1/screenpipe/pipes/time-breakdown/ ===
pipe.md
=== /volume1/screenpipe/pipes/video-export/ ===
pipe.md
Bash
Read pipe markdown files
IN
cat /volume1/screenpipe/pipes/day-recap/pipe.md && echo "===" && cat /volume1/screenpipe/pipes/meeting-summary/pipe.md 2>/dev/null | head -50
Copy code to clipboard
OUT
---
schedule: manual
enabled: true
template: true
title: Day Recap
description: "Today's accomplishments, key moments, and unfinished work"
icon: "📋"
featured: true
---
Analyze my screen and audio recordings from today (last 16 hours only).
Read screenpipe skill first.
Use this exact format:
## Summary
One sentence: what I mainly did today.
## Accomplishments
- Top 3 things I finished, with timestamps (e.g. "2:30 PM")
- Name specific apps, files, or projects
## Key Moments
- Important things I saw, said, or heard — with timestamps
## Unfinished Work
- What I should continue tomorrow — name the app/file/task
## Patterns
- Apps I used most, topics that came up repeatedly
Only report what you can verify from the data. End with: "**Next step:** [most important thing to continue]"
===
---
schedule: manual
enabled: true
template: true
title: Meeting Summary
description: "Summarize meeting transcript with key takeaways and action items"
icon: "🤝"
featured: false
---
Summarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.
Read screenpipe skill first.
Use this exact format:
## Meeting Summary
One sentence: what this meeting was about.
## Key Takeaways
- Top 3-5 important points discussed
- Include who said what when relevant
## Action Items
- [ ] Task — assigned to whom, deadline if mentioned
- [ ] Task — assigned to whom
## Decisions Made
- List any decisions or agreements reached
## Open Questions
- Anything unresolved or needing follow-up
Keep it concise and actionable.
Thinking
Thinking
Bash
Read summary consumer
IN
ls /volume1/screenpipe/app/consumers/ && cat /volume1/screenpipe/app/consumers/summary.py
Copy code to clipboard
OUT
activity.py
audio.py
elements.py
__init__.py
interactions.py
ocr.py
__pycache__
report.py
summary.py
"""AI summary generator using Claude."""
import os
from datetime import date
from typing import Any
from consumers.activity import app_time, summary_stats, browser_urls, ui_event_summary
from consumers.ocr import deduplicated_text
from consumers.audio import formatted_transcript
SUMMARY_TYPES = {
"day_recap": {
"title": "Day Recap",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
## Audio/speech:
{audio}
Write a concise day recap using EXACTLY this format:
## Summary
One sentence: what I mainly worked on today.
## Accomplishments
- Top 3 things I finished, with approximate times
- Name specific apps, files, or projects
## Key Moments
- Important things seen or heard, with timestamps
## Unfinished Work
- What to continue tomorrow
## Patterns
- Apps used most, topics that came up repeatedly
Only report what you can verify from the data. End with:
**Next step:** [most important thing to continue]""",
},
"standup": {
"title": "Standup Update",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
## Audio/speech:
{audio}
Write a brief standup update:
**Yesterday:** What I worked on (2-3 bullets)
**Today:** What I plan to continue (1-2 bullets)
**Blockers:** Any issues observed (or "None")
Keep it under 150 words. Only report what's verifiable from the data.""",
},
"focus_time": {
"title": "Focus & Distraction Analysis",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
Analyze focus vs distraction patterns:
## Deep Work Periods
- When and how long were sustained focus sessions?
- What was being worked on?
## Distractions
- Which apps/sites were used recreationally?
- How much time was lost to context switching?
## Recommendations
- 2-3 concrete suggestions to improve focus tomorrow
Be specific with times and app names.""",
},
}
def _build_context(for_date: date) -> dict[str, str]:
apps = app_time(for_date)
app_lines = "\n".join(f"- {a['app_name']}: {a['minutes']} min" for a in apps[:20])
urls = browser_urls(for_date, limit=20)
url_lines = "\n".join(
f"- {u['browser_url'][:100]} ({u['minutes']} min)" for u in urls
)
ui_rows = ui_event_summary(for_date)
ui_lines = "\n".join(
f"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches"
for r in ui_rows[:15]
)
ocr_rows = deduplicated_text(for_date, chunk_minutes=5)
ocr_lines = "\n".join(
f"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}"
for r in ocr_rows[:100]
)
audio = formatted_transcript(for_date)
return {
"app_time": app_lines or "(no app data)",
"browser_urls": url_lines or "(no browser data)",
"ui_events": ui_lines or "(no UI event data)",
"ocr_text": ocr_lines or "(no screen data)",
"audio": audio[:3000] if len(audio) > 3000 else audio,
}
def generate(
summary_type: str = "day_recap",
for_date: date | None = None,
api_key: str | None = None,
) -> dict[str, Any]:
"""Generate an AI summary. Returns dict with 'title', 'content', 'date'."""
import anthropic
d = for_date or date.today()
key = api_key or os.environ.get("ANTHROPIC_API_KEY", "")
if not key:
return {
"title": "Error",
"content": "ANTHROPIC_API_KEY not set. Add it to your .env file.",
"date": str(d),
}
spec = SUMMARY_TYPES.get(summary_type)
if not spec:
return {"title": "Error", "content": f"Unknown summary type: {summary_type}", "date": str(d)}
stats = summary_stats(d)
if stats["total_frames"] == 0:
return {
"title": spec["title"],
"content": f"No screen data found for {d}.",
"date": str(d),
}
ctx = _build_context(d)
prompt = spec["prompt"].format(**ctx)
client = anthropic.Anthropic(api_key=key)
message = client.messages.create(
model="claude-haiku-4-5-20251001",
max_tokens=1024,
messages=[{"role": "user", "content": prompt}],
)
return {
"title": spec["title"],
"content": message.content[0].text,
"date": str(d),
"stats": stats,
}
Thinking
Thinking
Bash
Read all pipe.md files
IN
for f in /volume1/screenpipe/pipes/*/pipe.md; do echo "=== $f ==="; cat "$f"; echo; done
Copy code to clipboard
OUT
=== /volume1/screenpipe/pipes/ai-habits/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: AI Habits
description: "How you use AI tools — patterns and insights"
icon: "🤖"
featured: true
---
Search my recordings from the last 24 hours for AI tool usage. Use app_name filter for each tool separately: ChatGPT, Claude, Copilot, Cursor, Gemini, Perplexity. Use limit=5 per search, max 6 searches total.
Read screenpipe skill first.
Use this exact format:
## AI Tools Used
- List each tool with approximate time spent (e.g. "Claude: ~45min")
## What I Used Them For
- For each tool: coding, writing, research, or brainstorming
## Usage Patterns
- Do I switch between tools? Use them in bursts or steadily?
## Effectiveness
- Which tool appeared alongside completed work vs. abandoned attempts
If no AI usage is found, say so clearly. End with: "**Tip:** [one suggestion to use AI tools more effectively]"
=== /volume1/screenpipe/pipes/day-recap/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Day Recap
description: "Today's accomplishments, key moments, and unfinished work"
icon: "📋"
featured: true
---
Analyze my screen and audio recordings from today (last 16 hours only).
Read screenpipe skill first.
Use this exact format:
## Summary
One sentence: what I mainly did today.
## Accomplishments
- Top 3 things I finished, with timestamps (e.g. "2:30 PM")
- Name specific apps, files, or projects
## Key Moments
- Important things I saw, said, or heard — with timestamps
## Unfinished Work
- What I should continue tomorrow — name the app/file/task
## Patterns
- Apps I used most, topics that came up repeatedly
Only report what you can verify from the data. End with: "**Next step:** [most important thing to continue]"
=== /volume1/screenpipe/pipes/meeting-summary/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Meeting Summary
description: "Summarize meeting transcript with key takeaways and action items"
icon: "🤝"
featured: false
---
Summarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.
Read screenpipe skill first.
Use this exact format:
## Meeting Summary
One sentence: what this meeting was about.
## Key Takeaways
- Top 3-5 important points discussed
- Include who said what when relevant
## Action Items
- [ ] Task — assigned to whom, deadline if mentioned
- [ ] Task — assigned to whom
## Decisions Made
- List any decisions or agreements reached
## Open Questions
- Anything unresolved or needing follow-up
Keep it concise and actionable.
=== /volume1/screenpipe/pipes/standup-update/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Standup Update
description: "What you did, what's next, and any blockers"
icon: "🏢"
featured: true
---
Based on my recordings from the last 24 hours, generate a standup update. Use limit=10 per search, max 3 searches total.
Read screenpipe skill first.
Use this exact format:
## Yesterday
- What I worked on (name specific projects, files, tools, PRs)
## Today
- What I will work on next (based on unfinished tasks and recent activity)
## Blockers
- Issues I hit — errors, slow builds, waiting on someone
- If no blockers, write "None"
Keep it under 150 words. Copy-paste ready for a team standup.
=== /volume1/screenpipe/pipes/time-breakdown/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Time Breakdown
description: "Where your time went — by app, project, and category"
icon: "⏱"
featured: false
---
Analyze my app usage from today (last 12 hours). Use limit=10 per search, max 4 searches. Prefer /raw_sql with COUNT/GROUP BY queries.
Read screenpipe skill first.
Use this exact format with durations and percentages:
## By Application
- List each app with duration and percentage, sorted by time (e.g. "VS Code: 2h 15min (28%)")
## By Category
- Group into: coding, meetings, browsing, writing, communication, other
- Show hours and percentage per category
## By Project
- Group related activities by project/topic. Name specific repos or tasks.
## Productivity Score
- Calculate: focused_work_hours / total_hours as a percentage
- Focused = coding + writing. Unfocused = browsing + switching.
End with: "**Suggestion:** [one specific change to improve tomorrow's productivity]"
=== /volume1/screenpipe/pipes/video-export/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Export Video Clip
description: "Create a video of your recent screen activity"
icon: "🎬"
featured: false
---
Export a video of my screen activity from the last 5 minutes.
Read screenpipe skill first.
Use the POST /frames/export endpoint with the time range and fps=1.0. Then show me the exported video file path as an inline code block so I can watch it.
If the export is large, suggest a lower fps or shorter time range....
|
NULL
|
NULL
|
NULL
|
NULL
|
|
21099
|
923
|
9
|
2026-05-11T17:12:09.637481+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-11/1778 /Users/lukas/.screenpipe/data/data/2026-05-11/1778519529637_m2.jpg...
|
Code
|
screenpipe_sync.sh — screenpipe [SSH: nas]
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧ Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py
M
db.py
docker-compose.yml
Dockerfile
M
main.py
M
requirements.txt
M
data
logs
pipes
.gitignore
app_settings.json
archive.db
archive.db-bak
U
db.sqlite
db.sqlite-shm
db.sqlite-wal
screenpipe_sync_updated.sh
U
screenpipe_sync.sh
screenpipe.db
Outline Section
OUTLINE
OUTLINE
Timeline Section
TIMELINE
TIMELINE
app_settings.json, Editor Group 1
screenpipe_sync.sh, Editor Group 1
pipe.md, Editor Group 1
.env, Editor Group 1
#!/bin/bash
# screenpipe_sync.sh
# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).
# Also copies the day's video/frame data folder to the NAS.
#
# Usage:
# ./screenpipe_sync.sh # syncs yesterday (default)
# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date
# ./screenpipe_sync.sh today # syncs today so far
#
# Cron example (runs at 3am daily):
# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1
set -euo pipefail
# ─── CONFIG ───────────────────────────────────────────────────────────────────
DB_SRC="${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}"
NAS_MOUNT="${NAS_MOUNT:-/Volumes/Test/screenpipe}"
NAS_DB="$NAS_MOUNT/archive.db"
NAS_DATA="$NAS_MOUNT/data"
LOG_FILE="$HOME/.screenpipe/sync.log"
# ──────────────────────────────────────────────────────────────────────────────
# ─── HELPERS ──────────────────────────────────────────────────────────────────
SCRIPT_START=$(date +%s)
log() {
local msg="[$(date '+%Y-%m-%d %H:%M:%S')] $*"
echo "$msg" | tee -a "$LOG_FILE"
}
step() {
local now=$(date +%s)
local elapsed=$(( now - SCRIPT_START ))
local min=$(( elapsed / 60 ))
local sec=$(( elapsed % 60 ))
printf "\n[+%02dm%02ds] ▶ %s\n" "$min" "$sec" "$*" | tee -a "$LOG_FILE"
}
run_sqlite_heredoc() {
local label="$1"
local sql="$2"
local start=$(date +%s)
printf " %-36s " "$label"
sqlite3 "$DB_SRC" <<< "$sql" &
local pid=$!
local spin=[PASSWORD] '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')
local i=0
while kill -0 "$pid" 2>/dev/null; do
printf "\r %-36s %s " "$label" "${spin[$i]}"
i=$(( (i + 1) % 10 ))
sleep 0.2
done
wait "$pid"
local rc=$?
if [ $rc -ne 0 ]; then
printf "\r %-36s ✗ FAILED\n" "$label" | tee -a "$LOG_FILE"
exit $rc
fi
local dur=$(( $(date +%s) - start ))
printf "\r %-36s ✓ %dm%02ds\n" "$label" "$(( dur / 60 ))" "$(( dur % 60 ))" | tee -a "$LOG_FILE"
}
check() {
local label="$1" got="$2" expected="$3"
if [ "$got" -eq "$expected" ]; then
printf " %-20s %s / %s ✓\n" "$label:" "$got" "$expected"
else
printf " %-20s %s / %s ✗ MISMATCH\n" "$label:" "$got" "$expected"
fi
}
# ──────────────────────────────────────────────────────────────────────────────
# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────
if [ "${1:-}" = "today" ]; then
TARGET_DATE=$(date +%Y-%m-%d)
elif [ -n "${1:-}" ]; then
TARGET_DATE="$1"
if ! [[ "$TARGET_DATE" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then
echo "ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday."
exit 1
fi
else
TARGET_DATE=$(date -v-1d +%Y-%m-%d)
fi
log "========================================"
log "Screenpipe sync starting for: $TARGET_DATE"
log "========================================"
# ─── PREFLIGHT ────────────────────────────────────────────────────────────────
step "Preflight checks"
if [ ! -f "$DB_SRC" ]; then
log "ERROR: Source DB not found at $DB_SRC"; exit 1
fi
printf " %-20s %s (%s)\n" "Source DB:" "OK" "$(du -sh "$DB_SRC" | cut -f1)"
if [ ! -d "$NAS_MOUNT" ]; then
log "ERROR: NAS not mounted at $NAS_MOUNT"; exit 1
fi
printf " %-20s %s\n" "NAS mount:" "OK $NAS_MOUNT"
# Check if DB already synced for this date
DB_ALREADY_SYNCED=false
if [ -f "$NAS_DB" ]; then
EXISTING=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';" 2>/dev/null || echo "0")
if [ "$EXISTING" -gt "0" ]; then
log "Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync"
DB_ALREADY_SYNCED=true
else
printf " %-20s %s (%s)\n" "Archive DB:" "exists" "$(du -sh "$NAS_DB" | cut -f1)"
fi
else
printf " %-20s %s\n" "Archive DB:" "will be created"
fi
# Source data dir for this date
DATA_SRC="$HOME/.screenpipe/data/data/$TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
DATA_SIZE=$(du -sh "$DATA_SRC" | cut -f1)
DATA_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
printf " %-20s %s (%s files, %s)\n" "Data dir:" "OK" "$DATA_FILES" "$DATA_SIZE"
else
printf " %-20s %s\n" "Data dir:" "not found — skipping file copy"
fi
# ─── DB SYNC ──────────────────────────────────────────────────────────────────
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────
step "Counting source rows for $TARGET_DATE"
SRC_FRAMES=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
SRC_ELEMENTS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_UI=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
SRC_OCR=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_MEETINGS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';")
printf " %-20s %s\n" "frames:" "$SRC_FRAMES"
printf " %-20s %s\n" "elements:" "$SRC_ELEMENTS"
printf " %-20s %s\n" "ui_events:" "$SRC_UI"
printf " %-20s %s\n" "ocr_text:" "$SRC_OCR"
printf " %-20s %s\n" "meetings:" "$SRC_MEETINGS"
if [ "$SRC_FRAMES" -eq "0" ]; then
log "No frames found for $TARGET_DATE — skipping DB sync"
DB_ALREADY_SYNCED=true
fi
fi
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── INIT TABLES ──────────────────────────────────────────────────────────
step "Initialising tables, indexes, FTS"
run_sqlite_heredoc "creating tables" "
ATTACH '$NAS_DB' AS nas;
CREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;
CREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;
CREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;
CREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;
DETACH nas;
"
run_sqlite_heredoc "creating indexes" "
ATTACH '$NAS_DB' AS nas;
CREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);
CREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);
DETACH nas;
"
run_sqlite_heredoc "creating FTS tables" "
ATTACH '$NAS_DB' AS nas;
CREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(
text, role, frame_id UNINDEXED,
content='elements', content_rowid='id', tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(
full_text, app_name, window_name, browser_url, id UNINDEXED,
tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(
text_content,
app_name,
window_title,
element_name,
content='ui_events',
content_rowid='id',
tokenize='unicode61'
);
DETACH nas;
"
# ─── SYNC DATA ────────────────────────────────────────────────────────────
step "Syncing data for $TARGET_DATE"
run_sqlite_heredoc "video_chunks" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.video_chunks
SELECT * FROM main.video_chunks
WHERE id IN (
SELECT DISTINCT video_chunk_id FROM main.frames
WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL
);
DETACH nas;
"
run_sqlite_heredoc "frames ($SRC_FRAMES rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.frames
SELECT * FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ocr_text ($SRC_OCR rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ocr_text
SELECT o.* FROM main.ocr_text o
JOIN main.frames f ON o.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ui_events ($SRC_UI rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ui_events
SELECT * FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "elements ($SRC_ELEMENTS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.elements
SELECT e.* FROM main.elements e
JOIN main.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "meetings ($SRC_MEETINGS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.meetings
SELECT * FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';
DETACH nas;
"
# ─── FTS UPDATE ───────────────────────────────────────────────────────────
step "Updating FTS indexes"
run_sqlite_heredoc "elements_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.elements_fts(rowid, text, role)
SELECT e.id, e.text, e.role
FROM nas.elements e
JOIN nas.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE'
AND e.text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "frames_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)
SELECT id, full_text, app_name, window_name, browser_url, id
FROM nas.frames
WHERE date(timestamp) = '$TARGET_DATE'
AND full_text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "ui_events_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)
SELECT id, text_content, app_name, window_title, element_name
FROM nas.ui_events
WHERE date(timestamp) = '$TARGET_DATE'
AND text_content IS NOT NULL;
DETACH nas;
"
# ─── VERIFY DB ────────────────────────────────────────────────────────────
step "Verifying DB"
V_FRAMES=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
V_ELEMENTS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_UI=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
V_OCR=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_MEETINGS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';")
check "frames" "$V_FRAMES" "$SRC_FRAMES"
check "elements" "$V_ELEMENTS" "$SRC_ELEMENTS"
check "ui_events" "$V_UI" "$SRC_UI"
check "ocr_text" "$V_OCR" "$SRC_OCR"
check "meetings" "$V_MEETINGS" "$SRC_MEETINGS"
fi
# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────
# Always runs regardless of DB sync status
step "Copying data folder for $TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
mkdir -p "$NAS_DATA/$TARGET_DATE"
RSYNC_START=$(date +%s)
printf " %-36s " "rsync $TARGET_DATE/ → NAS"
rsync -a --ignore-existing \
"$DATA_SRC/" \
"$NAS_DATA/$TARGET_DATE/" \
2>>"$LOG_FILE"
RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))
COPIED_FILES=$(ls "$NAS_DATA/$TARGET_DATE" | wc -l | tr -d ' ')
SRC_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
COPIED_SIZE=$(du -sh "$NAS_DATA/$TARGET_DATE" | cut -f1)
if [ "$COPIED_FILES" -eq "$SRC_FILES" ]; then
printf "\r %-36s ✓ %dm%02ds (%s files, %s)\n" \
"rsync $TARGET_DATE/ → NAS" \
"$(( RSYNC_DUR / 60 ))" "$(( RSYNC_DUR % 60 ))" \
"$COPIED_FILES" "$COPIED_SIZE" | tee -a "$LOG_FILE"
else
printf "\r %-36s ✗ %s / %s files\n" \
"rsync $TARGET_DATE/ → NAS" "$COPIED_FILES" "$SRC_FILES" | tee -a "$LOG_FILE"
fi
else
printf " %-36s %s\n" "rsync $TARGET_DATE/ → NAS" "skipped (no source dir)"
fi
# ─── SUMMARY ──────────────────────────────────────────────────────────────────
TOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))
DB_SIZE=$(du -sh "$NAS_DB" | cut -f1)
echo ""
log "Archive DB size: $DB_SIZE"
log "Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s"
log "Sync complete for $TARGET_DATE"
log "========================================"
#!/bin/bash
# screenpipe_sync.sh
# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).
# Also copies the day's video/frame data folder to the NAS.
#
# Usage:
# ./screenpipe_sync.sh # syncs yesterday (default)
# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date
# ./screenpipe_sync.sh today # syncs today so far
#
# Cron example (runs at 3am daily):
# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1
set -euo pipefail
# ─── CONFIG ───────────────────────────────────────────────────────────────────
DB_SRC="${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}"
NAS_MOUNT="${NAS_MOUNT:-/Volumes/Test/screenpipe}"
NAS_DB="$NAS_MOUNT/archive.db"
NAS_DATA="$NAS_MOUNT/data"
LOG_FILE="$HOME/.screenpipe/sync.log"
# ──────────────────────────────────────────────────────────────────────────────
# ─── HELPERS ──────────────────────────────────────────────────────────────────
SCRIPT_START=$(date +%s)
log() {
local msg="[$(date '+%Y-%m-%d %H:%M:%S')] $*"
echo "$msg" | tee -a "$LOG_FILE"
}
step() {
local now=$(date +%s)
local elapsed=$(( now - SCRIPT_START ))
local min=$(( elapsed / 60 ))
local sec=$(( elapsed % 60 ))
printf "\n[+%02dm%02ds] ▶ %s\n" "$min" "$sec" "$*" | tee -a "$LOG_FILE"
}
run_sqlite_heredoc() {
local label="$1"
local sql="$2"
local start=$(date +%s)
printf " %-36s " "$label"
sqlite3 "$DB_SRC" <<< "$sql" &
local pid=$!
local spin=[PASSWORD] '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')
local i=0
while kill -0 "$pid" 2>/dev/null; do
printf "\r %-36s %s " "$label" "${spin[$i]}"
i=$(( (i + 1) % 10 ))
sleep 0.2
done
wait "$pid"
local rc=$?
if [ $rc -ne 0 ]; then
printf "\r %-36s ✗ FAILED\n" "$label" | tee -a "$LOG_FILE"
exit $rc
fi
local dur=$(( $(date +%s) - start ))
printf "\r %-36s ✓ %dm%02ds\n" "$label" "$(( dur / 60 ))" "$(( dur % 60 ))" | tee -a "$LOG_FILE"
}
check() {
local label="$1" got="$2" expected="$3"
if [ "$got" -eq "$expected" ]; then
printf " %-20s %s / %s ✓\n" "$label:" "$got" "$expected"
else
printf " %-20s %s / %s ✗ MISMATCH\n" "$label:" "$got" "$expected"
fi
}
# ──────────────────────────────────────────────────────────────────────────────
# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────
if [ "${1:-}" = "today" ]; then
TARGET_DATE=$(date +%Y-%m-%d)
elif [ -n "${1:-}" ]; then
TARGET_DATE="$1"
if ! [[ "$TARGET_DATE" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then
echo "ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday."
exit 1
fi
else
TARGET_DATE=$(date -v-1d +%Y-%m-%d)
fi
log "========================================"
log "Screenpipe sync starting for: $TARGET_DATE"
log "========================================"
# ─── PREFLIGHT ────────────────────────────────────────────────────────────────
step "Preflight checks"
if [ ! -f "$DB_SRC" ]; then
log "ERROR: Source DB not found at $DB_SRC"; exit 1
fi
printf " %-20s %s (%s)\n" "Source DB:" "OK" "$(du -sh "$DB_SRC" | cut -f1)"
if [ ! -d "$NAS_MOUNT" ]; then
log "ERROR: NAS not mounted at $NAS_MOUNT"; exit 1
fi
printf " %-20s %s\n" "NAS mount:" "OK $NAS_MOUNT"
# Check if DB already synced for this date
DB_ALREADY_SYNCED=false
if [ -f "$NAS_DB" ]; then
EXISTING=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';" 2>/dev/null || echo "0")
if [ "$EXISTING" -gt "0" ]; then
log "Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync"
DB_ALREADY_SYNCED=true
else
printf " %-20s %s (%s)\n" "Archive DB:" "exists" "$(du -sh "$NAS_DB" | cut -f1)"
fi
else
printf " %-20s %s\n" "Archive DB:" "will be created"
fi
# Source data dir for this date
DATA_SRC="$HOME/.screenpipe/data/data/$TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
DATA_SIZE=$(du -sh "$DATA_SRC" | cut -f1)
DATA_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
printf " %-20s %s (%s files, %s)\n" "Data dir:" "OK" "$DATA_FILES" "$DATA_SIZE"
else
printf " %-20s %s\n" "Data dir:" "not found — skipping file copy"
fi
# ─── DB SYNC ──────────────────────────────────────────────────────────────────
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────
step "Counting source rows for $TARGET_DATE"
SRC_FRAMES=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
SRC_ELEMENTS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_UI=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
SRC_OCR=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_MEETINGS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';")
printf " %-20s %s\n" "frames:" "$SRC_FRAMES"
printf " %-20s %s\n" "elements:" "$SRC_ELEMENTS"
printf " %-20s %s\n" "ui_events:" "$SRC_UI"
printf " %-20s %s\n" "ocr_text:" "$SRC_OCR"
printf " %-20s %s\n" "meetings:" "$SRC_MEETINGS"
if [ "$SRC_FRAMES" -eq "0" ]; then
log "No frames found for $TARGET_DATE — skipping DB sync"
DB_ALREADY_SYNCED=true
fi
fi
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── INIT TABLES ──────────────────────────────────────────────────────────
step "Initialising tables, indexes, FTS"
run_sqlite_heredoc "creating tables" "
ATTACH '$NAS_DB' AS nas;
CREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;
CREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;
CREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;
CREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;
DETACH nas;
"
run_sqlite_heredoc "creating indexes" "
ATTACH '$NAS_DB' AS nas;
CREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);
CREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);
DETACH nas;
"
run_sqlite_heredoc "creating FTS tables" "
ATTACH '$NAS_DB' AS nas;
CREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(
text, role, frame_id UNINDEXED,
content='elements', content_rowid='id', tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(
full_text, app_name, window_name, browser_url, id UNINDEXED,
tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(
text_content,
app_name,
window_title,
element_name,
content='ui_events',
content_rowid='id',
tokenize='unicode61'
);
DETACH nas;
"
# ─── SYNC DATA ────────────────────────────────────────────────────────────
step "Syncing data for $TARGET_DATE"
run_sqlite_heredoc "video_chunks" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.video_chunks
SELECT * FROM main.video_chunks
WHERE id IN (
SELECT DISTINCT video_chunk_id FROM main.frames
WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL
);
DETACH nas;
"
run_sqlite_heredoc "frames ($SRC_FRAMES rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.frames
SELECT * FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ocr_text ($SRC_OCR rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ocr_text
SELECT o.* FROM main.ocr_text o
JOIN main.frames f ON o.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ui_events ($SRC_UI rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ui_events
SELECT * FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "elements ($SRC_ELEMENTS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.elements
SELECT e.* FROM main.elements e
JOIN main.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "meetings ($SRC_MEETINGS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.meetings
SELECT * FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';
DETACH nas;
"
# ─── FTS UPDATE ───────────────────────────────────────────────────────────
step "Updating FTS indexes"
run_sqlite_heredoc "elements_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.elements_fts(rowid, text, role)
SELECT e.id, e.text, e.role
FROM nas.elements e
JOIN nas.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE'
AND e.text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "frames_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)
SELECT id, full_text, app_name, window_name, browser_url, id
FROM nas.frames
WHERE date(timestamp) = '$TARGET_DATE'
AND full_text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "ui_events_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)
SELECT id, text_content, app_name, window_title, element_name
FROM nas.ui_events
WHERE date(timestamp) = '$TARGET_DATE'
AND text_content IS NOT NULL;
DETACH nas;
"
# ─── VERIFY DB ────────────────────────────────────────────────────────────
step "Verifying DB"
V_FRAMES=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
V_ELEMENTS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_UI=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
V_OCR=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_MEETINGS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';")
check "frames" "$V_FRAMES" "$SRC_FRAMES"
check "elements" "$V_ELEMENTS" "$SRC_ELEMENTS"
check "ui_events" "$V_UI" "$SRC_UI"
check "ocr_text" "$V_OCR" "$SRC_OCR"
check "meetings" "$V_MEETINGS" "$SRC_MEETINGS"
fi
# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────
# Always runs regardless of DB sync status
step "Copying data folder for $TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
mkdir -p "$NAS_DATA/$TARGET_DATE"
RSYNC_START=$(date +%s)
printf " %-36s " "rsync $TARGET_DATE/ → NAS"
rsync -a --ignore-existing \
"$DATA_SRC/" \
"$NAS_DATA/$TARGET_DATE/" \
2>>"$LOG_FILE"
RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))
COPIED_FILES=$(ls "$NAS_DATA/$TARGET_DATE" | wc -l | tr -d ' ')
SRC_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
COPIED_SIZE=$(du -sh "$NAS_DATA/$TARGET_DATE" | cut -f1)
if [ "$COPIED_FILES" -eq "$SRC_FILES" ]; then
printf "\r %-36s ✓ %dm%02ds (%s files, %s)\n" \
"rsync $TARGET_DATE/ → NAS" \
"$(( RSYNC_DUR / 60 ))" "$(( RSYNC_DUR % 60 ))" \
"$COPIED_FILES" "$COPIED_SIZE" | tee -a "$LOG_FILE"
else
printf "\r %-36s ✗ %s / %s files\n" \
"rsync $TARGET_DATE/ → NAS" "$COPIED_FILES" "$SRC_FILES" | tee -a "$LOG_FILE"
fi
else
printf " %-36s %s\n" "rsync $TARGET_DATE/ → NAS" "skipped (no source dir)"
fi
# ─── SUMMARY ──────────────────────────────────────────────────────────────────
TOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))
DB_SIZE=$(du -sh "$NAS_DB" | cut -f1)
echo ""
log "Archive DB size: $DB_SIZE"
log "Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s"
log "Sync complete for $TARGET_DATE"
log "========================================"
Implement and run pipe l…, Editor Group 2
Problems (⇧⌘M)
PROBLEMS
Output (⇧⌘U)
OUTPUT
Debug Console (⇧⌘Y)
DEBUG CONSOLE
Terminal (⌃`)
TERMINAL
Ports - 1 forwarded port
PORTS
1
remote SSH: nas
SSH: nas
screenpipe (Git) - master*, Checkout Branch/Tag...
master*
screenpipe (Git) - Synchronize Changes
No Problems
0
0
Forwarded Ports: 8766
1
Notifications
Sign In
Sign In
Shell Script
Editor Language Status: $(copilot) No inline suggestion available, Inline suggestions
LF
UTF-8
Spaces: 2
Ln 352, Col 47 (13096 selected)
git-commit Lukas Kovalik (2 weeks ago)
Lukas Kovalik (2 weeks ago)
Info: Setting up SSH Host nas: Setting up SSH tunnel...
|
[{"role":"AXRadioButton","text [{"role":"AXRadioButton","text":"Explorer (⇧⌘E)","depth":19,"bounds":{"left":0.0,"top":0.047885075,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":true},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.057462092,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Search (⇧⌘F)","depth":19,"bounds":{"left":0.0,"top":0.08619314,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.09577015,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Source Control (⌃⇧G) - 10 pending changes","depth":19,"bounds":{"left":0.0,"top":0.1245012,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.13407822,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"10","depth":22,"bounds":{"left":0.00831117,"top":0.1452514,"width":0.003656915,"height":0.008778931},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.00831117,"top":0.14604948,"width":0.0016622341,"height":0.007980846}},{"char_start":1,"char_count":1,"bounds":{"left":0.009973404,"top":0.14604948,"width":0.0023271276,"height":0.007980846}}],"role_description":"text"},{"role":"AXRadioButton","text":"Run and Debug (⇧⌘D)","depth":19,"bounds":{"left":0.0,"top":0.16280925,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.17238627,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Remote Explorer","depth":19,"bounds":{"left":0.0,"top":0.20111732,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.21069433,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Extensions (⇧⌘X) - 2 require update","depth":19,"bounds":{"left":0.0,"top":0.23942538,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.2490024,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"2","depth":22,"bounds":{"left":0.009640957,"top":0.2601756,"width":0.0019946808,"height":0.008778931},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Claude Code","depth":19,"bounds":{"left":0.0,"top":0.27773345,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"Containers","depth":19,"bounds":{"left":0.0,"top":0.3160415,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXHeading","text":"EXPLORER","depth":17,"bounds":{"left":0.022606382,"top":0.047885075,"width":0.018949468,"height":0.02793296},"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"EXPLORER","depth":18,"bounds":{"left":0.022606382,"top":0.056664005,"width":0.018949468,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.022606382,"top":0.056664005,"width":0.0023271276,"height":0.0103751}},{"char_start":1,"char_count":7,"bounds":{"left":0.024933511,"top":0.056664005,"width":0.01662234,"height":0.0103751}}],"role_description":"text"},{"role":"AXButton","text":"Explorer Section: screenpipe [SSH: nas]","depth":21,"bounds":{"left":0.015957447,"top":0.07581804,"width":0.09940159,"height":0.017557861},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":true},{"role":"AXStaticText","text":"","depth":23,"bounds":{"left":0.01662234,"top":0.07821229,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"Explorer Section: screenpipe [SSH: nas]","depth":22,"bounds":{"left":0.022606382,"top":0.07581804,"width":0.045877658,"height":0.017557861},"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"SCREENPIPE [SSH: NAS]","depth":23,"bounds":{"left":0.022606382,"top":0.079010375,"width":0.045877658,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.022606382,"top":0.07980846,"width":0.0026595744,"height":0.0103751}},{"char_start":1,"char_count":20,"bounds":{"left":0.025265958,"top":0.07980846,"width":0.043218084,"height":0.0103751}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.09577015,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"#recycle","depth":27,"bounds":{"left":0.025930852,"top":0.09577015,"width":0.017287234,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.096568234,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":7,"bounds":{"left":0.028590426,"top":0.096568234,"width":0.01462766,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.11332801,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"app","depth":27,"bounds":{"left":0.025930852,"top":0.11332801,"width":0.0076462766,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.11412609,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":2,"bounds":{"left":0.02825798,"top":0.11412609,"width":0.005319149,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.11412609,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.022273935,"top":0.13088587,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"__pycache__","depth":27,"bounds":{"left":0.028590426,"top":0.13088587,"width":0.026595745,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.13168396,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":10,"bounds":{"left":0.030917553,"top":0.13168396,"width":0.024268618,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.022273935,"top":0.14844373,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"consumers","depth":27,"bounds":{"left":0.028590426,"top":0.14844373,"width":0.022273935,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.14924182,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":8,"bounds":{"left":0.030917553,"top":0.14924182,"width":0.019946808,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.14924182,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.022273935,"top":0.1660016,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"static","depth":27,"bounds":{"left":0.028590426,"top":0.1660016,"width":0.010970744,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.16679968,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":5,"bounds":{"left":0.030917553,"top":0.16679968,"width":0.008976064,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.16679968,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.1819633,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":".env","depth":27,"bounds":{"left":0.028590426,"top":0.18355946,"width":0.00831117,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.18435754,"width":0.0013297872,"height":0.011971269}},{"char_start":1,"char_count":3,"bounds":{"left":0.029920213,"top":0.18435754,"width":0.006981383,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.19952115,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"cli.py","depth":27,"bounds":{"left":0.028590426,"top":0.20111732,"width":0.010638298,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.2019154,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":5,"bounds":{"left":0.030917553,"top":0.2019154,"width":0.00831117,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.2019154,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.21707901,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.py","depth":27,"bounds":{"left":0.028590426,"top":0.21867518,"width":0.011303191,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.21947326,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":4,"bounds":{"left":0.03125,"top":0.21947326,"width":0.008643617,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.23463687,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"docker-compose.yml","depth":27,"bounds":{"left":0.028590426,"top":0.23623304,"width":0.042220745,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.23703113,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":17,"bounds":{"left":0.03125,"top":0.23703113,"width":0.03956117,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.25219473,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Dockerfile","depth":27,"bounds":{"left":0.028590426,"top":0.25379092,"width":0.020611702,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.254589,"width":0.0033244682,"height":0.011971269}},{"char_start":1,"char_count":9,"bounds":{"left":0.031914894,"top":0.254589,"width":0.017287234,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.254589,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.2697526,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"main.py","depth":27,"bounds":{"left":0.028590426,"top":0.27134877,"width":0.015625,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.27214685,"width":0.003656915,"height":0.011971269}},{"char_start":1,"char_count":6,"bounds":{"left":0.032247342,"top":0.27214685,"width":0.012300532,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.27214685,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.28731045,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"requirements.txt","depth":27,"bounds":{"left":0.028590426,"top":0.28890663,"width":0.032912236,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.2897047,"width":0.0016622341,"height":0.011971269}},{"char_start":1,"char_count":15,"bounds":{"left":0.03025266,"top":0.2897047,"width":0.03158245,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.2897047,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.3064645,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"data","depth":27,"bounds":{"left":0.025930852,"top":0.3064645,"width":0.008976064,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.30726257,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":3,"bounds":{"left":0.028590426,"top":0.30726257,"width":0.0063164895,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.32402235,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"logs","depth":27,"bounds":{"left":0.025930852,"top":0.32402235,"width":0.00831117,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.32482043,"width":0.0009973404,"height":0.011971269}},{"char_start":1,"char_count":3,"bounds":{"left":0.026928192,"top":0.32482043,"width":0.0076462766,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.32482043,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.3415802,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"pipes","depth":27,"bounds":{"left":0.025930852,"top":0.3415802,"width":0.010970744,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.3423783,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":4,"bounds":{"left":0.028590426,"top":0.3423783,"width":0.00831117,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.3575419,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":".gitignore","depth":27,"bounds":{"left":0.025930852,"top":0.35913807,"width":0.018949468,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.35993615,"width":0.0013297872,"height":0.011971269}},{"char_start":1,"char_count":9,"bounds":{"left":0.027260639,"top":0.35993615,"width":0.017952127,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.37509975,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"app_settings.json","depth":27,"bounds":{"left":0.025930852,"top":0.37669593,"width":0.03557181,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.377494,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":16,"bounds":{"left":0.02825798,"top":0.377494,"width":0.03324468,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.3926576,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"archive.db","depth":27,"bounds":{"left":0.025930852,"top":0.3942538,"width":0.020944148,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.39505187,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":9,"bounds":{"left":0.02825798,"top":0.39505187,"width":0.01861702,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.4102155,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"archive.db-bak","depth":27,"bounds":{"left":0.025930852,"top":0.41181165,"width":0.03025266,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.41260973,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":13,"bounds":{"left":0.02825798,"top":0.41260973,"width":0.027925532,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"U","depth":27,"bounds":{"left":0.10704787,"top":0.41260973,"width":0.0029920214,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.42777336,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite","depth":27,"bounds":{"left":0.025930852,"top":0.4293695,"width":0.017287234,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.4301676,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":8,"bounds":{"left":0.028590426,"top":0.4301676,"width":0.014960106,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.44533122,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite-shm","depth":27,"bounds":{"left":0.025930852,"top":0.44692737,"width":0.027925532,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.44772545,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":12,"bounds":{"left":0.028590426,"top":0.44772545,"width":0.025265958,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.46288908,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite-wal","depth":27,"bounds":{"left":0.025930852,"top":0.46448523,"width":0.025930852,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.46528333,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":12,"bounds":{"left":0.028590426,"top":0.46528333,"width":0.023603724,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.48044693,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe_sync_updated.sh","depth":27,"bounds":{"left":0.025930852,"top":0.4820431,"width":0.059175532,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.4828412,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":25,"bounds":{"left":0.02825798,"top":0.4828412,"width":0.056848403,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"U","depth":27,"bounds":{"left":0.10704787,"top":0.4828412,"width":0.0029920214,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.4980048,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe_sync.sh","depth":27,"bounds":{"left":0.025930852,"top":0.49960095,"width":0.039893616,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.50039905,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":17,"bounds":{"left":0.02825798,"top":0.50039905,"width":0.037898935,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.51556265,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe.db","depth":27,"bounds":{"left":0.025930852,"top":0.5171588,"width":0.028590426,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.5179569,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":12,"bounds":{"left":0.02825798,"top":0.5179569,"width":0.026595745,"height":0.011971269}}],"role_description":"text"},{"role":"AXButton","text":"Outline Section","depth":21,"bounds":{"left":0.015957447,"top":0.9473264,"width":0.09940159,"height":0.017557861},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":23,"bounds":{"left":0.01662234,"top":0.9497207,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"OUTLINE","depth":22,"bounds":{"left":0.022606382,"top":0.9473264,"width":0.01662234,"height":0.017557861},"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"OUTLINE","depth":23,"bounds":{"left":0.022606382,"top":0.95131683,"width":0.01662234,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.022606382,"top":0.95131683,"width":0.0029920214,"height":0.0103751}},{"char_start":1,"char_count":6,"bounds":{"left":0.025598405,"top":0.95131683,"width":0.013630319,"height":0.0103751}}],"role_description":"text"},{"role":"AXButton","text":"Timeline Section","depth":21,"bounds":{"left":0.015957447,"top":0.9648843,"width":0.09940159,"height":0.017557861},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":23,"bounds":{"left":0.01662234,"top":0.96727854,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"TIMELINE","depth":22,"bounds":{"left":0.022606382,"top":0.9648843,"width":0.01761968,"height":0.017557861},"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"TIMELINE","depth":23,"bounds":{"left":0.022606382,"top":0.9688747,"width":0.01761968,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.022606382,"top":0.9688747,"width":0.0026595744,"height":0.0103751}},{"char_start":1,"char_count":7,"bounds":{"left":0.025265958,"top":0.9688747,"width":0.015292553,"height":0.0103751}}],"role_description":"text"},{"role":"AXRadioButton","text":"app_settings.json, Editor Group 1","depth":28,"bounds":{"left":0.11569149,"top":0.047885075,"width":0.055851065,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"screenpipe_sync.sh, Editor Group 1","depth":28,"bounds":{"left":0.17154256,"top":0.047885075,"width":0.06050532,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":false},{"role":"AXRadioButton","text":"pipe.md, Editor Group 1","depth":28,"bounds":{"left":0.23171543,"top":0.047885075,"width":0.040226065,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":".env, Editor Group 1","depth":28,"bounds":{"left":0.27194148,"top":0.047885075,"width":0.039893616,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"#!/bin/bash\n# screenpipe_sync.sh\n# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).\n# Also copies the day's video/frame data folder to the NAS.\n#\n# Usage:\n# ./screenpipe_sync.sh # syncs yesterday (default)\n# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date\n# ./screenpipe_sync.sh today # syncs today so far\n#\n# Cron example (runs at 3am daily):\n# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1\n\nset -euo pipefail\n\n# ─── CONFIG ───────────────────────────────────────────────────────────────────\nDB_SRC=\"${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}\"\nNAS_MOUNT=\"${NAS_MOUNT:-/Volumes/Test/screenpipe}\"\nNAS_DB=\"$NAS_MOUNT/archive.db\"\nNAS_DATA=\"$NAS_MOUNT/data\"\nLOG_FILE=\"$HOME/.screenpipe/sync.log\"\n# ──────────────────────────────────────────────────────────────────────────────\n\n# ─── HELPERS ──────────────────────────────────────────────────────────────────\nSCRIPT_START=$(date +%s)\n\nlog() {\n local msg=\"[$(date '+%Y-%m-%d %H:%M:%S')] $*\"\n echo \"$msg\" | tee -a \"$LOG_FILE\"\n}\n\nstep() {\n local now=$(date +%s)\n local elapsed=$(( now - SCRIPT_START ))\n local min=$(( elapsed / 60 ))\n local sec=$(( elapsed % 60 ))\n printf \"\\n[+%02dm%02ds] ▶ %s\\n\" \"$min\" \"$sec\" \"$*\" | tee -a \"$LOG_FILE\"\n}\n\nrun_sqlite_heredoc() {\n local label=\"$1\"\n local sql=\"$2\"\n local start=$(date +%s)\n\n printf \" %-36s \" \"$label\"\n\n sqlite3 \"$DB_SRC\" <<< \"$sql\" &\n local pid=$!\n local spin=('⠋' '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')\n local i=0\n while kill -0 \"$pid\" 2>/dev/null; do\n printf \"\\r %-36s %s \" \"$label\" \"${spin[$i]}\"\n i=$(( (i + 1) % 10 ))\n sleep 0.2\n done\n wait \"$pid\"\n local rc=$?\n if [ $rc -ne 0 ]; then\n printf \"\\r %-36s ✗ FAILED\\n\" \"$label\" | tee -a \"$LOG_FILE\"\n exit $rc\n fi\n\n local dur=$(( $(date +%s) - start ))\n printf \"\\r %-36s ✓ %dm%02ds\\n\" \"$label\" \"$(( dur / 60 ))\" \"$(( dur % 60 ))\" | tee -a \"$LOG_FILE\"\n}\n\ncheck() {\n local label=\"$1\" got=\"$2\" expected=\"$3\"\n if [ \"$got\" -eq \"$expected\" ]; then\n printf \" %-20s %s / %s ✓\\n\" \"$label:\" \"$got\" \"$expected\"\n else\n printf \" %-20s %s / %s ✗ MISMATCH\\n\" \"$label:\" \"$got\" \"$expected\"\n fi\n}\n# ──────────────────────────────────────────────────────────────────────────────\n\n# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────\nif [ \"${1:-}\" = \"today\" ]; then\n TARGET_DATE=$(date +%Y-%m-%d)\nelif [ -n \"${1:-}\" ]; then\n TARGET_DATE=\"$1\"\n if ! [[ \"$TARGET_DATE\" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then\n echo \"ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday.\"\n exit 1\n fi\nelse\n TARGET_DATE=$(date -v-1d +%Y-%m-%d)\nfi\n\nlog \"========================================\"\nlog \"Screenpipe sync starting for: $TARGET_DATE\"\nlog \"========================================\"\n\n# ─── PREFLIGHT ────────────────────────────────────────────────────────────────\nstep \"Preflight checks\"\n\nif [ ! -f \"$DB_SRC\" ]; then\n log \"ERROR: Source DB not found at $DB_SRC\"; exit 1\nfi\nprintf \" %-20s %s (%s)\\n\" \"Source DB:\" \"OK\" \"$(du -sh \"$DB_SRC\" | cut -f1)\"\n\nif [ ! -d \"$NAS_MOUNT\" ]; then\n log \"ERROR: NAS not mounted at $NAS_MOUNT\"; exit 1\nfi\nprintf \" %-20s %s\\n\" \"NAS mount:\" \"OK $NAS_MOUNT\"\n\n# Check if DB already synced for this date\nDB_ALREADY_SYNCED=false\nif [ -f \"$NAS_DB\" ]; then\n EXISTING=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\" 2>/dev/null || echo \"0\")\n if [ \"$EXISTING\" -gt \"0\" ]; then\n log \"Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync\"\n DB_ALREADY_SYNCED=true\n else\n printf \" %-20s %s (%s)\\n\" \"Archive DB:\" \"exists\" \"$(du -sh \"$NAS_DB\" | cut -f1)\"\n fi\nelse\n printf \" %-20s %s\\n\" \"Archive DB:\" \"will be created\"\nfi\n\n# Source data dir for this date\nDATA_SRC=\"$HOME/.screenpipe/data/data/$TARGET_DATE\"\nif [ -d \"$DATA_SRC\" ]; then\n DATA_SIZE=$(du -sh \"$DATA_SRC\" | cut -f1)\n DATA_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n printf \" %-20s %s (%s files, %s)\\n\" \"Data dir:\" \"OK\" \"$DATA_FILES\" \"$DATA_SIZE\"\nelse\n printf \" %-20s %s\\n\" \"Data dir:\" \"not found — skipping file copy\"\nfi\n\n# ─── DB SYNC ──────────────────────────────────────────────────────────────────\nif [ \"$DB_ALREADY_SYNCED\" = false ]; then\n\n # ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────\n step \"Counting source rows for $TARGET_DATE\"\n\n SRC_FRAMES=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\")\n SRC_ELEMENTS=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n SRC_UI=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';\")\n SRC_OCR=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n SRC_MEETINGS=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';\")\n\n printf \" %-20s %s\\n\" \"frames:\" \"$SRC_FRAMES\"\n printf \" %-20s %s\\n\" \"elements:\" \"$SRC_ELEMENTS\"\n printf \" %-20s %s\\n\" \"ui_events:\" \"$SRC_UI\"\n printf \" %-20s %s\\n\" \"ocr_text:\" \"$SRC_OCR\"\n printf \" %-20s %s\\n\" \"meetings:\" \"$SRC_MEETINGS\"\n\n if [ \"$SRC_FRAMES\" -eq \"0\" ]; then\n log \"No frames found for $TARGET_DATE — skipping DB sync\"\n DB_ALREADY_SYNCED=true\n fi\n\nfi\n\nif [ \"$DB_ALREADY_SYNCED\" = false ]; then\n\n # ─── INIT TABLES ──────────────────────────────────────────────────────────\n step \"Initialising tables, indexes, FTS\"\n\n run_sqlite_heredoc \"creating tables\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"creating indexes\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);\nCREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);\nCREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"creating FTS tables\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(\n text, role, frame_id UNINDEXED,\n content='elements', content_rowid='id', tokenize='unicode61'\n);\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(\n full_text, app_name, window_name, browser_url, id UNINDEXED,\n tokenize='unicode61'\n);\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(\n text_content,\n app_name,\n window_title,\n element_name,\n content='ui_events',\n content_rowid='id',\n tokenize='unicode61'\n);\nDETACH nas;\n\"\n\n # ─── SYNC DATA ────────────────────────────────────────────────────────────\n step \"Syncing data for $TARGET_DATE\"\n\n run_sqlite_heredoc \"video_chunks\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.video_chunks\n SELECT * FROM main.video_chunks\n WHERE id IN (\n SELECT DISTINCT video_chunk_id FROM main.frames\n WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL\n );\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames ($SRC_FRAMES rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.frames\n SELECT * FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ocr_text ($SRC_OCR rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ocr_text\n SELECT o.* FROM main.ocr_text o\n JOIN main.frames f ON o.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events ($SRC_UI rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ui_events\n SELECT * FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"elements ($SRC_ELEMENTS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.elements\n SELECT e.* FROM main.elements e\n JOIN main.frames f ON e.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"meetings ($SRC_MEETINGS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.meetings\n SELECT * FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n # ─── FTS UPDATE ───────────────────────────────────────────────────────────\n step \"Updating FTS indexes\"\n\n run_sqlite_heredoc \"elements_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.elements_fts(rowid, text, role)\n SELECT e.id, e.text, e.role\n FROM nas.elements e\n JOIN nas.frames f ON e.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE'\n AND e.text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)\n SELECT id, full_text, app_name, window_name, browser_url, id\n FROM nas.frames\n WHERE date(timestamp) = '$TARGET_DATE'\n AND full_text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)\n SELECT id, text_content, app_name, window_title, element_name\n FROM nas.ui_events\n WHERE date(timestamp) = '$TARGET_DATE'\n AND text_content IS NOT NULL;\nDETACH nas;\n\"\n\n # ─── VERIFY DB ────────────────────────────────────────────────────────────\n step \"Verifying DB\"\n\n V_FRAMES=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\")\n V_ELEMENTS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n V_UI=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';\")\n V_OCR=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n V_MEETINGS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';\")\n\n check \"frames\" \"$V_FRAMES\" \"$SRC_FRAMES\"\n check \"elements\" \"$V_ELEMENTS\" \"$SRC_ELEMENTS\"\n check \"ui_events\" \"$V_UI\" \"$SRC_UI\"\n check \"ocr_text\" \"$V_OCR\" \"$SRC_OCR\"\n check \"meetings\" \"$V_MEETINGS\" \"$SRC_MEETINGS\"\n\nfi\n\n# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────\n# Always runs regardless of DB sync status\nstep \"Copying data folder for $TARGET_DATE\"\n\nif [ -d \"$DATA_SRC\" ]; then\n mkdir -p \"$NAS_DATA/$TARGET_DATE\"\n RSYNC_START=$(date +%s)\n printf \" %-36s \" \"rsync $TARGET_DATE/ → NAS\"\n rsync -a --ignore-existing \\\n \"$DATA_SRC/\" \\\n \"$NAS_DATA/$TARGET_DATE/\" \\\n 2>>\"$LOG_FILE\"\n RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))\n COPIED_FILES=$(ls \"$NAS_DATA/$TARGET_DATE\" | wc -l | tr -d ' ')\n SRC_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n COPIED_SIZE=$(du -sh \"$NAS_DATA/$TARGET_DATE\" | cut -f1)\n if [ \"$COPIED_FILES\" -eq \"$SRC_FILES\" ]; then\n printf \"\\r %-36s ✓ %dm%02ds (%s files, %s)\\n\" \\\n \"rsync $TARGET_DATE/ → NAS\" \\\n \"$(( RSYNC_DUR / 60 ))\" \"$(( RSYNC_DUR % 60 ))\" \\\n \"$COPIED_FILES\" \"$COPIED_SIZE\" | tee -a \"$LOG_FILE\"\n else\n printf \"\\r %-36s ✗ %s / %s files\\n\" \\\n \"rsync $TARGET_DATE/ → NAS\" \"$COPIED_FILES\" \"$SRC_FILES\" | tee -a \"$LOG_FILE\"\n fi\nelse\n printf \" %-36s %s\\n\" \"rsync $TARGET_DATE/ → NAS\" \"skipped (no source dir)\"\nfi\n\n# ─── SUMMARY ──────────────────────────────────────────────────────────────────\nTOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))\nDB_SIZE=$(du -sh \"$NAS_DB\" | cut -f1)\n\necho \"\"\nlog \"Archive DB size: $DB_SIZE\"\nlog \"Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s\"\nlog \"Sync complete for $TARGET_DATE\"\nlog \"========================================\"","depth":28,"bounds":{"left":0.11569149,"top":0.0933759,"width":0.38031915,"height":0.0007980846},"on_screen":true,"value":"#!/bin/bash\n# screenpipe_sync.sh\n# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).\n# Also copies the day's video/frame data folder to the NAS.\n#\n# Usage:\n# ./screenpipe_sync.sh # syncs yesterday (default)\n# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date\n# ./screenpipe_sync.sh today # syncs today so far\n#\n# Cron example (runs at 3am daily):\n# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1\n\nset -euo pipefail\n\n# ─── CONFIG ───────────────────────────────────────────────────────────────────\nDB_SRC=\"${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}\"\nNAS_MOUNT=\"${NAS_MOUNT:-/Volumes/Test/screenpipe}\"\nNAS_DB=\"$NAS_MOUNT/archive.db\"\nNAS_DATA=\"$NAS_MOUNT/data\"\nLOG_FILE=\"$HOME/.screenpipe/sync.log\"\n# ──────────────────────────────────────────────────────────────────────────────\n\n# ─── HELPERS ──────────────────────────────────────────────────────────────────\nSCRIPT_START=$(date +%s)\n\nlog() {\n local msg=\"[$(date '+%Y-%m-%d %H:%M:%S')] $*\"\n echo \"$msg\" | tee -a \"$LOG_FILE\"\n}\n\nstep() {\n local now=$(date +%s)\n local elapsed=$(( now - SCRIPT_START ))\n local min=$(( elapsed / 60 ))\n local sec=$(( elapsed % 60 ))\n printf \"\\n[+%02dm%02ds] ▶ %s\\n\" \"$min\" \"$sec\" \"$*\" | tee -a \"$LOG_FILE\"\n}\n\nrun_sqlite_heredoc() {\n local label=\"$1\"\n local sql=\"$2\"\n local start=$(date +%s)\n\n printf \" %-36s \" \"$label\"\n\n sqlite3 \"$DB_SRC\" <<< \"$sql\" &\n local pid=$!\n local spin=('⠋' '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')\n local i=0\n while kill -0 \"$pid\" 2>/dev/null; do\n printf \"\\r %-36s %s \" \"$label\" \"${spin[$i]}\"\n i=$(( (i + 1) % 10 ))\n sleep 0.2\n done\n wait \"$pid\"\n local rc=$?\n if [ $rc -ne 0 ]; then\n printf \"\\r %-36s ✗ FAILED\\n\" \"$label\" | tee -a \"$LOG_FILE\"\n exit $rc\n fi\n\n local dur=$(( $(date +%s) - start ))\n printf \"\\r %-36s ✓ %dm%02ds\\n\" \"$label\" \"$(( dur / 60 ))\" \"$(( dur % 60 ))\" | tee -a \"$LOG_FILE\"\n}\n\ncheck() {\n local label=\"$1\" got=\"$2\" expected=\"$3\"\n if [ \"$got\" -eq \"$expected\" ]; then\n printf \" %-20s %s / %s ✓\\n\" \"$label:\" \"$got\" \"$expected\"\n else\n printf \" %-20s %s / %s ✗ MISMATCH\\n\" \"$label:\" \"$got\" \"$expected\"\n fi\n}\n# ──────────────────────────────────────────────────────────────────────────────\n\n# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────\nif [ \"${1:-}\" = \"today\" ]; then\n TARGET_DATE=$(date +%Y-%m-%d)\nelif [ -n \"${1:-}\" ]; then\n TARGET_DATE=\"$1\"\n if ! [[ \"$TARGET_DATE\" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then\n echo \"ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday.\"\n exit 1\n fi\nelse\n TARGET_DATE=$(date -v-1d +%Y-%m-%d)\nfi\n\nlog \"========================================\"\nlog \"Screenpipe sync starting for: $TARGET_DATE\"\nlog \"========================================\"\n\n# ─── PREFLIGHT ────────────────────────────────────────────────────────────────\nstep \"Preflight checks\"\n\nif [ ! -f \"$DB_SRC\" ]; then\n log \"ERROR: Source DB not found at $DB_SRC\"; exit 1\nfi\nprintf \" %-20s %s (%s)\\n\" \"Source DB:\" \"OK\" \"$(du -sh \"$DB_SRC\" | cut -f1)\"\n\nif [ ! -d \"$NAS_MOUNT\" ]; then\n log \"ERROR: NAS not mounted at $NAS_MOUNT\"; exit 1\nfi\nprintf \" %-20s %s\\n\" \"NAS mount:\" \"OK $NAS_MOUNT\"\n\n# Check if DB already synced for this date\nDB_ALREADY_SYNCED=false\nif [ -f \"$NAS_DB\" ]; then\n EXISTING=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\" 2>/dev/null || echo \"0\")\n if [ \"$EXISTING\" -gt \"0\" ]; then\n log \"Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync\"\n DB_ALREADY_SYNCED=true\n else\n printf \" %-20s %s (%s)\\n\" \"Archive DB:\" \"exists\" \"$(du -sh \"$NAS_DB\" | cut -f1)\"\n fi\nelse\n printf \" %-20s %s\\n\" \"Archive DB:\" \"will be created\"\nfi\n\n# Source data dir for this date\nDATA_SRC=\"$HOME/.screenpipe/data/data/$TARGET_DATE\"\nif [ -d \"$DATA_SRC\" ]; then\n DATA_SIZE=$(du -sh \"$DATA_SRC\" | cut -f1)\n DATA_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n printf \" %-20s %s (%s files, %s)\\n\" \"Data dir:\" \"OK\" \"$DATA_FILES\" \"$DATA_SIZE\"\nelse\n printf \" %-20s %s\\n\" \"Data dir:\" \"not found — skipping file copy\"\nfi\n\n# ─── DB SYNC ──────────────────────────────────────────────────────────────────\nif [ \"$DB_ALREADY_SYNCED\" = false ]; then\n\n # ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────\n step \"Counting source rows for $TARGET_DATE\"\n\n SRC_FRAMES=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\")\n SRC_ELEMENTS=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n SRC_UI=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';\")\n SRC_OCR=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n SRC_MEETINGS=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';\")\n\n printf \" %-20s %s\\n\" \"frames:\" \"$SRC_FRAMES\"\n printf \" %-20s %s\\n\" \"elements:\" \"$SRC_ELEMENTS\"\n printf \" %-20s %s\\n\" \"ui_events:\" \"$SRC_UI\"\n printf \" %-20s %s\\n\" \"ocr_text:\" \"$SRC_OCR\"\n printf \" %-20s %s\\n\" \"meetings:\" \"$SRC_MEETINGS\"\n\n if [ \"$SRC_FRAMES\" -eq \"0\" ]; then\n log \"No frames found for $TARGET_DATE — skipping DB sync\"\n DB_ALREADY_SYNCED=true\n fi\n\nfi\n\nif [ \"$DB_ALREADY_SYNCED\" = false ]; then\n\n # ─── INIT TABLES ──────────────────────────────────────────────────────────\n step \"Initialising tables, indexes, FTS\"\n\n run_sqlite_heredoc \"creating tables\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"creating indexes\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);\nCREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);\nCREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"creating FTS tables\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(\n text, role, frame_id UNINDEXED,\n content='elements', content_rowid='id', tokenize='unicode61'\n);\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(\n full_text, app_name, window_name, browser_url, id UNINDEXED,\n tokenize='unicode61'\n);\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(\n text_content,\n app_name,\n window_title,\n element_name,\n content='ui_events',\n content_rowid='id',\n tokenize='unicode61'\n);\nDETACH nas;\n\"\n\n # ─── SYNC DATA ────────────────────────────────────────────────────────────\n step \"Syncing data for $TARGET_DATE\"\n\n run_sqlite_heredoc \"video_chunks\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.video_chunks\n SELECT * FROM main.video_chunks\n WHERE id IN (\n SELECT DISTINCT video_chunk_id FROM main.frames\n WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL\n );\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames ($SRC_FRAMES rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.frames\n SELECT * FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ocr_text ($SRC_OCR rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ocr_text\n SELECT o.* FROM main.ocr_text o\n JOIN main.frames f ON o.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events ($SRC_UI rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ui_events\n SELECT * FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"elements ($SRC_ELEMENTS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.elements\n SELECT e.* FROM main.elements e\n JOIN main.frames f ON e.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"meetings ($SRC_MEETINGS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.meetings\n SELECT * FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n # ─── FTS UPDATE ───────────────────────────────────────────────────────────\n step \"Updating FTS indexes\"\n\n run_sqlite_heredoc \"elements_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.elements_fts(rowid, text, role)\n SELECT e.id, e.text, e.role\n FROM nas.elements e\n JOIN nas.frames f ON e.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE'\n AND e.text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)\n SELECT id, full_text, app_name, window_name, browser_url, id\n FROM nas.frames\n WHERE date(timestamp) = '$TARGET_DATE'\n AND full_text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)\n SELECT id, text_content, app_name, window_title, element_name\n FROM nas.ui_events\n WHERE date(timestamp) = '$TARGET_DATE'\n AND text_content IS NOT NULL;\nDETACH nas;\n\"\n\n # ─── VERIFY DB ────────────────────────────────────────────────────────────\n step \"Verifying DB\"\n\n V_FRAMES=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\")\n V_ELEMENTS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n V_UI=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';\")\n V_OCR=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n V_MEETINGS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';\")\n\n check \"frames\" \"$V_FRAMES\" \"$SRC_FRAMES\"\n check \"elements\" \"$V_ELEMENTS\" \"$SRC_ELEMENTS\"\n check \"ui_events\" \"$V_UI\" \"$SRC_UI\"\n check \"ocr_text\" \"$V_OCR\" \"$SRC_OCR\"\n check \"meetings\" \"$V_MEETINGS\" \"$SRC_MEETINGS\"\n\nfi\n\n# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────\n# Always runs regardless of DB sync status\nstep \"Copying data folder for $TARGET_DATE\"\n\nif [ -d \"$DATA_SRC\" ]; then\n mkdir -p \"$NAS_DATA/$TARGET_DATE\"\n RSYNC_START=$(date +%s)\n printf \" %-36s \" \"rsync $TARGET_DATE/ → NAS\"\n rsync -a --ignore-existing \\\n \"$DATA_SRC/\" \\\n \"$NAS_DATA/$TARGET_DATE/\" \\\n 2>>\"$LOG_FILE\"\n RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))\n COPIED_FILES=$(ls \"$NAS_DATA/$TARGET_DATE\" | wc -l | tr -d ' ')\n SRC_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n COPIED_SIZE=$(du -sh \"$NAS_DATA/$TARGET_DATE\" | cut -f1)\n if [ \"$COPIED_FILES\" -eq \"$SRC_FILES\" ]; then\n printf \"\\r %-36s ✓ %dm%02ds (%s files, %s)\\n\" \\\n \"rsync $TARGET_DATE/ → NAS\" \\\n \"$(( RSYNC_DUR / 60 ))\" \"$(( RSYNC_DUR % 60 ))\" \\\n \"$COPIED_FILES\" \"$COPIED_SIZE\" | tee -a \"$LOG_FILE\"\n else\n printf \"\\r %-36s ✗ %s / %s files\\n\" \\\n \"rsync $TARGET_DATE/ → NAS\" \"$COPIED_FILES\" \"$SRC_FILES\" | tee -a \"$LOG_FILE\"\n fi\nelse\n printf \" %-36s %s\\n\" \"rsync $TARGET_DATE/ → NAS\" \"skipped (no source dir)\"\nfi\n\n# ─── SUMMARY ──────────────────────────────────────────────────────────────────\nTOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))\nDB_SIZE=$(du -sh \"$NAS_DB\" | cut -f1)\n\necho \"\"\nlog \"Archive DB size: $DB_SIZE\"\nlog \"Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s\"\nlog \"Sync complete for $TARGET_DATE\"\nlog \"========================================\"","role_description":"editor","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"#!/bin/bash\n# screenpipe_sync.sh\n# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).\n# Also copies the day's video/frame data folder to the NAS.\n#\n# Usage:\n# ./screenpipe_sync.sh # syncs yesterday (default)\n# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date\n# ./screenpipe_sync.sh today # syncs today so far\n#\n# Cron example (runs at 3am daily):\n# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1\n\nset -euo pipefail\n\n# ─── CONFIG ───────────────────────────────────────────────────────────────────\nDB_SRC=\"${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}\"\nNAS_MOUNT=\"${NAS_MOUNT:-/Volumes/Test/screenpipe}\"\nNAS_DB=\"$NAS_MOUNT/archive.db\"\nNAS_DATA=\"$NAS_MOUNT/data\"\nLOG_FILE=\"$HOME/.screenpipe/sync.log\"\n# ──────────────────────────────────────────────────────────────────────────────\n\n# ─── HELPERS ──────────────────────────────────────────────────────────────────\nSCRIPT_START=$(date +%s)\n\nlog() {\n local msg=\"[$(date '+%Y-%m-%d %H:%M:%S')] $*\"\n echo \"$msg\" | tee -a \"$LOG_FILE\"\n}\n\nstep() {\n local now=$(date +%s)\n local elapsed=$(( now - SCRIPT_START ))\n local min=$(( elapsed / 60 ))\n local sec=$(( elapsed % 60 ))\n printf \"\\n[+%02dm%02ds] ▶ %s\\n\" \"$min\" \"$sec\" \"$*\" | tee -a \"$LOG_FILE\"\n}\n\nrun_sqlite_heredoc() {\n local label=\"$1\"\n local sql=\"$2\"\n local start=$(date +%s)\n\n printf \" %-36s \" \"$label\"\n\n sqlite3 \"$DB_SRC\" <<< \"$sql\" &\n local pid=$!\n local spin=('⠋' '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')\n local i=0\n while kill -0 \"$pid\" 2>/dev/null; do\n printf \"\\r %-36s %s \" \"$label\" \"${spin[$i]}\"\n i=$(( (i + 1) % 10 ))\n sleep 0.2\n done\n wait \"$pid\"\n local rc=$?\n if [ $rc -ne 0 ]; then\n printf \"\\r %-36s ✗ FAILED\\n\" \"$label\" | tee -a \"$LOG_FILE\"\n exit $rc\n fi\n\n local dur=$(( $(date +%s) - start ))\n printf \"\\r %-36s ✓ %dm%02ds\\n\" \"$label\" \"$(( dur / 60 ))\" \"$(( dur % 60 ))\" | tee -a \"$LOG_FILE\"\n}\n\ncheck() {\n local label=\"$1\" got=\"$2\" expected=\"$3\"\n if [ \"$got\" -eq \"$expected\" ]; then\n printf \" %-20s %s / %s ✓\\n\" \"$label:\" \"$got\" \"$expected\"\n else\n printf \" %-20s %s / %s ✗ MISMATCH\\n\" \"$label:\" \"$got\" \"$expected\"\n fi\n}\n# ──────────────────────────────────────────────────────────────────────────────\n\n# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────\nif [ \"${1:-}\" = \"today\" ]; then\n TARGET_DATE=$(date +%Y-%m-%d)\nelif [ -n \"${1:-}\" ]; then\n TARGET_DATE=\"$1\"\n if ! [[ \"$TARGET_DATE\" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then\n echo \"ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday.\"\n exit 1\n fi\nelse\n TARGET_DATE=$(date -v-1d +%Y-%m-%d)\nfi\n\nlog \"========================================\"\nlog \"Screenpipe sync starting for: $TARGET_DATE\"\nlog \"========================================\"\n\n# ─── PREFLIGHT ────────────────────────────────────────────────────────────────\nstep \"Preflight checks\"\n\nif [ ! -f \"$DB_SRC\" ]; then\n log \"ERROR: Source DB not found at $DB_SRC\"; exit 1\nfi\nprintf \" %-20s %s (%s)\\n\" \"Source DB:\" \"OK\" \"$(du -sh \"$DB_SRC\" | cut -f1)\"\n\nif [ ! -d \"$NAS_MOUNT\" ]; then\n log \"ERROR: NAS not mounted at $NAS_MOUNT\"; exit 1\nfi\nprintf \" %-20s %s\\n\" \"NAS mount:\" \"OK $NAS_MOUNT\"\n\n# Check if DB already synced for this date\nDB_ALREADY_SYNCED=false\nif [ -f \"$NAS_DB\" ]; then\n EXISTING=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\" 2>/dev/null || echo \"0\")\n if [ \"$EXISTING\" -gt \"0\" ]; then\n log \"Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync\"\n DB_ALREADY_SYNCED=true\n else\n printf \" %-20s %s (%s)\\n\" \"Archive DB:\" \"exists\" \"$(du -sh \"$NAS_DB\" | cut -f1)\"\n fi\nelse\n printf \" %-20s %s\\n\" \"Archive DB:\" \"will be created\"\nfi\n\n# Source data dir for this date\nDATA_SRC=\"$HOME/.screenpipe/data/data/$TARGET_DATE\"\nif [ -d \"$DATA_SRC\" ]; then\n DATA_SIZE=$(du -sh \"$DATA_SRC\" | cut -f1)\n DATA_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n printf \" %-20s %s (%s files, %s)\\n\" \"Data dir:\" \"OK\" \"$DATA_FILES\" \"$DATA_SIZE\"\nelse\n printf \" %-20s %s\\n\" \"Data dir:\" \"not found — skipping file copy\"\nfi\n\n# ─── DB SYNC ──────────────────────────────────────────────────────────────────\nif [ \"$DB_ALREADY_SYNCED\" = false ]; then\n\n # ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────\n step \"Counting source rows for $TARGET_DATE\"\n\n SRC_FRAMES=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\")\n SRC_ELEMENTS=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n SRC_UI=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';\")\n SRC_OCR=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n SRC_MEETINGS=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';\")\n\n printf \" %-20s %s\\n\" \"frames:\" \"$SRC_FRAMES\"\n printf \" %-20s %s\\n\" \"elements:\" \"$SRC_ELEMENTS\"\n printf \" %-20s %s\\n\" \"ui_events:\" \"$SRC_UI\"\n printf \" %-20s %s\\n\" \"ocr_text:\" \"$SRC_OCR\"\n printf \" %-20s %s\\n\" \"meetings:\" \"$SRC_MEETINGS\"\n\n if [ \"$SRC_FRAMES\" -eq \"0\" ]; then\n log \"No frames found for $TARGET_DATE — skipping DB sync\"\n DB_ALREADY_SYNCED=true\n fi\n\nfi\n\nif [ \"$DB_ALREADY_SYNCED\" = false ]; then\n\n # ─── INIT TABLES ──────────────────────────────────────────────────────────\n step \"Initialising tables, indexes, FTS\"\n\n run_sqlite_heredoc \"creating tables\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"creating indexes\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);\nCREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);\nCREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"creating FTS tables\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(\n text, role, frame_id UNINDEXED,\n content='elements', content_rowid='id', tokenize='unicode61'\n);\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(\n full_text, app_name, window_name, browser_url, id UNINDEXED,\n tokenize='unicode61'\n);\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(\n text_content,\n app_name,\n window_title,\n element_name,\n content='ui_events',\n content_rowid='id',\n tokenize='unicode61'\n);\nDETACH nas;\n\"\n\n # ─── SYNC DATA ────────────────────────────────────────────────────────────\n step \"Syncing data for $TARGET_DATE\"\n\n run_sqlite_heredoc \"video_chunks\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.video_chunks\n SELECT * FROM main.video_chunks\n WHERE id IN (\n SELECT DISTINCT video_chunk_id FROM main.frames\n WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL\n );\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames ($SRC_FRAMES rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.frames\n SELECT * FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ocr_text ($SRC_OCR rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ocr_text\n SELECT o.* FROM main.ocr_text o\n JOIN main.frames f ON o.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events ($SRC_UI rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ui_events\n SELECT * FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"elements ($SRC_ELEMENTS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.elements\n SELECT e.* FROM main.elements e\n JOIN main.frames f ON e.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"meetings ($SRC_MEETINGS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.meetings\n SELECT * FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n # ─── FTS UPDATE ───────────────────────────────────────────────────────────\n step \"Updating FTS indexes\"\n\n run_sqlite_heredoc \"elements_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.elements_fts(rowid, text, role)\n SELECT e.id, e.text, e.role\n FROM nas.elements e\n JOIN nas.frames f ON e.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE'\n AND e.text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)\n SELECT id, full_text, app_name, window_name, browser_url, id\n FROM nas.frames\n WHERE date(timestamp) = '$TARGET_DATE'\n AND full_text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)\n SELECT id, text_content, app_name, window_title, element_name\n FROM nas.ui_events\n WHERE date(timestamp) = '$TARGET_DATE'\n AND text_content IS NOT NULL;\nDETACH nas;\n\"\n\n # ─── VERIFY DB ────────────────────────────────────────────────────────────\n step \"Verifying DB\"\n\n V_FRAMES=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\")\n V_ELEMENTS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n V_UI=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';\")\n V_OCR=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n V_MEETINGS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';\")\n\n check \"frames\" \"$V_FRAMES\" \"$SRC_FRAMES\"\n check \"elements\" \"$V_ELEMENTS\" \"$SRC_ELEMENTS\"\n check \"ui_events\" \"$V_UI\" \"$SRC_UI\"\n check \"ocr_text\" \"$V_OCR\" \"$SRC_OCR\"\n check \"meetings\" \"$V_MEETINGS\" \"$SRC_MEETINGS\"\n\nfi\n\n# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────\n# Always runs regardless of DB sync status\nstep \"Copying data folder for $TARGET_DATE\"\n\nif [ -d \"$DATA_SRC\" ]; then\n mkdir -p \"$NAS_DATA/$TARGET_DATE\"\n RSYNC_START=$(date +%s)\n printf \" %-36s \" \"rsync $TARGET_DATE/ → NAS\"\n rsync -a --ignore-existing \\\n \"$DATA_SRC/\" \\\n \"$NAS_DATA/$TARGET_DATE/\" \\\n 2>>\"$LOG_FILE\"\n RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))\n COPIED_FILES=$(ls \"$NAS_DATA/$TARGET_DATE\" | wc -l | tr -d ' ')\n SRC_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n COPIED_SIZE=$(du -sh \"$NAS_DATA/$TARGET_DATE\" | cut -f1)\n if [ \"$COPIED_FILES\" -eq \"$SRC_FILES\" ]; then\n printf \"\\r %-36s ✓ %dm%02ds (%s files, %s)\\n\" \\\n \"rsync $TARGET_DATE/ → NAS\" \\\n \"$(( RSYNC_DUR / 60 ))\" \"$(( RSYNC_DUR % 60 ))\" \\\n \"$COPIED_FILES\" \"$COPIED_SIZE\" | tee -a \"$LOG_FILE\"\n else\n printf \"\\r %-36s ✗ %s / %s files\\n\" \\\n \"rsync $TARGET_DATE/ → NAS\" \"$COPIED_FILES\" \"$SRC_FILES\" | tee -a \"$LOG_FILE\"\n fi\nelse\n printf \" %-36s %s\\n\" \"rsync $TARGET_DATE/ → NAS\" \"skipped (no source dir)\"\nfi\n\n# ─── SUMMARY ──────────────────────────────────────────────────────────────────\nTOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))\nDB_SIZE=$(du -sh \"$NAS_DB\" | cut -f1)\n\necho \"\"\nlog \"Archive DB size: $DB_SIZE\"\nlog \"Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s\"\nlog \"Sync complete for $TARGET_DATE\"\nlog \"========================================\"","depth":29,"bounds":{"left":0.11569149,"top":0.0933759,"width":0.35804522,"height":0.0007980846},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Implement and run pipe l…, Editor Group 2","depth":28,"bounds":{"left":0.5578458,"top":0.047885075,"width":0.073803194,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":false},{"role":"AXRadioButton","text":"Problems (⇧⌘M)","depth":22,"bounds":{"left":0.118351065,"top":0.7278532,"width":0.027925532,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"PROBLEMS","depth":24,"bounds":{"left":0.122340426,"top":0.7366321,"width":0.019946808,"height":0.0103751},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Output (⇧⌘U)","depth":22,"bounds":{"left":0.14594415,"top":0.7278532,"width":0.023603724,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUTPUT","depth":24,"bounds":{"left":0.14993352,"top":0.7366321,"width":0.015625,"height":0.0103751},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Debug Console (⇧⌘Y)","depth":22,"bounds":{"left":0.16921543,"top":0.7278532,"width":0.039893616,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"DEBUG CONSOLE","depth":24,"bounds":{"left":0.1732048,"top":0.7366321,"width":0.031914894,"height":0.0103751},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Terminal (⌃`)","depth":22,"bounds":{"left":0.2087766,"top":0.7278532,"width":0.026595745,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":true},{"role":"AXStaticText","text":"TERMINAL","depth":24,"bounds":{"left":0.21276596,"top":0.7366321,"width":0.01861702,"height":0.0103751},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Ports - 1 forwarded port","depth":22,"bounds":{"left":0.23537233,"top":0.7278532,"width":0.026263298,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"PORTS","depth":24,"bounds":{"left":0.2393617,"top":0.7366321,"width":0.012300532,"height":0.0103751},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":25,"bounds":{"left":0.25465426,"top":0.73743016,"width":0.0019946808,"height":0.008778931},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"remote SSH: nas","depth":16,"bounds":{"left":0.0006648936,"top":0.98244214,"width":0.028590426,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.0033244682,"top":0.9848364,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"SSH: nas","depth":17,"bounds":{"left":0.008643617,"top":0.9856345,"width":0.017952127,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"screenpipe (Git) - master*, Checkout Branch/Tag...","depth":16,"bounds":{"left":0.030917553,"top":0.98244214,"width":0.023271276,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.031914894,"top":0.9848364,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"master*","depth":17,"bounds":{"left":0.03723404,"top":0.9856345,"width":0.015957447,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"screenpipe (Git) - Synchronize Changes","depth":16,"bounds":{"left":0.05418883,"top":0.98244214,"width":0.00731383,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"No Problems","depth":16,"bounds":{"left":0.06416223,"top":0.98244214,"width":0.022606382,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.06582447,"top":0.9848364,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"0","depth":17,"bounds":{"left":0.07114362,"top":0.9856345,"width":0.004986702,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.07579787,"top":0.9848364,"width":0.0056515955,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"0","depth":17,"bounds":{"left":0.08111702,"top":0.9856345,"width":0.0039893617,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Forwarded Ports: 8766","depth":16,"bounds":{"left":0.08843085,"top":0.98244214,"width":0.012632979,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.09009308,"top":0.9848364,"width":0.0056515955,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":17,"bounds":{"left":0.09541223,"top":0.9856345,"width":0.0039893617,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Notifications","depth":16,"bounds":{"left":0.9886968,"top":0.98244214,"width":0.010638298,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sign In","depth":16,"bounds":{"left":0.9650931,"top":0.98244214,"width":0.022606382,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.96675533,"top":0.9848364,"width":0.0056515955,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Sign In","depth":17,"bounds":{"left":0.97207445,"top":0.9856345,"width":0.013962766,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Shell Script","depth":16,"bounds":{"left":0.93916225,"top":0.98244214,"width":0.023603724,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Editor Language Status: $(copilot) No inline suggestion available, Inline suggestions","depth":16,"bounds":{"left":0.9318484,"top":0.98244214,"width":0.00731383,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"LF","depth":16,"bounds":{"left":0.9212101,"top":0.98244214,"width":0.007978723,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"UTF-8","depth":16,"bounds":{"left":0.90359044,"top":0.98244214,"width":0.015625,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Spaces: 2","depth":16,"bounds":{"left":0.8796542,"top":0.98244214,"width":0.022273935,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Ln 352, Col 47 (13096 selected)","depth":16,"bounds":{"left":0.8125,"top":0.98244214,"width":0.06549202,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"git-commit Lukas Kovalik (2 weeks ago)","depth":16,"bounds":{"left":0.74800533,"top":0.98244214,"width":0.062832445,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.7496675,"top":0.9848364,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Lukas Kovalik (2 weeks ago)","depth":17,"bounds":{"left":0.7549867,"top":0.9856345,"width":0.05418883,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Info: Setting up SSH Host nas: Setting up SSH tunnel","depth":12,"on_screen":false,"role_description":"text"}]...
|
-2310361797135886406
|
3898032390844845463
|
visual_change
|
accessibility
|
NULL
|
Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧ Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py
M
db.py
docker-compose.yml
Dockerfile
M
main.py
M
requirements.txt
M
data
logs
pipes
.gitignore
app_settings.json
archive.db
archive.db-bak
U
db.sqlite
db.sqlite-shm
db.sqlite-wal
screenpipe_sync_updated.sh
U
screenpipe_sync.sh
screenpipe.db
Outline Section
OUTLINE
OUTLINE
Timeline Section
TIMELINE
TIMELINE
app_settings.json, Editor Group 1
screenpipe_sync.sh, Editor Group 1
pipe.md, Editor Group 1
.env, Editor Group 1
#!/bin/bash
# screenpipe_sync.sh
# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).
# Also copies the day's video/frame data folder to the NAS.
#
# Usage:
# ./screenpipe_sync.sh # syncs yesterday (default)
# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date
# ./screenpipe_sync.sh today # syncs today so far
#
# Cron example (runs at 3am daily):
# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1
set -euo pipefail
# ─── CONFIG ───────────────────────────────────────────────────────────────────
DB_SRC="${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}"
NAS_MOUNT="${NAS_MOUNT:-/Volumes/Test/screenpipe}"
NAS_DB="$NAS_MOUNT/archive.db"
NAS_DATA="$NAS_MOUNT/data"
LOG_FILE="$HOME/.screenpipe/sync.log"
# ──────────────────────────────────────────────────────────────────────────────
# ─── HELPERS ──────────────────────────────────────────────────────────────────
SCRIPT_START=$(date +%s)
log() {
local msg="[$(date '+%Y-%m-%d %H:%M:%S')] $*"
echo "$msg" | tee -a "$LOG_FILE"
}
step() {
local now=$(date +%s)
local elapsed=$(( now - SCRIPT_START ))
local min=$(( elapsed / 60 ))
local sec=$(( elapsed % 60 ))
printf "\n[+%02dm%02ds] ▶ %s\n" "$min" "$sec" "$*" | tee -a "$LOG_FILE"
}
run_sqlite_heredoc() {
local label="$1"
local sql="$2"
local start=$(date +%s)
printf " %-36s " "$label"
sqlite3 "$DB_SRC" <<< "$sql" &
local pid=$!
local spin=[PASSWORD] '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')
local i=0
while kill -0 "$pid" 2>/dev/null; do
printf "\r %-36s %s " "$label" "${spin[$i]}"
i=$(( (i + 1) % 10 ))
sleep 0.2
done
wait "$pid"
local rc=$?
if [ $rc -ne 0 ]; then
printf "\r %-36s ✗ FAILED\n" "$label" | tee -a "$LOG_FILE"
exit $rc
fi
local dur=$(( $(date +%s) - start ))
printf "\r %-36s ✓ %dm%02ds\n" "$label" "$(( dur / 60 ))" "$(( dur % 60 ))" | tee -a "$LOG_FILE"
}
check() {
local label="$1" got="$2" expected="$3"
if [ "$got" -eq "$expected" ]; then
printf " %-20s %s / %s ✓\n" "$label:" "$got" "$expected"
else
printf " %-20s %s / %s ✗ MISMATCH\n" "$label:" "$got" "$expected"
fi
}
# ──────────────────────────────────────────────────────────────────────────────
# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────
if [ "${1:-}" = "today" ]; then
TARGET_DATE=$(date +%Y-%m-%d)
elif [ -n "${1:-}" ]; then
TARGET_DATE="$1"
if ! [[ "$TARGET_DATE" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then
echo "ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday."
exit 1
fi
else
TARGET_DATE=$(date -v-1d +%Y-%m-%d)
fi
log "========================================"
log "Screenpipe sync starting for: $TARGET_DATE"
log "========================================"
# ─── PREFLIGHT ────────────────────────────────────────────────────────────────
step "Preflight checks"
if [ ! -f "$DB_SRC" ]; then
log "ERROR: Source DB not found at $DB_SRC"; exit 1
fi
printf " %-20s %s (%s)\n" "Source DB:" "OK" "$(du -sh "$DB_SRC" | cut -f1)"
if [ ! -d "$NAS_MOUNT" ]; then
log "ERROR: NAS not mounted at $NAS_MOUNT"; exit 1
fi
printf " %-20s %s\n" "NAS mount:" "OK $NAS_MOUNT"
# Check if DB already synced for this date
DB_ALREADY_SYNCED=false
if [ -f "$NAS_DB" ]; then
EXISTING=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';" 2>/dev/null || echo "0")
if [ "$EXISTING" -gt "0" ]; then
log "Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync"
DB_ALREADY_SYNCED=true
else
printf " %-20s %s (%s)\n" "Archive DB:" "exists" "$(du -sh "$NAS_DB" | cut -f1)"
fi
else
printf " %-20s %s\n" "Archive DB:" "will be created"
fi
# Source data dir for this date
DATA_SRC="$HOME/.screenpipe/data/data/$TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
DATA_SIZE=$(du -sh "$DATA_SRC" | cut -f1)
DATA_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
printf " %-20s %s (%s files, %s)\n" "Data dir:" "OK" "$DATA_FILES" "$DATA_SIZE"
else
printf " %-20s %s\n" "Data dir:" "not found — skipping file copy"
fi
# ─── DB SYNC ──────────────────────────────────────────────────────────────────
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────
step "Counting source rows for $TARGET_DATE"
SRC_FRAMES=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
SRC_ELEMENTS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_UI=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
SRC_OCR=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_MEETINGS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';")
printf " %-20s %s\n" "frames:" "$SRC_FRAMES"
printf " %-20s %s\n" "elements:" "$SRC_ELEMENTS"
printf " %-20s %s\n" "ui_events:" "$SRC_UI"
printf " %-20s %s\n" "ocr_text:" "$SRC_OCR"
printf " %-20s %s\n" "meetings:" "$SRC_MEETINGS"
if [ "$SRC_FRAMES" -eq "0" ]; then
log "No frames found for $TARGET_DATE — skipping DB sync"
DB_ALREADY_SYNCED=true
fi
fi
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── INIT TABLES ──────────────────────────────────────────────────────────
step "Initialising tables, indexes, FTS"
run_sqlite_heredoc "creating tables" "
ATTACH '$NAS_DB' AS nas;
CREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;
CREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;
CREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;
CREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;
DETACH nas;
"
run_sqlite_heredoc "creating indexes" "
ATTACH '$NAS_DB' AS nas;
CREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);
CREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);
DETACH nas;
"
run_sqlite_heredoc "creating FTS tables" "
ATTACH '$NAS_DB' AS nas;
CREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(
text, role, frame_id UNINDEXED,
content='elements', content_rowid='id', tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(
full_text, app_name, window_name, browser_url, id UNINDEXED,
tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(
text_content,
app_name,
window_title,
element_name,
content='ui_events',
content_rowid='id',
tokenize='unicode61'
);
DETACH nas;
"
# ─── SYNC DATA ────────────────────────────────────────────────────────────
step "Syncing data for $TARGET_DATE"
run_sqlite_heredoc "video_chunks" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.video_chunks
SELECT * FROM main.video_chunks
WHERE id IN (
SELECT DISTINCT video_chunk_id FROM main.frames
WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL
);
DETACH nas;
"
run_sqlite_heredoc "frames ($SRC_FRAMES rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.frames
SELECT * FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ocr_text ($SRC_OCR rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ocr_text
SELECT o.* FROM main.ocr_text o
JOIN main.frames f ON o.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ui_events ($SRC_UI rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ui_events
SELECT * FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "elements ($SRC_ELEMENTS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.elements
SELECT e.* FROM main.elements e
JOIN main.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "meetings ($SRC_MEETINGS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.meetings
SELECT * FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';
DETACH nas;
"
# ─── FTS UPDATE ───────────────────────────────────────────────────────────
step "Updating FTS indexes"
run_sqlite_heredoc "elements_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.elements_fts(rowid, text, role)
SELECT e.id, e.text, e.role
FROM nas.elements e
JOIN nas.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE'
AND e.text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "frames_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)
SELECT id, full_text, app_name, window_name, browser_url, id
FROM nas.frames
WHERE date(timestamp) = '$TARGET_DATE'
AND full_text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "ui_events_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)
SELECT id, text_content, app_name, window_title, element_name
FROM nas.ui_events
WHERE date(timestamp) = '$TARGET_DATE'
AND text_content IS NOT NULL;
DETACH nas;
"
# ─── VERIFY DB ────────────────────────────────────────────────────────────
step "Verifying DB"
V_FRAMES=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
V_ELEMENTS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_UI=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
V_OCR=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_MEETINGS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';")
check "frames" "$V_FRAMES" "$SRC_FRAMES"
check "elements" "$V_ELEMENTS" "$SRC_ELEMENTS"
check "ui_events" "$V_UI" "$SRC_UI"
check "ocr_text" "$V_OCR" "$SRC_OCR"
check "meetings" "$V_MEETINGS" "$SRC_MEETINGS"
fi
# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────
# Always runs regardless of DB sync status
step "Copying data folder for $TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
mkdir -p "$NAS_DATA/$TARGET_DATE"
RSYNC_START=$(date +%s)
printf " %-36s " "rsync $TARGET_DATE/ → NAS"
rsync -a --ignore-existing \
"$DATA_SRC/" \
"$NAS_DATA/$TARGET_DATE/" \
2>>"$LOG_FILE"
RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))
COPIED_FILES=$(ls "$NAS_DATA/$TARGET_DATE" | wc -l | tr -d ' ')
SRC_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
COPIED_SIZE=$(du -sh "$NAS_DATA/$TARGET_DATE" | cut -f1)
if [ "$COPIED_FILES" -eq "$SRC_FILES" ]; then
printf "\r %-36s ✓ %dm%02ds (%s files, %s)\n" \
"rsync $TARGET_DATE/ → NAS" \
"$(( RSYNC_DUR / 60 ))" "$(( RSYNC_DUR % 60 ))" \
"$COPIED_FILES" "$COPIED_SIZE" | tee -a "$LOG_FILE"
else
printf "\r %-36s ✗ %s / %s files\n" \
"rsync $TARGET_DATE/ → NAS" "$COPIED_FILES" "$SRC_FILES" | tee -a "$LOG_FILE"
fi
else
printf " %-36s %s\n" "rsync $TARGET_DATE/ → NAS" "skipped (no source dir)"
fi
# ─── SUMMARY ──────────────────────────────────────────────────────────────────
TOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))
DB_SIZE=$(du -sh "$NAS_DB" | cut -f1)
echo ""
log "Archive DB size: $DB_SIZE"
log "Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s"
log "Sync complete for $TARGET_DATE"
log "========================================"
#!/bin/bash
# screenpipe_sync.sh
# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).
# Also copies the day's video/frame data folder to the NAS.
#
# Usage:
# ./screenpipe_sync.sh # syncs yesterday (default)
# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date
# ./screenpipe_sync.sh today # syncs today so far
#
# Cron example (runs at 3am daily):
# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1
set -euo pipefail
# ─── CONFIG ───────────────────────────────────────────────────────────────────
DB_SRC="${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}"
NAS_MOUNT="${NAS_MOUNT:-/Volumes/Test/screenpipe}"
NAS_DB="$NAS_MOUNT/archive.db"
NAS_DATA="$NAS_MOUNT/data"
LOG_FILE="$HOME/.screenpipe/sync.log"
# ──────────────────────────────────────────────────────────────────────────────
# ─── HELPERS ──────────────────────────────────────────────────────────────────
SCRIPT_START=$(date +%s)
log() {
local msg="[$(date '+%Y-%m-%d %H:%M:%S')] $*"
echo "$msg" | tee -a "$LOG_FILE"
}
step() {
local now=$(date +%s)
local elapsed=$(( now - SCRIPT_START ))
local min=$(( elapsed / 60 ))
local sec=$(( elapsed % 60 ))
printf "\n[+%02dm%02ds] ▶ %s\n" "$min" "$sec" "$*" | tee -a "$LOG_FILE"
}
run_sqlite_heredoc() {
local label="$1"
local sql="$2"
local start=$(date +%s)
printf " %-36s " "$label"
sqlite3 "$DB_SRC" <<< "$sql" &
local pid=$!
local spin=[PASSWORD] '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')
local i=0
while kill -0 "$pid" 2>/dev/null; do
printf "\r %-36s %s " "$label" "${spin[$i]}"
i=$(( (i + 1) % 10 ))
sleep 0.2
done
wait "$pid"
local rc=$?
if [ $rc -ne 0 ]; then
printf "\r %-36s ✗ FAILED\n" "$label" | tee -a "$LOG_FILE"
exit $rc
fi
local dur=$(( $(date +%s) - start ))
printf "\r %-36s ✓ %dm%02ds\n" "$label" "$(( dur / 60 ))" "$(( dur % 60 ))" | tee -a "$LOG_FILE"
}
check() {
local label="$1" got="$2" expected="$3"
if [ "$got" -eq "$expected" ]; then
printf " %-20s %s / %s ✓\n" "$label:" "$got" "$expected"
else
printf " %-20s %s / %s ✗ MISMATCH\n" "$label:" "$got" "$expected"
fi
}
# ──────────────────────────────────────────────────────────────────────────────
# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────
if [ "${1:-}" = "today" ]; then
TARGET_DATE=$(date +%Y-%m-%d)
elif [ -n "${1:-}" ]; then
TARGET_DATE="$1"
if ! [[ "$TARGET_DATE" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then
echo "ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday."
exit 1
fi
else
TARGET_DATE=$(date -v-1d +%Y-%m-%d)
fi
log "========================================"
log "Screenpipe sync starting for: $TARGET_DATE"
log "========================================"
# ─── PREFLIGHT ────────────────────────────────────────────────────────────────
step "Preflight checks"
if [ ! -f "$DB_SRC" ]; then
log "ERROR: Source DB not found at $DB_SRC"; exit 1
fi
printf " %-20s %s (%s)\n" "Source DB:" "OK" "$(du -sh "$DB_SRC" | cut -f1)"
if [ ! -d "$NAS_MOUNT" ]; then
log "ERROR: NAS not mounted at $NAS_MOUNT"; exit 1
fi
printf " %-20s %s\n" "NAS mount:" "OK $NAS_MOUNT"
# Check if DB already synced for this date
DB_ALREADY_SYNCED=false
if [ -f "$NAS_DB" ]; then
EXISTING=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';" 2>/dev/null || echo "0")
if [ "$EXISTING" -gt "0" ]; then
log "Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync"
DB_ALREADY_SYNCED=true
else
printf " %-20s %s (%s)\n" "Archive DB:" "exists" "$(du -sh "$NAS_DB" | cut -f1)"
fi
else
printf " %-20s %s\n" "Archive DB:" "will be created"
fi
# Source data dir for this date
DATA_SRC="$HOME/.screenpipe/data/data/$TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
DATA_SIZE=$(du -sh "$DATA_SRC" | cut -f1)
DATA_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
printf " %-20s %s (%s files, %s)\n" "Data dir:" "OK" "$DATA_FILES" "$DATA_SIZE"
else
printf " %-20s %s\n" "Data dir:" "not found — skipping file copy"
fi
# ─── DB SYNC ──────────────────────────────────────────────────────────────────
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────
step "Counting source rows for $TARGET_DATE"
SRC_FRAMES=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
SRC_ELEMENTS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_UI=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
SRC_OCR=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_MEETINGS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';")
printf " %-20s %s\n" "frames:" "$SRC_FRAMES"
printf " %-20s %s\n" "elements:" "$SRC_ELEMENTS"
printf " %-20s %s\n" "ui_events:" "$SRC_UI"
printf " %-20s %s\n" "ocr_text:" "$SRC_OCR"
printf " %-20s %s\n" "meetings:" "$SRC_MEETINGS"
if [ "$SRC_FRAMES" -eq "0" ]; then
log "No frames found for $TARGET_DATE — skipping DB sync"
DB_ALREADY_SYNCED=true
fi
fi
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── INIT TABLES ──────────────────────────────────────────────────────────
step "Initialising tables, indexes, FTS"
run_sqlite_heredoc "creating tables" "
ATTACH '$NAS_DB' AS nas;
CREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;
CREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;
CREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;
CREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;
DETACH nas;
"
run_sqlite_heredoc "creating indexes" "
ATTACH '$NAS_DB' AS nas;
CREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);
CREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);
DETACH nas;
"
run_sqlite_heredoc "creating FTS tables" "
ATTACH '$NAS_DB' AS nas;
CREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(
text, role, frame_id UNINDEXED,
content='elements', content_rowid='id', tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(
full_text, app_name, window_name, browser_url, id UNINDEXED,
tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(
text_content,
app_name,
window_title,
element_name,
content='ui_events',
content_rowid='id',
tokenize='unicode61'
);
DETACH nas;
"
# ─── SYNC DATA ────────────────────────────────────────────────────────────
step "Syncing data for $TARGET_DATE"
run_sqlite_heredoc "video_chunks" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.video_chunks
SELECT * FROM main.video_chunks
WHERE id IN (
SELECT DISTINCT video_chunk_id FROM main.frames
WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL
);
DETACH nas;
"
run_sqlite_heredoc "frames ($SRC_FRAMES rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.frames
SELECT * FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ocr_text ($SRC_OCR rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ocr_text
SELECT o.* FROM main.ocr_text o
JOIN main.frames f ON o.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ui_events ($SRC_UI rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ui_events
SELECT * FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "elements ($SRC_ELEMENTS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.elements
SELECT e.* FROM main.elements e
JOIN main.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "meetings ($SRC_MEETINGS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.meetings
SELECT * FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';
DETACH nas;
"
# ─── FTS UPDATE ───────────────────────────────────────────────────────────
step "Updating FTS indexes"
run_sqlite_heredoc "elements_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.elements_fts(rowid, text, role)
SELECT e.id, e.text, e.role
FROM nas.elements e
JOIN nas.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE'
AND e.text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "frames_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)
SELECT id, full_text, app_name, window_name, browser_url, id
FROM nas.frames
WHERE date(timestamp) = '$TARGET_DATE'
AND full_text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "ui_events_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)
SELECT id, text_content, app_name, window_title, element_name
FROM nas.ui_events
WHERE date(timestamp) = '$TARGET_DATE'
AND text_content IS NOT NULL;
DETACH nas;
"
# ─── VERIFY DB ────────────────────────────────────────────────────────────
step "Verifying DB"
V_FRAMES=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
V_ELEMENTS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_UI=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
V_OCR=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_MEETINGS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';")
check "frames" "$V_FRAMES" "$SRC_FRAMES"
check "elements" "$V_ELEMENTS" "$SRC_ELEMENTS"
check "ui_events" "$V_UI" "$SRC_UI"
check "ocr_text" "$V_OCR" "$SRC_OCR"
check "meetings" "$V_MEETINGS" "$SRC_MEETINGS"
fi
# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────
# Always runs regardless of DB sync status
step "Copying data folder for $TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
mkdir -p "$NAS_DATA/$TARGET_DATE"
RSYNC_START=$(date +%s)
printf " %-36s " "rsync $TARGET_DATE/ → NAS"
rsync -a --ignore-existing \
"$DATA_SRC/" \
"$NAS_DATA/$TARGET_DATE/" \
2>>"$LOG_FILE"
RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))
COPIED_FILES=$(ls "$NAS_DATA/$TARGET_DATE" | wc -l | tr -d ' ')
SRC_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
COPIED_SIZE=$(du -sh "$NAS_DATA/$TARGET_DATE" | cut -f1)
if [ "$COPIED_FILES" -eq "$SRC_FILES" ]; then
printf "\r %-36s ✓ %dm%02ds (%s files, %s)\n" \
"rsync $TARGET_DATE/ → NAS" \
"$(( RSYNC_DUR / 60 ))" "$(( RSYNC_DUR % 60 ))" \
"$COPIED_FILES" "$COPIED_SIZE" | tee -a "$LOG_FILE"
else
printf "\r %-36s ✗ %s / %s files\n" \
"rsync $TARGET_DATE/ → NAS" "$COPIED_FILES" "$SRC_FILES" | tee -a "$LOG_FILE"
fi
else
printf " %-36s %s\n" "rsync $TARGET_DATE/ → NAS" "skipped (no source dir)"
fi
# ─── SUMMARY ──────────────────────────────────────────────────────────────────
TOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))
DB_SIZE=$(du -sh "$NAS_DB" | cut -f1)
echo ""
log "Archive DB size: $DB_SIZE"
log "Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s"
log "Sync complete for $TARGET_DATE"
log "========================================"
Implement and run pipe l…, Editor Group 2
Problems (⇧⌘M)
PROBLEMS
Output (⇧⌘U)
OUTPUT
Debug Console (⇧⌘Y)
DEBUG CONSOLE
Terminal (⌃`)
TERMINAL
Ports - 1 forwarded port
PORTS
1
remote SSH: nas
SSH: nas
screenpipe (Git) - master*, Checkout Branch/Tag...
master*
screenpipe (Git) - Synchronize Changes
No Problems
0
0
Forwarded Ports: 8766
1
Notifications
Sign In
Sign In
Shell Script
Editor Language Status: $(copilot) No inline suggestion available, Inline suggestions
LF
UTF-8
Spaces: 2
Ln 352, Col 47 (13096 selected)
git-commit Lukas Kovalik (2 weeks ago)
Lukas Kovalik (2 weeks ago)
Info: Setting up SSH Host nas: Setting up SSH tunnel...
|
21098
|
NULL
|
NULL
|
NULL
|
|
21100
|
922
|
11
|
2026-05-11T17:12:11.611882+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-11/1778 /Users/lukas/.screenpipe/data/data/2026-05-11/1778519531611_m1.jpg...
|
Code
|
screenpipe_sync.sh — screenpipe [SSH: nas]
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧ Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py
M
db.py
docker-compose.yml
Dockerfile
M
main.py
M
requirements.txt
M
data
logs
pipes
.gitignore
app_settings.json
archive.db
archive.db-bak
U
db.sqlite
db.sqlite-shm
db.sqlite-wal
screenpipe_sync_updated.sh
U
screenpipe_sync.sh
screenpipe.db
Outline Section
OUTLINE
OUTLINE
Timeline Section
TIMELINE
TIMELINE
app_settings.json, Editor Group 1
screenpipe_sync.sh, Editor Group 1
pipe.md, Editor Group 1
.env, Editor Group 1
#!/bin/bash
# screenpipe_sync.sh
# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).
# Also copies the day's video/frame data folder to the NAS.
#
# Usage:
# ./screenpipe_sync.sh # syncs yesterday (default)
# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date
# ./screenpipe_sync.sh today # syncs today so far
#
# Cron example (runs at 3am daily):
# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1
set -euo pipefail
# ─── CONFIG ───────────────────────────────────────────────────────────────────
DB_SRC="${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}"
NAS_MOUNT="${NAS_MOUNT:-/Volumes/Test/screenpipe}"
NAS_DB="$NAS_MOUNT/archive.db"
NAS_DATA="$NAS_MOUNT/data"
LOG_FILE="$HOME/.screenpipe/sync.log"
# ──────────────────────────────────────────────────────────────────────────────
# ─── HELPERS ──────────────────────────────────────────────────────────────────
SCRIPT_START=$(date +%s)
log() {
local msg="[$(date '+%Y-%m-%d %H:%M:%S')] $*"
echo "$msg" | tee -a "$LOG_FILE"
}
step() {
local now=$(date +%s)
local elapsed=$(( now - SCRIPT_START ))
local min=$(( elapsed / 60 ))
local sec=$(( elapsed % 60 ))
printf "\n[+%02dm%02ds] ▶ %s\n" "$min" "$sec" "$*" | tee -a "$LOG_FILE"
}
run_sqlite_heredoc() {
local label="$1"
local sql="$2"
local start=$(date +%s)
printf " %-36s " "$label"
sqlite3 "$DB_SRC" <<< "$sql" &
local pid=$!
local spin=[PASSWORD] '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')
local i=0
while kill -0 "$pid" 2>/dev/null; do
printf "\r %-36s %s " "$label" "${spin[$i]}"
i=$(( (i + 1) % 10 ))
sleep 0.2
done
wait "$pid"
local rc=$?
if [ $rc -ne 0 ]; then
printf "\r %-36s ✗ FAILED\n" "$label" | tee -a "$LOG_FILE"
exit $rc
fi
local dur=$(( $(date +%s) - start ))
printf "\r %-36s ✓ %dm%02ds\n" "$label" "$(( dur / 60 ))" "$(( dur % 60 ))" | tee -a "$LOG_FILE"
}
check() {
local label="$1" got="$2" expected="$3"
if [ "$got" -eq "$expected" ]; then
printf " %-20s %s / %s ✓\n" "$label:" "$got" "$expected"
else
printf " %-20s %s / %s ✗ MISMATCH\n" "$label:" "$got" "$expected"
fi
}
# ──────────────────────────────────────────────────────────────────────────────
# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────
if [ "${1:-}" = "today" ]; then
TARGET_DATE=$(date +%Y-%m-%d)
elif [ -n "${1:-}" ]; then
TARGET_DATE="$1"
if ! [[ "$TARGET_DATE" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then
echo "ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday."
exit 1
fi
else
TARGET_DATE=$(date -v-1d +%Y-%m-%d)
fi
log "========================================"
log "Screenpipe sync starting for: $TARGET_DATE"
log "========================================"
# ─── PREFLIGHT ────────────────────────────────────────────────────────────────
step "Preflight checks"
if [ ! -f "$DB_SRC" ]; then
log "ERROR: Source DB not found at $DB_SRC"; exit 1
fi
printf " %-20s %s (%s)\n" "Source DB:" "OK" "$(du -sh "$DB_SRC" | cut -f1)"
if [ ! -d "$NAS_MOUNT" ]; then
log "ERROR: NAS not mounted at $NAS_MOUNT"; exit 1
fi
printf " %-20s %s\n" "NAS mount:" "OK $NAS_MOUNT"
# Check if DB already synced for this date
DB_ALREADY_SYNCED=false
if [ -f "$NAS_DB" ]; then
EXISTING=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';" 2>/dev/null || echo "0")
if [ "$EXISTING" -gt "0" ]; then
log "Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync"
DB_ALREADY_SYNCED=true
else
printf " %-20s %s (%s)\n" "Archive DB:" "exists" "$(du -sh "$NAS_DB" | cut -f1)"
fi
else
printf " %-20s %s\n" "Archive DB:" "will be created"
fi
# Source data dir for this date
DATA_SRC="$HOME/.screenpipe/data/data/$TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
DATA_SIZE=$(du -sh "$DATA_SRC" | cut -f1)
DATA_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
printf " %-20s %s (%s files, %s)\n" "Data dir:" "OK" "$DATA_FILES" "$DATA_SIZE"
else
printf " %-20s %s\n" "Data dir:" "not found — skipping file copy"
fi
# ─── DB SYNC ──────────────────────────────────────────────────────────────────
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────
step "Counting source rows for $TARGET_DATE"
SRC_FRAMES=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
SRC_ELEMENTS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_UI=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
SRC_OCR=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_MEETINGS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';")
printf " %-20s %s\n" "frames:" "$SRC_FRAMES"
printf " %-20s %s\n" "elements:" "$SRC_ELEMENTS"
printf " %-20s %s\n" "ui_events:" "$SRC_UI"
printf " %-20s %s\n" "ocr_text:" "$SRC_OCR"
printf " %-20s %s\n" "meetings:" "$SRC_MEETINGS"
if [ "$SRC_FRAMES" -eq "0" ]; then
log "No frames found for $TARGET_DATE — skipping DB sync"
DB_ALREADY_SYNCED=true
fi
fi
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── INIT TABLES ──────────────────────────────────────────────────────────
step "Initialising tables, indexes, FTS"
run_sqlite_heredoc "creating tables" "
ATTACH '$NAS_DB' AS nas;
CREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;
CREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;
CREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;
CREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;
DETACH nas;
"
run_sqlite_heredoc "creating indexes" "
ATTACH '$NAS_DB' AS nas;
CREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);
CREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);
DETACH nas;
"
run_sqlite_heredoc "creating FTS tables" "
ATTACH '$NAS_DB' AS nas;
CREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(
text, role, frame_id UNINDEXED,
content='elements', content_rowid='id', tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(
full_text, app_name, window_name, browser_url, id UNINDEXED,
tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(
text_content,
app_name,
window_title,
element_name,
content='ui_events',
content_rowid='id',
tokenize='unicode61'
);
DETACH nas;
"
# ─── SYNC DATA ────────────────────────────────────────────────────────────
step "Syncing data for $TARGET_DATE"
run_sqlite_heredoc "video_chunks" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.video_chunks
SELECT * FROM main.video_chunks
WHERE id IN (
SELECT DISTINCT video_chunk_id FROM main.frames
WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL
);
DETACH nas;
"
run_sqlite_heredoc "frames ($SRC_FRAMES rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.frames
SELECT * FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ocr_text ($SRC_OCR rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ocr_text
SELECT o.* FROM main.ocr_text o
JOIN main.frames f ON o.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ui_events ($SRC_UI rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ui_events
SELECT * FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "elements ($SRC_ELEMENTS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.elements
SELECT e.* FROM main.elements e
JOIN main.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "meetings ($SRC_MEETINGS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.meetings
SELECT * FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';
DETACH nas;
"
# ─── FTS UPDATE ───────────────────────────────────────────────────────────
step "Updating FTS indexes"
run_sqlite_heredoc "elements_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.elements_fts(rowid, text, role)
SELECT e.id, e.text, e.role
FROM nas.elements e
JOIN nas.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE'
AND e.text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "frames_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)
SELECT id, full_text, app_name, window_name, browser_url, id
FROM nas.frames
WHERE date(timestamp) = '$TARGET_DATE'
AND full_text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "ui_events_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)
SELECT id, text_content, app_name, window_title, element_name
FROM nas.ui_events
WHERE date(timestamp) = '$TARGET_DATE'
AND text_content IS NOT NULL;
DETACH nas;
"
# ─── VERIFY DB ────────────────────────────────────────────────────────────
step "Verifying DB"
V_FRAMES=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
V_ELEMENTS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_UI=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
V_OCR=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_MEETINGS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';")
check "frames" "$V_FRAMES" "$SRC_FRAMES"
check "elements" "$V_ELEMENTS" "$SRC_ELEMENTS"
check "ui_events" "$V_UI" "$SRC_UI"
check "ocr_text" "$V_OCR" "$SRC_OCR"
check "meetings" "$V_MEETINGS" "$SRC_MEETINGS"
fi
# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────
# Always runs regardless of DB sync status
step "Copying data folder for $TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
mkdir -p "$NAS_DATA/$TARGET_DATE"
RSYNC_START=$(date +%s)
printf " %-36s " "rsync $TARGET_DATE/ → NAS"
rsync -a --ignore-existing \
"$DATA_SRC/" \
"$NAS_DATA/$TARGET_DATE/" \
2>>"$LOG_FILE"
RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))
COPIED_FILES=$(ls "$NAS_DATA/$TARGET_DATE" | wc -l | tr -d ' ')
SRC_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
COPIED_SIZE=$(du -sh "$NAS_DATA/$TARGET_DATE" | cut -f1)
if [ "$COPIED_FILES" -eq "$SRC_FILES" ]; then
printf "\r %-36s ✓ %dm%02ds (%s files, %s)\n" \
"rsync $TARGET_DATE/ → NAS" \
"$(( RSYNC_DUR / 60 ))" "$(( RSYNC_DUR % 60 ))" \
"$COPIED_FILES" "$COPIED_SIZE" | tee -a "$LOG_FILE"
else
printf "\r %-36s ✗ %s / %s files\n" \
"rsync $TARGET_DATE/ → NAS" "$COPIED_FILES" "$SRC_FILES" | tee -a "$LOG_FILE"
fi
else
printf " %-36s %s\n" "rsync $TARGET_DATE/ → NAS" "skipped (no source dir)"
fi
# ─── SUMMARY ──────────────────────────────────────────────────────────────────
TOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))
DB_SIZE=$(du -sh "$NAS_DB" | cut -f1)
echo ""
log "Archive DB size: $DB_SIZE"
log "Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s"
log "Sync complete for $TARGET_DATE"
log "========================================"
#!/bin/bash
# screenpipe_sync.sh
# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).
# Also copies the day's video/frame data folder to the NAS.
#
# Usage:
# ./screenpipe_sync.sh # syncs yesterday (default)
# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date
# ./screenpipe_sync.sh today # syncs today so far
#
# Cron example (runs at 3am daily):
# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1
set -euo pipefail
# ─── CONFIG ───────────────────────────────────────────────────────────────────
DB_SRC="${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}"
NAS_MOUNT="${NAS_MOUNT:-/Volumes/Test/screenpipe}"
NAS_DB="$NAS_MOUNT/archive.db"
NAS_DATA="$NAS_MOUNT/data"
LOG_FILE="$HOME/.screenpipe/sync.log"
# ──────────────────────────────────────────────────────────────────────────────
# ─── HELPERS ──────────────────────────────────────────────────────────────────
SCRIPT_START=$(date +%s)
log() {
local msg="[$(date '+%Y-%m-%d %H:%M:%S')] $*"
echo "$msg" | tee -a "$LOG_FILE"
}
step() {
local now=$(date +%s)
local elapsed=$(( now - SCRIPT_START ))
local min=$(( elapsed / 60 ))
local sec=$(( elapsed % 60 ))
printf "\n[+%02dm%02ds] ▶ %s\n" "$min" "$sec" "$*" | tee -a "$LOG_FILE"
}
run_sqlite_heredoc() {
local label="$1"
local sql="$2"
local start=$(date +%s)
printf " %-36s " "$label"
sqlite3 "$DB_SRC" <<< "$sql" &
local pid=$!
local spin=[PASSWORD] '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')
local i=0
while kill -0 "$pid" 2>/dev/null; do
printf "\r %-36s %s " "$label" "${spin[$i]}"
i=$(( (i + 1) % 10 ))
sleep 0.2
done
wait "$pid"
local rc=$?
if [ $rc -ne 0 ]; then
printf "\r %-36s ✗ FAILED\n" "$label" | tee -a "$LOG_FILE"
exit $rc
fi
local dur=$(( $(date +%s) - start ))
printf "\r %-36s ✓ %dm%02ds\n" "$label" "$(( dur / 60 ))" "$(( dur % 60 ))" | tee -a "$LOG_FILE"
}
check() {
local label="$1" got="$2" expected="$3"
if [ "$got" -eq "$expected" ]; then
printf " %-20s %s / %s ✓\n" "$label:" "$got" "$expected"
else
printf " %-20s %s / %s ✗ MISMATCH\n" "$label:" "$got" "$expected"
fi
}
# ──────────────────────────────────────────────────────────────────────────────
# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────
if [ "${1:-}" = "today" ]; then
TARGET_DATE=$(date +%Y-%m-%d)
elif [ -n "${1:-}" ]; then
TARGET_DATE="$1"
if ! [[ "$TARGET_DATE" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then
echo "ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday."
exit 1
fi
else
TARGET_DATE=$(date -v-1d +%Y-%m-%d)
fi
log "========================================"
log "Screenpipe sync starting for: $TARGET_DATE"
log "========================================"
# ─── PREFLIGHT ────────────────────────────────────────────────────────────────
step "Preflight checks"
if [ ! -f "$DB_SRC" ]; then
log "ERROR: Source DB not found at $DB_SRC"; exit 1
fi
printf " %-20s %s (%s)\n" "Source DB:" "OK" "$(du -sh "$DB_SRC" | cut -f1)"
if [ ! -d "$NAS_MOUNT" ]; then
log "ERROR: NAS not mounted at $NAS_MOUNT"; exit 1
fi
printf " %-20s %s\n" "NAS mount:" "OK $NAS_MOUNT"
# Check if DB already synced for this date
DB_ALREADY_SYNCED=false
if [ -f "$NAS_DB" ]; then
EXISTING=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';" 2>/dev/null || echo "0")
if [ "$EXISTING" -gt "0" ]; then
log "Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync"
DB_ALREADY_SYNCED=true
else
printf " %-20s %s (%s)\n" "Archive DB:" "exists" "$(du -sh "$NAS_DB" | cut -f1)"
fi
else
printf " %-20s %s\n" "Archive DB:" "will be created"
fi
# Source data dir for this date
DATA_SRC="$HOME/.screenpipe/data/data/$TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
DATA_SIZE=$(du -sh "$DATA_SRC" | cut -f1)
DATA_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
printf " %-20s %s (%s files, %s)\n" "Data dir:" "OK" "$DATA_FILES" "$DATA_SIZE"
else
printf " %-20s %s\n" "Data dir:" "not found — skipping file copy"
fi
# ─── DB SYNC ──────────────────────────────────────────────────────────────────
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────
step "Counting source rows for $TARGET_DATE"
SRC_FRAMES=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
SRC_ELEMENTS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_UI=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
SRC_OCR=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_MEETINGS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';")
printf " %-20s %s\n" "frames:" "$SRC_FRAMES"
printf " %-20s %s\n" "elements:" "$SRC_ELEMENTS"
printf " %-20s %s\n" "ui_events:" "$SRC_UI"
printf " %-20s %s\n" "ocr_text:" "$SRC_OCR"
printf " %-20s %s\n" "meetings:" "$SRC_MEETINGS"
if [ "$SRC_FRAMES" -eq "0" ]; then
log "No frames found for $TARGET_DATE — skipping DB sync"
DB_ALREADY_SYNCED=true
fi
fi
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── INIT TABLES ──────────────────────────────────────────────────────────
step "Initialising tables, indexes, FTS"
run_sqlite_heredoc "creating tables" "
ATTACH '$NAS_DB' AS nas;
CREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;
CREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;
CREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;
CREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;
DETACH nas;
"
run_sqlite_heredoc "creating indexes" "
ATTACH '$NAS_DB' AS nas;
CREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);
CREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);
DETACH nas;
"
run_sqlite_heredoc "creating FTS tables" "
ATTACH '$NAS_DB' AS nas;
CREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(
text, role, frame_id UNINDEXED,
content='elements', content_rowid='id', tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(
full_text, app_name, window_name, browser_url, id UNINDEXED,
tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(
text_content,
app_name,
window_title,
element_name,
content='ui_events',
content_rowid='id',
tokenize='unicode61'
);
DETACH nas;
"
# ─── SYNC DATA ────────────────────────────────────────────────────────────
step "Syncing data for $TARGET_DATE"
run_sqlite_heredoc "video_chunks" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.video_chunks
SELECT * FROM main.video_chunks
WHERE id IN (
SELECT DISTINCT video_chunk_id FROM main.frames
WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL
);
DETACH nas;
"
run_sqlite_heredoc "frames ($SRC_FRAMES rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.frames
SELECT * FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ocr_text ($SRC_OCR rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ocr_text
SELECT o.* FROM main.ocr_text o
JOIN main.frames f ON o.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ui_events ($SRC_UI rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ui_events
SELECT * FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "elements ($SRC_ELEMENTS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.elements
SELECT e.* FROM main.elements e
JOIN main.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "meetings ($SRC_MEETINGS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.meetings
SELECT * FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';
DETACH nas;
"
# ─── FTS UPDATE ───────────────────────────────────────────────────────────
step "Updating FTS indexes"
run_sqlite_heredoc "elements_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.elements_fts(rowid, text, role)
SELECT e.id, e.text, e.role
FROM nas.elements e
JOIN nas.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE'
AND e.text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "frames_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)
SELECT id, full_text, app_name, window_name, browser_url, id
FROM nas.frames
WHERE date(timestamp) = '$TARGET_DATE'
AND full_text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "ui_events_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)
SELECT id, text_content, app_name, window_title, element_name
FROM nas.ui_events
WHERE date(timestamp) = '$TARGET_DATE'
AND text_content IS NOT NULL;
DETACH nas;
"
# ─── VERIFY DB ────────────────────────────────────────────────────────────
step "Verifying DB"
V_FRAMES=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
V_ELEMENTS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_UI=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
V_OCR=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_MEETINGS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';")
check "frames" "$V_FRAMES" "$SRC_FRAMES"
check "elements" "$V_ELEMENTS" "$SRC_ELEMENTS"
check "ui_events" "$V_UI" "$SRC_UI"
check "ocr_text" "$V_OCR" "$SRC_OCR"
check "meetings" "$V_MEETINGS" "$SRC_MEETINGS"
fi
# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────
# Always runs regardless of DB sync status
step "Copying data folder for $TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
mkdir -p "$NAS_DATA/$TARGET_DATE"
RSYNC_START=$(date +%s)
printf " %-36s " "rsync $TARGET_DATE/ → NAS"
rsync -a --ignore-existing \
"$DATA_SRC/" \
"$NAS_DATA/$TARGET_DATE/" \
2>>"$LOG_FILE"
RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))
COPIED_FILES=$(ls "$NAS_DATA/$TARGET_DATE" | wc -l | tr -d ' ')
SRC_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
COPIED_SIZE=$(du -sh "$NAS_DATA/$TARGET_DATE" | cut -f1)
if [ "$COPIED_FILES" -eq "$SRC_FILES" ]; then
printf "\r %-36s ✓ %dm%02ds (%s files, %s)\n" \
"rsync $TARGET_DATE/ → NAS" \
"$(( RSYNC_DUR / 60 ))" "$(( RSYNC_DUR % 60 ))" \
"$COPIED_FILES" "$COPIED_SIZE" | tee -a "$LOG_FILE"
else
printf "\r %-36s ✗ %s / %s files\n" \
"rsync $TARGET_DATE/ → NAS" "$COPIED_FILES" "$SRC_FILES" | tee -a "$LOG_FILE"
fi
else
printf " %-36s %s\n" "rsync $TARGET_DATE/ → NAS" "skipped (no source dir)"
fi
# ─── SUMMARY ──────────────────────────────────────────────────────────────────
TOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))
DB_SIZE=$(du -sh "$NAS_DB" | cut -f1)
echo ""
log "Archive DB size: $DB_SIZE"
log "Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s"
log "Sync complete for $TARGET_DATE"
log "========================================"
Implement and run pipe l…, Editor Group 2
Problems (⇧⌘M)
PROBLEMS
Output (⇧⌘U)
OUTPUT
Debug Console (⇧⌘Y)
DEBUG CONSOLE
Terminal (⌃`)
TERMINAL
Ports - 1 forwarded port
PORTS
1
remote SSH: nas
SSH: nas
screenpipe (Git) - master*, Checkout Branch/Tag...
master*
screenpipe (Git) - Synchronize Changes
No Problems
0
0
Forwarded Ports: 8766
1
Notifications
Sign In
Sign In
Shell Script
Editor Language Status: $(copilot) No inline suggestion available, Inline suggestions
LF
UTF-8
Spaces: 2
Ln 29, Col 35
git-commit Lukas Kovalik (2 weeks ago)
Lukas Kovalik (2 weeks ago)
No results found
Implement and run pipe logic
Session history
New session
Message actions
main.py
main.py
lets implement logic with pipes. how can I run it?
Thinking
Thinking
Let me look at the current project structure to understand what's already in place.
Bash
List project files
IN
find /volume1/screenpipe -type f | head -50 && echo "---" && ls /volume1/screenpipe
Copy code to clipboard
OUT
/volume1/screenpipe/.DS_Store
/volume1/screenpipe/screenpipe.db
/volume1/screenpipe/screenpipe_sync.sh
/volume1/screenpipe/app_settings.json
/volume1/screenpipe/.gitignore
/volume1/screenpipe/archive.db
/volume1/screenpipe/db.sqlite
/volume1/screenpipe/db.sqlite-wal
/volume1/screenpipe/db.sqlite-shm
/volume1/screenpipe/#recycle/desktop.ini
/volume1/screenpipe/#recycle/db.sqlite
/volume1/screenpipe/#recycle/Copy #1 of db.sqlite
/volume1/screenpipe/#recycle/.DS_Store
/volume1/screenpipe/#recycle/Copy #2 of db.sqlite
/volume1/screenpipe/#recycle/archive.db
/volume1/screenpipe/#recycle/Copy #1 of archive.db
/volume1/screenpipe/#recycle/Copy #2 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of archive.db
/volume1/screenpipe/#recycle/Copy #4 of archive.db
/volume1/screenpipe/#recycle/Copy #5 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of db.sqlite
/volume1/screenpipe/#recycle/Copy #4 of db.sqlite
/volume1/screenpipe/#recycle/Copy #6 of archive.db
/volume1/screenpipe/#recycle/test.txt
/volume1/screenpipe/#recycle/Copy #7 of archive.db
/volume1/screenpipe/#recycle/Copy #8 of archive.db
/volume1/screenpipe/#recycle/archive.db-journal
/volume1/screenpipe/#recycle/Copy #1 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #2 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #3 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #4 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #6 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #7 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of db.sqlite
/volume1/screenpipe/pipes/.DS_Store
/volume1/screenpipe/app/.env
/volume1/screenpipe/app/cli.py
/volume1/screenpipe/app/.DS_Store
/volume1/screenpipe/app/db.py
/volume1/screenpipe/app/docker-compose.yml
/volume1/screenpipe/app/main.py
/volume1/screenpipe/app/requirements.txt
/volume1/screenpipe/app/Dockerfile
/volume1/screenpipe/data/.DS_Store
/volume1/screenpipe/.git/description
/volume1/screenpipe/.git/HEAD
/volume1/screenpipe/.git/index
/volume1/screenpipe/.git/COMMIT_EDITMSG
/volume1/screenpipe/#recycle/data/.DS_Store
---
app
app_settings.json
archive.db
data
db.sqlite
db.sqlite-shm
db.sqlite-wal
pipes
#recycle
screenpipe.db
screenpipe_sync.sh
Read
main.py
main.py
Bash
Check pipes directory and docker-compose
IN
ls /volume1/screenpipe/pipes/ && ls /volume1/screenpipe/app/ && cat /volume1/screenpipe/app/docker-compose.yml
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
cli.py
consumers
db.py
docker-compose.yml
Dockerfile
main.py
__pycache__
requirements.txt
static
services:
screenpipe-app:
build: .
container_name: screenpipe-app
restart: unless-stopped
ports:
- "8766:8000"
volumes:
- /volume1/screenpipe:/data
env_file:
- .env
environment:
TZ: Europe/Sofia
DB_PATH: /data/db.sqlite
sqlite-web-archive:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-archive
restart: unless-stopped
ports:
- "8767:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/archive.db"]
sqlite-web-live:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-live
restart: unless-stopped
ports:
- "8768:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/db.sqlite"]
Read
requirements.txt
requirements.txt
Bash
Inspect a pipe directory
IN
ls /volume1/screenpipe/pipes/day-recap/ && cat /volume1/screenpipe/pipes/day-recap/pipe.json 2>/dev/null || ls /volume1/screenpipe/pipes/day-recap/
Copy code to clipboard...
|
[{"role":"AXRadioButton","text [{"role":"AXRadioButton","text":"Explorer (⇧⌘E)","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":true},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Search (⇧⌘F)","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Source Control (⌃⇧G) - 10 pending changes","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"10","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Run and Debug (⇧⌘D)","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Remote Explorer","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Extensions (⇧⌘X) - 2 require update","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"2","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Claude Code","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"Containers","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXHeading","text":"EXPLORER","depth":17,"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"EXPLORER","depth":18,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Explorer Section: screenpipe [SSH: nas]","depth":21,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":true},{"role":"AXStaticText","text":"","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"Explorer Section: screenpipe [SSH: nas]","depth":22,"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"SCREENPIPE [SSH: NAS]","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"#recycle","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"app","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"__pycache__","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"consumers","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"static","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":".env","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"cli.py","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.py","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"docker-compose.yml","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Dockerfile","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"main.py","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"requirements.txt","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"data","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"logs","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"pipes","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":".gitignore","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"app_settings.json","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"archive.db","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"archive.db-bak","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"U","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite-shm","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite-wal","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe_sync_updated.sh","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"U","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe_sync.sh","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe.db","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Outline Section","depth":21,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"OUTLINE","depth":22,"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"OUTLINE","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Timeline Section","depth":21,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"TIMELINE","depth":22,"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"TIMELINE","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"app_settings.json, Editor Group 1","depth":28,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"screenpipe_sync.sh, Editor Group 1","depth":28,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":false},{"role":"AXRadioButton","text":"pipe.md, Editor Group 1","depth":28,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":".env, Editor Group 1","depth":28,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"#!/bin/bash\n# screenpipe_sync.sh\n# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).\n# Also copies the day's video/frame data folder to the NAS.\n#\n# Usage:\n# ./screenpipe_sync.sh # syncs yesterday (default)\n# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date\n# ./screenpipe_sync.sh today # syncs today so far\n#\n# Cron example (runs at 3am daily):\n# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1\n\nset -euo pipefail\n\n# ─── CONFIG ───────────────────────────────────────────────────────────────────\nDB_SRC=\"${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}\"\nNAS_MOUNT=\"${NAS_MOUNT:-/Volumes/Test/screenpipe}\"\nNAS_DB=\"$NAS_MOUNT/archive.db\"\nNAS_DATA=\"$NAS_MOUNT/data\"\nLOG_FILE=\"$HOME/.screenpipe/sync.log\"\n# ──────────────────────────────────────────────────────────────────────────────\n\n# ─── HELPERS ──────────────────────────────────────────────────────────────────\nSCRIPT_START=$(date +%s)\n\nlog() {\n local msg=\"[$(date '+%Y-%m-%d %H:%M:%S')] $*\"\n echo \"$msg\" | tee -a \"$LOG_FILE\"\n}\n\nstep() {\n local now=$(date +%s)\n local elapsed=$(( now - SCRIPT_START ))\n local min=$(( elapsed / 60 ))\n local sec=$(( elapsed % 60 ))\n printf \"\\n[+%02dm%02ds] ▶ %s\\n\" \"$min\" \"$sec\" \"$*\" | tee -a \"$LOG_FILE\"\n}\n\nrun_sqlite_heredoc() {\n local label=\"$1\"\n local sql=\"$2\"\n local start=$(date +%s)\n\n printf \" %-36s \" \"$label\"\n\n sqlite3 \"$DB_SRC\" <<< \"$sql\" &\n local pid=$!\n local spin=('⠋' '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')\n local i=0\n while kill -0 \"$pid\" 2>/dev/null; do\n printf \"\\r %-36s %s \" \"$label\" \"${spin[$i]}\"\n i=$(( (i + 1) % 10 ))\n sleep 0.2\n done\n wait \"$pid\"\n local rc=$?\n if [ $rc -ne 0 ]; then\n printf \"\\r %-36s ✗ FAILED\\n\" \"$label\" | tee -a \"$LOG_FILE\"\n exit $rc\n fi\n\n local dur=$(( $(date +%s) - start ))\n printf \"\\r %-36s ✓ %dm%02ds\\n\" \"$label\" \"$(( dur / 60 ))\" \"$(( dur % 60 ))\" | tee -a \"$LOG_FILE\"\n}\n\ncheck() {\n local label=\"$1\" got=\"$2\" expected=\"$3\"\n if [ \"$got\" -eq \"$expected\" ]; then\n printf \" %-20s %s / %s ✓\\n\" \"$label:\" \"$got\" \"$expected\"\n else\n printf \" %-20s %s / %s ✗ MISMATCH\\n\" \"$label:\" \"$got\" \"$expected\"\n fi\n}\n# ──────────────────────────────────────────────────────────────────────────────\n\n# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────\nif [ \"${1:-}\" = \"today\" ]; then\n TARGET_DATE=$(date +%Y-%m-%d)\nelif [ -n \"${1:-}\" ]; then\n TARGET_DATE=\"$1\"\n if ! [[ \"$TARGET_DATE\" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then\n echo \"ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday.\"\n exit 1\n fi\nelse\n TARGET_DATE=$(date -v-1d +%Y-%m-%d)\nfi\n\nlog \"========================================\"\nlog \"Screenpipe sync starting for: $TARGET_DATE\"\nlog \"========================================\"\n\n# ─── PREFLIGHT ────────────────────────────────────────────────────────────────\nstep \"Preflight checks\"\n\nif [ ! -f \"$DB_SRC\" ]; then\n log \"ERROR: Source DB not found at $DB_SRC\"; exit 1\nfi\nprintf \" %-20s %s (%s)\\n\" \"Source DB:\" \"OK\" \"$(du -sh \"$DB_SRC\" | cut -f1)\"\n\nif [ ! -d \"$NAS_MOUNT\" ]; then\n log \"ERROR: NAS not mounted at $NAS_MOUNT\"; exit 1\nfi\nprintf \" %-20s %s\\n\" \"NAS mount:\" \"OK $NAS_MOUNT\"\n\n# Check if DB already synced for this date\nDB_ALREADY_SYNCED=false\nif [ -f \"$NAS_DB\" ]; then\n EXISTING=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\" 2>/dev/null || echo \"0\")\n if [ \"$EXISTING\" -gt \"0\" ]; then\n log \"Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync\"\n DB_ALREADY_SYNCED=true\n else\n printf \" %-20s %s (%s)\\n\" \"Archive DB:\" \"exists\" \"$(du -sh \"$NAS_DB\" | cut -f1)\"\n fi\nelse\n printf \" %-20s %s\\n\" \"Archive DB:\" \"will be created\"\nfi\n\n# Source data dir for this date\nDATA_SRC=\"$HOME/.screenpipe/data/data/$TARGET_DATE\"\nif [ -d \"$DATA_SRC\" ]; then\n DATA_SIZE=$(du -sh \"$DATA_SRC\" | cut -f1)\n DATA_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n printf \" %-20s %s (%s files, %s)\\n\" \"Data dir:\" \"OK\" \"$DATA_FILES\" \"$DATA_SIZE\"\nelse\n printf \" %-20s %s\\n\" \"Data dir:\" \"not found — skipping file copy\"\nfi\n\n# ─── DB SYNC ──────────────────────────────────────────────────────────────────\nif [ \"$DB_ALREADY_SYNCED\" = false ]; then\n\n # ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────\n step \"Counting source rows for $TARGET_DATE\"\n\n SRC_FRAMES=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\")\n SRC_ELEMENTS=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n SRC_UI=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';\")\n SRC_OCR=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n SRC_MEETINGS=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';\")\n\n printf \" %-20s %s\\n\" \"frames:\" \"$SRC_FRAMES\"\n printf \" %-20s %s\\n\" \"elements:\" \"$SRC_ELEMENTS\"\n printf \" %-20s %s\\n\" \"ui_events:\" \"$SRC_UI\"\n printf \" %-20s %s\\n\" \"ocr_text:\" \"$SRC_OCR\"\n printf \" %-20s %s\\n\" \"meetings:\" \"$SRC_MEETINGS\"\n\n if [ \"$SRC_FRAMES\" -eq \"0\" ]; then\n log \"No frames found for $TARGET_DATE — skipping DB sync\"\n DB_ALREADY_SYNCED=true\n fi\n\nfi\n\nif [ \"$DB_ALREADY_SYNCED\" = false ]; then\n\n # ─── INIT TABLES ──────────────────────────────────────────────────────────\n step \"Initialising tables, indexes, FTS\"\n\n run_sqlite_heredoc \"creating tables\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"creating indexes\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);\nCREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);\nCREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"creating FTS tables\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(\n text, role, frame_id UNINDEXED,\n content='elements', content_rowid='id', tokenize='unicode61'\n);\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(\n full_text, app_name, window_name, browser_url, id UNINDEXED,\n tokenize='unicode61'\n);\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(\n text_content,\n app_name,\n window_title,\n element_name,\n content='ui_events',\n content_rowid='id',\n tokenize='unicode61'\n);\nDETACH nas;\n\"\n\n # ─── SYNC DATA ────────────────────────────────────────────────────────────\n step \"Syncing data for $TARGET_DATE\"\n\n run_sqlite_heredoc \"video_chunks\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.video_chunks\n SELECT * FROM main.video_chunks\n WHERE id IN (\n SELECT DISTINCT video_chunk_id FROM main.frames\n WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL\n );\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames ($SRC_FRAMES rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.frames\n SELECT * FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ocr_text ($SRC_OCR rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ocr_text\n SELECT o.* FROM main.ocr_text o\n JOIN main.frames f ON o.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events ($SRC_UI rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ui_events\n SELECT * FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"elements ($SRC_ELEMENTS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.elements\n SELECT e.* FROM main.elements e\n JOIN main.frames f ON e.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"meetings ($SRC_MEETINGS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.meetings\n SELECT * FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n # ─── FTS UPDATE ───────────────────────────────────────────────────────────\n step \"Updating FTS indexes\"\n\n run_sqlite_heredoc \"elements_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.elements_fts(rowid, text, role)\n SELECT e.id, e.text, e.role\n FROM nas.elements e\n JOIN nas.frames f ON e.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE'\n AND e.text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)\n SELECT id, full_text, app_name, window_name, browser_url, id\n FROM nas.frames\n WHERE date(timestamp) = '$TARGET_DATE'\n AND full_text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)\n SELECT id, text_content, app_name, window_title, element_name\n FROM nas.ui_events\n WHERE date(timestamp) = '$TARGET_DATE'\n AND text_content IS NOT NULL;\nDETACH nas;\n\"\n\n # ─── VERIFY DB ────────────────────────────────────────────────────────────\n step \"Verifying DB\"\n\n V_FRAMES=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\")\n V_ELEMENTS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n V_UI=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';\")\n V_OCR=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n V_MEETINGS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';\")\n\n check \"frames\" \"$V_FRAMES\" \"$SRC_FRAMES\"\n check \"elements\" \"$V_ELEMENTS\" \"$SRC_ELEMENTS\"\n check \"ui_events\" \"$V_UI\" \"$SRC_UI\"\n check \"ocr_text\" \"$V_OCR\" \"$SRC_OCR\"\n check \"meetings\" \"$V_MEETINGS\" \"$SRC_MEETINGS\"\n\nfi\n\n# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────\n# Always runs regardless of DB sync status\nstep \"Copying data folder for $TARGET_DATE\"\n\nif [ -d \"$DATA_SRC\" ]; then\n mkdir -p \"$NAS_DATA/$TARGET_DATE\"\n RSYNC_START=$(date +%s)\n printf \" %-36s \" \"rsync $TARGET_DATE/ → NAS\"\n rsync -a --ignore-existing \\\n \"$DATA_SRC/\" \\\n \"$NAS_DATA/$TARGET_DATE/\" \\\n 2>>\"$LOG_FILE\"\n RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))\n COPIED_FILES=$(ls \"$NAS_DATA/$TARGET_DATE\" | wc -l | tr -d ' ')\n SRC_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n COPIED_SIZE=$(du -sh \"$NAS_DATA/$TARGET_DATE\" | cut -f1)\n if [ \"$COPIED_FILES\" -eq \"$SRC_FILES\" ]; then\n printf \"\\r %-36s ✓ %dm%02ds (%s files, %s)\\n\" \\\n \"rsync $TARGET_DATE/ → NAS\" \\\n \"$(( RSYNC_DUR / 60 ))\" \"$(( RSYNC_DUR % 60 ))\" \\\n \"$COPIED_FILES\" \"$COPIED_SIZE\" | tee -a \"$LOG_FILE\"\n else\n printf \"\\r %-36s ✗ %s / %s files\\n\" \\\n \"rsync $TARGET_DATE/ → NAS\" \"$COPIED_FILES\" \"$SRC_FILES\" | tee -a \"$LOG_FILE\"\n fi\nelse\n printf \" %-36s %s\\n\" \"rsync $TARGET_DATE/ → NAS\" \"skipped (no source dir)\"\nfi\n\n# ─── SUMMARY ──────────────────────────────────────────────────────────────────\nTOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))\nDB_SIZE=$(du -sh \"$NAS_DB\" | cut -f1)\n\necho \"\"\nlog \"Archive DB size: $DB_SIZE\"\nlog \"Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s\"\nlog \"Sync complete for $TARGET_DATE\"\nlog \"========================================\"","depth":28,"on_screen":true,"value":"#!/bin/bash\n# screenpipe_sync.sh\n# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).\n# Also copies the day's video/frame data folder to the NAS.\n#\n# Usage:\n# ./screenpipe_sync.sh # syncs yesterday (default)\n# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date\n# ./screenpipe_sync.sh today # syncs today so far\n#\n# Cron example (runs at 3am daily):\n# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1\n\nset -euo pipefail\n\n# ─── CONFIG ───────────────────────────────────────────────────────────────────\nDB_SRC=\"${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}\"\nNAS_MOUNT=\"${NAS_MOUNT:-/Volumes/Test/screenpipe}\"\nNAS_DB=\"$NAS_MOUNT/archive.db\"\nNAS_DATA=\"$NAS_MOUNT/data\"\nLOG_FILE=\"$HOME/.screenpipe/sync.log\"\n# ──────────────────────────────────────────────────────────────────────────────\n\n# ─── HELPERS ──────────────────────────────────────────────────────────────────\nSCRIPT_START=$(date +%s)\n\nlog() {\n local msg=\"[$(date '+%Y-%m-%d %H:%M:%S')] $*\"\n echo \"$msg\" | tee -a \"$LOG_FILE\"\n}\n\nstep() {\n local now=$(date +%s)\n local elapsed=$(( now - SCRIPT_START ))\n local min=$(( elapsed / 60 ))\n local sec=$(( elapsed % 60 ))\n printf \"\\n[+%02dm%02ds] ▶ %s\\n\" \"$min\" \"$sec\" \"$*\" | tee -a \"$LOG_FILE\"\n}\n\nrun_sqlite_heredoc() {\n local label=\"$1\"\n local sql=\"$2\"\n local start=$(date +%s)\n\n printf \" %-36s \" \"$label\"\n\n sqlite3 \"$DB_SRC\" <<< \"$sql\" &\n local pid=$!\n local spin=('⠋' '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')\n local i=0\n while kill -0 \"$pid\" 2>/dev/null; do\n printf \"\\r %-36s %s \" \"$label\" \"${spin[$i]}\"\n i=$(( (i + 1) % 10 ))\n sleep 0.2\n done\n wait \"$pid\"\n local rc=$?\n if [ $rc -ne 0 ]; then\n printf \"\\r %-36s ✗ FAILED\\n\" \"$label\" | tee -a \"$LOG_FILE\"\n exit $rc\n fi\n\n local dur=$(( $(date +%s) - start ))\n printf \"\\r %-36s ✓ %dm%02ds\\n\" \"$label\" \"$(( dur / 60 ))\" \"$(( dur % 60 ))\" | tee -a \"$LOG_FILE\"\n}\n\ncheck() {\n local label=\"$1\" got=\"$2\" expected=\"$3\"\n if [ \"$got\" -eq \"$expected\" ]; then\n printf \" %-20s %s / %s ✓\\n\" \"$label:\" \"$got\" \"$expected\"\n else\n printf \" %-20s %s / %s ✗ MISMATCH\\n\" \"$label:\" \"$got\" \"$expected\"\n fi\n}\n# ──────────────────────────────────────────────────────────────────────────────\n\n# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────\nif [ \"${1:-}\" = \"today\" ]; then\n TARGET_DATE=$(date +%Y-%m-%d)\nelif [ -n \"${1:-}\" ]; then\n TARGET_DATE=\"$1\"\n if ! [[ \"$TARGET_DATE\" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then\n echo \"ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday.\"\n exit 1\n fi\nelse\n TARGET_DATE=$(date -v-1d +%Y-%m-%d)\nfi\n\nlog \"========================================\"\nlog \"Screenpipe sync starting for: $TARGET_DATE\"\nlog \"========================================\"\n\n# ─── PREFLIGHT ────────────────────────────────────────────────────────────────\nstep \"Preflight checks\"\n\nif [ ! -f \"$DB_SRC\" ]; then\n log \"ERROR: Source DB not found at $DB_SRC\"; exit 1\nfi\nprintf \" %-20s %s (%s)\\n\" \"Source DB:\" \"OK\" \"$(du -sh \"$DB_SRC\" | cut -f1)\"\n\nif [ ! -d \"$NAS_MOUNT\" ]; then\n log \"ERROR: NAS not mounted at $NAS_MOUNT\"; exit 1\nfi\nprintf \" %-20s %s\\n\" \"NAS mount:\" \"OK $NAS_MOUNT\"\n\n# Check if DB already synced for this date\nDB_ALREADY_SYNCED=false\nif [ -f \"$NAS_DB\" ]; then\n EXISTING=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\" 2>/dev/null || echo \"0\")\n if [ \"$EXISTING\" -gt \"0\" ]; then\n log \"Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync\"\n DB_ALREADY_SYNCED=true\n else\n printf \" %-20s %s (%s)\\n\" \"Archive DB:\" \"exists\" \"$(du -sh \"$NAS_DB\" | cut -f1)\"\n fi\nelse\n printf \" %-20s %s\\n\" \"Archive DB:\" \"will be created\"\nfi\n\n# Source data dir for this date\nDATA_SRC=\"$HOME/.screenpipe/data/data/$TARGET_DATE\"\nif [ -d \"$DATA_SRC\" ]; then\n DATA_SIZE=$(du -sh \"$DATA_SRC\" | cut -f1)\n DATA_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n printf \" %-20s %s (%s files, %s)\\n\" \"Data dir:\" \"OK\" \"$DATA_FILES\" \"$DATA_SIZE\"\nelse\n printf \" %-20s %s\\n\" \"Data dir:\" \"not found — skipping file copy\"\nfi\n\n# ─── DB SYNC ──────────────────────────────────────────────────────────────────\nif [ \"$DB_ALREADY_SYNCED\" = false ]; then\n\n # ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────\n step \"Counting source rows for $TARGET_DATE\"\n\n SRC_FRAMES=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\")\n SRC_ELEMENTS=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n SRC_UI=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';\")\n SRC_OCR=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n SRC_MEETINGS=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';\")\n\n printf \" %-20s %s\\n\" \"frames:\" \"$SRC_FRAMES\"\n printf \" %-20s %s\\n\" \"elements:\" \"$SRC_ELEMENTS\"\n printf \" %-20s %s\\n\" \"ui_events:\" \"$SRC_UI\"\n printf \" %-20s %s\\n\" \"ocr_text:\" \"$SRC_OCR\"\n printf \" %-20s %s\\n\" \"meetings:\" \"$SRC_MEETINGS\"\n\n if [ \"$SRC_FRAMES\" -eq \"0\" ]; then\n log \"No frames found for $TARGET_DATE — skipping DB sync\"\n DB_ALREADY_SYNCED=true\n fi\n\nfi\n\nif [ \"$DB_ALREADY_SYNCED\" = false ]; then\n\n # ─── INIT TABLES ──────────────────────────────────────────────────────────\n step \"Initialising tables, indexes, FTS\"\n\n run_sqlite_heredoc \"creating tables\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"creating indexes\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);\nCREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);\nCREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"creating FTS tables\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(\n text, role, frame_id UNINDEXED,\n content='elements', content_rowid='id', tokenize='unicode61'\n);\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(\n full_text, app_name, window_name, browser_url, id UNINDEXED,\n tokenize='unicode61'\n);\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(\n text_content,\n app_name,\n window_title,\n element_name,\n content='ui_events',\n content_rowid='id',\n tokenize='unicode61'\n);\nDETACH nas;\n\"\n\n # ─── SYNC DATA ────────────────────────────────────────────────────────────\n step \"Syncing data for $TARGET_DATE\"\n\n run_sqlite_heredoc \"video_chunks\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.video_chunks\n SELECT * FROM main.video_chunks\n WHERE id IN (\n SELECT DISTINCT video_chunk_id FROM main.frames\n WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL\n );\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames ($SRC_FRAMES rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.frames\n SELECT * FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ocr_text ($SRC_OCR rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ocr_text\n SELECT o.* FROM main.ocr_text o\n JOIN main.frames f ON o.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events ($SRC_UI rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ui_events\n SELECT * FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"elements ($SRC_ELEMENTS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.elements\n SELECT e.* FROM main.elements e\n JOIN main.frames f ON e.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"meetings ($SRC_MEETINGS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.meetings\n SELECT * FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n # ─── FTS UPDATE ───────────────────────────────────────────────────────────\n step \"Updating FTS indexes\"\n\n run_sqlite_heredoc \"elements_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.elements_fts(rowid, text, role)\n SELECT e.id, e.text, e.role\n FROM nas.elements e\n JOIN nas.frames f ON e.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE'\n AND e.text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)\n SELECT id, full_text, app_name, window_name, browser_url, id\n FROM nas.frames\n WHERE date(timestamp) = '$TARGET_DATE'\n AND full_text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)\n SELECT id, text_content, app_name, window_title, element_name\n FROM nas.ui_events\n WHERE date(timestamp) = '$TARGET_DATE'\n AND text_content IS NOT NULL;\nDETACH nas;\n\"\n\n # ─── VERIFY DB ────────────────────────────────────────────────────────────\n step \"Verifying DB\"\n\n V_FRAMES=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\")\n V_ELEMENTS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n V_UI=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';\")\n V_OCR=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n V_MEETINGS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';\")\n\n check \"frames\" \"$V_FRAMES\" \"$SRC_FRAMES\"\n check \"elements\" \"$V_ELEMENTS\" \"$SRC_ELEMENTS\"\n check \"ui_events\" \"$V_UI\" \"$SRC_UI\"\n check \"ocr_text\" \"$V_OCR\" \"$SRC_OCR\"\n check \"meetings\" \"$V_MEETINGS\" \"$SRC_MEETINGS\"\n\nfi\n\n# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────\n# Always runs regardless of DB sync status\nstep \"Copying data folder for $TARGET_DATE\"\n\nif [ -d \"$DATA_SRC\" ]; then\n mkdir -p \"$NAS_DATA/$TARGET_DATE\"\n RSYNC_START=$(date +%s)\n printf \" %-36s \" \"rsync $TARGET_DATE/ → NAS\"\n rsync -a --ignore-existing \\\n \"$DATA_SRC/\" \\\n \"$NAS_DATA/$TARGET_DATE/\" \\\n 2>>\"$LOG_FILE\"\n RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))\n COPIED_FILES=$(ls \"$NAS_DATA/$TARGET_DATE\" | wc -l | tr -d ' ')\n SRC_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n COPIED_SIZE=$(du -sh \"$NAS_DATA/$TARGET_DATE\" | cut -f1)\n if [ \"$COPIED_FILES\" -eq \"$SRC_FILES\" ]; then\n printf \"\\r %-36s ✓ %dm%02ds (%s files, %s)\\n\" \\\n \"rsync $TARGET_DATE/ → NAS\" \\\n \"$(( RSYNC_DUR / 60 ))\" \"$(( RSYNC_DUR % 60 ))\" \\\n \"$COPIED_FILES\" \"$COPIED_SIZE\" | tee -a \"$LOG_FILE\"\n else\n printf \"\\r %-36s ✗ %s / %s files\\n\" \\\n \"rsync $TARGET_DATE/ → NAS\" \"$COPIED_FILES\" \"$SRC_FILES\" | tee -a \"$LOG_FILE\"\n fi\nelse\n printf \" %-36s %s\\n\" \"rsync $TARGET_DATE/ → NAS\" \"skipped (no source dir)\"\nfi\n\n# ─── SUMMARY ──────────────────────────────────────────────────────────────────\nTOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))\nDB_SIZE=$(du -sh \"$NAS_DB\" | cut -f1)\n\necho \"\"\nlog \"Archive DB size: $DB_SIZE\"\nlog \"Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s\"\nlog \"Sync complete for $TARGET_DATE\"\nlog \"========================================\"","role_description":"editor","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"#!/bin/bash\n# screenpipe_sync.sh\n# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).\n# Also copies the day's video/frame data folder to the NAS.\n#\n# Usage:\n# ./screenpipe_sync.sh # syncs yesterday (default)\n# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date\n# ./screenpipe_sync.sh today # syncs today so far\n#\n# Cron example (runs at 3am daily):\n# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1\n\nset -euo pipefail\n\n# ─── CONFIG ───────────────────────────────────────────────────────────────────\nDB_SRC=\"${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}\"\nNAS_MOUNT=\"${NAS_MOUNT:-/Volumes/Test/screenpipe}\"\nNAS_DB=\"$NAS_MOUNT/archive.db\"\nNAS_DATA=\"$NAS_MOUNT/data\"\nLOG_FILE=\"$HOME/.screenpipe/sync.log\"\n# ──────────────────────────────────────────────────────────────────────────────\n\n# ─── HELPERS ──────────────────────────────────────────────────────────────────\nSCRIPT_START=$(date +%s)\n\nlog() {\n local msg=\"[$(date '+%Y-%m-%d %H:%M:%S')] $*\"\n echo \"$msg\" | tee -a \"$LOG_FILE\"\n}\n\nstep() {\n local now=$(date +%s)\n local elapsed=$(( now - SCRIPT_START ))\n local min=$(( elapsed / 60 ))\n local sec=$(( elapsed % 60 ))\n printf \"\\n[+%02dm%02ds] ▶ %s\\n\" \"$min\" \"$sec\" \"$*\" | tee -a \"$LOG_FILE\"\n}\n\nrun_sqlite_heredoc() {\n local label=\"$1\"\n local sql=\"$2\"\n local start=$(date +%s)\n\n printf \" %-36s \" \"$label\"\n\n sqlite3 \"$DB_SRC\" <<< \"$sql\" &\n local pid=$!\n local spin=('⠋' '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')\n local i=0\n while kill -0 \"$pid\" 2>/dev/null; do\n printf \"\\r %-36s %s \" \"$label\" \"${spin[$i]}\"\n i=$(( (i + 1) % 10 ))\n sleep 0.2\n done\n wait \"$pid\"\n local rc=$?\n if [ $rc -ne 0 ]; then\n printf \"\\r %-36s ✗ FAILED\\n\" \"$label\" | tee -a \"$LOG_FILE\"\n exit $rc\n fi\n\n local dur=$(( $(date +%s) - start ))\n printf \"\\r %-36s ✓ %dm%02ds\\n\" \"$label\" \"$(( dur / 60 ))\" \"$(( dur % 60 ))\" | tee -a \"$LOG_FILE\"\n}\n\ncheck() {\n local label=\"$1\" got=\"$2\" expected=\"$3\"\n if [ \"$got\" -eq \"$expected\" ]; then\n printf \" %-20s %s / %s ✓\\n\" \"$label:\" \"$got\" \"$expected\"\n else\n printf \" %-20s %s / %s ✗ MISMATCH\\n\" \"$label:\" \"$got\" \"$expected\"\n fi\n}\n# ──────────────────────────────────────────────────────────────────────────────\n\n# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────\nif [ \"${1:-}\" = \"today\" ]; then\n TARGET_DATE=$(date +%Y-%m-%d)\nelif [ -n \"${1:-}\" ]; then\n TARGET_DATE=\"$1\"\n if ! [[ \"$TARGET_DATE\" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then\n echo \"ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday.\"\n exit 1\n fi\nelse\n TARGET_DATE=$(date -v-1d +%Y-%m-%d)\nfi\n\nlog \"========================================\"\nlog \"Screenpipe sync starting for: $TARGET_DATE\"\nlog \"========================================\"\n\n# ─── PREFLIGHT ────────────────────────────────────────────────────────────────\nstep \"Preflight checks\"\n\nif [ ! -f \"$DB_SRC\" ]; then\n log \"ERROR: Source DB not found at $DB_SRC\"; exit 1\nfi\nprintf \" %-20s %s (%s)\\n\" \"Source DB:\" \"OK\" \"$(du -sh \"$DB_SRC\" | cut -f1)\"\n\nif [ ! -d \"$NAS_MOUNT\" ]; then\n log \"ERROR: NAS not mounted at $NAS_MOUNT\"; exit 1\nfi\nprintf \" %-20s %s\\n\" \"NAS mount:\" \"OK $NAS_MOUNT\"\n\n# Check if DB already synced for this date\nDB_ALREADY_SYNCED=false\nif [ -f \"$NAS_DB\" ]; then\n EXISTING=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\" 2>/dev/null || echo \"0\")\n if [ \"$EXISTING\" -gt \"0\" ]; then\n log \"Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync\"\n DB_ALREADY_SYNCED=true\n else\n printf \" %-20s %s (%s)\\n\" \"Archive DB:\" \"exists\" \"$(du -sh \"$NAS_DB\" | cut -f1)\"\n fi\nelse\n printf \" %-20s %s\\n\" \"Archive DB:\" \"will be created\"\nfi\n\n# Source data dir for this date\nDATA_SRC=\"$HOME/.screenpipe/data/data/$TARGET_DATE\"\nif [ -d \"$DATA_SRC\" ]; then\n DATA_SIZE=$(du -sh \"$DATA_SRC\" | cut -f1)\n DATA_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n printf \" %-20s %s (%s files, %s)\\n\" \"Data dir:\" \"OK\" \"$DATA_FILES\" \"$DATA_SIZE\"\nelse\n printf \" %-20s %s\\n\" \"Data dir:\" \"not found — skipping file copy\"\nfi\n\n# ─── DB SYNC ──────────────────────────────────────────────────────────────────\nif [ \"$DB_ALREADY_SYNCED\" = false ]; then\n\n # ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────\n step \"Counting source rows for $TARGET_DATE\"\n\n SRC_FRAMES=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\")\n SRC_ELEMENTS=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n SRC_UI=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';\")\n SRC_OCR=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n SRC_MEETINGS=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';\")\n\n printf \" %-20s %s\\n\" \"frames:\" \"$SRC_FRAMES\"\n printf \" %-20s %s\\n\" \"elements:\" \"$SRC_ELEMENTS\"\n printf \" %-20s %s\\n\" \"ui_events:\" \"$SRC_UI\"\n printf \" %-20s %s\\n\" \"ocr_text:\" \"$SRC_OCR\"\n printf \" %-20s %s\\n\" \"meetings:\" \"$SRC_MEETINGS\"\n\n if [ \"$SRC_FRAMES\" -eq \"0\" ]; then\n log \"No frames found for $TARGET_DATE — skipping DB sync\"\n DB_ALREADY_SYNCED=true\n fi\n\nfi\n\nif [ \"$DB_ALREADY_SYNCED\" = false ]; then\n\n # ─── INIT TABLES ──────────────────────────────────────────────────────────\n step \"Initialising tables, indexes, FTS\"\n\n run_sqlite_heredoc \"creating tables\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"creating indexes\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);\nCREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);\nCREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"creating FTS tables\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(\n text, role, frame_id UNINDEXED,\n content='elements', content_rowid='id', tokenize='unicode61'\n);\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(\n full_text, app_name, window_name, browser_url, id UNINDEXED,\n tokenize='unicode61'\n);\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(\n text_content,\n app_name,\n window_title,\n element_name,\n content='ui_events',\n content_rowid='id',\n tokenize='unicode61'\n);\nDETACH nas;\n\"\n\n # ─── SYNC DATA ────────────────────────────────────────────────────────────\n step \"Syncing data for $TARGET_DATE\"\n\n run_sqlite_heredoc \"video_chunks\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.video_chunks\n SELECT * FROM main.video_chunks\n WHERE id IN (\n SELECT DISTINCT video_chunk_id FROM main.frames\n WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL\n );\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames ($SRC_FRAMES rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.frames\n SELECT * FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ocr_text ($SRC_OCR rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ocr_text\n SELECT o.* FROM main.ocr_text o\n JOIN main.frames f ON o.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events ($SRC_UI rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ui_events\n SELECT * FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"elements ($SRC_ELEMENTS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.elements\n SELECT e.* FROM main.elements e\n JOIN main.frames f ON e.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"meetings ($SRC_MEETINGS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.meetings\n SELECT * FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n # ─── FTS UPDATE ───────────────────────────────────────────────────────────\n step \"Updating FTS indexes\"\n\n run_sqlite_heredoc \"elements_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.elements_fts(rowid, text, role)\n SELECT e.id, e.text, e.role\n FROM nas.elements e\n JOIN nas.frames f ON e.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE'\n AND e.text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)\n SELECT id, full_text, app_name, window_name, browser_url, id\n FROM nas.frames\n WHERE date(timestamp) = '$TARGET_DATE'\n AND full_text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)\n SELECT id, text_content, app_name, window_title, element_name\n FROM nas.ui_events\n WHERE date(timestamp) = '$TARGET_DATE'\n AND text_content IS NOT NULL;\nDETACH nas;\n\"\n\n # ─── VERIFY DB ────────────────────────────────────────────────────────────\n step \"Verifying DB\"\n\n V_FRAMES=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\")\n V_ELEMENTS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n V_UI=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';\")\n V_OCR=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n V_MEETINGS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';\")\n\n check \"frames\" \"$V_FRAMES\" \"$SRC_FRAMES\"\n check \"elements\" \"$V_ELEMENTS\" \"$SRC_ELEMENTS\"\n check \"ui_events\" \"$V_UI\" \"$SRC_UI\"\n check \"ocr_text\" \"$V_OCR\" \"$SRC_OCR\"\n check \"meetings\" \"$V_MEETINGS\" \"$SRC_MEETINGS\"\n\nfi\n\n# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────\n# Always runs regardless of DB sync status\nstep \"Copying data folder for $TARGET_DATE\"\n\nif [ -d \"$DATA_SRC\" ]; then\n mkdir -p \"$NAS_DATA/$TARGET_DATE\"\n RSYNC_START=$(date +%s)\n printf \" %-36s \" \"rsync $TARGET_DATE/ → NAS\"\n rsync -a --ignore-existing \\\n \"$DATA_SRC/\" \\\n \"$NAS_DATA/$TARGET_DATE/\" \\\n 2>>\"$LOG_FILE\"\n RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))\n COPIED_FILES=$(ls \"$NAS_DATA/$TARGET_DATE\" | wc -l | tr -d ' ')\n SRC_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n COPIED_SIZE=$(du -sh \"$NAS_DATA/$TARGET_DATE\" | cut -f1)\n if [ \"$COPIED_FILES\" -eq \"$SRC_FILES\" ]; then\n printf \"\\r %-36s ✓ %dm%02ds (%s files, %s)\\n\" \\\n \"rsync $TARGET_DATE/ → NAS\" \\\n \"$(( RSYNC_DUR / 60 ))\" \"$(( RSYNC_DUR % 60 ))\" \\\n \"$COPIED_FILES\" \"$COPIED_SIZE\" | tee -a \"$LOG_FILE\"\n else\n printf \"\\r %-36s ✗ %s / %s files\\n\" \\\n \"rsync $TARGET_DATE/ → NAS\" \"$COPIED_FILES\" \"$SRC_FILES\" | tee -a \"$LOG_FILE\"\n fi\nelse\n printf \" %-36s %s\\n\" \"rsync $TARGET_DATE/ → NAS\" \"skipped (no source dir)\"\nfi\n\n# ─── SUMMARY ──────────────────────────────────────────────────────────────────\nTOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))\nDB_SIZE=$(du -sh \"$NAS_DB\" | cut -f1)\n\necho \"\"\nlog \"Archive DB size: $DB_SIZE\"\nlog \"Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s\"\nlog \"Sync complete for $TARGET_DATE\"\nlog \"========================================\"","depth":29,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Implement and run pipe l…, Editor Group 2","depth":28,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":false},{"role":"AXRadioButton","text":"Problems (⇧⌘M)","depth":22,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"PROBLEMS","depth":24,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Output (⇧⌘U)","depth":22,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUTPUT","depth":24,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Debug Console (⇧⌘Y)","depth":22,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"DEBUG CONSOLE","depth":24,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Terminal (⌃`)","depth":22,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":true},{"role":"AXStaticText","text":"TERMINAL","depth":24,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Ports - 1 forwarded port","depth":22,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"PORTS","depth":24,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":25,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"remote SSH: nas","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"SSH: nas","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"screenpipe (Git) - master*, Checkout Branch/Tag...","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"master*","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"screenpipe (Git) - Synchronize Changes","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"No Problems","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"0","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"0","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Forwarded Ports: 8766","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Notifications","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sign In","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Sign In","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Shell Script","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Editor Language Status: $(copilot) No inline suggestion available, Inline suggestions","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"LF","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"UTF-8","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Spaces: 2","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Ln 29, Col 35","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"git-commit Lukas Kovalik (2 weeks ago)","depth":16,"bounds":{"left":1.0,"top":0.0,"width":-0.07361114,"height":0.024444444},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":1.0,"top":0.0,"width":-0.07708335,"height":0.017777778},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Lukas Kovalik (2 weeks ago)","depth":17,"bounds":{"left":1.0,"top":0.0,"width":-0.08819449,"height":0.015555556},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"No results found","depth":12,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Implement and run pipe logic","depth":19,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Session history","depth":19,"on_screen":true,"help_text":"Session history","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"New session","depth":19,"on_screen":true,"help_text":"New session","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Message actions","depth":24,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"main.py","depth":23,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"lets implement logic with pipes. how can I run it?","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Let me look at the current project structure to understand what's already in place.","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"List project files","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"find /volume1/screenpipe -type f | head -50 && echo \"---\" && ls /volume1/screenpipe","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"/volume1/screenpipe/.DS_Store\n/volume1/screenpipe/screenpipe.db\n/volume1/screenpipe/screenpipe_sync.sh\n/volume1/screenpipe/app_settings.json\n/volume1/screenpipe/.gitignore\n/volume1/screenpipe/archive.db\n/volume1/screenpipe/db.sqlite\n/volume1/screenpipe/db.sqlite-wal\n/volume1/screenpipe/db.sqlite-shm\n/volume1/screenpipe/#recycle/desktop.ini\n/volume1/screenpipe/#recycle/db.sqlite\n/volume1/screenpipe/#recycle/Copy #1 of db.sqlite\n/volume1/screenpipe/#recycle/.DS_Store\n/volume1/screenpipe/#recycle/Copy #2 of db.sqlite\n/volume1/screenpipe/#recycle/archive.db\n/volume1/screenpipe/#recycle/Copy #1 of archive.db\n/volume1/screenpipe/#recycle/Copy #2 of archive.db\n/volume1/screenpipe/#recycle/Copy #3 of archive.db\n/volume1/screenpipe/#recycle/Copy #4 of archive.db\n/volume1/screenpipe/#recycle/Copy #5 of archive.db\n/volume1/screenpipe/#recycle/Copy #3 of db.sqlite\n/volume1/screenpipe/#recycle/Copy #4 of db.sqlite\n/volume1/screenpipe/#recycle/Copy #6 of archive.db\n/volume1/screenpipe/#recycle/test.txt\n/volume1/screenpipe/#recycle/Copy #7 of archive.db\n/volume1/screenpipe/#recycle/Copy #8 of archive.db\n/volume1/screenpipe/#recycle/archive.db-journal\n/volume1/screenpipe/#recycle/Copy #1 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #2 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #3 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #4 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #5 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #6 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #7 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #5 of db.sqlite\n/volume1/screenpipe/pipes/.DS_Store\n/volume1/screenpipe/app/.env\n/volume1/screenpipe/app/cli.py\n/volume1/screenpipe/app/.DS_Store\n/volume1/screenpipe/app/db.py\n/volume1/screenpipe/app/docker-compose.yml\n/volume1/screenpipe/app/main.py\n/volume1/screenpipe/app/requirements.txt\n/volume1/screenpipe/app/Dockerfile\n/volume1/screenpipe/data/.DS_Store\n/volume1/screenpipe/.git/description\n/volume1/screenpipe/.git/HEAD\n/volume1/screenpipe/.git/index\n/volume1/screenpipe/.git/COMMIT_EDITMSG\n/volume1/screenpipe/#recycle/data/.DS_Store\n---\napp\napp_settings.json\narchive.db\ndata\ndb.sqlite\ndb.sqlite-shm\ndb.sqlite-wal\npipes\n#recycle\nscreenpipe.db\nscreenpipe_sync.sh","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"main.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Check pipes directory and docker-compose","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/pipes/ && ls /volume1/screenpipe/app/ && cat /volume1/screenpipe/app/docker-compose.yml","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ai-habits\nday-recap\nmeeting-summary\nstandup-update\ntime-breakdown\nvideo-export\ncli.py\nconsumers\ndb.py\ndocker-compose.yml\nDockerfile\nmain.py\n__pycache__\nrequirements.txt\nstatic\nservices:\n screenpipe-app:\n build: .\n container_name: screenpipe-app\n restart: unless-stopped\n ports:\n - \"8766:8000\"\n volumes:\n - /volume1/screenpipe:/data\n env_file:\n - .env\n environment:\n TZ: Europe/Sofia\n DB_PATH: /data/db.sqlite\n\n sqlite-web-archive:\n image: ghcr.io/coleifer/sqlite-web:latest\n container_name: screenpipe-sqlweb-archive\n restart: unless-stopped\n ports:\n - \"8767:8080\"\n volumes:\n - /volume1/screenpipe:/data\n command: [\"-H\", \"0.0.0.0\", \"-r\", \"/data/archive.db\"]\n\n sqlite-web-live:\n image: ghcr.io/coleifer/sqlite-web:latest\n container_name: screenpipe-sqlweb-live\n restart: unless-stopped\n ports:\n - \"8768:8080\"\n volumes:\n - /volume1/screenpipe:/data\n command: [\"-H\", \"0.0.0.0\", \"-r\", \"/data/db.sqlite\"]","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"requirements.txt","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"requirements.txt","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Inspect a pipe directory","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/pipes/day-recap/ && cat /volume1/screenpipe/pipes/day-recap/pipe.json 2>/dev/null || ls /volume1/screenpipe/pipes/day-recap/","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
8369589233681041862
|
3895780591031160599
|
click
|
accessibility
|
NULL
|
Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧ Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py
M
db.py
docker-compose.yml
Dockerfile
M
main.py
M
requirements.txt
M
data
logs
pipes
.gitignore
app_settings.json
archive.db
archive.db-bak
U
db.sqlite
db.sqlite-shm
db.sqlite-wal
screenpipe_sync_updated.sh
U
screenpipe_sync.sh
screenpipe.db
Outline Section
OUTLINE
OUTLINE
Timeline Section
TIMELINE
TIMELINE
app_settings.json, Editor Group 1
screenpipe_sync.sh, Editor Group 1
pipe.md, Editor Group 1
.env, Editor Group 1
#!/bin/bash
# screenpipe_sync.sh
# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).
# Also copies the day's video/frame data folder to the NAS.
#
# Usage:
# ./screenpipe_sync.sh # syncs yesterday (default)
# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date
# ./screenpipe_sync.sh today # syncs today so far
#
# Cron example (runs at 3am daily):
# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1
set -euo pipefail
# ─── CONFIG ───────────────────────────────────────────────────────────────────
DB_SRC="${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}"
NAS_MOUNT="${NAS_MOUNT:-/Volumes/Test/screenpipe}"
NAS_DB="$NAS_MOUNT/archive.db"
NAS_DATA="$NAS_MOUNT/data"
LOG_FILE="$HOME/.screenpipe/sync.log"
# ──────────────────────────────────────────────────────────────────────────────
# ─── HELPERS ──────────────────────────────────────────────────────────────────
SCRIPT_START=$(date +%s)
log() {
local msg="[$(date '+%Y-%m-%d %H:%M:%S')] $*"
echo "$msg" | tee -a "$LOG_FILE"
}
step() {
local now=$(date +%s)
local elapsed=$(( now - SCRIPT_START ))
local min=$(( elapsed / 60 ))
local sec=$(( elapsed % 60 ))
printf "\n[+%02dm%02ds] ▶ %s\n" "$min" "$sec" "$*" | tee -a "$LOG_FILE"
}
run_sqlite_heredoc() {
local label="$1"
local sql="$2"
local start=$(date +%s)
printf " %-36s " "$label"
sqlite3 "$DB_SRC" <<< "$sql" &
local pid=$!
local spin=[PASSWORD] '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')
local i=0
while kill -0 "$pid" 2>/dev/null; do
printf "\r %-36s %s " "$label" "${spin[$i]}"
i=$(( (i + 1) % 10 ))
sleep 0.2
done
wait "$pid"
local rc=$?
if [ $rc -ne 0 ]; then
printf "\r %-36s ✗ FAILED\n" "$label" | tee -a "$LOG_FILE"
exit $rc
fi
local dur=$(( $(date +%s) - start ))
printf "\r %-36s ✓ %dm%02ds\n" "$label" "$(( dur / 60 ))" "$(( dur % 60 ))" | tee -a "$LOG_FILE"
}
check() {
local label="$1" got="$2" expected="$3"
if [ "$got" -eq "$expected" ]; then
printf " %-20s %s / %s ✓\n" "$label:" "$got" "$expected"
else
printf " %-20s %s / %s ✗ MISMATCH\n" "$label:" "$got" "$expected"
fi
}
# ──────────────────────────────────────────────────────────────────────────────
# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────
if [ "${1:-}" = "today" ]; then
TARGET_DATE=$(date +%Y-%m-%d)
elif [ -n "${1:-}" ]; then
TARGET_DATE="$1"
if ! [[ "$TARGET_DATE" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then
echo "ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday."
exit 1
fi
else
TARGET_DATE=$(date -v-1d +%Y-%m-%d)
fi
log "========================================"
log "Screenpipe sync starting for: $TARGET_DATE"
log "========================================"
# ─── PREFLIGHT ────────────────────────────────────────────────────────────────
step "Preflight checks"
if [ ! -f "$DB_SRC" ]; then
log "ERROR: Source DB not found at $DB_SRC"; exit 1
fi
printf " %-20s %s (%s)\n" "Source DB:" "OK" "$(du -sh "$DB_SRC" | cut -f1)"
if [ ! -d "$NAS_MOUNT" ]; then
log "ERROR: NAS not mounted at $NAS_MOUNT"; exit 1
fi
printf " %-20s %s\n" "NAS mount:" "OK $NAS_MOUNT"
# Check if DB already synced for this date
DB_ALREADY_SYNCED=false
if [ -f "$NAS_DB" ]; then
EXISTING=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';" 2>/dev/null || echo "0")
if [ "$EXISTING" -gt "0" ]; then
log "Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync"
DB_ALREADY_SYNCED=true
else
printf " %-20s %s (%s)\n" "Archive DB:" "exists" "$(du -sh "$NAS_DB" | cut -f1)"
fi
else
printf " %-20s %s\n" "Archive DB:" "will be created"
fi
# Source data dir for this date
DATA_SRC="$HOME/.screenpipe/data/data/$TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
DATA_SIZE=$(du -sh "$DATA_SRC" | cut -f1)
DATA_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
printf " %-20s %s (%s files, %s)\n" "Data dir:" "OK" "$DATA_FILES" "$DATA_SIZE"
else
printf " %-20s %s\n" "Data dir:" "not found — skipping file copy"
fi
# ─── DB SYNC ──────────────────────────────────────────────────────────────────
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────
step "Counting source rows for $TARGET_DATE"
SRC_FRAMES=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
SRC_ELEMENTS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_UI=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
SRC_OCR=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_MEETINGS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';")
printf " %-20s %s\n" "frames:" "$SRC_FRAMES"
printf " %-20s %s\n" "elements:" "$SRC_ELEMENTS"
printf " %-20s %s\n" "ui_events:" "$SRC_UI"
printf " %-20s %s\n" "ocr_text:" "$SRC_OCR"
printf " %-20s %s\n" "meetings:" "$SRC_MEETINGS"
if [ "$SRC_FRAMES" -eq "0" ]; then
log "No frames found for $TARGET_DATE — skipping DB sync"
DB_ALREADY_SYNCED=true
fi
fi
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── INIT TABLES ──────────────────────────────────────────────────────────
step "Initialising tables, indexes, FTS"
run_sqlite_heredoc "creating tables" "
ATTACH '$NAS_DB' AS nas;
CREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;
CREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;
CREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;
CREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;
DETACH nas;
"
run_sqlite_heredoc "creating indexes" "
ATTACH '$NAS_DB' AS nas;
CREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);
CREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);
DETACH nas;
"
run_sqlite_heredoc "creating FTS tables" "
ATTACH '$NAS_DB' AS nas;
CREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(
text, role, frame_id UNINDEXED,
content='elements', content_rowid='id', tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(
full_text, app_name, window_name, browser_url, id UNINDEXED,
tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(
text_content,
app_name,
window_title,
element_name,
content='ui_events',
content_rowid='id',
tokenize='unicode61'
);
DETACH nas;
"
# ─── SYNC DATA ────────────────────────────────────────────────────────────
step "Syncing data for $TARGET_DATE"
run_sqlite_heredoc "video_chunks" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.video_chunks
SELECT * FROM main.video_chunks
WHERE id IN (
SELECT DISTINCT video_chunk_id FROM main.frames
WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL
);
DETACH nas;
"
run_sqlite_heredoc "frames ($SRC_FRAMES rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.frames
SELECT * FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ocr_text ($SRC_OCR rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ocr_text
SELECT o.* FROM main.ocr_text o
JOIN main.frames f ON o.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ui_events ($SRC_UI rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ui_events
SELECT * FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "elements ($SRC_ELEMENTS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.elements
SELECT e.* FROM main.elements e
JOIN main.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "meetings ($SRC_MEETINGS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.meetings
SELECT * FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';
DETACH nas;
"
# ─── FTS UPDATE ───────────────────────────────────────────────────────────
step "Updating FTS indexes"
run_sqlite_heredoc "elements_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.elements_fts(rowid, text, role)
SELECT e.id, e.text, e.role
FROM nas.elements e
JOIN nas.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE'
AND e.text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "frames_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)
SELECT id, full_text, app_name, window_name, browser_url, id
FROM nas.frames
WHERE date(timestamp) = '$TARGET_DATE'
AND full_text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "ui_events_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)
SELECT id, text_content, app_name, window_title, element_name
FROM nas.ui_events
WHERE date(timestamp) = '$TARGET_DATE'
AND text_content IS NOT NULL;
DETACH nas;
"
# ─── VERIFY DB ────────────────────────────────────────────────────────────
step "Verifying DB"
V_FRAMES=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
V_ELEMENTS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_UI=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
V_OCR=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_MEETINGS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';")
check "frames" "$V_FRAMES" "$SRC_FRAMES"
check "elements" "$V_ELEMENTS" "$SRC_ELEMENTS"
check "ui_events" "$V_UI" "$SRC_UI"
check "ocr_text" "$V_OCR" "$SRC_OCR"
check "meetings" "$V_MEETINGS" "$SRC_MEETINGS"
fi
# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────
# Always runs regardless of DB sync status
step "Copying data folder for $TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
mkdir -p "$NAS_DATA/$TARGET_DATE"
RSYNC_START=$(date +%s)
printf " %-36s " "rsync $TARGET_DATE/ → NAS"
rsync -a --ignore-existing \
"$DATA_SRC/" \
"$NAS_DATA/$TARGET_DATE/" \
2>>"$LOG_FILE"
RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))
COPIED_FILES=$(ls "$NAS_DATA/$TARGET_DATE" | wc -l | tr -d ' ')
SRC_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
COPIED_SIZE=$(du -sh "$NAS_DATA/$TARGET_DATE" | cut -f1)
if [ "$COPIED_FILES" -eq "$SRC_FILES" ]; then
printf "\r %-36s ✓ %dm%02ds (%s files, %s)\n" \
"rsync $TARGET_DATE/ → NAS" \
"$(( RSYNC_DUR / 60 ))" "$(( RSYNC_DUR % 60 ))" \
"$COPIED_FILES" "$COPIED_SIZE" | tee -a "$LOG_FILE"
else
printf "\r %-36s ✗ %s / %s files\n" \
"rsync $TARGET_DATE/ → NAS" "$COPIED_FILES" "$SRC_FILES" | tee -a "$LOG_FILE"
fi
else
printf " %-36s %s\n" "rsync $TARGET_DATE/ → NAS" "skipped (no source dir)"
fi
# ─── SUMMARY ──────────────────────────────────────────────────────────────────
TOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))
DB_SIZE=$(du -sh "$NAS_DB" | cut -f1)
echo ""
log "Archive DB size: $DB_SIZE"
log "Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s"
log "Sync complete for $TARGET_DATE"
log "========================================"
#!/bin/bash
# screenpipe_sync.sh
# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).
# Also copies the day's video/frame data folder to the NAS.
#
# Usage:
# ./screenpipe_sync.sh # syncs yesterday (default)
# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date
# ./screenpipe_sync.sh today # syncs today so far
#
# Cron example (runs at 3am daily):
# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1
set -euo pipefail
# ─── CONFIG ───────────────────────────────────────────────────────────────────
DB_SRC="${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}"
NAS_MOUNT="${NAS_MOUNT:-/Volumes/Test/screenpipe}"
NAS_DB="$NAS_MOUNT/archive.db"
NAS_DATA="$NAS_MOUNT/data"
LOG_FILE="$HOME/.screenpipe/sync.log"
# ──────────────────────────────────────────────────────────────────────────────
# ─── HELPERS ──────────────────────────────────────────────────────────────────
SCRIPT_START=$(date +%s)
log() {
local msg="[$(date '+%Y-%m-%d %H:%M:%S')] $*"
echo "$msg" | tee -a "$LOG_FILE"
}
step() {
local now=$(date +%s)
local elapsed=$(( now - SCRIPT_START ))
local min=$(( elapsed / 60 ))
local sec=$(( elapsed % 60 ))
printf "\n[+%02dm%02ds] ▶ %s\n" "$min" "$sec" "$*" | tee -a "$LOG_FILE"
}
run_sqlite_heredoc() {
local label="$1"
local sql="$2"
local start=$(date +%s)
printf " %-36s " "$label"
sqlite3 "$DB_SRC" <<< "$sql" &
local pid=$!
local spin=[PASSWORD] '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')
local i=0
while kill -0 "$pid" 2>/dev/null; do
printf "\r %-36s %s " "$label" "${spin[$i]}"
i=$(( (i + 1) % 10 ))
sleep 0.2
done
wait "$pid"
local rc=$?
if [ $rc -ne 0 ]; then
printf "\r %-36s ✗ FAILED\n" "$label" | tee -a "$LOG_FILE"
exit $rc
fi
local dur=$(( $(date +%s) - start ))
printf "\r %-36s ✓ %dm%02ds\n" "$label" "$(( dur / 60 ))" "$(( dur % 60 ))" | tee -a "$LOG_FILE"
}
check() {
local label="$1" got="$2" expected="$3"
if [ "$got" -eq "$expected" ]; then
printf " %-20s %s / %s ✓\n" "$label:" "$got" "$expected"
else
printf " %-20s %s / %s ✗ MISMATCH\n" "$label:" "$got" "$expected"
fi
}
# ──────────────────────────────────────────────────────────────────────────────
# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────
if [ "${1:-}" = "today" ]; then
TARGET_DATE=$(date +%Y-%m-%d)
elif [ -n "${1:-}" ]; then
TARGET_DATE="$1"
if ! [[ "$TARGET_DATE" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then
echo "ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday."
exit 1
fi
else
TARGET_DATE=$(date -v-1d +%Y-%m-%d)
fi
log "========================================"
log "Screenpipe sync starting for: $TARGET_DATE"
log "========================================"
# ─── PREFLIGHT ────────────────────────────────────────────────────────────────
step "Preflight checks"
if [ ! -f "$DB_SRC" ]; then
log "ERROR: Source DB not found at $DB_SRC"; exit 1
fi
printf " %-20s %s (%s)\n" "Source DB:" "OK" "$(du -sh "$DB_SRC" | cut -f1)"
if [ ! -d "$NAS_MOUNT" ]; then
log "ERROR: NAS not mounted at $NAS_MOUNT"; exit 1
fi
printf " %-20s %s\n" "NAS mount:" "OK $NAS_MOUNT"
# Check if DB already synced for this date
DB_ALREADY_SYNCED=false
if [ -f "$NAS_DB" ]; then
EXISTING=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';" 2>/dev/null || echo "0")
if [ "$EXISTING" -gt "0" ]; then
log "Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync"
DB_ALREADY_SYNCED=true
else
printf " %-20s %s (%s)\n" "Archive DB:" "exists" "$(du -sh "$NAS_DB" | cut -f1)"
fi
else
printf " %-20s %s\n" "Archive DB:" "will be created"
fi
# Source data dir for this date
DATA_SRC="$HOME/.screenpipe/data/data/$TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
DATA_SIZE=$(du -sh "$DATA_SRC" | cut -f1)
DATA_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
printf " %-20s %s (%s files, %s)\n" "Data dir:" "OK" "$DATA_FILES" "$DATA_SIZE"
else
printf " %-20s %s\n" "Data dir:" "not found — skipping file copy"
fi
# ─── DB SYNC ──────────────────────────────────────────────────────────────────
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────
step "Counting source rows for $TARGET_DATE"
SRC_FRAMES=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
SRC_ELEMENTS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_UI=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
SRC_OCR=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_MEETINGS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';")
printf " %-20s %s\n" "frames:" "$SRC_FRAMES"
printf " %-20s %s\n" "elements:" "$SRC_ELEMENTS"
printf " %-20s %s\n" "ui_events:" "$SRC_UI"
printf " %-20s %s\n" "ocr_text:" "$SRC_OCR"
printf " %-20s %s\n" "meetings:" "$SRC_MEETINGS"
if [ "$SRC_FRAMES" -eq "0" ]; then
log "No frames found for $TARGET_DATE — skipping DB sync"
DB_ALREADY_SYNCED=true
fi
fi
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── INIT TABLES ──────────────────────────────────────────────────────────
step "Initialising tables, indexes, FTS"
run_sqlite_heredoc "creating tables" "
ATTACH '$NAS_DB' AS nas;
CREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;
CREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;
CREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;
CREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;
DETACH nas;
"
run_sqlite_heredoc "creating indexes" "
ATTACH '$NAS_DB' AS nas;
CREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);
CREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);
DETACH nas;
"
run_sqlite_heredoc "creating FTS tables" "
ATTACH '$NAS_DB' AS nas;
CREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(
text, role, frame_id UNINDEXED,
content='elements', content_rowid='id', tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(
full_text, app_name, window_name, browser_url, id UNINDEXED,
tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(
text_content,
app_name,
window_title,
element_name,
content='ui_events',
content_rowid='id',
tokenize='unicode61'
);
DETACH nas;
"
# ─── SYNC DATA ────────────────────────────────────────────────────────────
step "Syncing data for $TARGET_DATE"
run_sqlite_heredoc "video_chunks" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.video_chunks
SELECT * FROM main.video_chunks
WHERE id IN (
SELECT DISTINCT video_chunk_id FROM main.frames
WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL
);
DETACH nas;
"
run_sqlite_heredoc "frames ($SRC_FRAMES rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.frames
SELECT * FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ocr_text ($SRC_OCR rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ocr_text
SELECT o.* FROM main.ocr_text o
JOIN main.frames f ON o.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ui_events ($SRC_UI rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ui_events
SELECT * FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "elements ($SRC_ELEMENTS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.elements
SELECT e.* FROM main.elements e
JOIN main.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "meetings ($SRC_MEETINGS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.meetings
SELECT * FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';
DETACH nas;
"
# ─── FTS UPDATE ───────────────────────────────────────────────────────────
step "Updating FTS indexes"
run_sqlite_heredoc "elements_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.elements_fts(rowid, text, role)
SELECT e.id, e.text, e.role
FROM nas.elements e
JOIN nas.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE'
AND e.text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "frames_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)
SELECT id, full_text, app_name, window_name, browser_url, id
FROM nas.frames
WHERE date(timestamp) = '$TARGET_DATE'
AND full_text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "ui_events_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)
SELECT id, text_content, app_name, window_title, element_name
FROM nas.ui_events
WHERE date(timestamp) = '$TARGET_DATE'
AND text_content IS NOT NULL;
DETACH nas;
"
# ─── VERIFY DB ────────────────────────────────────────────────────────────
step "Verifying DB"
V_FRAMES=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
V_ELEMENTS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_UI=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
V_OCR=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_MEETINGS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';")
check "frames" "$V_FRAMES" "$SRC_FRAMES"
check "elements" "$V_ELEMENTS" "$SRC_ELEMENTS"
check "ui_events" "$V_UI" "$SRC_UI"
check "ocr_text" "$V_OCR" "$SRC_OCR"
check "meetings" "$V_MEETINGS" "$SRC_MEETINGS"
fi
# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────
# Always runs regardless of DB sync status
step "Copying data folder for $TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
mkdir -p "$NAS_DATA/$TARGET_DATE"
RSYNC_START=$(date +%s)
printf " %-36s " "rsync $TARGET_DATE/ → NAS"
rsync -a --ignore-existing \
"$DATA_SRC/" \
"$NAS_DATA/$TARGET_DATE/" \
2>>"$LOG_FILE"
RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))
COPIED_FILES=$(ls "$NAS_DATA/$TARGET_DATE" | wc -l | tr -d ' ')
SRC_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
COPIED_SIZE=$(du -sh "$NAS_DATA/$TARGET_DATE" | cut -f1)
if [ "$COPIED_FILES" -eq "$SRC_FILES" ]; then
printf "\r %-36s ✓ %dm%02ds (%s files, %s)\n" \
"rsync $TARGET_DATE/ → NAS" \
"$(( RSYNC_DUR / 60 ))" "$(( RSYNC_DUR % 60 ))" \
"$COPIED_FILES" "$COPIED_SIZE" | tee -a "$LOG_FILE"
else
printf "\r %-36s ✗ %s / %s files\n" \
"rsync $TARGET_DATE/ → NAS" "$COPIED_FILES" "$SRC_FILES" | tee -a "$LOG_FILE"
fi
else
printf " %-36s %s\n" "rsync $TARGET_DATE/ → NAS" "skipped (no source dir)"
fi
# ─── SUMMARY ──────────────────────────────────────────────────────────────────
TOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))
DB_SIZE=$(du -sh "$NAS_DB" | cut -f1)
echo ""
log "Archive DB size: $DB_SIZE"
log "Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s"
log "Sync complete for $TARGET_DATE"
log "========================================"
Implement and run pipe l…, Editor Group 2
Problems (⇧⌘M)
PROBLEMS
Output (⇧⌘U)
OUTPUT
Debug Console (⇧⌘Y)
DEBUG CONSOLE
Terminal (⌃`)
TERMINAL
Ports - 1 forwarded port
PORTS
1
remote SSH: nas
SSH: nas
screenpipe (Git) - master*, Checkout Branch/Tag...
master*
screenpipe (Git) - Synchronize Changes
No Problems
0
0
Forwarded Ports: 8766
1
Notifications
Sign In
Sign In
Shell Script
Editor Language Status: $(copilot) No inline suggestion available, Inline suggestions
LF
UTF-8
Spaces: 2
Ln 29, Col 35
git-commit Lukas Kovalik (2 weeks ago)
Lukas Kovalik (2 weeks ago)
No results found
Implement and run pipe logic
Session history
New session
Message actions
main.py
main.py
lets implement logic with pipes. how can I run it?
Thinking
Thinking
Let me look at the current project structure to understand what's already in place.
Bash
List project files
IN
find /volume1/screenpipe -type f | head -50 && echo "---" && ls /volume1/screenpipe
Copy code to clipboard
OUT
/volume1/screenpipe/.DS_Store
/volume1/screenpipe/screenpipe.db
/volume1/screenpipe/screenpipe_sync.sh
/volume1/screenpipe/app_settings.json
/volume1/screenpipe/.gitignore
/volume1/screenpipe/archive.db
/volume1/screenpipe/db.sqlite
/volume1/screenpipe/db.sqlite-wal
/volume1/screenpipe/db.sqlite-shm
/volume1/screenpipe/#recycle/desktop.ini
/volume1/screenpipe/#recycle/db.sqlite
/volume1/screenpipe/#recycle/Copy #1 of db.sqlite
/volume1/screenpipe/#recycle/.DS_Store
/volume1/screenpipe/#recycle/Copy #2 of db.sqlite
/volume1/screenpipe/#recycle/archive.db
/volume1/screenpipe/#recycle/Copy #1 of archive.db
/volume1/screenpipe/#recycle/Copy #2 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of archive.db
/volume1/screenpipe/#recycle/Copy #4 of archive.db
/volume1/screenpipe/#recycle/Copy #5 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of db.sqlite
/volume1/screenpipe/#recycle/Copy #4 of db.sqlite
/volume1/screenpipe/#recycle/Copy #6 of archive.db
/volume1/screenpipe/#recycle/test.txt
/volume1/screenpipe/#recycle/Copy #7 of archive.db
/volume1/screenpipe/#recycle/Copy #8 of archive.db
/volume1/screenpipe/#recycle/archive.db-journal
/volume1/screenpipe/#recycle/Copy #1 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #2 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #3 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #4 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #6 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #7 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of db.sqlite
/volume1/screenpipe/pipes/.DS_Store
/volume1/screenpipe/app/.env
/volume1/screenpipe/app/cli.py
/volume1/screenpipe/app/.DS_Store
/volume1/screenpipe/app/db.py
/volume1/screenpipe/app/docker-compose.yml
/volume1/screenpipe/app/main.py
/volume1/screenpipe/app/requirements.txt
/volume1/screenpipe/app/Dockerfile
/volume1/screenpipe/data/.DS_Store
/volume1/screenpipe/.git/description
/volume1/screenpipe/.git/HEAD
/volume1/screenpipe/.git/index
/volume1/screenpipe/.git/COMMIT_EDITMSG
/volume1/screenpipe/#recycle/data/.DS_Store
---
app
app_settings.json
archive.db
data
db.sqlite
db.sqlite-shm
db.sqlite-wal
pipes
#recycle
screenpipe.db
screenpipe_sync.sh
Read
main.py
main.py
Bash
Check pipes directory and docker-compose
IN
ls /volume1/screenpipe/pipes/ && ls /volume1/screenpipe/app/ && cat /volume1/screenpipe/app/docker-compose.yml
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
cli.py
consumers
db.py
docker-compose.yml
Dockerfile
main.py
__pycache__
requirements.txt
static
services:
screenpipe-app:
build: .
container_name: screenpipe-app
restart: unless-stopped
ports:
- "8766:8000"
volumes:
- /volume1/screenpipe:/data
env_file:
- .env
environment:
TZ: Europe/Sofia
DB_PATH: /data/db.sqlite
sqlite-web-archive:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-archive
restart: unless-stopped
ports:
- "8767:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/archive.db"]
sqlite-web-live:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-live
restart: unless-stopped
ports:
- "8768:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/db.sqlite"]
Read
requirements.txt
requirements.txt
Bash
Inspect a pipe directory
IN
ls /volume1/screenpipe/pipes/day-recap/ && cat /volume1/screenpipe/pipes/day-recap/pipe.json 2>/dev/null || ls /volume1/screenpipe/pipes/day-recap/
Copy code to clipboard...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
21101
|
923
|
10
|
2026-05-11T17:12:11.596299+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-11/1778 /Users/lukas/.screenpipe/data/data/2026-05-11/1778519531596_m2.jpg...
|
Code
|
screenpipe_sync.sh — screenpipe [SSH: nas]
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧ Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py
M
db.py
docker-compose.yml
Dockerfile
M
main.py
M
requirements.txt
M
data
logs
pipes
.gitignore
app_settings.json
archive.db
archive.db-bak
U
db.sqlite
db.sqlite-shm
db.sqlite-wal
screenpipe_sync_updated.sh
U
screenpipe_sync.sh
screenpipe.db
Outline Section
OUTLINE
OUTLINE
Timeline Section
TIMELINE
TIMELINE
app_settings.json, Editor Group 1
screenpipe_sync.sh, Editor Group 1
pipe.md, Editor Group 1
.env, Editor Group 1
#!/bin/bash
# screenpipe_sync.sh
# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).
# Also copies the day's video/frame data folder to the NAS.
#
# Usage:
# ./screenpipe_sync.sh # syncs yesterday (default)
# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date
# ./screenpipe_sync.sh today # syncs today so far
#
# Cron example (runs at 3am daily):
# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1
set -euo pipefail
# ─── CONFIG ───────────────────────────────────────────────────────────────────
DB_SRC="${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}"
NAS_MOUNT="${NAS_MOUNT:-/Volumes/Test/screenpipe}"
NAS_DB="$NAS_MOUNT/archive.db"
NAS_DATA="$NAS_MOUNT/data"
LOG_FILE="$HOME/.screenpipe/sync.log"
# ──────────────────────────────────────────────────────────────────────────────
# ─── HELPERS ──────────────────────────────────────────────────────────────────
SCRIPT_START=$(date +%s)
log() {
local msg="[$(date '+%Y-%m-%d %H:%M:%S')] $*"
echo "$msg" | tee -a "$LOG_FILE"
}
step() {
local now=$(date +%s)
local elapsed=$(( now - SCRIPT_START ))
local min=$(( elapsed / 60 ))
local sec=$(( elapsed % 60 ))
printf "\n[+%02dm%02ds] ▶ %s\n" "$min" "$sec" "$*" | tee -a "$LOG_FILE"
}
run_sqlite_heredoc() {
local label="$1"
local sql="$2"
local start=$(date +%s)
printf " %-36s " "$label"
sqlite3 "$DB_SRC" <<< "$sql" &
local pid=$!
local spin=[PASSWORD] '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')
local i=0
while kill -0 "$pid" 2>/dev/null; do
printf "\r %-36s %s " "$label" "${spin[$i]}"
i=$(( (i + 1) % 10 ))
sleep 0.2
done
wait "$pid"
local rc=$?
if [ $rc -ne 0 ]; then
printf "\r %-36s ✗ FAILED\n" "$label" | tee -a "$LOG_FILE"
exit $rc
fi
local dur=$(( $(date +%s) - start ))
printf "\r %-36s ✓ %dm%02ds\n" "$label" "$(( dur / 60 ))" "$(( dur % 60 ))" | tee -a "$LOG_FILE"
}
check() {
local label="$1" got="$2" expected="$3"
if [ "$got" -eq "$expected" ]; then
printf " %-20s %s / %s ✓\n" "$label:" "$got" "$expected"
else
printf " %-20s %s / %s ✗ MISMATCH\n" "$label:" "$got" "$expected"
fi
}
# ──────────────────────────────────────────────────────────────────────────────
# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────
if [ "${1:-}" = "today" ]; then
TARGET_DATE=$(date +%Y-%m-%d)
elif [ -n "${1:-}" ]; then
TARGET_DATE="$1"
if ! [[ "$TARGET_DATE" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then
echo "ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday."
exit 1
fi
else
TARGET_DATE=$(date -v-1d +%Y-%m-%d)
fi
log "========================================"
log "Screenpipe sync starting for: $TARGET_DATE"
log "========================================"
# ─── PREFLIGHT ────────────────────────────────────────────────────────────────
step "Preflight checks"
if [ ! -f "$DB_SRC" ]; then
log "ERROR: Source DB not found at $DB_SRC"; exit 1
fi
printf " %-20s %s (%s)\n" "Source DB:" "OK" "$(du -sh "$DB_SRC" | cut -f1)"
if [ ! -d "$NAS_MOUNT" ]; then
log "ERROR: NAS not mounted at $NAS_MOUNT"; exit 1
fi
printf " %-20s %s\n" "NAS mount:" "OK $NAS_MOUNT"
# Check if DB already synced for this date
DB_ALREADY_SYNCED=false
if [ -f "$NAS_DB" ]; then
EXISTING=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';" 2>/dev/null || echo "0")
if [ "$EXISTING" -gt "0" ]; then
log "Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync"
DB_ALREADY_SYNCED=true
else
printf " %-20s %s (%s)\n" "Archive DB:" "exists" "$(du -sh "$NAS_DB" | cut -f1)"
fi
else
printf " %-20s %s\n" "Archive DB:" "will be created"
fi
# Source data dir for this date
DATA_SRC="$HOME/.screenpipe/data/data/$TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
DATA_SIZE=$(du -sh "$DATA_SRC" | cut -f1)
DATA_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
printf " %-20s %s (%s files, %s)\n" "Data dir:" "OK" "$DATA_FILES" "$DATA_SIZE"
else
printf " %-20s %s\n" "Data dir:" "not found — skipping file copy"
fi
# ─── DB SYNC ──────────────────────────────────────────────────────────────────
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────
step "Counting source rows for $TARGET_DATE"
SRC_FRAMES=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
SRC_ELEMENTS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_UI=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
SRC_OCR=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_MEETINGS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';")
printf " %-20s %s\n" "frames:" "$SRC_FRAMES"
printf " %-20s %s\n" "elements:" "$SRC_ELEMENTS"
printf " %-20s %s\n" "ui_events:" "$SRC_UI"
printf " %-20s %s\n" "ocr_text:" "$SRC_OCR"
printf " %-20s %s\n" "meetings:" "$SRC_MEETINGS"
if [ "$SRC_FRAMES" -eq "0" ]; then
log "No frames found for $TARGET_DATE — skipping DB sync"
DB_ALREADY_SYNCED=true
fi
fi
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── INIT TABLES ──────────────────────────────────────────────────────────
step "Initialising tables, indexes, FTS"
run_sqlite_heredoc "creating tables" "
ATTACH '$NAS_DB' AS nas;
CREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;
CREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;
CREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;
CREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;
DETACH nas;
"
run_sqlite_heredoc "creating indexes" "
ATTACH '$NAS_DB' AS nas;
CREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);
CREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);
DETACH nas;
"
run_sqlite_heredoc "creating FTS tables" "
ATTACH '$NAS_DB' AS nas;
CREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(
text, role, frame_id UNINDEXED,
content='elements', content_rowid='id', tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(
full_text, app_name, window_name, browser_url, id UNINDEXED,
tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(
text_content,
app_name,
window_title,
element_name,
content='ui_events',
content_rowid='id',
tokenize='unicode61'
);
DETACH nas;
"
# ─── SYNC DATA ────────────────────────────────────────────────────────────
step "Syncing data for $TARGET_DATE"
run_sqlite_heredoc "video_chunks" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.video_chunks
SELECT * FROM main.video_chunks
WHERE id IN (
SELECT DISTINCT video_chunk_id FROM main.frames
WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL
);
DETACH nas;
"
run_sqlite_heredoc "frames ($SRC_FRAMES rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.frames
SELECT * FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ocr_text ($SRC_OCR rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ocr_text
SELECT o.* FROM main.ocr_text o
JOIN main.frames f ON o.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ui_events ($SRC_UI rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ui_events
SELECT * FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "elements ($SRC_ELEMENTS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.elements
SELECT e.* FROM main.elements e
JOIN main.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "meetings ($SRC_MEETINGS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.meetings
SELECT * FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';
DETACH nas;
"
# ─── FTS UPDATE ───────────────────────────────────────────────────────────
step "Updating FTS indexes"
run_sqlite_heredoc "elements_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.elements_fts(rowid, text, role)
SELECT e.id, e.text, e.role
FROM nas.elements e
JOIN nas.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE'
AND e.text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "frames_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)
SELECT id, full_text, app_name, window_name, browser_url, id
FROM nas.frames
WHERE date(timestamp) = '$TARGET_DATE'
AND full_text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "ui_events_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)
SELECT id, text_content, app_name, window_title, element_name
FROM nas.ui_events
WHERE date(timestamp) = '$TARGET_DATE'
AND text_content IS NOT NULL;
DETACH nas;
"
# ─── VERIFY DB ────────────────────────────────────────────────────────────
step "Verifying DB"
V_FRAMES=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
V_ELEMENTS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_UI=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
V_OCR=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_MEETINGS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';")
check "frames" "$V_FRAMES" "$SRC_FRAMES"
check "elements" "$V_ELEMENTS" "$SRC_ELEMENTS"
check "ui_events" "$V_UI" "$SRC_UI"
check "ocr_text" "$V_OCR" "$SRC_OCR"
check "meetings" "$V_MEETINGS" "$SRC_MEETINGS"
fi
# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────
# Always runs regardless of DB sync status
step "Copying data folder for $TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
mkdir -p "$NAS_DATA/$TARGET_DATE"
RSYNC_START=$(date +%s)
printf " %-36s " "rsync $TARGET_DATE/ → NAS"
rsync -a --ignore-existing \
"$DATA_SRC/" \
"$NAS_DATA/$TARGET_DATE/" \
2>>"$LOG_FILE"
RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))
COPIED_FILES=$(ls "$NAS_DATA/$TARGET_DATE" | wc -l | tr -d ' ')
SRC_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
COPIED_SIZE=$(du -sh "$NAS_DATA/$TARGET_DATE" | cut -f1)
if [ "$COPIED_FILES" -eq "$SRC_FILES" ]; then
printf "\r %-36s ✓ %dm%02ds (%s files, %s)\n" \
"rsync $TARGET_DATE/ → NAS" \
"$(( RSYNC_DUR / 60 ))" "$(( RSYNC_DUR % 60 ))" \
"$COPIED_FILES" "$COPIED_SIZE" | tee -a "$LOG_FILE"
else
printf "\r %-36s ✗ %s / %s files\n" \
"rsync $TARGET_DATE/ → NAS" "$COPIED_FILES" "$SRC_FILES" | tee -a "$LOG_FILE"
fi
else
printf " %-36s %s\n" "rsync $TARGET_DATE/ → NAS" "skipped (no source dir)"
fi
# ─── SUMMARY ──────────────────────────────────────────────────────────────────
TOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))
DB_SIZE=$(du -sh "$NAS_DB" | cut -f1)
echo ""
log "Archive DB size: $DB_SIZE"
log "Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s"
log "Sync complete for $TARGET_DATE"
log "========================================"
#!/bin/bash
# screenpipe_sync.sh
# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).
# Also copies the day's video/frame data folder to the NAS.
#
# Usage:
# ./screenpipe_sync.sh # syncs yesterday (default)
# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date
# ./screenpipe_sync.sh today # syncs today so far
#
# Cron example (runs at 3am daily):
# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1
set -euo pipefail
# ─── CONFIG ───────────────────────────────────────────────────────────────────
DB_SRC="${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}"
NAS_MOUNT="${NAS_MOUNT:-/Volumes/Test/screenpipe}"
NAS_DB="$NAS_MOUNT/archive.db"
NAS_DATA="$NAS_MOUNT/data"
LOG_FILE="$HOME/.screenpipe/sync.log"
# ──────────────────────────────────────────────────────────────────────────────
# ─── HELPERS ──────────────────────────────────────────────────────────────────
SCRIPT_START=$(date +%s)
log() {
local msg="[$(date '+%Y-%m-%d %H:%M:%S')] $*"
echo "$msg" | tee -a "$LOG_FILE"
}
step() {
local now=$(date +%s)
local elapsed=$(( now - SCRIPT_START ))
local min=$(( elapsed / 60 ))
local sec=$(( elapsed % 60 ))
printf "\n[+%02dm%02ds] ▶ %s\n" "$min" "$sec" "$*" | tee -a "$LOG_FILE"
}
run_sqlite_heredoc() {
local label="$1"
local sql="$2"
local start=$(date +%s)
printf " %-36s " "$label"
sqlite3 "$DB_SRC" <<< "$sql" &
local pid=$!
local spin=[PASSWORD] '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')
local i=0
while kill -0 "$pid" 2>/dev/null; do
printf "\r %-36s %s " "$label" "${spin[$i]}"
i=$(( (i + 1) % 10 ))
sleep 0.2
done
wait "$pid"
local rc=$?
if [ $rc -ne 0 ]; then
printf "\r %-36s ✗ FAILED\n" "$label" | tee -a "$LOG_FILE"
exit $rc
fi
local dur=$(( $(date +%s) - start ))
printf "\r %-36s ✓ %dm%02ds\n" "$label" "$(( dur / 60 ))" "$(( dur % 60 ))" | tee -a "$LOG_FILE"
}
check() {
local label="$1" got="$2" expected="$3"
if [ "$got" -eq "$expected" ]; then
printf " %-20s %s / %s ✓\n" "$label:" "$got" "$expected"
else
printf " %-20s %s / %s ✗ MISMATCH\n" "$label:" "$got" "$expected"
fi
}
# ──────────────────────────────────────────────────────────────────────────────
# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────
if [ "${1:-}" = "today" ]; then
TARGET_DATE=$(date +%Y-%m-%d)
elif [ -n "${1:-}" ]; then
TARGET_DATE="$1"
if ! [[ "$TARGET_DATE" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then
echo "ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday."
exit 1
fi
else
TARGET_DATE=$(date -v-1d +%Y-%m-%d)
fi
log "========================================"
log "Screenpipe sync starting for: $TARGET_DATE"
log "========================================"
# ─── PREFLIGHT ────────────────────────────────────────────────────────────────
step "Preflight checks"
if [ ! -f "$DB_SRC" ]; then
log "ERROR: Source DB not found at $DB_SRC"; exit 1
fi
printf " %-20s %s (%s)\n" "Source DB:" "OK" "$(du -sh "$DB_SRC" | cut -f1)"
if [ ! -d "$NAS_MOUNT" ]; then
log "ERROR: NAS not mounted at $NAS_MOUNT"; exit 1
fi
printf " %-20s %s\n" "NAS mount:" "OK $NAS_MOUNT"
# Check if DB already synced for this date
DB_ALREADY_SYNCED=false
if [ -f "$NAS_DB" ]; then
EXISTING=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';" 2>/dev/null || echo "0")
if [ "$EXISTING" -gt "0" ]; then
log "Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync"
DB_ALREADY_SYNCED=true
else
printf " %-20s %s (%s)\n" "Archive DB:" "exists" "$(du -sh "$NAS_DB" | cut -f1)"
fi
else
printf " %-20s %s\n" "Archive DB:" "will be created"
fi
# Source data dir for this date
DATA_SRC="$HOME/.screenpipe/data/data/$TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
DATA_SIZE=$(du -sh "$DATA_SRC" | cut -f1)
DATA_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
printf " %-20s %s (%s files, %s)\n" "Data dir:" "OK" "$DATA_FILES" "$DATA_SIZE"
else
printf " %-20s %s\n" "Data dir:" "not found — skipping file copy"
fi
# ─── DB SYNC ──────────────────────────────────────────────────────────────────
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────
step "Counting source rows for $TARGET_DATE"
SRC_FRAMES=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
SRC_ELEMENTS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_UI=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
SRC_OCR=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_MEETINGS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';")
printf " %-20s %s\n" "frames:" "$SRC_FRAMES"
printf " %-20s %s\n" "elements:" "$SRC_ELEMENTS"
printf " %-20s %s\n" "ui_events:" "$SRC_UI"
printf " %-20s %s\n" "ocr_text:" "$SRC_OCR"
printf " %-20s %s\n" "meetings:" "$SRC_MEETINGS"
if [ "$SRC_FRAMES" -eq "0" ]; then
log "No frames found for $TARGET_DATE — skipping DB sync"
DB_ALREADY_SYNCED=true
fi
fi
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── INIT TABLES ──────────────────────────────────────────────────────────
step "Initialising tables, indexes, FTS"
run_sqlite_heredoc "creating tables" "
ATTACH '$NAS_DB' AS nas;
CREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;
CREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;
CREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;
CREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;
DETACH nas;
"
run_sqlite_heredoc "creating indexes" "
ATTACH '$NAS_DB' AS nas;
CREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);
CREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);
DETACH nas;
"
run_sqlite_heredoc "creating FTS tables" "
ATTACH '$NAS_DB' AS nas;
CREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(
text, role, frame_id UNINDEXED,
content='elements', content_rowid='id', tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(
full_text, app_name, window_name, browser_url, id UNINDEXED,
tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(
text_content,
app_name,
window_title,
element_name,
content='ui_events',
content_rowid='id',
tokenize='unicode61'
);
DETACH nas;
"
# ─── SYNC DATA ────────────────────────────────────────────────────────────
step "Syncing data for $TARGET_DATE"
run_sqlite_heredoc "video_chunks" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.video_chunks
SELECT * FROM main.video_chunks
WHERE id IN (
SELECT DISTINCT video_chunk_id FROM main.frames
WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL
);
DETACH nas;
"
run_sqlite_heredoc "frames ($SRC_FRAMES rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.frames
SELECT * FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ocr_text ($SRC_OCR rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ocr_text
SELECT o.* FROM main.ocr_text o
JOIN main.frames f ON o.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ui_events ($SRC_UI rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ui_events
SELECT * FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "elements ($SRC_ELEMENTS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.elements
SELECT e.* FROM main.elements e
JOIN main.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "meetings ($SRC_MEETINGS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.meetings
SELECT * FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';
DETACH nas;
"
# ─── FTS UPDATE ───────────────────────────────────────────────────────────
step "Updating FTS indexes"
run_sqlite_heredoc "elements_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.elements_fts(rowid, text, role)
SELECT e.id, e.text, e.role
FROM nas.elements e
JOIN nas.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE'
AND e.text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "frames_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)
SELECT id, full_text, app_name, window_name, browser_url, id
FROM nas.frames
WHERE date(timestamp) = '$TARGET_DATE'
AND full_text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "ui_events_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)
SELECT id, text_content, app_name, window_title, element_name
FROM nas.ui_events
WHERE date(timestamp) = '$TARGET_DATE'
AND text_content IS NOT NULL;
DETACH nas;
"
# ─── VERIFY DB ────────────────────────────────────────────────────────────
step "Verifying DB"
V_FRAMES=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
V_ELEMENTS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_UI=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
V_OCR=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_MEETINGS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';")
check "frames" "$V_FRAMES" "$SRC_FRAMES"
check "elements" "$V_ELEMENTS" "$SRC_ELEMENTS"
check "ui_events" "$V_UI" "$SRC_UI"
check "ocr_text" "$V_OCR" "$SRC_OCR"
check "meetings" "$V_MEETINGS" "$SRC_MEETINGS"
fi
# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────
# Always runs regardless of DB sync status
step "Copying data folder for $TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
mkdir -p "$NAS_DATA/$TARGET_DATE"
RSYNC_START=$(date +%s)
printf " %-36s " "rsync $TARGET_DATE/ → NAS"
rsync -a --ignore-existing \
"$DATA_SRC/" \
"$NAS_DATA/$TARGET_DATE/" \
2>>"$LOG_FILE"
RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))
COPIED_FILES=$(ls "$NAS_DATA/$TARGET_DATE" | wc -l | tr -d ' ')
SRC_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
COPIED_SIZE=$(du -sh "$NAS_DATA/$TARGET_DATE" | cut -f1)
if [ "$COPIED_FILES" -eq "$SRC_FILES" ]; then
printf "\r %-36s ✓ %dm%02ds (%s files, %s)\n" \
"rsync $TARGET_DATE/ → NAS" \
"$(( RSYNC_DUR / 60 ))" "$(( RSYNC_DUR % 60 ))" \
"$COPIED_FILES" "$COPIED_SIZE" | tee -a "$LOG_FILE"
else
printf "\r %-36s ✗ %s / %s files\n" \
"rsync $TARGET_DATE/ → NAS" "$COPIED_FILES" "$SRC_FILES" | tee -a "$LOG_FILE"
fi
else
printf " %-36s %s\n" "rsync $TARGET_DATE/ → NAS" "skipped (no source dir)"
fi
# ─── SUMMARY ──────────────────────────────────────────────────────────────────
TOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))
DB_SIZE=$(du -sh "$NAS_DB" | cut -f1)
echo ""
log "Archive DB size: $DB_SIZE"
log "Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s"
log "Sync complete for $TARGET_DATE"
log "========================================"
Implement and run pipe l…, Editor Group 2
Problems (⇧⌘M)
PROBLEMS
Output (⇧⌘U)
OUTPUT
Debug Console (⇧⌘Y)
DEBUG CONSOLE
Terminal (⌃`)
TERMINAL
Ports - 1 forwarded port
PORTS
1
remote SSH: nas
SSH: nas
screenpipe (Git) - master*, Checkout Branch/Tag...
master*
screenpipe (Git) - Synchronize Changes
No Problems
0
0
Forwarded Ports: 8766
1
Notifications
Sign In
Sign In
Shell Script
Editor Language Status: $(copilot) No inline suggestion available, Inline suggestions
LF
UTF-8
Spaces: 2...
|
[{"role":"AXRadioButton","text [{"role":"AXRadioButton","text":"Explorer (⇧⌘E)","depth":19,"bounds":{"left":0.0,"top":0.047885075,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":true},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.057462092,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Search (⇧⌘F)","depth":19,"bounds":{"left":0.0,"top":0.08619314,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.09577015,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Source Control (⌃⇧G) - 10 pending changes","depth":19,"bounds":{"left":0.0,"top":0.1245012,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.13407822,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"10","depth":22,"bounds":{"left":0.00831117,"top":0.1452514,"width":0.003656915,"height":0.008778931},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.00831117,"top":0.14604948,"width":0.0016622341,"height":0.007980846}},{"char_start":1,"char_count":1,"bounds":{"left":0.009973404,"top":0.14604948,"width":0.0023271276,"height":0.007980846}}],"role_description":"text"},{"role":"AXRadioButton","text":"Run and Debug (⇧⌘D)","depth":19,"bounds":{"left":0.0,"top":0.16280925,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.17238627,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Remote Explorer","depth":19,"bounds":{"left":0.0,"top":0.20111732,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.21069433,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Extensions (⇧⌘X) - 2 require update","depth":19,"bounds":{"left":0.0,"top":0.23942538,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.2490024,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"2","depth":22,"bounds":{"left":0.009640957,"top":0.2601756,"width":0.0019946808,"height":0.008778931},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Claude Code","depth":19,"bounds":{"left":0.0,"top":0.27773345,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"Containers","depth":19,"bounds":{"left":0.0,"top":0.3160415,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXHeading","text":"EXPLORER","depth":17,"bounds":{"left":0.022606382,"top":0.047885075,"width":0.018949468,"height":0.02793296},"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"EXPLORER","depth":18,"bounds":{"left":0.022606382,"top":0.056664005,"width":0.018949468,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.022606382,"top":0.056664005,"width":0.0023271276,"height":0.0103751}},{"char_start":1,"char_count":7,"bounds":{"left":0.024933511,"top":0.056664005,"width":0.01662234,"height":0.0103751}}],"role_description":"text"},{"role":"AXButton","text":"Explorer Section: screenpipe [SSH: nas]","depth":21,"bounds":{"left":0.015957447,"top":0.07581804,"width":0.09940159,"height":0.017557861},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":true},{"role":"AXStaticText","text":"","depth":23,"bounds":{"left":0.01662234,"top":0.07821229,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"Explorer Section: screenpipe [SSH: nas]","depth":22,"bounds":{"left":0.022606382,"top":0.07581804,"width":0.045877658,"height":0.017557861},"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"SCREENPIPE [SSH: NAS]","depth":23,"bounds":{"left":0.022606382,"top":0.079010375,"width":0.045877658,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.022606382,"top":0.07980846,"width":0.0026595744,"height":0.0103751}},{"char_start":1,"char_count":20,"bounds":{"left":0.025265958,"top":0.07980846,"width":0.043218084,"height":0.0103751}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.09577015,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"#recycle","depth":27,"bounds":{"left":0.025930852,"top":0.09577015,"width":0.017287234,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.096568234,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":7,"bounds":{"left":0.028590426,"top":0.096568234,"width":0.01462766,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.11332801,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"app","depth":27,"bounds":{"left":0.025930852,"top":0.11332801,"width":0.0076462766,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.11412609,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":2,"bounds":{"left":0.02825798,"top":0.11412609,"width":0.005319149,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.11412609,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.022273935,"top":0.13088587,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"__pycache__","depth":27,"bounds":{"left":0.028590426,"top":0.13088587,"width":0.026595745,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.13168396,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":10,"bounds":{"left":0.030917553,"top":0.13168396,"width":0.024268618,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.022273935,"top":0.14844373,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"consumers","depth":27,"bounds":{"left":0.028590426,"top":0.14844373,"width":0.022273935,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.14924182,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":8,"bounds":{"left":0.030917553,"top":0.14924182,"width":0.019946808,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.14924182,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.022273935,"top":0.1660016,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"static","depth":27,"bounds":{"left":0.028590426,"top":0.1660016,"width":0.010970744,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.16679968,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":5,"bounds":{"left":0.030917553,"top":0.16679968,"width":0.008976064,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.16679968,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.1819633,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":".env","depth":27,"bounds":{"left":0.028590426,"top":0.18355946,"width":0.00831117,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.18435754,"width":0.0013297872,"height":0.011971269}},{"char_start":1,"char_count":3,"bounds":{"left":0.029920213,"top":0.18435754,"width":0.006981383,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.19952115,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"cli.py","depth":27,"bounds":{"left":0.028590426,"top":0.20111732,"width":0.010638298,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.2019154,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":5,"bounds":{"left":0.030917553,"top":0.2019154,"width":0.00831117,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.2019154,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.21707901,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.py","depth":27,"bounds":{"left":0.028590426,"top":0.21867518,"width":0.011303191,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.21947326,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":4,"bounds":{"left":0.03125,"top":0.21947326,"width":0.008643617,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.23463687,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"docker-compose.yml","depth":27,"bounds":{"left":0.028590426,"top":0.23623304,"width":0.042220745,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.23703113,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":17,"bounds":{"left":0.03125,"top":0.23703113,"width":0.03956117,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.25219473,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Dockerfile","depth":27,"bounds":{"left":0.028590426,"top":0.25379092,"width":0.020611702,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.254589,"width":0.0033244682,"height":0.011971269}},{"char_start":1,"char_count":9,"bounds":{"left":0.031914894,"top":0.254589,"width":0.017287234,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.254589,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.2697526,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"main.py","depth":27,"bounds":{"left":0.028590426,"top":0.27134877,"width":0.015625,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.27214685,"width":0.003656915,"height":0.011971269}},{"char_start":1,"char_count":6,"bounds":{"left":0.032247342,"top":0.27214685,"width":0.012300532,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.27214685,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.28731045,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"requirements.txt","depth":27,"bounds":{"left":0.028590426,"top":0.28890663,"width":0.032912236,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.2897047,"width":0.0016622341,"height":0.011971269}},{"char_start":1,"char_count":15,"bounds":{"left":0.03025266,"top":0.2897047,"width":0.03158245,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.2897047,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.3064645,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"data","depth":27,"bounds":{"left":0.025930852,"top":0.3064645,"width":0.008976064,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.30726257,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":3,"bounds":{"left":0.028590426,"top":0.30726257,"width":0.0063164895,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.32402235,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"logs","depth":27,"bounds":{"left":0.025930852,"top":0.32402235,"width":0.00831117,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.32482043,"width":0.0009973404,"height":0.011971269}},{"char_start":1,"char_count":3,"bounds":{"left":0.026928192,"top":0.32482043,"width":0.0076462766,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.32482043,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.3415802,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"pipes","depth":27,"bounds":{"left":0.025930852,"top":0.3415802,"width":0.010970744,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.3423783,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":4,"bounds":{"left":0.028590426,"top":0.3423783,"width":0.00831117,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.3575419,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":".gitignore","depth":27,"bounds":{"left":0.025930852,"top":0.35913807,"width":0.018949468,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.35993615,"width":0.0013297872,"height":0.011971269}},{"char_start":1,"char_count":9,"bounds":{"left":0.027260639,"top":0.35993615,"width":0.017952127,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.37509975,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"app_settings.json","depth":27,"bounds":{"left":0.025930852,"top":0.37669593,"width":0.03557181,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.377494,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":16,"bounds":{"left":0.02825798,"top":0.377494,"width":0.03324468,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.3926576,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"archive.db","depth":27,"bounds":{"left":0.025930852,"top":0.3942538,"width":0.020944148,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.39505187,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":9,"bounds":{"left":0.02825798,"top":0.39505187,"width":0.01861702,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.4102155,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"archive.db-bak","depth":27,"bounds":{"left":0.025930852,"top":0.41181165,"width":0.03025266,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.41260973,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":13,"bounds":{"left":0.02825798,"top":0.41260973,"width":0.027925532,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"U","depth":27,"bounds":{"left":0.10704787,"top":0.41260973,"width":0.0029920214,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.42777336,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite","depth":27,"bounds":{"left":0.025930852,"top":0.4293695,"width":0.017287234,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.4301676,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":8,"bounds":{"left":0.028590426,"top":0.4301676,"width":0.014960106,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.44533122,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite-shm","depth":27,"bounds":{"left":0.025930852,"top":0.44692737,"width":0.027925532,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.44772545,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":12,"bounds":{"left":0.028590426,"top":0.44772545,"width":0.025265958,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.46288908,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite-wal","depth":27,"bounds":{"left":0.025930852,"top":0.46448523,"width":0.025930852,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.46528333,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":12,"bounds":{"left":0.028590426,"top":0.46528333,"width":0.023603724,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.48044693,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe_sync_updated.sh","depth":27,"bounds":{"left":0.025930852,"top":0.4820431,"width":0.059175532,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.4828412,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":25,"bounds":{"left":0.02825798,"top":0.4828412,"width":0.056848403,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"U","depth":27,"bounds":{"left":0.10704787,"top":0.4828412,"width":0.0029920214,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.4980048,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe_sync.sh","depth":27,"bounds":{"left":0.025930852,"top":0.49960095,"width":0.039893616,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.50039905,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":17,"bounds":{"left":0.02825798,"top":0.50039905,"width":0.037898935,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.51556265,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe.db","depth":27,"bounds":{"left":0.025930852,"top":0.5171588,"width":0.028590426,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.5179569,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":12,"bounds":{"left":0.02825798,"top":0.5179569,"width":0.026595745,"height":0.011971269}}],"role_description":"text"},{"role":"AXButton","text":"Outline Section","depth":21,"bounds":{"left":0.015957447,"top":0.9473264,"width":0.09940159,"height":0.017557861},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":23,"bounds":{"left":0.01662234,"top":0.9497207,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"OUTLINE","depth":22,"bounds":{"left":0.022606382,"top":0.9473264,"width":0.01662234,"height":0.017557861},"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"OUTLINE","depth":23,"bounds":{"left":0.022606382,"top":0.95131683,"width":0.01662234,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.022606382,"top":0.95131683,"width":0.0029920214,"height":0.0103751}},{"char_start":1,"char_count":6,"bounds":{"left":0.025598405,"top":0.95131683,"width":0.013630319,"height":0.0103751}}],"role_description":"text"},{"role":"AXButton","text":"Timeline Section","depth":21,"bounds":{"left":0.015957447,"top":0.9648843,"width":0.09940159,"height":0.017557861},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":23,"bounds":{"left":0.01662234,"top":0.96727854,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"TIMELINE","depth":22,"bounds":{"left":0.022606382,"top":0.9648843,"width":0.01761968,"height":0.017557861},"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"TIMELINE","depth":23,"bounds":{"left":0.022606382,"top":0.9688747,"width":0.01761968,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.022606382,"top":0.9688747,"width":0.0026595744,"height":0.0103751}},{"char_start":1,"char_count":7,"bounds":{"left":0.025265958,"top":0.9688747,"width":0.015292553,"height":0.0103751}}],"role_description":"text"},{"role":"AXRadioButton","text":"app_settings.json, Editor Group 1","depth":28,"bounds":{"left":0.11569149,"top":0.047885075,"width":0.055851065,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"screenpipe_sync.sh, Editor Group 1","depth":28,"bounds":{"left":0.17154256,"top":0.047885075,"width":0.06050532,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":false},{"role":"AXRadioButton","text":"pipe.md, Editor Group 1","depth":28,"bounds":{"left":0.23171543,"top":0.047885075,"width":0.040226065,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":".env, Editor Group 1","depth":28,"bounds":{"left":0.27194148,"top":0.047885075,"width":0.039893616,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"#!/bin/bash\n# screenpipe_sync.sh\n# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).\n# Also copies the day's video/frame data folder to the NAS.\n#\n# Usage:\n# ./screenpipe_sync.sh # syncs yesterday (default)\n# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date\n# ./screenpipe_sync.sh today # syncs today so far\n#\n# Cron example (runs at 3am daily):\n# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1\n\nset -euo pipefail\n\n# ─── CONFIG ───────────────────────────────────────────────────────────────────\nDB_SRC=\"${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}\"\nNAS_MOUNT=\"${NAS_MOUNT:-/Volumes/Test/screenpipe}\"\nNAS_DB=\"$NAS_MOUNT/archive.db\"\nNAS_DATA=\"$NAS_MOUNT/data\"\nLOG_FILE=\"$HOME/.screenpipe/sync.log\"\n# ──────────────────────────────────────────────────────────────────────────────\n\n# ─── HELPERS ──────────────────────────────────────────────────────────────────\nSCRIPT_START=$(date +%s)\n\nlog() {\n local msg=\"[$(date '+%Y-%m-%d %H:%M:%S')] $*\"\n echo \"$msg\" | tee -a \"$LOG_FILE\"\n}\n\nstep() {\n local now=$(date +%s)\n local elapsed=$(( now - SCRIPT_START ))\n local min=$(( elapsed / 60 ))\n local sec=$(( elapsed % 60 ))\n printf \"\\n[+%02dm%02ds] ▶ %s\\n\" \"$min\" \"$sec\" \"$*\" | tee -a \"$LOG_FILE\"\n}\n\nrun_sqlite_heredoc() {\n local label=\"$1\"\n local sql=\"$2\"\n local start=$(date +%s)\n\n printf \" %-36s \" \"$label\"\n\n sqlite3 \"$DB_SRC\" <<< \"$sql\" &\n local pid=$!\n local spin=('⠋' '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')\n local i=0\n while kill -0 \"$pid\" 2>/dev/null; do\n printf \"\\r %-36s %s \" \"$label\" \"${spin[$i]}\"\n i=$(( (i + 1) % 10 ))\n sleep 0.2\n done\n wait \"$pid\"\n local rc=$?\n if [ $rc -ne 0 ]; then\n printf \"\\r %-36s ✗ FAILED\\n\" \"$label\" | tee -a \"$LOG_FILE\"\n exit $rc\n fi\n\n local dur=$(( $(date +%s) - start ))\n printf \"\\r %-36s ✓ %dm%02ds\\n\" \"$label\" \"$(( dur / 60 ))\" \"$(( dur % 60 ))\" | tee -a \"$LOG_FILE\"\n}\n\ncheck() {\n local label=\"$1\" got=\"$2\" expected=\"$3\"\n if [ \"$got\" -eq \"$expected\" ]; then\n printf \" %-20s %s / %s ✓\\n\" \"$label:\" \"$got\" \"$expected\"\n else\n printf \" %-20s %s / %s ✗ MISMATCH\\n\" \"$label:\" \"$got\" \"$expected\"\n fi\n}\n# ──────────────────────────────────────────────────────────────────────────────\n\n# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────\nif [ \"${1:-}\" = \"today\" ]; then\n TARGET_DATE=$(date +%Y-%m-%d)\nelif [ -n \"${1:-}\" ]; then\n TARGET_DATE=\"$1\"\n if ! [[ \"$TARGET_DATE\" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then\n echo \"ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday.\"\n exit 1\n fi\nelse\n TARGET_DATE=$(date -v-1d +%Y-%m-%d)\nfi\n\nlog \"========================================\"\nlog \"Screenpipe sync starting for: $TARGET_DATE\"\nlog \"========================================\"\n\n# ─── PREFLIGHT ────────────────────────────────────────────────────────────────\nstep \"Preflight checks\"\n\nif [ ! -f \"$DB_SRC\" ]; then\n log \"ERROR: Source DB not found at $DB_SRC\"; exit 1\nfi\nprintf \" %-20s %s (%s)\\n\" \"Source DB:\" \"OK\" \"$(du -sh \"$DB_SRC\" | cut -f1)\"\n\nif [ ! -d \"$NAS_MOUNT\" ]; then\n log \"ERROR: NAS not mounted at $NAS_MOUNT\"; exit 1\nfi\nprintf \" %-20s %s\\n\" \"NAS mount:\" \"OK $NAS_MOUNT\"\n\n# Check if DB already synced for this date\nDB_ALREADY_SYNCED=false\nif [ -f \"$NAS_DB\" ]; then\n EXISTING=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\" 2>/dev/null || echo \"0\")\n if [ \"$EXISTING\" -gt \"0\" ]; then\n log \"Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync\"\n DB_ALREADY_SYNCED=true\n else\n printf \" %-20s %s (%s)\\n\" \"Archive DB:\" \"exists\" \"$(du -sh \"$NAS_DB\" | cut -f1)\"\n fi\nelse\n printf \" %-20s %s\\n\" \"Archive DB:\" \"will be created\"\nfi\n\n# Source data dir for this date\nDATA_SRC=\"$HOME/.screenpipe/data/data/$TARGET_DATE\"\nif [ -d \"$DATA_SRC\" ]; then\n DATA_SIZE=$(du -sh \"$DATA_SRC\" | cut -f1)\n DATA_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n printf \" %-20s %s (%s files, %s)\\n\" \"Data dir:\" \"OK\" \"$DATA_FILES\" \"$DATA_SIZE\"\nelse\n printf \" %-20s %s\\n\" \"Data dir:\" \"not found — skipping file copy\"\nfi\n\n# ─── DB SYNC ──────────────────────────────────────────────────────────────────\nif [ \"$DB_ALREADY_SYNCED\" = false ]; then\n\n # ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────\n step \"Counting source rows for $TARGET_DATE\"\n\n SRC_FRAMES=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\")\n SRC_ELEMENTS=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n SRC_UI=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';\")\n SRC_OCR=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n SRC_MEETINGS=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';\")\n\n printf \" %-20s %s\\n\" \"frames:\" \"$SRC_FRAMES\"\n printf \" %-20s %s\\n\" \"elements:\" \"$SRC_ELEMENTS\"\n printf \" %-20s %s\\n\" \"ui_events:\" \"$SRC_UI\"\n printf \" %-20s %s\\n\" \"ocr_text:\" \"$SRC_OCR\"\n printf \" %-20s %s\\n\" \"meetings:\" \"$SRC_MEETINGS\"\n\n if [ \"$SRC_FRAMES\" -eq \"0\" ]; then\n log \"No frames found for $TARGET_DATE — skipping DB sync\"\n DB_ALREADY_SYNCED=true\n fi\n\nfi\n\nif [ \"$DB_ALREADY_SYNCED\" = false ]; then\n\n # ─── INIT TABLES ──────────────────────────────────────────────────────────\n step \"Initialising tables, indexes, FTS\"\n\n run_sqlite_heredoc \"creating tables\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"creating indexes\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);\nCREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);\nCREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"creating FTS tables\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(\n text, role, frame_id UNINDEXED,\n content='elements', content_rowid='id', tokenize='unicode61'\n);\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(\n full_text, app_name, window_name, browser_url, id UNINDEXED,\n tokenize='unicode61'\n);\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(\n text_content,\n app_name,\n window_title,\n element_name,\n content='ui_events',\n content_rowid='id',\n tokenize='unicode61'\n);\nDETACH nas;\n\"\n\n # ─── SYNC DATA ────────────────────────────────────────────────────────────\n step \"Syncing data for $TARGET_DATE\"\n\n run_sqlite_heredoc \"video_chunks\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.video_chunks\n SELECT * FROM main.video_chunks\n WHERE id IN (\n SELECT DISTINCT video_chunk_id FROM main.frames\n WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL\n );\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames ($SRC_FRAMES rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.frames\n SELECT * FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ocr_text ($SRC_OCR rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ocr_text\n SELECT o.* FROM main.ocr_text o\n JOIN main.frames f ON o.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events ($SRC_UI rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ui_events\n SELECT * FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"elements ($SRC_ELEMENTS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.elements\n SELECT e.* FROM main.elements e\n JOIN main.frames f ON e.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"meetings ($SRC_MEETINGS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.meetings\n SELECT * FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n # ─── FTS UPDATE ───────────────────────────────────────────────────────────\n step \"Updating FTS indexes\"\n\n run_sqlite_heredoc \"elements_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.elements_fts(rowid, text, role)\n SELECT e.id, e.text, e.role\n FROM nas.elements e\n JOIN nas.frames f ON e.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE'\n AND e.text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)\n SELECT id, full_text, app_name, window_name, browser_url, id\n FROM nas.frames\n WHERE date(timestamp) = '$TARGET_DATE'\n AND full_text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)\n SELECT id, text_content, app_name, window_title, element_name\n FROM nas.ui_events\n WHERE date(timestamp) = '$TARGET_DATE'\n AND text_content IS NOT NULL;\nDETACH nas;\n\"\n\n # ─── VERIFY DB ────────────────────────────────────────────────────────────\n step \"Verifying DB\"\n\n V_FRAMES=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\")\n V_ELEMENTS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n V_UI=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';\")\n V_OCR=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n V_MEETINGS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';\")\n\n check \"frames\" \"$V_FRAMES\" \"$SRC_FRAMES\"\n check \"elements\" \"$V_ELEMENTS\" \"$SRC_ELEMENTS\"\n check \"ui_events\" \"$V_UI\" \"$SRC_UI\"\n check \"ocr_text\" \"$V_OCR\" \"$SRC_OCR\"\n check \"meetings\" \"$V_MEETINGS\" \"$SRC_MEETINGS\"\n\nfi\n\n# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────\n# Always runs regardless of DB sync status\nstep \"Copying data folder for $TARGET_DATE\"\n\nif [ -d \"$DATA_SRC\" ]; then\n mkdir -p \"$NAS_DATA/$TARGET_DATE\"\n RSYNC_START=$(date +%s)\n printf \" %-36s \" \"rsync $TARGET_DATE/ → NAS\"\n rsync -a --ignore-existing \\\n \"$DATA_SRC/\" \\\n \"$NAS_DATA/$TARGET_DATE/\" \\\n 2>>\"$LOG_FILE\"\n RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))\n COPIED_FILES=$(ls \"$NAS_DATA/$TARGET_DATE\" | wc -l | tr -d ' ')\n SRC_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n COPIED_SIZE=$(du -sh \"$NAS_DATA/$TARGET_DATE\" | cut -f1)\n if [ \"$COPIED_FILES\" -eq \"$SRC_FILES\" ]; then\n printf \"\\r %-36s ✓ %dm%02ds (%s files, %s)\\n\" \\\n \"rsync $TARGET_DATE/ → NAS\" \\\n \"$(( RSYNC_DUR / 60 ))\" \"$(( RSYNC_DUR % 60 ))\" \\\n \"$COPIED_FILES\" \"$COPIED_SIZE\" | tee -a \"$LOG_FILE\"\n else\n printf \"\\r %-36s ✗ %s / %s files\\n\" \\\n \"rsync $TARGET_DATE/ → NAS\" \"$COPIED_FILES\" \"$SRC_FILES\" | tee -a \"$LOG_FILE\"\n fi\nelse\n printf \" %-36s %s\\n\" \"rsync $TARGET_DATE/ → NAS\" \"skipped (no source dir)\"\nfi\n\n# ─── SUMMARY ──────────────────────────────────────────────────────────────────\nTOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))\nDB_SIZE=$(du -sh \"$NAS_DB\" | cut -f1)\n\necho \"\"\nlog \"Archive DB size: $DB_SIZE\"\nlog \"Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s\"\nlog \"Sync complete for $TARGET_DATE\"\nlog \"========================================\"","depth":28,"bounds":{"left":0.13763298,"top":0.40542698,"width":0.38031915,"height":0.014365523},"on_screen":true,"value":"#!/bin/bash\n# screenpipe_sync.sh\n# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).\n# Also copies the day's video/frame data folder to the NAS.\n#\n# Usage:\n# ./screenpipe_sync.sh # syncs yesterday (default)\n# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date\n# ./screenpipe_sync.sh today # syncs today so far\n#\n# Cron example (runs at 3am daily):\n# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1\n\nset -euo pipefail\n\n# ─── CONFIG ───────────────────────────────────────────────────────────────────\nDB_SRC=\"${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}\"\nNAS_MOUNT=\"${NAS_MOUNT:-/Volumes/Test/screenpipe}\"\nNAS_DB=\"$NAS_MOUNT/archive.db\"\nNAS_DATA=\"$NAS_MOUNT/data\"\nLOG_FILE=\"$HOME/.screenpipe/sync.log\"\n# ──────────────────────────────────────────────────────────────────────────────\n\n# ─── HELPERS ──────────────────────────────────────────────────────────────────\nSCRIPT_START=$(date +%s)\n\nlog() {\n local msg=\"[$(date '+%Y-%m-%d %H:%M:%S')] $*\"\n echo \"$msg\" | tee -a \"$LOG_FILE\"\n}\n\nstep() {\n local now=$(date +%s)\n local elapsed=$(( now - SCRIPT_START ))\n local min=$(( elapsed / 60 ))\n local sec=$(( elapsed % 60 ))\n printf \"\\n[+%02dm%02ds] ▶ %s\\n\" \"$min\" \"$sec\" \"$*\" | tee -a \"$LOG_FILE\"\n}\n\nrun_sqlite_heredoc() {\n local label=\"$1\"\n local sql=\"$2\"\n local start=$(date +%s)\n\n printf \" %-36s \" \"$label\"\n\n sqlite3 \"$DB_SRC\" <<< \"$sql\" &\n local pid=$!\n local spin=('⠋' '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')\n local i=0\n while kill -0 \"$pid\" 2>/dev/null; do\n printf \"\\r %-36s %s \" \"$label\" \"${spin[$i]}\"\n i=$(( (i + 1) % 10 ))\n sleep 0.2\n done\n wait \"$pid\"\n local rc=$?\n if [ $rc -ne 0 ]; then\n printf \"\\r %-36s ✗ FAILED\\n\" \"$label\" | tee -a \"$LOG_FILE\"\n exit $rc\n fi\n\n local dur=$(( $(date +%s) - start ))\n printf \"\\r %-36s ✓ %dm%02ds\\n\" \"$label\" \"$(( dur / 60 ))\" \"$(( dur % 60 ))\" | tee -a \"$LOG_FILE\"\n}\n\ncheck() {\n local label=\"$1\" got=\"$2\" expected=\"$3\"\n if [ \"$got\" -eq \"$expected\" ]; then\n printf \" %-20s %s / %s ✓\\n\" \"$label:\" \"$got\" \"$expected\"\n else\n printf \" %-20s %s / %s ✗ MISMATCH\\n\" \"$label:\" \"$got\" \"$expected\"\n fi\n}\n# ──────────────────────────────────────────────────────────────────────────────\n\n# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────\nif [ \"${1:-}\" = \"today\" ]; then\n TARGET_DATE=$(date +%Y-%m-%d)\nelif [ -n \"${1:-}\" ]; then\n TARGET_DATE=\"$1\"\n if ! [[ \"$TARGET_DATE\" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then\n echo \"ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday.\"\n exit 1\n fi\nelse\n TARGET_DATE=$(date -v-1d +%Y-%m-%d)\nfi\n\nlog \"========================================\"\nlog \"Screenpipe sync starting for: $TARGET_DATE\"\nlog \"========================================\"\n\n# ─── PREFLIGHT ────────────────────────────────────────────────────────────────\nstep \"Preflight checks\"\n\nif [ ! -f \"$DB_SRC\" ]; then\n log \"ERROR: Source DB not found at $DB_SRC\"; exit 1\nfi\nprintf \" %-20s %s (%s)\\n\" \"Source DB:\" \"OK\" \"$(du -sh \"$DB_SRC\" | cut -f1)\"\n\nif [ ! -d \"$NAS_MOUNT\" ]; then\n log \"ERROR: NAS not mounted at $NAS_MOUNT\"; exit 1\nfi\nprintf \" %-20s %s\\n\" \"NAS mount:\" \"OK $NAS_MOUNT\"\n\n# Check if DB already synced for this date\nDB_ALREADY_SYNCED=false\nif [ -f \"$NAS_DB\" ]; then\n EXISTING=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\" 2>/dev/null || echo \"0\")\n if [ \"$EXISTING\" -gt \"0\" ]; then\n log \"Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync\"\n DB_ALREADY_SYNCED=true\n else\n printf \" %-20s %s (%s)\\n\" \"Archive DB:\" \"exists\" \"$(du -sh \"$NAS_DB\" | cut -f1)\"\n fi\nelse\n printf \" %-20s %s\\n\" \"Archive DB:\" \"will be created\"\nfi\n\n# Source data dir for this date\nDATA_SRC=\"$HOME/.screenpipe/data/data/$TARGET_DATE\"\nif [ -d \"$DATA_SRC\" ]; then\n DATA_SIZE=$(du -sh \"$DATA_SRC\" | cut -f1)\n DATA_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n printf \" %-20s %s (%s files, %s)\\n\" \"Data dir:\" \"OK\" \"$DATA_FILES\" \"$DATA_SIZE\"\nelse\n printf \" %-20s %s\\n\" \"Data dir:\" \"not found — skipping file copy\"\nfi\n\n# ─── DB SYNC ──────────────────────────────────────────────────────────────────\nif [ \"$DB_ALREADY_SYNCED\" = false ]; then\n\n # ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────\n step \"Counting source rows for $TARGET_DATE\"\n\n SRC_FRAMES=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\")\n SRC_ELEMENTS=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n SRC_UI=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';\")\n SRC_OCR=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n SRC_MEETINGS=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';\")\n\n printf \" %-20s %s\\n\" \"frames:\" \"$SRC_FRAMES\"\n printf \" %-20s %s\\n\" \"elements:\" \"$SRC_ELEMENTS\"\n printf \" %-20s %s\\n\" \"ui_events:\" \"$SRC_UI\"\n printf \" %-20s %s\\n\" \"ocr_text:\" \"$SRC_OCR\"\n printf \" %-20s %s\\n\" \"meetings:\" \"$SRC_MEETINGS\"\n\n if [ \"$SRC_FRAMES\" -eq \"0\" ]; then\n log \"No frames found for $TARGET_DATE — skipping DB sync\"\n DB_ALREADY_SYNCED=true\n fi\n\nfi\n\nif [ \"$DB_ALREADY_SYNCED\" = false ]; then\n\n # ─── INIT TABLES ──────────────────────────────────────────────────────────\n step \"Initialising tables, indexes, FTS\"\n\n run_sqlite_heredoc \"creating tables\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"creating indexes\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);\nCREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);\nCREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"creating FTS tables\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(\n text, role, frame_id UNINDEXED,\n content='elements', content_rowid='id', tokenize='unicode61'\n);\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(\n full_text, app_name, window_name, browser_url, id UNINDEXED,\n tokenize='unicode61'\n);\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(\n text_content,\n app_name,\n window_title,\n element_name,\n content='ui_events',\n content_rowid='id',\n tokenize='unicode61'\n);\nDETACH nas;\n\"\n\n # ─── SYNC DATA ────────────────────────────────────────────────────────────\n step \"Syncing data for $TARGET_DATE\"\n\n run_sqlite_heredoc \"video_chunks\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.video_chunks\n SELECT * FROM main.video_chunks\n WHERE id IN (\n SELECT DISTINCT video_chunk_id FROM main.frames\n WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL\n );\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames ($SRC_FRAMES rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.frames\n SELECT * FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ocr_text ($SRC_OCR rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ocr_text\n SELECT o.* FROM main.ocr_text o\n JOIN main.frames f ON o.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events ($SRC_UI rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ui_events\n SELECT * FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"elements ($SRC_ELEMENTS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.elements\n SELECT e.* FROM main.elements e\n JOIN main.frames f ON e.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"meetings ($SRC_MEETINGS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.meetings\n SELECT * FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n # ─── FTS UPDATE ───────────────────────────────────────────────────────────\n step \"Updating FTS indexes\"\n\n run_sqlite_heredoc \"elements_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.elements_fts(rowid, text, role)\n SELECT e.id, e.text, e.role\n FROM nas.elements e\n JOIN nas.frames f ON e.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE'\n AND e.text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)\n SELECT id, full_text, app_name, window_name, browser_url, id\n FROM nas.frames\n WHERE date(timestamp) = '$TARGET_DATE'\n AND full_text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)\n SELECT id, text_content, app_name, window_title, element_name\n FROM nas.ui_events\n WHERE date(timestamp) = '$TARGET_DATE'\n AND text_content IS NOT NULL;\nDETACH nas;\n\"\n\n # ─── VERIFY DB ────────────────────────────────────────────────────────────\n step \"Verifying DB\"\n\n V_FRAMES=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\")\n V_ELEMENTS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n V_UI=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';\")\n V_OCR=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n V_MEETINGS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';\")\n\n check \"frames\" \"$V_FRAMES\" \"$SRC_FRAMES\"\n check \"elements\" \"$V_ELEMENTS\" \"$SRC_ELEMENTS\"\n check \"ui_events\" \"$V_UI\" \"$SRC_UI\"\n check \"ocr_text\" \"$V_OCR\" \"$SRC_OCR\"\n check \"meetings\" \"$V_MEETINGS\" \"$SRC_MEETINGS\"\n\nfi\n\n# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────\n# Always runs regardless of DB sync status\nstep \"Copying data folder for $TARGET_DATE\"\n\nif [ -d \"$DATA_SRC\" ]; then\n mkdir -p \"$NAS_DATA/$TARGET_DATE\"\n RSYNC_START=$(date +%s)\n printf \" %-36s \" \"rsync $TARGET_DATE/ → NAS\"\n rsync -a --ignore-existing \\\n \"$DATA_SRC/\" \\\n \"$NAS_DATA/$TARGET_DATE/\" \\\n 2>>\"$LOG_FILE\"\n RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))\n COPIED_FILES=$(ls \"$NAS_DATA/$TARGET_DATE\" | wc -l | tr -d ' ')\n SRC_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n COPIED_SIZE=$(du -sh \"$NAS_DATA/$TARGET_DATE\" | cut -f1)\n if [ \"$COPIED_FILES\" -eq \"$SRC_FILES\" ]; then\n printf \"\\r %-36s ✓ %dm%02ds (%s files, %s)\\n\" \\\n \"rsync $TARGET_DATE/ → NAS\" \\\n \"$(( RSYNC_DUR / 60 ))\" \"$(( RSYNC_DUR % 60 ))\" \\\n \"$COPIED_FILES\" \"$COPIED_SIZE\" | tee -a \"$LOG_FILE\"\n else\n printf \"\\r %-36s ✗ %s / %s files\\n\" \\\n \"rsync $TARGET_DATE/ → NAS\" \"$COPIED_FILES\" \"$SRC_FILES\" | tee -a \"$LOG_FILE\"\n fi\nelse\n printf \" %-36s %s\\n\" \"rsync $TARGET_DATE/ → NAS\" \"skipped (no source dir)\"\nfi\n\n# ─── SUMMARY ──────────────────────────────────────────────────────────────────\nTOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))\nDB_SIZE=$(du -sh \"$NAS_DB\" | cut -f1)\n\necho \"\"\nlog \"Archive DB size: $DB_SIZE\"\nlog \"Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s\"\nlog \"Sync complete for $TARGET_DATE\"\nlog \"========================================\"","role_description":"editor","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"#!/bin/bash\n# screenpipe_sync.sh\n# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).\n# Also copies the day's video/frame data folder to the NAS.\n#\n# Usage:\n# ./screenpipe_sync.sh # syncs yesterday (default)\n# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date\n# ./screenpipe_sync.sh today # syncs today so far\n#\n# Cron example (runs at 3am daily):\n# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1\n\nset -euo pipefail\n\n# ─── CONFIG ───────────────────────────────────────────────────────────────────\nDB_SRC=\"${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}\"\nNAS_MOUNT=\"${NAS_MOUNT:-/Volumes/Test/screenpipe}\"\nNAS_DB=\"$NAS_MOUNT/archive.db\"\nNAS_DATA=\"$NAS_MOUNT/data\"\nLOG_FILE=\"$HOME/.screenpipe/sync.log\"\n# ──────────────────────────────────────────────────────────────────────────────\n\n# ─── HELPERS ──────────────────────────────────────────────────────────────────\nSCRIPT_START=$(date +%s)\n\nlog() {\n local msg=\"[$(date '+%Y-%m-%d %H:%M:%S')] $*\"\n echo \"$msg\" | tee -a \"$LOG_FILE\"\n}\n\nstep() {\n local now=$(date +%s)\n local elapsed=$(( now - SCRIPT_START ))\n local min=$(( elapsed / 60 ))\n local sec=$(( elapsed % 60 ))\n printf \"\\n[+%02dm%02ds] ▶ %s\\n\" \"$min\" \"$sec\" \"$*\" | tee -a \"$LOG_FILE\"\n}\n\nrun_sqlite_heredoc() {\n local label=\"$1\"\n local sql=\"$2\"\n local start=$(date +%s)\n\n printf \" %-36s \" \"$label\"\n\n sqlite3 \"$DB_SRC\" <<< \"$sql\" &\n local pid=$!\n local spin=('⠋' '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')\n local i=0\n while kill -0 \"$pid\" 2>/dev/null; do\n printf \"\\r %-36s %s \" \"$label\" \"${spin[$i]}\"\n i=$(( (i + 1) % 10 ))\n sleep 0.2\n done\n wait \"$pid\"\n local rc=$?\n if [ $rc -ne 0 ]; then\n printf \"\\r %-36s ✗ FAILED\\n\" \"$label\" | tee -a \"$LOG_FILE\"\n exit $rc\n fi\n\n local dur=$(( $(date +%s) - start ))\n printf \"\\r %-36s ✓ %dm%02ds\\n\" \"$label\" \"$(( dur / 60 ))\" \"$(( dur % 60 ))\" | tee -a \"$LOG_FILE\"\n}\n\ncheck() {\n local label=\"$1\" got=\"$2\" expected=\"$3\"\n if [ \"$got\" -eq \"$expected\" ]; then\n printf \" %-20s %s / %s ✓\\n\" \"$label:\" \"$got\" \"$expected\"\n else\n printf \" %-20s %s / %s ✗ MISMATCH\\n\" \"$label:\" \"$got\" \"$expected\"\n fi\n}\n# ──────────────────────────────────────────────────────────────────────────────\n\n# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────\nif [ \"${1:-}\" = \"today\" ]; then\n TARGET_DATE=$(date +%Y-%m-%d)\nelif [ -n \"${1:-}\" ]; then\n TARGET_DATE=\"$1\"\n if ! [[ \"$TARGET_DATE\" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then\n echo \"ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday.\"\n exit 1\n fi\nelse\n TARGET_DATE=$(date -v-1d +%Y-%m-%d)\nfi\n\nlog \"========================================\"\nlog \"Screenpipe sync starting for: $TARGET_DATE\"\nlog \"========================================\"\n\n# ─── PREFLIGHT ────────────────────────────────────────────────────────────────\nstep \"Preflight checks\"\n\nif [ ! -f \"$DB_SRC\" ]; then\n log \"ERROR: Source DB not found at $DB_SRC\"; exit 1\nfi\nprintf \" %-20s %s (%s)\\n\" \"Source DB:\" \"OK\" \"$(du -sh \"$DB_SRC\" | cut -f1)\"\n\nif [ ! -d \"$NAS_MOUNT\" ]; then\n log \"ERROR: NAS not mounted at $NAS_MOUNT\"; exit 1\nfi\nprintf \" %-20s %s\\n\" \"NAS mount:\" \"OK $NAS_MOUNT\"\n\n# Check if DB already synced for this date\nDB_ALREADY_SYNCED=false\nif [ -f \"$NAS_DB\" ]; then\n EXISTING=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\" 2>/dev/null || echo \"0\")\n if [ \"$EXISTING\" -gt \"0\" ]; then\n log \"Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync\"\n DB_ALREADY_SYNCED=true\n else\n printf \" %-20s %s (%s)\\n\" \"Archive DB:\" \"exists\" \"$(du -sh \"$NAS_DB\" | cut -f1)\"\n fi\nelse\n printf \" %-20s %s\\n\" \"Archive DB:\" \"will be created\"\nfi\n\n# Source data dir for this date\nDATA_SRC=\"$HOME/.screenpipe/data/data/$TARGET_DATE\"\nif [ -d \"$DATA_SRC\" ]; then\n DATA_SIZE=$(du -sh \"$DATA_SRC\" | cut -f1)\n DATA_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n printf \" %-20s %s (%s files, %s)\\n\" \"Data dir:\" \"OK\" \"$DATA_FILES\" \"$DATA_SIZE\"\nelse\n printf \" %-20s %s\\n\" \"Data dir:\" \"not found — skipping file copy\"\nfi\n\n# ─── DB SYNC ──────────────────────────────────────────────────────────────────\nif [ \"$DB_ALREADY_SYNCED\" = false ]; then\n\n # ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────\n step \"Counting source rows for $TARGET_DATE\"\n\n SRC_FRAMES=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\")\n SRC_ELEMENTS=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n SRC_UI=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';\")\n SRC_OCR=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n SRC_MEETINGS=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';\")\n\n printf \" %-20s %s\\n\" \"frames:\" \"$SRC_FRAMES\"\n printf \" %-20s %s\\n\" \"elements:\" \"$SRC_ELEMENTS\"\n printf \" %-20s %s\\n\" \"ui_events:\" \"$SRC_UI\"\n printf \" %-20s %s\\n\" \"ocr_text:\" \"$SRC_OCR\"\n printf \" %-20s %s\\n\" \"meetings:\" \"$SRC_MEETINGS\"\n\n if [ \"$SRC_FRAMES\" -eq \"0\" ]; then\n log \"No frames found for $TARGET_DATE — skipping DB sync\"\n DB_ALREADY_SYNCED=true\n fi\n\nfi\n\nif [ \"$DB_ALREADY_SYNCED\" = false ]; then\n\n # ─── INIT TABLES ──────────────────────────────────────────────────────────\n step \"Initialising tables, indexes, FTS\"\n\n run_sqlite_heredoc \"creating tables\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"creating indexes\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);\nCREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);\nCREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"creating FTS tables\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(\n text, role, frame_id UNINDEXED,\n content='elements', content_rowid='id', tokenize='unicode61'\n);\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(\n full_text, app_name, window_name, browser_url, id UNINDEXED,\n tokenize='unicode61'\n);\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(\n text_content,\n app_name,\n window_title,\n element_name,\n content='ui_events',\n content_rowid='id',\n tokenize='unicode61'\n);\nDETACH nas;\n\"\n\n # ─── SYNC DATA ────────────────────────────────────────────────────────────\n step \"Syncing data for $TARGET_DATE\"\n\n run_sqlite_heredoc \"video_chunks\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.video_chunks\n SELECT * FROM main.video_chunks\n WHERE id IN (\n SELECT DISTINCT video_chunk_id FROM main.frames\n WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL\n );\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames ($SRC_FRAMES rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.frames\n SELECT * FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ocr_text ($SRC_OCR rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ocr_text\n SELECT o.* FROM main.ocr_text o\n JOIN main.frames f ON o.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events ($SRC_UI rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ui_events\n SELECT * FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"elements ($SRC_ELEMENTS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.elements\n SELECT e.* FROM main.elements e\n JOIN main.frames f ON e.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"meetings ($SRC_MEETINGS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.meetings\n SELECT * FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n # ─── FTS UPDATE ───────────────────────────────────────────────────────────\n step \"Updating FTS indexes\"\n\n run_sqlite_heredoc \"elements_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.elements_fts(rowid, text, role)\n SELECT e.id, e.text, e.role\n FROM nas.elements e\n JOIN nas.frames f ON e.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE'\n AND e.text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)\n SELECT id, full_text, app_name, window_name, browser_url, id\n FROM nas.frames\n WHERE date(timestamp) = '$TARGET_DATE'\n AND full_text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)\n SELECT id, text_content, app_name, window_title, element_name\n FROM nas.ui_events\n WHERE date(timestamp) = '$TARGET_DATE'\n AND text_content IS NOT NULL;\nDETACH nas;\n\"\n\n # ─── VERIFY DB ────────────────────────────────────────────────────────────\n step \"Verifying DB\"\n\n V_FRAMES=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\")\n V_ELEMENTS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n V_UI=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';\")\n V_OCR=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n V_MEETINGS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';\")\n\n check \"frames\" \"$V_FRAMES\" \"$SRC_FRAMES\"\n check \"elements\" \"$V_ELEMENTS\" \"$SRC_ELEMENTS\"\n check \"ui_events\" \"$V_UI\" \"$SRC_UI\"\n check \"ocr_text\" \"$V_OCR\" \"$SRC_OCR\"\n check \"meetings\" \"$V_MEETINGS\" \"$SRC_MEETINGS\"\n\nfi\n\n# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────\n# Always runs regardless of DB sync status\nstep \"Copying data folder for $TARGET_DATE\"\n\nif [ -d \"$DATA_SRC\" ]; then\n mkdir -p \"$NAS_DATA/$TARGET_DATE\"\n RSYNC_START=$(date +%s)\n printf \" %-36s \" \"rsync $TARGET_DATE/ → NAS\"\n rsync -a --ignore-existing \\\n \"$DATA_SRC/\" \\\n \"$NAS_DATA/$TARGET_DATE/\" \\\n 2>>\"$LOG_FILE\"\n RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))\n COPIED_FILES=$(ls \"$NAS_DATA/$TARGET_DATE\" | wc -l | tr -d ' ')\n SRC_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n COPIED_SIZE=$(du -sh \"$NAS_DATA/$TARGET_DATE\" | cut -f1)\n if [ \"$COPIED_FILES\" -eq \"$SRC_FILES\" ]; then\n printf \"\\r %-36s ✓ %dm%02ds (%s files, %s)\\n\" \\\n \"rsync $TARGET_DATE/ → NAS\" \\\n \"$(( RSYNC_DUR / 60 ))\" \"$(( RSYNC_DUR % 60 ))\" \\\n \"$COPIED_FILES\" \"$COPIED_SIZE\" | tee -a \"$LOG_FILE\"\n else\n printf \"\\r %-36s ✗ %s / %s files\\n\" \\\n \"rsync $TARGET_DATE/ → NAS\" \"$COPIED_FILES\" \"$SRC_FILES\" | tee -a \"$LOG_FILE\"\n fi\nelse\n printf \" %-36s %s\\n\" \"rsync $TARGET_DATE/ → NAS\" \"skipped (no source dir)\"\nfi\n\n# ─── SUMMARY ──────────────────────────────────────────────────────────────────\nTOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))\nDB_SIZE=$(du -sh \"$NAS_DB\" | cut -f1)\n\necho \"\"\nlog \"Archive DB size: $DB_SIZE\"\nlog \"Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s\"\nlog \"Sync complete for $TARGET_DATE\"\nlog \"========================================\"","depth":29,"bounds":{"left":0.13763298,"top":0.40542698,"width":0.35804522,"height":0.014365523},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Implement and run pipe l…, Editor Group 2","depth":28,"bounds":{"left":0.5578458,"top":0.047885075,"width":0.073803194,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":false},{"role":"AXRadioButton","text":"Problems (⇧⌘M)","depth":22,"bounds":{"left":0.118351065,"top":0.7278532,"width":0.027925532,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"PROBLEMS","depth":24,"bounds":{"left":0.122340426,"top":0.7366321,"width":0.019946808,"height":0.0103751},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Output (⇧⌘U)","depth":22,"bounds":{"left":0.14594415,"top":0.7278532,"width":0.023603724,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUTPUT","depth":24,"bounds":{"left":0.14993352,"top":0.7366321,"width":0.015625,"height":0.0103751},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Debug Console (⇧⌘Y)","depth":22,"bounds":{"left":0.16921543,"top":0.7278532,"width":0.039893616,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"DEBUG CONSOLE","depth":24,"bounds":{"left":0.1732048,"top":0.7366321,"width":0.031914894,"height":0.0103751},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Terminal (⌃`)","depth":22,"bounds":{"left":0.2087766,"top":0.7278532,"width":0.026595745,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":true},{"role":"AXStaticText","text":"TERMINAL","depth":24,"bounds":{"left":0.21276596,"top":0.7366321,"width":0.01861702,"height":0.0103751},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Ports - 1 forwarded port","depth":22,"bounds":{"left":0.23537233,"top":0.7278532,"width":0.026263298,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"PORTS","depth":24,"bounds":{"left":0.2393617,"top":0.7366321,"width":0.012300532,"height":0.0103751},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":25,"bounds":{"left":0.25465426,"top":0.73743016,"width":0.0019946808,"height":0.008778931},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"remote SSH: nas","depth":16,"bounds":{"left":0.0006648936,"top":0.98244214,"width":0.028590426,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.0033244682,"top":0.9848364,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"SSH: nas","depth":17,"bounds":{"left":0.008643617,"top":0.9856345,"width":0.017952127,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"screenpipe (Git) - master*, Checkout Branch/Tag...","depth":16,"bounds":{"left":0.030917553,"top":0.98244214,"width":0.023271276,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.031914894,"top":0.9848364,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"master*","depth":17,"bounds":{"left":0.03723404,"top":0.9856345,"width":0.015957447,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"screenpipe (Git) - Synchronize Changes","depth":16,"bounds":{"left":0.05418883,"top":0.98244214,"width":0.00731383,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"No Problems","depth":16,"bounds":{"left":0.06416223,"top":0.98244214,"width":0.022606382,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.06582447,"top":0.9848364,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"0","depth":17,"bounds":{"left":0.07114362,"top":0.9856345,"width":0.004986702,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.07579787,"top":0.9848364,"width":0.0056515955,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"0","depth":17,"bounds":{"left":0.08111702,"top":0.9856345,"width":0.0039893617,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Forwarded Ports: 8766","depth":16,"bounds":{"left":0.08843085,"top":0.98244214,"width":0.012632979,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.09009308,"top":0.9848364,"width":0.0056515955,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":17,"bounds":{"left":0.09541223,"top":0.9856345,"width":0.0039893617,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Notifications","depth":16,"bounds":{"left":0.9886968,"top":0.98244214,"width":0.010638298,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sign In","depth":16,"bounds":{"left":0.9650931,"top":0.98244214,"width":0.022606382,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.96675533,"top":0.9848364,"width":0.0056515955,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Sign In","depth":17,"bounds":{"left":0.97207445,"top":0.9856345,"width":0.013962766,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Shell Script","depth":16,"bounds":{"left":0.93916225,"top":0.98244214,"width":0.023603724,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Editor Language Status: $(copilot) No inline suggestion available, Inline suggestions","depth":16,"bounds":{"left":0.9318484,"top":0.98244214,"width":0.00731383,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"LF","depth":16,"bounds":{"left":0.9212101,"top":0.98244214,"width":0.007978723,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"UTF-8","depth":16,"bounds":{"left":0.90359044,"top":0.98244214,"width":0.015625,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Spaces: 2","depth":16,"bounds":{"left":0.8796542,"top":0.98244214,"width":0.022273935,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
-6464446508504939945
|
3895780591031160215
|
click
|
accessibility
|
NULL
|
Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧ Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py
M
db.py
docker-compose.yml
Dockerfile
M
main.py
M
requirements.txt
M
data
logs
pipes
.gitignore
app_settings.json
archive.db
archive.db-bak
U
db.sqlite
db.sqlite-shm
db.sqlite-wal
screenpipe_sync_updated.sh
U
screenpipe_sync.sh
screenpipe.db
Outline Section
OUTLINE
OUTLINE
Timeline Section
TIMELINE
TIMELINE
app_settings.json, Editor Group 1
screenpipe_sync.sh, Editor Group 1
pipe.md, Editor Group 1
.env, Editor Group 1
#!/bin/bash
# screenpipe_sync.sh
# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).
# Also copies the day's video/frame data folder to the NAS.
#
# Usage:
# ./screenpipe_sync.sh # syncs yesterday (default)
# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date
# ./screenpipe_sync.sh today # syncs today so far
#
# Cron example (runs at 3am daily):
# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1
set -euo pipefail
# ─── CONFIG ───────────────────────────────────────────────────────────────────
DB_SRC="${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}"
NAS_MOUNT="${NAS_MOUNT:-/Volumes/Test/screenpipe}"
NAS_DB="$NAS_MOUNT/archive.db"
NAS_DATA="$NAS_MOUNT/data"
LOG_FILE="$HOME/.screenpipe/sync.log"
# ──────────────────────────────────────────────────────────────────────────────
# ─── HELPERS ──────────────────────────────────────────────────────────────────
SCRIPT_START=$(date +%s)
log() {
local msg="[$(date '+%Y-%m-%d %H:%M:%S')] $*"
echo "$msg" | tee -a "$LOG_FILE"
}
step() {
local now=$(date +%s)
local elapsed=$(( now - SCRIPT_START ))
local min=$(( elapsed / 60 ))
local sec=$(( elapsed % 60 ))
printf "\n[+%02dm%02ds] ▶ %s\n" "$min" "$sec" "$*" | tee -a "$LOG_FILE"
}
run_sqlite_heredoc() {
local label="$1"
local sql="$2"
local start=$(date +%s)
printf " %-36s " "$label"
sqlite3 "$DB_SRC" <<< "$sql" &
local pid=$!
local spin=[PASSWORD] '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')
local i=0
while kill -0 "$pid" 2>/dev/null; do
printf "\r %-36s %s " "$label" "${spin[$i]}"
i=$(( (i + 1) % 10 ))
sleep 0.2
done
wait "$pid"
local rc=$?
if [ $rc -ne 0 ]; then
printf "\r %-36s ✗ FAILED\n" "$label" | tee -a "$LOG_FILE"
exit $rc
fi
local dur=$(( $(date +%s) - start ))
printf "\r %-36s ✓ %dm%02ds\n" "$label" "$(( dur / 60 ))" "$(( dur % 60 ))" | tee -a "$LOG_FILE"
}
check() {
local label="$1" got="$2" expected="$3"
if [ "$got" -eq "$expected" ]; then
printf " %-20s %s / %s ✓\n" "$label:" "$got" "$expected"
else
printf " %-20s %s / %s ✗ MISMATCH\n" "$label:" "$got" "$expected"
fi
}
# ──────────────────────────────────────────────────────────────────────────────
# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────
if [ "${1:-}" = "today" ]; then
TARGET_DATE=$(date +%Y-%m-%d)
elif [ -n "${1:-}" ]; then
TARGET_DATE="$1"
if ! [[ "$TARGET_DATE" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then
echo "ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday."
exit 1
fi
else
TARGET_DATE=$(date -v-1d +%Y-%m-%d)
fi
log "========================================"
log "Screenpipe sync starting for: $TARGET_DATE"
log "========================================"
# ─── PREFLIGHT ────────────────────────────────────────────────────────────────
step "Preflight checks"
if [ ! -f "$DB_SRC" ]; then
log "ERROR: Source DB not found at $DB_SRC"; exit 1
fi
printf " %-20s %s (%s)\n" "Source DB:" "OK" "$(du -sh "$DB_SRC" | cut -f1)"
if [ ! -d "$NAS_MOUNT" ]; then
log "ERROR: NAS not mounted at $NAS_MOUNT"; exit 1
fi
printf " %-20s %s\n" "NAS mount:" "OK $NAS_MOUNT"
# Check if DB already synced for this date
DB_ALREADY_SYNCED=false
if [ -f "$NAS_DB" ]; then
EXISTING=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';" 2>/dev/null || echo "0")
if [ "$EXISTING" -gt "0" ]; then
log "Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync"
DB_ALREADY_SYNCED=true
else
printf " %-20s %s (%s)\n" "Archive DB:" "exists" "$(du -sh "$NAS_DB" | cut -f1)"
fi
else
printf " %-20s %s\n" "Archive DB:" "will be created"
fi
# Source data dir for this date
DATA_SRC="$HOME/.screenpipe/data/data/$TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
DATA_SIZE=$(du -sh "$DATA_SRC" | cut -f1)
DATA_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
printf " %-20s %s (%s files, %s)\n" "Data dir:" "OK" "$DATA_FILES" "$DATA_SIZE"
else
printf " %-20s %s\n" "Data dir:" "not found — skipping file copy"
fi
# ─── DB SYNC ──────────────────────────────────────────────────────────────────
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────
step "Counting source rows for $TARGET_DATE"
SRC_FRAMES=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
SRC_ELEMENTS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_UI=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
SRC_OCR=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_MEETINGS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';")
printf " %-20s %s\n" "frames:" "$SRC_FRAMES"
printf " %-20s %s\n" "elements:" "$SRC_ELEMENTS"
printf " %-20s %s\n" "ui_events:" "$SRC_UI"
printf " %-20s %s\n" "ocr_text:" "$SRC_OCR"
printf " %-20s %s\n" "meetings:" "$SRC_MEETINGS"
if [ "$SRC_FRAMES" -eq "0" ]; then
log "No frames found for $TARGET_DATE — skipping DB sync"
DB_ALREADY_SYNCED=true
fi
fi
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── INIT TABLES ──────────────────────────────────────────────────────────
step "Initialising tables, indexes, FTS"
run_sqlite_heredoc "creating tables" "
ATTACH '$NAS_DB' AS nas;
CREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;
CREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;
CREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;
CREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;
DETACH nas;
"
run_sqlite_heredoc "creating indexes" "
ATTACH '$NAS_DB' AS nas;
CREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);
CREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);
DETACH nas;
"
run_sqlite_heredoc "creating FTS tables" "
ATTACH '$NAS_DB' AS nas;
CREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(
text, role, frame_id UNINDEXED,
content='elements', content_rowid='id', tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(
full_text, app_name, window_name, browser_url, id UNINDEXED,
tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(
text_content,
app_name,
window_title,
element_name,
content='ui_events',
content_rowid='id',
tokenize='unicode61'
);
DETACH nas;
"
# ─── SYNC DATA ────────────────────────────────────────────────────────────
step "Syncing data for $TARGET_DATE"
run_sqlite_heredoc "video_chunks" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.video_chunks
SELECT * FROM main.video_chunks
WHERE id IN (
SELECT DISTINCT video_chunk_id FROM main.frames
WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL
);
DETACH nas;
"
run_sqlite_heredoc "frames ($SRC_FRAMES rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.frames
SELECT * FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ocr_text ($SRC_OCR rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ocr_text
SELECT o.* FROM main.ocr_text o
JOIN main.frames f ON o.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ui_events ($SRC_UI rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ui_events
SELECT * FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "elements ($SRC_ELEMENTS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.elements
SELECT e.* FROM main.elements e
JOIN main.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "meetings ($SRC_MEETINGS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.meetings
SELECT * FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';
DETACH nas;
"
# ─── FTS UPDATE ───────────────────────────────────────────────────────────
step "Updating FTS indexes"
run_sqlite_heredoc "elements_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.elements_fts(rowid, text, role)
SELECT e.id, e.text, e.role
FROM nas.elements e
JOIN nas.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE'
AND e.text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "frames_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)
SELECT id, full_text, app_name, window_name, browser_url, id
FROM nas.frames
WHERE date(timestamp) = '$TARGET_DATE'
AND full_text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "ui_events_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)
SELECT id, text_content, app_name, window_title, element_name
FROM nas.ui_events
WHERE date(timestamp) = '$TARGET_DATE'
AND text_content IS NOT NULL;
DETACH nas;
"
# ─── VERIFY DB ────────────────────────────────────────────────────────────
step "Verifying DB"
V_FRAMES=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
V_ELEMENTS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_UI=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
V_OCR=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_MEETINGS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';")
check "frames" "$V_FRAMES" "$SRC_FRAMES"
check "elements" "$V_ELEMENTS" "$SRC_ELEMENTS"
check "ui_events" "$V_UI" "$SRC_UI"
check "ocr_text" "$V_OCR" "$SRC_OCR"
check "meetings" "$V_MEETINGS" "$SRC_MEETINGS"
fi
# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────
# Always runs regardless of DB sync status
step "Copying data folder for $TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
mkdir -p "$NAS_DATA/$TARGET_DATE"
RSYNC_START=$(date +%s)
printf " %-36s " "rsync $TARGET_DATE/ → NAS"
rsync -a --ignore-existing \
"$DATA_SRC/" \
"$NAS_DATA/$TARGET_DATE/" \
2>>"$LOG_FILE"
RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))
COPIED_FILES=$(ls "$NAS_DATA/$TARGET_DATE" | wc -l | tr -d ' ')
SRC_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
COPIED_SIZE=$(du -sh "$NAS_DATA/$TARGET_DATE" | cut -f1)
if [ "$COPIED_FILES" -eq "$SRC_FILES" ]; then
printf "\r %-36s ✓ %dm%02ds (%s files, %s)\n" \
"rsync $TARGET_DATE/ → NAS" \
"$(( RSYNC_DUR / 60 ))" "$(( RSYNC_DUR % 60 ))" \
"$COPIED_FILES" "$COPIED_SIZE" | tee -a "$LOG_FILE"
else
printf "\r %-36s ✗ %s / %s files\n" \
"rsync $TARGET_DATE/ → NAS" "$COPIED_FILES" "$SRC_FILES" | tee -a "$LOG_FILE"
fi
else
printf " %-36s %s\n" "rsync $TARGET_DATE/ → NAS" "skipped (no source dir)"
fi
# ─── SUMMARY ──────────────────────────────────────────────────────────────────
TOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))
DB_SIZE=$(du -sh "$NAS_DB" | cut -f1)
echo ""
log "Archive DB size: $DB_SIZE"
log "Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s"
log "Sync complete for $TARGET_DATE"
log "========================================"
#!/bin/bash
# screenpipe_sync.sh
# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).
# Also copies the day's video/frame data folder to the NAS.
#
# Usage:
# ./screenpipe_sync.sh # syncs yesterday (default)
# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date
# ./screenpipe_sync.sh today # syncs today so far
#
# Cron example (runs at 3am daily):
# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1
set -euo pipefail
# ─── CONFIG ───────────────────────────────────────────────────────────────────
DB_SRC="${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}"
NAS_MOUNT="${NAS_MOUNT:-/Volumes/Test/screenpipe}"
NAS_DB="$NAS_MOUNT/archive.db"
NAS_DATA="$NAS_MOUNT/data"
LOG_FILE="$HOME/.screenpipe/sync.log"
# ──────────────────────────────────────────────────────────────────────────────
# ─── HELPERS ──────────────────────────────────────────────────────────────────
SCRIPT_START=$(date +%s)
log() {
local msg="[$(date '+%Y-%m-%d %H:%M:%S')] $*"
echo "$msg" | tee -a "$LOG_FILE"
}
step() {
local now=$(date +%s)
local elapsed=$(( now - SCRIPT_START ))
local min=$(( elapsed / 60 ))
local sec=$(( elapsed % 60 ))
printf "\n[+%02dm%02ds] ▶ %s\n" "$min" "$sec" "$*" | tee -a "$LOG_FILE"
}
run_sqlite_heredoc() {
local label="$1"
local sql="$2"
local start=$(date +%s)
printf " %-36s " "$label"
sqlite3 "$DB_SRC" <<< "$sql" &
local pid=$!
local spin=[PASSWORD] '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')
local i=0
while kill -0 "$pid" 2>/dev/null; do
printf "\r %-36s %s " "$label" "${spin[$i]}"
i=$(( (i + 1) % 10 ))
sleep 0.2
done
wait "$pid"
local rc=$?
if [ $rc -ne 0 ]; then
printf "\r %-36s ✗ FAILED\n" "$label" | tee -a "$LOG_FILE"
exit $rc
fi
local dur=$(( $(date +%s) - start ))
printf "\r %-36s ✓ %dm%02ds\n" "$label" "$(( dur / 60 ))" "$(( dur % 60 ))" | tee -a "$LOG_FILE"
}
check() {
local label="$1" got="$2" expected="$3"
if [ "$got" -eq "$expected" ]; then
printf " %-20s %s / %s ✓\n" "$label:" "$got" "$expected"
else
printf " %-20s %s / %s ✗ MISMATCH\n" "$label:" "$got" "$expected"
fi
}
# ──────────────────────────────────────────────────────────────────────────────
# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────
if [ "${1:-}" = "today" ]; then
TARGET_DATE=$(date +%Y-%m-%d)
elif [ -n "${1:-}" ]; then
TARGET_DATE="$1"
if ! [[ "$TARGET_DATE" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then
echo "ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday."
exit 1
fi
else
TARGET_DATE=$(date -v-1d +%Y-%m-%d)
fi
log "========================================"
log "Screenpipe sync starting for: $TARGET_DATE"
log "========================================"
# ─── PREFLIGHT ────────────────────────────────────────────────────────────────
step "Preflight checks"
if [ ! -f "$DB_SRC" ]; then
log "ERROR: Source DB not found at $DB_SRC"; exit 1
fi
printf " %-20s %s (%s)\n" "Source DB:" "OK" "$(du -sh "$DB_SRC" | cut -f1)"
if [ ! -d "$NAS_MOUNT" ]; then
log "ERROR: NAS not mounted at $NAS_MOUNT"; exit 1
fi
printf " %-20s %s\n" "NAS mount:" "OK $NAS_MOUNT"
# Check if DB already synced for this date
DB_ALREADY_SYNCED=false
if [ -f "$NAS_DB" ]; then
EXISTING=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';" 2>/dev/null || echo "0")
if [ "$EXISTING" -gt "0" ]; then
log "Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync"
DB_ALREADY_SYNCED=true
else
printf " %-20s %s (%s)\n" "Archive DB:" "exists" "$(du -sh "$NAS_DB" | cut -f1)"
fi
else
printf " %-20s %s\n" "Archive DB:" "will be created"
fi
# Source data dir for this date
DATA_SRC="$HOME/.screenpipe/data/data/$TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
DATA_SIZE=$(du -sh "$DATA_SRC" | cut -f1)
DATA_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
printf " %-20s %s (%s files, %s)\n" "Data dir:" "OK" "$DATA_FILES" "$DATA_SIZE"
else
printf " %-20s %s\n" "Data dir:" "not found — skipping file copy"
fi
# ─── DB SYNC ──────────────────────────────────────────────────────────────────
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────
step "Counting source rows for $TARGET_DATE"
SRC_FRAMES=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
SRC_ELEMENTS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_UI=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
SRC_OCR=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_MEETINGS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';")
printf " %-20s %s\n" "frames:" "$SRC_FRAMES"
printf " %-20s %s\n" "elements:" "$SRC_ELEMENTS"
printf " %-20s %s\n" "ui_events:" "$SRC_UI"
printf " %-20s %s\n" "ocr_text:" "$SRC_OCR"
printf " %-20s %s\n" "meetings:" "$SRC_MEETINGS"
if [ "$SRC_FRAMES" -eq "0" ]; then
log "No frames found for $TARGET_DATE — skipping DB sync"
DB_ALREADY_SYNCED=true
fi
fi
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── INIT TABLES ──────────────────────────────────────────────────────────
step "Initialising tables, indexes, FTS"
run_sqlite_heredoc "creating tables" "
ATTACH '$NAS_DB' AS nas;
CREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;
CREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;
CREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;
CREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;
DETACH nas;
"
run_sqlite_heredoc "creating indexes" "
ATTACH '$NAS_DB' AS nas;
CREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);
CREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);
DETACH nas;
"
run_sqlite_heredoc "creating FTS tables" "
ATTACH '$NAS_DB' AS nas;
CREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(
text, role, frame_id UNINDEXED,
content='elements', content_rowid='id', tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(
full_text, app_name, window_name, browser_url, id UNINDEXED,
tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(
text_content,
app_name,
window_title,
element_name,
content='ui_events',
content_rowid='id',
tokenize='unicode61'
);
DETACH nas;
"
# ─── SYNC DATA ────────────────────────────────────────────────────────────
step "Syncing data for $TARGET_DATE"
run_sqlite_heredoc "video_chunks" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.video_chunks
SELECT * FROM main.video_chunks
WHERE id IN (
SELECT DISTINCT video_chunk_id FROM main.frames
WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL
);
DETACH nas;
"
run_sqlite_heredoc "frames ($SRC_FRAMES rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.frames
SELECT * FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ocr_text ($SRC_OCR rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ocr_text
SELECT o.* FROM main.ocr_text o
JOIN main.frames f ON o.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ui_events ($SRC_UI rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ui_events
SELECT * FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "elements ($SRC_ELEMENTS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.elements
SELECT e.* FROM main.elements e
JOIN main.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "meetings ($SRC_MEETINGS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.meetings
SELECT * FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';
DETACH nas;
"
# ─── FTS UPDATE ───────────────────────────────────────────────────────────
step "Updating FTS indexes"
run_sqlite_heredoc "elements_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.elements_fts(rowid, text, role)
SELECT e.id, e.text, e.role
FROM nas.elements e
JOIN nas.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE'
AND e.text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "frames_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)
SELECT id, full_text, app_name, window_name, browser_url, id
FROM nas.frames
WHERE date(timestamp) = '$TARGET_DATE'
AND full_text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "ui_events_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)
SELECT id, text_content, app_name, window_title, element_name
FROM nas.ui_events
WHERE date(timestamp) = '$TARGET_DATE'
AND text_content IS NOT NULL;
DETACH nas;
"
# ─── VERIFY DB ────────────────────────────────────────────────────────────
step "Verifying DB"
V_FRAMES=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
V_ELEMENTS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_UI=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
V_OCR=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_MEETINGS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';")
check "frames" "$V_FRAMES" "$SRC_FRAMES"
check "elements" "$V_ELEMENTS" "$SRC_ELEMENTS"
check "ui_events" "$V_UI" "$SRC_UI"
check "ocr_text" "$V_OCR" "$SRC_OCR"
check "meetings" "$V_MEETINGS" "$SRC_MEETINGS"
fi
# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────
# Always runs regardless of DB sync status
step "Copying data folder for $TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
mkdir -p "$NAS_DATA/$TARGET_DATE"
RSYNC_START=$(date +%s)
printf " %-36s " "rsync $TARGET_DATE/ → NAS"
rsync -a --ignore-existing \
"$DATA_SRC/" \
"$NAS_DATA/$TARGET_DATE/" \
2>>"$LOG_FILE"
RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))
COPIED_FILES=$(ls "$NAS_DATA/$TARGET_DATE" | wc -l | tr -d ' ')
SRC_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
COPIED_SIZE=$(du -sh "$NAS_DATA/$TARGET_DATE" | cut -f1)
if [ "$COPIED_FILES" -eq "$SRC_FILES" ]; then
printf "\r %-36s ✓ %dm%02ds (%s files, %s)\n" \
"rsync $TARGET_DATE/ → NAS" \
"$(( RSYNC_DUR / 60 ))" "$(( RSYNC_DUR % 60 ))" \
"$COPIED_FILES" "$COPIED_SIZE" | tee -a "$LOG_FILE"
else
printf "\r %-36s ✗ %s / %s files\n" \
"rsync $TARGET_DATE/ → NAS" "$COPIED_FILES" "$SRC_FILES" | tee -a "$LOG_FILE"
fi
else
printf " %-36s %s\n" "rsync $TARGET_DATE/ → NAS" "skipped (no source dir)"
fi
# ─── SUMMARY ──────────────────────────────────────────────────────────────────
TOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))
DB_SIZE=$(du -sh "$NAS_DB" | cut -f1)
echo ""
log "Archive DB size: $DB_SIZE"
log "Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s"
log "Sync complete for $TARGET_DATE"
log "========================================"
Implement and run pipe l…, Editor Group 2
Problems (⇧⌘M)
PROBLEMS
Output (⇧⌘U)
OUTPUT
Debug Console (⇧⌘Y)
DEBUG CONSOLE
Terminal (⌃`)
TERMINAL
Ports - 1 forwarded port
PORTS
1
remote SSH: nas
SSH: nas
screenpipe (Git) - master*, Checkout Branch/Tag...
master*
screenpipe (Git) - Synchronize Changes
No Problems
0
0
Forwarded Ports: 8766
1
Notifications
Sign In
Sign In
Shell Script
Editor Language Status: $(copilot) No inline suggestion available, Inline suggestions
LF
UTF-8
Spaces: 2...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
21102
|
923
|
11
|
2026-05-11T17:12:12.676598+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-11/1778 /Users/lukas/.screenpipe/data/data/2026-05-11/1778519532676_m2.jpg...
|
Code
|
screenpipe_sync.sh — screenpipe [SSH: nas]
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧ Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py
M
db.py
docker-compose.yml
Dockerfile
M
main.py
M
requirements.txt
M
data
logs
pipes
.gitignore
app_settings.json
archive.db
archive.db-bak
U
db.sqlite
db.sqlite-shm
db.sqlite-wal
screenpipe_sync_updated.sh
U
screenpipe_sync.sh
screenpipe.db
Outline Section
OUTLINE
OUTLINE
Timeline Section
TIMELINE
TIMELINE
app_settings.json, Editor Group 1
screenpipe_sync.sh, Editor Group 1
pipe.md, Editor Group 1
.env, Editor Group 1
#!/bin/bash
# screenpipe_sync.sh
# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).
# Also copies the day's video/frame data folder to the NAS.
#
# Usage:
# ./screenpipe_sync.sh # syncs yesterday (default)
# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date
# ./screenpipe_sync.sh today # syncs today so far
#
# Cron example (runs at 3am daily):
# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1
set -euo pipefail
# ─── CONFIG ───────────────────────────────────────────────────────────────────
DB_SRC="${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}"
NAS_MOUNT="${NAS_MOUNT:-/Volumes/Test/screenpipe}"
NAS_DB="$NAS_MOUNT/archive.db"
NAS_DATA="$NAS_MOUNT/data"
LOG_FILE="$HOME/.screenpipe/sync.log"
# ──────────────────────────────────────────────────────────────────────────────
# ─── HELPERS ──────────────────────────────────────────────────────────────────
SCRIPT_START=$(date +%s)
log() {
local msg="[$(date '+%Y-%m-%d %H:%M:%S')] $*"
echo "$msg" | tee -a "$LOG_FILE"
}
step() {
local now=$(date +%s)
local elapsed=$(( now - SCRIPT_START ))
local min=$(( elapsed / 60 ))
local sec=$(( elapsed % 60 ))
printf "\n[+%02dm%02ds] ▶ %s\n" "$min" "$sec" "$*" | tee -a "$LOG_FILE"
}
run_sqlite_heredoc() {
local label="$1"
local sql="$2"
local start=$(date +%s)
printf " %-36s " "$label"
sqlite3 "$DB_SRC" <<< "$sql" &
local pid=$!
local spin=[PASSWORD] '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')
local i=0
while kill -0 "$pid" 2>/dev/null; do
printf "\r %-36s %s " "$label" "${spin[$i]}"
i=$(( (i + 1) % 10 ))
sleep 0.2
done
wait "$pid"
local rc=$?
if [ $rc -ne 0 ]; then
printf "\r %-36s ✗ FAILED\n" "$label" | tee -a "$LOG_FILE"
exit $rc
fi
local dur=$(( $(date +%s) - start ))
printf "\r %-36s ✓ %dm%02ds\n" "$label" "$(( dur / 60 ))" "$(( dur % 60 ))" | tee -a "$LOG_FILE"
}
check() {
local label="$1" got="$2" expected="$3"
if [ "$got" -eq "$expected" ]; then
printf " %-20s %s / %s ✓\n" "$label:" "$got" "$expected"
else
printf " %-20s %s / %s ✗ MISMATCH\n" "$label:" "$got" "$expected"
fi
}
# ──────────────────────────────────────────────────────────────────────────────
# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────
if [ "${1:-}" = "today" ]; then
TARGET_DATE=$(date +%Y-%m-%d)
elif [ -n "${1:-}" ]; then
TARGET_DATE="$1"
if ! [[ "$TARGET_DATE" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then
echo "ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday."
exit 1
fi
else
TARGET_DATE=$(date -v-1d +%Y-%m-%d)
fi
log "========================================"
log "Screenpipe sync starting for: $TARGET_DATE"
log "========================================"
# ─── PREFLIGHT ────────────────────────────────────────────────────────────────
step "Preflight checks"
if [ ! -f "$DB_SRC" ]; then
log "ERROR: Source DB not found at $DB_SRC"; exit 1
fi
printf " %-20s %s (%s)\n" "Source DB:" "OK" "$(du -sh "$DB_SRC" | cut -f1)"
if [ ! -d "$NAS_MOUNT" ]; then
log "ERROR: NAS not mounted at $NAS_MOUNT"; exit 1
fi
printf " %-20s %s\n" "NAS mount:" "OK $NAS_MOUNT"
# Check if DB already synced for this date
DB_ALREADY_SYNCED=false
if [ -f "$NAS_DB" ]; then
EXISTING=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';" 2>/dev/null || echo "0")
if [ "$EXISTING" -gt "0" ]; then
log "Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync"
DB_ALREADY_SYNCED=true
else
printf " %-20s %s (%s)\n" "Archive DB:" "exists" "$(du -sh "$NAS_DB" | cut -f1)"
fi
else
printf " %-20s %s\n" "Archive DB:" "will be created"
fi
# Source data dir for this date
DATA_SRC="$HOME/.screenpipe/data/data/$TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
DATA_SIZE=$(du -sh "$DATA_SRC" | cut -f1)
DATA_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
printf " %-20s %s (%s files, %s)\n" "Data dir:" "OK" "$DATA_FILES" "$DATA_SIZE"
else
printf " %-20s %s\n" "Data dir:" "not found — skipping file copy"
fi
# ─── DB SYNC ──────────────────────────────────────────────────────────────────
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────
step "Counting source rows for $TARGET_DATE"
SRC_FRAMES=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
SRC_ELEMENTS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_UI=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
SRC_OCR=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_MEETINGS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';")
printf " %-20s %s\n" "frames:" "$SRC_FRAMES"
printf " %-20s %s\n" "elements:" "$SRC_ELEMENTS"
printf " %-20s %s\n" "ui_events:" "$SRC_UI"
printf " %-20s %s\n" "ocr_text:" "$SRC_OCR"
printf " %-20s %s\n" "meetings:" "$SRC_MEETINGS"
if [ "$SRC_FRAMES" -eq "0" ]; then
log "No frames found for $TARGET_DATE — skipping DB sync"
DB_ALREADY_SYNCED=true
fi
fi
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── INIT TABLES ──────────────────────────────────────────────────────────
step "Initialising tables, indexes, FTS"
run_sqlite_heredoc "creating tables" "
ATTACH '$NAS_DB' AS nas;
CREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;
CREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;
CREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;
CREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;
DETACH nas;
"
run_sqlite_heredoc "creating indexes" "
ATTACH '$NAS_DB' AS nas;
CREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);
CREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);
DETACH nas;
"
run_sqlite_heredoc "creating FTS tables" "
ATTACH '$NAS_DB' AS nas;
CREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(
text, role, frame_id UNINDEXED,
content='elements', content_rowid='id', tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(
full_text, app_name, window_name, browser_url, id UNINDEXED,
tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(
text_content,
app_name,
window_title,
element_name,
content='ui_events',
content_rowid='id',
tokenize='unicode61'
);
DETACH nas;
"
# ─── SYNC DATA ────────────────────────────────────────────────────────────
step "Syncing data for $TARGET_DATE"
run_sqlite_heredoc "video_chunks" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.video_chunks
SELECT * FROM main.video_chunks
WHERE id IN (
SELECT DISTINCT video_chunk_id FROM main.frames
WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL
);
DETACH nas;
"
run_sqlite_heredoc "frames ($SRC_FRAMES rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.frames
SELECT * FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ocr_text ($SRC_OCR rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ocr_text
SELECT o.* FROM main.ocr_text o
JOIN main.frames f ON o.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ui_events ($SRC_UI rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ui_events
SELECT * FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "elements ($SRC_ELEMENTS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.elements
SELECT e.* FROM main.elements e
JOIN main.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "meetings ($SRC_MEETINGS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.meetings
SELECT * FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';
DETACH nas;
"
# ─── FTS UPDATE ───────────────────────────────────────────────────────────
step "Updating FTS indexes"
run_sqlite_heredoc "elements_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.elements_fts(rowid, text, role)
SELECT e.id, e.text, e.role
FROM nas.elements e
JOIN nas.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE'
AND e.text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "frames_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)
SELECT id, full_text, app_name, window_name, browser_url, id
FROM nas.frames
WHERE date(timestamp) = '$TARGET_DATE'
AND full_text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "ui_events_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)
SELECT id, text_content, app_name, window_title, element_name
FROM nas.ui_events
WHERE date(timestamp) = '$TARGET_DATE'
AND text_content IS NOT NULL;
DETACH nas;
"
# ─── VERIFY DB ────────────────────────────────────────────────────────────
step "Verifying DB"
V_FRAMES=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
V_ELEMENTS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_UI=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
V_OCR=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_MEETINGS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';")
check "frames" "$V_FRAMES" "$SRC_FRAMES"
check "elements" "$V_ELEMENTS" "$SRC_ELEMENTS"
check "ui_events" "$V_UI" "$SRC_UI"
check "ocr_text" "$V_OCR" "$SRC_OCR"
check "meetings" "$V_MEETINGS" "$SRC_MEETINGS"
fi
# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────
# Always runs regardless of DB sync status
step "Copying data folder for $TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
mkdir -p "$NAS_DATA/$TARGET_DATE"
RSYNC_START=$(date +%s)
printf " %-36s " "rsync $TARGET_DATE/ → NAS"
rsync -a --ignore-existing \
"$DATA_SRC/" \
"$NAS_DATA/$TARGET_DATE/" \
2>>"$LOG_FILE"
RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))
COPIED_FILES=$(ls "$NAS_DATA/$TARGET_DATE" | wc -l | tr -d ' ')
SRC_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
COPIED_SIZE=$(du -sh "$NAS_DATA/$TARGET_DATE" | cut -f1)
if [ "$COPIED_FILES" -eq "$SRC_FILES" ]; then
printf "\r %-36s ✓ %dm%02ds (%s files, %s)\n" \
"rsync $TARGET_DATE/ → NAS" \
"$(( RSYNC_DUR / 60 ))" "$(( RSYNC_DUR % 60 ))" \
"$COPIED_FILES" "$COPIED_SIZE" | tee -a "$LOG_FILE"
else
printf "\r %-36s ✗ %s / %s files\n" \
"rsync $TARGET_DATE/ → NAS" "$COPIED_FILES" "$SRC_FILES" | tee -a "$LOG_FILE"
fi
else
printf " %-36s %s\n" "rsync $TARGET_DATE/ → NAS" "skipped (no source dir)"
fi
# ─── SUMMARY ──────────────────────────────────────────────────────────────────
TOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))
DB_SIZE=$(du -sh "$NAS_DB" | cut -f1)
echo ""
log "Archive DB size: $DB_SIZE"
log "Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s"
log "Sync complete for $TARGET_DATE"
log "========================================"
#!/bin/bash
# screenpipe_sync.sh
# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).
# Also copies the day's video/frame data folder to the NAS.
#
# Usage:
# ./screenpipe_sync.sh # syncs yesterday (default)
# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date
# ./screenpipe_sync.sh today # syncs today so far
#
# Cron example (runs at 3am daily):
# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1
set -euo pipefail
# ─── CONFIG ───────────────────────────────────────────────────────────────────
DB_SRC="${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}"
NAS_MOUNT="${NAS_MOUNT:-/Volumes/Test/screenpipe}"
NAS_DB="$NAS_MOUNT/archive.db"
NAS_DATA="$NAS_MOUNT/data"
LOG_FILE="$HOME/.screenpipe/sync.log"
# ──────────────────────────────────────────────────────────────────────────────
# ─── HELPERS ──────────────────────────────────────────────────────────────────
SCRIPT_START=$(date +%s)
log() {
local msg="[$(date '+%Y-%m-%d %H:%M:%S')] $*"
echo "$msg" | tee -a "$LOG_FILE"
}
step() {
local now=$(date +%s)
local elapsed=$(( now - SCRIPT_START ))
local min=$(( elapsed / 60 ))
local sec=$(( elapsed % 60 ))
printf "\n[+%02dm%02ds] ▶ %s\n" "$min" "$sec" "$*" | tee -a "$LOG_FILE"
}
run_sqlite_heredoc() {
local label="$1"
local sql="$2"
local start=$(date +%s)
printf " %-36s " "$label"
sqlite3 "$DB_SRC" <<< "$sql" &
local pid=$!
local spin=[PASSWORD] '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')
local i=0
while kill -0 "$pid" 2>/dev/null; do
printf "\r %-36s %s " "$label" "${spin[$i]}"
i=$(( (i + 1) % 10 ))
sleep 0.2
done
wait "$pid"
local rc=$?
if [ $rc -ne 0 ]; then
printf "\r %-36s ✗ FAILED\n" "$label" | tee -a "$LOG_FILE"
exit $rc
fi
local dur=$(( $(date +%s) - start ))
printf "\r %-36s ✓ %dm%02ds\n" "$label" "$(( dur / 60 ))" "$(( dur % 60 ))" | tee -a "$LOG_FILE"
}
check() {
local label="$1" got="$2" expected="$3"
if [ "$got" -eq "$expected" ]; then
printf " %-20s %s / %s ✓\n" "$label:" "$got" "$expected"
else
printf " %-20s %s / %s ✗ MISMATCH\n" "$label:" "$got" "$expected"
fi
}
# ──────────────────────────────────────────────────────────────────────────────
# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────
if [ "${1:-}" = "today" ]; then
TARGET_DATE=$(date +%Y-%m-%d)
elif [ -n "${1:-}" ]; then
TARGET_DATE="$1"
if ! [[ "$TARGET_DATE" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then
echo "ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday."
exit 1
fi
else
TARGET_DATE=$(date -v-1d +%Y-%m-%d)
fi
log "========================================"
log "Screenpipe sync starting for: $TARGET_DATE"
log "========================================"
# ─── PREFLIGHT ────────────────────────────────────────────────────────────────
step "Preflight checks"
if [ ! -f "$DB_SRC" ]; then
log "ERROR: Source DB not found at $DB_SRC"; exit 1
fi
printf " %-20s %s (%s)\n" "Source DB:" "OK" "$(du -sh "$DB_SRC" | cut -f1)"
if [ ! -d "$NAS_MOUNT" ]; then
log "ERROR: NAS not mounted at $NAS_MOUNT"; exit 1
fi
printf " %-20s %s\n" "NAS mount:" "OK $NAS_MOUNT"
# Check if DB already synced for this date
DB_ALREADY_SYNCED=false
if [ -f "$NAS_DB" ]; then
EXISTING=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';" 2>/dev/null || echo "0")
if [ "$EXISTING" -gt "0" ]; then
log "Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync"
DB_ALREADY_SYNCED=true
else
printf " %-20s %s (%s)\n" "Archive DB:" "exists" "$(du -sh "$NAS_DB" | cut -f1)"
fi
else
printf " %-20s %s\n" "Archive DB:" "will be created"
fi
# Source data dir for this date
DATA_SRC="$HOME/.screenpipe/data/data/$TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
DATA_SIZE=$(du -sh "$DATA_SRC" | cut -f1)
DATA_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
printf " %-20s %s (%s files, %s)\n" "Data dir:" "OK" "$DATA_FILES" "$DATA_SIZE"
else
printf " %-20s %s\n" "Data dir:" "not found — skipping file copy"
fi
# ─── DB SYNC ──────────────────────────────────────────────────────────────────
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────
step "Counting source rows for $TARGET_DATE"
SRC_FRAMES=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
SRC_ELEMENTS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_UI=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
SRC_OCR=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_MEETINGS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';")
printf " %-20s %s\n" "frames:" "$SRC_FRAMES"
printf " %-20s %s\n" "elements:" "$SRC_ELEMENTS"
printf " %-20s %s\n" "ui_events:" "$SRC_UI"
printf " %-20s %s\n" "ocr_text:" "$SRC_OCR"
printf " %-20s %s\n" "meetings:" "$SRC_MEETINGS"
if [ "$SRC_FRAMES" -eq "0" ]; then
log "No frames found for $TARGET_DATE — skipping DB sync"
DB_ALREADY_SYNCED=true
fi
fi
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── INIT TABLES ──────────────────────────────────────────────────────────
step "Initialising tables, indexes, FTS"
run_sqlite_heredoc "creating tables" "
ATTACH '$NAS_DB' AS nas;
CREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;
CREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;
CREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;
CREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;
DETACH nas;
"
run_sqlite_heredoc "creating indexes" "
ATTACH '$NAS_DB' AS nas;
CREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);
CREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);
DETACH nas;
"
run_sqlite_heredoc "creating FTS tables" "
ATTACH '$NAS_DB' AS nas;
CREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(
text, role, frame_id UNINDEXED,
content='elements', content_rowid='id', tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(
full_text, app_name, window_name, browser_url, id UNINDEXED,
tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(
text_content,
app_name,
window_title,
element_name,
content='ui_events',
content_rowid='id',
tokenize='unicode61'
);
DETACH nas;
"
# ─── SYNC DATA ────────────────────────────────────────────────────────────
step "Syncing data for $TARGET_DATE"
run_sqlite_heredoc "video_chunks" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.video_chunks
SELECT * FROM main.video_chunks
WHERE id IN (
SELECT DISTINCT video_chunk_id FROM main.frames
WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL
);
DETACH nas;
"
run_sqlite_heredoc "frames ($SRC_FRAMES rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.frames
SELECT * FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ocr_text ($SRC_OCR rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ocr_text
SELECT o.* FROM main.ocr_text o
JOIN main.frames f ON o.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ui_events ($SRC_UI rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ui_events
SELECT * FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "elements ($SRC_ELEMENTS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.elements
SELECT e.* FROM main.elements e
JOIN main.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "meetings ($SRC_MEETINGS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.meetings
SELECT * FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';
DETACH nas;
"
# ─── FTS UPDATE ───────────────────────────────────────────────────────────
step "Updating FTS indexes"
run_sqlite_heredoc "elements_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.elements_fts(rowid, text, role)
SELECT e.id, e.text, e.role
FROM nas.elements e
JOIN nas.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE'
AND e.text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "frames_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)
SELECT id, full_text, app_name, window_name, browser_url, id
FROM nas.frames
WHERE date(timestamp) = '$TARGET_DATE'
AND full_text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "ui_events_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)
SELECT id, text_content, app_name, window_title, element_name
FROM nas.ui_events
WHERE date(timestamp) = '$TARGET_DATE'
AND text_content IS NOT NULL;
DETACH nas;
"
# ─── VERIFY DB ────────────────────────────────────────────────────────────
step "Verifying DB"
V_FRAMES=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
V_ELEMENTS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_UI=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
V_OCR=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_MEETINGS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';")
check "frames" "$V_FRAMES" "$SRC_FRAMES"
check "elements" "$V_ELEMENTS" "$SRC_ELEMENTS"
check "ui_events" "$V_UI" "$SRC_UI"
check "ocr_text" "$V_OCR" "$SRC_OCR"
check "meetings" "$V_MEETINGS" "$SRC_MEETINGS"
fi
# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────
# Always runs regardless of DB sync status
step "Copying data folder for $TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
mkdir -p "$NAS_DATA/$TARGET_DATE"
RSYNC_START=$(date +%s)
printf " %-36s " "rsync $TARGET_DATE/ → NAS"
rsync -a --ignore-existing \
"$DATA_SRC/" \
"$NAS_DATA/$TARGET_DATE/" \
2>>"$LOG_FILE"
RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))
COPIED_FILES=$(ls "$NAS_DATA/$TARGET_DATE" | wc -l | tr -d ' ')
SRC_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
COPIED_SIZE=$(du -sh "$NAS_DATA/$TARGET_DATE" | cut -f1)
if [ "$COPIED_FILES" -eq "$SRC_FILES" ]; then
printf "\r %-36s ✓ %dm%02ds (%s files, %s)\n" \
"rsync $TARGET_DATE/ → NAS" \
"$(( RSYNC_DUR / 60 ))" "$(( RSYNC_DUR % 60 ))" \
"$COPIED_FILES" "$COPIED_SIZE" | tee -a "$LOG_FILE"
else
printf "\r %-36s ✗ %s / %s files\n" \
"rsync $TARGET_DATE/ → NAS" "$COPIED_FILES" "$SRC_FILES" | tee -a "$LOG_FILE"
fi
else
printf " %-36s %s\n" "rsync $TARGET_DATE/ → NAS" "skipped (no source dir)"
fi
# ─── SUMMARY ──────────────────────────────────────────────────────────────────
TOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))
DB_SIZE=$(du -sh "$NAS_DB" | cut -f1)
echo ""
log "Archive DB size: $DB_SIZE"
log "Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s"
log "Sync complete for $TARGET_DATE"
log "========================================"
Implement and run pipe l…, Editor Group 2
Problems (⇧⌘M)
PROBLEMS
Output (⇧⌘U)
OUTPUT
Debug Console (⇧⌘Y)
DEBUG CONSOLE
Terminal (⌃`)
TERMINAL
Ports - 1 forwarded port
PORTS
1
remote SSH: nas
SSH: nas
screenpipe (Git) - master*, Checkout Branch/Tag...
master*
screenpipe (Git) - Synchronize Changes
No Problems
0
0
Forwarded Ports: 8766
1
Notifications
Sign In
Sign In
Shell Script
Editor Language Status: $(copilot) No inline suggestion available, Inline suggestions
LF
UTF-8
Spaces: 2
Ln 29, Col 35
git-commit Lukas Kovalik (2 weeks ago)
Lukas Kovalik (2 weeks ago)
No results found
Implement and run pipe logic
Session history
New session
Message actions
main.py
main.py
lets implement logic with pipes. how can I run it?
Thinking
Thinking
Let me look at the current project structure to understand what's already in place.
Bash
List project files
IN
find /volume1/screenpipe -type f | head -50 && echo "---" && ls /volume1/screenpipe
Copy code to clipboard
OUT
/volume1/screenpipe/.DS_Store
/volume1/screenpipe/screenpipe.db
/volume1/screenpipe/screenpipe_sync.sh
/volume1/screenpipe/app_settings.json
/volume1/screenpipe/.gitignore
/volume1/screenpipe/archive.db
/volume1/screenpipe/db.sqlite
/volume1/screenpipe/db.sqlite-wal
/volume1/screenpipe/db.sqlite-shm
/volume1/screenpipe/#recycle/desktop.ini
/volume1/screenpipe/#recycle/db.sqlite
/volume1/screenpipe/#recycle/Copy #1 of db.sqlite
/volume1/screenpipe/#recycle/.DS_Store
/volume1/screenpipe/#recycle/Copy #2 of db.sqlite
/volume1/screenpipe/#recycle/archive.db
/volume1/screenpipe/#recycle/Copy #1 of archive.db
/volume1/screenpipe/#recycle/Copy #2 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of archive.db
/volume1/screenpipe/#recycle/Copy #4 of archive.db
/volume1/screenpipe/#recycle/Copy #5 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of db.sqlite
/volume1/screenpipe/#recycle/Copy #4 of db.sqlite
/volume1/screenpipe/#recycle/Copy #6 of archive.db
/volume1/screenpipe/#recycle/test.txt
/volume1/screenpipe/#recycle/Copy #7 of archive.db
/volume1/screenpipe/#recycle/Copy #8 of archive.db
/volume1/screenpipe/#recycle/archive.db-journal
/volume1/screenpipe/#recycle/Copy #1 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #2 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #3 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #4 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #6 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #7 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of db.sqlite
/volume1/screenpipe/pipes/.DS_Store
/volume1/screenpipe/app/.env
/volume1/screenpipe/app/cli.py
/volume1/screenpipe/app/.DS_Store
/volume1/screenpipe/app/db.py
/volume1/screenpipe/app/docker-compose.yml
/volume1/screenpipe/app/main.py
/volume1/screenpipe/app/requirements.txt
/volume1/screenpipe/app/Dockerfile
/volume1/screenpipe/data/.DS_Store
/volume1/screenpipe/.git/description
/volume1/screenpipe/.git/HEAD
/volume1/screenpipe/.git/index
/volume1/screenpipe/.git/COMMIT_EDITMSG
/volume1/screenpipe/#recycle/data/.DS_Store
---
app
app_settings.json
archive.db
data
db.sqlite
db.sqlite-shm
db.sqlite-wal
pipes
#recycle
screenpipe.db
screenpipe_sync.sh
Read
main.py
main.py
Bash
Check pipes directory and docker-compose
IN
ls /volume1/screenpipe/pipes/ && ls /volume1/screenpipe/app/ && cat /volume1/screenpipe/app/docker-compose.yml
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
cli.py
consumers
db.py
docker-compose.yml
Dockerfile
main.py
__pycache__
requirements.txt
static
services:
screenpipe-app:
build: .
container_name: screenpipe-app
restart: unless-stopped
ports:
- "8766:8000"
volumes:
- /volume1/screenpipe:/data
env_file:
- .env
environment:
TZ: Europe/Sofia
DB_PATH: /data/db.sqlite
sqlite-web-archive:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-archive
restart: unless-stopped
ports:
- "8767:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/archive.db"]
sqlite-web-live:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-live
restart: unless-stopped
ports:
- "8768:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/db.sqlite"]
Read
requirements.txt
requirements.txt
Bash
Inspect a pipe directory
IN
ls /volume1/screenpipe/pipes/day-recap/ && cat /volume1/screenpipe/pipes/day-recap/pipe.json 2>/dev/null || ls /volume1/screenpipe/pipes/day-recap/
Copy code to clipboard
OUT
pipe.md
pipe.md
Read
cli.py
cli.py
Bash
List all pipes and their contents
IN
ls /volume1/screenpipe/pipes/ && for d in /volume1/screenpipe/pipes/*/; do echo "=== $d ==="; ls "$d"; done
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
=== /volume1/screenpipe/pipes/ai-habits/ ===
pipe.md
=== /volume1/screenpipe/pipes/day-recap/ ===
pipe.md
=== /volume1/screenpipe/pipes/meeting-summary/ ===
pipe.md
=== /volume1/screenpipe/pipes/standup-update/ ===
pipe.md
=== /volume1/screenpipe/pipes/time-breakdown/ ===
pipe.md
=== /volume1/screenpipe/pipes/video-export/ ===
pipe.md
Bash
Read pipe markdown files
IN
cat /volume1/screenpipe/pipes/day-recap/pipe.md && echo "===" && cat /volume1/screenpipe/pipes/meeting-summary/pipe.md 2>/dev/null | head -50
Copy code to clipboard
OUT
---
schedule: manual
enabled: true
template: true
title: Day Recap
description: "Today's accomplishments, key moments, and unfinished work"
icon: "📋"
featured: true
---
Analyze my screen and audio recordings from today (last 16 hours only).
Read screenpipe skill first.
Use this exact format:
## Summary
One sentence: what I mainly did today.
## Accomplishments
- Top 3 things I finished, with timestamps (e.g. "2:30 PM")
- Name specific apps, files, or projects
## Key Moments
- Important things I saw, said, or heard — with timestamps
## Unfinished Work
- What I should continue tomorrow — name the app/file/task
## Patterns
- Apps I used most, topics that came up repeatedly
Only report what you can verify from the data. End with: "**Next step:** [most important thing to continue]"
===
---
schedule: manual
enabled: true
template: true
title: Meeting Summary
description: "Summarize meeting transcript with key takeaways and action items"
icon: "🤝"
featured: false
---
Summarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.
Read screenpipe skill first.
Use this exact format:
## Meeting Summary
One sentence: what this meeting was about.
## Key Takeaways
- Top 3-5 important points discussed
- Include who said what when relevant
## Action Items
- [ ] Task — assigned to whom, deadline if mentioned
- [ ] Task — assigned to whom
## Decisions Made
- List any decisions or agreements reached
## Open Questions
- Anything unresolved or needing follow-up
Keep it concise and actionable.
Thinking
Thinking
Bash
Read summary consumer
IN
ls /volume1/screenpipe/app/consumers/ && cat /volume1/screenpipe/app/consumers/summary.py
Copy code to clipboard
OUT
activity.py
audio.py
elements.py
__init__.py
interactions.py
ocr.py
__pycache__
report.py
summary.py
"""AI summary generator using Claude."""
import os
from datetime import date
from typing import Any
from consumers.activity import app_time, summary_stats, browser_urls, ui_event_summary
from consumers.ocr import deduplicated_text
from consumers.audio import formatted_transcript
SUMMARY_TYPES = {
"day_recap": {
"title": "Day Recap",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
## Audio/speech:
{audio}
Write a concise day recap using EXACTLY this format:
## Summary
One sentence: what I mainly worked on today.
## Accomplishments
- Top 3 things I finished, with approximate times
- Name specific apps, files, or projects
## Key Moments
- Important things seen or heard, with timestamps
## Unfinished Work
- What to continue tomorrow
## Patterns
- Apps used most, topics that came up repeatedly
Only report what you can verify from the data. End with:
**Next step:** [most important thing to continue]""",
},
"standup": {
"title": "Standup Update",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
## Audio/speech:
{audio}
Write a brief standup update:
**Yesterday:** What I worked on (2-3 bullets)
**Today:** What I plan to continue (1-2 bullets)
**Blockers:** Any issues observed (or "None")
Keep it under 150 words. Only report what's verifiable from the data.""",
},
"focus_time": {
"title": "Focus & Distraction Analysis",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
Analyze focus vs distraction patterns:
## Deep Work Periods
- When and how long were sustained focus sessions?
- What was being worked on?
## Distractions
- Which apps/sites were used recreationally?
- How much time was lost to context switching?
## Recommendations
- 2-3 concrete suggestions to improve focus tomorrow
Be specific with times and app names.""",
},
}
def _build_context(for_date: date) -> dict[str, str]:
apps = app_time(for_date)
app_lines = "\n".join(f"- {a['app_name']}: {a['minutes']} min" for a in apps[:20])
urls = browser_urls(for_date, limit=20)
url_lines = "\n".join(
f"- {u['browser_url'][:100]} ({u['minutes']} min)" for u in urls
)
ui_rows = ui_event_summary(for_date)
ui_lines = "\n".join(
f"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches"
for r in ui_rows[:15]
)
ocr_rows = deduplicated_text(for_date, chunk_minutes=5)
ocr_lines = "\n".join(
f"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}"
for r in ocr_rows[:100]
)
audio = formatted_transcript(for_date)
return {
"app_time": app_lines or "(no app data)",
"browser_urls": url_lines or "(no browser data)",
"ui_events": ui_lines or "(no UI event data)",
"ocr_text": ocr_lines or "(no screen data)",
"audio": audio[:3000] if len(audio) > 3000 else audio,
}
def generate(
summary_type: str = "day_recap",
for_date: date | None = None,
api_key: str | None = None,
) -> dict[str, Any]:
"""Generate an AI summary. Returns dict with 'title', 'content', 'date'."""
import anthropic
d = for_date or date.today()
key = api_key or os.environ.get("ANTHROPIC_API_KEY", "")
if not key:
return {
"title": "Error",
"content": "ANTHROPIC_API_KEY not set. Add it to your .env file.",
"date": str(d),
}
spec = SUMMARY_TYPES.get(summary_type)
if not spec:
return {"title": "Error", "content": f"Unknown summary type: {summary_type}", "date": str(d)}
stats = summary_stats(d)
if stats["total_frames"] == 0:
return {
"title": spec["title"],
"content": f"No screen data found for {d}.",
"date": str(d),
}
ctx = _build_context(d)
prompt = spec["prompt"].format(**ctx)
client = anthropic.Anthropic(api_key=key)
message = client.messages.create(
model="claude-haiku-4-5-20251001",
max_tokens=1024,
messages=[{"role": "user", "content": prompt}],
)
return {
"title": spec["title"],
"content": message.content[0].text,
"date": str(d),
"stats": stats,
}
Thinking
Thinking
Bash
Read all pipe.md files
IN
for f in /volume1/screenpipe/pipes/*/pipe.md; do echo "=== $f ==="; cat "$f"; echo; done
Copy code to clipboard
OUT
=== /volume1/screenpipe/pipes/ai-habits/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: AI Habits
description: "How you use AI tools — patterns and insights"
icon: "🤖"
featured: true
---
Search my recordings from the last 24 hours for AI tool usage. Use app_name filter for each tool separately: ChatGPT, Claude, Copilot, Cursor, Gemini, Perplexity. Use limit=5 per search, max 6 searches total.
Read screenpipe skill first.
Use this exact format:
## AI Tools Used
- List each tool with approximate time spent (e.g. "Claude: ~45min")
## What I Used Them For
- For each tool: coding, writing, research, or brainstorming
## Usage Patterns
- Do I switch between tools? Use them in bursts or steadily?
## Effectiveness
- Which tool appeared alongside completed work vs. abandoned attempts
If no AI usage is found, say so clearly. End with: "**Tip:** [one suggestion to use AI tools more effectively]"
=== /volume1/screenpipe/pipes/day-recap/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Day Recap
description: "Today's accomplishments, key moments, and unfinished work"
icon: "📋"
featured: true
---
Analyze my screen and audio recordings from today (last 16 hours only).
Read screenpipe skill first.
Use this exact format:
## Summary
One sentence: what I mainly did today.
## Accomplishments
- Top 3 things I finished, with timestamps (e.g. "2:30 PM")
- Name specific apps, files, or projects
## Key Moments
- Important things I saw, said, or heard — with timestamps
## Unfinished Work
- What I should continue tomorrow — name the app/file/task
## Patterns
- Apps I used most, topics that came up repeatedly
Only report what you can verify from the data. End with: "**Next step:** [most important thing to continue]"
=== /volume1/screenpipe/pipes/meeting-summary/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Meeting Summary
description: "Summarize meeting transcript with key takeaways and action items"
icon: "🤝"
featured: false
---
Summarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.
Read screenpipe skill first.
Use this exact format:
## Meeting Summary
One sentence: what this meeting was about.
## Key Takeaways
- Top 3-5 important points discussed
- Include who said what when relevant
## Action Items
- [ ] Task — assigned to whom, deadline if mentioned
- [ ] Task — assigned to whom
## Decisions Made
- List any decisions or agreements reached
## Open Questions
- Anything unresolved or needing follow-up
Keep it concise and actionable.
=== /volume1/screenpipe/pipes/standup-update/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Standup Update
description: "What you did, what's next, and any blockers"
icon: "🏢"
featured: true
---
Based on my recordings from the last 24 hours, generate a standup update. Use limit=10 per search, max 3 searches total.
Read screenpipe skill first.
Use this exact format:
## Yesterday
- What I worked on (name specific projects, files, tools, PRs)
## Today
- What I will work on next (based on unfinished tasks and recent activity)
## Blockers
- Issues I hit — errors, slow builds, waiting on someone
- If no blockers, write "None"
Keep it under 150 words. Copy-paste ready for a team standup.
=== /volume1/screenpipe/pipes/time-breakdown/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Time Breakdown
description: "Where your time went — by app, project, and category"
icon: "⏱"
featured: false
---
Analyze my app usage from today (last 12 hours). Use limit=10 per search, max 4 searches. Prefer /raw_sql with COUNT/GROUP BY queries.
Read screenpipe skill first.
Use this exact format with durations and percentages:
## By Application
- List each app with duration and percentage, sorted by time (e.g. "VS Code: 2h 15min (28%)")
## By Category
- Group into: coding, meetings, browsing, writing, communication, other
- Show hours and percentage per category
## By Project
- Group related activities by project/topic. Name specific repos or tasks.
## Productivity Score
- Calculate: focused_work_hours / total_hours as a percentage
- Focused = coding + writing. Unfocused = browsing + switching.
End with: "**Suggestion:** [one specific change to improve tomorrow's productivity]"
=== /volume1/screenpipe/pipes/video-export/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Export Video Clip
description: "Create a video of your recent screen activity"
icon: "🎬"
featured: false
---
Export a video of my screen activity from the last 5 minutes.
Read screenpipe skill first.
Use the POST /frames/export endpoint with the time range and fps=1.0. Then show me the exported video file path as an inline code block so I can watch it.
If the export is large, suggest a lower fps or shorter time range.
Thinking
Thinking
Now I have a clear picture. The pipes are markdown prompt templates in
/volume1/screenpipe/pipes/
, but there's no code to actually load and run them —
consumers/summary.py
has its own hardcoded prompts instead.
Here's what I'll implement:
consumers/pipes.py
— dynamically loads pipe.md files and runs them via Claude (data injected as system message, pipe body as user prompt)
main.py
— two new endpoints:
GET /api/pipes
and
POST /api/pipes/{pipe_id}/run
cli.py
— a
pipe
command to run pipes from the terminal...
|
[{"role":"AXRadioButton","text [{"role":"AXRadioButton","text":"Explorer (⇧⌘E)","depth":19,"bounds":{"left":0.0,"top":0.047885075,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":true},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.057462092,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Search (⇧⌘F)","depth":19,"bounds":{"left":0.0,"top":0.08619314,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.09577015,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Source Control (⌃⇧G) - 10 pending changes","depth":19,"bounds":{"left":0.0,"top":0.1245012,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.13407822,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"10","depth":22,"bounds":{"left":0.00831117,"top":0.1452514,"width":0.003656915,"height":0.008778931},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.00831117,"top":0.14604948,"width":0.0016622341,"height":0.007980846}},{"char_start":1,"char_count":1,"bounds":{"left":0.009973404,"top":0.14604948,"width":0.0023271276,"height":0.007980846}}],"role_description":"text"},{"role":"AXRadioButton","text":"Run and Debug (⇧⌘D)","depth":19,"bounds":{"left":0.0,"top":0.16280925,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.17238627,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Remote Explorer","depth":19,"bounds":{"left":0.0,"top":0.20111732,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.21069433,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Extensions (⇧⌘X) - 2 require update","depth":19,"bounds":{"left":0.0,"top":0.23942538,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.2490024,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"2","depth":22,"bounds":{"left":0.009640957,"top":0.2601756,"width":0.0019946808,"height":0.008778931},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Claude Code","depth":19,"bounds":{"left":0.0,"top":0.27773345,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"Containers","depth":19,"bounds":{"left":0.0,"top":0.3160415,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXHeading","text":"EXPLORER","depth":17,"bounds":{"left":0.022606382,"top":0.047885075,"width":0.018949468,"height":0.02793296},"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"EXPLORER","depth":18,"bounds":{"left":0.022606382,"top":0.056664005,"width":0.018949468,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.022606382,"top":0.056664005,"width":0.0023271276,"height":0.0103751}},{"char_start":1,"char_count":7,"bounds":{"left":0.024933511,"top":0.056664005,"width":0.01662234,"height":0.0103751}}],"role_description":"text"},{"role":"AXButton","text":"Explorer Section: screenpipe [SSH: nas]","depth":21,"bounds":{"left":0.015957447,"top":0.07581804,"width":0.09940159,"height":0.017557861},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":true},{"role":"AXStaticText","text":"","depth":23,"bounds":{"left":0.01662234,"top":0.07821229,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"Explorer Section: screenpipe [SSH: nas]","depth":22,"bounds":{"left":0.022606382,"top":0.07581804,"width":0.045877658,"height":0.017557861},"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"SCREENPIPE [SSH: NAS]","depth":23,"bounds":{"left":0.022606382,"top":0.079010375,"width":0.045877658,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.022606382,"top":0.07980846,"width":0.0026595744,"height":0.0103751}},{"char_start":1,"char_count":20,"bounds":{"left":0.025265958,"top":0.07980846,"width":0.043218084,"height":0.0103751}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.09577015,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"#recycle","depth":27,"bounds":{"left":0.025930852,"top":0.09577015,"width":0.017287234,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.096568234,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":7,"bounds":{"left":0.028590426,"top":0.096568234,"width":0.01462766,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.11332801,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"app","depth":27,"bounds":{"left":0.025930852,"top":0.11332801,"width":0.0076462766,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.11412609,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":2,"bounds":{"left":0.02825798,"top":0.11412609,"width":0.005319149,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.11412609,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.022273935,"top":0.13088587,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"__pycache__","depth":27,"bounds":{"left":0.028590426,"top":0.13088587,"width":0.026595745,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.13168396,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":10,"bounds":{"left":0.030917553,"top":0.13168396,"width":0.024268618,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.022273935,"top":0.14844373,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"consumers","depth":27,"bounds":{"left":0.028590426,"top":0.14844373,"width":0.022273935,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.14924182,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":8,"bounds":{"left":0.030917553,"top":0.14924182,"width":0.019946808,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.14924182,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.022273935,"top":0.1660016,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"static","depth":27,"bounds":{"left":0.028590426,"top":0.1660016,"width":0.010970744,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.16679968,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":5,"bounds":{"left":0.030917553,"top":0.16679968,"width":0.008976064,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.16679968,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.1819633,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":".env","depth":27,"bounds":{"left":0.028590426,"top":0.18355946,"width":0.00831117,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.18435754,"width":0.0013297872,"height":0.011971269}},{"char_start":1,"char_count":3,"bounds":{"left":0.029920213,"top":0.18435754,"width":0.006981383,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.19952115,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"cli.py","depth":27,"bounds":{"left":0.028590426,"top":0.20111732,"width":0.010638298,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.2019154,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":5,"bounds":{"left":0.030917553,"top":0.2019154,"width":0.00831117,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.2019154,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.21707901,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.py","depth":27,"bounds":{"left":0.028590426,"top":0.21867518,"width":0.011303191,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.21947326,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":4,"bounds":{"left":0.03125,"top":0.21947326,"width":0.008643617,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.23463687,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"docker-compose.yml","depth":27,"bounds":{"left":0.028590426,"top":0.23623304,"width":0.042220745,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.23703113,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":17,"bounds":{"left":0.03125,"top":0.23703113,"width":0.03956117,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.25219473,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Dockerfile","depth":27,"bounds":{"left":0.028590426,"top":0.25379092,"width":0.020611702,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.254589,"width":0.0033244682,"height":0.011971269}},{"char_start":1,"char_count":9,"bounds":{"left":0.031914894,"top":0.254589,"width":0.017287234,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.254589,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.2697526,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"main.py","depth":27,"bounds":{"left":0.028590426,"top":0.27134877,"width":0.015625,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.27214685,"width":0.003656915,"height":0.011971269}},{"char_start":1,"char_count":6,"bounds":{"left":0.032247342,"top":0.27214685,"width":0.012300532,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.27214685,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.28731045,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"requirements.txt","depth":27,"bounds":{"left":0.028590426,"top":0.28890663,"width":0.032912236,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.2897047,"width":0.0016622341,"height":0.011971269}},{"char_start":1,"char_count":15,"bounds":{"left":0.03025266,"top":0.2897047,"width":0.03158245,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.2897047,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.3064645,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"data","depth":27,"bounds":{"left":0.025930852,"top":0.3064645,"width":0.008976064,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.30726257,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":3,"bounds":{"left":0.028590426,"top":0.30726257,"width":0.0063164895,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.32402235,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"logs","depth":27,"bounds":{"left":0.025930852,"top":0.32402235,"width":0.00831117,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.32482043,"width":0.0009973404,"height":0.011971269}},{"char_start":1,"char_count":3,"bounds":{"left":0.026928192,"top":0.32482043,"width":0.0076462766,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.32482043,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.3415802,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"pipes","depth":27,"bounds":{"left":0.025930852,"top":0.3415802,"width":0.010970744,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.3423783,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":4,"bounds":{"left":0.028590426,"top":0.3423783,"width":0.00831117,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.3575419,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":".gitignore","depth":27,"bounds":{"left":0.025930852,"top":0.35913807,"width":0.018949468,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.35993615,"width":0.0013297872,"height":0.011971269}},{"char_start":1,"char_count":9,"bounds":{"left":0.027260639,"top":0.35993615,"width":0.017952127,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.37509975,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"app_settings.json","depth":27,"bounds":{"left":0.025930852,"top":0.37669593,"width":0.03557181,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.377494,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":16,"bounds":{"left":0.02825798,"top":0.377494,"width":0.03324468,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.3926576,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"archive.db","depth":27,"bounds":{"left":0.025930852,"top":0.3942538,"width":0.020944148,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.39505187,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":9,"bounds":{"left":0.02825798,"top":0.39505187,"width":0.01861702,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.4102155,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"archive.db-bak","depth":27,"bounds":{"left":0.025930852,"top":0.41181165,"width":0.03025266,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.41260973,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":13,"bounds":{"left":0.02825798,"top":0.41260973,"width":0.027925532,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"U","depth":27,"bounds":{"left":0.10704787,"top":0.41260973,"width":0.0029920214,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.42777336,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite","depth":27,"bounds":{"left":0.025930852,"top":0.4293695,"width":0.017287234,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.4301676,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":8,"bounds":{"left":0.028590426,"top":0.4301676,"width":0.014960106,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.44533122,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite-shm","depth":27,"bounds":{"left":0.025930852,"top":0.44692737,"width":0.027925532,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.44772545,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":12,"bounds":{"left":0.028590426,"top":0.44772545,"width":0.025265958,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.46288908,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite-wal","depth":27,"bounds":{"left":0.025930852,"top":0.46448523,"width":0.025930852,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.46528333,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":12,"bounds":{"left":0.028590426,"top":0.46528333,"width":0.023603724,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.48044693,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe_sync_updated.sh","depth":27,"bounds":{"left":0.025930852,"top":0.4820431,"width":0.059175532,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.4828412,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":25,"bounds":{"left":0.02825798,"top":0.4828412,"width":0.056848403,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"U","depth":27,"bounds":{"left":0.10704787,"top":0.4828412,"width":0.0029920214,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.4980048,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe_sync.sh","depth":27,"bounds":{"left":0.025930852,"top":0.49960095,"width":0.039893616,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.50039905,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":17,"bounds":{"left":0.02825798,"top":0.50039905,"width":0.037898935,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.51556265,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe.db","depth":27,"bounds":{"left":0.025930852,"top":0.5171588,"width":0.028590426,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.5179569,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":12,"bounds":{"left":0.02825798,"top":0.5179569,"width":0.026595745,"height":0.011971269}}],"role_description":"text"},{"role":"AXButton","text":"Outline Section","depth":21,"bounds":{"left":0.015957447,"top":0.9473264,"width":0.09940159,"height":0.017557861},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":23,"bounds":{"left":0.01662234,"top":0.9497207,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"OUTLINE","depth":22,"bounds":{"left":0.022606382,"top":0.9473264,"width":0.01662234,"height":0.017557861},"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"OUTLINE","depth":23,"bounds":{"left":0.022606382,"top":0.95131683,"width":0.01662234,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.022606382,"top":0.95131683,"width":0.0029920214,"height":0.0103751}},{"char_start":1,"char_count":6,"bounds":{"left":0.025598405,"top":0.95131683,"width":0.013630319,"height":0.0103751}}],"role_description":"text"},{"role":"AXButton","text":"Timeline Section","depth":21,"bounds":{"left":0.015957447,"top":0.9648843,"width":0.09940159,"height":0.017557861},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":23,"bounds":{"left":0.01662234,"top":0.96727854,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"TIMELINE","depth":22,"bounds":{"left":0.022606382,"top":0.9648843,"width":0.01761968,"height":0.017557861},"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"TIMELINE","depth":23,"bounds":{"left":0.022606382,"top":0.9688747,"width":0.01761968,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.022606382,"top":0.9688747,"width":0.0026595744,"height":0.0103751}},{"char_start":1,"char_count":7,"bounds":{"left":0.025265958,"top":0.9688747,"width":0.015292553,"height":0.0103751}}],"role_description":"text"},{"role":"AXRadioButton","text":"app_settings.json, Editor Group 1","depth":28,"bounds":{"left":0.11569149,"top":0.047885075,"width":0.055851065,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"screenpipe_sync.sh, Editor Group 1","depth":28,"bounds":{"left":0.17154256,"top":0.047885075,"width":0.06050532,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":false},{"role":"AXRadioButton","text":"pipe.md, Editor Group 1","depth":28,"bounds":{"left":0.23171543,"top":0.047885075,"width":0.040226065,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":".env, Editor Group 1","depth":28,"bounds":{"left":0.27194148,"top":0.047885075,"width":0.039893616,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"#!/bin/bash\n# screenpipe_sync.sh\n# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).\n# Also copies the day's video/frame data folder to the NAS.\n#\n# Usage:\n# ./screenpipe_sync.sh # syncs yesterday (default)\n# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date\n# ./screenpipe_sync.sh today # syncs today so far\n#\n# Cron example (runs at 3am daily):\n# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1\n\nset -euo pipefail\n\n# ─── CONFIG ───────────────────────────────────────────────────────────────────\nDB_SRC=\"${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}\"\nNAS_MOUNT=\"${NAS_MOUNT:-/Volumes/Test/screenpipe}\"\nNAS_DB=\"$NAS_MOUNT/archive.db\"\nNAS_DATA=\"$NAS_MOUNT/data\"\nLOG_FILE=\"$HOME/.screenpipe/sync.log\"\n# ──────────────────────────────────────────────────────────────────────────────\n\n# ─── HELPERS ──────────────────────────────────────────────────────────────────\nSCRIPT_START=$(date +%s)\n\nlog() {\n local msg=\"[$(date '+%Y-%m-%d %H:%M:%S')] $*\"\n echo \"$msg\" | tee -a \"$LOG_FILE\"\n}\n\nstep() {\n local now=$(date +%s)\n local elapsed=$(( now - SCRIPT_START ))\n local min=$(( elapsed / 60 ))\n local sec=$(( elapsed % 60 ))\n printf \"\\n[+%02dm%02ds] ▶ %s\\n\" \"$min\" \"$sec\" \"$*\" | tee -a \"$LOG_FILE\"\n}\n\nrun_sqlite_heredoc() {\n local label=\"$1\"\n local sql=\"$2\"\n local start=$(date +%s)\n\n printf \" %-36s \" \"$label\"\n\n sqlite3 \"$DB_SRC\" <<< \"$sql\" &\n local pid=$!\n local spin=('⠋' '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')\n local i=0\n while kill -0 \"$pid\" 2>/dev/null; do\n printf \"\\r %-36s %s \" \"$label\" \"${spin[$i]}\"\n i=$(( (i + 1) % 10 ))\n sleep 0.2\n done\n wait \"$pid\"\n local rc=$?\n if [ $rc -ne 0 ]; then\n printf \"\\r %-36s ✗ FAILED\\n\" \"$label\" | tee -a \"$LOG_FILE\"\n exit $rc\n fi\n\n local dur=$(( $(date +%s) - start ))\n printf \"\\r %-36s ✓ %dm%02ds\\n\" \"$label\" \"$(( dur / 60 ))\" \"$(( dur % 60 ))\" | tee -a \"$LOG_FILE\"\n}\n\ncheck() {\n local label=\"$1\" got=\"$2\" expected=\"$3\"\n if [ \"$got\" -eq \"$expected\" ]; then\n printf \" %-20s %s / %s ✓\\n\" \"$label:\" \"$got\" \"$expected\"\n else\n printf \" %-20s %s / %s ✗ MISMATCH\\n\" \"$label:\" \"$got\" \"$expected\"\n fi\n}\n# ──────────────────────────────────────────────────────────────────────────────\n\n# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────\nif [ \"${1:-}\" = \"today\" ]; then\n TARGET_DATE=$(date +%Y-%m-%d)\nelif [ -n \"${1:-}\" ]; then\n TARGET_DATE=\"$1\"\n if ! [[ \"$TARGET_DATE\" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then\n echo \"ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday.\"\n exit 1\n fi\nelse\n TARGET_DATE=$(date -v-1d +%Y-%m-%d)\nfi\n\nlog \"========================================\"\nlog \"Screenpipe sync starting for: $TARGET_DATE\"\nlog \"========================================\"\n\n# ─── PREFLIGHT ────────────────────────────────────────────────────────────────\nstep \"Preflight checks\"\n\nif [ ! -f \"$DB_SRC\" ]; then\n log \"ERROR: Source DB not found at $DB_SRC\"; exit 1\nfi\nprintf \" %-20s %s (%s)\\n\" \"Source DB:\" \"OK\" \"$(du -sh \"$DB_SRC\" | cut -f1)\"\n\nif [ ! -d \"$NAS_MOUNT\" ]; then\n log \"ERROR: NAS not mounted at $NAS_MOUNT\"; exit 1\nfi\nprintf \" %-20s %s\\n\" \"NAS mount:\" \"OK $NAS_MOUNT\"\n\n# Check if DB already synced for this date\nDB_ALREADY_SYNCED=false\nif [ -f \"$NAS_DB\" ]; then\n EXISTING=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\" 2>/dev/null || echo \"0\")\n if [ \"$EXISTING\" -gt \"0\" ]; then\n log \"Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync\"\n DB_ALREADY_SYNCED=true\n else\n printf \" %-20s %s (%s)\\n\" \"Archive DB:\" \"exists\" \"$(du -sh \"$NAS_DB\" | cut -f1)\"\n fi\nelse\n printf \" %-20s %s\\n\" \"Archive DB:\" \"will be created\"\nfi\n\n# Source data dir for this date\nDATA_SRC=\"$HOME/.screenpipe/data/data/$TARGET_DATE\"\nif [ -d \"$DATA_SRC\" ]; then\n DATA_SIZE=$(du -sh \"$DATA_SRC\" | cut -f1)\n DATA_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n printf \" %-20s %s (%s files, %s)\\n\" \"Data dir:\" \"OK\" \"$DATA_FILES\" \"$DATA_SIZE\"\nelse\n printf \" %-20s %s\\n\" \"Data dir:\" \"not found — skipping file copy\"\nfi\n\n# ─── DB SYNC ──────────────────────────────────────────────────────────────────\nif [ \"$DB_ALREADY_SYNCED\" = false ]; then\n\n # ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────\n step \"Counting source rows for $TARGET_DATE\"\n\n SRC_FRAMES=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\")\n SRC_ELEMENTS=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n SRC_UI=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';\")\n SRC_OCR=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n SRC_MEETINGS=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';\")\n\n printf \" %-20s %s\\n\" \"frames:\" \"$SRC_FRAMES\"\n printf \" %-20s %s\\n\" \"elements:\" \"$SRC_ELEMENTS\"\n printf \" %-20s %s\\n\" \"ui_events:\" \"$SRC_UI\"\n printf \" %-20s %s\\n\" \"ocr_text:\" \"$SRC_OCR\"\n printf \" %-20s %s\\n\" \"meetings:\" \"$SRC_MEETINGS\"\n\n if [ \"$SRC_FRAMES\" -eq \"0\" ]; then\n log \"No frames found for $TARGET_DATE — skipping DB sync\"\n DB_ALREADY_SYNCED=true\n fi\n\nfi\n\nif [ \"$DB_ALREADY_SYNCED\" = false ]; then\n\n # ─── INIT TABLES ──────────────────────────────────────────────────────────\n step \"Initialising tables, indexes, FTS\"\n\n run_sqlite_heredoc \"creating tables\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"creating indexes\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);\nCREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);\nCREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"creating FTS tables\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(\n text, role, frame_id UNINDEXED,\n content='elements', content_rowid='id', tokenize='unicode61'\n);\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(\n full_text, app_name, window_name, browser_url, id UNINDEXED,\n tokenize='unicode61'\n);\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(\n text_content,\n app_name,\n window_title,\n element_name,\n content='ui_events',\n content_rowid='id',\n tokenize='unicode61'\n);\nDETACH nas;\n\"\n\n # ─── SYNC DATA ────────────────────────────────────────────────────────────\n step \"Syncing data for $TARGET_DATE\"\n\n run_sqlite_heredoc \"video_chunks\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.video_chunks\n SELECT * FROM main.video_chunks\n WHERE id IN (\n SELECT DISTINCT video_chunk_id FROM main.frames\n WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL\n );\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames ($SRC_FRAMES rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.frames\n SELECT * FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ocr_text ($SRC_OCR rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ocr_text\n SELECT o.* FROM main.ocr_text o\n JOIN main.frames f ON o.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events ($SRC_UI rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ui_events\n SELECT * FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"elements ($SRC_ELEMENTS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.elements\n SELECT e.* FROM main.elements e\n JOIN main.frames f ON e.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"meetings ($SRC_MEETINGS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.meetings\n SELECT * FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n # ─── FTS UPDATE ───────────────────────────────────────────────────────────\n step \"Updating FTS indexes\"\n\n run_sqlite_heredoc \"elements_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.elements_fts(rowid, text, role)\n SELECT e.id, e.text, e.role\n FROM nas.elements e\n JOIN nas.frames f ON e.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE'\n AND e.text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)\n SELECT id, full_text, app_name, window_name, browser_url, id\n FROM nas.frames\n WHERE date(timestamp) = '$TARGET_DATE'\n AND full_text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)\n SELECT id, text_content, app_name, window_title, element_name\n FROM nas.ui_events\n WHERE date(timestamp) = '$TARGET_DATE'\n AND text_content IS NOT NULL;\nDETACH nas;\n\"\n\n # ─── VERIFY DB ────────────────────────────────────────────────────────────\n step \"Verifying DB\"\n\n V_FRAMES=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\")\n V_ELEMENTS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n V_UI=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';\")\n V_OCR=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n V_MEETINGS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';\")\n\n check \"frames\" \"$V_FRAMES\" \"$SRC_FRAMES\"\n check \"elements\" \"$V_ELEMENTS\" \"$SRC_ELEMENTS\"\n check \"ui_events\" \"$V_UI\" \"$SRC_UI\"\n check \"ocr_text\" \"$V_OCR\" \"$SRC_OCR\"\n check \"meetings\" \"$V_MEETINGS\" \"$SRC_MEETINGS\"\n\nfi\n\n# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────\n# Always runs regardless of DB sync status\nstep \"Copying data folder for $TARGET_DATE\"\n\nif [ -d \"$DATA_SRC\" ]; then\n mkdir -p \"$NAS_DATA/$TARGET_DATE\"\n RSYNC_START=$(date +%s)\n printf \" %-36s \" \"rsync $TARGET_DATE/ → NAS\"\n rsync -a --ignore-existing \\\n \"$DATA_SRC/\" \\\n \"$NAS_DATA/$TARGET_DATE/\" \\\n 2>>\"$LOG_FILE\"\n RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))\n COPIED_FILES=$(ls \"$NAS_DATA/$TARGET_DATE\" | wc -l | tr -d ' ')\n SRC_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n COPIED_SIZE=$(du -sh \"$NAS_DATA/$TARGET_DATE\" | cut -f1)\n if [ \"$COPIED_FILES\" -eq \"$SRC_FILES\" ]; then\n printf \"\\r %-36s ✓ %dm%02ds (%s files, %s)\\n\" \\\n \"rsync $TARGET_DATE/ → NAS\" \\\n \"$(( RSYNC_DUR / 60 ))\" \"$(( RSYNC_DUR % 60 ))\" \\\n \"$COPIED_FILES\" \"$COPIED_SIZE\" | tee -a \"$LOG_FILE\"\n else\n printf \"\\r %-36s ✗ %s / %s files\\n\" \\\n \"rsync $TARGET_DATE/ → NAS\" \"$COPIED_FILES\" \"$SRC_FILES\" | tee -a \"$LOG_FILE\"\n fi\nelse\n printf \" %-36s %s\\n\" \"rsync $TARGET_DATE/ → NAS\" \"skipped (no source dir)\"\nfi\n\n# ─── SUMMARY ──────────────────────────────────────────────────────────────────\nTOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))\nDB_SIZE=$(du -sh \"$NAS_DB\" | cut -f1)\n\necho \"\"\nlog \"Archive DB size: $DB_SIZE\"\nlog \"Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s\"\nlog \"Sync complete for $TARGET_DATE\"\nlog \"========================================\"","depth":28,"bounds":{"left":0.13763298,"top":0.36871508,"width":0.38031915,"height":0.014365523},"on_screen":true,"value":"#!/bin/bash\n# screenpipe_sync.sh\n# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).\n# Also copies the day's video/frame data folder to the NAS.\n#\n# Usage:\n# ./screenpipe_sync.sh # syncs yesterday (default)\n# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date\n# ./screenpipe_sync.sh today # syncs today so far\n#\n# Cron example (runs at 3am daily):\n# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1\n\nset -euo pipefail\n\n# ─── CONFIG ───────────────────────────────────────────────────────────────────\nDB_SRC=\"${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}\"\nNAS_MOUNT=\"${NAS_MOUNT:-/Volumes/Test/screenpipe}\"\nNAS_DB=\"$NAS_MOUNT/archive.db\"\nNAS_DATA=\"$NAS_MOUNT/data\"\nLOG_FILE=\"$HOME/.screenpipe/sync.log\"\n# ──────────────────────────────────────────────────────────────────────────────\n\n# ─── HELPERS ──────────────────────────────────────────────────────────────────\nSCRIPT_START=$(date +%s)\n\nlog() {\n local msg=\"[$(date '+%Y-%m-%d %H:%M:%S')] $*\"\n echo \"$msg\" | tee -a \"$LOG_FILE\"\n}\n\nstep() {\n local now=$(date +%s)\n local elapsed=$(( now - SCRIPT_START ))\n local min=$(( elapsed / 60 ))\n local sec=$(( elapsed % 60 ))\n printf \"\\n[+%02dm%02ds] ▶ %s\\n\" \"$min\" \"$sec\" \"$*\" | tee -a \"$LOG_FILE\"\n}\n\nrun_sqlite_heredoc() {\n local label=\"$1\"\n local sql=\"$2\"\n local start=$(date +%s)\n\n printf \" %-36s \" \"$label\"\n\n sqlite3 \"$DB_SRC\" <<< \"$sql\" &\n local pid=$!\n local spin=('⠋' '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')\n local i=0\n while kill -0 \"$pid\" 2>/dev/null; do\n printf \"\\r %-36s %s \" \"$label\" \"${spin[$i]}\"\n i=$(( (i + 1) % 10 ))\n sleep 0.2\n done\n wait \"$pid\"\n local rc=$?\n if [ $rc -ne 0 ]; then\n printf \"\\r %-36s ✗ FAILED\\n\" \"$label\" | tee -a \"$LOG_FILE\"\n exit $rc\n fi\n\n local dur=$(( $(date +%s) - start ))\n printf \"\\r %-36s ✓ %dm%02ds\\n\" \"$label\" \"$(( dur / 60 ))\" \"$(( dur % 60 ))\" | tee -a \"$LOG_FILE\"\n}\n\ncheck() {\n local label=\"$1\" got=\"$2\" expected=\"$3\"\n if [ \"$got\" -eq \"$expected\" ]; then\n printf \" %-20s %s / %s ✓\\n\" \"$label:\" \"$got\" \"$expected\"\n else\n printf \" %-20s %s / %s ✗ MISMATCH\\n\" \"$label:\" \"$got\" \"$expected\"\n fi\n}\n# ──────────────────────────────────────────────────────────────────────────────\n\n# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────\nif [ \"${1:-}\" = \"today\" ]; then\n TARGET_DATE=$(date +%Y-%m-%d)\nelif [ -n \"${1:-}\" ]; then\n TARGET_DATE=\"$1\"\n if ! [[ \"$TARGET_DATE\" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then\n echo \"ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday.\"\n exit 1\n fi\nelse\n TARGET_DATE=$(date -v-1d +%Y-%m-%d)\nfi\n\nlog \"========================================\"\nlog \"Screenpipe sync starting for: $TARGET_DATE\"\nlog \"========================================\"\n\n# ─── PREFLIGHT ────────────────────────────────────────────────────────────────\nstep \"Preflight checks\"\n\nif [ ! -f \"$DB_SRC\" ]; then\n log \"ERROR: Source DB not found at $DB_SRC\"; exit 1\nfi\nprintf \" %-20s %s (%s)\\n\" \"Source DB:\" \"OK\" \"$(du -sh \"$DB_SRC\" | cut -f1)\"\n\nif [ ! -d \"$NAS_MOUNT\" ]; then\n log \"ERROR: NAS not mounted at $NAS_MOUNT\"; exit 1\nfi\nprintf \" %-20s %s\\n\" \"NAS mount:\" \"OK $NAS_MOUNT\"\n\n# Check if DB already synced for this date\nDB_ALREADY_SYNCED=false\nif [ -f \"$NAS_DB\" ]; then\n EXISTING=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\" 2>/dev/null || echo \"0\")\n if [ \"$EXISTING\" -gt \"0\" ]; then\n log \"Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync\"\n DB_ALREADY_SYNCED=true\n else\n printf \" %-20s %s (%s)\\n\" \"Archive DB:\" \"exists\" \"$(du -sh \"$NAS_DB\" | cut -f1)\"\n fi\nelse\n printf \" %-20s %s\\n\" \"Archive DB:\" \"will be created\"\nfi\n\n# Source data dir for this date\nDATA_SRC=\"$HOME/.screenpipe/data/data/$TARGET_DATE\"\nif [ -d \"$DATA_SRC\" ]; then\n DATA_SIZE=$(du -sh \"$DATA_SRC\" | cut -f1)\n DATA_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n printf \" %-20s %s (%s files, %s)\\n\" \"Data dir:\" \"OK\" \"$DATA_FILES\" \"$DATA_SIZE\"\nelse\n printf \" %-20s %s\\n\" \"Data dir:\" \"not found — skipping file copy\"\nfi\n\n# ─── DB SYNC ──────────────────────────────────────────────────────────────────\nif [ \"$DB_ALREADY_SYNCED\" = false ]; then\n\n # ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────\n step \"Counting source rows for $TARGET_DATE\"\n\n SRC_FRAMES=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\")\n SRC_ELEMENTS=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n SRC_UI=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';\")\n SRC_OCR=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n SRC_MEETINGS=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';\")\n\n printf \" %-20s %s\\n\" \"frames:\" \"$SRC_FRAMES\"\n printf \" %-20s %s\\n\" \"elements:\" \"$SRC_ELEMENTS\"\n printf \" %-20s %s\\n\" \"ui_events:\" \"$SRC_UI\"\n printf \" %-20s %s\\n\" \"ocr_text:\" \"$SRC_OCR\"\n printf \" %-20s %s\\n\" \"meetings:\" \"$SRC_MEETINGS\"\n\n if [ \"$SRC_FRAMES\" -eq \"0\" ]; then\n log \"No frames found for $TARGET_DATE — skipping DB sync\"\n DB_ALREADY_SYNCED=true\n fi\n\nfi\n\nif [ \"$DB_ALREADY_SYNCED\" = false ]; then\n\n # ─── INIT TABLES ──────────────────────────────────────────────────────────\n step \"Initialising tables, indexes, FTS\"\n\n run_sqlite_heredoc \"creating tables\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"creating indexes\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);\nCREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);\nCREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"creating FTS tables\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(\n text, role, frame_id UNINDEXED,\n content='elements', content_rowid='id', tokenize='unicode61'\n);\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(\n full_text, app_name, window_name, browser_url, id UNINDEXED,\n tokenize='unicode61'\n);\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(\n text_content,\n app_name,\n window_title,\n element_name,\n content='ui_events',\n content_rowid='id',\n tokenize='unicode61'\n);\nDETACH nas;\n\"\n\n # ─── SYNC DATA ────────────────────────────────────────────────────────────\n step \"Syncing data for $TARGET_DATE\"\n\n run_sqlite_heredoc \"video_chunks\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.video_chunks\n SELECT * FROM main.video_chunks\n WHERE id IN (\n SELECT DISTINCT video_chunk_id FROM main.frames\n WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL\n );\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames ($SRC_FRAMES rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.frames\n SELECT * FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ocr_text ($SRC_OCR rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ocr_text\n SELECT o.* FROM main.ocr_text o\n JOIN main.frames f ON o.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events ($SRC_UI rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ui_events\n SELECT * FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"elements ($SRC_ELEMENTS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.elements\n SELECT e.* FROM main.elements e\n JOIN main.frames f ON e.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"meetings ($SRC_MEETINGS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.meetings\n SELECT * FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n # ─── FTS UPDATE ───────────────────────────────────────────────────────────\n step \"Updating FTS indexes\"\n\n run_sqlite_heredoc \"elements_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.elements_fts(rowid, text, role)\n SELECT e.id, e.text, e.role\n FROM nas.elements e\n JOIN nas.frames f ON e.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE'\n AND e.text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)\n SELECT id, full_text, app_name, window_name, browser_url, id\n FROM nas.frames\n WHERE date(timestamp) = '$TARGET_DATE'\n AND full_text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)\n SELECT id, text_content, app_name, window_title, element_name\n FROM nas.ui_events\n WHERE date(timestamp) = '$TARGET_DATE'\n AND text_content IS NOT NULL;\nDETACH nas;\n\"\n\n # ─── VERIFY DB ────────────────────────────────────────────────────────────\n step \"Verifying DB\"\n\n V_FRAMES=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\")\n V_ELEMENTS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n V_UI=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';\")\n V_OCR=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n V_MEETINGS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';\")\n\n check \"frames\" \"$V_FRAMES\" \"$SRC_FRAMES\"\n check \"elements\" \"$V_ELEMENTS\" \"$SRC_ELEMENTS\"\n check \"ui_events\" \"$V_UI\" \"$SRC_UI\"\n check \"ocr_text\" \"$V_OCR\" \"$SRC_OCR\"\n check \"meetings\" \"$V_MEETINGS\" \"$SRC_MEETINGS\"\n\nfi\n\n# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────\n# Always runs regardless of DB sync status\nstep \"Copying data folder for $TARGET_DATE\"\n\nif [ -d \"$DATA_SRC\" ]; then\n mkdir -p \"$NAS_DATA/$TARGET_DATE\"\n RSYNC_START=$(date +%s)\n printf \" %-36s \" \"rsync $TARGET_DATE/ → NAS\"\n rsync -a --ignore-existing \\\n \"$DATA_SRC/\" \\\n \"$NAS_DATA/$TARGET_DATE/\" \\\n 2>>\"$LOG_FILE\"\n RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))\n COPIED_FILES=$(ls \"$NAS_DATA/$TARGET_DATE\" | wc -l | tr -d ' ')\n SRC_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n COPIED_SIZE=$(du -sh \"$NAS_DATA/$TARGET_DATE\" | cut -f1)\n if [ \"$COPIED_FILES\" -eq \"$SRC_FILES\" ]; then\n printf \"\\r %-36s ✓ %dm%02ds (%s files, %s)\\n\" \\\n \"rsync $TARGET_DATE/ → NAS\" \\\n \"$(( RSYNC_DUR / 60 ))\" \"$(( RSYNC_DUR % 60 ))\" \\\n \"$COPIED_FILES\" \"$COPIED_SIZE\" | tee -a \"$LOG_FILE\"\n else\n printf \"\\r %-36s ✗ %s / %s files\\n\" \\\n \"rsync $TARGET_DATE/ → NAS\" \"$COPIED_FILES\" \"$SRC_FILES\" | tee -a \"$LOG_FILE\"\n fi\nelse\n printf \" %-36s %s\\n\" \"rsync $TARGET_DATE/ → NAS\" \"skipped (no source dir)\"\nfi\n\n# ─── SUMMARY ──────────────────────────────────────────────────────────────────\nTOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))\nDB_SIZE=$(du -sh \"$NAS_DB\" | cut -f1)\n\necho \"\"\nlog \"Archive DB size: $DB_SIZE\"\nlog \"Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s\"\nlog \"Sync complete for $TARGET_DATE\"\nlog \"========================================\"","role_description":"editor","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"#!/bin/bash\n# screenpipe_sync.sh\n# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).\n# Also copies the day's video/frame data folder to the NAS.\n#\n# Usage:\n# ./screenpipe_sync.sh # syncs yesterday (default)\n# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date\n# ./screenpipe_sync.sh today # syncs today so far\n#\n# Cron example (runs at 3am daily):\n# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1\n\nset -euo pipefail\n\n# ─── CONFIG ───────────────────────────────────────────────────────────────────\nDB_SRC=\"${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}\"\nNAS_MOUNT=\"${NAS_MOUNT:-/Volumes/Test/screenpipe}\"\nNAS_DB=\"$NAS_MOUNT/archive.db\"\nNAS_DATA=\"$NAS_MOUNT/data\"\nLOG_FILE=\"$HOME/.screenpipe/sync.log\"\n# ──────────────────────────────────────────────────────────────────────────────\n\n# ─── HELPERS ──────────────────────────────────────────────────────────────────\nSCRIPT_START=$(date +%s)\n\nlog() {\n local msg=\"[$(date '+%Y-%m-%d %H:%M:%S')] $*\"\n echo \"$msg\" | tee -a \"$LOG_FILE\"\n}\n\nstep() {\n local now=$(date +%s)\n local elapsed=$(( now - SCRIPT_START ))\n local min=$(( elapsed / 60 ))\n local sec=$(( elapsed % 60 ))\n printf \"\\n[+%02dm%02ds] ▶ %s\\n\" \"$min\" \"$sec\" \"$*\" | tee -a \"$LOG_FILE\"\n}\n\nrun_sqlite_heredoc() {\n local label=\"$1\"\n local sql=\"$2\"\n local start=$(date +%s)\n\n printf \" %-36s \" \"$label\"\n\n sqlite3 \"$DB_SRC\" <<< \"$sql\" &\n local pid=$!\n local spin=('⠋' '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')\n local i=0\n while kill -0 \"$pid\" 2>/dev/null; do\n printf \"\\r %-36s %s \" \"$label\" \"${spin[$i]}\"\n i=$(( (i + 1) % 10 ))\n sleep 0.2\n done\n wait \"$pid\"\n local rc=$?\n if [ $rc -ne 0 ]; then\n printf \"\\r %-36s ✗ FAILED\\n\" \"$label\" | tee -a \"$LOG_FILE\"\n exit $rc\n fi\n\n local dur=$(( $(date +%s) - start ))\n printf \"\\r %-36s ✓ %dm%02ds\\n\" \"$label\" \"$(( dur / 60 ))\" \"$(( dur % 60 ))\" | tee -a \"$LOG_FILE\"\n}\n\ncheck() {\n local label=\"$1\" got=\"$2\" expected=\"$3\"\n if [ \"$got\" -eq \"$expected\" ]; then\n printf \" %-20s %s / %s ✓\\n\" \"$label:\" \"$got\" \"$expected\"\n else\n printf \" %-20s %s / %s ✗ MISMATCH\\n\" \"$label:\" \"$got\" \"$expected\"\n fi\n}\n# ──────────────────────────────────────────────────────────────────────────────\n\n# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────\nif [ \"${1:-}\" = \"today\" ]; then\n TARGET_DATE=$(date +%Y-%m-%d)\nelif [ -n \"${1:-}\" ]; then\n TARGET_DATE=\"$1\"\n if ! [[ \"$TARGET_DATE\" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then\n echo \"ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday.\"\n exit 1\n fi\nelse\n TARGET_DATE=$(date -v-1d +%Y-%m-%d)\nfi\n\nlog \"========================================\"\nlog \"Screenpipe sync starting for: $TARGET_DATE\"\nlog \"========================================\"\n\n# ─── PREFLIGHT ────────────────────────────────────────────────────────────────\nstep \"Preflight checks\"\n\nif [ ! -f \"$DB_SRC\" ]; then\n log \"ERROR: Source DB not found at $DB_SRC\"; exit 1\nfi\nprintf \" %-20s %s (%s)\\n\" \"Source DB:\" \"OK\" \"$(du -sh \"$DB_SRC\" | cut -f1)\"\n\nif [ ! -d \"$NAS_MOUNT\" ]; then\n log \"ERROR: NAS not mounted at $NAS_MOUNT\"; exit 1\nfi\nprintf \" %-20s %s\\n\" \"NAS mount:\" \"OK $NAS_MOUNT\"\n\n# Check if DB already synced for this date\nDB_ALREADY_SYNCED=false\nif [ -f \"$NAS_DB\" ]; then\n EXISTING=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\" 2>/dev/null || echo \"0\")\n if [ \"$EXISTING\" -gt \"0\" ]; then\n log \"Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync\"\n DB_ALREADY_SYNCED=true\n else\n printf \" %-20s %s (%s)\\n\" \"Archive DB:\" \"exists\" \"$(du -sh \"$NAS_DB\" | cut -f1)\"\n fi\nelse\n printf \" %-20s %s\\n\" \"Archive DB:\" \"will be created\"\nfi\n\n# Source data dir for this date\nDATA_SRC=\"$HOME/.screenpipe/data/data/$TARGET_DATE\"\nif [ -d \"$DATA_SRC\" ]; then\n DATA_SIZE=$(du -sh \"$DATA_SRC\" | cut -f1)\n DATA_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n printf \" %-20s %s (%s files, %s)\\n\" \"Data dir:\" \"OK\" \"$DATA_FILES\" \"$DATA_SIZE\"\nelse\n printf \" %-20s %s\\n\" \"Data dir:\" \"not found — skipping file copy\"\nfi\n\n# ─── DB SYNC ──────────────────────────────────────────────────────────────────\nif [ \"$DB_ALREADY_SYNCED\" = false ]; then\n\n # ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────\n step \"Counting source rows for $TARGET_DATE\"\n\n SRC_FRAMES=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\")\n SRC_ELEMENTS=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n SRC_UI=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';\")\n SRC_OCR=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n SRC_MEETINGS=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';\")\n\n printf \" %-20s %s\\n\" \"frames:\" \"$SRC_FRAMES\"\n printf \" %-20s %s\\n\" \"elements:\" \"$SRC_ELEMENTS\"\n printf \" %-20s %s\\n\" \"ui_events:\" \"$SRC_UI\"\n printf \" %-20s %s\\n\" \"ocr_text:\" \"$SRC_OCR\"\n printf \" %-20s %s\\n\" \"meetings:\" \"$SRC_MEETINGS\"\n\n if [ \"$SRC_FRAMES\" -eq \"0\" ]; then\n log \"No frames found for $TARGET_DATE — skipping DB sync\"\n DB_ALREADY_SYNCED=true\n fi\n\nfi\n\nif [ \"$DB_ALREADY_SYNCED\" = false ]; then\n\n # ─── INIT TABLES ──────────────────────────────────────────────────────────\n step \"Initialising tables, indexes, FTS\"\n\n run_sqlite_heredoc \"creating tables\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"creating indexes\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);\nCREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);\nCREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"creating FTS tables\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(\n text, role, frame_id UNINDEXED,\n content='elements', content_rowid='id', tokenize='unicode61'\n);\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(\n full_text, app_name, window_name, browser_url, id UNINDEXED,\n tokenize='unicode61'\n);\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(\n text_content,\n app_name,\n window_title,\n element_name,\n content='ui_events',\n content_rowid='id',\n tokenize='unicode61'\n);\nDETACH nas;\n\"\n\n # ─── SYNC DATA ────────────────────────────────────────────────────────────\n step \"Syncing data for $TARGET_DATE\"\n\n run_sqlite_heredoc \"video_chunks\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.video_chunks\n SELECT * FROM main.video_chunks\n WHERE id IN (\n SELECT DISTINCT video_chunk_id FROM main.frames\n WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL\n );\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames ($SRC_FRAMES rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.frames\n SELECT * FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ocr_text ($SRC_OCR rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ocr_text\n SELECT o.* FROM main.ocr_text o\n JOIN main.frames f ON o.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events ($SRC_UI rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ui_events\n SELECT * FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"elements ($SRC_ELEMENTS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.elements\n SELECT e.* FROM main.elements e\n JOIN main.frames f ON e.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"meetings ($SRC_MEETINGS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.meetings\n SELECT * FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n # ─── FTS UPDATE ───────────────────────────────────────────────────────────\n step \"Updating FTS indexes\"\n\n run_sqlite_heredoc \"elements_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.elements_fts(rowid, text, role)\n SELECT e.id, e.text, e.role\n FROM nas.elements e\n JOIN nas.frames f ON e.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE'\n AND e.text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)\n SELECT id, full_text, app_name, window_name, browser_url, id\n FROM nas.frames\n WHERE date(timestamp) = '$TARGET_DATE'\n AND full_text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)\n SELECT id, text_content, app_name, window_title, element_name\n FROM nas.ui_events\n WHERE date(timestamp) = '$TARGET_DATE'\n AND text_content IS NOT NULL;\nDETACH nas;\n\"\n\n # ─── VERIFY DB ────────────────────────────────────────────────────────────\n step \"Verifying DB\"\n\n V_FRAMES=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\")\n V_ELEMENTS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n V_UI=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';\")\n V_OCR=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n V_MEETINGS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';\")\n\n check \"frames\" \"$V_FRAMES\" \"$SRC_FRAMES\"\n check \"elements\" \"$V_ELEMENTS\" \"$SRC_ELEMENTS\"\n check \"ui_events\" \"$V_UI\" \"$SRC_UI\"\n check \"ocr_text\" \"$V_OCR\" \"$SRC_OCR\"\n check \"meetings\" \"$V_MEETINGS\" \"$SRC_MEETINGS\"\n\nfi\n\n# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────\n# Always runs regardless of DB sync status\nstep \"Copying data folder for $TARGET_DATE\"\n\nif [ -d \"$DATA_SRC\" ]; then\n mkdir -p \"$NAS_DATA/$TARGET_DATE\"\n RSYNC_START=$(date +%s)\n printf \" %-36s \" \"rsync $TARGET_DATE/ → NAS\"\n rsync -a --ignore-existing \\\n \"$DATA_SRC/\" \\\n \"$NAS_DATA/$TARGET_DATE/\" \\\n 2>>\"$LOG_FILE\"\n RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))\n COPIED_FILES=$(ls \"$NAS_DATA/$TARGET_DATE\" | wc -l | tr -d ' ')\n SRC_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n COPIED_SIZE=$(du -sh \"$NAS_DATA/$TARGET_DATE\" | cut -f1)\n if [ \"$COPIED_FILES\" -eq \"$SRC_FILES\" ]; then\n printf \"\\r %-36s ✓ %dm%02ds (%s files, %s)\\n\" \\\n \"rsync $TARGET_DATE/ → NAS\" \\\n \"$(( RSYNC_DUR / 60 ))\" \"$(( RSYNC_DUR % 60 ))\" \\\n \"$COPIED_FILES\" \"$COPIED_SIZE\" | tee -a \"$LOG_FILE\"\n else\n printf \"\\r %-36s ✗ %s / %s files\\n\" \\\n \"rsync $TARGET_DATE/ → NAS\" \"$COPIED_FILES\" \"$SRC_FILES\" | tee -a \"$LOG_FILE\"\n fi\nelse\n printf \" %-36s %s\\n\" \"rsync $TARGET_DATE/ → NAS\" \"skipped (no source dir)\"\nfi\n\n# ─── SUMMARY ──────────────────────────────────────────────────────────────────\nTOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))\nDB_SIZE=$(du -sh \"$NAS_DB\" | cut -f1)\n\necho \"\"\nlog \"Archive DB size: $DB_SIZE\"\nlog \"Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s\"\nlog \"Sync complete for $TARGET_DATE\"\nlog \"========================================\"","depth":29,"bounds":{"left":0.13763298,"top":0.36871508,"width":0.35804522,"height":0.014365523},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Implement and run pipe l…, Editor Group 2","depth":28,"bounds":{"left":0.5578458,"top":0.047885075,"width":0.073803194,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":false},{"role":"AXRadioButton","text":"Problems (⇧⌘M)","depth":22,"bounds":{"left":0.118351065,"top":0.7278532,"width":0.027925532,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"PROBLEMS","depth":24,"bounds":{"left":0.122340426,"top":0.7366321,"width":0.019946808,"height":0.0103751},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Output (⇧⌘U)","depth":22,"bounds":{"left":0.14594415,"top":0.7278532,"width":0.023603724,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUTPUT","depth":24,"bounds":{"left":0.14993352,"top":0.7366321,"width":0.015625,"height":0.0103751},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Debug Console (⇧⌘Y)","depth":22,"bounds":{"left":0.16921543,"top":0.7278532,"width":0.039893616,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"DEBUG CONSOLE","depth":24,"bounds":{"left":0.1732048,"top":0.7366321,"width":0.031914894,"height":0.0103751},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Terminal (⌃`)","depth":22,"bounds":{"left":0.2087766,"top":0.7278532,"width":0.026595745,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":true},{"role":"AXStaticText","text":"TERMINAL","depth":24,"bounds":{"left":0.21276596,"top":0.7366321,"width":0.01861702,"height":0.0103751},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Ports - 1 forwarded port","depth":22,"bounds":{"left":0.23537233,"top":0.7278532,"width":0.026263298,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"PORTS","depth":24,"bounds":{"left":0.2393617,"top":0.7366321,"width":0.012300532,"height":0.0103751},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":25,"bounds":{"left":0.25465426,"top":0.73743016,"width":0.0019946808,"height":0.008778931},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"remote SSH: nas","depth":16,"bounds":{"left":0.0006648936,"top":0.98244214,"width":0.028590426,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.0033244682,"top":0.9848364,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"SSH: nas","depth":17,"bounds":{"left":0.008643617,"top":0.9856345,"width":0.017952127,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"screenpipe (Git) - master*, Checkout Branch/Tag...","depth":16,"bounds":{"left":0.030917553,"top":0.98244214,"width":0.023271276,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.031914894,"top":0.9848364,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"master*","depth":17,"bounds":{"left":0.03723404,"top":0.9856345,"width":0.015957447,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"screenpipe (Git) - Synchronize Changes","depth":16,"bounds":{"left":0.05418883,"top":0.98244214,"width":0.00731383,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"No Problems","depth":16,"bounds":{"left":0.06416223,"top":0.98244214,"width":0.022606382,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.06582447,"top":0.9848364,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"0","depth":17,"bounds":{"left":0.07114362,"top":0.9856345,"width":0.004986702,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.07579787,"top":0.9848364,"width":0.0056515955,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"0","depth":17,"bounds":{"left":0.08111702,"top":0.9856345,"width":0.0039893617,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Forwarded Ports: 8766","depth":16,"bounds":{"left":0.08843085,"top":0.98244214,"width":0.012632979,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.09009308,"top":0.9848364,"width":0.0056515955,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":17,"bounds":{"left":0.09541223,"top":0.9856345,"width":0.0039893617,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Notifications","depth":16,"bounds":{"left":0.9886968,"top":0.98244214,"width":0.010638298,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sign In","depth":16,"bounds":{"left":0.9650931,"top":0.98244214,"width":0.022606382,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.96675533,"top":0.9848364,"width":0.0056515955,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Sign In","depth":17,"bounds":{"left":0.97207445,"top":0.9856345,"width":0.013962766,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Shell Script","depth":16,"bounds":{"left":0.93916225,"top":0.98244214,"width":0.023603724,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Editor Language Status: $(copilot) No inline suggestion available, Inline suggestions","depth":16,"bounds":{"left":0.9318484,"top":0.98244214,"width":0.00731383,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"LF","depth":16,"bounds":{"left":0.9212101,"top":0.98244214,"width":0.007978723,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"UTF-8","depth":16,"bounds":{"left":0.90359044,"top":0.98244214,"width":0.015625,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Spaces: 2","depth":16,"bounds":{"left":0.8796542,"top":0.98244214,"width":0.022273935,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Ln 29, Col 35","depth":16,"bounds":{"left":0.8490692,"top":0.98244214,"width":0.028922873,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"git-commit Lukas Kovalik (2 weeks ago)","depth":16,"bounds":{"left":0.78424203,"top":0.98244214,"width":0.062832445,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.7859042,"top":0.9848364,"width":0.0056515955,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Lukas Kovalik (2 weeks ago)","depth":17,"bounds":{"left":0.7912234,"top":0.9856345,"width":0.05418883,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"No results found","depth":12,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Implement and run pipe logic","depth":19,"bounds":{"left":0.56017286,"top":0.08060654,"width":0.07114362,"height":0.022346368},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Session history","depth":19,"bounds":{"left":0.9780585,"top":0.08060654,"width":0.00930851,"height":0.022346368},"on_screen":true,"help_text":"Session history","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"New session","depth":19,"bounds":{"left":0.9886968,"top":0.08060654,"width":0.00930851,"height":0.022346368},"on_screen":true,"help_text":"New session","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Message actions","depth":24,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"main.py","depth":23,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"lets implement logic with pipes. how can I run it?","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Let me look at the current project structure to understand what's already in place.","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"List project files","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"find /volume1/screenpipe -type f | head -50 && echo \"---\" && ls /volume1/screenpipe","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"/volume1/screenpipe/.DS_Store\n/volume1/screenpipe/screenpipe.db\n/volume1/screenpipe/screenpipe_sync.sh\n/volume1/screenpipe/app_settings.json\n/volume1/screenpipe/.gitignore\n/volume1/screenpipe/archive.db\n/volume1/screenpipe/db.sqlite\n/volume1/screenpipe/db.sqlite-wal\n/volume1/screenpipe/db.sqlite-shm\n/volume1/screenpipe/#recycle/desktop.ini\n/volume1/screenpipe/#recycle/db.sqlite\n/volume1/screenpipe/#recycle/Copy #1 of db.sqlite\n/volume1/screenpipe/#recycle/.DS_Store\n/volume1/screenpipe/#recycle/Copy #2 of db.sqlite\n/volume1/screenpipe/#recycle/archive.db\n/volume1/screenpipe/#recycle/Copy #1 of archive.db\n/volume1/screenpipe/#recycle/Copy #2 of archive.db\n/volume1/screenpipe/#recycle/Copy #3 of archive.db\n/volume1/screenpipe/#recycle/Copy #4 of archive.db\n/volume1/screenpipe/#recycle/Copy #5 of archive.db\n/volume1/screenpipe/#recycle/Copy #3 of db.sqlite\n/volume1/screenpipe/#recycle/Copy #4 of db.sqlite\n/volume1/screenpipe/#recycle/Copy #6 of archive.db\n/volume1/screenpipe/#recycle/test.txt\n/volume1/screenpipe/#recycle/Copy #7 of archive.db\n/volume1/screenpipe/#recycle/Copy #8 of archive.db\n/volume1/screenpipe/#recycle/archive.db-journal\n/volume1/screenpipe/#recycle/Copy #1 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #2 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #3 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #4 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #5 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #6 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #7 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #5 of db.sqlite\n/volume1/screenpipe/pipes/.DS_Store\n/volume1/screenpipe/app/.env\n/volume1/screenpipe/app/cli.py\n/volume1/screenpipe/app/.DS_Store\n/volume1/screenpipe/app/db.py\n/volume1/screenpipe/app/docker-compose.yml\n/volume1/screenpipe/app/main.py\n/volume1/screenpipe/app/requirements.txt\n/volume1/screenpipe/app/Dockerfile\n/volume1/screenpipe/data/.DS_Store\n/volume1/screenpipe/.git/description\n/volume1/screenpipe/.git/HEAD\n/volume1/screenpipe/.git/index\n/volume1/screenpipe/.git/COMMIT_EDITMSG\n/volume1/screenpipe/#recycle/data/.DS_Store\n---\napp\napp_settings.json\narchive.db\ndata\ndb.sqlite\ndb.sqlite-shm\ndb.sqlite-wal\npipes\n#recycle\nscreenpipe.db\nscreenpipe_sync.sh","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"main.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Check pipes directory and docker-compose","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/pipes/ && ls /volume1/screenpipe/app/ && cat /volume1/screenpipe/app/docker-compose.yml","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ai-habits\nday-recap\nmeeting-summary\nstandup-update\ntime-breakdown\nvideo-export\ncli.py\nconsumers\ndb.py\ndocker-compose.yml\nDockerfile\nmain.py\n__pycache__\nrequirements.txt\nstatic\nservices:\n screenpipe-app:\n build: .\n container_name: screenpipe-app\n restart: unless-stopped\n ports:\n - \"8766:8000\"\n volumes:\n - /volume1/screenpipe:/data\n env_file:\n - .env\n environment:\n TZ: Europe/Sofia\n DB_PATH: /data/db.sqlite\n\n sqlite-web-archive:\n image: ghcr.io/coleifer/sqlite-web:latest\n container_name: screenpipe-sqlweb-archive\n restart: unless-stopped\n ports:\n - \"8767:8080\"\n volumes:\n - /volume1/screenpipe:/data\n command: [\"-H\", \"0.0.0.0\", \"-r\", \"/data/archive.db\"]\n\n sqlite-web-live:\n image: ghcr.io/coleifer/sqlite-web:latest\n container_name: screenpipe-sqlweb-live\n restart: unless-stopped\n ports:\n - \"8768:8080\"\n volumes:\n - /volume1/screenpipe:/data\n command: [\"-H\", \"0.0.0.0\", \"-r\", \"/data/db.sqlite\"]","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"requirements.txt","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"requirements.txt","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Inspect a pipe directory","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/pipes/day-recap/ && cat /volume1/screenpipe/pipes/day-recap/pipe.json 2>/dev/null || ls /volume1/screenpipe/pipes/day-recap/","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"pipe.md\npipe.md","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"cli.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"cli.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"List all pipes and their contents","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/pipes/ && for d in /volume1/screenpipe/pipes/*/; do echo \"=== $d ===\"; ls \"$d\"; done","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ai-habits\nday-recap\nmeeting-summary\nstandup-update\ntime-breakdown\nvideo-export\n=== /volume1/screenpipe/pipes/ai-habits/ ===\npipe.md\n=== /volume1/screenpipe/pipes/day-recap/ ===\npipe.md\n=== /volume1/screenpipe/pipes/meeting-summary/ ===\npipe.md\n=== /volume1/screenpipe/pipes/standup-update/ ===\npipe.md\n=== /volume1/screenpipe/pipes/time-breakdown/ ===\npipe.md\n=== /volume1/screenpipe/pipes/video-export/ ===\npipe.md","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read pipe markdown files","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"cat /volume1/screenpipe/pipes/day-recap/pipe.md && echo \"===\" && cat /volume1/screenpipe/pipes/meeting-summary/pipe.md 2>/dev/null | head -50","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Day Recap\ndescription: \"Today's accomplishments, key moments, and unfinished work\"\nicon: \"📋\"\nfeatured: true\n---\n\nAnalyze my screen and audio recordings from today (last 16 hours only). \n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Summary\nOne sentence: what I mainly did today.\n\n## Accomplishments\n- Top 3 things I finished, with timestamps (e.g. \"2:30 PM\")\n- Name specific apps, files, or projects\n\n## Key Moments\n- Important things I saw, said, or heard — with timestamps\n\n## Unfinished Work\n- What I should continue tomorrow — name the app/file/task\n\n## Patterns\n- Apps I used most, topics that came up repeatedly\n\nOnly report what you can verify from the data. End with: \"**Next step:** [most important thing to continue]\"\n===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Meeting Summary\ndescription: \"Summarize meeting transcript with key takeaways and action items\"\nicon: \"🤝\"\nfeatured: false\n---\n\nSummarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.\n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Meeting Summary\nOne sentence: what this meeting was about.\n\n## Key Takeaways\n- Top 3-5 important points discussed\n- Include who said what when relevant\n\n## Action Items\n- [ ] Task — assigned to whom, deadline if mentioned\n- [ ] Task — assigned to whom\n\n## Decisions Made\n- List any decisions or agreements reached\n\n## Open Questions\n- Anything unresolved or needing follow-up\n\nKeep it concise and actionable.","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read summary consumer","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/app/consumers/ && cat /volume1/screenpipe/app/consumers/summary.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"activity.py\naudio.py\nelements.py\n__init__.py\ninteractions.py\nocr.py\n__pycache__\nreport.py\nsummary.py\n\"\"\"AI summary generator using Claude.\"\"\"\nimport os\nfrom datetime import date\nfrom typing import Any\n\nfrom consumers.activity import app_time, summary_stats, browser_urls, ui_event_summary\nfrom consumers.ocr import deduplicated_text\nfrom consumers.audio import formatted_transcript\n\n\nSUMMARY_TYPES = {\n \"day_recap\": {\n \"title\": \"Day Recap\",\n \"prompt\": \"\"\"\\\nYou are analyzing a person's computer activity for the day.\n\n## App usage (minutes per app):\n{app_time}\n\n## Browser URLs visited:\n{browser_urls}\n\n## UI activity per app (clicks / keystrokes / app-switches):\n{ui_events}\n\n## Screen content (sampled every 5 minutes):\n{ocr_text}\n\n## Audio/speech:\n{audio}\n\nWrite a concise day recap using EXACTLY this format:\n\n## Summary\nOne sentence: what I mainly worked on today.\n\n## Accomplishments\n- Top 3 things I finished, with approximate times\n- Name specific apps, files, or projects\n\n## Key Moments\n- Important things seen or heard, with timestamps\n\n## Unfinished Work\n- What to continue tomorrow\n\n## Patterns\n- Apps used most, topics that came up repeatedly\n\nOnly report what you can verify from the data. End with:\n**Next step:** [most important thing to continue]\"\"\",\n },\n \"standup\": {\n \"title\": \"Standup Update\",\n \"prompt\": \"\"\"\\\nYou are analyzing a person's computer activity for the day.\n\n## App usage (minutes per app):\n{app_time}\n\n## Browser URLs visited:\n{browser_urls}\n\n## UI activity per app (clicks / keystrokes / app-switches):\n{ui_events}\n\n## Screen content (sampled every 5 minutes):\n{ocr_text}\n\n## Audio/speech:\n{audio}\n\nWrite a brief standup update:\n\n**Yesterday:** What I worked on (2-3 bullets)\n**Today:** What I plan to continue (1-2 bullets)\n**Blockers:** Any issues observed (or \"None\")\n\nKeep it under 150 words. Only report what's verifiable from the data.\"\"\",\n },\n \"focus_time\": {\n \"title\": \"Focus & Distraction Analysis\",\n \"prompt\": \"\"\"\\\nYou are analyzing a person's computer activity for the day.\n\n## App usage (minutes per app):\n{app_time}\n\n## Browser URLs visited:\n{browser_urls}\n\n## UI activity per app (clicks / keystrokes / app-switches):\n{ui_events}\n\n## Screen content (sampled every 5 minutes):\n{ocr_text}\n\nAnalyze focus vs distraction patterns:\n\n## Deep Work Periods\n- When and how long were sustained focus sessions?\n- What was being worked on?\n\n## Distractions\n- Which apps/sites were used recreationally?\n- How much time was lost to context switching?\n\n## Recommendations\n- 2-3 concrete suggestions to improve focus tomorrow\n\nBe specific with times and app names.\"\"\",\n },\n}\n\n\ndef _build_context(for_date: date) -> dict[str, str]:\n apps = app_time(for_date)\n app_lines = \"\\n\".join(f\"- {a['app_name']}: {a['minutes']} min\" for a in apps[:20])\n\n urls = browser_urls(for_date, limit=20)\n url_lines = \"\\n\".join(\n f\"- {u['browser_url'][:100]} ({u['minutes']} min)\" for u in urls\n )\n\n ui_rows = ui_event_summary(for_date)\n ui_lines = \"\\n\".join(\n f\"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches\"\n for r in ui_rows[:15]\n )\n\n ocr_rows = deduplicated_text(for_date, chunk_minutes=5)\n ocr_lines = \"\\n\".join(\n f\"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}\"\n for r in ocr_rows[:100]\n )\n\n audio = formatted_transcript(for_date)\n\n return {\n \"app_time\": app_lines or \"(no app data)\",\n \"browser_urls\": url_lines or \"(no browser data)\",\n \"ui_events\": ui_lines or \"(no UI event data)\",\n \"ocr_text\": ocr_lines or \"(no screen data)\",\n \"audio\": audio[:3000] if len(audio) > 3000 else audio,\n }\n\n\ndef generate(\n summary_type: str = \"day_recap\",\n for_date: date | None = None,\n api_key: str | None = None,\n) -> dict[str, Any]:\n \"\"\"Generate an AI summary. Returns dict with 'title', 'content', 'date'.\"\"\"\n import anthropic\n\n d = for_date or date.today()\n key = api_key or os.environ.get(\"ANTHROPIC_API_KEY\", \"\")\n if not key:\n return {\n \"title\": \"Error\",\n \"content\": \"ANTHROPIC_API_KEY not set. Add it to your .env file.\",\n \"date\": str(d),\n }\n\n spec = SUMMARY_TYPES.get(summary_type)\n if not spec:\n return {\"title\": \"Error\", \"content\": f\"Unknown summary type: {summary_type}\", \"date\": str(d)}\n\n stats = summary_stats(d)\n if stats[\"total_frames\"] == 0:\n return {\n \"title\": spec[\"title\"],\n \"content\": f\"No screen data found for {d}.\",\n \"date\": str(d),\n }\n\n ctx = _build_context(d)\n prompt = spec[\"prompt\"].format(**ctx)\n\n client = anthropic.Anthropic(api_key=key)\n message = client.messages.create(\n model=\"claude-haiku-4-5-20251001\",\n max_tokens=1024,\n messages=[{\"role\": \"user\", \"content\": prompt}],\n )\n\n return {\n \"title\": spec[\"title\"],\n \"content\": message.content[0].text,\n \"date\": str(d),\n \"stats\": stats,\n }","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read all pipe.md files","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"for f in /volume1/screenpipe/pipes/*/pipe.md; do echo \"=== $f ===\"; cat \"$f\"; echo; done","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"=== /volume1/screenpipe/pipes/ai-habits/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: AI Habits\ndescription: \"How you use AI tools — patterns and insights\"\nicon: \"🤖\"\nfeatured: true\n---\n\nSearch my recordings from the last 24 hours for AI tool usage. Use app_name filter for each tool separately: ChatGPT, Claude, Copilot, Cursor, Gemini, Perplexity. Use limit=5 per search, max 6 searches total.\n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## AI Tools Used\n- List each tool with approximate time spent (e.g. \"Claude: ~45min\")\n\n## What I Used Them For\n- For each tool: coding, writing, research, or brainstorming\n\n## Usage Patterns\n- Do I switch between tools? Use them in bursts or steadily?\n\n## Effectiveness\n- Which tool appeared alongside completed work vs. abandoned attempts\n\nIf no AI usage is found, say so clearly. End with: \"**Tip:** [one suggestion to use AI tools more effectively]\"\n\n=== /volume1/screenpipe/pipes/day-recap/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Day Recap\ndescription: \"Today's accomplishments, key moments, and unfinished work\"\nicon: \"📋\"\nfeatured: true\n---\n\nAnalyze my screen and audio recordings from today (last 16 hours only). \n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Summary\nOne sentence: what I mainly did today.\n\n## Accomplishments\n- Top 3 things I finished, with timestamps (e.g. \"2:30 PM\")\n- Name specific apps, files, or projects\n\n## Key Moments\n- Important things I saw, said, or heard — with timestamps\n\n## Unfinished Work\n- What I should continue tomorrow — name the app/file/task\n\n## Patterns\n- Apps I used most, topics that came up repeatedly\n\nOnly report what you can verify from the data. End with: \"**Next step:** [most important thing to continue]\"\n\n=== /volume1/screenpipe/pipes/meeting-summary/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Meeting Summary\ndescription: \"Summarize meeting transcript with key takeaways and action items\"\nicon: \"🤝\"\nfeatured: false\n---\n\nSummarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.\n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Meeting Summary\nOne sentence: what this meeting was about.\n\n## Key Takeaways\n- Top 3-5 important points discussed\n- Include who said what when relevant\n\n## Action Items\n- [ ] Task — assigned to whom, deadline if mentioned\n- [ ] Task — assigned to whom\n\n## Decisions Made\n- List any decisions or agreements reached\n\n## Open Questions\n- Anything unresolved or needing follow-up\n\nKeep it concise and actionable.\n\n=== /volume1/screenpipe/pipes/standup-update/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Standup Update\ndescription: \"What you did, what's next, and any blockers\"\nicon: \"🏢\"\nfeatured: true\n---\n\nBased on my recordings from the last 24 hours, generate a standup update. Use limit=10 per search, max 3 searches total.\n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Yesterday\n- What I worked on (name specific projects, files, tools, PRs)\n\n## Today\n- What I will work on next (based on unfinished tasks and recent activity)\n\n## Blockers\n- Issues I hit — errors, slow builds, waiting on someone\n- If no blockers, write \"None\"\n\nKeep it under 150 words. Copy-paste ready for a team standup.\n\n=== /volume1/screenpipe/pipes/time-breakdown/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Time Breakdown\ndescription: \"Where your time went — by app, project, and category\"\nicon: \"⏱\"\nfeatured: false\n---\n\nAnalyze my app usage from today (last 12 hours). Use limit=10 per search, max 4 searches. Prefer /raw_sql with COUNT/GROUP BY queries.\n\nRead screenpipe skill first.\n\nUse this exact format with durations and percentages:\n\n## By Application\n- List each app with duration and percentage, sorted by time (e.g. \"VS Code: 2h 15min (28%)\")\n\n## By Category\n- Group into: coding, meetings, browsing, writing, communication, other\n- Show hours and percentage per category\n\n## By Project\n- Group related activities by project/topic. Name specific repos or tasks.\n\n## Productivity Score\n- Calculate: focused_work_hours / total_hours as a percentage\n- Focused = coding + writing. Unfocused = browsing + switching.\n\nEnd with: \"**Suggestion:** [one specific change to improve tomorrow's productivity]\"\n\n=== /volume1/screenpipe/pipes/video-export/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Export Video Clip\ndescription: \"Create a video of your recent screen activity\"\nicon: \"🎬\"\nfeatured: false\n---\n\nExport a video of my screen activity from the last 5 minutes.\n\nRead screenpipe skill first.\n\nUse the POST /frames/export endpoint with the time range and fps=1.0. Then show me the exported video file path as an inline code block so I can watch it.\n\nIf the export is large, suggest a lower fps or shorter time range.","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Now I have a clear picture. The pipes are markdown prompt templates in","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"/volume1/screenpipe/pipes/","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":", but there's no code to actually load and run them —","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"consumers/summary.py","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"has its own hardcoded prompts instead.","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Here's what I'll implement:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"consumers/pipes.py","depth":26,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"— dynamically loads pipe.md files and runs them via Claude (data injected as system message, pipe body as user prompt)","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"main.py","depth":26,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"— two new endpoints:","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"GET /api/pipes","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"and","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"POST /api/pipes/{pipe_id}/run","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"cli.py","depth":26,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"— a","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"pipe","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"command to run pipes from the terminal","depth":24,"on_screen":false,"role_description":"text"}]...
|
1661999495696698492
|
3895833367589391637
|
visual_change
|
accessibility
|
NULL
|
Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧ Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py
M
db.py
docker-compose.yml
Dockerfile
M
main.py
M
requirements.txt
M
data
logs
pipes
.gitignore
app_settings.json
archive.db
archive.db-bak
U
db.sqlite
db.sqlite-shm
db.sqlite-wal
screenpipe_sync_updated.sh
U
screenpipe_sync.sh
screenpipe.db
Outline Section
OUTLINE
OUTLINE
Timeline Section
TIMELINE
TIMELINE
app_settings.json, Editor Group 1
screenpipe_sync.sh, Editor Group 1
pipe.md, Editor Group 1
.env, Editor Group 1
#!/bin/bash
# screenpipe_sync.sh
# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).
# Also copies the day's video/frame data folder to the NAS.
#
# Usage:
# ./screenpipe_sync.sh # syncs yesterday (default)
# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date
# ./screenpipe_sync.sh today # syncs today so far
#
# Cron example (runs at 3am daily):
# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1
set -euo pipefail
# ─── CONFIG ───────────────────────────────────────────────────────────────────
DB_SRC="${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}"
NAS_MOUNT="${NAS_MOUNT:-/Volumes/Test/screenpipe}"
NAS_DB="$NAS_MOUNT/archive.db"
NAS_DATA="$NAS_MOUNT/data"
LOG_FILE="$HOME/.screenpipe/sync.log"
# ──────────────────────────────────────────────────────────────────────────────
# ─── HELPERS ──────────────────────────────────────────────────────────────────
SCRIPT_START=$(date +%s)
log() {
local msg="[$(date '+%Y-%m-%d %H:%M:%S')] $*"
echo "$msg" | tee -a "$LOG_FILE"
}
step() {
local now=$(date +%s)
local elapsed=$(( now - SCRIPT_START ))
local min=$(( elapsed / 60 ))
local sec=$(( elapsed % 60 ))
printf "\n[+%02dm%02ds] ▶ %s\n" "$min" "$sec" "$*" | tee -a "$LOG_FILE"
}
run_sqlite_heredoc() {
local label="$1"
local sql="$2"
local start=$(date +%s)
printf " %-36s " "$label"
sqlite3 "$DB_SRC" <<< "$sql" &
local pid=$!
local spin=[PASSWORD] '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')
local i=0
while kill -0 "$pid" 2>/dev/null; do
printf "\r %-36s %s " "$label" "${spin[$i]}"
i=$(( (i + 1) % 10 ))
sleep 0.2
done
wait "$pid"
local rc=$?
if [ $rc -ne 0 ]; then
printf "\r %-36s ✗ FAILED\n" "$label" | tee -a "$LOG_FILE"
exit $rc
fi
local dur=$(( $(date +%s) - start ))
printf "\r %-36s ✓ %dm%02ds\n" "$label" "$(( dur / 60 ))" "$(( dur % 60 ))" | tee -a "$LOG_FILE"
}
check() {
local label="$1" got="$2" expected="$3"
if [ "$got" -eq "$expected" ]; then
printf " %-20s %s / %s ✓\n" "$label:" "$got" "$expected"
else
printf " %-20s %s / %s ✗ MISMATCH\n" "$label:" "$got" "$expected"
fi
}
# ──────────────────────────────────────────────────────────────────────────────
# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────
if [ "${1:-}" = "today" ]; then
TARGET_DATE=$(date +%Y-%m-%d)
elif [ -n "${1:-}" ]; then
TARGET_DATE="$1"
if ! [[ "$TARGET_DATE" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then
echo "ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday."
exit 1
fi
else
TARGET_DATE=$(date -v-1d +%Y-%m-%d)
fi
log "========================================"
log "Screenpipe sync starting for: $TARGET_DATE"
log "========================================"
# ─── PREFLIGHT ────────────────────────────────────────────────────────────────
step "Preflight checks"
if [ ! -f "$DB_SRC" ]; then
log "ERROR: Source DB not found at $DB_SRC"; exit 1
fi
printf " %-20s %s (%s)\n" "Source DB:" "OK" "$(du -sh "$DB_SRC" | cut -f1)"
if [ ! -d "$NAS_MOUNT" ]; then
log "ERROR: NAS not mounted at $NAS_MOUNT"; exit 1
fi
printf " %-20s %s\n" "NAS mount:" "OK $NAS_MOUNT"
# Check if DB already synced for this date
DB_ALREADY_SYNCED=false
if [ -f "$NAS_DB" ]; then
EXISTING=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';" 2>/dev/null || echo "0")
if [ "$EXISTING" -gt "0" ]; then
log "Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync"
DB_ALREADY_SYNCED=true
else
printf " %-20s %s (%s)\n" "Archive DB:" "exists" "$(du -sh "$NAS_DB" | cut -f1)"
fi
else
printf " %-20s %s\n" "Archive DB:" "will be created"
fi
# Source data dir for this date
DATA_SRC="$HOME/.screenpipe/data/data/$TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
DATA_SIZE=$(du -sh "$DATA_SRC" | cut -f1)
DATA_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
printf " %-20s %s (%s files, %s)\n" "Data dir:" "OK" "$DATA_FILES" "$DATA_SIZE"
else
printf " %-20s %s\n" "Data dir:" "not found — skipping file copy"
fi
# ─── DB SYNC ──────────────────────────────────────────────────────────────────
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────
step "Counting source rows for $TARGET_DATE"
SRC_FRAMES=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
SRC_ELEMENTS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_UI=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
SRC_OCR=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_MEETINGS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';")
printf " %-20s %s\n" "frames:" "$SRC_FRAMES"
printf " %-20s %s\n" "elements:" "$SRC_ELEMENTS"
printf " %-20s %s\n" "ui_events:" "$SRC_UI"
printf " %-20s %s\n" "ocr_text:" "$SRC_OCR"
printf " %-20s %s\n" "meetings:" "$SRC_MEETINGS"
if [ "$SRC_FRAMES" -eq "0" ]; then
log "No frames found for $TARGET_DATE — skipping DB sync"
DB_ALREADY_SYNCED=true
fi
fi
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── INIT TABLES ──────────────────────────────────────────────────────────
step "Initialising tables, indexes, FTS"
run_sqlite_heredoc "creating tables" "
ATTACH '$NAS_DB' AS nas;
CREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;
CREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;
CREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;
CREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;
DETACH nas;
"
run_sqlite_heredoc "creating indexes" "
ATTACH '$NAS_DB' AS nas;
CREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);
CREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);
DETACH nas;
"
run_sqlite_heredoc "creating FTS tables" "
ATTACH '$NAS_DB' AS nas;
CREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(
text, role, frame_id UNINDEXED,
content='elements', content_rowid='id', tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(
full_text, app_name, window_name, browser_url, id UNINDEXED,
tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(
text_content,
app_name,
window_title,
element_name,
content='ui_events',
content_rowid='id',
tokenize='unicode61'
);
DETACH nas;
"
# ─── SYNC DATA ────────────────────────────────────────────────────────────
step "Syncing data for $TARGET_DATE"
run_sqlite_heredoc "video_chunks" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.video_chunks
SELECT * FROM main.video_chunks
WHERE id IN (
SELECT DISTINCT video_chunk_id FROM main.frames
WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL
);
DETACH nas;
"
run_sqlite_heredoc "frames ($SRC_FRAMES rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.frames
SELECT * FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ocr_text ($SRC_OCR rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ocr_text
SELECT o.* FROM main.ocr_text o
JOIN main.frames f ON o.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ui_events ($SRC_UI rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ui_events
SELECT * FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "elements ($SRC_ELEMENTS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.elements
SELECT e.* FROM main.elements e
JOIN main.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "meetings ($SRC_MEETINGS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.meetings
SELECT * FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';
DETACH nas;
"
# ─── FTS UPDATE ───────────────────────────────────────────────────────────
step "Updating FTS indexes"
run_sqlite_heredoc "elements_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.elements_fts(rowid, text, role)
SELECT e.id, e.text, e.role
FROM nas.elements e
JOIN nas.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE'
AND e.text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "frames_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)
SELECT id, full_text, app_name, window_name, browser_url, id
FROM nas.frames
WHERE date(timestamp) = '$TARGET_DATE'
AND full_text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "ui_events_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)
SELECT id, text_content, app_name, window_title, element_name
FROM nas.ui_events
WHERE date(timestamp) = '$TARGET_DATE'
AND text_content IS NOT NULL;
DETACH nas;
"
# ─── VERIFY DB ────────────────────────────────────────────────────────────
step "Verifying DB"
V_FRAMES=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
V_ELEMENTS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_UI=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
V_OCR=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_MEETINGS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';")
check "frames" "$V_FRAMES" "$SRC_FRAMES"
check "elements" "$V_ELEMENTS" "$SRC_ELEMENTS"
check "ui_events" "$V_UI" "$SRC_UI"
check "ocr_text" "$V_OCR" "$SRC_OCR"
check "meetings" "$V_MEETINGS" "$SRC_MEETINGS"
fi
# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────
# Always runs regardless of DB sync status
step "Copying data folder for $TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
mkdir -p "$NAS_DATA/$TARGET_DATE"
RSYNC_START=$(date +%s)
printf " %-36s " "rsync $TARGET_DATE/ → NAS"
rsync -a --ignore-existing \
"$DATA_SRC/" \
"$NAS_DATA/$TARGET_DATE/" \
2>>"$LOG_FILE"
RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))
COPIED_FILES=$(ls "$NAS_DATA/$TARGET_DATE" | wc -l | tr -d ' ')
SRC_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
COPIED_SIZE=$(du -sh "$NAS_DATA/$TARGET_DATE" | cut -f1)
if [ "$COPIED_FILES" -eq "$SRC_FILES" ]; then
printf "\r %-36s ✓ %dm%02ds (%s files, %s)\n" \
"rsync $TARGET_DATE/ → NAS" \
"$(( RSYNC_DUR / 60 ))" "$(( RSYNC_DUR % 60 ))" \
"$COPIED_FILES" "$COPIED_SIZE" | tee -a "$LOG_FILE"
else
printf "\r %-36s ✗ %s / %s files\n" \
"rsync $TARGET_DATE/ → NAS" "$COPIED_FILES" "$SRC_FILES" | tee -a "$LOG_FILE"
fi
else
printf " %-36s %s\n" "rsync $TARGET_DATE/ → NAS" "skipped (no source dir)"
fi
# ─── SUMMARY ──────────────────────────────────────────────────────────────────
TOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))
DB_SIZE=$(du -sh "$NAS_DB" | cut -f1)
echo ""
log "Archive DB size: $DB_SIZE"
log "Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s"
log "Sync complete for $TARGET_DATE"
log "========================================"
#!/bin/bash
# screenpipe_sync.sh
# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).
# Also copies the day's video/frame data folder to the NAS.
#
# Usage:
# ./screenpipe_sync.sh # syncs yesterday (default)
# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date
# ./screenpipe_sync.sh today # syncs today so far
#
# Cron example (runs at 3am daily):
# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1
set -euo pipefail
# ─── CONFIG ───────────────────────────────────────────────────────────────────
DB_SRC="${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}"
NAS_MOUNT="${NAS_MOUNT:-/Volumes/Test/screenpipe}"
NAS_DB="$NAS_MOUNT/archive.db"
NAS_DATA="$NAS_MOUNT/data"
LOG_FILE="$HOME/.screenpipe/sync.log"
# ──────────────────────────────────────────────────────────────────────────────
# ─── HELPERS ──────────────────────────────────────────────────────────────────
SCRIPT_START=$(date +%s)
log() {
local msg="[$(date '+%Y-%m-%d %H:%M:%S')] $*"
echo "$msg" | tee -a "$LOG_FILE"
}
step() {
local now=$(date +%s)
local elapsed=$(( now - SCRIPT_START ))
local min=$(( elapsed / 60 ))
local sec=$(( elapsed % 60 ))
printf "\n[+%02dm%02ds] ▶ %s\n" "$min" "$sec" "$*" | tee -a "$LOG_FILE"
}
run_sqlite_heredoc() {
local label="$1"
local sql="$2"
local start=$(date +%s)
printf " %-36s " "$label"
sqlite3 "$DB_SRC" <<< "$sql" &
local pid=$!
local spin=[PASSWORD] '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')
local i=0
while kill -0 "$pid" 2>/dev/null; do
printf "\r %-36s %s " "$label" "${spin[$i]}"
i=$(( (i + 1) % 10 ))
sleep 0.2
done
wait "$pid"
local rc=$?
if [ $rc -ne 0 ]; then
printf "\r %-36s ✗ FAILED\n" "$label" | tee -a "$LOG_FILE"
exit $rc
fi
local dur=$(( $(date +%s) - start ))
printf "\r %-36s ✓ %dm%02ds\n" "$label" "$(( dur / 60 ))" "$(( dur % 60 ))" | tee -a "$LOG_FILE"
}
check() {
local label="$1" got="$2" expected="$3"
if [ "$got" -eq "$expected" ]; then
printf " %-20s %s / %s ✓\n" "$label:" "$got" "$expected"
else
printf " %-20s %s / %s ✗ MISMATCH\n" "$label:" "$got" "$expected"
fi
}
# ──────────────────────────────────────────────────────────────────────────────
# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────
if [ "${1:-}" = "today" ]; then
TARGET_DATE=$(date +%Y-%m-%d)
elif [ -n "${1:-}" ]; then
TARGET_DATE="$1"
if ! [[ "$TARGET_DATE" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then
echo "ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday."
exit 1
fi
else
TARGET_DATE=$(date -v-1d +%Y-%m-%d)
fi
log "========================================"
log "Screenpipe sync starting for: $TARGET_DATE"
log "========================================"
# ─── PREFLIGHT ────────────────────────────────────────────────────────────────
step "Preflight checks"
if [ ! -f "$DB_SRC" ]; then
log "ERROR: Source DB not found at $DB_SRC"; exit 1
fi
printf " %-20s %s (%s)\n" "Source DB:" "OK" "$(du -sh "$DB_SRC" | cut -f1)"
if [ ! -d "$NAS_MOUNT" ]; then
log "ERROR: NAS not mounted at $NAS_MOUNT"; exit 1
fi
printf " %-20s %s\n" "NAS mount:" "OK $NAS_MOUNT"
# Check if DB already synced for this date
DB_ALREADY_SYNCED=false
if [ -f "$NAS_DB" ]; then
EXISTING=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';" 2>/dev/null || echo "0")
if [ "$EXISTING" -gt "0" ]; then
log "Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync"
DB_ALREADY_SYNCED=true
else
printf " %-20s %s (%s)\n" "Archive DB:" "exists" "$(du -sh "$NAS_DB" | cut -f1)"
fi
else
printf " %-20s %s\n" "Archive DB:" "will be created"
fi
# Source data dir for this date
DATA_SRC="$HOME/.screenpipe/data/data/$TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
DATA_SIZE=$(du -sh "$DATA_SRC" | cut -f1)
DATA_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
printf " %-20s %s (%s files, %s)\n" "Data dir:" "OK" "$DATA_FILES" "$DATA_SIZE"
else
printf " %-20s %s\n" "Data dir:" "not found — skipping file copy"
fi
# ─── DB SYNC ──────────────────────────────────────────────────────────────────
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────
step "Counting source rows for $TARGET_DATE"
SRC_FRAMES=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
SRC_ELEMENTS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_UI=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
SRC_OCR=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_MEETINGS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';")
printf " %-20s %s\n" "frames:" "$SRC_FRAMES"
printf " %-20s %s\n" "elements:" "$SRC_ELEMENTS"
printf " %-20s %s\n" "ui_events:" "$SRC_UI"
printf " %-20s %s\n" "ocr_text:" "$SRC_OCR"
printf " %-20s %s\n" "meetings:" "$SRC_MEETINGS"
if [ "$SRC_FRAMES" -eq "0" ]; then
log "No frames found for $TARGET_DATE — skipping DB sync"
DB_ALREADY_SYNCED=true
fi
fi
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── INIT TABLES ──────────────────────────────────────────────────────────
step "Initialising tables, indexes, FTS"
run_sqlite_heredoc "creating tables" "
ATTACH '$NAS_DB' AS nas;
CREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;
CREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;
CREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;
CREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;
DETACH nas;
"
run_sqlite_heredoc "creating indexes" "
ATTACH '$NAS_DB' AS nas;
CREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);
CREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);
DETACH nas;
"
run_sqlite_heredoc "creating FTS tables" "
ATTACH '$NAS_DB' AS nas;
CREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(
text, role, frame_id UNINDEXED,
content='elements', content_rowid='id', tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(
full_text, app_name, window_name, browser_url, id UNINDEXED,
tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(
text_content,
app_name,
window_title,
element_name,
content='ui_events',
content_rowid='id',
tokenize='unicode61'
);
DETACH nas;
"
# ─── SYNC DATA ────────────────────────────────────────────────────────────
step "Syncing data for $TARGET_DATE"
run_sqlite_heredoc "video_chunks" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.video_chunks
SELECT * FROM main.video_chunks
WHERE id IN (
SELECT DISTINCT video_chunk_id FROM main.frames
WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL
);
DETACH nas;
"
run_sqlite_heredoc "frames ($SRC_FRAMES rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.frames
SELECT * FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ocr_text ($SRC_OCR rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ocr_text
SELECT o.* FROM main.ocr_text o
JOIN main.frames f ON o.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ui_events ($SRC_UI rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ui_events
SELECT * FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "elements ($SRC_ELEMENTS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.elements
SELECT e.* FROM main.elements e
JOIN main.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "meetings ($SRC_MEETINGS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.meetings
SELECT * FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';
DETACH nas;
"
# ─── FTS UPDATE ───────────────────────────────────────────────────────────
step "Updating FTS indexes"
run_sqlite_heredoc "elements_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.elements_fts(rowid, text, role)
SELECT e.id, e.text, e.role
FROM nas.elements e
JOIN nas.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE'
AND e.text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "frames_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)
SELECT id, full_text, app_name, window_name, browser_url, id
FROM nas.frames
WHERE date(timestamp) = '$TARGET_DATE'
AND full_text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "ui_events_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)
SELECT id, text_content, app_name, window_title, element_name
FROM nas.ui_events
WHERE date(timestamp) = '$TARGET_DATE'
AND text_content IS NOT NULL;
DETACH nas;
"
# ─── VERIFY DB ────────────────────────────────────────────────────────────
step "Verifying DB"
V_FRAMES=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
V_ELEMENTS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_UI=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
V_OCR=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_MEETINGS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';")
check "frames" "$V_FRAMES" "$SRC_FRAMES"
check "elements" "$V_ELEMENTS" "$SRC_ELEMENTS"
check "ui_events" "$V_UI" "$SRC_UI"
check "ocr_text" "$V_OCR" "$SRC_OCR"
check "meetings" "$V_MEETINGS" "$SRC_MEETINGS"
fi
# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────
# Always runs regardless of DB sync status
step "Copying data folder for $TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
mkdir -p "$NAS_DATA/$TARGET_DATE"
RSYNC_START=$(date +%s)
printf " %-36s " "rsync $TARGET_DATE/ → NAS"
rsync -a --ignore-existing \
"$DATA_SRC/" \
"$NAS_DATA/$TARGET_DATE/" \
2>>"$LOG_FILE"
RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))
COPIED_FILES=$(ls "$NAS_DATA/$TARGET_DATE" | wc -l | tr -d ' ')
SRC_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
COPIED_SIZE=$(du -sh "$NAS_DATA/$TARGET_DATE" | cut -f1)
if [ "$COPIED_FILES" -eq "$SRC_FILES" ]; then
printf "\r %-36s ✓ %dm%02ds (%s files, %s)\n" \
"rsync $TARGET_DATE/ → NAS" \
"$(( RSYNC_DUR / 60 ))" "$(( RSYNC_DUR % 60 ))" \
"$COPIED_FILES" "$COPIED_SIZE" | tee -a "$LOG_FILE"
else
printf "\r %-36s ✗ %s / %s files\n" \
"rsync $TARGET_DATE/ → NAS" "$COPIED_FILES" "$SRC_FILES" | tee -a "$LOG_FILE"
fi
else
printf " %-36s %s\n" "rsync $TARGET_DATE/ → NAS" "skipped (no source dir)"
fi
# ─── SUMMARY ──────────────────────────────────────────────────────────────────
TOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))
DB_SIZE=$(du -sh "$NAS_DB" | cut -f1)
echo ""
log "Archive DB size: $DB_SIZE"
log "Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s"
log "Sync complete for $TARGET_DATE"
log "========================================"
Implement and run pipe l…, Editor Group 2
Problems (⇧⌘M)
PROBLEMS
Output (⇧⌘U)
OUTPUT
Debug Console (⇧⌘Y)
DEBUG CONSOLE
Terminal (⌃`)
TERMINAL
Ports - 1 forwarded port
PORTS
1
remote SSH: nas
SSH: nas
screenpipe (Git) - master*, Checkout Branch/Tag...
master*
screenpipe (Git) - Synchronize Changes
No Problems
0
0
Forwarded Ports: 8766
1
Notifications
Sign In
Sign In
Shell Script
Editor Language Status: $(copilot) No inline suggestion available, Inline suggestions
LF
UTF-8
Spaces: 2
Ln 29, Col 35
git-commit Lukas Kovalik (2 weeks ago)
Lukas Kovalik (2 weeks ago)
No results found
Implement and run pipe logic
Session history
New session
Message actions
main.py
main.py
lets implement logic with pipes. how can I run it?
Thinking
Thinking
Let me look at the current project structure to understand what's already in place.
Bash
List project files
IN
find /volume1/screenpipe -type f | head -50 && echo "---" && ls /volume1/screenpipe
Copy code to clipboard
OUT
/volume1/screenpipe/.DS_Store
/volume1/screenpipe/screenpipe.db
/volume1/screenpipe/screenpipe_sync.sh
/volume1/screenpipe/app_settings.json
/volume1/screenpipe/.gitignore
/volume1/screenpipe/archive.db
/volume1/screenpipe/db.sqlite
/volume1/screenpipe/db.sqlite-wal
/volume1/screenpipe/db.sqlite-shm
/volume1/screenpipe/#recycle/desktop.ini
/volume1/screenpipe/#recycle/db.sqlite
/volume1/screenpipe/#recycle/Copy #1 of db.sqlite
/volume1/screenpipe/#recycle/.DS_Store
/volume1/screenpipe/#recycle/Copy #2 of db.sqlite
/volume1/screenpipe/#recycle/archive.db
/volume1/screenpipe/#recycle/Copy #1 of archive.db
/volume1/screenpipe/#recycle/Copy #2 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of archive.db
/volume1/screenpipe/#recycle/Copy #4 of archive.db
/volume1/screenpipe/#recycle/Copy #5 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of db.sqlite
/volume1/screenpipe/#recycle/Copy #4 of db.sqlite
/volume1/screenpipe/#recycle/Copy #6 of archive.db
/volume1/screenpipe/#recycle/test.txt
/volume1/screenpipe/#recycle/Copy #7 of archive.db
/volume1/screenpipe/#recycle/Copy #8 of archive.db
/volume1/screenpipe/#recycle/archive.db-journal
/volume1/screenpipe/#recycle/Copy #1 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #2 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #3 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #4 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #6 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #7 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of db.sqlite
/volume1/screenpipe/pipes/.DS_Store
/volume1/screenpipe/app/.env
/volume1/screenpipe/app/cli.py
/volume1/screenpipe/app/.DS_Store
/volume1/screenpipe/app/db.py
/volume1/screenpipe/app/docker-compose.yml
/volume1/screenpipe/app/main.py
/volume1/screenpipe/app/requirements.txt
/volume1/screenpipe/app/Dockerfile
/volume1/screenpipe/data/.DS_Store
/volume1/screenpipe/.git/description
/volume1/screenpipe/.git/HEAD
/volume1/screenpipe/.git/index
/volume1/screenpipe/.git/COMMIT_EDITMSG
/volume1/screenpipe/#recycle/data/.DS_Store
---
app
app_settings.json
archive.db
data
db.sqlite
db.sqlite-shm
db.sqlite-wal
pipes
#recycle
screenpipe.db
screenpipe_sync.sh
Read
main.py
main.py
Bash
Check pipes directory and docker-compose
IN
ls /volume1/screenpipe/pipes/ && ls /volume1/screenpipe/app/ && cat /volume1/screenpipe/app/docker-compose.yml
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
cli.py
consumers
db.py
docker-compose.yml
Dockerfile
main.py
__pycache__
requirements.txt
static
services:
screenpipe-app:
build: .
container_name: screenpipe-app
restart: unless-stopped
ports:
- "8766:8000"
volumes:
- /volume1/screenpipe:/data
env_file:
- .env
environment:
TZ: Europe/Sofia
DB_PATH: /data/db.sqlite
sqlite-web-archive:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-archive
restart: unless-stopped
ports:
- "8767:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/archive.db"]
sqlite-web-live:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-live
restart: unless-stopped
ports:
- "8768:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/db.sqlite"]
Read
requirements.txt
requirements.txt
Bash
Inspect a pipe directory
IN
ls /volume1/screenpipe/pipes/day-recap/ && cat /volume1/screenpipe/pipes/day-recap/pipe.json 2>/dev/null || ls /volume1/screenpipe/pipes/day-recap/
Copy code to clipboard
OUT
pipe.md
pipe.md
Read
cli.py
cli.py
Bash
List all pipes and their contents
IN
ls /volume1/screenpipe/pipes/ && for d in /volume1/screenpipe/pipes/*/; do echo "=== $d ==="; ls "$d"; done
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
=== /volume1/screenpipe/pipes/ai-habits/ ===
pipe.md
=== /volume1/screenpipe/pipes/day-recap/ ===
pipe.md
=== /volume1/screenpipe/pipes/meeting-summary/ ===
pipe.md
=== /volume1/screenpipe/pipes/standup-update/ ===
pipe.md
=== /volume1/screenpipe/pipes/time-breakdown/ ===
pipe.md
=== /volume1/screenpipe/pipes/video-export/ ===
pipe.md
Bash
Read pipe markdown files
IN
cat /volume1/screenpipe/pipes/day-recap/pipe.md && echo "===" && cat /volume1/screenpipe/pipes/meeting-summary/pipe.md 2>/dev/null | head -50
Copy code to clipboard
OUT
---
schedule: manual
enabled: true
template: true
title: Day Recap
description: "Today's accomplishments, key moments, and unfinished work"
icon: "📋"
featured: true
---
Analyze my screen and audio recordings from today (last 16 hours only).
Read screenpipe skill first.
Use this exact format:
## Summary
One sentence: what I mainly did today.
## Accomplishments
- Top 3 things I finished, with timestamps (e.g. "2:30 PM")
- Name specific apps, files, or projects
## Key Moments
- Important things I saw, said, or heard — with timestamps
## Unfinished Work
- What I should continue tomorrow — name the app/file/task
## Patterns
- Apps I used most, topics that came up repeatedly
Only report what you can verify from the data. End with: "**Next step:** [most important thing to continue]"
===
---
schedule: manual
enabled: true
template: true
title: Meeting Summary
description: "Summarize meeting transcript with key takeaways and action items"
icon: "🤝"
featured: false
---
Summarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.
Read screenpipe skill first.
Use this exact format:
## Meeting Summary
One sentence: what this meeting was about.
## Key Takeaways
- Top 3-5 important points discussed
- Include who said what when relevant
## Action Items
- [ ] Task — assigned to whom, deadline if mentioned
- [ ] Task — assigned to whom
## Decisions Made
- List any decisions or agreements reached
## Open Questions
- Anything unresolved or needing follow-up
Keep it concise and actionable.
Thinking
Thinking
Bash
Read summary consumer
IN
ls /volume1/screenpipe/app/consumers/ && cat /volume1/screenpipe/app/consumers/summary.py
Copy code to clipboard
OUT
activity.py
audio.py
elements.py
__init__.py
interactions.py
ocr.py
__pycache__
report.py
summary.py
"""AI summary generator using Claude."""
import os
from datetime import date
from typing import Any
from consumers.activity import app_time, summary_stats, browser_urls, ui_event_summary
from consumers.ocr import deduplicated_text
from consumers.audio import formatted_transcript
SUMMARY_TYPES = {
"day_recap": {
"title": "Day Recap",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
## Audio/speech:
{audio}
Write a concise day recap using EXACTLY this format:
## Summary
One sentence: what I mainly worked on today.
## Accomplishments
- Top 3 things I finished, with approximate times
- Name specific apps, files, or projects
## Key Moments
- Important things seen or heard, with timestamps
## Unfinished Work
- What to continue tomorrow
## Patterns
- Apps used most, topics that came up repeatedly
Only report what you can verify from the data. End with:
**Next step:** [most important thing to continue]""",
},
"standup": {
"title": "Standup Update",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
## Audio/speech:
{audio}
Write a brief standup update:
**Yesterday:** What I worked on (2-3 bullets)
**Today:** What I plan to continue (1-2 bullets)
**Blockers:** Any issues observed (or "None")
Keep it under 150 words. Only report what's verifiable from the data.""",
},
"focus_time": {
"title": "Focus & Distraction Analysis",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
Analyze focus vs distraction patterns:
## Deep Work Periods
- When and how long were sustained focus sessions?
- What was being worked on?
## Distractions
- Which apps/sites were used recreationally?
- How much time was lost to context switching?
## Recommendations
- 2-3 concrete suggestions to improve focus tomorrow
Be specific with times and app names.""",
},
}
def _build_context(for_date: date) -> dict[str, str]:
apps = app_time(for_date)
app_lines = "\n".join(f"- {a['app_name']}: {a['minutes']} min" for a in apps[:20])
urls = browser_urls(for_date, limit=20)
url_lines = "\n".join(
f"- {u['browser_url'][:100]} ({u['minutes']} min)" for u in urls
)
ui_rows = ui_event_summary(for_date)
ui_lines = "\n".join(
f"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches"
for r in ui_rows[:15]
)
ocr_rows = deduplicated_text(for_date, chunk_minutes=5)
ocr_lines = "\n".join(
f"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}"
for r in ocr_rows[:100]
)
audio = formatted_transcript(for_date)
return {
"app_time": app_lines or "(no app data)",
"browser_urls": url_lines or "(no browser data)",
"ui_events": ui_lines or "(no UI event data)",
"ocr_text": ocr_lines or "(no screen data)",
"audio": audio[:3000] if len(audio) > 3000 else audio,
}
def generate(
summary_type: str = "day_recap",
for_date: date | None = None,
api_key: str | None = None,
) -> dict[str, Any]:
"""Generate an AI summary. Returns dict with 'title', 'content', 'date'."""
import anthropic
d = for_date or date.today()
key = api_key or os.environ.get("ANTHROPIC_API_KEY", "")
if not key:
return {
"title": "Error",
"content": "ANTHROPIC_API_KEY not set. Add it to your .env file.",
"date": str(d),
}
spec = SUMMARY_TYPES.get(summary_type)
if not spec:
return {"title": "Error", "content": f"Unknown summary type: {summary_type}", "date": str(d)}
stats = summary_stats(d)
if stats["total_frames"] == 0:
return {
"title": spec["title"],
"content": f"No screen data found for {d}.",
"date": str(d),
}
ctx = _build_context(d)
prompt = spec["prompt"].format(**ctx)
client = anthropic.Anthropic(api_key=key)
message = client.messages.create(
model="claude-haiku-4-5-20251001",
max_tokens=1024,
messages=[{"role": "user", "content": prompt}],
)
return {
"title": spec["title"],
"content": message.content[0].text,
"date": str(d),
"stats": stats,
}
Thinking
Thinking
Bash
Read all pipe.md files
IN
for f in /volume1/screenpipe/pipes/*/pipe.md; do echo "=== $f ==="; cat "$f"; echo; done
Copy code to clipboard
OUT
=== /volume1/screenpipe/pipes/ai-habits/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: AI Habits
description: "How you use AI tools — patterns and insights"
icon: "🤖"
featured: true
---
Search my recordings from the last 24 hours for AI tool usage. Use app_name filter for each tool separately: ChatGPT, Claude, Copilot, Cursor, Gemini, Perplexity. Use limit=5 per search, max 6 searches total.
Read screenpipe skill first.
Use this exact format:
## AI Tools Used
- List each tool with approximate time spent (e.g. "Claude: ~45min")
## What I Used Them For
- For each tool: coding, writing, research, or brainstorming
## Usage Patterns
- Do I switch between tools? Use them in bursts or steadily?
## Effectiveness
- Which tool appeared alongside completed work vs. abandoned attempts
If no AI usage is found, say so clearly. End with: "**Tip:** [one suggestion to use AI tools more effectively]"
=== /volume1/screenpipe/pipes/day-recap/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Day Recap
description: "Today's accomplishments, key moments, and unfinished work"
icon: "📋"
featured: true
---
Analyze my screen and audio recordings from today (last 16 hours only).
Read screenpipe skill first.
Use this exact format:
## Summary
One sentence: what I mainly did today.
## Accomplishments
- Top 3 things I finished, with timestamps (e.g. "2:30 PM")
- Name specific apps, files, or projects
## Key Moments
- Important things I saw, said, or heard — with timestamps
## Unfinished Work
- What I should continue tomorrow — name the app/file/task
## Patterns
- Apps I used most, topics that came up repeatedly
Only report what you can verify from the data. End with: "**Next step:** [most important thing to continue]"
=== /volume1/screenpipe/pipes/meeting-summary/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Meeting Summary
description: "Summarize meeting transcript with key takeaways and action items"
icon: "🤝"
featured: false
---
Summarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.
Read screenpipe skill first.
Use this exact format:
## Meeting Summary
One sentence: what this meeting was about.
## Key Takeaways
- Top 3-5 important points discussed
- Include who said what when relevant
## Action Items
- [ ] Task — assigned to whom, deadline if mentioned
- [ ] Task — assigned to whom
## Decisions Made
- List any decisions or agreements reached
## Open Questions
- Anything unresolved or needing follow-up
Keep it concise and actionable.
=== /volume1/screenpipe/pipes/standup-update/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Standup Update
description: "What you did, what's next, and any blockers"
icon: "🏢"
featured: true
---
Based on my recordings from the last 24 hours, generate a standup update. Use limit=10 per search, max 3 searches total.
Read screenpipe skill first.
Use this exact format:
## Yesterday
- What I worked on (name specific projects, files, tools, PRs)
## Today
- What I will work on next (based on unfinished tasks and recent activity)
## Blockers
- Issues I hit — errors, slow builds, waiting on someone
- If no blockers, write "None"
Keep it under 150 words. Copy-paste ready for a team standup.
=== /volume1/screenpipe/pipes/time-breakdown/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Time Breakdown
description: "Where your time went — by app, project, and category"
icon: "⏱"
featured: false
---
Analyze my app usage from today (last 12 hours). Use limit=10 per search, max 4 searches. Prefer /raw_sql with COUNT/GROUP BY queries.
Read screenpipe skill first.
Use this exact format with durations and percentages:
## By Application
- List each app with duration and percentage, sorted by time (e.g. "VS Code: 2h 15min (28%)")
## By Category
- Group into: coding, meetings, browsing, writing, communication, other
- Show hours and percentage per category
## By Project
- Group related activities by project/topic. Name specific repos or tasks.
## Productivity Score
- Calculate: focused_work_hours / total_hours as a percentage
- Focused = coding + writing. Unfocused = browsing + switching.
End with: "**Suggestion:** [one specific change to improve tomorrow's productivity]"
=== /volume1/screenpipe/pipes/video-export/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Export Video Clip
description: "Create a video of your recent screen activity"
icon: "🎬"
featured: false
---
Export a video of my screen activity from the last 5 minutes.
Read screenpipe skill first.
Use the POST /frames/export endpoint with the time range and fps=1.0. Then show me the exported video file path as an inline code block so I can watch it.
If the export is large, suggest a lower fps or shorter time range.
Thinking
Thinking
Now I have a clear picture. The pipes are markdown prompt templates in
/volume1/screenpipe/pipes/
, but there's no code to actually load and run them —
consumers/summary.py
has its own hardcoded prompts instead.
Here's what I'll implement:
consumers/pipes.py
— dynamically loads pipe.md files and runs them via Claude (data injected as system message, pipe body as user prompt)
main.py
— two new endpoints:
GET /api/pipes
and
POST /api/pipes/{pipe_id}/run
cli.py
— a
pipe
command to run pipes from the terminal...
|
21101
|
NULL
|
NULL
|
NULL
|
|
21103
|
923
|
12
|
2026-05-11T17:12:18.681516+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-11/1778 /Users/lukas/.screenpipe/data/data/2026-05-11/1778519538681_m2.jpg...
|
Code
|
screenpipe_sync.sh — screenpipe [SSH: nas]
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧ Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py
M
db.py
docker-compose.yml
Dockerfile
M
main.py
M
requirements.txt
M
data
logs
pipes
.gitignore
app_settings.json
archive.db
archive.db-bak
U
db.sqlite
db.sqlite-shm
db.sqlite-wal
screenpipe_sync_updated.sh
U
screenpipe_sync.sh
screenpipe.db
Outline Section
OUTLINE
OUTLINE
Timeline Section
TIMELINE
TIMELINE
app_settings.json, Editor Group 1
screenpipe_sync.sh, Editor Group 1
pipe.md, Editor Group 1
.env, Editor Group 1
#!/bin/bash
# screenpipe_sync.sh
# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).
# Also copies the day's video/frame data folder to the NAS.
#
# Usage:
# ./screenpipe_sync.sh # syncs yesterday (default)
# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date
# ./screenpipe_sync.sh today # syncs today so far
#
# Cron example (runs at 3am daily):
# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1
set -euo pipefail
# ─── CONFIG ───────────────────────────────────────────────────────────────────
DB_SRC="${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}"
NAS_MOUNT="${NAS_MOUNT:-/Volumes/Test/screenpipe}"
NAS_DB="$NAS_MOUNT/archive.db"
NAS_DATA="$NAS_MOUNT/data"
LOG_FILE="$HOME/.screenpipe/sync.log"
# ──────────────────────────────────────────────────────────────────────────────
# ─── HELPERS ──────────────────────────────────────────────────────────────────
SCRIPT_START=$(date +%s)
log() {
local msg="[$(date '+%Y-%m-%d %H:%M:%S')] $*"
echo "$msg" | tee -a "$LOG_FILE"
}
step() {
local now=$(date +%s)
local elapsed=$(( now - SCRIPT_START ))
local min=$(( elapsed / 60 ))
local sec=$(( elapsed % 60 ))
printf "\n[+%02dm%02ds] ▶ %s\n" "$min" "$sec" "$*" | tee -a "$LOG_FILE"
}
run_sqlite_heredoc() {
local label="$1"
local sql="$2"
local start=$(date +%s)
printf " %-36s " "$label"
sqlite3 "$DB_SRC" <<< "$sql" &
local pid=$!
local spin=[PASSWORD] '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')
local i=0
while kill -0 "$pid" 2>/dev/null; do
printf "\r %-36s %s " "$label" "${spin[$i]}"
i=$(( (i + 1) % 10 ))
sleep 0.2
done
wait "$pid"
local rc=$?
if [ $rc -ne 0 ]; then
printf "\r %-36s ✗ FAILED\n" "$label" | tee -a "$LOG_FILE"
exit $rc
fi
local dur=$(( $(date +%s) - start ))
printf "\r %-36s ✓ %dm%02ds\n" "$label" "$(( dur / 60 ))" "$(( dur % 60 ))" | tee -a "$LOG_FILE"
}
check() {
local label="$1" got="$2" expected="$3"
if [ "$got" -eq "$expected" ]; then
printf " %-20s %s / %s ✓\n" "$label:" "$got" "$expected"
else
printf " %-20s %s / %s ✗ MISMATCH\n" "$label:" "$got" "$expected"
fi
}
# ──────────────────────────────────────────────────────────────────────────────
# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────
if [ "${1:-}" = "today" ]; then
TARGET_DATE=$(date +%Y-%m-%d)
elif [ -n "${1:-}" ]; then
TARGET_DATE="$1"
if ! [[ "$TARGET_DATE" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then
echo "ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday."
exit 1
fi
else
TARGET_DATE=$(date -v-1d +%Y-%m-%d)
fi
log "========================================"
log "Screenpipe sync starting for: $TARGET_DATE"
log "========================================"
# ─── PREFLIGHT ────────────────────────────────────────────────────────────────
step "Preflight checks"
if [ ! -f "$DB_SRC" ]; then
log "ERROR: Source DB not found at $DB_SRC"; exit 1
fi
printf " %-20s %s (%s)\n" "Source DB:" "OK" "$(du -sh "$DB_SRC" | cut -f1)"
if [ ! -d "$NAS_MOUNT" ]; then
log "ERROR: NAS not mounted at $NAS_MOUNT"; exit 1
fi
printf " %-20s %s\n" "NAS mount:" "OK $NAS_MOUNT"
# Check if DB already synced for this date
DB_ALREADY_SYNCED=false
if [ -f "$NAS_DB" ]; then
EXISTING=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';" 2>/dev/null || echo "0")
if [ "$EXISTING" -gt "0" ]; then
log "Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync"
DB_ALREADY_SYNCED=true
else
printf " %-20s %s (%s)\n" "Archive DB:" "exists" "$(du -sh "$NAS_DB" | cut -f1)"
fi
else
printf " %-20s %s\n" "Archive DB:" "will be created"
fi
# Source data dir for this date
DATA_SRC="$HOME/.screenpipe/data/data/$TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
DATA_SIZE=$(du -sh "$DATA_SRC" | cut -f1)
DATA_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
printf " %-20s %s (%s files, %s)\n" "Data dir:" "OK" "$DATA_FILES" "$DATA_SIZE"
else
printf " %-20s %s\n" "Data dir:" "not found — skipping file copy"
fi
# ─── DB SYNC ──────────────────────────────────────────────────────────────────
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────
step "Counting source rows for $TARGET_DATE"
SRC_FRAMES=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
SRC_ELEMENTS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_UI=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
SRC_OCR=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_MEETINGS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';")
printf " %-20s %s\n" "frames:" "$SRC_FRAMES"
printf " %-20s %s\n" "elements:" "$SRC_ELEMENTS"
printf " %-20s %s\n" "ui_events:" "$SRC_UI"
printf " %-20s %s\n" "ocr_text:" "$SRC_OCR"
printf " %-20s %s\n" "meetings:" "$SRC_MEETINGS"
if [ "$SRC_FRAMES" -eq "0" ]; then
log "No frames found for $TARGET_DATE — skipping DB sync"
DB_ALREADY_SYNCED=true
fi
fi
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── INIT TABLES ──────────────────────────────────────────────────────────
step "Initialising tables, indexes, FTS"
run_sqlite_heredoc "creating tables" "
ATTACH '$NAS_DB' AS nas;
CREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;
CREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;
CREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;
CREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;
DETACH nas;
"
run_sqlite_heredoc "creating indexes" "
ATTACH '$NAS_DB' AS nas;
CREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);
CREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);
DETACH nas;
"
run_sqlite_heredoc "creating FTS tables" "
ATTACH '$NAS_DB' AS nas;
CREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(
text, role, frame_id UNINDEXED,
content='elements', content_rowid='id', tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(
full_text, app_name, window_name, browser_url, id UNINDEXED,
tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(
text_content,
app_name,
window_title,
element_name,
content='ui_events',
content_rowid='id',
tokenize='unicode61'
);
DETACH nas;
"
# ─── SYNC DATA ────────────────────────────────────────────────────────────
step "Syncing data for $TARGET_DATE"
run_sqlite_heredoc "video_chunks" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.video_chunks
SELECT * FROM main.video_chunks
WHERE id IN (
SELECT DISTINCT video_chunk_id FROM main.frames
WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL
);
DETACH nas;
"
run_sqlite_heredoc "frames ($SRC_FRAMES rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.frames
SELECT * FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ocr_text ($SRC_OCR rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ocr_text
SELECT o.* FROM main.ocr_text o
JOIN main.frames f ON o.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ui_events ($SRC_UI rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ui_events
SELECT * FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "elements ($SRC_ELEMENTS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.elements
SELECT e.* FROM main.elements e
JOIN main.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "meetings ($SRC_MEETINGS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.meetings
SELECT * FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';
DETACH nas;
"
# ─── FTS UPDATE ───────────────────────────────────────────────────────────
step "Updating FTS indexes"
run_sqlite_heredoc "elements_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.elements_fts(rowid, text, role)
SELECT e.id, e.text, e.role
FROM nas.elements e
JOIN nas.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE'
AND e.text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "frames_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)
SELECT id, full_text, app_name, window_name, browser_url, id
FROM nas.frames
WHERE date(timestamp) = '$TARGET_DATE'
AND full_text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "ui_events_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)
SELECT id, text_content, app_name, window_title, element_name
FROM nas.ui_events
WHERE date(timestamp) = '$TARGET_DATE'
AND text_content IS NOT NULL;
DETACH nas;
"
# ─── VERIFY DB ────────────────────────────────────────────────────────────
step "Verifying DB"
V_FRAMES=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
V_ELEMENTS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_UI=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
V_OCR=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_MEETINGS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';")
check "frames" "$V_FRAMES" "$SRC_FRAMES"
check "elements" "$V_ELEMENTS" "$SRC_ELEMENTS"
check "ui_events" "$V_UI" "$SRC_UI"
check "ocr_text" "$V_OCR" "$SRC_OCR"
check "meetings" "$V_MEETINGS" "$SRC_MEETINGS"
fi
# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────
# Always runs regardless of DB sync status
step "Copying data folder for $TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
mkdir -p "$NAS_DATA/$TARGET_DATE"
RSYNC_START=$(date +%s)
printf " %-36s " "rsync $TARGET_DATE/ → NAS"
rsync -a --ignore-existing \
"$DATA_SRC/" \
"$NAS_DATA/$TARGET_DATE/" \
2>>"$LOG_FILE"
RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))
COPIED_FILES=$(ls "$NAS_DATA/$TARGET_DATE" | wc -l | tr -d ' ')
SRC_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
COPIED_SIZE=$(du -sh "$NAS_DATA/$TARGET_DATE" | cut -f1)
if [ "$COPIED_FILES" -eq "$SRC_FILES" ]; then
printf "\r %-36s ✓ %dm%02ds (%s files, %s)\n" \
"rsync $TARGET_DATE/ → NAS" \
"$(( RSYNC_DUR / 60 ))" "$(( RSYNC_DUR % 60 ))" \
"$COPIED_FILES" "$COPIED_SIZE" | tee -a "$LOG_FILE"
else
printf "\r %-36s ✗ %s / %s files\n" \
"rsync $TARGET_DATE/ → NAS" "$COPIED_FILES" "$SRC_FILES" | tee -a "$LOG_FILE"
fi
else
printf " %-36s %s\n" "rsync $TARGET_DATE/ → NAS" "skipped (no source dir)"
fi
# ─── SUMMARY ──────────────────────────────────────────────────────────────────
TOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))
DB_SIZE=$(du -sh "$NAS_DB" | cut -f1)
echo ""
log "Archive DB size: $DB_SIZE"
log "Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s"
log "Sync complete for $TARGET_DATE"
log "========================================"
#!/bin/bash
# screenpipe_sync.sh
# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).
# Also copies the day's video/frame data folder to the NAS.
#
# Usage:
# ./screenpipe_sync.sh # syncs yesterday (default)
# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date
# ./screenpipe_sync.sh today # syncs today so far
#
# Cron example (runs at 3am daily):
# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1
set -euo pipefail
# ─── CONFIG ───────────────────────────────────────────────────────────────────
DB_SRC="${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}"
NAS_MOUNT="${NAS_MOUNT:-/Volumes/Test/screenpipe}"
NAS_DB="$NAS_MOUNT/archive.db"
NAS_DATA="$NAS_MOUNT/data"
LOG_FILE="$HOME/.screenpipe/sync.log"
# ──────────────────────────────────────────────────────────────────────────────
# ─── HELPERS ──────────────────────────────────────────────────────────────────
SCRIPT_START=$(date +%s)
log() {
local msg="[$(date '+%Y-%m-%d %H:%M:%S')] $*"
echo "$msg" | tee -a "$LOG_FILE"
}
step() {
local now=$(date +%s)
local elapsed=$(( now - SCRIPT_START ))
local min=$(( elapsed / 60 ))
local sec=$(( elapsed % 60 ))
printf "\n[+%02dm%02ds] ▶ %s\n" "$min" "$sec" "$*" | tee -a "$LOG_FILE"
}
run_sqlite_heredoc() {
local label="$1"
local sql="$2"
local start=$(date +%s)
printf " %-36s " "$label"
sqlite3 "$DB_SRC" <<< "$sql" &
local pid=$!
local spin=[PASSWORD] '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')
local i=0
while kill -0 "$pid" 2>/dev/null; do
printf "\r %-36s %s " "$label" "${spin[$i]}"
i=$(( (i + 1) % 10 ))
sleep 0.2
done
wait "$pid"
local rc=$?
if [ $rc -ne 0 ]; then
printf "\r %-36s ✗ FAILED\n" "$label" | tee -a "$LOG_FILE"
exit $rc
fi
local dur=$(( $(date +%s) - start ))
printf "\r %-36s ✓ %dm%02ds\n" "$label" "$(( dur / 60 ))" "$(( dur % 60 ))" | tee -a "$LOG_FILE"
}
check() {
local label="$1" got="$2" expected="$3"
if [ "$got" -eq "$expected" ]; then
printf " %-20s %s / %s ✓\n" "$label:" "$got" "$expected"
else
printf " %-20s %s / %s ✗ MISMATCH\n" "$label:" "$got" "$expected"
fi
}
# ──────────────────────────────────────────────────────────────────────────────
# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────
if [ "${1:-}" = "today" ]; then
TARGET_DATE=$(date +%Y-%m-%d)
elif [ -n "${1:-}" ]; then
TARGET_DATE="$1"
if ! [[ "$TARGET_DATE" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then
echo "ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday."
exit 1
fi
else
TARGET_DATE=$(date -v-1d +%Y-%m-%d)
fi
log "========================================"
log "Screenpipe sync starting for: $TARGET_DATE"
log "========================================"
# ─── PREFLIGHT ────────────────────────────────────────────────────────────────
step "Preflight checks"
if [ ! -f "$DB_SRC" ]; then
log "ERROR: Source DB not found at $DB_SRC"; exit 1
fi
printf " %-20s %s (%s)\n" "Source DB:" "OK" "$(du -sh "$DB_SRC" | cut -f1)"
if [ ! -d "$NAS_MOUNT" ]; then
log "ERROR: NAS not mounted at $NAS_MOUNT"; exit 1
fi
printf " %-20s %s\n" "NAS mount:" "OK $NAS_MOUNT"
# Check if DB already synced for this date
DB_ALREADY_SYNCED=false
if [ -f "$NAS_DB" ]; then
EXISTING=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';" 2>/dev/null || echo "0")
if [ "$EXISTING" -gt "0" ]; then
log "Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync"
DB_ALREADY_SYNCED=true
else
printf " %-20s %s (%s)\n" "Archive DB:" "exists" "$(du -sh "$NAS_DB" | cut -f1)"
fi
else
printf " %-20s %s\n" "Archive DB:" "will be created"
fi
# Source data dir for this date
DATA_SRC="$HOME/.screenpipe/data/data/$TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
DATA_SIZE=$(du -sh "$DATA_SRC" | cut -f1)
DATA_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
printf " %-20s %s (%s files, %s)\n" "Data dir:" "OK" "$DATA_FILES" "$DATA_SIZE"
else
printf " %-20s %s\n" "Data dir:" "not found — skipping file copy"
fi
# ─── DB SYNC ──────────────────────────────────────────────────────────────────
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────
step "Counting source rows for $TARGET_DATE"
SRC_FRAMES=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
SRC_ELEMENTS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_UI=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
SRC_OCR=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_MEETINGS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';")
printf " %-20s %s\n" "frames:" "$SRC_FRAMES"
printf " %-20s %s\n" "elements:" "$SRC_ELEMENTS"
printf " %-20s %s\n" "ui_events:" "$SRC_UI"
printf " %-20s %s\n" "ocr_text:" "$SRC_OCR"
printf " %-20s %s\n" "meetings:" "$SRC_MEETINGS"
if [ "$SRC_FRAMES" -eq "0" ]; then
log "No frames found for $TARGET_DATE — skipping DB sync"
DB_ALREADY_SYNCED=true
fi
fi
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── INIT TABLES ──────────────────────────────────────────────────────────
step "Initialising tables, indexes, FTS"
run_sqlite_heredoc "creating tables" "
ATTACH '$NAS_DB' AS nas;
CREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;
CREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;
CREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;
CREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;
DETACH nas;
"
run_sqlite_heredoc "creating indexes" "
ATTACH '$NAS_DB' AS nas;
CREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);
CREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);
DETACH nas;
"
run_sqlite_heredoc "creating FTS tables" "
ATTACH '$NAS_DB' AS nas;
CREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(
text, role, frame_id UNINDEXED,
content='elements', content_rowid='id', tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(
full_text, app_name, window_name, browser_url, id UNINDEXED,
tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(
text_content,
app_name,
window_title,
element_name,
content='ui_events',
content_rowid='id',
tokenize='unicode61'
);
DETACH nas;
"
# ─── SYNC DATA ────────────────────────────────────────────────────────────
step "Syncing data for $TARGET_DATE"
run_sqlite_heredoc "video_chunks" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.video_chunks
SELECT * FROM main.video_chunks
WHERE id IN (
SELECT DISTINCT video_chunk_id FROM main.frames
WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL
);
DETACH nas;
"
run_sqlite_heredoc "frames ($SRC_FRAMES rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.frames
SELECT * FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ocr_text ($SRC_OCR rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ocr_text
SELECT o.* FROM main.ocr_text o
JOIN main.frames f ON o.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ui_events ($SRC_UI rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ui_events
SELECT * FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "elements ($SRC_ELEMENTS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.elements
SELECT e.* FROM main.elements e
JOIN main.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "meetings ($SRC_MEETINGS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.meetings
SELECT * FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';
DETACH nas;
"
# ─── FTS UPDATE ───────────────────────────────────────────────────────────
step "Updating FTS indexes"
run_sqlite_heredoc "elements_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.elements_fts(rowid, text, role)
SELECT e.id, e.text, e.role
FROM nas.elements e
JOIN nas.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE'
AND e.text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "frames_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)
SELECT id, full_text, app_name, window_name, browser_url, id
FROM nas.frames
WHERE date(timestamp) = '$TARGET_DATE'
AND full_text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "ui_events_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)
SELECT id, text_content, app_name, window_title, element_name
FROM nas.ui_events
WHERE date(timestamp) = '$TARGET_DATE'
AND text_content IS NOT NULL;
DETACH nas;
"
# ─── VERIFY DB ────────────────────────────────────────────────────────────
step "Verifying DB"
V_FRAMES=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
V_ELEMENTS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_UI=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
V_OCR=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_MEETINGS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';")
check "frames" "$V_FRAMES" "$SRC_FRAMES"
check "elements" "$V_ELEMENTS" "$SRC_ELEMENTS"
check "ui_events" "$V_UI" "$SRC_UI"
check "ocr_text" "$V_OCR" "$SRC_OCR"
check "meetings" "$V_MEETINGS" "$SRC_MEETINGS"
fi
# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────
# Always runs regardless of DB sync status
step "Copying data folder for $TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
mkdir -p "$NAS_DATA/$TARGET_DATE"
RSYNC_START=$(date +%s)
printf " %-36s " "rsync $TARGET_DATE/ → NAS"
rsync -a --ignore-existing \
"$DATA_SRC/" \
"$NAS_DATA/$TARGET_DATE/" \
2>>"$LOG_FILE"
RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))
COPIED_FILES=$(ls "$NAS_DATA/$TARGET_DATE" | wc -l | tr -d ' ')
SRC_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
COPIED_SIZE=$(du -sh "$NAS_DATA/$TARGET_DATE" | cut -f1)
if [ "$COPIED_FILES" -eq "$SRC_FILES" ]; then
printf "\r %-36s ✓ %dm%02ds (%s files, %s)\n" \
"rsync $TARGET_DATE/ → NAS" \
"$(( RSYNC_DUR / 60 ))" "$(( RSYNC_DUR % 60 ))" \
"$COPIED_FILES" "$COPIED_SIZE" | tee -a "$LOG_FILE"
else
printf "\r %-36s ✗ %s / %s files\n" \
"rsync $TARGET_DATE/ → NAS" "$COPIED_FILES" "$SRC_FILES" | tee -a "$LOG_FILE"
fi
else
printf " %-36s %s\n" "rsync $TARGET_DATE/ → NAS" "skipped (no source dir)"
fi
# ─── SUMMARY ──────────────────────────────────────────────────────────────────
TOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))
DB_SIZE=$(du -sh "$NAS_DB" | cut -f1)
echo ""
log "Archive DB size: $DB_SIZE"
log "Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s"
log "Sync complete for $TARGET_DATE"
log "========================================"
Implement and run pipe l…, Editor Group 2
Problems (⇧⌘M)
PROBLEMS
Output (⇧⌘U)
OUTPUT
Debug Console (⇧⌘Y)
DEBUG CONSOLE
Terminal (⌃`)
TERMINAL
Ports - 1 forwarded port
PORTS
1
remote SSH: nas
SSH: nas
screenpipe (Git) - master*, Checkout Branch/Tag...
master*
screenpipe (Git) - Synchronize Changes
No Problems
0
0
Forwarded Ports: 8766
1
Notifications
Sign In
Sign In
Shell Script
Editor Language Status: Inline Suggestions, next: $(copilot) No inline suggestion available, Inline suggestions
LF
UTF-8
Spaces: 2
Ln 352, Col 47 (13096 selected)
git-commit Lukas Kovalik (2 weeks ago)
Lukas Kovalik (2 weeks ago)
No results found
Implement and run pipe logic
Session history
New session
Message actions
main.py
main.py
lets implement logic with pipes. how can I run it?
Thinking
Thinking
Let me look at the current project structure to understand what's already in place.
Bash
List project files
IN
find /volume1/screenpipe -type f | head -50 && echo "---" && ls /volume1/screenpipe
Copy code to clipboard
OUT
/volume1/screenpipe/.DS_Store
/volume1/screenpipe/screenpipe.db
/volume1/screenpipe/screenpipe_sync.sh
/volume1/screenpipe/app_settings.json
/volume1/screenpipe/.gitignore
/volume1/screenpipe/archive.db
/volume1/screenpipe/db.sqlite
/volume1/screenpipe/db.sqlite-wal
/volume1/screenpipe/db.sqlite-shm
/volume1/screenpipe/#recycle/desktop.ini
/volume1/screenpipe/#recycle/db.sqlite
/volume1/screenpipe/#recycle/Copy #1 of db.sqlite
/volume1/screenpipe/#recycle/.DS_Store
/volume1/screenpipe/#recycle/Copy #2 of db.sqlite
/volume1/screenpipe/#recycle/archive.db
/volume1/screenpipe/#recycle/Copy #1 of archive.db
/volume1/screenpipe/#recycle/Copy #2 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of archive.db
/volume1/screenpipe/#recycle/Copy #4 of archive.db
/volume1/screenpipe/#recycle/Copy #5 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of db.sqlite
/volume1/screenpipe/#recycle/Copy #4 of db.sqlite
/volume1/screenpipe/#recycle/Copy #6 of archive.db
/volume1/screenpipe/#recycle/test.txt
/volume1/screenpipe/#recycle/Copy #7 of archive.db
/volume1/screenpipe/#recycle/Copy #8 of archive.db
/volume1/screenpipe/#recycle/archive.db-journal
/volume1/screenpipe/#recycle/Copy #1 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #2 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #3 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #4 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #6 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #7 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of db.sqlite
/volume1/screenpipe/pipes/.DS_Store
/volume1/screenpipe/app/.env
/volume1/screenpipe/app/cli.py
/volume1/screenpipe/app/.DS_Store
/volume1/screenpipe/app/db.py
/volume1/screenpipe/app/docker-compose.yml
/volume1/screenpipe/app/main.py
/volume1/screenpipe/app/requirements.txt
/volume1/screenpipe/app/Dockerfile
/volume1/screenpipe/data/.DS_Store
/volume1/screenpipe/.git/description
/volume1/screenpipe/.git/HEAD
/volume1/screenpipe/.git/index
/volume1/screenpipe/.git/COMMIT_EDITMSG
/volume1/screenpipe/#recycle/data/.DS_Store
---
app
app_settings.json
archive.db
data
db.sqlite
db.sqlite-shm
db.sqlite-wal
pipes
#recycle
screenpipe.db
screenpipe_sync.sh
Read
main.py
main.py
Bash
Check pipes directory and docker-compose
IN
ls /volume1/screenpipe/pipes/ && ls /volume1/screenpipe/app/ && cat /volume1/screenpipe/app/docker-compose.yml
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
cli.py
consumers
db.py
docker-compose.yml
Dockerfile
main.py
__pycache__
requirements.txt
static
services:
screenpipe-app:
build: .
container_name: screenpipe-app
restart: unless-stopped
ports:
- "8766:8000"
volumes:
- /volume1/screenpipe:/data
env_file:
- .env
environment:
TZ: Europe/Sofia
DB_PATH: /data/db.sqlite
sqlite-web-archive:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-archive
restart: unless-stopped
ports:
- "8767:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/archive.db"]
sqlite-web-live:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-live
restart: unless-stopped
ports:
- "8768:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/db.sqlite"]
Read
requirements.txt
requirements.txt
Bash
Inspect a pipe directory
IN
ls /volume1/screenpipe/pipes/day-recap/ && cat /volume1/screenpipe/pipes/day-recap/pipe.json 2>/dev/null || ls /volume1/screenpipe/pipes/day-recap/
Copy code to clipboard
OUT
pipe.md
pipe.md
Read
cli.py
cli.py
Bash
List all pipes and their contents
IN
ls /volume1/screenpipe/pipes/ && for d in /volume1/screenpipe/pipes/*/; do echo "=== $d ==="; ls "$d"; done
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
=== /volume1/screenpipe/pipes/ai-habits/ ===
pipe.md
=== /volume1/screenpipe/pipes/day-recap/ ===
pipe.md
=== /volume1/screenpipe/pipes/meeting-summary/ ===
pipe.md
=== /volume1/screenpipe/pipes/standup-update/ ===
pipe.md
=== /volume1/screenpipe/pipes/time-breakdown/ ===
pipe.md
=== /volume1/screenpipe/pipes/video-export/ ===
pipe.md
Bash
Read pipe markdown files
IN
cat /volume1/screenpipe/pipes/day-recap/pipe.md && echo "===" && cat /volume1/screenpipe/pipes/meeting-summary/pipe.md 2>/dev/null | head -50
Copy code to clipboard
OUT
---
schedule: manual
enabled: true
template: true
title: Day Recap
description: "Today's accomplishments, key moments, and unfinished work"
icon: "📋"
featured: true
---
Analyze my screen and audio recordings from today (last 16 hours only).
Read screenpipe skill first.
Use this exact format:
## Summary
One sentence: what I mainly did today.
## Accomplishments
- Top 3 things I finished, with timestamps (e.g. "2:30 PM")
- Name specific apps, files, or projects
## Key Moments
- Important things I saw, said, or heard — with timestamps
## Unfinished Work
- What I should continue tomorrow — name the app/file/task
## Patterns
- Apps I used most, topics that came up repeatedly
Only report what you can verify from the data. End with: "**Next step:** [most important thing to continue]"
===
---
schedule: manual
enabled: true
template: true
title: Meeting Summary
description: "Summarize meeting transcript with key takeaways and action items"
icon: "🤝"
featured: false
---
Summarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.
Read screenpipe skill first.
Use this exact format:
## Meeting Summary
One sentence: what this meeting was about.
## Key Takeaways
- Top 3-5 important points discussed
- Include who said what when relevant
## Action Items
- [ ] Task — assigned to whom, deadline if mentioned
- [ ] Task — assigned to whom
## Decisions Made
- List any decisions or agreements reached
## Open Questions
- Anything unresolved or needing follow-up
Keep it concise and actionable.
Thinking
Thinking
Bash
Read summary consumer
IN
ls /volume1/screenpipe/app/consumers/ && cat /volume1/screenpipe/app/consumers/summary.py
Copy code to clipboard
OUT
activity.py
audio.py
elements.py
__init__.py
interactions.py
ocr.py
__pycache__
report.py
summary.py
"""AI summary generator using Claude."""
import os
from datetime import date
from typing import Any
from consumers.activity import app_time, summary_stats, browser_urls, ui_event_summary
from consumers.ocr import deduplicated_text
from consumers.audio import formatted_transcript
SUMMARY_TYPES = {
"day_recap": {
"title": "Day Recap",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
## Audio/speech:
{audio}
Write a concise day recap using EXACTLY this format:
## Summary
One sentence: what I mainly worked on today.
## Accomplishments
- Top 3 things I finished, with approximate times
- Name specific apps, files, or projects
## Key Moments
- Important things seen or heard, with timestamps
## Unfinished Work
- What to continue tomorrow
## Patterns
- Apps used most, topics that came up repeatedly
Only report what you can verify from the data. End with:
**Next step:** [most important thing to continue]""",
},
"standup": {
"title": "Standup Update",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
## Audio/speech:
{audio}
Write a brief standup update:
**Yesterday:** What I worked on (2-3 bullets)
**Today:** What I plan to continue (1-2 bullets)
**Blockers:** Any issues observed (or "None")
Keep it under 150 words. Only report what's verifiable from the data.""",
},
"focus_time": {
"title": "Focus & Distraction Analysis",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
Analyze focus vs distraction patterns:
## Deep Work Periods
- When and how long were sustained focus sessions?
- What was being worked on?
## Distractions
- Which apps/sites were used recreationally?
- How much time was lost to context switching?
## Recommendations
- 2-3 concrete suggestions to improve focus tomorrow
Be specific with times and app names.""",
},
}
def _build_context(for_date: date) -> dict[str, str]:
apps = app_time(for_date)
app_lines = "\n".join(f"- {a['app_name']}: {a['minutes']} min" for a in apps[:20])
urls = browser_urls(for_date, limit=20)
url_lines = "\n".join(
f"- {u['browser_url'][:100]} ({u['minutes']} min)" for u in urls
)
ui_rows = ui_event_summary(for_date)
ui_lines = "\n".join(
f"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches"
for r in ui_rows[:15]
)
ocr_rows = deduplicated_text(for_date, chunk_minutes=5)
ocr_lines = "\n".join(
f"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}"
for r in ocr_rows[:100]
)
audio = formatted_transcript(for_date)
return {
"app_time": app_lines or "(no app data)",
"browser_urls": url_lines or "(no browser data)",
"ui_events": ui_lines or "(no UI event data)",
"ocr_text": ocr_lines or "(no screen data)",
"audio": audio[:3000] if len(audio) > 3000 else audio,
}
def generate(
summary_type: str = "day_recap",
for_date: date | None = None,
api_key: str | None = None,
) -> dict[str, Any]:
"""Generate an AI summary. Returns dict with 'title', 'content', 'date'."""
import anthropic
d = for_date or date.today()
key = api_key or os.environ.get("ANTHROPIC_API_KEY", "")
if not key:
return {
"title": "Error",
"content": "ANTHROPIC_API_KEY not set. Add it to your .env file.",
"date": str(d),
}
spec = SUMMARY_TYPES.get(summary_type)
if not spec:
return {"title": "Error", "content": f"Unknown summary type: {summary_type}", "date": str(d)}
stats = summary_stats(d)
if stats["total_frames"] == 0:
return {
"title": spec["title"],
"content": f"No screen data found for {d}.",
"date": str(d),
}
ctx = _build_context(d)
prompt = spec["prompt"].format(**ctx)
client = anthropic.Anthropic(api_key=key)
message = client.messages.create(
model="claude-haiku-4-5-20251001",
max_tokens=1024,
messages=[{"role": "user", "content": prompt}],
)
return {
"title": spec["title"],
"content": message.content[0].text,
"date": str(d),
"stats": stats,
}
Thinking
Thinking
Bash
Read all pipe.md files
IN
for f in /volume1/screenpipe/pipes/*/pipe.md; do echo "=== $f ==="; cat "$f"; echo; done
Copy code to clipboard
OUT
=== /volume1/screenpipe/pipes/ai-habits/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: AI Habits
description: "How you use AI tools — patterns and insights"
icon: "🤖"
featured: true
---
Search my recordings from the last 24 hours for AI tool usage. Use app_name filter for each tool separately: ChatGPT, Claude, Copilot, Cursor, Gemini, Perplexity. Use limit=5 per search, max 6 searches total.
Read screenpipe skill first.
Use this exact format:
## AI Tools Used
- List each tool with approximate time spent (e.g. "Claude: ~45min")
## What I Used Them For
- For each tool: coding, writing, research, or brainstorming
## Usage Patterns
- Do I switch between tools? Use them in bursts or steadily?
## Effectiveness
- Which tool appeared alongside completed work vs. abandoned attempts
If no AI usage is found, say so clearly. End with: "**Tip:** [one suggestion to use AI tools more effectively]"
=== /volume1/screenpipe/pipes/day-recap/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Day Recap
description: "Today's accomplishments, key moments, and unfinished work"
icon: "📋"
featured: true
---
Analyze my screen and audio recordings from today (last 16 hours only).
Read screenpipe skill first.
Use this exact format:
## Summary
One sentence: what I mainly did today.
## Accomplishments
- Top 3 things I finished, with timestamps (e.g. "2:30 PM")
- Name specific apps, files, or projects
## Key Moments
- Important things I saw, said, or heard — with timestamps
## Unfinished Work
- What I should continue tomorrow — name the app/file/task
## Patterns
- Apps I used most, topics that came up repeatedly
Only report what you can verify from the data. End with: "**Next step:** [most important thing to continue]"
=== /volume1/screenpipe/pipes/meeting-summary/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Meeting Summary
description: "Summarize meeting transcript with key takeaways and action items"
icon: "🤝"
featured: false
---
Summarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.
Read screenpipe skill first.
Use this exact format:
## Meeting Summary
One sentence: what this meeting was about.
## Key Takeaways
- Top 3-5 important points discussed
- Include who said what when relevant
## Action Items
- [ ] Task — assigned to whom, deadline if mentioned
- [ ] Task — assigned to whom
## Decisions Made
- List any decisions or agreements reached
## Open Questions
- Anything unresolved or needing follow-up
Keep it concise and actionable.
=== /volume1/screenpipe/pipes/standup-update/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Standup Update
description: "What you did, what's next, and any blockers"
icon: "🏢"
featured: true
---
Based on my recordings from the last 24 hours, generate a standup update. Use limit=10 per search, max 3 searches total.
Read screenpipe skill first.
Use this exact format:
## Yesterday
- What I worked on (name specific projects, files, tools, PRs)
## Today
- What I will work on next (based on unfinished tasks and recent activity)
## Blockers
- Issues I hit — errors, slow builds, waiting on someone
- If no blockers, write "None"
Keep it under 150 words. Copy-paste ready for a team standup.
=== /volume1/screenpipe/pipes/time-breakdown/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Time Breakdown
description: "Where your time went — by app, project, and category"
icon: "⏱"
featured: false
---
Analyze my app usage from today (last 12 hours). Use limit=10 per search, max 4 searches. Prefer /raw_sql with COUNT/GROUP BY queries.
Read screenpipe skill first.
Use this exact format with durations and percentages:
## By Application
- List each app with duration and percentage, sorted by time (e.g. "VS Code: 2h 15min (28%)")
## By Category
- Group into: coding, meetings, browsing, writing, communication, other
- Show hours and percentage per category
## By Project
- Group related activities by project/topic. Name specific repos or tasks.
## Productivity Score
- Calculate: focused_work_hours / total_hours as a percentage
- Focused = coding + writing. Unfocused = browsing + switching.
End with: "**Suggestion:** [one specific change to improve tomorrow's productivity]"
=== /volume1/screenpipe/pipes/video-export/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Export Video Clip
description: "Create a video of your recent screen activity"
icon: "🎬"
featured: false
---
Export a video of my screen activity from the last 5 minutes.
Read screenpipe skill first.
Use the POST /frames/export endpoint with the time range and fps=1.0. Then show me the exported video file path as an inline code block so I can watch it.
If the export is large, suggest a lower fps or shorter time range.
Thinking
Thinking
Now I have a clear picture. The pipes are markdown prompt templates in
/volume1/screenpipe/pipes/
, but there's no code to actually load and run them —
consumers/summary.py
has its own hardcoded prompts instead.
Here's what I'll implement:
consumers/pipes.py
— dynamically loads pipe.md files and runs them via Claude (data injected as system message, pipe body as user prompt)
main.py
— two new endpoints:
GET /api/pipes
and
POST /api/pipes/{pipe_id}/run
cli.py
— a
pipe
command to run pipes from the terminal
Let me build it:
Bash
Check browser_urls signature
IN
cat /volume1/screenpipe/app/consumers/activity.py | grep "def browser_urls" -A 5
Copy code to clipboard
OUT
def browser_urls(
for_date: date | None = None,
app_name: str | None = None,
ts_from: str | None = None,
ts_to: str | None = None,
limit: int = 30,
Write
pipes.py
pipes.py
143 lines
"""Dynamic pipe loader and runner."""
import os
import re
from datetime import date
from pathlib import Path
from typing import Any
def _parse_frontmatter(text: str) -> tuple[dict, str]:
if not text.startswith("---"):
return {}, text
try:
end = text.index("---", 3)
except ValueError:
return {}, text
fm_text = text[3:end].strip()
body = text[end + 3:].strip()
meta: dict = {}
for line in fm_text.splitlines():
if ":" in line:
k, _, v = li...
|
[{"role":"AXRadioButton","text [{"role":"AXRadioButton","text":"Explorer (⇧⌘E)","depth":19,"bounds":{"left":0.0,"top":0.047885075,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":true},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.057462092,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Search (⇧⌘F)","depth":19,"bounds":{"left":0.0,"top":0.08619314,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.09577015,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Source Control (⌃⇧G) - 10 pending changes","depth":19,"bounds":{"left":0.0,"top":0.1245012,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.13407822,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"10","depth":22,"bounds":{"left":0.00831117,"top":0.1452514,"width":0.003656915,"height":0.008778931},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.00831117,"top":0.14604948,"width":0.0016622341,"height":0.007980846}},{"char_start":1,"char_count":1,"bounds":{"left":0.009973404,"top":0.14604948,"width":0.0023271276,"height":0.007980846}}],"role_description":"text"},{"role":"AXRadioButton","text":"Run and Debug (⇧⌘D)","depth":19,"bounds":{"left":0.0,"top":0.16280925,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.17238627,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Remote Explorer","depth":19,"bounds":{"left":0.0,"top":0.20111732,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.21069433,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Extensions (⇧⌘X) - 2 require update","depth":19,"bounds":{"left":0.0,"top":0.23942538,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.2490024,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"2","depth":22,"bounds":{"left":0.009640957,"top":0.2601756,"width":0.0019946808,"height":0.008778931},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Claude Code","depth":19,"bounds":{"left":0.0,"top":0.27773345,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"Containers","depth":19,"bounds":{"left":0.0,"top":0.3160415,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXHeading","text":"EXPLORER","depth":17,"bounds":{"left":0.022606382,"top":0.047885075,"width":0.018949468,"height":0.02793296},"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"EXPLORER","depth":18,"bounds":{"left":0.022606382,"top":0.056664005,"width":0.018949468,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.022606382,"top":0.056664005,"width":0.0023271276,"height":0.0103751}},{"char_start":1,"char_count":7,"bounds":{"left":0.024933511,"top":0.056664005,"width":0.01662234,"height":0.0103751}}],"role_description":"text"},{"role":"AXButton","text":"Explorer Section: screenpipe [SSH: nas]","depth":21,"bounds":{"left":0.015957447,"top":0.07581804,"width":0.09940159,"height":0.017557861},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":true},{"role":"AXStaticText","text":"","depth":23,"bounds":{"left":0.01662234,"top":0.07821229,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"Explorer Section: screenpipe [SSH: nas]","depth":22,"bounds":{"left":0.022606382,"top":0.07581804,"width":0.045877658,"height":0.017557861},"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"SCREENPIPE [SSH: NAS]","depth":23,"bounds":{"left":0.022606382,"top":0.079010375,"width":0.045877658,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.022606382,"top":0.07980846,"width":0.0026595744,"height":0.0103751}},{"char_start":1,"char_count":20,"bounds":{"left":0.025265958,"top":0.07980846,"width":0.043218084,"height":0.0103751}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.09577015,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"#recycle","depth":27,"bounds":{"left":0.025930852,"top":0.09577015,"width":0.017287234,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.096568234,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":7,"bounds":{"left":0.028590426,"top":0.096568234,"width":0.01462766,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.11332801,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"app","depth":27,"bounds":{"left":0.025930852,"top":0.11332801,"width":0.0076462766,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.11412609,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":2,"bounds":{"left":0.02825798,"top":0.11412609,"width":0.005319149,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.11412609,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.022273935,"top":0.13088587,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"__pycache__","depth":27,"bounds":{"left":0.028590426,"top":0.13088587,"width":0.026595745,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.13168396,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":10,"bounds":{"left":0.030917553,"top":0.13168396,"width":0.024268618,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.022273935,"top":0.14844373,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"consumers","depth":27,"bounds":{"left":0.028590426,"top":0.14844373,"width":0.022273935,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.14924182,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":8,"bounds":{"left":0.030917553,"top":0.14924182,"width":0.019946808,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.14924182,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.022273935,"top":0.1660016,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"static","depth":27,"bounds":{"left":0.028590426,"top":0.1660016,"width":0.010970744,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.16679968,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":5,"bounds":{"left":0.030917553,"top":0.16679968,"width":0.008976064,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.16679968,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.1819633,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":".env","depth":27,"bounds":{"left":0.028590426,"top":0.18355946,"width":0.00831117,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.18435754,"width":0.0013297872,"height":0.011971269}},{"char_start":1,"char_count":3,"bounds":{"left":0.029920213,"top":0.18435754,"width":0.006981383,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.19952115,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"cli.py","depth":27,"bounds":{"left":0.028590426,"top":0.20111732,"width":0.010638298,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.2019154,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":5,"bounds":{"left":0.030917553,"top":0.2019154,"width":0.00831117,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.2019154,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.21707901,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.py","depth":27,"bounds":{"left":0.028590426,"top":0.21867518,"width":0.011303191,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.21947326,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":4,"bounds":{"left":0.03125,"top":0.21947326,"width":0.008643617,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.23463687,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"docker-compose.yml","depth":27,"bounds":{"left":0.028590426,"top":0.23623304,"width":0.042220745,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.23703113,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":17,"bounds":{"left":0.03125,"top":0.23703113,"width":0.03956117,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.25219473,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Dockerfile","depth":27,"bounds":{"left":0.028590426,"top":0.25379092,"width":0.020611702,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.254589,"width":0.0033244682,"height":0.011971269}},{"char_start":1,"char_count":9,"bounds":{"left":0.031914894,"top":0.254589,"width":0.017287234,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.254589,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.2697526,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"main.py","depth":27,"bounds":{"left":0.028590426,"top":0.27134877,"width":0.015625,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.27214685,"width":0.003656915,"height":0.011971269}},{"char_start":1,"char_count":6,"bounds":{"left":0.032247342,"top":0.27214685,"width":0.012300532,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.27214685,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.28731045,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"requirements.txt","depth":27,"bounds":{"left":0.028590426,"top":0.28890663,"width":0.032912236,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.2897047,"width":0.0016622341,"height":0.011971269}},{"char_start":1,"char_count":15,"bounds":{"left":0.03025266,"top":0.2897047,"width":0.03158245,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.2897047,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.3064645,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"data","depth":27,"bounds":{"left":0.025930852,"top":0.3064645,"width":0.008976064,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.30726257,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":3,"bounds":{"left":0.028590426,"top":0.30726257,"width":0.0063164895,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.32402235,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"logs","depth":27,"bounds":{"left":0.025930852,"top":0.32402235,"width":0.00831117,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.32482043,"width":0.0009973404,"height":0.011971269}},{"char_start":1,"char_count":3,"bounds":{"left":0.026928192,"top":0.32482043,"width":0.0076462766,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.32482043,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.3415802,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"pipes","depth":27,"bounds":{"left":0.025930852,"top":0.3415802,"width":0.010970744,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.3423783,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":4,"bounds":{"left":0.028590426,"top":0.3423783,"width":0.00831117,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.3575419,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":".gitignore","depth":27,"bounds":{"left":0.025930852,"top":0.35913807,"width":0.018949468,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.35993615,"width":0.0013297872,"height":0.011971269}},{"char_start":1,"char_count":9,"bounds":{"left":0.027260639,"top":0.35993615,"width":0.017952127,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.37509975,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"app_settings.json","depth":27,"bounds":{"left":0.025930852,"top":0.37669593,"width":0.03557181,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.377494,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":16,"bounds":{"left":0.02825798,"top":0.377494,"width":0.03324468,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.3926576,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"archive.db","depth":27,"bounds":{"left":0.025930852,"top":0.3942538,"width":0.020944148,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.39505187,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":9,"bounds":{"left":0.02825798,"top":0.39505187,"width":0.01861702,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.4102155,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"archive.db-bak","depth":27,"bounds":{"left":0.025930852,"top":0.41181165,"width":0.03025266,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.41260973,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":13,"bounds":{"left":0.02825798,"top":0.41260973,"width":0.027925532,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"U","depth":27,"bounds":{"left":0.10704787,"top":0.41260973,"width":0.0029920214,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.42777336,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite","depth":27,"bounds":{"left":0.025930852,"top":0.4293695,"width":0.017287234,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.4301676,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":8,"bounds":{"left":0.028590426,"top":0.4301676,"width":0.014960106,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.44533122,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite-shm","depth":27,"bounds":{"left":0.025930852,"top":0.44692737,"width":0.027925532,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.44772545,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":12,"bounds":{"left":0.028590426,"top":0.44772545,"width":0.025265958,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.46288908,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite-wal","depth":27,"bounds":{"left":0.025930852,"top":0.46448523,"width":0.025930852,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.46528333,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":12,"bounds":{"left":0.028590426,"top":0.46528333,"width":0.023603724,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.48044693,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe_sync_updated.sh","depth":27,"bounds":{"left":0.025930852,"top":0.4820431,"width":0.059175532,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.4828412,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":25,"bounds":{"left":0.02825798,"top":0.4828412,"width":0.056848403,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"U","depth":27,"bounds":{"left":0.10704787,"top":0.4828412,"width":0.0029920214,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.4980048,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe_sync.sh","depth":27,"bounds":{"left":0.025930852,"top":0.49960095,"width":0.039893616,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.50039905,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":17,"bounds":{"left":0.02825798,"top":0.50039905,"width":0.037898935,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.51556265,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe.db","depth":27,"bounds":{"left":0.025930852,"top":0.5171588,"width":0.028590426,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.5179569,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":12,"bounds":{"left":0.02825798,"top":0.5179569,"width":0.026595745,"height":0.011971269}}],"role_description":"text"},{"role":"AXButton","text":"Outline Section","depth":21,"bounds":{"left":0.015957447,"top":0.9473264,"width":0.09940159,"height":0.017557861},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":23,"bounds":{"left":0.01662234,"top":0.9497207,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"OUTLINE","depth":22,"bounds":{"left":0.022606382,"top":0.9473264,"width":0.01662234,"height":0.017557861},"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"OUTLINE","depth":23,"bounds":{"left":0.022606382,"top":0.95131683,"width":0.01662234,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.022606382,"top":0.95131683,"width":0.0029920214,"height":0.0103751}},{"char_start":1,"char_count":6,"bounds":{"left":0.025598405,"top":0.95131683,"width":0.013630319,"height":0.0103751}}],"role_description":"text"},{"role":"AXButton","text":"Timeline Section","depth":21,"bounds":{"left":0.015957447,"top":0.9648843,"width":0.09940159,"height":0.017557861},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":23,"bounds":{"left":0.01662234,"top":0.96727854,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"TIMELINE","depth":22,"bounds":{"left":0.022606382,"top":0.9648843,"width":0.01761968,"height":0.017557861},"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"TIMELINE","depth":23,"bounds":{"left":0.022606382,"top":0.9688747,"width":0.01761968,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.022606382,"top":0.9688747,"width":0.0026595744,"height":0.0103751}},{"char_start":1,"char_count":7,"bounds":{"left":0.025265958,"top":0.9688747,"width":0.015292553,"height":0.0103751}}],"role_description":"text"},{"role":"AXRadioButton","text":"app_settings.json, Editor Group 1","depth":28,"bounds":{"left":0.11569149,"top":0.047885075,"width":0.055851065,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"screenpipe_sync.sh, Editor Group 1","depth":28,"bounds":{"left":0.17154256,"top":0.047885075,"width":0.06050532,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":false},{"role":"AXRadioButton","text":"pipe.md, Editor Group 1","depth":28,"bounds":{"left":0.23171543,"top":0.047885075,"width":0.040226065,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":".env, Editor Group 1","depth":28,"bounds":{"left":0.27194148,"top":0.047885075,"width":0.039893616,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"#!/bin/bash\n# screenpipe_sync.sh\n# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).\n# Also copies the day's video/frame data folder to the NAS.\n#\n# Usage:\n# ./screenpipe_sync.sh # syncs yesterday (default)\n# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date\n# ./screenpipe_sync.sh today # syncs today so far\n#\n# Cron example (runs at 3am daily):\n# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1\n\nset -euo pipefail\n\n# ─── CONFIG ───────────────────────────────────────────────────────────────────\nDB_SRC=\"${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}\"\nNAS_MOUNT=\"${NAS_MOUNT:-/Volumes/Test/screenpipe}\"\nNAS_DB=\"$NAS_MOUNT/archive.db\"\nNAS_DATA=\"$NAS_MOUNT/data\"\nLOG_FILE=\"$HOME/.screenpipe/sync.log\"\n# ──────────────────────────────────────────────────────────────────────────────\n\n# ─── HELPERS ──────────────────────────────────────────────────────────────────\nSCRIPT_START=$(date +%s)\n\nlog() {\n local msg=\"[$(date '+%Y-%m-%d %H:%M:%S')] $*\"\n echo \"$msg\" | tee -a \"$LOG_FILE\"\n}\n\nstep() {\n local now=$(date +%s)\n local elapsed=$(( now - SCRIPT_START ))\n local min=$(( elapsed / 60 ))\n local sec=$(( elapsed % 60 ))\n printf \"\\n[+%02dm%02ds] ▶ %s\\n\" \"$min\" \"$sec\" \"$*\" | tee -a \"$LOG_FILE\"\n}\n\nrun_sqlite_heredoc() {\n local label=\"$1\"\n local sql=\"$2\"\n local start=$(date +%s)\n\n printf \" %-36s \" \"$label\"\n\n sqlite3 \"$DB_SRC\" <<< \"$sql\" &\n local pid=$!\n local spin=('⠋' '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')\n local i=0\n while kill -0 \"$pid\" 2>/dev/null; do\n printf \"\\r %-36s %s \" \"$label\" \"${spin[$i]}\"\n i=$(( (i + 1) % 10 ))\n sleep 0.2\n done\n wait \"$pid\"\n local rc=$?\n if [ $rc -ne 0 ]; then\n printf \"\\r %-36s ✗ FAILED\\n\" \"$label\" | tee -a \"$LOG_FILE\"\n exit $rc\n fi\n\n local dur=$(( $(date +%s) - start ))\n printf \"\\r %-36s ✓ %dm%02ds\\n\" \"$label\" \"$(( dur / 60 ))\" \"$(( dur % 60 ))\" | tee -a \"$LOG_FILE\"\n}\n\ncheck() {\n local label=\"$1\" got=\"$2\" expected=\"$3\"\n if [ \"$got\" -eq \"$expected\" ]; then\n printf \" %-20s %s / %s ✓\\n\" \"$label:\" \"$got\" \"$expected\"\n else\n printf \" %-20s %s / %s ✗ MISMATCH\\n\" \"$label:\" \"$got\" \"$expected\"\n fi\n}\n# ──────────────────────────────────────────────────────────────────────────────\n\n# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────\nif [ \"${1:-}\" = \"today\" ]; then\n TARGET_DATE=$(date +%Y-%m-%d)\nelif [ -n \"${1:-}\" ]; then\n TARGET_DATE=\"$1\"\n if ! [[ \"$TARGET_DATE\" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then\n echo \"ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday.\"\n exit 1\n fi\nelse\n TARGET_DATE=$(date -v-1d +%Y-%m-%d)\nfi\n\nlog \"========================================\"\nlog \"Screenpipe sync starting for: $TARGET_DATE\"\nlog \"========================================\"\n\n# ─── PREFLIGHT ────────────────────────────────────────────────────────────────\nstep \"Preflight checks\"\n\nif [ ! -f \"$DB_SRC\" ]; then\n log \"ERROR: Source DB not found at $DB_SRC\"; exit 1\nfi\nprintf \" %-20s %s (%s)\\n\" \"Source DB:\" \"OK\" \"$(du -sh \"$DB_SRC\" | cut -f1)\"\n\nif [ ! -d \"$NAS_MOUNT\" ]; then\n log \"ERROR: NAS not mounted at $NAS_MOUNT\"; exit 1\nfi\nprintf \" %-20s %s\\n\" \"NAS mount:\" \"OK $NAS_MOUNT\"\n\n# Check if DB already synced for this date\nDB_ALREADY_SYNCED=false\nif [ -f \"$NAS_DB\" ]; then\n EXISTING=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\" 2>/dev/null || echo \"0\")\n if [ \"$EXISTING\" -gt \"0\" ]; then\n log \"Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync\"\n DB_ALREADY_SYNCED=true\n else\n printf \" %-20s %s (%s)\\n\" \"Archive DB:\" \"exists\" \"$(du -sh \"$NAS_DB\" | cut -f1)\"\n fi\nelse\n printf \" %-20s %s\\n\" \"Archive DB:\" \"will be created\"\nfi\n\n# Source data dir for this date\nDATA_SRC=\"$HOME/.screenpipe/data/data/$TARGET_DATE\"\nif [ -d \"$DATA_SRC\" ]; then\n DATA_SIZE=$(du -sh \"$DATA_SRC\" | cut -f1)\n DATA_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n printf \" %-20s %s (%s files, %s)\\n\" \"Data dir:\" \"OK\" \"$DATA_FILES\" \"$DATA_SIZE\"\nelse\n printf \" %-20s %s\\n\" \"Data dir:\" \"not found — skipping file copy\"\nfi\n\n# ─── DB SYNC ──────────────────────────────────────────────────────────────────\nif [ \"$DB_ALREADY_SYNCED\" = false ]; then\n\n # ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────\n step \"Counting source rows for $TARGET_DATE\"\n\n SRC_FRAMES=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\")\n SRC_ELEMENTS=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n SRC_UI=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';\")\n SRC_OCR=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n SRC_MEETINGS=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';\")\n\n printf \" %-20s %s\\n\" \"frames:\" \"$SRC_FRAMES\"\n printf \" %-20s %s\\n\" \"elements:\" \"$SRC_ELEMENTS\"\n printf \" %-20s %s\\n\" \"ui_events:\" \"$SRC_UI\"\n printf \" %-20s %s\\n\" \"ocr_text:\" \"$SRC_OCR\"\n printf \" %-20s %s\\n\" \"meetings:\" \"$SRC_MEETINGS\"\n\n if [ \"$SRC_FRAMES\" -eq \"0\" ]; then\n log \"No frames found for $TARGET_DATE — skipping DB sync\"\n DB_ALREADY_SYNCED=true\n fi\n\nfi\n\nif [ \"$DB_ALREADY_SYNCED\" = false ]; then\n\n # ─── INIT TABLES ──────────────────────────────────────────────────────────\n step \"Initialising tables, indexes, FTS\"\n\n run_sqlite_heredoc \"creating tables\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"creating indexes\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);\nCREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);\nCREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"creating FTS tables\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(\n text, role, frame_id UNINDEXED,\n content='elements', content_rowid='id', tokenize='unicode61'\n);\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(\n full_text, app_name, window_name, browser_url, id UNINDEXED,\n tokenize='unicode61'\n);\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(\n text_content,\n app_name,\n window_title,\n element_name,\n content='ui_events',\n content_rowid='id',\n tokenize='unicode61'\n);\nDETACH nas;\n\"\n\n # ─── SYNC DATA ────────────────────────────────────────────────────────────\n step \"Syncing data for $TARGET_DATE\"\n\n run_sqlite_heredoc \"video_chunks\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.video_chunks\n SELECT * FROM main.video_chunks\n WHERE id IN (\n SELECT DISTINCT video_chunk_id FROM main.frames\n WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL\n );\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames ($SRC_FRAMES rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.frames\n SELECT * FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ocr_text ($SRC_OCR rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ocr_text\n SELECT o.* FROM main.ocr_text o\n JOIN main.frames f ON o.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events ($SRC_UI rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ui_events\n SELECT * FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"elements ($SRC_ELEMENTS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.elements\n SELECT e.* FROM main.elements e\n JOIN main.frames f ON e.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"meetings ($SRC_MEETINGS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.meetings\n SELECT * FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n # ─── FTS UPDATE ───────────────────────────────────────────────────────────\n step \"Updating FTS indexes\"\n\n run_sqlite_heredoc \"elements_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.elements_fts(rowid, text, role)\n SELECT e.id, e.text, e.role\n FROM nas.elements e\n JOIN nas.frames f ON e.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE'\n AND e.text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)\n SELECT id, full_text, app_name, window_name, browser_url, id\n FROM nas.frames\n WHERE date(timestamp) = '$TARGET_DATE'\n AND full_text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)\n SELECT id, text_content, app_name, window_title, element_name\n FROM nas.ui_events\n WHERE date(timestamp) = '$TARGET_DATE'\n AND text_content IS NOT NULL;\nDETACH nas;\n\"\n\n # ─── VERIFY DB ────────────────────────────────────────────────────────────\n step \"Verifying DB\"\n\n V_FRAMES=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\")\n V_ELEMENTS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n V_UI=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';\")\n V_OCR=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n V_MEETINGS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';\")\n\n check \"frames\" \"$V_FRAMES\" \"$SRC_FRAMES\"\n check \"elements\" \"$V_ELEMENTS\" \"$SRC_ELEMENTS\"\n check \"ui_events\" \"$V_UI\" \"$SRC_UI\"\n check \"ocr_text\" \"$V_OCR\" \"$SRC_OCR\"\n check \"meetings\" \"$V_MEETINGS\" \"$SRC_MEETINGS\"\n\nfi\n\n# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────\n# Always runs regardless of DB sync status\nstep \"Copying data folder for $TARGET_DATE\"\n\nif [ -d \"$DATA_SRC\" ]; then\n mkdir -p \"$NAS_DATA/$TARGET_DATE\"\n RSYNC_START=$(date +%s)\n printf \" %-36s \" \"rsync $TARGET_DATE/ → NAS\"\n rsync -a --ignore-existing \\\n \"$DATA_SRC/\" \\\n \"$NAS_DATA/$TARGET_DATE/\" \\\n 2>>\"$LOG_FILE\"\n RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))\n COPIED_FILES=$(ls \"$NAS_DATA/$TARGET_DATE\" | wc -l | tr -d ' ')\n SRC_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n COPIED_SIZE=$(du -sh \"$NAS_DATA/$TARGET_DATE\" | cut -f1)\n if [ \"$COPIED_FILES\" -eq \"$SRC_FILES\" ]; then\n printf \"\\r %-36s ✓ %dm%02ds (%s files, %s)\\n\" \\\n \"rsync $TARGET_DATE/ → NAS\" \\\n \"$(( RSYNC_DUR / 60 ))\" \"$(( RSYNC_DUR % 60 ))\" \\\n \"$COPIED_FILES\" \"$COPIED_SIZE\" | tee -a \"$LOG_FILE\"\n else\n printf \"\\r %-36s ✗ %s / %s files\\n\" \\\n \"rsync $TARGET_DATE/ → NAS\" \"$COPIED_FILES\" \"$SRC_FILES\" | tee -a \"$LOG_FILE\"\n fi\nelse\n printf \" %-36s %s\\n\" \"rsync $TARGET_DATE/ → NAS\" \"skipped (no source dir)\"\nfi\n\n# ─── SUMMARY ──────────────────────────────────────────────────────────────────\nTOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))\nDB_SIZE=$(du -sh \"$NAS_DB\" | cut -f1)\n\necho \"\"\nlog \"Archive DB size: $DB_SIZE\"\nlog \"Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s\"\nlog \"Sync complete for $TARGET_DATE\"\nlog \"========================================\"","depth":28,"bounds":{"left":0.13763298,"top":0.16041501,"width":0.38031915,"height":0.014365523},"on_screen":true,"value":"#!/bin/bash\n# screenpipe_sync.sh\n# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).\n# Also copies the day's video/frame data folder to the NAS.\n#\n# Usage:\n# ./screenpipe_sync.sh # syncs yesterday (default)\n# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date\n# ./screenpipe_sync.sh today # syncs today so far\n#\n# Cron example (runs at 3am daily):\n# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1\n\nset -euo pipefail\n\n# ─── CONFIG ───────────────────────────────────────────────────────────────────\nDB_SRC=\"${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}\"\nNAS_MOUNT=\"${NAS_MOUNT:-/Volumes/Test/screenpipe}\"\nNAS_DB=\"$NAS_MOUNT/archive.db\"\nNAS_DATA=\"$NAS_MOUNT/data\"\nLOG_FILE=\"$HOME/.screenpipe/sync.log\"\n# ──────────────────────────────────────────────────────────────────────────────\n\n# ─── HELPERS ──────────────────────────────────────────────────────────────────\nSCRIPT_START=$(date +%s)\n\nlog() {\n local msg=\"[$(date '+%Y-%m-%d %H:%M:%S')] $*\"\n echo \"$msg\" | tee -a \"$LOG_FILE\"\n}\n\nstep() {\n local now=$(date +%s)\n local elapsed=$(( now - SCRIPT_START ))\n local min=$(( elapsed / 60 ))\n local sec=$(( elapsed % 60 ))\n printf \"\\n[+%02dm%02ds] ▶ %s\\n\" \"$min\" \"$sec\" \"$*\" | tee -a \"$LOG_FILE\"\n}\n\nrun_sqlite_heredoc() {\n local label=\"$1\"\n local sql=\"$2\"\n local start=$(date +%s)\n\n printf \" %-36s \" \"$label\"\n\n sqlite3 \"$DB_SRC\" <<< \"$sql\" &\n local pid=$!\n local spin=('⠋' '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')\n local i=0\n while kill -0 \"$pid\" 2>/dev/null; do\n printf \"\\r %-36s %s \" \"$label\" \"${spin[$i]}\"\n i=$(( (i + 1) % 10 ))\n sleep 0.2\n done\n wait \"$pid\"\n local rc=$?\n if [ $rc -ne 0 ]; then\n printf \"\\r %-36s ✗ FAILED\\n\" \"$label\" | tee -a \"$LOG_FILE\"\n exit $rc\n fi\n\n local dur=$(( $(date +%s) - start ))\n printf \"\\r %-36s ✓ %dm%02ds\\n\" \"$label\" \"$(( dur / 60 ))\" \"$(( dur % 60 ))\" | tee -a \"$LOG_FILE\"\n}\n\ncheck() {\n local label=\"$1\" got=\"$2\" expected=\"$3\"\n if [ \"$got\" -eq \"$expected\" ]; then\n printf \" %-20s %s / %s ✓\\n\" \"$label:\" \"$got\" \"$expected\"\n else\n printf \" %-20s %s / %s ✗ MISMATCH\\n\" \"$label:\" \"$got\" \"$expected\"\n fi\n}\n# ──────────────────────────────────────────────────────────────────────────────\n\n# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────\nif [ \"${1:-}\" = \"today\" ]; then\n TARGET_DATE=$(date +%Y-%m-%d)\nelif [ -n \"${1:-}\" ]; then\n TARGET_DATE=\"$1\"\n if ! [[ \"$TARGET_DATE\" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then\n echo \"ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday.\"\n exit 1\n fi\nelse\n TARGET_DATE=$(date -v-1d +%Y-%m-%d)\nfi\n\nlog \"========================================\"\nlog \"Screenpipe sync starting for: $TARGET_DATE\"\nlog \"========================================\"\n\n# ─── PREFLIGHT ────────────────────────────────────────────────────────────────\nstep \"Preflight checks\"\n\nif [ ! -f \"$DB_SRC\" ]; then\n log \"ERROR: Source DB not found at $DB_SRC\"; exit 1\nfi\nprintf \" %-20s %s (%s)\\n\" \"Source DB:\" \"OK\" \"$(du -sh \"$DB_SRC\" | cut -f1)\"\n\nif [ ! -d \"$NAS_MOUNT\" ]; then\n log \"ERROR: NAS not mounted at $NAS_MOUNT\"; exit 1\nfi\nprintf \" %-20s %s\\n\" \"NAS mount:\" \"OK $NAS_MOUNT\"\n\n# Check if DB already synced for this date\nDB_ALREADY_SYNCED=false\nif [ -f \"$NAS_DB\" ]; then\n EXISTING=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\" 2>/dev/null || echo \"0\")\n if [ \"$EXISTING\" -gt \"0\" ]; then\n log \"Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync\"\n DB_ALREADY_SYNCED=true\n else\n printf \" %-20s %s (%s)\\n\" \"Archive DB:\" \"exists\" \"$(du -sh \"$NAS_DB\" | cut -f1)\"\n fi\nelse\n printf \" %-20s %s\\n\" \"Archive DB:\" \"will be created\"\nfi\n\n# Source data dir for this date\nDATA_SRC=\"$HOME/.screenpipe/data/data/$TARGET_DATE\"\nif [ -d \"$DATA_SRC\" ]; then\n DATA_SIZE=$(du -sh \"$DATA_SRC\" | cut -f1)\n DATA_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n printf \" %-20s %s (%s files, %s)\\n\" \"Data dir:\" \"OK\" \"$DATA_FILES\" \"$DATA_SIZE\"\nelse\n printf \" %-20s %s\\n\" \"Data dir:\" \"not found — skipping file copy\"\nfi\n\n# ─── DB SYNC ──────────────────────────────────────────────────────────────────\nif [ \"$DB_ALREADY_SYNCED\" = false ]; then\n\n # ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────\n step \"Counting source rows for $TARGET_DATE\"\n\n SRC_FRAMES=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\")\n SRC_ELEMENTS=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n SRC_UI=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';\")\n SRC_OCR=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n SRC_MEETINGS=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';\")\n\n printf \" %-20s %s\\n\" \"frames:\" \"$SRC_FRAMES\"\n printf \" %-20s %s\\n\" \"elements:\" \"$SRC_ELEMENTS\"\n printf \" %-20s %s\\n\" \"ui_events:\" \"$SRC_UI\"\n printf \" %-20s %s\\n\" \"ocr_text:\" \"$SRC_OCR\"\n printf \" %-20s %s\\n\" \"meetings:\" \"$SRC_MEETINGS\"\n\n if [ \"$SRC_FRAMES\" -eq \"0\" ]; then\n log \"No frames found for $TARGET_DATE — skipping DB sync\"\n DB_ALREADY_SYNCED=true\n fi\n\nfi\n\nif [ \"$DB_ALREADY_SYNCED\" = false ]; then\n\n # ─── INIT TABLES ──────────────────────────────────────────────────────────\n step \"Initialising tables, indexes, FTS\"\n\n run_sqlite_heredoc \"creating tables\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"creating indexes\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);\nCREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);\nCREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"creating FTS tables\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(\n text, role, frame_id UNINDEXED,\n content='elements', content_rowid='id', tokenize='unicode61'\n);\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(\n full_text, app_name, window_name, browser_url, id UNINDEXED,\n tokenize='unicode61'\n);\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(\n text_content,\n app_name,\n window_title,\n element_name,\n content='ui_events',\n content_rowid='id',\n tokenize='unicode61'\n);\nDETACH nas;\n\"\n\n # ─── SYNC DATA ────────────────────────────────────────────────────────────\n step \"Syncing data for $TARGET_DATE\"\n\n run_sqlite_heredoc \"video_chunks\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.video_chunks\n SELECT * FROM main.video_chunks\n WHERE id IN (\n SELECT DISTINCT video_chunk_id FROM main.frames\n WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL\n );\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames ($SRC_FRAMES rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.frames\n SELECT * FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ocr_text ($SRC_OCR rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ocr_text\n SELECT o.* FROM main.ocr_text o\n JOIN main.frames f ON o.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events ($SRC_UI rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ui_events\n SELECT * FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"elements ($SRC_ELEMENTS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.elements\n SELECT e.* FROM main.elements e\n JOIN main.frames f ON e.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"meetings ($SRC_MEETINGS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.meetings\n SELECT * FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n # ─── FTS UPDATE ───────────────────────────────────────────────────────────\n step \"Updating FTS indexes\"\n\n run_sqlite_heredoc \"elements_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.elements_fts(rowid, text, role)\n SELECT e.id, e.text, e.role\n FROM nas.elements e\n JOIN nas.frames f ON e.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE'\n AND e.text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)\n SELECT id, full_text, app_name, window_name, browser_url, id\n FROM nas.frames\n WHERE date(timestamp) = '$TARGET_DATE'\n AND full_text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)\n SELECT id, text_content, app_name, window_title, element_name\n FROM nas.ui_events\n WHERE date(timestamp) = '$TARGET_DATE'\n AND text_content IS NOT NULL;\nDETACH nas;\n\"\n\n # ─── VERIFY DB ────────────────────────────────────────────────────────────\n step \"Verifying DB\"\n\n V_FRAMES=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\")\n V_ELEMENTS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n V_UI=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';\")\n V_OCR=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n V_MEETINGS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';\")\n\n check \"frames\" \"$V_FRAMES\" \"$SRC_FRAMES\"\n check \"elements\" \"$V_ELEMENTS\" \"$SRC_ELEMENTS\"\n check \"ui_events\" \"$V_UI\" \"$SRC_UI\"\n check \"ocr_text\" \"$V_OCR\" \"$SRC_OCR\"\n check \"meetings\" \"$V_MEETINGS\" \"$SRC_MEETINGS\"\n\nfi\n\n# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────\n# Always runs regardless of DB sync status\nstep \"Copying data folder for $TARGET_DATE\"\n\nif [ -d \"$DATA_SRC\" ]; then\n mkdir -p \"$NAS_DATA/$TARGET_DATE\"\n RSYNC_START=$(date +%s)\n printf \" %-36s \" \"rsync $TARGET_DATE/ → NAS\"\n rsync -a --ignore-existing \\\n \"$DATA_SRC/\" \\\n \"$NAS_DATA/$TARGET_DATE/\" \\\n 2>>\"$LOG_FILE\"\n RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))\n COPIED_FILES=$(ls \"$NAS_DATA/$TARGET_DATE\" | wc -l | tr -d ' ')\n SRC_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n COPIED_SIZE=$(du -sh \"$NAS_DATA/$TARGET_DATE\" | cut -f1)\n if [ \"$COPIED_FILES\" -eq \"$SRC_FILES\" ]; then\n printf \"\\r %-36s ✓ %dm%02ds (%s files, %s)\\n\" \\\n \"rsync $TARGET_DATE/ → NAS\" \\\n \"$(( RSYNC_DUR / 60 ))\" \"$(( RSYNC_DUR % 60 ))\" \\\n \"$COPIED_FILES\" \"$COPIED_SIZE\" | tee -a \"$LOG_FILE\"\n else\n printf \"\\r %-36s ✗ %s / %s files\\n\" \\\n \"rsync $TARGET_DATE/ → NAS\" \"$COPIED_FILES\" \"$SRC_FILES\" | tee -a \"$LOG_FILE\"\n fi\nelse\n printf \" %-36s %s\\n\" \"rsync $TARGET_DATE/ → NAS\" \"skipped (no source dir)\"\nfi\n\n# ─── SUMMARY ──────────────────────────────────────────────────────────────────\nTOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))\nDB_SIZE=$(du -sh \"$NAS_DB\" | cut -f1)\n\necho \"\"\nlog \"Archive DB size: $DB_SIZE\"\nlog \"Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s\"\nlog \"Sync complete for $TARGET_DATE\"\nlog \"========================================\"","role_description":"editor","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"#!/bin/bash\n# screenpipe_sync.sh\n# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).\n# Also copies the day's video/frame data folder to the NAS.\n#\n# Usage:\n# ./screenpipe_sync.sh # syncs yesterday (default)\n# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date\n# ./screenpipe_sync.sh today # syncs today so far\n#\n# Cron example (runs at 3am daily):\n# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1\n\nset -euo pipefail\n\n# ─── CONFIG ───────────────────────────────────────────────────────────────────\nDB_SRC=\"${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}\"\nNAS_MOUNT=\"${NAS_MOUNT:-/Volumes/Test/screenpipe}\"\nNAS_DB=\"$NAS_MOUNT/archive.db\"\nNAS_DATA=\"$NAS_MOUNT/data\"\nLOG_FILE=\"$HOME/.screenpipe/sync.log\"\n# ──────────────────────────────────────────────────────────────────────────────\n\n# ─── HELPERS ──────────────────────────────────────────────────────────────────\nSCRIPT_START=$(date +%s)\n\nlog() {\n local msg=\"[$(date '+%Y-%m-%d %H:%M:%S')] $*\"\n echo \"$msg\" | tee -a \"$LOG_FILE\"\n}\n\nstep() {\n local now=$(date +%s)\n local elapsed=$(( now - SCRIPT_START ))\n local min=$(( elapsed / 60 ))\n local sec=$(( elapsed % 60 ))\n printf \"\\n[+%02dm%02ds] ▶ %s\\n\" \"$min\" \"$sec\" \"$*\" | tee -a \"$LOG_FILE\"\n}\n\nrun_sqlite_heredoc() {\n local label=\"$1\"\n local sql=\"$2\"\n local start=$(date +%s)\n\n printf \" %-36s \" \"$label\"\n\n sqlite3 \"$DB_SRC\" <<< \"$sql\" &\n local pid=$!\n local spin=('⠋' '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')\n local i=0\n while kill -0 \"$pid\" 2>/dev/null; do\n printf \"\\r %-36s %s \" \"$label\" \"${spin[$i]}\"\n i=$(( (i + 1) % 10 ))\n sleep 0.2\n done\n wait \"$pid\"\n local rc=$?\n if [ $rc -ne 0 ]; then\n printf \"\\r %-36s ✗ FAILED\\n\" \"$label\" | tee -a \"$LOG_FILE\"\n exit $rc\n fi\n\n local dur=$(( $(date +%s) - start ))\n printf \"\\r %-36s ✓ %dm%02ds\\n\" \"$label\" \"$(( dur / 60 ))\" \"$(( dur % 60 ))\" | tee -a \"$LOG_FILE\"\n}\n\ncheck() {\n local label=\"$1\" got=\"$2\" expected=\"$3\"\n if [ \"$got\" -eq \"$expected\" ]; then\n printf \" %-20s %s / %s ✓\\n\" \"$label:\" \"$got\" \"$expected\"\n else\n printf \" %-20s %s / %s ✗ MISMATCH\\n\" \"$label:\" \"$got\" \"$expected\"\n fi\n}\n# ──────────────────────────────────────────────────────────────────────────────\n\n# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────\nif [ \"${1:-}\" = \"today\" ]; then\n TARGET_DATE=$(date +%Y-%m-%d)\nelif [ -n \"${1:-}\" ]; then\n TARGET_DATE=\"$1\"\n if ! [[ \"$TARGET_DATE\" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then\n echo \"ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday.\"\n exit 1\n fi\nelse\n TARGET_DATE=$(date -v-1d +%Y-%m-%d)\nfi\n\nlog \"========================================\"\nlog \"Screenpipe sync starting for: $TARGET_DATE\"\nlog \"========================================\"\n\n# ─── PREFLIGHT ────────────────────────────────────────────────────────────────\nstep \"Preflight checks\"\n\nif [ ! -f \"$DB_SRC\" ]; then\n log \"ERROR: Source DB not found at $DB_SRC\"; exit 1\nfi\nprintf \" %-20s %s (%s)\\n\" \"Source DB:\" \"OK\" \"$(du -sh \"$DB_SRC\" | cut -f1)\"\n\nif [ ! -d \"$NAS_MOUNT\" ]; then\n log \"ERROR: NAS not mounted at $NAS_MOUNT\"; exit 1\nfi\nprintf \" %-20s %s\\n\" \"NAS mount:\" \"OK $NAS_MOUNT\"\n\n# Check if DB already synced for this date\nDB_ALREADY_SYNCED=false\nif [ -f \"$NAS_DB\" ]; then\n EXISTING=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\" 2>/dev/null || echo \"0\")\n if [ \"$EXISTING\" -gt \"0\" ]; then\n log \"Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync\"\n DB_ALREADY_SYNCED=true\n else\n printf \" %-20s %s (%s)\\n\" \"Archive DB:\" \"exists\" \"$(du -sh \"$NAS_DB\" | cut -f1)\"\n fi\nelse\n printf \" %-20s %s\\n\" \"Archive DB:\" \"will be created\"\nfi\n\n# Source data dir for this date\nDATA_SRC=\"$HOME/.screenpipe/data/data/$TARGET_DATE\"\nif [ -d \"$DATA_SRC\" ]; then\n DATA_SIZE=$(du -sh \"$DATA_SRC\" | cut -f1)\n DATA_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n printf \" %-20s %s (%s files, %s)\\n\" \"Data dir:\" \"OK\" \"$DATA_FILES\" \"$DATA_SIZE\"\nelse\n printf \" %-20s %s\\n\" \"Data dir:\" \"not found — skipping file copy\"\nfi\n\n# ─── DB SYNC ──────────────────────────────────────────────────────────────────\nif [ \"$DB_ALREADY_SYNCED\" = false ]; then\n\n # ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────\n step \"Counting source rows for $TARGET_DATE\"\n\n SRC_FRAMES=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\")\n SRC_ELEMENTS=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n SRC_UI=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';\")\n SRC_OCR=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n SRC_MEETINGS=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';\")\n\n printf \" %-20s %s\\n\" \"frames:\" \"$SRC_FRAMES\"\n printf \" %-20s %s\\n\" \"elements:\" \"$SRC_ELEMENTS\"\n printf \" %-20s %s\\n\" \"ui_events:\" \"$SRC_UI\"\n printf \" %-20s %s\\n\" \"ocr_text:\" \"$SRC_OCR\"\n printf \" %-20s %s\\n\" \"meetings:\" \"$SRC_MEETINGS\"\n\n if [ \"$SRC_FRAMES\" -eq \"0\" ]; then\n log \"No frames found for $TARGET_DATE — skipping DB sync\"\n DB_ALREADY_SYNCED=true\n fi\n\nfi\n\nif [ \"$DB_ALREADY_SYNCED\" = false ]; then\n\n # ─── INIT TABLES ──────────────────────────────────────────────────────────\n step \"Initialising tables, indexes, FTS\"\n\n run_sqlite_heredoc \"creating tables\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"creating indexes\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);\nCREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);\nCREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"creating FTS tables\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(\n text, role, frame_id UNINDEXED,\n content='elements', content_rowid='id', tokenize='unicode61'\n);\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(\n full_text, app_name, window_name, browser_url, id UNINDEXED,\n tokenize='unicode61'\n);\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(\n text_content,\n app_name,\n window_title,\n element_name,\n content='ui_events',\n content_rowid='id',\n tokenize='unicode61'\n);\nDETACH nas;\n\"\n\n # ─── SYNC DATA ────────────────────────────────────────────────────────────\n step \"Syncing data for $TARGET_DATE\"\n\n run_sqlite_heredoc \"video_chunks\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.video_chunks\n SELECT * FROM main.video_chunks\n WHERE id IN (\n SELECT DISTINCT video_chunk_id FROM main.frames\n WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL\n );\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames ($SRC_FRAMES rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.frames\n SELECT * FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ocr_text ($SRC_OCR rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ocr_text\n SELECT o.* FROM main.ocr_text o\n JOIN main.frames f ON o.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events ($SRC_UI rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ui_events\n SELECT * FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"elements ($SRC_ELEMENTS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.elements\n SELECT e.* FROM main.elements e\n JOIN main.frames f ON e.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"meetings ($SRC_MEETINGS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.meetings\n SELECT * FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n # ─── FTS UPDATE ───────────────────────────────────────────────────────────\n step \"Updating FTS indexes\"\n\n run_sqlite_heredoc \"elements_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.elements_fts(rowid, text, role)\n SELECT e.id, e.text, e.role\n FROM nas.elements e\n JOIN nas.frames f ON e.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE'\n AND e.text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)\n SELECT id, full_text, app_name, window_name, browser_url, id\n FROM nas.frames\n WHERE date(timestamp) = '$TARGET_DATE'\n AND full_text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)\n SELECT id, text_content, app_name, window_title, element_name\n FROM nas.ui_events\n WHERE date(timestamp) = '$TARGET_DATE'\n AND text_content IS NOT NULL;\nDETACH nas;\n\"\n\n # ─── VERIFY DB ────────────────────────────────────────────────────────────\n step \"Verifying DB\"\n\n V_FRAMES=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\")\n V_ELEMENTS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n V_UI=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';\")\n V_OCR=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n V_MEETINGS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';\")\n\n check \"frames\" \"$V_FRAMES\" \"$SRC_FRAMES\"\n check \"elements\" \"$V_ELEMENTS\" \"$SRC_ELEMENTS\"\n check \"ui_events\" \"$V_UI\" \"$SRC_UI\"\n check \"ocr_text\" \"$V_OCR\" \"$SRC_OCR\"\n check \"meetings\" \"$V_MEETINGS\" \"$SRC_MEETINGS\"\n\nfi\n\n# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────\n# Always runs regardless of DB sync status\nstep \"Copying data folder for $TARGET_DATE\"\n\nif [ -d \"$DATA_SRC\" ]; then\n mkdir -p \"$NAS_DATA/$TARGET_DATE\"\n RSYNC_START=$(date +%s)\n printf \" %-36s \" \"rsync $TARGET_DATE/ → NAS\"\n rsync -a --ignore-existing \\\n \"$DATA_SRC/\" \\\n \"$NAS_DATA/$TARGET_DATE/\" \\\n 2>>\"$LOG_FILE\"\n RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))\n COPIED_FILES=$(ls \"$NAS_DATA/$TARGET_DATE\" | wc -l | tr -d ' ')\n SRC_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n COPIED_SIZE=$(du -sh \"$NAS_DATA/$TARGET_DATE\" | cut -f1)\n if [ \"$COPIED_FILES\" -eq \"$SRC_FILES\" ]; then\n printf \"\\r %-36s ✓ %dm%02ds (%s files, %s)\\n\" \\\n \"rsync $TARGET_DATE/ → NAS\" \\\n \"$(( RSYNC_DUR / 60 ))\" \"$(( RSYNC_DUR % 60 ))\" \\\n \"$COPIED_FILES\" \"$COPIED_SIZE\" | tee -a \"$LOG_FILE\"\n else\n printf \"\\r %-36s ✗ %s / %s files\\n\" \\\n \"rsync $TARGET_DATE/ → NAS\" \"$COPIED_FILES\" \"$SRC_FILES\" | tee -a \"$LOG_FILE\"\n fi\nelse\n printf \" %-36s %s\\n\" \"rsync $TARGET_DATE/ → NAS\" \"skipped (no source dir)\"\nfi\n\n# ─── SUMMARY ──────────────────────────────────────────────────────────────────\nTOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))\nDB_SIZE=$(du -sh \"$NAS_DB\" | cut -f1)\n\necho \"\"\nlog \"Archive DB size: $DB_SIZE\"\nlog \"Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s\"\nlog \"Sync complete for $TARGET_DATE\"\nlog \"========================================\"","depth":29,"bounds":{"left":0.13763298,"top":0.16041501,"width":0.35804522,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Implement and run pipe l…, Editor Group 2","depth":28,"bounds":{"left":0.5578458,"top":0.047885075,"width":0.073803194,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":false},{"role":"AXRadioButton","text":"Problems (⇧⌘M)","depth":22,"bounds":{"left":0.118351065,"top":0.7278532,"width":0.027925532,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"PROBLEMS","depth":24,"bounds":{"left":0.122340426,"top":0.7366321,"width":0.019946808,"height":0.0103751},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Output (⇧⌘U)","depth":22,"bounds":{"left":0.14594415,"top":0.7278532,"width":0.023603724,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUTPUT","depth":24,"bounds":{"left":0.14993352,"top":0.7366321,"width":0.015625,"height":0.0103751},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Debug Console (⇧⌘Y)","depth":22,"bounds":{"left":0.16921543,"top":0.7278532,"width":0.039893616,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"DEBUG CONSOLE","depth":24,"bounds":{"left":0.1732048,"top":0.7366321,"width":0.031914894,"height":0.0103751},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Terminal (⌃`)","depth":22,"bounds":{"left":0.2087766,"top":0.7278532,"width":0.026595745,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":true},{"role":"AXStaticText","text":"TERMINAL","depth":24,"bounds":{"left":0.21276596,"top":0.7366321,"width":0.01861702,"height":0.0103751},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Ports - 1 forwarded port","depth":22,"bounds":{"left":0.23537233,"top":0.7278532,"width":0.026263298,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"PORTS","depth":24,"bounds":{"left":0.2393617,"top":0.7366321,"width":0.012300532,"height":0.0103751},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":25,"bounds":{"left":0.25465426,"top":0.73743016,"width":0.0019946808,"height":0.008778931},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"remote SSH: nas","depth":16,"bounds":{"left":0.0006648936,"top":0.98244214,"width":0.028590426,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.0033244682,"top":0.9848364,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"SSH: nas","depth":17,"bounds":{"left":0.008643617,"top":0.9856345,"width":0.017952127,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"screenpipe (Git) - master*, Checkout Branch/Tag...","depth":16,"bounds":{"left":0.030917553,"top":0.98244214,"width":0.023271276,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.031914894,"top":0.9848364,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"master*","depth":17,"bounds":{"left":0.03723404,"top":0.9856345,"width":0.015957447,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"screenpipe (Git) - Synchronize Changes","depth":16,"bounds":{"left":0.05418883,"top":0.98244214,"width":0.00731383,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"No Problems","depth":16,"bounds":{"left":0.06416223,"top":0.98244214,"width":0.022606382,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.06582447,"top":0.9848364,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"0","depth":17,"bounds":{"left":0.07114362,"top":0.9856345,"width":0.004986702,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.07579787,"top":0.9848364,"width":0.0056515955,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"0","depth":17,"bounds":{"left":0.08111702,"top":0.9856345,"width":0.0039893617,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Forwarded Ports: 8766","depth":16,"bounds":{"left":0.08843085,"top":0.98244214,"width":0.012632979,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.09009308,"top":0.9848364,"width":0.0056515955,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":17,"bounds":{"left":0.09541223,"top":0.9856345,"width":0.0039893617,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Notifications","depth":16,"bounds":{"left":0.9886968,"top":0.98244214,"width":0.010638298,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sign In","depth":16,"bounds":{"left":0.9650931,"top":0.98244214,"width":0.022606382,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.96675533,"top":0.9848364,"width":0.0056515955,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Sign In","depth":17,"bounds":{"left":0.97207445,"top":0.9856345,"width":0.013962766,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Shell Script","depth":16,"bounds":{"left":0.93916225,"top":0.98244214,"width":0.023603724,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Editor Language Status: Inline Suggestions, next: $(copilot) No inline suggestion available, Inline suggestions","depth":16,"bounds":{"left":0.9318484,"top":0.98244214,"width":0.00731383,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"LF","depth":16,"bounds":{"left":0.9212101,"top":0.98244214,"width":0.007978723,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"UTF-8","depth":16,"bounds":{"left":0.90359044,"top":0.98244214,"width":0.015625,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Spaces: 2","depth":16,"bounds":{"left":0.8796542,"top":0.98244214,"width":0.022273935,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Ln 352, Col 47 (13096 selected)","depth":16,"bounds":{"left":0.8125,"top":0.98244214,"width":0.06549202,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"git-commit Lukas Kovalik (2 weeks ago)","depth":16,"bounds":{"left":0.74800533,"top":0.98244214,"width":0.062832445,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.7496675,"top":0.9848364,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Lukas Kovalik (2 weeks ago)","depth":17,"bounds":{"left":0.7549867,"top":0.9856345,"width":0.05418883,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"No results found","depth":12,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Implement and run pipe logic","depth":19,"bounds":{"left":0.56017286,"top":0.08060654,"width":0.07114362,"height":0.022346368},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Session history","depth":19,"bounds":{"left":0.9780585,"top":0.08060654,"width":0.00930851,"height":0.022346368},"on_screen":true,"help_text":"Session history","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"New session","depth":19,"bounds":{"left":0.9886968,"top":0.08060654,"width":0.00930851,"height":0.022346368},"on_screen":true,"help_text":"New session","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Message actions","depth":24,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"main.py","depth":23,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"lets implement logic with pipes. how can I run it?","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Let me look at the current project structure to understand what's already in place.","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"List project files","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"find /volume1/screenpipe -type f | head -50 && echo \"---\" && ls /volume1/screenpipe","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"/volume1/screenpipe/.DS_Store\n/volume1/screenpipe/screenpipe.db\n/volume1/screenpipe/screenpipe_sync.sh\n/volume1/screenpipe/app_settings.json\n/volume1/screenpipe/.gitignore\n/volume1/screenpipe/archive.db\n/volume1/screenpipe/db.sqlite\n/volume1/screenpipe/db.sqlite-wal\n/volume1/screenpipe/db.sqlite-shm\n/volume1/screenpipe/#recycle/desktop.ini\n/volume1/screenpipe/#recycle/db.sqlite\n/volume1/screenpipe/#recycle/Copy #1 of db.sqlite\n/volume1/screenpipe/#recycle/.DS_Store\n/volume1/screenpipe/#recycle/Copy #2 of db.sqlite\n/volume1/screenpipe/#recycle/archive.db\n/volume1/screenpipe/#recycle/Copy #1 of archive.db\n/volume1/screenpipe/#recycle/Copy #2 of archive.db\n/volume1/screenpipe/#recycle/Copy #3 of archive.db\n/volume1/screenpipe/#recycle/Copy #4 of archive.db\n/volume1/screenpipe/#recycle/Copy #5 of archive.db\n/volume1/screenpipe/#recycle/Copy #3 of db.sqlite\n/volume1/screenpipe/#recycle/Copy #4 of db.sqlite\n/volume1/screenpipe/#recycle/Copy #6 of archive.db\n/volume1/screenpipe/#recycle/test.txt\n/volume1/screenpipe/#recycle/Copy #7 of archive.db\n/volume1/screenpipe/#recycle/Copy #8 of archive.db\n/volume1/screenpipe/#recycle/archive.db-journal\n/volume1/screenpipe/#recycle/Copy #1 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #2 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #3 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #4 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #5 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #6 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #7 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #5 of db.sqlite\n/volume1/screenpipe/pipes/.DS_Store\n/volume1/screenpipe/app/.env\n/volume1/screenpipe/app/cli.py\n/volume1/screenpipe/app/.DS_Store\n/volume1/screenpipe/app/db.py\n/volume1/screenpipe/app/docker-compose.yml\n/volume1/screenpipe/app/main.py\n/volume1/screenpipe/app/requirements.txt\n/volume1/screenpipe/app/Dockerfile\n/volume1/screenpipe/data/.DS_Store\n/volume1/screenpipe/.git/description\n/volume1/screenpipe/.git/HEAD\n/volume1/screenpipe/.git/index\n/volume1/screenpipe/.git/COMMIT_EDITMSG\n/volume1/screenpipe/#recycle/data/.DS_Store\n---\napp\napp_settings.json\narchive.db\ndata\ndb.sqlite\ndb.sqlite-shm\ndb.sqlite-wal\npipes\n#recycle\nscreenpipe.db\nscreenpipe_sync.sh","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"main.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Check pipes directory and docker-compose","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/pipes/ && ls /volume1/screenpipe/app/ && cat /volume1/screenpipe/app/docker-compose.yml","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ai-habits\nday-recap\nmeeting-summary\nstandup-update\ntime-breakdown\nvideo-export\ncli.py\nconsumers\ndb.py\ndocker-compose.yml\nDockerfile\nmain.py\n__pycache__\nrequirements.txt\nstatic\nservices:\n screenpipe-app:\n build: .\n container_name: screenpipe-app\n restart: unless-stopped\n ports:\n - \"8766:8000\"\n volumes:\n - /volume1/screenpipe:/data\n env_file:\n - .env\n environment:\n TZ: Europe/Sofia\n DB_PATH: /data/db.sqlite\n\n sqlite-web-archive:\n image: ghcr.io/coleifer/sqlite-web:latest\n container_name: screenpipe-sqlweb-archive\n restart: unless-stopped\n ports:\n - \"8767:8080\"\n volumes:\n - /volume1/screenpipe:/data\n command: [\"-H\", \"0.0.0.0\", \"-r\", \"/data/archive.db\"]\n\n sqlite-web-live:\n image: ghcr.io/coleifer/sqlite-web:latest\n container_name: screenpipe-sqlweb-live\n restart: unless-stopped\n ports:\n - \"8768:8080\"\n volumes:\n - /volume1/screenpipe:/data\n command: [\"-H\", \"0.0.0.0\", \"-r\", \"/data/db.sqlite\"]","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"requirements.txt","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"requirements.txt","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Inspect a pipe directory","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/pipes/day-recap/ && cat /volume1/screenpipe/pipes/day-recap/pipe.json 2>/dev/null || ls /volume1/screenpipe/pipes/day-recap/","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"pipe.md\npipe.md","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"cli.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"cli.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"List all pipes and their contents","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/pipes/ && for d in /volume1/screenpipe/pipes/*/; do echo \"=== $d ===\"; ls \"$d\"; done","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ai-habits\nday-recap\nmeeting-summary\nstandup-update\ntime-breakdown\nvideo-export\n=== /volume1/screenpipe/pipes/ai-habits/ ===\npipe.md\n=== /volume1/screenpipe/pipes/day-recap/ ===\npipe.md\n=== /volume1/screenpipe/pipes/meeting-summary/ ===\npipe.md\n=== /volume1/screenpipe/pipes/standup-update/ ===\npipe.md\n=== /volume1/screenpipe/pipes/time-breakdown/ ===\npipe.md\n=== /volume1/screenpipe/pipes/video-export/ ===\npipe.md","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read pipe markdown files","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"cat /volume1/screenpipe/pipes/day-recap/pipe.md && echo \"===\" && cat /volume1/screenpipe/pipes/meeting-summary/pipe.md 2>/dev/null | head -50","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Day Recap\ndescription: \"Today's accomplishments, key moments, and unfinished work\"\nicon: \"📋\"\nfeatured: true\n---\n\nAnalyze my screen and audio recordings from today (last 16 hours only). \n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Summary\nOne sentence: what I mainly did today.\n\n## Accomplishments\n- Top 3 things I finished, with timestamps (e.g. \"2:30 PM\")\n- Name specific apps, files, or projects\n\n## Key Moments\n- Important things I saw, said, or heard — with timestamps\n\n## Unfinished Work\n- What I should continue tomorrow — name the app/file/task\n\n## Patterns\n- Apps I used most, topics that came up repeatedly\n\nOnly report what you can verify from the data. End with: \"**Next step:** [most important thing to continue]\"\n===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Meeting Summary\ndescription: \"Summarize meeting transcript with key takeaways and action items\"\nicon: \"🤝\"\nfeatured: false\n---\n\nSummarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.\n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Meeting Summary\nOne sentence: what this meeting was about.\n\n## Key Takeaways\n- Top 3-5 important points discussed\n- Include who said what when relevant\n\n## Action Items\n- [ ] Task — assigned to whom, deadline if mentioned\n- [ ] Task — assigned to whom\n\n## Decisions Made\n- List any decisions or agreements reached\n\n## Open Questions\n- Anything unresolved or needing follow-up\n\nKeep it concise and actionable.","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read summary consumer","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/app/consumers/ && cat /volume1/screenpipe/app/consumers/summary.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"activity.py\naudio.py\nelements.py\n__init__.py\ninteractions.py\nocr.py\n__pycache__\nreport.py\nsummary.py\n\"\"\"AI summary generator using Claude.\"\"\"\nimport os\nfrom datetime import date\nfrom typing import Any\n\nfrom consumers.activity import app_time, summary_stats, browser_urls, ui_event_summary\nfrom consumers.ocr import deduplicated_text\nfrom consumers.audio import formatted_transcript\n\n\nSUMMARY_TYPES = {\n \"day_recap\": {\n \"title\": \"Day Recap\",\n \"prompt\": \"\"\"\\\nYou are analyzing a person's computer activity for the day.\n\n## App usage (minutes per app):\n{app_time}\n\n## Browser URLs visited:\n{browser_urls}\n\n## UI activity per app (clicks / keystrokes / app-switches):\n{ui_events}\n\n## Screen content (sampled every 5 minutes):\n{ocr_text}\n\n## Audio/speech:\n{audio}\n\nWrite a concise day recap using EXACTLY this format:\n\n## Summary\nOne sentence: what I mainly worked on today.\n\n## Accomplishments\n- Top 3 things I finished, with approximate times\n- Name specific apps, files, or projects\n\n## Key Moments\n- Important things seen or heard, with timestamps\n\n## Unfinished Work\n- What to continue tomorrow\n\n## Patterns\n- Apps used most, topics that came up repeatedly\n\nOnly report what you can verify from the data. End with:\n**Next step:** [most important thing to continue]\"\"\",\n },\n \"standup\": {\n \"title\": \"Standup Update\",\n \"prompt\": \"\"\"\\\nYou are analyzing a person's computer activity for the day.\n\n## App usage (minutes per app):\n{app_time}\n\n## Browser URLs visited:\n{browser_urls}\n\n## UI activity per app (clicks / keystrokes / app-switches):\n{ui_events}\n\n## Screen content (sampled every 5 minutes):\n{ocr_text}\n\n## Audio/speech:\n{audio}\n\nWrite a brief standup update:\n\n**Yesterday:** What I worked on (2-3 bullets)\n**Today:** What I plan to continue (1-2 bullets)\n**Blockers:** Any issues observed (or \"None\")\n\nKeep it under 150 words. Only report what's verifiable from the data.\"\"\",\n },\n \"focus_time\": {\n \"title\": \"Focus & Distraction Analysis\",\n \"prompt\": \"\"\"\\\nYou are analyzing a person's computer activity for the day.\n\n## App usage (minutes per app):\n{app_time}\n\n## Browser URLs visited:\n{browser_urls}\n\n## UI activity per app (clicks / keystrokes / app-switches):\n{ui_events}\n\n## Screen content (sampled every 5 minutes):\n{ocr_text}\n\nAnalyze focus vs distraction patterns:\n\n## Deep Work Periods\n- When and how long were sustained focus sessions?\n- What was being worked on?\n\n## Distractions\n- Which apps/sites were used recreationally?\n- How much time was lost to context switching?\n\n## Recommendations\n- 2-3 concrete suggestions to improve focus tomorrow\n\nBe specific with times and app names.\"\"\",\n },\n}\n\n\ndef _build_context(for_date: date) -> dict[str, str]:\n apps = app_time(for_date)\n app_lines = \"\\n\".join(f\"- {a['app_name']}: {a['minutes']} min\" for a in apps[:20])\n\n urls = browser_urls(for_date, limit=20)\n url_lines = \"\\n\".join(\n f\"- {u['browser_url'][:100]} ({u['minutes']} min)\" for u in urls\n )\n\n ui_rows = ui_event_summary(for_date)\n ui_lines = \"\\n\".join(\n f\"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches\"\n for r in ui_rows[:15]\n )\n\n ocr_rows = deduplicated_text(for_date, chunk_minutes=5)\n ocr_lines = \"\\n\".join(\n f\"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}\"\n for r in ocr_rows[:100]\n )\n\n audio = formatted_transcript(for_date)\n\n return {\n \"app_time\": app_lines or \"(no app data)\",\n \"browser_urls\": url_lines or \"(no browser data)\",\n \"ui_events\": ui_lines or \"(no UI event data)\",\n \"ocr_text\": ocr_lines or \"(no screen data)\",\n \"audio\": audio[:3000] if len(audio) > 3000 else audio,\n }\n\n\ndef generate(\n summary_type: str = \"day_recap\",\n for_date: date | None = None,\n api_key: str | None = None,\n) -> dict[str, Any]:\n \"\"\"Generate an AI summary. Returns dict with 'title', 'content', 'date'.\"\"\"\n import anthropic\n\n d = for_date or date.today()\n key = api_key or os.environ.get(\"ANTHROPIC_API_KEY\", \"\")\n if not key:\n return {\n \"title\": \"Error\",\n \"content\": \"ANTHROPIC_API_KEY not set. Add it to your .env file.\",\n \"date\": str(d),\n }\n\n spec = SUMMARY_TYPES.get(summary_type)\n if not spec:\n return {\"title\": \"Error\", \"content\": f\"Unknown summary type: {summary_type}\", \"date\": str(d)}\n\n stats = summary_stats(d)\n if stats[\"total_frames\"] == 0:\n return {\n \"title\": spec[\"title\"],\n \"content\": f\"No screen data found for {d}.\",\n \"date\": str(d),\n }\n\n ctx = _build_context(d)\n prompt = spec[\"prompt\"].format(**ctx)\n\n client = anthropic.Anthropic(api_key=key)\n message = client.messages.create(\n model=\"claude-haiku-4-5-20251001\",\n max_tokens=1024,\n messages=[{\"role\": \"user\", \"content\": prompt}],\n )\n\n return {\n \"title\": spec[\"title\"],\n \"content\": message.content[0].text,\n \"date\": str(d),\n \"stats\": stats,\n }","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read all pipe.md files","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"for f in /volume1/screenpipe/pipes/*/pipe.md; do echo \"=== $f ===\"; cat \"$f\"; echo; done","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"=== /volume1/screenpipe/pipes/ai-habits/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: AI Habits\ndescription: \"How you use AI tools — patterns and insights\"\nicon: \"🤖\"\nfeatured: true\n---\n\nSearch my recordings from the last 24 hours for AI tool usage. Use app_name filter for each tool separately: ChatGPT, Claude, Copilot, Cursor, Gemini, Perplexity. Use limit=5 per search, max 6 searches total.\n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## AI Tools Used\n- List each tool with approximate time spent (e.g. \"Claude: ~45min\")\n\n## What I Used Them For\n- For each tool: coding, writing, research, or brainstorming\n\n## Usage Patterns\n- Do I switch between tools? Use them in bursts or steadily?\n\n## Effectiveness\n- Which tool appeared alongside completed work vs. abandoned attempts\n\nIf no AI usage is found, say so clearly. End with: \"**Tip:** [one suggestion to use AI tools more effectively]\"\n\n=== /volume1/screenpipe/pipes/day-recap/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Day Recap\ndescription: \"Today's accomplishments, key moments, and unfinished work\"\nicon: \"📋\"\nfeatured: true\n---\n\nAnalyze my screen and audio recordings from today (last 16 hours only). \n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Summary\nOne sentence: what I mainly did today.\n\n## Accomplishments\n- Top 3 things I finished, with timestamps (e.g. \"2:30 PM\")\n- Name specific apps, files, or projects\n\n## Key Moments\n- Important things I saw, said, or heard — with timestamps\n\n## Unfinished Work\n- What I should continue tomorrow — name the app/file/task\n\n## Patterns\n- Apps I used most, topics that came up repeatedly\n\nOnly report what you can verify from the data. End with: \"**Next step:** [most important thing to continue]\"\n\n=== /volume1/screenpipe/pipes/meeting-summary/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Meeting Summary\ndescription: \"Summarize meeting transcript with key takeaways and action items\"\nicon: \"🤝\"\nfeatured: false\n---\n\nSummarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.\n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Meeting Summary\nOne sentence: what this meeting was about.\n\n## Key Takeaways\n- Top 3-5 important points discussed\n- Include who said what when relevant\n\n## Action Items\n- [ ] Task — assigned to whom, deadline if mentioned\n- [ ] Task — assigned to whom\n\n## Decisions Made\n- List any decisions or agreements reached\n\n## Open Questions\n- Anything unresolved or needing follow-up\n\nKeep it concise and actionable.\n\n=== /volume1/screenpipe/pipes/standup-update/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Standup Update\ndescription: \"What you did, what's next, and any blockers\"\nicon: \"🏢\"\nfeatured: true\n---\n\nBased on my recordings from the last 24 hours, generate a standup update. Use limit=10 per search, max 3 searches total.\n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Yesterday\n- What I worked on (name specific projects, files, tools, PRs)\n\n## Today\n- What I will work on next (based on unfinished tasks and recent activity)\n\n## Blockers\n- Issues I hit — errors, slow builds, waiting on someone\n- If no blockers, write \"None\"\n\nKeep it under 150 words. Copy-paste ready for a team standup.\n\n=== /volume1/screenpipe/pipes/time-breakdown/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Time Breakdown\ndescription: \"Where your time went — by app, project, and category\"\nicon: \"⏱\"\nfeatured: false\n---\n\nAnalyze my app usage from today (last 12 hours). Use limit=10 per search, max 4 searches. Prefer /raw_sql with COUNT/GROUP BY queries.\n\nRead screenpipe skill first.\n\nUse this exact format with durations and percentages:\n\n## By Application\n- List each app with duration and percentage, sorted by time (e.g. \"VS Code: 2h 15min (28%)\")\n\n## By Category\n- Group into: coding, meetings, browsing, writing, communication, other\n- Show hours and percentage per category\n\n## By Project\n- Group related activities by project/topic. Name specific repos or tasks.\n\n## Productivity Score\n- Calculate: focused_work_hours / total_hours as a percentage\n- Focused = coding + writing. Unfocused = browsing + switching.\n\nEnd with: \"**Suggestion:** [one specific change to improve tomorrow's productivity]\"\n\n=== /volume1/screenpipe/pipes/video-export/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Export Video Clip\ndescription: \"Create a video of your recent screen activity\"\nicon: \"🎬\"\nfeatured: false\n---\n\nExport a video of my screen activity from the last 5 minutes.\n\nRead screenpipe skill first.\n\nUse the POST /frames/export endpoint with the time range and fps=1.0. Then show me the exported video file path as an inline code block so I can watch it.\n\nIf the export is large, suggest a lower fps or shorter time range.","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Now I have a clear picture. The pipes are markdown prompt templates in","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"/volume1/screenpipe/pipes/","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":", but there's no code to actually load and run them —","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"consumers/summary.py","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"has its own hardcoded prompts instead.","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Here's what I'll implement:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"consumers/pipes.py","depth":26,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"— dynamically loads pipe.md files and runs them via Claude (data injected as system message, pipe body as user prompt)","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"main.py","depth":26,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"— two new endpoints:","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"GET /api/pipes","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"and","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"POST /api/pipes/{pipe_id}/run","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"cli.py","depth":26,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"— a","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"pipe","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"command to run pipes from the terminal","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Let me build it:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Check browser_urls signature","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"cat /volume1/screenpipe/app/consumers/activity.py | grep \"def browser_urls\" -A 5","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"def browser_urls(\n for_date: date | None = None,\n app_name: str | None = None,\n ts_from: str | None = None,\n ts_to: str | None = None,\n limit: int = 30,","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Write","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"pipes.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"pipes.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"143 lines","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"\"\"\"Dynamic pipe loader and runner.\"\"\"\nimport os\nimport re\nfrom datetime import date\nfrom pathlib import Path\nfrom typing import Any\n\n\ndef _parse_frontmatter(text: str) -> tuple[dict, str]:\n if not text.startswith(\"---\"):\n return {}, text\n try:\n end = text.index(\"---\", 3)\n except ValueError:\n return {}, text\n fm_text = text[3:end].strip()\n body = text[end + 3:].strip()\n meta: dict = {}\n for line in fm_text.splitlines():\n if \":\" in line:\n k, _, v = line.partition(\":\")\n meta[k.strip()] = v.strip().strip('\"')\n return meta, body\n\n\ndef load_pipes(pipes_dir: Path) -> list[dict]:\n if not pipes_dir.exists():\n return []\n pipes = []\n for pipe_dir in sorted(pipes_dir.iterdir()):\n if not pipe_dir.is_dir() or pipe_dir.name.startswith(\".\"):\n continue\n pipe_md = pipe_dir / \"pipe.md\"\n if not pipe_md.exists():\n continue\n text = pipe_md.read_text(encoding=\"utf-8\")\n meta, body = _parse_frontmatter(text)\n if meta.get(\"enabled\", \"true\").lower() == \"false\":\n continue\n body = re.sub(r\"Read screenpipe skill first\\.?\\n?\", \"\", body).strip()\n pipes.append({\n \"id\": pipe_dir.name,\n \"title\": meta.get(\"title\", pipe_dir.name),\n \"description\": meta.get(\"description\", \"\"),\n \"icon\": meta.get(\"icon\", \"\"),\n \"schedule\": meta.get(\"schedule\", \"manual\"),\n \"featured\": meta.get(\"featured\", \"false\").lower() == \"true\",\n \"prompt\": body,\n })\n return pipes\n\n\ndef _build_system(d: date, stats: dict) -> str:\n from consumers.activity import app_time, browser_urls, ui_event_summary\n from consumers.ocr import deduplicated_text\n from consumers.audio import formatted_transcript\n\n apps = app_time(d)\n app_lines = \"\\n\".join(f\"- {a['app_name']}: {a['minutes']} min\" for a in apps[:20])\n\n urls = browser_urls(d, limit=20)\n url_lines = \"\\n\".join(f\"- {u['browser_url'][:100]} ({u['minutes']} min)\" for u in urls)\n\n ui_rows = ui_event_summary(d)\n ui_lines = \"\\n\".join(\n f\"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches\"\n for r in ui_rows[:15]\n )\n\n ocr_rows = deduplicated_text(d, chunk_minutes=5)\n ocr_lines = \"\\n\".join(\n f\"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}\"\n for r in ocr_rows[:100]\n )\n\n audio = formatted_transcript(d)\n if len(audio) > 3000:\n audio = audio[:3000]\n\n return f\"\"\"You are analyzing screenpipe data — recordings of a person's computer activity.\n\n## App usage (minutes per app):\n{app_lines or '(no app data)'}\n\n## Browser URLs visited:\n{url_lines or '(no browser data)'}\n\n## UI activity per app (clicks / keystrokes / app-switches):\n{ui_lines or '(no UI event data)'}\n\n## Screen content (sampled every 5 minutes):\n{ocr_lines or '(no screen data)'}\n\n## Audio / speech:\n{audio or '(no audio data)'}\n\nDate: {d}\nTotal frames recorded: {stats['total_frames']}\"\"\"\n\n\ndef run_pipe(\n pipe_id: str,\n for_date: date | None = None,\n api_key: str | None = None,\n pipes_dir: Path | None = None,\n) -> dict[str, Any]:\n import anthropic\n from consumers.activity import summary_stats\n\n d = for_date or date.today()\n key = api_key or os.environ.get(\"ANTHROPIC_API_KEY\", \"\")\n if not key:\n return {\"title\": \"Error\", \"content\": \"ANTHROPIC_API_KEY not set.\", \"date\": str(d)}\n\n _pipes_dir = pipes_dir or Path(os.environ.get(\"PIPES_DIR\", \"/data/pipes\"))\n all_pipes = {p[\"id\"]: p for p in load_pipes(_pipes_dir)}\n\n if pipe_id not in all_pipes:\n return {\"title\": \"Error\", \"content\": f\"Pipe not found: {pipe_id}\", \"date\": str(d)}\n\n pipe = all_pipes[pipe_id]\n stats = summary_stats(d)\n\n if stats[\"total_frames\"] == 0:\n return {\"title\": pipe[\"title\"], \"content\": f\"No screen data found for {d}.\", \"date\": str(d)}\n\n system = _build_system(d, stats)\n\n client = anthropic.Anthropic(api_key=key)\n message = client.messages.create(\n model=\"claude-haiku-4-5-20251001\",\n max_tokens=1024,\n system=system,\n messages=[{\"role\": \"user\", \"content\": pipe[\"prompt\"]}],\n )\n\n return {\n \"title\": pipe[\"title\"],\n \"content\": message.content[0].text,\n \"date\": str(d),\n \"stats\": stats,\n }","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Now add the API endpoints to","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"main.py","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":":","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Edit","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"main.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Added 1 line","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Edit","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"main.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Added 1 line","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Now add the pipe endpoints at the end of main.py, before the closing summary section:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Edit","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"main.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Added 14 lines","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Now add the CLI command to","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"cli.py","depth":23,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"cli.py","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":":","depth":23,"on_screen":false,"role_description":"text"}]...
|
-7544365287433738573
|
4472294119892815125
|
visual_change
|
accessibility
|
NULL
|
Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧ Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py
M
db.py
docker-compose.yml
Dockerfile
M
main.py
M
requirements.txt
M
data
logs
pipes
.gitignore
app_settings.json
archive.db
archive.db-bak
U
db.sqlite
db.sqlite-shm
db.sqlite-wal
screenpipe_sync_updated.sh
U
screenpipe_sync.sh
screenpipe.db
Outline Section
OUTLINE
OUTLINE
Timeline Section
TIMELINE
TIMELINE
app_settings.json, Editor Group 1
screenpipe_sync.sh, Editor Group 1
pipe.md, Editor Group 1
.env, Editor Group 1
#!/bin/bash
# screenpipe_sync.sh
# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).
# Also copies the day's video/frame data folder to the NAS.
#
# Usage:
# ./screenpipe_sync.sh # syncs yesterday (default)
# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date
# ./screenpipe_sync.sh today # syncs today so far
#
# Cron example (runs at 3am daily):
# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1
set -euo pipefail
# ─── CONFIG ───────────────────────────────────────────────────────────────────
DB_SRC="${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}"
NAS_MOUNT="${NAS_MOUNT:-/Volumes/Test/screenpipe}"
NAS_DB="$NAS_MOUNT/archive.db"
NAS_DATA="$NAS_MOUNT/data"
LOG_FILE="$HOME/.screenpipe/sync.log"
# ──────────────────────────────────────────────────────────────────────────────
# ─── HELPERS ──────────────────────────────────────────────────────────────────
SCRIPT_START=$(date +%s)
log() {
local msg="[$(date '+%Y-%m-%d %H:%M:%S')] $*"
echo "$msg" | tee -a "$LOG_FILE"
}
step() {
local now=$(date +%s)
local elapsed=$(( now - SCRIPT_START ))
local min=$(( elapsed / 60 ))
local sec=$(( elapsed % 60 ))
printf "\n[+%02dm%02ds] ▶ %s\n" "$min" "$sec" "$*" | tee -a "$LOG_FILE"
}
run_sqlite_heredoc() {
local label="$1"
local sql="$2"
local start=$(date +%s)
printf " %-36s " "$label"
sqlite3 "$DB_SRC" <<< "$sql" &
local pid=$!
local spin=[PASSWORD] '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')
local i=0
while kill -0 "$pid" 2>/dev/null; do
printf "\r %-36s %s " "$label" "${spin[$i]}"
i=$(( (i + 1) % 10 ))
sleep 0.2
done
wait "$pid"
local rc=$?
if [ $rc -ne 0 ]; then
printf "\r %-36s ✗ FAILED\n" "$label" | tee -a "$LOG_FILE"
exit $rc
fi
local dur=$(( $(date +%s) - start ))
printf "\r %-36s ✓ %dm%02ds\n" "$label" "$(( dur / 60 ))" "$(( dur % 60 ))" | tee -a "$LOG_FILE"
}
check() {
local label="$1" got="$2" expected="$3"
if [ "$got" -eq "$expected" ]; then
printf " %-20s %s / %s ✓\n" "$label:" "$got" "$expected"
else
printf " %-20s %s / %s ✗ MISMATCH\n" "$label:" "$got" "$expected"
fi
}
# ──────────────────────────────────────────────────────────────────────────────
# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────
if [ "${1:-}" = "today" ]; then
TARGET_DATE=$(date +%Y-%m-%d)
elif [ -n "${1:-}" ]; then
TARGET_DATE="$1"
if ! [[ "$TARGET_DATE" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then
echo "ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday."
exit 1
fi
else
TARGET_DATE=$(date -v-1d +%Y-%m-%d)
fi
log "========================================"
log "Screenpipe sync starting for: $TARGET_DATE"
log "========================================"
# ─── PREFLIGHT ────────────────────────────────────────────────────────────────
step "Preflight checks"
if [ ! -f "$DB_SRC" ]; then
log "ERROR: Source DB not found at $DB_SRC"; exit 1
fi
printf " %-20s %s (%s)\n" "Source DB:" "OK" "$(du -sh "$DB_SRC" | cut -f1)"
if [ ! -d "$NAS_MOUNT" ]; then
log "ERROR: NAS not mounted at $NAS_MOUNT"; exit 1
fi
printf " %-20s %s\n" "NAS mount:" "OK $NAS_MOUNT"
# Check if DB already synced for this date
DB_ALREADY_SYNCED=false
if [ -f "$NAS_DB" ]; then
EXISTING=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';" 2>/dev/null || echo "0")
if [ "$EXISTING" -gt "0" ]; then
log "Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync"
DB_ALREADY_SYNCED=true
else
printf " %-20s %s (%s)\n" "Archive DB:" "exists" "$(du -sh "$NAS_DB" | cut -f1)"
fi
else
printf " %-20s %s\n" "Archive DB:" "will be created"
fi
# Source data dir for this date
DATA_SRC="$HOME/.screenpipe/data/data/$TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
DATA_SIZE=$(du -sh "$DATA_SRC" | cut -f1)
DATA_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
printf " %-20s %s (%s files, %s)\n" "Data dir:" "OK" "$DATA_FILES" "$DATA_SIZE"
else
printf " %-20s %s\n" "Data dir:" "not found — skipping file copy"
fi
# ─── DB SYNC ──────────────────────────────────────────────────────────────────
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────
step "Counting source rows for $TARGET_DATE"
SRC_FRAMES=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
SRC_ELEMENTS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_UI=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
SRC_OCR=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_MEETINGS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';")
printf " %-20s %s\n" "frames:" "$SRC_FRAMES"
printf " %-20s %s\n" "elements:" "$SRC_ELEMENTS"
printf " %-20s %s\n" "ui_events:" "$SRC_UI"
printf " %-20s %s\n" "ocr_text:" "$SRC_OCR"
printf " %-20s %s\n" "meetings:" "$SRC_MEETINGS"
if [ "$SRC_FRAMES" -eq "0" ]; then
log "No frames found for $TARGET_DATE — skipping DB sync"
DB_ALREADY_SYNCED=true
fi
fi
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── INIT TABLES ──────────────────────────────────────────────────────────
step "Initialising tables, indexes, FTS"
run_sqlite_heredoc "creating tables" "
ATTACH '$NAS_DB' AS nas;
CREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;
CREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;
CREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;
CREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;
DETACH nas;
"
run_sqlite_heredoc "creating indexes" "
ATTACH '$NAS_DB' AS nas;
CREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);
CREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);
DETACH nas;
"
run_sqlite_heredoc "creating FTS tables" "
ATTACH '$NAS_DB' AS nas;
CREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(
text, role, frame_id UNINDEXED,
content='elements', content_rowid='id', tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(
full_text, app_name, window_name, browser_url, id UNINDEXED,
tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(
text_content,
app_name,
window_title,
element_name,
content='ui_events',
content_rowid='id',
tokenize='unicode61'
);
DETACH nas;
"
# ─── SYNC DATA ────────────────────────────────────────────────────────────
step "Syncing data for $TARGET_DATE"
run_sqlite_heredoc "video_chunks" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.video_chunks
SELECT * FROM main.video_chunks
WHERE id IN (
SELECT DISTINCT video_chunk_id FROM main.frames
WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL
);
DETACH nas;
"
run_sqlite_heredoc "frames ($SRC_FRAMES rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.frames
SELECT * FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ocr_text ($SRC_OCR rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ocr_text
SELECT o.* FROM main.ocr_text o
JOIN main.frames f ON o.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ui_events ($SRC_UI rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ui_events
SELECT * FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "elements ($SRC_ELEMENTS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.elements
SELECT e.* FROM main.elements e
JOIN main.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "meetings ($SRC_MEETINGS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.meetings
SELECT * FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';
DETACH nas;
"
# ─── FTS UPDATE ───────────────────────────────────────────────────────────
step "Updating FTS indexes"
run_sqlite_heredoc "elements_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.elements_fts(rowid, text, role)
SELECT e.id, e.text, e.role
FROM nas.elements e
JOIN nas.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE'
AND e.text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "frames_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)
SELECT id, full_text, app_name, window_name, browser_url, id
FROM nas.frames
WHERE date(timestamp) = '$TARGET_DATE'
AND full_text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "ui_events_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)
SELECT id, text_content, app_name, window_title, element_name
FROM nas.ui_events
WHERE date(timestamp) = '$TARGET_DATE'
AND text_content IS NOT NULL;
DETACH nas;
"
# ─── VERIFY DB ────────────────────────────────────────────────────────────
step "Verifying DB"
V_FRAMES=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
V_ELEMENTS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_UI=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
V_OCR=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_MEETINGS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';")
check "frames" "$V_FRAMES" "$SRC_FRAMES"
check "elements" "$V_ELEMENTS" "$SRC_ELEMENTS"
check "ui_events" "$V_UI" "$SRC_UI"
check "ocr_text" "$V_OCR" "$SRC_OCR"
check "meetings" "$V_MEETINGS" "$SRC_MEETINGS"
fi
# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────
# Always runs regardless of DB sync status
step "Copying data folder for $TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
mkdir -p "$NAS_DATA/$TARGET_DATE"
RSYNC_START=$(date +%s)
printf " %-36s " "rsync $TARGET_DATE/ → NAS"
rsync -a --ignore-existing \
"$DATA_SRC/" \
"$NAS_DATA/$TARGET_DATE/" \
2>>"$LOG_FILE"
RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))
COPIED_FILES=$(ls "$NAS_DATA/$TARGET_DATE" | wc -l | tr -d ' ')
SRC_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
COPIED_SIZE=$(du -sh "$NAS_DATA/$TARGET_DATE" | cut -f1)
if [ "$COPIED_FILES" -eq "$SRC_FILES" ]; then
printf "\r %-36s ✓ %dm%02ds (%s files, %s)\n" \
"rsync $TARGET_DATE/ → NAS" \
"$(( RSYNC_DUR / 60 ))" "$(( RSYNC_DUR % 60 ))" \
"$COPIED_FILES" "$COPIED_SIZE" | tee -a "$LOG_FILE"
else
printf "\r %-36s ✗ %s / %s files\n" \
"rsync $TARGET_DATE/ → NAS" "$COPIED_FILES" "$SRC_FILES" | tee -a "$LOG_FILE"
fi
else
printf " %-36s %s\n" "rsync $TARGET_DATE/ → NAS" "skipped (no source dir)"
fi
# ─── SUMMARY ──────────────────────────────────────────────────────────────────
TOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))
DB_SIZE=$(du -sh "$NAS_DB" | cut -f1)
echo ""
log "Archive DB size: $DB_SIZE"
log "Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s"
log "Sync complete for $TARGET_DATE"
log "========================================"
#!/bin/bash
# screenpipe_sync.sh
# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).
# Also copies the day's video/frame data folder to the NAS.
#
# Usage:
# ./screenpipe_sync.sh # syncs yesterday (default)
# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date
# ./screenpipe_sync.sh today # syncs today so far
#
# Cron example (runs at 3am daily):
# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1
set -euo pipefail
# ─── CONFIG ───────────────────────────────────────────────────────────────────
DB_SRC="${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}"
NAS_MOUNT="${NAS_MOUNT:-/Volumes/Test/screenpipe}"
NAS_DB="$NAS_MOUNT/archive.db"
NAS_DATA="$NAS_MOUNT/data"
LOG_FILE="$HOME/.screenpipe/sync.log"
# ──────────────────────────────────────────────────────────────────────────────
# ─── HELPERS ──────────────────────────────────────────────────────────────────
SCRIPT_START=$(date +%s)
log() {
local msg="[$(date '+%Y-%m-%d %H:%M:%S')] $*"
echo "$msg" | tee -a "$LOG_FILE"
}
step() {
local now=$(date +%s)
local elapsed=$(( now - SCRIPT_START ))
local min=$(( elapsed / 60 ))
local sec=$(( elapsed % 60 ))
printf "\n[+%02dm%02ds] ▶ %s\n" "$min" "$sec" "$*" | tee -a "$LOG_FILE"
}
run_sqlite_heredoc() {
local label="$1"
local sql="$2"
local start=$(date +%s)
printf " %-36s " "$label"
sqlite3 "$DB_SRC" <<< "$sql" &
local pid=$!
local spin=[PASSWORD] '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')
local i=0
while kill -0 "$pid" 2>/dev/null; do
printf "\r %-36s %s " "$label" "${spin[$i]}"
i=$(( (i + 1) % 10 ))
sleep 0.2
done
wait "$pid"
local rc=$?
if [ $rc -ne 0 ]; then
printf "\r %-36s ✗ FAILED\n" "$label" | tee -a "$LOG_FILE"
exit $rc
fi
local dur=$(( $(date +%s) - start ))
printf "\r %-36s ✓ %dm%02ds\n" "$label" "$(( dur / 60 ))" "$(( dur % 60 ))" | tee -a "$LOG_FILE"
}
check() {
local label="$1" got="$2" expected="$3"
if [ "$got" -eq "$expected" ]; then
printf " %-20s %s / %s ✓\n" "$label:" "$got" "$expected"
else
printf " %-20s %s / %s ✗ MISMATCH\n" "$label:" "$got" "$expected"
fi
}
# ──────────────────────────────────────────────────────────────────────────────
# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────
if [ "${1:-}" = "today" ]; then
TARGET_DATE=$(date +%Y-%m-%d)
elif [ -n "${1:-}" ]; then
TARGET_DATE="$1"
if ! [[ "$TARGET_DATE" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then
echo "ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday."
exit 1
fi
else
TARGET_DATE=$(date -v-1d +%Y-%m-%d)
fi
log "========================================"
log "Screenpipe sync starting for: $TARGET_DATE"
log "========================================"
# ─── PREFLIGHT ────────────────────────────────────────────────────────────────
step "Preflight checks"
if [ ! -f "$DB_SRC" ]; then
log "ERROR: Source DB not found at $DB_SRC"; exit 1
fi
printf " %-20s %s (%s)\n" "Source DB:" "OK" "$(du -sh "$DB_SRC" | cut -f1)"
if [ ! -d "$NAS_MOUNT" ]; then
log "ERROR: NAS not mounted at $NAS_MOUNT"; exit 1
fi
printf " %-20s %s\n" "NAS mount:" "OK $NAS_MOUNT"
# Check if DB already synced for this date
DB_ALREADY_SYNCED=false
if [ -f "$NAS_DB" ]; then
EXISTING=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';" 2>/dev/null || echo "0")
if [ "$EXISTING" -gt "0" ]; then
log "Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync"
DB_ALREADY_SYNCED=true
else
printf " %-20s %s (%s)\n" "Archive DB:" "exists" "$(du -sh "$NAS_DB" | cut -f1)"
fi
else
printf " %-20s %s\n" "Archive DB:" "will be created"
fi
# Source data dir for this date
DATA_SRC="$HOME/.screenpipe/data/data/$TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
DATA_SIZE=$(du -sh "$DATA_SRC" | cut -f1)
DATA_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
printf " %-20s %s (%s files, %s)\n" "Data dir:" "OK" "$DATA_FILES" "$DATA_SIZE"
else
printf " %-20s %s\n" "Data dir:" "not found — skipping file copy"
fi
# ─── DB SYNC ──────────────────────────────────────────────────────────────────
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────
step "Counting source rows for $TARGET_DATE"
SRC_FRAMES=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
SRC_ELEMENTS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_UI=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
SRC_OCR=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_MEETINGS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';")
printf " %-20s %s\n" "frames:" "$SRC_FRAMES"
printf " %-20s %s\n" "elements:" "$SRC_ELEMENTS"
printf " %-20s %s\n" "ui_events:" "$SRC_UI"
printf " %-20s %s\n" "ocr_text:" "$SRC_OCR"
printf " %-20s %s\n" "meetings:" "$SRC_MEETINGS"
if [ "$SRC_FRAMES" -eq "0" ]; then
log "No frames found for $TARGET_DATE — skipping DB sync"
DB_ALREADY_SYNCED=true
fi
fi
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── INIT TABLES ──────────────────────────────────────────────────────────
step "Initialising tables, indexes, FTS"
run_sqlite_heredoc "creating tables" "
ATTACH '$NAS_DB' AS nas;
CREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;
CREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;
CREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;
CREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;
DETACH nas;
"
run_sqlite_heredoc "creating indexes" "
ATTACH '$NAS_DB' AS nas;
CREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);
CREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);
DETACH nas;
"
run_sqlite_heredoc "creating FTS tables" "
ATTACH '$NAS_DB' AS nas;
CREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(
text, role, frame_id UNINDEXED,
content='elements', content_rowid='id', tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(
full_text, app_name, window_name, browser_url, id UNINDEXED,
tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(
text_content,
app_name,
window_title,
element_name,
content='ui_events',
content_rowid='id',
tokenize='unicode61'
);
DETACH nas;
"
# ─── SYNC DATA ────────────────────────────────────────────────────────────
step "Syncing data for $TARGET_DATE"
run_sqlite_heredoc "video_chunks" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.video_chunks
SELECT * FROM main.video_chunks
WHERE id IN (
SELECT DISTINCT video_chunk_id FROM main.frames
WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL
);
DETACH nas;
"
run_sqlite_heredoc "frames ($SRC_FRAMES rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.frames
SELECT * FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ocr_text ($SRC_OCR rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ocr_text
SELECT o.* FROM main.ocr_text o
JOIN main.frames f ON o.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ui_events ($SRC_UI rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ui_events
SELECT * FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "elements ($SRC_ELEMENTS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.elements
SELECT e.* FROM main.elements e
JOIN main.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "meetings ($SRC_MEETINGS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.meetings
SELECT * FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';
DETACH nas;
"
# ─── FTS UPDATE ───────────────────────────────────────────────────────────
step "Updating FTS indexes"
run_sqlite_heredoc "elements_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.elements_fts(rowid, text, role)
SELECT e.id, e.text, e.role
FROM nas.elements e
JOIN nas.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE'
AND e.text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "frames_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)
SELECT id, full_text, app_name, window_name, browser_url, id
FROM nas.frames
WHERE date(timestamp) = '$TARGET_DATE'
AND full_text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "ui_events_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)
SELECT id, text_content, app_name, window_title, element_name
FROM nas.ui_events
WHERE date(timestamp) = '$TARGET_DATE'
AND text_content IS NOT NULL;
DETACH nas;
"
# ─── VERIFY DB ────────────────────────────────────────────────────────────
step "Verifying DB"
V_FRAMES=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
V_ELEMENTS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_UI=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
V_OCR=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_MEETINGS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';")
check "frames" "$V_FRAMES" "$SRC_FRAMES"
check "elements" "$V_ELEMENTS" "$SRC_ELEMENTS"
check "ui_events" "$V_UI" "$SRC_UI"
check "ocr_text" "$V_OCR" "$SRC_OCR"
check "meetings" "$V_MEETINGS" "$SRC_MEETINGS"
fi
# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────
# Always runs regardless of DB sync status
step "Copying data folder for $TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
mkdir -p "$NAS_DATA/$TARGET_DATE"
RSYNC_START=$(date +%s)
printf " %-36s " "rsync $TARGET_DATE/ → NAS"
rsync -a --ignore-existing \
"$DATA_SRC/" \
"$NAS_DATA/$TARGET_DATE/" \
2>>"$LOG_FILE"
RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))
COPIED_FILES=$(ls "$NAS_DATA/$TARGET_DATE" | wc -l | tr -d ' ')
SRC_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
COPIED_SIZE=$(du -sh "$NAS_DATA/$TARGET_DATE" | cut -f1)
if [ "$COPIED_FILES" -eq "$SRC_FILES" ]; then
printf "\r %-36s ✓ %dm%02ds (%s files, %s)\n" \
"rsync $TARGET_DATE/ → NAS" \
"$(( RSYNC_DUR / 60 ))" "$(( RSYNC_DUR % 60 ))" \
"$COPIED_FILES" "$COPIED_SIZE" | tee -a "$LOG_FILE"
else
printf "\r %-36s ✗ %s / %s files\n" \
"rsync $TARGET_DATE/ → NAS" "$COPIED_FILES" "$SRC_FILES" | tee -a "$LOG_FILE"
fi
else
printf " %-36s %s\n" "rsync $TARGET_DATE/ → NAS" "skipped (no source dir)"
fi
# ─── SUMMARY ──────────────────────────────────────────────────────────────────
TOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))
DB_SIZE=$(du -sh "$NAS_DB" | cut -f1)
echo ""
log "Archive DB size: $DB_SIZE"
log "Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s"
log "Sync complete for $TARGET_DATE"
log "========================================"
Implement and run pipe l…, Editor Group 2
Problems (⇧⌘M)
PROBLEMS
Output (⇧⌘U)
OUTPUT
Debug Console (⇧⌘Y)
DEBUG CONSOLE
Terminal (⌃`)
TERMINAL
Ports - 1 forwarded port
PORTS
1
remote SSH: nas
SSH: nas
screenpipe (Git) - master*, Checkout Branch/Tag...
master*
screenpipe (Git) - Synchronize Changes
No Problems
0
0
Forwarded Ports: 8766
1
Notifications
Sign In
Sign In
Shell Script
Editor Language Status: Inline Suggestions, next: $(copilot) No inline suggestion available, Inline suggestions
LF
UTF-8
Spaces: 2
Ln 352, Col 47 (13096 selected)
git-commit Lukas Kovalik (2 weeks ago)
Lukas Kovalik (2 weeks ago)
No results found
Implement and run pipe logic
Session history
New session
Message actions
main.py
main.py
lets implement logic with pipes. how can I run it?
Thinking
Thinking
Let me look at the current project structure to understand what's already in place.
Bash
List project files
IN
find /volume1/screenpipe -type f | head -50 && echo "---" && ls /volume1/screenpipe
Copy code to clipboard
OUT
/volume1/screenpipe/.DS_Store
/volume1/screenpipe/screenpipe.db
/volume1/screenpipe/screenpipe_sync.sh
/volume1/screenpipe/app_settings.json
/volume1/screenpipe/.gitignore
/volume1/screenpipe/archive.db
/volume1/screenpipe/db.sqlite
/volume1/screenpipe/db.sqlite-wal
/volume1/screenpipe/db.sqlite-shm
/volume1/screenpipe/#recycle/desktop.ini
/volume1/screenpipe/#recycle/db.sqlite
/volume1/screenpipe/#recycle/Copy #1 of db.sqlite
/volume1/screenpipe/#recycle/.DS_Store
/volume1/screenpipe/#recycle/Copy #2 of db.sqlite
/volume1/screenpipe/#recycle/archive.db
/volume1/screenpipe/#recycle/Copy #1 of archive.db
/volume1/screenpipe/#recycle/Copy #2 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of archive.db
/volume1/screenpipe/#recycle/Copy #4 of archive.db
/volume1/screenpipe/#recycle/Copy #5 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of db.sqlite
/volume1/screenpipe/#recycle/Copy #4 of db.sqlite
/volume1/screenpipe/#recycle/Copy #6 of archive.db
/volume1/screenpipe/#recycle/test.txt
/volume1/screenpipe/#recycle/Copy #7 of archive.db
/volume1/screenpipe/#recycle/Copy #8 of archive.db
/volume1/screenpipe/#recycle/archive.db-journal
/volume1/screenpipe/#recycle/Copy #1 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #2 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #3 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #4 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #6 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #7 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of db.sqlite
/volume1/screenpipe/pipes/.DS_Store
/volume1/screenpipe/app/.env
/volume1/screenpipe/app/cli.py
/volume1/screenpipe/app/.DS_Store
/volume1/screenpipe/app/db.py
/volume1/screenpipe/app/docker-compose.yml
/volume1/screenpipe/app/main.py
/volume1/screenpipe/app/requirements.txt
/volume1/screenpipe/app/Dockerfile
/volume1/screenpipe/data/.DS_Store
/volume1/screenpipe/.git/description
/volume1/screenpipe/.git/HEAD
/volume1/screenpipe/.git/index
/volume1/screenpipe/.git/COMMIT_EDITMSG
/volume1/screenpipe/#recycle/data/.DS_Store
---
app
app_settings.json
archive.db
data
db.sqlite
db.sqlite-shm
db.sqlite-wal
pipes
#recycle
screenpipe.db
screenpipe_sync.sh
Read
main.py
main.py
Bash
Check pipes directory and docker-compose
IN
ls /volume1/screenpipe/pipes/ && ls /volume1/screenpipe/app/ && cat /volume1/screenpipe/app/docker-compose.yml
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
cli.py
consumers
db.py
docker-compose.yml
Dockerfile
main.py
__pycache__
requirements.txt
static
services:
screenpipe-app:
build: .
container_name: screenpipe-app
restart: unless-stopped
ports:
- "8766:8000"
volumes:
- /volume1/screenpipe:/data
env_file:
- .env
environment:
TZ: Europe/Sofia
DB_PATH: /data/db.sqlite
sqlite-web-archive:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-archive
restart: unless-stopped
ports:
- "8767:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/archive.db"]
sqlite-web-live:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-live
restart: unless-stopped
ports:
- "8768:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/db.sqlite"]
Read
requirements.txt
requirements.txt
Bash
Inspect a pipe directory
IN
ls /volume1/screenpipe/pipes/day-recap/ && cat /volume1/screenpipe/pipes/day-recap/pipe.json 2>/dev/null || ls /volume1/screenpipe/pipes/day-recap/
Copy code to clipboard
OUT
pipe.md
pipe.md
Read
cli.py
cli.py
Bash
List all pipes and their contents
IN
ls /volume1/screenpipe/pipes/ && for d in /volume1/screenpipe/pipes/*/; do echo "=== $d ==="; ls "$d"; done
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
=== /volume1/screenpipe/pipes/ai-habits/ ===
pipe.md
=== /volume1/screenpipe/pipes/day-recap/ ===
pipe.md
=== /volume1/screenpipe/pipes/meeting-summary/ ===
pipe.md
=== /volume1/screenpipe/pipes/standup-update/ ===
pipe.md
=== /volume1/screenpipe/pipes/time-breakdown/ ===
pipe.md
=== /volume1/screenpipe/pipes/video-export/ ===
pipe.md
Bash
Read pipe markdown files
IN
cat /volume1/screenpipe/pipes/day-recap/pipe.md && echo "===" && cat /volume1/screenpipe/pipes/meeting-summary/pipe.md 2>/dev/null | head -50
Copy code to clipboard
OUT
---
schedule: manual
enabled: true
template: true
title: Day Recap
description: "Today's accomplishments, key moments, and unfinished work"
icon: "📋"
featured: true
---
Analyze my screen and audio recordings from today (last 16 hours only).
Read screenpipe skill first.
Use this exact format:
## Summary
One sentence: what I mainly did today.
## Accomplishments
- Top 3 things I finished, with timestamps (e.g. "2:30 PM")
- Name specific apps, files, or projects
## Key Moments
- Important things I saw, said, or heard — with timestamps
## Unfinished Work
- What I should continue tomorrow — name the app/file/task
## Patterns
- Apps I used most, topics that came up repeatedly
Only report what you can verify from the data. End with: "**Next step:** [most important thing to continue]"
===
---
schedule: manual
enabled: true
template: true
title: Meeting Summary
description: "Summarize meeting transcript with key takeaways and action items"
icon: "🤝"
featured: false
---
Summarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.
Read screenpipe skill first.
Use this exact format:
## Meeting Summary
One sentence: what this meeting was about.
## Key Takeaways
- Top 3-5 important points discussed
- Include who said what when relevant
## Action Items
- [ ] Task — assigned to whom, deadline if mentioned
- [ ] Task — assigned to whom
## Decisions Made
- List any decisions or agreements reached
## Open Questions
- Anything unresolved or needing follow-up
Keep it concise and actionable.
Thinking
Thinking
Bash
Read summary consumer
IN
ls /volume1/screenpipe/app/consumers/ && cat /volume1/screenpipe/app/consumers/summary.py
Copy code to clipboard
OUT
activity.py
audio.py
elements.py
__init__.py
interactions.py
ocr.py
__pycache__
report.py
summary.py
"""AI summary generator using Claude."""
import os
from datetime import date
from typing import Any
from consumers.activity import app_time, summary_stats, browser_urls, ui_event_summary
from consumers.ocr import deduplicated_text
from consumers.audio import formatted_transcript
SUMMARY_TYPES = {
"day_recap": {
"title": "Day Recap",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
## Audio/speech:
{audio}
Write a concise day recap using EXACTLY this format:
## Summary
One sentence: what I mainly worked on today.
## Accomplishments
- Top 3 things I finished, with approximate times
- Name specific apps, files, or projects
## Key Moments
- Important things seen or heard, with timestamps
## Unfinished Work
- What to continue tomorrow
## Patterns
- Apps used most, topics that came up repeatedly
Only report what you can verify from the data. End with:
**Next step:** [most important thing to continue]""",
},
"standup": {
"title": "Standup Update",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
## Audio/speech:
{audio}
Write a brief standup update:
**Yesterday:** What I worked on (2-3 bullets)
**Today:** What I plan to continue (1-2 bullets)
**Blockers:** Any issues observed (or "None")
Keep it under 150 words. Only report what's verifiable from the data.""",
},
"focus_time": {
"title": "Focus & Distraction Analysis",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
Analyze focus vs distraction patterns:
## Deep Work Periods
- When and how long were sustained focus sessions?
- What was being worked on?
## Distractions
- Which apps/sites were used recreationally?
- How much time was lost to context switching?
## Recommendations
- 2-3 concrete suggestions to improve focus tomorrow
Be specific with times and app names.""",
},
}
def _build_context(for_date: date) -> dict[str, str]:
apps = app_time(for_date)
app_lines = "\n".join(f"- {a['app_name']}: {a['minutes']} min" for a in apps[:20])
urls = browser_urls(for_date, limit=20)
url_lines = "\n".join(
f"- {u['browser_url'][:100]} ({u['minutes']} min)" for u in urls
)
ui_rows = ui_event_summary(for_date)
ui_lines = "\n".join(
f"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches"
for r in ui_rows[:15]
)
ocr_rows = deduplicated_text(for_date, chunk_minutes=5)
ocr_lines = "\n".join(
f"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}"
for r in ocr_rows[:100]
)
audio = formatted_transcript(for_date)
return {
"app_time": app_lines or "(no app data)",
"browser_urls": url_lines or "(no browser data)",
"ui_events": ui_lines or "(no UI event data)",
"ocr_text": ocr_lines or "(no screen data)",
"audio": audio[:3000] if len(audio) > 3000 else audio,
}
def generate(
summary_type: str = "day_recap",
for_date: date | None = None,
api_key: str | None = None,
) -> dict[str, Any]:
"""Generate an AI summary. Returns dict with 'title', 'content', 'date'."""
import anthropic
d = for_date or date.today()
key = api_key or os.environ.get("ANTHROPIC_API_KEY", "")
if not key:
return {
"title": "Error",
"content": "ANTHROPIC_API_KEY not set. Add it to your .env file.",
"date": str(d),
}
spec = SUMMARY_TYPES.get(summary_type)
if not spec:
return {"title": "Error", "content": f"Unknown summary type: {summary_type}", "date": str(d)}
stats = summary_stats(d)
if stats["total_frames"] == 0:
return {
"title": spec["title"],
"content": f"No screen data found for {d}.",
"date": str(d),
}
ctx = _build_context(d)
prompt = spec["prompt"].format(**ctx)
client = anthropic.Anthropic(api_key=key)
message = client.messages.create(
model="claude-haiku-4-5-20251001",
max_tokens=1024,
messages=[{"role": "user", "content": prompt}],
)
return {
"title": spec["title"],
"content": message.content[0].text,
"date": str(d),
"stats": stats,
}
Thinking
Thinking
Bash
Read all pipe.md files
IN
for f in /volume1/screenpipe/pipes/*/pipe.md; do echo "=== $f ==="; cat "$f"; echo; done
Copy code to clipboard
OUT
=== /volume1/screenpipe/pipes/ai-habits/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: AI Habits
description: "How you use AI tools — patterns and insights"
icon: "🤖"
featured: true
---
Search my recordings from the last 24 hours for AI tool usage. Use app_name filter for each tool separately: ChatGPT, Claude, Copilot, Cursor, Gemini, Perplexity. Use limit=5 per search, max 6 searches total.
Read screenpipe skill first.
Use this exact format:
## AI Tools Used
- List each tool with approximate time spent (e.g. "Claude: ~45min")
## What I Used Them For
- For each tool: coding, writing, research, or brainstorming
## Usage Patterns
- Do I switch between tools? Use them in bursts or steadily?
## Effectiveness
- Which tool appeared alongside completed work vs. abandoned attempts
If no AI usage is found, say so clearly. End with: "**Tip:** [one suggestion to use AI tools more effectively]"
=== /volume1/screenpipe/pipes/day-recap/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Day Recap
description: "Today's accomplishments, key moments, and unfinished work"
icon: "📋"
featured: true
---
Analyze my screen and audio recordings from today (last 16 hours only).
Read screenpipe skill first.
Use this exact format:
## Summary
One sentence: what I mainly did today.
## Accomplishments
- Top 3 things I finished, with timestamps (e.g. "2:30 PM")
- Name specific apps, files, or projects
## Key Moments
- Important things I saw, said, or heard — with timestamps
## Unfinished Work
- What I should continue tomorrow — name the app/file/task
## Patterns
- Apps I used most, topics that came up repeatedly
Only report what you can verify from the data. End with: "**Next step:** [most important thing to continue]"
=== /volume1/screenpipe/pipes/meeting-summary/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Meeting Summary
description: "Summarize meeting transcript with key takeaways and action items"
icon: "🤝"
featured: false
---
Summarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.
Read screenpipe skill first.
Use this exact format:
## Meeting Summary
One sentence: what this meeting was about.
## Key Takeaways
- Top 3-5 important points discussed
- Include who said what when relevant
## Action Items
- [ ] Task — assigned to whom, deadline if mentioned
- [ ] Task — assigned to whom
## Decisions Made
- List any decisions or agreements reached
## Open Questions
- Anything unresolved or needing follow-up
Keep it concise and actionable.
=== /volume1/screenpipe/pipes/standup-update/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Standup Update
description: "What you did, what's next, and any blockers"
icon: "🏢"
featured: true
---
Based on my recordings from the last 24 hours, generate a standup update. Use limit=10 per search, max 3 searches total.
Read screenpipe skill first.
Use this exact format:
## Yesterday
- What I worked on (name specific projects, files, tools, PRs)
## Today
- What I will work on next (based on unfinished tasks and recent activity)
## Blockers
- Issues I hit — errors, slow builds, waiting on someone
- If no blockers, write "None"
Keep it under 150 words. Copy-paste ready for a team standup.
=== /volume1/screenpipe/pipes/time-breakdown/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Time Breakdown
description: "Where your time went — by app, project, and category"
icon: "⏱"
featured: false
---
Analyze my app usage from today (last 12 hours). Use limit=10 per search, max 4 searches. Prefer /raw_sql with COUNT/GROUP BY queries.
Read screenpipe skill first.
Use this exact format with durations and percentages:
## By Application
- List each app with duration and percentage, sorted by time (e.g. "VS Code: 2h 15min (28%)")
## By Category
- Group into: coding, meetings, browsing, writing, communication, other
- Show hours and percentage per category
## By Project
- Group related activities by project/topic. Name specific repos or tasks.
## Productivity Score
- Calculate: focused_work_hours / total_hours as a percentage
- Focused = coding + writing. Unfocused = browsing + switching.
End with: "**Suggestion:** [one specific change to improve tomorrow's productivity]"
=== /volume1/screenpipe/pipes/video-export/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Export Video Clip
description: "Create a video of your recent screen activity"
icon: "🎬"
featured: false
---
Export a video of my screen activity from the last 5 minutes.
Read screenpipe skill first.
Use the POST /frames/export endpoint with the time range and fps=1.0. Then show me the exported video file path as an inline code block so I can watch it.
If the export is large, suggest a lower fps or shorter time range.
Thinking
Thinking
Now I have a clear picture. The pipes are markdown prompt templates in
/volume1/screenpipe/pipes/
, but there's no code to actually load and run them —
consumers/summary.py
has its own hardcoded prompts instead.
Here's what I'll implement:
consumers/pipes.py
— dynamically loads pipe.md files and runs them via Claude (data injected as system message, pipe body as user prompt)
main.py
— two new endpoints:
GET /api/pipes
and
POST /api/pipes/{pipe_id}/run
cli.py
— a
pipe
command to run pipes from the terminal
Let me build it:
Bash
Check browser_urls signature
IN
cat /volume1/screenpipe/app/consumers/activity.py | grep "def browser_urls" -A 5
Copy code to clipboard
OUT
def browser_urls(
for_date: date | None = None,
app_name: str | None = None,
ts_from: str | None = None,
ts_to: str | None = None,
limit: int = 30,
Write
pipes.py
pipes.py
143 lines
"""Dynamic pipe loader and runner."""
import os
import re
from datetime import date
from pathlib import Path
from typing import Any
def _parse_frontmatter(text: str) -> tuple[dict, str]:
if not text.startswith("---"):
return {}, text
try:
end = text.index("---", 3)
except ValueError:
return {}, text
fm_text = text[3:end].strip()
body = text[end + 3:].strip()
meta: dict = {}
for line in fm_text.splitlines():
if ":" in line:
k, _, v = li...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
21104
|
922
|
12
|
2026-05-11T17:12:19.749919+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-11/1778 /Users/lukas/.screenpipe/data/data/2026-05-11/1778519539749_m1.jpg...
|
Code
|
screenpipe_sync.sh — screenpipe [SSH: nas]
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Explorer (⇧⌘E) - 1 unsaved file
1
Search (⇧⌘F)
Explorer (⇧⌘E) - 1 unsaved file
1
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py
M
db.py
docker-compose.yml
Dockerfile
M
main.py
M
requirements.txt
M
data
logs
pipes
.gitignore
app_settings.json
archive.db
archive.db-bak
U
db.sqlite
db.sqlite-shm
db.sqlite-wal
screenpipe_sync_updated.sh
U
screenpipe_sync.sh
screenpipe.db
Outline Section
OUTLINE
OUTLINE
Timeline Section
TIMELINE
TIMELINE
app_settings.json, Editor Group 1
screenpipe_sync.sh, Editor Group 1
pipe.md, Editor Group 1
.env, Editor Group 1
#!/bin/bash
# screenpipe_sync.sh
# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).
# Also copies the day's video/frame data folder to the NAS.
#
# Schema-drift tolerant: if Screenpipe migrations add new columns to the source DB,
# the NAS archive gets ALTER TABLE'd to match. Inserts use explicit column lists,
# so positional mismatches can't occur.
#
# Usage:
# ./screenpipe_sync.sh # syncs yesterday (default)
# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date
# ./screenpipe_sync.sh today # syncs today so far
#
# Cron example (runs at 3am daily):
# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1
set -euo pipefail
# ─── CONFIG ───────────────────────────────────────────────────────────────────
DB_SRC="${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}"
NAS_MOUNT="${NAS_MOUNT:-/Volumes/screenpipe}"
NAS_DB="$NAS_MOUNT/archive.db"
NAS_DATA="$NAS_MOUNT/data"
LOG_FILE="$HOME/.screenpipe/sync.log"
# Tables that get schema drift handling. Order matters for FK-ish references
# (parents before children: video_chunks → frames → elements/ocr_text/ui_events).
SYNC_TABLES=(video_chunks frames elements ocr_text ui_events meetings)
# ──────────────────────────────────────────────────────────────────────────────
# ─── HELPERS ──────────────────────────────────────────────────────────────────
SCRIPT_START=$(date +%s)
log() {
local msg="[$(date '+%Y-%m-%d %H:%M:%S')] $*"
echo "$msg" | tee -a "$LOG_FILE"
}
step() {
local now=$(date +%s)
local elapsed=$(( now - SCRIPT_START ))
local min=$(( elapsed / 60 ))
local sec=$(( elapsed % 60 ))
printf "\n[+%02dm%02ds] ▶ %s\n" "$min" "$sec" "$*" | tee -a "$LOG_FILE"
}
run_sqlite_heredoc() {
local label="$1"
local sql="$2"
local start=$(date +%s)
printf " %-36s " "$label"
sqlite3 "$DB_SRC" <<< "$sql" &
local pid=$!
local spin=[PASSWORD] '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')
local i=0
while kill -0 "$pid" 2>/dev/null; do
printf "\r %-36s %s " "$label" "${spin[$i]}"
i=$(( (i + 1) % 10 ))
sleep 0.2
done
wait "$pid"
local rc=$?
if [ $rc -ne 0 ]; then
printf "\r %-36s ✗ FAILED\n" "$label" | tee -a "$LOG_FILE"
exit $rc
fi
local dur=$(( $(date +%s) - start ))
printf "\r %-36s ✓ %dm%02ds\n" "$label" "$(( dur / 60 ))" "$(( dur % 60 ))" | tee -a "$LOG_FILE"
}
check() {
local label="$1" got="$2" expected="$3"
if [ "$got" -eq "$expected" ]; then
printf " %-20s %s / %s ✓\n" "$label:" "$got" "$expected"
else
printf " %-20s %s / %s ✗ MISMATCH\n" "$label:" "$got" "$expected"
fi
}
# ─── SCHEMA HELPERS ───────────────────────────────────────────────────────────
# Echoes "name|type" lines for a table from a given DB.
table_columns_with_types() {
local db="$1" table="$2"
sqlite3 "$db" "PRAGMA table_info($table);" | awk -F'|' '{print $2 "|" $3}'
}
# Echoes just column names, one per line.
table_columns() {
local db="$1" table="$2"
sqlite3 "$db" "PRAGMA table_info($table);" | awk -F'|' '{print $2}'
}
# Returns true (0) if a table exists in the given DB.
table_exists() {
local db="$1" table="$2"
local count
count=$(sqlite3 "$db" "SELECT COUNT(*) FROM sqlite_master WHERE type='table' AND name='$table';")
[ "$count" -gt 0 ]
}
# Adds any columns present in source but missing in NAS for the given table.
# Uses ALTER TABLE ADD COLUMN, which is a fast metadata-only operation in SQLite.
ensure_columns() {
local table="$1"
local label="schema: $table"
printf " %-36s " "$label"
if ! table_exists "$DB_SRC" "$table"; then
printf "✗ source missing — skipping\n"
return 0
fi
if ! table_exists "$NAS_DB" "$table"; then
printf "✓ fresh (created above)\n"
return 0
fi
local src_cols
src_cols=$(table_columns_with_types "$DB_SRC" "$table")
local nas_cols
nas_cols=$(table_columns "$NAS_DB" "$table")
local added=0
local added_names=""
while IFS='|' read -r name type; do
[ -z "$name" ] && continue
# Use grep -F -x for fixed-string exact match (safe against regex chars).
if ! echo "$nas_cols" | grep -Fxq "$name"; then
# SQLite ALTER TABLE ADD COLUMN: type is optional, no NOT NULL allowed
# without a constant default. Default-NULL is exactly what we want for archive.
sqlite3 "$NAS_DB" "ALTER TABLE $table ADD COLUMN \"$name\" $type;"
added=$((added + 1))
added_names="$added_names $name"
fi
done <<< "$src_cols"
if [ "$added" -gt 0 ]; then
printf "✓ added %d:%s\n" "$added" "$added_names"
else
printf "✓ in sync\n"
fi
}
# Echoes a comma-separated list of source columns for a table, double-quoted
# so reserved words and hyphens are safe. If an alias is provided, columns are
# prefixed (e.g. `o."col"`). Used for both INSERT and SELECT sides; aliased
# form is required when SELECTing from a JOIN where column names collide
# (e.g. ocr_text and frames both have app_name, window_name).
build_col_list() {
local table="$1"
local alias="${2:-}"
local prefix=""
[ -n "$alias" ] && prefix="${alias}."
table_columns "$DB_SRC" "$table" | awk 'NF' | awk -v p="$prefix" '{print p "\"" $0 "\""}' | paste -sd, -
}
# ──────────────────────────────────────────────────────────────────────────────
# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────
if [ "${1:-}" = "today" ]; then
TARGET_DATE=$(date +%Y-%m-%d)
elif [ -n "${1:-}" ]; then
TARGET_DATE="$1"
if ! [[ "$TARGET_DATE" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then
echo "ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday."
exit 1
fi
else
TARGET_DATE=$(date -v-1d +%Y-%m-%d)
fi
log "========================================"
log "Screenpipe sync starting for: $TARGET_DATE"
log "========================================"
# ─── PREFLIGHT ────────────────────────────────────────────────────────────────
step "Preflight checks"
if [ ! -f "$DB_SRC" ]; then
log "ERROR: Source DB not found at $DB_SRC"; exit 1
fi
printf " %-20s %s (%s)\n" "Source DB:" "OK" "$(du -sh "$DB_SRC" | cut -f1)"
if [ ! -d "$NAS_MOUNT" ]; then
log "ERROR: NAS not mounted at $NAS_MOUNT"; exit 1
fi
printf " %-20s %s\n" "NAS mount:" "OK $NAS_MOUNT"
# Check if DB already synced for this date
DB_ALREADY_SYNCED=false
if [ -f "$NAS_DB" ]; then
if table_exists "$NAS_DB" "frames"; then
EXISTING=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';" 2>/dev/null || echo "0")
if [ "$EXISTING" -gt "0" ]; then
log "Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync"
DB_ALREADY_SYNCED=true
else
printf " %-20s %s (%s)\n" "Archive DB:" "exists" "$(du -sh "$NAS_DB" | cut -f1)"
fi
else
printf " %-20s %s\n" "Archive DB:" "exists, no frames table yet"
fi
else
printf " %-20s %s\n" "Archive DB:" "will be created"
fi
# Source data dir for this date
DATA_SRC="$HOME/.screenpipe/data/data/$TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
DATA_SIZE=$(du -sh "$DATA_SRC" | cut -f1)
DATA_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
printf " %-20s %s (%s files, %s)\n" "Data dir:" "OK" "$DATA_FILES" "$DATA_SIZE"
else
printf " %-20s %s\n" "Data dir:" "not found — skipping file copy"
fi
# ─── DB SYNC ──────────────────────────────────────────────────────────────────
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────
step "Counting source rows for $TARGET_DATE"
SRC_FRAMES=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
SRC_ELEMENTS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_UI=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
SRC_OCR=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_MEETINGS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';")
printf " %-20s %s\n" "frames:" "$SRC_FRAMES"
printf " %-20s %s\n" "elements:" "$SRC_ELEMENTS"
printf " %-20s %s\n" "ui_events:" "$SRC_UI"
printf " %-20s %s\n" "ocr_text:" "$SRC_OCR"
printf " %-20s %s\n" "meetings:" "$SRC_MEETINGS"
if [ "$SRC_FRAMES" -eq "0" ]; then
log "No frames found for $TARGET_DATE — skipping DB sync"
DB_ALREADY_SYNCED=true
fi
fi
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── INIT TABLES ──────────────────────────────────────────────────────────
step "Initialising tables (CREATE IF NOT EXISTS)"
run_sqlite_heredoc "creating tables" "
ATTACH '$NAS_DB' AS nas;
CREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;
CREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;
CREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;
CREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;
DETACH nas;
"
# ─── SCHEMA DRIFT FIX ─────────────────────────────────────────────────────
# Runs AFTER CREATE IF NOT EXISTS so newly-created tables are no-ops here,
# and pre-existing tables get any missing columns added.
step "Reconciling NAS schema with source"
for tbl in "${SYNC_TABLES[@]}"; do
ensure_columns "$tbl"
done
run_sqlite_heredoc "creating indexes" "
ATTACH '$NAS_DB' AS nas;
CREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);
CREATE INDEX IF NOT EXISTS nas.idx_frames_document_path ON frames(document_path) WHERE document_path IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_elements_onscreen_frame ON elements(frame_id) WHERE on_screen = 1 AND text IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);
CREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);
DETACH nas;
"
run_sqlite_heredoc "creating FTS tables" "
ATTACH '$NAS_DB' AS nas;
CREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(
text, role, frame_id UNINDEXED,
content='elements', content_rowid='id', tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(
full_text, app_name, window_name, browser_url, id UNINDEXED,
tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(
text_content,
app_name,
window_title,
element_name,
content='ui_events',
content_rowid='id',
tokenize='unicode61'
);
DETACH nas;
"
# ─── BUILD EXPLICIT COLUMN LISTS ──────────────────────────────────────────
# After ensure_columns, source ⊆ NAS for every synced table, so source's
# column list is a safe subset to use on both sides of the INSERT.
# For tables that JOIN frames (ocr_text, elements), the SELECT side needs
# alias-qualified columns because both tables share names (app_name, etc).
FRAMES_COLS=$(build_col_list frames)
ELEMENTS_COLS=$(build_col_list elements)
ELEMENTS_COLS_E=$(build_col_list elements e)
UI_EVENTS_COLS=$(build_col_list ui_events)
OCR_TEXT_COLS=$(build_col_list ocr_text)
OCR_TEXT_COLS_O=$(build_col_list ocr_text o)
VIDEO_CHUNKS_COLS=$(build_col_list video_chunks)
MEETINGS_COLS=$(build_col_list meetings)
# ─── SYNC DATA ────────────────────────────────────────────────────────────
step "Syncing data for $TARGET_DATE"
run_sqlite_heredoc "video_chunks" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.video_chunks ($VIDEO_CHUNKS_COLS)
SELECT $VIDEO_CHUNKS_COLS FROM main.video_chunks
WHERE id IN (
SELECT DISTINCT video_chunk_id FROM main.frames
WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL
);
DETACH nas;
"
run_sqlite_heredoc "frames ($SRC_FRAMES rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.frames ($FRAMES_COLS)
SELECT $FRAMES_COLS FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ocr_text ($SRC_OCR rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ocr_text ($OCR_TEXT_COLS)
SELECT $OCR_TEXT_COLS_O FROM main.ocr_text o
JOIN main.frames f ON o.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ui_events ($SRC_UI rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ui_events ($UI_EVENTS_COLS)
SELECT $UI_EVENTS_COLS FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "elements ($SRC_ELEMENTS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.elements ($ELEMENTS_COLS)
SELECT $ELEMENTS_COLS_E FROM main.elements e
JOIN main.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "meetings ($SRC_MEETINGS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.meetings ($MEETINGS_COLS)
SELECT $MEETINGS_COLS FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';
DETACH nas;
"
# ─── FTS UPDATE ───────────────────────────────────────────────────────────
step "Updating FTS indexes"
run_sqlite_heredoc "elements_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.elements_fts(rowid, text, role)
SELECT e.id, e.text, e.role
FROM nas.elements e
JOIN nas.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE'
AND e.text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "frames_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)
SELECT id, full_text, app_name, window_name, browser_url, id
FROM nas.frames
WHERE date(timestamp) = '$TARGET_DATE'
AND full_text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "ui_events_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)
SELECT id, text_content, app_name, window_title, element_name
FROM nas.ui_events
WHERE date(timestamp) = '$TARGET_DATE'
AND text_content IS NOT NULL;
DETACH nas;
"
# ─── VERIFY DB ────────────────────────────────────────────────────────────
step "Verifying DB"
V_FRAMES=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
V_ELEMENTS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_UI=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
V_OCR=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_MEETINGS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';")
check "frames" "$V_FRAMES" "$SRC_FRAMES"
check "elements" "$V_ELEMENTS" "$SRC_ELEMENTS"
check "ui_events" "$V_UI" "$SRC_UI"
check "ocr_text" "$V_OCR" "$SRC_OCR"
check "meetings" "$V_MEETINGS" "$SRC_MEETINGS"
fi
# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────
# Always runs regardless of DB sync status
step "Copying data folder for $TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
mkdir -p "$NAS_DATA/$TARGET_DATE"
RSYNC_START=$(date +%s)
printf " %-36s " "rsync $TARGET_DATE/ → NAS"
rsync -a --ignore-existing \
"$DATA_SRC/" \
"$NAS_DATA/$TARGET_DATE/" \
2>>"$LOG_FILE"
RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))
COPIED_FILES=$(ls "$NAS_DATA/$TARGET_DATE" | wc -l | tr -d ' ')
SRC_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
COPIED_SIZE=$(du -sh "$NAS_DATA/$TARGET_DATE" | cut -f1)
if [ "$COPIED_FILES" -eq "$SRC_FILES" ]; then
printf "\r %-36s ✓ %dm%02ds (%s files, %s)\n" \
"rsync $TARGET_DATE/ → NAS" \
"$(( RSYNC_DUR / 60 ))" "$(( RSYNC_DUR % 60 ))" \
"$COPIED_FILES" "$COPIED_SIZE" | tee -a "$LOG_FILE"
else
printf "\r %-36s ✗ %s / %s files\n" \
"rsync $TARGET_DATE/ → NAS" "$COPIED_FILES" "$SRC_FILES" | tee -a "$LOG_FILE"
fi
else
printf " %-36s %s\n" "rsync $TARGET_DATE/ → NAS" "skipped (no source dir)"
fi
# ─── COPY LOGS ────────────────────────────────────────────────────────────────
# Screenpipe writes daily logs to ~/.screenpipe/screenpipe.YYYY-MM-DD.N.log
# (N is a rotation counter, almost always 0). Mirror them to NAS so log
# analysis can happen on the consumer side without SSH'ing back to the Mac.
step "Copying screenpipe logs for $TARGET_DATE"
NAS_LOGS="$NAS_MOUNT/logs"
mkdir -p "$NAS_LOGS"
# Use a glob with nullglob so an empty match doesn't expand to a literal pattern.
shopt -s nullglob
LOG_FILES=( "$HOME/.screenpipe/screenpipe.$TARGET_DATE."*.log )
shopt -u nullglob
if [ ${#LOG_FILES[@]} -gt 0 ]; then
printf " %-36s " "rsync logs → NAS"
# No --ignore-existing here: logs grow during the day, so we want rsync's
# default size+mtime check to refresh files that have changed.
rsync -a "${LOG_FILES[@]}" "$NAS_LOGS/" 2>>"$LOG_FILE"
COPIED=${#LOG_FILES[@]}
TOTAL_SIZE=$(du -ch "${LOG_FILES[@]}" | tail -1 | cut -f1)
printf "✓ %d file(s), %s\n" "$COPIED" "$TOTAL_SIZE" | tee -a "$LOG_FILE"
else
printf " %-36s %s\n" "rsync logs → NAS" "skipped (no matching logs)"
fi
# ─── SUMMARY ──────────────────────────────────────────────────────────────────
TOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))
DB_SIZE=$(du -sh "$NAS_DB" | cut -f1)
echo ""
log "Archive DB size: $DB_SIZE"
log "Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s"
log "Sync complete for $TARGET_DATE"
log "========================================"
# Mirror this script's own logbook to NAS so sync health can be monitored
# from the consumer side. Done last so the summary lines above are included.
rsync -a "$HOME/.screenpipe/sync.log" "$NAS_LOGS/sync.log" 2>/dev/null || true
#!/bin/bash
# screenpipe_sync.sh
# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).
# Also copies the day's video/frame data folder to the NAS.
#
# Schema-drift tolerant: if Screenpipe migrations add new columns to the source DB,
# the NAS archive gets ALTER TABLE'd to match. Inserts use explicit column lists,
# so positional mismatches can't occur.
#
# Usage:
# ./screenpipe_sync.sh # syncs yesterday (default)
# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date
# ./screenpipe_sync.sh today # syncs today so far
#
# Cron example (runs at 3am daily):
# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1
set -euo pipefail
# ─── CONFIG ───────────────────────────────────────────────────────────────────
DB_SRC="${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}"
NAS_MOUNT="${NAS_MOUNT:-/Volumes/screenpipe}"
NAS_DB="$NAS_MOUNT/archive.db"
NAS_DATA="$NAS_MOUNT/data"
LOG_FILE="$HOME/.screenpipe/sync.log"
# Tables that get schema drift handling. Order matters for FK-ish references
# (parents before children: video_chunks → frames → elements/ocr_text/ui_events).
SYNC_TABLES=(video_chunks frames elements ocr_text ui_events meetings)
# ──────────────────────────────────────────────────────────────────────────────
# ─── HELPERS ──────────────────────────────────────────────────────────────────
SCRIPT_START=$(date +%s)
log() {
local msg="[$(date '+%Y-%m-%d %H:%M:%S')] $*"
echo "$msg" | tee -a "$LOG_FILE"
}
step() {
local now=$(date +%s)
local elapsed=$(( now - SCRIPT_START ))
local min=$(( elapsed / 60 ))
local sec=$(( elapsed % 60 ))
printf "\n[+%02dm%02ds] ▶ %s\n" "$min" "$sec" "$*" | tee -a "$LOG_FILE"
}
run_sqlite_heredoc() {
local label="$1"
local sql="$2"
local start=$(date +%s)
printf " %-36s " "$label"
sqlite3 "$DB_SRC" <<< "$sql" &
local pid=$!
local spin=[PASSWORD] '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')
local i=0
while kill -0 "$pid" 2>/dev/null; do
printf "\r %-36s %s " "$label" "${spin[$i]}"
i=$(( (i + 1) % 10 ))
sleep 0.2
done
wait "$pid"
local rc=$?
if [ $rc -ne 0 ]; then
printf "\r %-36s ✗ FAILED\n" "$label" | tee -a "$LOG_FILE"
exit $rc
fi
local dur=$(( $(date +%s) - start ))
printf "\r %-36s ✓ %dm%02ds\n" "$label" "$(( dur / 60 ))" "$(( dur % 60 ))" | tee -a "$LOG_FILE"
}
check() {
local label="$1" got="$2" expected="$3"
if [ "$got" -eq "$expected" ]; then
printf " %-20s %s / %s ✓\n" "$label:" "$got" "$expected"
else
printf " %-20s %s / %s ✗ MISMATCH\n" "$label:" "$got" "$expected"
fi
}
# ─── SCHEMA HELPERS ───────────────────────────────────────────────────────────
# Echoes "name|type" lines for a table from a given DB.
table_columns_with_types() {
local db="$1" table="$2"
sqlite3 "$db" "PRAGMA table_info($table);" | awk -F'|' '{print $2 "|" $3}'
}
# Echoes just column names, one per line.
table_columns() {
local db="$1" table="$2"
sqlite3 "$db" "PRAGMA table_info($table);" | awk -F'|' '{print $2}'
}
# Returns true (0) if a table exists in the given DB.
table_exists() {
local db="$1" table="$2"
local count
count=$(sqlite3 "$db" "SELECT COUNT(*) FROM sqlite_master WHERE type='table' AND name='$table';")
[ "$count" -gt 0 ]
}
# Adds any columns present in source but missing in NAS for the given table.
# Uses ALTER TABLE ADD COLUMN, which is a fast metadata-only operation in SQLite.
ensure_columns() {
local table="$1"
local label="schema: $table"
printf " %-36s " "$label"
if ! table_exists "$DB_SRC" "$table"; then
printf "✗ source missing — skipping\n"
return 0
fi
if ! table_exists "$NAS_DB" "$table"; then
printf "✓ fresh (created above)\n"
return 0
fi
local src_cols
src_cols=$(table_columns_with_types "$DB_SRC" "$table")
local nas_cols
nas_cols=$(table_columns "$NAS_DB" "$table")
local added=0
local added_names=""
while IFS='|' read -r name type; do
[ -z "$name" ] && continue
# Use grep -F -x for fixed-string exact match (safe against regex chars).
if ! echo "$nas_cols" | grep -Fxq "$name"; then
# SQLite ALTER TABLE ADD COLUMN: type is optional, no NOT NULL allowed
# without a constant default. Default-NULL is exactly what we want for archive.
sqlite3 "$NAS_DB" "ALTER TABLE $table ADD COLUMN \"$name\" $type;"
added=$((added + 1))
added_names="$added_names $name"
fi
done <<< "$src_cols"
if [ "$added" -gt 0 ]; then
printf "✓ added %d:%s\n" "$added" "$added_names"
else
printf "✓ in sync\n"
fi
}
# Echoes a comma-separated list of source columns for a table, double-quoted
# so reserved words and hyphens are safe. If an alias is provided, columns are
# prefixed (e.g. `o."col"`). Used for both INSERT and SELECT sides; aliased
# form is required when SELECTing from a JOIN where column names collide
# (e.g. ocr_text and frames both have app_name, window_name).
build_col_list() {
local table="$1"
local alias="${2:-}"
local prefix=""
[ -n "$alias" ] && prefix="${alias}."
table_columns "$DB_SRC" "$table" | awk 'NF' | awk -v p="$prefix" '{print p "\"" $0 "\""}' | paste -sd, -
}
# ──────────────────────────────────────────────────────────────────────────────
# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────
if [ "${1:-}" = "today" ]; then
TARGET_DATE=$(date +%Y-%m-%d)
elif [ -n "${1:-}" ]; then
TARGET_DATE="$1"
if ! [[ "$TARGET_DATE" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then
echo "ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday."
exit 1
fi
else
TARGET_DATE=$(date -v-1d +%Y-%m-%d)
fi
log "========================================"
log "Screenpipe sync starting for: $TARGET_DATE"
log "========================================"
# ─── PREFLIGHT ────────────────────────────────────────────────────────────────
step "Preflight checks"
if [ ! -f "$DB_SRC" ]; then
log "ERROR: Source DB not found at $DB_SRC"; exit 1
fi
printf " %-20s %s (%s)\n" "Source DB:" "OK" "$(du -sh "$DB_SRC" | cut -f1)"
if [ ! -d "$NAS_MOUNT" ]; then
log "ERROR: NAS not mounted at $NAS_MOUNT"; exit 1
fi
printf " %-20s %s\n" "NAS mount:" "OK $NAS_MOUNT"
# Check if DB already synced for this date
DB_ALREADY_SYNCED=false
if [ -f "$NAS_DB" ]; then
if table_exists "$NAS_DB" "frames"; then
EXISTING=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';" 2>/dev/null || echo "0")
if [ "$EXISTING" -gt "0" ]; then
log "Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync"
DB_ALREADY_SYNCED=true
else
printf " %-20s %s (%s)\n" "Archive DB:" "exists" "$(du -sh "$NAS_DB" | cut -f1)"
fi
else
printf " %-20s %s\n" "Archive DB:" "exists, no frames table yet"
fi
else
printf " %-20s %s\n" "Archive DB:" "will be created"
fi
# Source data dir for this date
DATA_SRC="$HOME/.screenpipe/data/data/$TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
DATA_SIZE=$(du -sh "$DATA_SRC" | cut -f1)
DATA_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
printf " %-20s %s (%s files, %s)\n" "Data dir:" "OK" "$DATA_FILES" "$DATA_SIZE"
else
printf " %-20s %s\n" "Data dir:" "not found — skipping file copy"
fi
# ─── DB SYNC ──────────────────────────────────────────────────────────────────
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────
step "Counting source rows for $TARGET_DATE"
SRC_FRAMES=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
SRC_ELEMENTS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_UI=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
SRC_OCR=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_MEETINGS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';")
printf " %-20s %s\n" "frames:" "$SRC_FRAMES"
printf " %-20s %s\n" "elements:" "$SRC_ELEMENTS"
printf " %-20s %s\n" "ui_events:" "$SRC_UI"
printf " %-20s %s\n" "ocr_text:" "$SRC_OCR"
printf " %-20s %s\n" "meetings:" "$SRC_MEETINGS"
if [ "$SRC_FRAMES" -eq "0" ]; then
log "No frames found for $TARGET_DATE — skipping DB sync"
DB_ALREADY_SYNCED=true
fi
fi
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── INIT TABLES ──────────────────────────────────────────────────────────
step "Initialising tables (CREATE IF NOT EXISTS)"
run_sqlite_heredoc "creating tables" "
ATTACH '$NAS_DB' AS nas;
CREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;
CREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;
CREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;
CREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;
DETACH nas;
"
# ─── SCHEMA DRIFT FIX ─────────────────────────────────────────────────────
# Runs AFTER CREATE IF NOT EXISTS so newly-created tables are no-ops here,
# and pre-existing tables get any missing columns added.
step "Reconciling NAS schema with source"
for tbl in "${SYNC_TABLES[@]}"; do
ensure_columns "$tbl"
done
run_sqlite_heredoc "creating indexes" "
ATTACH '$NAS_DB' AS nas;
CREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);
CREATE INDEX IF NOT EXISTS nas.idx_frames_document_path ON frames(document_path) WHERE document_path IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_elements_onscreen_frame ON elements(frame_id) WHERE on_screen = 1 AND text IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);
CREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);
DETACH nas;
"
run_sqlite_heredoc "creating FTS tables" "
ATTACH '$NAS_DB' AS nas;
CREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(
text, role, frame_id UNINDEXED,
content='elements', content_rowid='id', tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(
full_text, app_name, window_name, browser_url, id UNINDEXED,
tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(
text_content,
app_name,
window_title,
element_name,
content='ui_events',
content_rowid='id',
tokenize='unicode61'
);
DETACH nas;
"
# ─── BUILD EXPLICIT COLUMN LISTS ──────────────────────────────────────────
# After ensure_columns, source ⊆ NAS for every synced table, so source's
# column list is a safe subset to use on both sides of the INSERT.
# For tables that JOIN frames (ocr_text, elements), the SELECT side needs
# alias-qualified columns because both tables share names (app_name, etc).
FRAMES_COLS=$(build_col_list frames)
ELEMENTS_COLS=$(build_col_list elements)
ELEMENTS_COLS_E=$(build_col_list elements e)
UI_EVENTS_COLS=$(build_col_list ui_events)
OCR_TEXT_COLS=$(build_col_list ocr_text)
OCR_TEXT_COLS_O=$(build_col_list ocr_text o)
VIDEO_CHUNKS_COLS=$(build_col_list video_chunks)
MEETINGS_COLS=$(build_col_list meetings)
# ─── SYNC DATA ────────────────────────────────────────────────────────────
step "Syncing data for $TARGET_DATE"
run_sqlite_heredoc "video_chunks" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.video_chunks ($VIDEO_CHUNKS_COLS)
SELECT $VIDEO_CHUNKS_COLS FROM main.video_chunks
WHERE id IN (
SELECT DISTINCT video_chunk_id FROM main.frames
WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL
);
DETACH nas;
"
run_sqlite_heredoc "frames ($SRC_FRAMES rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.frames ($FRAMES_COLS)
SELECT $FRAMES_COLS FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ocr_text ($SRC_OCR rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ocr_text ($OCR_TEXT_COLS)
SELECT $OCR_TEXT_COLS_O FROM main.ocr_text o
JOIN main.frames f ON o.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ui_events ($SRC_UI rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ui_events ($UI_EVENTS_COLS)
SELECT $UI_EVENTS_COLS FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "elements ($SRC_ELEMENTS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.elements ($ELEMENTS_COLS)
SELECT $ELEMENTS_COLS_E FROM main.elements e
JOIN main.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "meetings ($SRC_MEETINGS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.meetings ($MEETINGS_COLS)
SELECT $MEETINGS_COLS FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';
DETACH nas;
"
# ─── FTS UPDATE ───────────────────────────────────────────────────────────
step "Updating FTS indexes"
run_sqlite_heredoc "elements_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.elements_fts(rowid, text, role)
SELECT e.id, e.text, e.role
FROM nas.elements e
JOIN nas.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE'
AND e.text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "frames_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)
SELECT id, full_text, app_name, window_name, browser_url, id
FROM nas.frames
WHERE date(timestamp) = '$TARGET_DATE'
AND full_text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "ui_events_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)
SELECT id, text_content, app_name, window_title, element_name
FROM nas.ui_events
WHERE date(timestamp) = '$TARGET_DATE'
AND text_content IS NOT NULL;
DETACH nas;
"
# ─── VERIFY DB ────────────────────────────────────────────────────────────
step "Verifying DB"
V_FRAMES=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
V_ELEMENTS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_UI=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
V_OCR=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_MEETINGS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';")
check "frames" "$V_FRAMES" "$SRC_FRAMES"
check "elements" "$V_ELEMENTS" "$SRC_ELEMENTS"
check "ui_events" "$V_UI" "$SRC_UI"
check "ocr_text" "$V_OCR" "$SRC_OCR"
check "meetings" "$V_MEETINGS" "$SRC_MEETINGS"
fi
# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────
# Always runs regardless of DB sync status
step "Copying data folder for $TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
mkdir -p "$NAS_DATA/$TARGET_DATE"
RSYNC_START=$(date +%s)
printf " %-36s " "rsync $TARGET_DATE/ → NAS"
rsync -a --ignore-existing \
"$DATA_SRC/" \
"$NAS_DATA/$TARGET_DATE/" \
2>>"$LOG_FILE"
RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))
COPIED_FILES=$(ls "$NAS_DATA/$TARGET_DATE" | wc -l | tr -d ' ')
SRC_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
COPIED_SIZE=$(du -sh "$NAS_DATA/$TARGET_DATE" | cut -f1)
if [ "$COPIED_FILES" -eq "$SRC_FILES" ]; then
printf "\r %-36s ✓ %dm%02ds (%s files, %s)\n" \
"rsync $TARGET_DATE/ → NAS" \
"$(( RSYNC_DUR / 60 ))" "$(( RSYNC_DUR % 60 ))" \
"$COPIED_FILES" "$COPIED_SIZE" | tee -a "$LOG_FILE"
else
printf "\r %-36s ✗ %s / %s files\n" \
"rsync $TARGET_DATE/ → NAS" "$COPIED_FILES" "$SRC_FILES" | tee -a "$LOG_FILE"
fi
else
printf " %-36s %s\n" "rsync $TARGET_DATE/ → NAS" "skipped (no source dir)"
fi
# ─── COPY LOGS ────────────────────────────────────────────────────────────────
# Screenpipe writes daily logs to ~/.screenpipe/screenpipe.YYYY-MM-DD.N.log
# (N is a rotation counter, almost always 0). Mirror them to NAS so log
# analysis can happen on the consumer side without SSH'ing back to the Mac.
step "Copying screenpipe logs for $TARGET_DATE"
NAS_LOGS="$NAS_MOUNT/logs"
mkdir -p "$NAS_LOGS"
# Use a glob with nullglob so an empty match doesn't expand to a literal pattern.
shopt -s nullglob
LOG_FILES=( "$HOME/.screenpipe/screenpipe.$TARGET_DATE."*.log )
shopt -u nullglob
if [ ${#LOG_FILES[@]} -gt 0 ]; then
printf " %-36s " "rsync logs → NAS"
# No --ignore-existing here: logs grow during the day, so we want rsync's
# default size+mtime check to refresh files that have changed.
rsync -a "${LOG_FILES[@]}" "$NAS_LOGS/" 2>>"$LOG_FILE"
COPIED=${#LOG_FILES[@]}
TOTAL_SIZE=$(du -ch "${LOG_FILES[@]}" | tail -1 | cut -f1)
printf "✓ %d file(s), %s\n" "$COPIED" "$TOTAL_SIZE" | tee -a "$LOG_FILE"
else
printf " %-36s %s\n" "rsync logs → NAS" "skipped (no matching logs)"
fi
# ─── SUMMARY ──────────────────────────────────────────────────────────────────
TOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))
DB_SIZE=$(du -sh "$NAS_DB" | cut -f1)
echo ""
log "Archive DB size: $DB_SIZE"
log "Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s"
log "Sync complete for $TARGET_DATE"
log "========================================"
# Mirror this script's own logbook to NAS so sync health can be monitored
# from the consumer side. Done last so the summary lines above are included.
rsync -a "$HOME/.screenpipe/sync.log" "$NAS_LOGS/sync.log" 2>/dev/null || true
Implement and run pipe l…, Editor Group 2
Problems (⇧⌘M)
PROBLEMS
Output (⇧⌘U)
OUTPUT
Debug Console (⇧⌘Y)
DEBUG CONSOLE
Terminal (⌃`)
TERMINAL
Ports - 1 forwarded port
PORTS
1
remote SSH: nas
SSH: nas
screenpipe (Git) - master*, Checkout Branch/Tag...
master*
screenpipe (Git) - Synchronize Changes
No Problems
0
0
Forwarded Ports: 8766
1
Notifications
Sign In
Sign In
Shell Script
Editor Language Status: Inline Suggestions, next: $(copilot) No inline suggestion available, Inline suggestions
LF
UTF-8
Spaces: 2
Ln 480, Col 3
git-commit Not Committed Yet
Not Committed Yet
No results found
Implement and run pipe logic
Session history
New session
Message actions
main.py
main.py
lets implement logic with pipes. how can I run it?
Thinking
Thinking
Let me look at the current project structure to understand what's already in place.
Bash
List project files
IN
find /volume1/screenpipe -type f | head -50 && echo "---" && ls /volume1/screenpipe
Copy code to clipboard
OUT
/volume1/screenpipe/.DS_Store
/volume1/screenpipe/screenpipe.db
/volume1/screenpipe/screenpipe_sync.sh
/volume1/screenpipe/app_settings.json
/volume1/screenpipe/.gitignore
/volume1/screenpipe/archive.db
/volume1/screenpipe/db.sqlite
/volume1/screenpipe/db.sqlite-wal
/volume1/screenpipe/db.sqlite-shm
/volume1/screenpipe/#recycle/desktop.ini
/volume1/screenpipe/#recycle/db.sqlite
/volume1/screenpipe/#recycle/Copy #1 of db.sqlite
/volume1/screenpipe/#recycle/.DS_Store
/volume1/screenpipe/#recycle/Copy #2 of db.sqlite
/volume1/screenpipe/#recycle/archive.db
/volume1/screenpipe/#recycle/Copy #1 of archive.db
/volume1/screenpipe/#recycle/Copy #2 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of archive.db
/volume1/screenpipe/#recycle/Copy #4 of archive.db
/volume1/screenpipe/#recycle/Copy #5 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of db.sqlite
/volume1/screenpipe/#recycle/Copy #4 of db.sqlite
/volume1/screenpipe/#recycle/Copy #6 of archive.db
/volume1/screenpipe/#recycle/test.txt
/volume1/screenpipe/#recycle/Copy #7 of archive.db
/volume1/screenpipe/#recycle/Copy #8 of archive.db
/volume1/screenpipe/#recycle/archive.db-journal
/volume1/screenpipe/#recycle/Copy #1 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #2 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #3 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #4 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #6 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #7 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of db.sqlite
/volume1/screenpipe/pipes/.DS_Store
/volume1/screenpipe/app/.env
/volume1/screenpipe/app/cli.py
/volume1/screenpipe/app/.DS_Store
/volume1/screenpipe/app/db.py
/volume1/screenpipe/app/docker-compose.yml
/volume1/screenpipe/app/main.py
/volume1/screenpipe/app/requirements.txt
/volume1/screenpipe/app/Dockerfile
/volume1/screenpipe/data/.DS_Store
/volume1/screenpipe/.git/description
/volume1/screenpipe/.git/HEAD
/volume1/screenpipe/.git/index
/volume1/screenpipe/.git/COMMIT_EDITMSG
/volume1/screenpipe/#recycle/data/.DS_Store
---
app
app_settings.json
archive.db
data
db.sqlite
db.sqlite-shm
db.sqlite-wal
pipes
#recycle
screenpipe.db
screenpipe_sync.sh
Read
main.py
main.py
Bash
Check pipes directory and docker-compose
IN
ls /volume1/screenpipe/pipes/ && ls /volume1/screenpipe/app/ && cat /volume1/screenpipe/app/docker-compose.yml
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
cli.py
consumers
db.py
docker-compose.yml
Dockerfile
main.py
__pycache__
requirements.txt
static
services:
screenpipe-app:
build: .
container_name: screenpipe-app
restart: unless-stopped
ports:
- "8766:8000"
volumes:
- /volume1/screenpipe:/data
env_file:
- .env
environment:
TZ: Europe/Sofia
DB_PATH: /data/db.sqlite
sqlite-web-archive:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-archive
restart: unless-stopped
ports:
- "8767:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/archive.db"]
sqlite-web-live:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-live
restart: unless-stopped
ports:
- "8768:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/db.sqlite"]
Read
requirements.txt
requirements.txt
Bash
Inspect a pipe directory
IN
ls /volume1/screenpipe/pipes/day-recap/ && cat /volume1/screenpipe/pipes/day-recap/pipe.json 2>/dev/null || ls /volume1/screenpipe/pipes/day-recap/
Copy code to clipboard
OUT
pipe.md
pipe.md...
|
[{"role":"AXRadioButton","text [{"role":"AXRadioButton","text":"Explorer (⇧⌘E) - 1 unsaved file","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":true},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Search (⇧⌘F)","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Source Control (⌃⇧G) - 10 pending changes","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"10","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Run and Debug (⇧⌘D)","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Remote Explorer","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Extensions (⇧⌘X) - 2 require update","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"2","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Claude Code","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"Containers","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXHeading","text":"EXPLORER","depth":17,"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"EXPLORER","depth":18,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Explorer Section: screenpipe [SSH: nas]","depth":21,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":true},{"role":"AXStaticText","text":"","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"Explorer Section: screenpipe [SSH: nas]","depth":22,"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"SCREENPIPE [SSH: NAS]","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"#recycle","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"app","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"__pycache__","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"consumers","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"static","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":".env","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"cli.py","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.py","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"docker-compose.yml","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Dockerfile","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"main.py","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"requirements.txt","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"data","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"logs","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"pipes","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":".gitignore","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"app_settings.json","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"archive.db","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"archive.db-bak","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"U","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite-shm","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite-wal","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe_sync_updated.sh","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"U","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe_sync.sh","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe.db","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Outline Section","depth":21,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"OUTLINE","depth":22,"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"OUTLINE","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Timeline Section","depth":21,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"TIMELINE","depth":22,"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"TIMELINE","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"app_settings.json, Editor Group 1","depth":28,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"screenpipe_sync.sh, Editor Group 1","depth":28,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":false},{"role":"AXRadioButton","text":"pipe.md, Editor Group 1","depth":28,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":".env, Editor Group 1","depth":28,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"#!/bin/bash\n# screenpipe_sync.sh\n# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).\n# Also copies the day's video/frame data folder to the NAS.\n#\n# Schema-drift tolerant: if Screenpipe migrations add new columns to the source DB,\n# the NAS archive gets ALTER TABLE'd to match. Inserts use explicit column lists,\n# so positional mismatches can't occur.\n#\n# Usage:\n# ./screenpipe_sync.sh # syncs yesterday (default)\n# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date\n# ./screenpipe_sync.sh today # syncs today so far\n#\n# Cron example (runs at 3am daily):\n# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1\n\nset -euo pipefail\n\n# ─── CONFIG ───────────────────────────────────────────────────────────────────\nDB_SRC=\"${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}\"\nNAS_MOUNT=\"${NAS_MOUNT:-/Volumes/screenpipe}\"\nNAS_DB=\"$NAS_MOUNT/archive.db\"\nNAS_DATA=\"$NAS_MOUNT/data\"\nLOG_FILE=\"$HOME/.screenpipe/sync.log\"\n# Tables that get schema drift handling. Order matters for FK-ish references\n# (parents before children: video_chunks → frames → elements/ocr_text/ui_events).\nSYNC_TABLES=(video_chunks frames elements ocr_text ui_events meetings)\n# ──────────────────────────────────────────────────────────────────────────────\n\n# ─── HELPERS ──────────────────────────────────────────────────────────────────\nSCRIPT_START=$(date +%s)\n\nlog() {\n local msg=\"[$(date '+%Y-%m-%d %H:%M:%S')] $*\"\n echo \"$msg\" | tee -a \"$LOG_FILE\"\n}\n\nstep() {\n local now=$(date +%s)\n local elapsed=$(( now - SCRIPT_START ))\n local min=$(( elapsed / 60 ))\n local sec=$(( elapsed % 60 ))\n printf \"\\n[+%02dm%02ds] ▶ %s\\n\" \"$min\" \"$sec\" \"$*\" | tee -a \"$LOG_FILE\"\n}\n\nrun_sqlite_heredoc() {\n local label=\"$1\"\n local sql=\"$2\"\n local start=$(date +%s)\n\n printf \" %-36s \" \"$label\"\n\n sqlite3 \"$DB_SRC\" <<< \"$sql\" &\n local pid=$!\n local spin=('⠋' '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')\n local i=0\n while kill -0 \"$pid\" 2>/dev/null; do\n printf \"\\r %-36s %s \" \"$label\" \"${spin[$i]}\"\n i=$(( (i + 1) % 10 ))\n sleep 0.2\n done\n wait \"$pid\"\n local rc=$?\n if [ $rc -ne 0 ]; then\n printf \"\\r %-36s ✗ FAILED\\n\" \"$label\" | tee -a \"$LOG_FILE\"\n exit $rc\n fi\n\n local dur=$(( $(date +%s) - start ))\n printf \"\\r %-36s ✓ %dm%02ds\\n\" \"$label\" \"$(( dur / 60 ))\" \"$(( dur % 60 ))\" | tee -a \"$LOG_FILE\"\n}\n\ncheck() {\n local label=\"$1\" got=\"$2\" expected=\"$3\"\n if [ \"$got\" -eq \"$expected\" ]; then\n printf \" %-20s %s / %s ✓\\n\" \"$label:\" \"$got\" \"$expected\"\n else\n printf \" %-20s %s / %s ✗ MISMATCH\\n\" \"$label:\" \"$got\" \"$expected\"\n fi\n}\n\n# ─── SCHEMA HELPERS ───────────────────────────────────────────────────────────\n# Echoes \"name|type\" lines for a table from a given DB.\ntable_columns_with_types() {\n local db=\"$1\" table=\"$2\"\n sqlite3 \"$db\" \"PRAGMA table_info($table);\" | awk -F'|' '{print $2 \"|\" $3}'\n}\n\n# Echoes just column names, one per line.\ntable_columns() {\n local db=\"$1\" table=\"$2\"\n sqlite3 \"$db\" \"PRAGMA table_info($table);\" | awk -F'|' '{print $2}'\n}\n\n# Returns true (0) if a table exists in the given DB.\ntable_exists() {\n local db=\"$1\" table=\"$2\"\n local count\n count=$(sqlite3 \"$db\" \"SELECT COUNT(*) FROM sqlite_master WHERE type='table' AND name='$table';\")\n [ \"$count\" -gt 0 ]\n}\n\n# Adds any columns present in source but missing in NAS for the given table.\n# Uses ALTER TABLE ADD COLUMN, which is a fast metadata-only operation in SQLite.\nensure_columns() {\n local table=\"$1\"\n local label=\"schema: $table\"\n printf \" %-36s \" \"$label\"\n\n if ! table_exists \"$DB_SRC\" \"$table\"; then\n printf \"✗ source missing — skipping\\n\"\n return 0\n fi\n\n if ! table_exists \"$NAS_DB\" \"$table\"; then\n printf \"✓ fresh (created above)\\n\"\n return 0\n fi\n\n local src_cols\n src_cols=$(table_columns_with_types \"$DB_SRC\" \"$table\")\n local nas_cols\n nas_cols=$(table_columns \"$NAS_DB\" \"$table\")\n\n local added=0\n local added_names=\"\"\n while IFS='|' read -r name type; do\n [ -z \"$name\" ] && continue\n # Use grep -F -x for fixed-string exact match (safe against regex chars).\n if ! echo \"$nas_cols\" | grep -Fxq \"$name\"; then\n # SQLite ALTER TABLE ADD COLUMN: type is optional, no NOT NULL allowed\n # without a constant default. Default-NULL is exactly what we want for archive.\n sqlite3 \"$NAS_DB\" \"ALTER TABLE $table ADD COLUMN \\\"$name\\\" $type;\"\n added=$((added + 1))\n added_names=\"$added_names $name\"\n fi\n done <<< \"$src_cols\"\n\n if [ \"$added\" -gt 0 ]; then\n printf \"✓ added %d:%s\\n\" \"$added\" \"$added_names\"\n else\n printf \"✓ in sync\\n\"\n fi\n}\n\n# Echoes a comma-separated list of source columns for a table, double-quoted\n# so reserved words and hyphens are safe. If an alias is provided, columns are\n# prefixed (e.g. `o.\"col\"`). Used for both INSERT and SELECT sides; aliased\n# form is required when SELECTing from a JOIN where column names collide\n# (e.g. ocr_text and frames both have app_name, window_name).\nbuild_col_list() {\n local table=\"$1\"\n local alias=\"${2:-}\"\n local prefix=\"\"\n [ -n \"$alias\" ] && prefix=\"${alias}.\"\n table_columns \"$DB_SRC\" \"$table\" | awk 'NF' | awk -v p=\"$prefix\" '{print p \"\\\"\" $0 \"\\\"\"}' | paste -sd, -\n}\n# ──────────────────────────────────────────────────────────────────────────────\n\n# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────\nif [ \"${1:-}\" = \"today\" ]; then\n TARGET_DATE=$(date +%Y-%m-%d)\nelif [ -n \"${1:-}\" ]; then\n TARGET_DATE=\"$1\"\n if ! [[ \"$TARGET_DATE\" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then\n echo \"ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday.\"\n exit 1\n fi\nelse\n TARGET_DATE=$(date -v-1d +%Y-%m-%d)\nfi\n\nlog \"========================================\"\nlog \"Screenpipe sync starting for: $TARGET_DATE\"\nlog \"========================================\"\n\n# ─── PREFLIGHT ────────────────────────────────────────────────────────────────\nstep \"Preflight checks\"\n\nif [ ! -f \"$DB_SRC\" ]; then\n log \"ERROR: Source DB not found at $DB_SRC\"; exit 1\nfi\nprintf \" %-20s %s (%s)\\n\" \"Source DB:\" \"OK\" \"$(du -sh \"$DB_SRC\" | cut -f1)\"\n\nif [ ! -d \"$NAS_MOUNT\" ]; then\n log \"ERROR: NAS not mounted at $NAS_MOUNT\"; exit 1\nfi\nprintf \" %-20s %s\\n\" \"NAS mount:\" \"OK $NAS_MOUNT\"\n\n# Check if DB already synced for this date\nDB_ALREADY_SYNCED=false\nif [ -f \"$NAS_DB\" ]; then\n if table_exists \"$NAS_DB\" \"frames\"; then\n EXISTING=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\" 2>/dev/null || echo \"0\")\n if [ \"$EXISTING\" -gt \"0\" ]; then\n log \"Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync\"\n DB_ALREADY_SYNCED=true\n else\n printf \" %-20s %s (%s)\\n\" \"Archive DB:\" \"exists\" \"$(du -sh \"$NAS_DB\" | cut -f1)\"\n fi\n else\n printf \" %-20s %s\\n\" \"Archive DB:\" \"exists, no frames table yet\"\n fi\nelse\n printf \" %-20s %s\\n\" \"Archive DB:\" \"will be created\"\nfi\n\n# Source data dir for this date\nDATA_SRC=\"$HOME/.screenpipe/data/data/$TARGET_DATE\"\nif [ -d \"$DATA_SRC\" ]; then\n DATA_SIZE=$(du -sh \"$DATA_SRC\" | cut -f1)\n DATA_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n printf \" %-20s %s (%s files, %s)\\n\" \"Data dir:\" \"OK\" \"$DATA_FILES\" \"$DATA_SIZE\"\nelse\n printf \" %-20s %s\\n\" \"Data dir:\" \"not found — skipping file copy\"\nfi\n\n# ─── DB SYNC ──────────────────────────────────────────────────────────────────\nif [ \"$DB_ALREADY_SYNCED\" = false ]; then\n\n # ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────\n step \"Counting source rows for $TARGET_DATE\"\n\n SRC_FRAMES=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\")\n SRC_ELEMENTS=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n SRC_UI=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';\")\n SRC_OCR=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n SRC_MEETINGS=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';\")\n\n printf \" %-20s %s\\n\" \"frames:\" \"$SRC_FRAMES\"\n printf \" %-20s %s\\n\" \"elements:\" \"$SRC_ELEMENTS\"\n printf \" %-20s %s\\n\" \"ui_events:\" \"$SRC_UI\"\n printf \" %-20s %s\\n\" \"ocr_text:\" \"$SRC_OCR\"\n printf \" %-20s %s\\n\" \"meetings:\" \"$SRC_MEETINGS\"\n\n if [ \"$SRC_FRAMES\" -eq \"0\" ]; then\n log \"No frames found for $TARGET_DATE — skipping DB sync\"\n DB_ALREADY_SYNCED=true\n fi\n\nfi\n\nif [ \"$DB_ALREADY_SYNCED\" = false ]; then\n\n # ─── INIT TABLES ──────────────────────────────────────────────────────────\n step \"Initialising tables (CREATE IF NOT EXISTS)\"\n\n run_sqlite_heredoc \"creating tables\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;\nDETACH nas;\n\"\n\n # ─── SCHEMA DRIFT FIX ─────────────────────────────────────────────────────\n # Runs AFTER CREATE IF NOT EXISTS so newly-created tables are no-ops here,\n # and pre-existing tables get any missing columns added.\n step \"Reconciling NAS schema with source\"\n for tbl in \"${SYNC_TABLES[@]}\"; do\n ensure_columns \"$tbl\"\n done\n\n run_sqlite_heredoc \"creating indexes\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_document_path ON frames(document_path) WHERE document_path IS NOT NULL;\nCREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;\nCREATE INDEX IF NOT EXISTS nas.idx_elements_onscreen_frame ON elements(frame_id) WHERE on_screen = 1 AND text IS NOT NULL;\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);\nCREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"creating FTS tables\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(\n text, role, frame_id UNINDEXED,\n content='elements', content_rowid='id', tokenize='unicode61'\n);\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(\n full_text, app_name, window_name, browser_url, id UNINDEXED,\n tokenize='unicode61'\n);\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(\n text_content,\n app_name,\n window_title,\n element_name,\n content='ui_events',\n content_rowid='id',\n tokenize='unicode61'\n);\nDETACH nas;\n\"\n\n # ─── BUILD EXPLICIT COLUMN LISTS ──────────────────────────────────────────\n # After ensure_columns, source ⊆ NAS for every synced table, so source's\n # column list is a safe subset to use on both sides of the INSERT.\n # For tables that JOIN frames (ocr_text, elements), the SELECT side needs\n # alias-qualified columns because both tables share names (app_name, etc).\n FRAMES_COLS=$(build_col_list frames)\n ELEMENTS_COLS=$(build_col_list elements)\n ELEMENTS_COLS_E=$(build_col_list elements e)\n UI_EVENTS_COLS=$(build_col_list ui_events)\n OCR_TEXT_COLS=$(build_col_list ocr_text)\n OCR_TEXT_COLS_O=$(build_col_list ocr_text o)\n VIDEO_CHUNKS_COLS=$(build_col_list video_chunks)\n MEETINGS_COLS=$(build_col_list meetings)\n\n # ─── SYNC DATA ────────────────────────────────────────────────────────────\n step \"Syncing data for $TARGET_DATE\"\n\n run_sqlite_heredoc \"video_chunks\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.video_chunks ($VIDEO_CHUNKS_COLS)\n SELECT $VIDEO_CHUNKS_COLS FROM main.video_chunks\n WHERE id IN (\n SELECT DISTINCT video_chunk_id FROM main.frames\n WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL\n );\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames ($SRC_FRAMES rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.frames ($FRAMES_COLS)\n SELECT $FRAMES_COLS FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ocr_text ($SRC_OCR rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ocr_text ($OCR_TEXT_COLS)\n SELECT $OCR_TEXT_COLS_O FROM main.ocr_text o\n JOIN main.frames f ON o.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events ($SRC_UI rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ui_events ($UI_EVENTS_COLS)\n SELECT $UI_EVENTS_COLS FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"elements ($SRC_ELEMENTS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.elements ($ELEMENTS_COLS)\n SELECT $ELEMENTS_COLS_E FROM main.elements e\n JOIN main.frames f ON e.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"meetings ($SRC_MEETINGS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.meetings ($MEETINGS_COLS)\n SELECT $MEETINGS_COLS FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n # ─── FTS UPDATE ───────────────────────────────────────────────────────────\n step \"Updating FTS indexes\"\n\n run_sqlite_heredoc \"elements_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.elements_fts(rowid, text, role)\n SELECT e.id, e.text, e.role\n FROM nas.elements e\n JOIN nas.frames f ON e.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE'\n AND e.text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)\n SELECT id, full_text, app_name, window_name, browser_url, id\n FROM nas.frames\n WHERE date(timestamp) = '$TARGET_DATE'\n AND full_text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)\n SELECT id, text_content, app_name, window_title, element_name\n FROM nas.ui_events\n WHERE date(timestamp) = '$TARGET_DATE'\n AND text_content IS NOT NULL;\nDETACH nas;\n\"\n\n # ─── VERIFY DB ────────────────────────────────────────────────────────────\n step \"Verifying DB\"\n\n V_FRAMES=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\")\n V_ELEMENTS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n V_UI=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';\")\n V_OCR=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n V_MEETINGS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';\")\n\n check \"frames\" \"$V_FRAMES\" \"$SRC_FRAMES\"\n check \"elements\" \"$V_ELEMENTS\" \"$SRC_ELEMENTS\"\n check \"ui_events\" \"$V_UI\" \"$SRC_UI\"\n check \"ocr_text\" \"$V_OCR\" \"$SRC_OCR\"\n check \"meetings\" \"$V_MEETINGS\" \"$SRC_MEETINGS\"\n\nfi\n\n# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────\n# Always runs regardless of DB sync status\nstep \"Copying data folder for $TARGET_DATE\"\n\nif [ -d \"$DATA_SRC\" ]; then\n mkdir -p \"$NAS_DATA/$TARGET_DATE\"\n RSYNC_START=$(date +%s)\n printf \" %-36s \" \"rsync $TARGET_DATE/ → NAS\"\n rsync -a --ignore-existing \\\n \"$DATA_SRC/\" \\\n \"$NAS_DATA/$TARGET_DATE/\" \\\n 2>>\"$LOG_FILE\"\n RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))\n COPIED_FILES=$(ls \"$NAS_DATA/$TARGET_DATE\" | wc -l | tr -d ' ')\n SRC_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n COPIED_SIZE=$(du -sh \"$NAS_DATA/$TARGET_DATE\" | cut -f1)\n if [ \"$COPIED_FILES\" -eq \"$SRC_FILES\" ]; then\n printf \"\\r %-36s ✓ %dm%02ds (%s files, %s)\\n\" \\\n \"rsync $TARGET_DATE/ → NAS\" \\\n \"$(( RSYNC_DUR / 60 ))\" \"$(( RSYNC_DUR % 60 ))\" \\\n \"$COPIED_FILES\" \"$COPIED_SIZE\" | tee -a \"$LOG_FILE\"\n else\n printf \"\\r %-36s ✗ %s / %s files\\n\" \\\n \"rsync $TARGET_DATE/ → NAS\" \"$COPIED_FILES\" \"$SRC_FILES\" | tee -a \"$LOG_FILE\"\n fi\nelse\n printf \" %-36s %s\\n\" \"rsync $TARGET_DATE/ → NAS\" \"skipped (no source dir)\"\nfi\n\n# ─── COPY LOGS ────────────────────────────────────────────────────────────────\n# Screenpipe writes daily logs to ~/.screenpipe/screenpipe.YYYY-MM-DD.N.log\n# (N is a rotation counter, almost always 0). Mirror them to NAS so log\n# analysis can happen on the consumer side without SSH'ing back to the Mac.\nstep \"Copying screenpipe logs for $TARGET_DATE\"\n\nNAS_LOGS=\"$NAS_MOUNT/logs\"\nmkdir -p \"$NAS_LOGS\"\n\n# Use a glob with nullglob so an empty match doesn't expand to a literal pattern.\nshopt -s nullglob\nLOG_FILES=( \"$HOME/.screenpipe/screenpipe.$TARGET_DATE.\"*.log )\nshopt -u nullglob\n\nif [ ${#LOG_FILES[@]} -gt 0 ]; then\n printf \" %-36s \" \"rsync logs → NAS\"\n # No --ignore-existing here: logs grow during the day, so we want rsync's\n # default size+mtime check to refresh files that have changed.\n rsync -a \"${LOG_FILES[@]}\" \"$NAS_LOGS/\" 2>>\"$LOG_FILE\"\n COPIED=${#LOG_FILES[@]}\n TOTAL_SIZE=$(du -ch \"${LOG_FILES[@]}\" | tail -1 | cut -f1)\n printf \"✓ %d file(s), %s\\n\" \"$COPIED\" \"$TOTAL_SIZE\" | tee -a \"$LOG_FILE\"\nelse\n printf \" %-36s %s\\n\" \"rsync logs → NAS\" \"skipped (no matching logs)\"\nfi\n\n# ─── SUMMARY ──────────────────────────────────────────────────────────────────\nTOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))\nDB_SIZE=$(du -sh \"$NAS_DB\" | cut -f1)\n\necho \"\"\nlog \"Archive DB size: $DB_SIZE\"\nlog \"Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s\"\nlog \"Sync complete for $TARGET_DATE\"\nlog \"========================================\"\n\n# Mirror this script's own logbook to NAS so sync health can be monitored\n# from the consumer side. Done last so the summary lines above are included.\nrsync -a \"$HOME/.screenpipe/sync.log\" \"$NAS_LOGS/sync.log\" 2>/dev/null || true","depth":28,"on_screen":true,"value":"#!/bin/bash\n# screenpipe_sync.sh\n# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).\n# Also copies the day's video/frame data folder to the NAS.\n#\n# Schema-drift tolerant: if Screenpipe migrations add new columns to the source DB,\n# the NAS archive gets ALTER TABLE'd to match. Inserts use explicit column lists,\n# so positional mismatches can't occur.\n#\n# Usage:\n# ./screenpipe_sync.sh # syncs yesterday (default)\n# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date\n# ./screenpipe_sync.sh today # syncs today so far\n#\n# Cron example (runs at 3am daily):\n# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1\n\nset -euo pipefail\n\n# ─── CONFIG ───────────────────────────────────────────────────────────────────\nDB_SRC=\"${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}\"\nNAS_MOUNT=\"${NAS_MOUNT:-/Volumes/screenpipe}\"\nNAS_DB=\"$NAS_MOUNT/archive.db\"\nNAS_DATA=\"$NAS_MOUNT/data\"\nLOG_FILE=\"$HOME/.screenpipe/sync.log\"\n# Tables that get schema drift handling. Order matters for FK-ish references\n# (parents before children: video_chunks → frames → elements/ocr_text/ui_events).\nSYNC_TABLES=(video_chunks frames elements ocr_text ui_events meetings)\n# ──────────────────────────────────────────────────────────────────────────────\n\n# ─── HELPERS ──────────────────────────────────────────────────────────────────\nSCRIPT_START=$(date +%s)\n\nlog() {\n local msg=\"[$(date '+%Y-%m-%d %H:%M:%S')] $*\"\n echo \"$msg\" | tee -a \"$LOG_FILE\"\n}\n\nstep() {\n local now=$(date +%s)\n local elapsed=$(( now - SCRIPT_START ))\n local min=$(( elapsed / 60 ))\n local sec=$(( elapsed % 60 ))\n printf \"\\n[+%02dm%02ds] ▶ %s\\n\" \"$min\" \"$sec\" \"$*\" | tee -a \"$LOG_FILE\"\n}\n\nrun_sqlite_heredoc() {\n local label=\"$1\"\n local sql=\"$2\"\n local start=$(date +%s)\n\n printf \" %-36s \" \"$label\"\n\n sqlite3 \"$DB_SRC\" <<< \"$sql\" &\n local pid=$!\n local spin=('⠋' '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')\n local i=0\n while kill -0 \"$pid\" 2>/dev/null; do\n printf \"\\r %-36s %s \" \"$label\" \"${spin[$i]}\"\n i=$(( (i + 1) % 10 ))\n sleep 0.2\n done\n wait \"$pid\"\n local rc=$?\n if [ $rc -ne 0 ]; then\n printf \"\\r %-36s ✗ FAILED\\n\" \"$label\" | tee -a \"$LOG_FILE\"\n exit $rc\n fi\n\n local dur=$(( $(date +%s) - start ))\n printf \"\\r %-36s ✓ %dm%02ds\\n\" \"$label\" \"$(( dur / 60 ))\" \"$(( dur % 60 ))\" | tee -a \"$LOG_FILE\"\n}\n\ncheck() {\n local label=\"$1\" got=\"$2\" expected=\"$3\"\n if [ \"$got\" -eq \"$expected\" ]; then\n printf \" %-20s %s / %s ✓\\n\" \"$label:\" \"$got\" \"$expected\"\n else\n printf \" %-20s %s / %s ✗ MISMATCH\\n\" \"$label:\" \"$got\" \"$expected\"\n fi\n}\n\n# ─── SCHEMA HELPERS ───────────────────────────────────────────────────────────\n# Echoes \"name|type\" lines for a table from a given DB.\ntable_columns_with_types() {\n local db=\"$1\" table=\"$2\"\n sqlite3 \"$db\" \"PRAGMA table_info($table);\" | awk -F'|' '{print $2 \"|\" $3}'\n}\n\n# Echoes just column names, one per line.\ntable_columns() {\n local db=\"$1\" table=\"$2\"\n sqlite3 \"$db\" \"PRAGMA table_info($table);\" | awk -F'|' '{print $2}'\n}\n\n# Returns true (0) if a table exists in the given DB.\ntable_exists() {\n local db=\"$1\" table=\"$2\"\n local count\n count=$(sqlite3 \"$db\" \"SELECT COUNT(*) FROM sqlite_master WHERE type='table' AND name='$table';\")\n [ \"$count\" -gt 0 ]\n}\n\n# Adds any columns present in source but missing in NAS for the given table.\n# Uses ALTER TABLE ADD COLUMN, which is a fast metadata-only operation in SQLite.\nensure_columns() {\n local table=\"$1\"\n local label=\"schema: $table\"\n printf \" %-36s \" \"$label\"\n\n if ! table_exists \"$DB_SRC\" \"$table\"; then\n printf \"✗ source missing — skipping\\n\"\n return 0\n fi\n\n if ! table_exists \"$NAS_DB\" \"$table\"; then\n printf \"✓ fresh (created above)\\n\"\n return 0\n fi\n\n local src_cols\n src_cols=$(table_columns_with_types \"$DB_SRC\" \"$table\")\n local nas_cols\n nas_cols=$(table_columns \"$NAS_DB\" \"$table\")\n\n local added=0\n local added_names=\"\"\n while IFS='|' read -r name type; do\n [ -z \"$name\" ] && continue\n # Use grep -F -x for fixed-string exact match (safe against regex chars).\n if ! echo \"$nas_cols\" | grep -Fxq \"$name\"; then\n # SQLite ALTER TABLE ADD COLUMN: type is optional, no NOT NULL allowed\n # without a constant default. Default-NULL is exactly what we want for archive.\n sqlite3 \"$NAS_DB\" \"ALTER TABLE $table ADD COLUMN \\\"$name\\\" $type;\"\n added=$((added + 1))\n added_names=\"$added_names $name\"\n fi\n done <<< \"$src_cols\"\n\n if [ \"$added\" -gt 0 ]; then\n printf \"✓ added %d:%s\\n\" \"$added\" \"$added_names\"\n else\n printf \"✓ in sync\\n\"\n fi\n}\n\n# Echoes a comma-separated list of source columns for a table, double-quoted\n# so reserved words and hyphens are safe. If an alias is provided, columns are\n# prefixed (e.g. `o.\"col\"`). Used for both INSERT and SELECT sides; aliased\n# form is required when SELECTing from a JOIN where column names collide\n# (e.g. ocr_text and frames both have app_name, window_name).\nbuild_col_list() {\n local table=\"$1\"\n local alias=\"${2:-}\"\n local prefix=\"\"\n [ -n \"$alias\" ] && prefix=\"${alias}.\"\n table_columns \"$DB_SRC\" \"$table\" | awk 'NF' | awk -v p=\"$prefix\" '{print p \"\\\"\" $0 \"\\\"\"}' | paste -sd, -\n}\n# ──────────────────────────────────────────────────────────────────────────────\n\n# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────\nif [ \"${1:-}\" = \"today\" ]; then\n TARGET_DATE=$(date +%Y-%m-%d)\nelif [ -n \"${1:-}\" ]; then\n TARGET_DATE=\"$1\"\n if ! [[ \"$TARGET_DATE\" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then\n echo \"ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday.\"\n exit 1\n fi\nelse\n TARGET_DATE=$(date -v-1d +%Y-%m-%d)\nfi\n\nlog \"========================================\"\nlog \"Screenpipe sync starting for: $TARGET_DATE\"\nlog \"========================================\"\n\n# ─── PREFLIGHT ────────────────────────────────────────────────────────────────\nstep \"Preflight checks\"\n\nif [ ! -f \"$DB_SRC\" ]; then\n log \"ERROR: Source DB not found at $DB_SRC\"; exit 1\nfi\nprintf \" %-20s %s (%s)\\n\" \"Source DB:\" \"OK\" \"$(du -sh \"$DB_SRC\" | cut -f1)\"\n\nif [ ! -d \"$NAS_MOUNT\" ]; then\n log \"ERROR: NAS not mounted at $NAS_MOUNT\"; exit 1\nfi\nprintf \" %-20s %s\\n\" \"NAS mount:\" \"OK $NAS_MOUNT\"\n\n# Check if DB already synced for this date\nDB_ALREADY_SYNCED=false\nif [ -f \"$NAS_DB\" ]; then\n if table_exists \"$NAS_DB\" \"frames\"; then\n EXISTING=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\" 2>/dev/null || echo \"0\")\n if [ \"$EXISTING\" -gt \"0\" ]; then\n log \"Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync\"\n DB_ALREADY_SYNCED=true\n else\n printf \" %-20s %s (%s)\\n\" \"Archive DB:\" \"exists\" \"$(du -sh \"$NAS_DB\" | cut -f1)\"\n fi\n else\n printf \" %-20s %s\\n\" \"Archive DB:\" \"exists, no frames table yet\"\n fi\nelse\n printf \" %-20s %s\\n\" \"Archive DB:\" \"will be created\"\nfi\n\n# Source data dir for this date\nDATA_SRC=\"$HOME/.screenpipe/data/data/$TARGET_DATE\"\nif [ -d \"$DATA_SRC\" ]; then\n DATA_SIZE=$(du -sh \"$DATA_SRC\" | cut -f1)\n DATA_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n printf \" %-20s %s (%s files, %s)\\n\" \"Data dir:\" \"OK\" \"$DATA_FILES\" \"$DATA_SIZE\"\nelse\n printf \" %-20s %s\\n\" \"Data dir:\" \"not found — skipping file copy\"\nfi\n\n# ─── DB SYNC ──────────────────────────────────────────────────────────────────\nif [ \"$DB_ALREADY_SYNCED\" = false ]; then\n\n # ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────\n step \"Counting source rows for $TARGET_DATE\"\n\n SRC_FRAMES=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\")\n SRC_ELEMENTS=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n SRC_UI=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';\")\n SRC_OCR=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n SRC_MEETINGS=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';\")\n\n printf \" %-20s %s\\n\" \"frames:\" \"$SRC_FRAMES\"\n printf \" %-20s %s\\n\" \"elements:\" \"$SRC_ELEMENTS\"\n printf \" %-20s %s\\n\" \"ui_events:\" \"$SRC_UI\"\n printf \" %-20s %s\\n\" \"ocr_text:\" \"$SRC_OCR\"\n printf \" %-20s %s\\n\" \"meetings:\" \"$SRC_MEETINGS\"\n\n if [ \"$SRC_FRAMES\" -eq \"0\" ]; then\n log \"No frames found for $TARGET_DATE — skipping DB sync\"\n DB_ALREADY_SYNCED=true\n fi\n\nfi\n\nif [ \"$DB_ALREADY_SYNCED\" = false ]; then\n\n # ─── INIT TABLES ──────────────────────────────────────────────────────────\n step \"Initialising tables (CREATE IF NOT EXISTS)\"\n\n run_sqlite_heredoc \"creating tables\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;\nDETACH nas;\n\"\n\n # ─── SCHEMA DRIFT FIX ─────────────────────────────────────────────────────\n # Runs AFTER CREATE IF NOT EXISTS so newly-created tables are no-ops here,\n # and pre-existing tables get any missing columns added.\n step \"Reconciling NAS schema with source\"\n for tbl in \"${SYNC_TABLES[@]}\"; do\n ensure_columns \"$tbl\"\n done\n\n run_sqlite_heredoc \"creating indexes\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_document_path ON frames(document_path) WHERE document_path IS NOT NULL;\nCREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;\nCREATE INDEX IF NOT EXISTS nas.idx_elements_onscreen_frame ON elements(frame_id) WHERE on_screen = 1 AND text IS NOT NULL;\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);\nCREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"creating FTS tables\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(\n text, role, frame_id UNINDEXED,\n content='elements', content_rowid='id', tokenize='unicode61'\n);\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(\n full_text, app_name, window_name, browser_url, id UNINDEXED,\n tokenize='unicode61'\n);\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(\n text_content,\n app_name,\n window_title,\n element_name,\n content='ui_events',\n content_rowid='id',\n tokenize='unicode61'\n);\nDETACH nas;\n\"\n\n # ─── BUILD EXPLICIT COLUMN LISTS ──────────────────────────────────────────\n # After ensure_columns, source ⊆ NAS for every synced table, so source's\n # column list is a safe subset to use on both sides of the INSERT.\n # For tables that JOIN frames (ocr_text, elements), the SELECT side needs\n # alias-qualified columns because both tables share names (app_name, etc).\n FRAMES_COLS=$(build_col_list frames)\n ELEMENTS_COLS=$(build_col_list elements)\n ELEMENTS_COLS_E=$(build_col_list elements e)\n UI_EVENTS_COLS=$(build_col_list ui_events)\n OCR_TEXT_COLS=$(build_col_list ocr_text)\n OCR_TEXT_COLS_O=$(build_col_list ocr_text o)\n VIDEO_CHUNKS_COLS=$(build_col_list video_chunks)\n MEETINGS_COLS=$(build_col_list meetings)\n\n # ─── SYNC DATA ────────────────────────────────────────────────────────────\n step \"Syncing data for $TARGET_DATE\"\n\n run_sqlite_heredoc \"video_chunks\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.video_chunks ($VIDEO_CHUNKS_COLS)\n SELECT $VIDEO_CHUNKS_COLS FROM main.video_chunks\n WHERE id IN (\n SELECT DISTINCT video_chunk_id FROM main.frames\n WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL\n );\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames ($SRC_FRAMES rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.frames ($FRAMES_COLS)\n SELECT $FRAMES_COLS FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ocr_text ($SRC_OCR rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ocr_text ($OCR_TEXT_COLS)\n SELECT $OCR_TEXT_COLS_O FROM main.ocr_text o\n JOIN main.frames f ON o.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events ($SRC_UI rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ui_events ($UI_EVENTS_COLS)\n SELECT $UI_EVENTS_COLS FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"elements ($SRC_ELEMENTS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.elements ($ELEMENTS_COLS)\n SELECT $ELEMENTS_COLS_E FROM main.elements e\n JOIN main.frames f ON e.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"meetings ($SRC_MEETINGS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.meetings ($MEETINGS_COLS)\n SELECT $MEETINGS_COLS FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n # ─── FTS UPDATE ───────────────────────────────────────────────────────────\n step \"Updating FTS indexes\"\n\n run_sqlite_heredoc \"elements_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.elements_fts(rowid, text, role)\n SELECT e.id, e.text, e.role\n FROM nas.elements e\n JOIN nas.frames f ON e.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE'\n AND e.text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)\n SELECT id, full_text, app_name, window_name, browser_url, id\n FROM nas.frames\n WHERE date(timestamp) = '$TARGET_DATE'\n AND full_text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)\n SELECT id, text_content, app_name, window_title, element_name\n FROM nas.ui_events\n WHERE date(timestamp) = '$TARGET_DATE'\n AND text_content IS NOT NULL;\nDETACH nas;\n\"\n\n # ─── VERIFY DB ────────────────────────────────────────────────────────────\n step \"Verifying DB\"\n\n V_FRAMES=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\")\n V_ELEMENTS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n V_UI=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';\")\n V_OCR=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n V_MEETINGS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';\")\n\n check \"frames\" \"$V_FRAMES\" \"$SRC_FRAMES\"\n check \"elements\" \"$V_ELEMENTS\" \"$SRC_ELEMENTS\"\n check \"ui_events\" \"$V_UI\" \"$SRC_UI\"\n check \"ocr_text\" \"$V_OCR\" \"$SRC_OCR\"\n check \"meetings\" \"$V_MEETINGS\" \"$SRC_MEETINGS\"\n\nfi\n\n# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────\n# Always runs regardless of DB sync status\nstep \"Copying data folder for $TARGET_DATE\"\n\nif [ -d \"$DATA_SRC\" ]; then\n mkdir -p \"$NAS_DATA/$TARGET_DATE\"\n RSYNC_START=$(date +%s)\n printf \" %-36s \" \"rsync $TARGET_DATE/ → NAS\"\n rsync -a --ignore-existing \\\n \"$DATA_SRC/\" \\\n \"$NAS_DATA/$TARGET_DATE/\" \\\n 2>>\"$LOG_FILE\"\n RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))\n COPIED_FILES=$(ls \"$NAS_DATA/$TARGET_DATE\" | wc -l | tr -d ' ')\n SRC_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n COPIED_SIZE=$(du -sh \"$NAS_DATA/$TARGET_DATE\" | cut -f1)\n if [ \"$COPIED_FILES\" -eq \"$SRC_FILES\" ]; then\n printf \"\\r %-36s ✓ %dm%02ds (%s files, %s)\\n\" \\\n \"rsync $TARGET_DATE/ → NAS\" \\\n \"$(( RSYNC_DUR / 60 ))\" \"$(( RSYNC_DUR % 60 ))\" \\\n \"$COPIED_FILES\" \"$COPIED_SIZE\" | tee -a \"$LOG_FILE\"\n else\n printf \"\\r %-36s ✗ %s / %s files\\n\" \\\n \"rsync $TARGET_DATE/ → NAS\" \"$COPIED_FILES\" \"$SRC_FILES\" | tee -a \"$LOG_FILE\"\n fi\nelse\n printf \" %-36s %s\\n\" \"rsync $TARGET_DATE/ → NAS\" \"skipped (no source dir)\"\nfi\n\n# ─── COPY LOGS ────────────────────────────────────────────────────────────────\n# Screenpipe writes daily logs to ~/.screenpipe/screenpipe.YYYY-MM-DD.N.log\n# (N is a rotation counter, almost always 0). Mirror them to NAS so log\n# analysis can happen on the consumer side without SSH'ing back to the Mac.\nstep \"Copying screenpipe logs for $TARGET_DATE\"\n\nNAS_LOGS=\"$NAS_MOUNT/logs\"\nmkdir -p \"$NAS_LOGS\"\n\n# Use a glob with nullglob so an empty match doesn't expand to a literal pattern.\nshopt -s nullglob\nLOG_FILES=( \"$HOME/.screenpipe/screenpipe.$TARGET_DATE.\"*.log )\nshopt -u nullglob\n\nif [ ${#LOG_FILES[@]} -gt 0 ]; then\n printf \" %-36s \" \"rsync logs → NAS\"\n # No --ignore-existing here: logs grow during the day, so we want rsync's\n # default size+mtime check to refresh files that have changed.\n rsync -a \"${LOG_FILES[@]}\" \"$NAS_LOGS/\" 2>>\"$LOG_FILE\"\n COPIED=${#LOG_FILES[@]}\n TOTAL_SIZE=$(du -ch \"${LOG_FILES[@]}\" | tail -1 | cut -f1)\n printf \"✓ %d file(s), %s\\n\" \"$COPIED\" \"$TOTAL_SIZE\" | tee -a \"$LOG_FILE\"\nelse\n printf \" %-36s %s\\n\" \"rsync logs → NAS\" \"skipped (no matching logs)\"\nfi\n\n# ─── SUMMARY ──────────────────────────────────────────────────────────────────\nTOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))\nDB_SIZE=$(du -sh \"$NAS_DB\" | cut -f1)\n\necho \"\"\nlog \"Archive DB size: $DB_SIZE\"\nlog \"Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s\"\nlog \"Sync complete for $TARGET_DATE\"\nlog \"========================================\"\n\n# Mirror this script's own logbook to NAS so sync health can be monitored\n# from the consumer side. Done last so the summary lines above are included.\nrsync -a \"$HOME/.screenpipe/sync.log\" \"$NAS_LOGS/sync.log\" 2>/dev/null || true","role_description":"editor","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"#!/bin/bash\n# screenpipe_sync.sh\n# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).\n# Also copies the day's video/frame data folder to the NAS.\n#\n# Schema-drift tolerant: if Screenpipe migrations add new columns to the source DB,\n# the NAS archive gets ALTER TABLE'd to match. Inserts use explicit column lists,\n# so positional mismatches can't occur.\n#\n# Usage:\n# ./screenpipe_sync.sh # syncs yesterday (default)\n# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date\n# ./screenpipe_sync.sh today # syncs today so far\n#\n# Cron example (runs at 3am daily):\n# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1\n\nset -euo pipefail\n\n# ─── CONFIG ───────────────────────────────────────────────────────────────────\nDB_SRC=\"${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}\"\nNAS_MOUNT=\"${NAS_MOUNT:-/Volumes/screenpipe}\"\nNAS_DB=\"$NAS_MOUNT/archive.db\"\nNAS_DATA=\"$NAS_MOUNT/data\"\nLOG_FILE=\"$HOME/.screenpipe/sync.log\"\n# Tables that get schema drift handling. Order matters for FK-ish references\n# (parents before children: video_chunks → frames → elements/ocr_text/ui_events).\nSYNC_TABLES=(video_chunks frames elements ocr_text ui_events meetings)\n# ──────────────────────────────────────────────────────────────────────────────\n\n# ─── HELPERS ──────────────────────────────────────────────────────────────────\nSCRIPT_START=$(date +%s)\n\nlog() {\n local msg=\"[$(date '+%Y-%m-%d %H:%M:%S')] $*\"\n echo \"$msg\" | tee -a \"$LOG_FILE\"\n}\n\nstep() {\n local now=$(date +%s)\n local elapsed=$(( now - SCRIPT_START ))\n local min=$(( elapsed / 60 ))\n local sec=$(( elapsed % 60 ))\n printf \"\\n[+%02dm%02ds] ▶ %s\\n\" \"$min\" \"$sec\" \"$*\" | tee -a \"$LOG_FILE\"\n}\n\nrun_sqlite_heredoc() {\n local label=\"$1\"\n local sql=\"$2\"\n local start=$(date +%s)\n\n printf \" %-36s \" \"$label\"\n\n sqlite3 \"$DB_SRC\" <<< \"$sql\" &\n local pid=$!\n local spin=('⠋' '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')\n local i=0\n while kill -0 \"$pid\" 2>/dev/null; do\n printf \"\\r %-36s %s \" \"$label\" \"${spin[$i]}\"\n i=$(( (i + 1) % 10 ))\n sleep 0.2\n done\n wait \"$pid\"\n local rc=$?\n if [ $rc -ne 0 ]; then\n printf \"\\r %-36s ✗ FAILED\\n\" \"$label\" | tee -a \"$LOG_FILE\"\n exit $rc\n fi\n\n local dur=$(( $(date +%s) - start ))\n printf \"\\r %-36s ✓ %dm%02ds\\n\" \"$label\" \"$(( dur / 60 ))\" \"$(( dur % 60 ))\" | tee -a \"$LOG_FILE\"\n}\n\ncheck() {\n local label=\"$1\" got=\"$2\" expected=\"$3\"\n if [ \"$got\" -eq \"$expected\" ]; then\n printf \" %-20s %s / %s ✓\\n\" \"$label:\" \"$got\" \"$expected\"\n else\n printf \" %-20s %s / %s ✗ MISMATCH\\n\" \"$label:\" \"$got\" \"$expected\"\n fi\n}\n\n# ─── SCHEMA HELPERS ───────────────────────────────────────────────────────────\n# Echoes \"name|type\" lines for a table from a given DB.\ntable_columns_with_types() {\n local db=\"$1\" table=\"$2\"\n sqlite3 \"$db\" \"PRAGMA table_info($table);\" | awk -F'|' '{print $2 \"|\" $3}'\n}\n\n# Echoes just column names, one per line.\ntable_columns() {\n local db=\"$1\" table=\"$2\"\n sqlite3 \"$db\" \"PRAGMA table_info($table);\" | awk -F'|' '{print $2}'\n}\n\n# Returns true (0) if a table exists in the given DB.\ntable_exists() {\n local db=\"$1\" table=\"$2\"\n local count\n count=$(sqlite3 \"$db\" \"SELECT COUNT(*) FROM sqlite_master WHERE type='table' AND name='$table';\")\n [ \"$count\" -gt 0 ]\n}\n\n# Adds any columns present in source but missing in NAS for the given table.\n# Uses ALTER TABLE ADD COLUMN, which is a fast metadata-only operation in SQLite.\nensure_columns() {\n local table=\"$1\"\n local label=\"schema: $table\"\n printf \" %-36s \" \"$label\"\n\n if ! table_exists \"$DB_SRC\" \"$table\"; then\n printf \"✗ source missing — skipping\\n\"\n return 0\n fi\n\n if ! table_exists \"$NAS_DB\" \"$table\"; then\n printf \"✓ fresh (created above)\\n\"\n return 0\n fi\n\n local src_cols\n src_cols=$(table_columns_with_types \"$DB_SRC\" \"$table\")\n local nas_cols\n nas_cols=$(table_columns \"$NAS_DB\" \"$table\")\n\n local added=0\n local added_names=\"\"\n while IFS='|' read -r name type; do\n [ -z \"$name\" ] && continue\n # Use grep -F -x for fixed-string exact match (safe against regex chars).\n if ! echo \"$nas_cols\" | grep -Fxq \"$name\"; then\n # SQLite ALTER TABLE ADD COLUMN: type is optional, no NOT NULL allowed\n # without a constant default. Default-NULL is exactly what we want for archive.\n sqlite3 \"$NAS_DB\" \"ALTER TABLE $table ADD COLUMN \\\"$name\\\" $type;\"\n added=$((added + 1))\n added_names=\"$added_names $name\"\n fi\n done <<< \"$src_cols\"\n\n if [ \"$added\" -gt 0 ]; then\n printf \"✓ added %d:%s\\n\" \"$added\" \"$added_names\"\n else\n printf \"✓ in sync\\n\"\n fi\n}\n\n# Echoes a comma-separated list of source columns for a table, double-quoted\n# so reserved words and hyphens are safe. If an alias is provided, columns are\n# prefixed (e.g. `o.\"col\"`). Used for both INSERT and SELECT sides; aliased\n# form is required when SELECTing from a JOIN where column names collide\n# (e.g. ocr_text and frames both have app_name, window_name).\nbuild_col_list() {\n local table=\"$1\"\n local alias=\"${2:-}\"\n local prefix=\"\"\n [ -n \"$alias\" ] && prefix=\"${alias}.\"\n table_columns \"$DB_SRC\" \"$table\" | awk 'NF' | awk -v p=\"$prefix\" '{print p \"\\\"\" $0 \"\\\"\"}' | paste -sd, -\n}\n# ──────────────────────────────────────────────────────────────────────────────\n\n# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────\nif [ \"${1:-}\" = \"today\" ]; then\n TARGET_DATE=$(date +%Y-%m-%d)\nelif [ -n \"${1:-}\" ]; then\n TARGET_DATE=\"$1\"\n if ! [[ \"$TARGET_DATE\" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then\n echo \"ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday.\"\n exit 1\n fi\nelse\n TARGET_DATE=$(date -v-1d +%Y-%m-%d)\nfi\n\nlog \"========================================\"\nlog \"Screenpipe sync starting for: $TARGET_DATE\"\nlog \"========================================\"\n\n# ─── PREFLIGHT ────────────────────────────────────────────────────────────────\nstep \"Preflight checks\"\n\nif [ ! -f \"$DB_SRC\" ]; then\n log \"ERROR: Source DB not found at $DB_SRC\"; exit 1\nfi\nprintf \" %-20s %s (%s)\\n\" \"Source DB:\" \"OK\" \"$(du -sh \"$DB_SRC\" | cut -f1)\"\n\nif [ ! -d \"$NAS_MOUNT\" ]; then\n log \"ERROR: NAS not mounted at $NAS_MOUNT\"; exit 1\nfi\nprintf \" %-20s %s\\n\" \"NAS mount:\" \"OK $NAS_MOUNT\"\n\n# Check if DB already synced for this date\nDB_ALREADY_SYNCED=false\nif [ -f \"$NAS_DB\" ]; then\n if table_exists \"$NAS_DB\" \"frames\"; then\n EXISTING=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\" 2>/dev/null || echo \"0\")\n if [ \"$EXISTING\" -gt \"0\" ]; then\n log \"Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync\"\n DB_ALREADY_SYNCED=true\n else\n printf \" %-20s %s (%s)\\n\" \"Archive DB:\" \"exists\" \"$(du -sh \"$NAS_DB\" | cut -f1)\"\n fi\n else\n printf \" %-20s %s\\n\" \"Archive DB:\" \"exists, no frames table yet\"\n fi\nelse\n printf \" %-20s %s\\n\" \"Archive DB:\" \"will be created\"\nfi\n\n# Source data dir for this date\nDATA_SRC=\"$HOME/.screenpipe/data/data/$TARGET_DATE\"\nif [ -d \"$DATA_SRC\" ]; then\n DATA_SIZE=$(du -sh \"$DATA_SRC\" | cut -f1)\n DATA_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n printf \" %-20s %s (%s files, %s)\\n\" \"Data dir:\" \"OK\" \"$DATA_FILES\" \"$DATA_SIZE\"\nelse\n printf \" %-20s %s\\n\" \"Data dir:\" \"not found — skipping file copy\"\nfi\n\n# ─── DB SYNC ──────────────────────────────────────────────────────────────────\nif [ \"$DB_ALREADY_SYNCED\" = false ]; then\n\n # ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────\n step \"Counting source rows for $TARGET_DATE\"\n\n SRC_FRAMES=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\")\n SRC_ELEMENTS=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n SRC_UI=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';\")\n SRC_OCR=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n SRC_MEETINGS=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';\")\n\n printf \" %-20s %s\\n\" \"frames:\" \"$SRC_FRAMES\"\n printf \" %-20s %s\\n\" \"elements:\" \"$SRC_ELEMENTS\"\n printf \" %-20s %s\\n\" \"ui_events:\" \"$SRC_UI\"\n printf \" %-20s %s\\n\" \"ocr_text:\" \"$SRC_OCR\"\n printf \" %-20s %s\\n\" \"meetings:\" \"$SRC_MEETINGS\"\n\n if [ \"$SRC_FRAMES\" -eq \"0\" ]; then\n log \"No frames found for $TARGET_DATE — skipping DB sync\"\n DB_ALREADY_SYNCED=true\n fi\n\nfi\n\nif [ \"$DB_ALREADY_SYNCED\" = false ]; then\n\n # ─── INIT TABLES ──────────────────────────────────────────────────────────\n step \"Initialising tables (CREATE IF NOT EXISTS)\"\n\n run_sqlite_heredoc \"creating tables\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;\nDETACH nas;\n\"\n\n # ─── SCHEMA DRIFT FIX ─────────────────────────────────────────────────────\n # Runs AFTER CREATE IF NOT EXISTS so newly-created tables are no-ops here,\n # and pre-existing tables get any missing columns added.\n step \"Reconciling NAS schema with source\"\n for tbl in \"${SYNC_TABLES[@]}\"; do\n ensure_columns \"$tbl\"\n done\n\n run_sqlite_heredoc \"creating indexes\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_document_path ON frames(document_path) WHERE document_path IS NOT NULL;\nCREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;\nCREATE INDEX IF NOT EXISTS nas.idx_elements_onscreen_frame ON elements(frame_id) WHERE on_screen = 1 AND text IS NOT NULL;\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);\nCREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"creating FTS tables\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(\n text, role, frame_id UNINDEXED,\n content='elements', content_rowid='id', tokenize='unicode61'\n);\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(\n full_text, app_name, window_name, browser_url, id UNINDEXED,\n tokenize='unicode61'\n);\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(\n text_content,\n app_name,\n window_title,\n element_name,\n content='ui_events',\n content_rowid='id',\n tokenize='unicode61'\n);\nDETACH nas;\n\"\n\n # ─── BUILD EXPLICIT COLUMN LISTS ──────────────────────────────────────────\n # After ensure_columns, source ⊆ NAS for every synced table, so source's\n # column list is a safe subset to use on both sides of the INSERT.\n # For tables that JOIN frames (ocr_text, elements), the SELECT side needs\n # alias-qualified columns because both tables share names (app_name, etc).\n FRAMES_COLS=$(build_col_list frames)\n ELEMENTS_COLS=$(build_col_list elements)\n ELEMENTS_COLS_E=$(build_col_list elements e)\n UI_EVENTS_COLS=$(build_col_list ui_events)\n OCR_TEXT_COLS=$(build_col_list ocr_text)\n OCR_TEXT_COLS_O=$(build_col_list ocr_text o)\n VIDEO_CHUNKS_COLS=$(build_col_list video_chunks)\n MEETINGS_COLS=$(build_col_list meetings)\n\n # ─── SYNC DATA ────────────────────────────────────────────────────────────\n step \"Syncing data for $TARGET_DATE\"\n\n run_sqlite_heredoc \"video_chunks\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.video_chunks ($VIDEO_CHUNKS_COLS)\n SELECT $VIDEO_CHUNKS_COLS FROM main.video_chunks\n WHERE id IN (\n SELECT DISTINCT video_chunk_id FROM main.frames\n WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL\n );\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames ($SRC_FRAMES rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.frames ($FRAMES_COLS)\n SELECT $FRAMES_COLS FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ocr_text ($SRC_OCR rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ocr_text ($OCR_TEXT_COLS)\n SELECT $OCR_TEXT_COLS_O FROM main.ocr_text o\n JOIN main.frames f ON o.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events ($SRC_UI rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ui_events ($UI_EVENTS_COLS)\n SELECT $UI_EVENTS_COLS FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"elements ($SRC_ELEMENTS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.elements ($ELEMENTS_COLS)\n SELECT $ELEMENTS_COLS_E FROM main.elements e\n JOIN main.frames f ON e.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"meetings ($SRC_MEETINGS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.meetings ($MEETINGS_COLS)\n SELECT $MEETINGS_COLS FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n # ─── FTS UPDATE ───────────────────────────────────────────────────────────\n step \"Updating FTS indexes\"\n\n run_sqlite_heredoc \"elements_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.elements_fts(rowid, text, role)\n SELECT e.id, e.text, e.role\n FROM nas.elements e\n JOIN nas.frames f ON e.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE'\n AND e.text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)\n SELECT id, full_text, app_name, window_name, browser_url, id\n FROM nas.frames\n WHERE date(timestamp) = '$TARGET_DATE'\n AND full_text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)\n SELECT id, text_content, app_name, window_title, element_name\n FROM nas.ui_events\n WHERE date(timestamp) = '$TARGET_DATE'\n AND text_content IS NOT NULL;\nDETACH nas;\n\"\n\n # ─── VERIFY DB ────────────────────────────────────────────────────────────\n step \"Verifying DB\"\n\n V_FRAMES=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\")\n V_ELEMENTS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n V_UI=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';\")\n V_OCR=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n V_MEETINGS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';\")\n\n check \"frames\" \"$V_FRAMES\" \"$SRC_FRAMES\"\n check \"elements\" \"$V_ELEMENTS\" \"$SRC_ELEMENTS\"\n check \"ui_events\" \"$V_UI\" \"$SRC_UI\"\n check \"ocr_text\" \"$V_OCR\" \"$SRC_OCR\"\n check \"meetings\" \"$V_MEETINGS\" \"$SRC_MEETINGS\"\n\nfi\n\n# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────\n# Always runs regardless of DB sync status\nstep \"Copying data folder for $TARGET_DATE\"\n\nif [ -d \"$DATA_SRC\" ]; then\n mkdir -p \"$NAS_DATA/$TARGET_DATE\"\n RSYNC_START=$(date +%s)\n printf \" %-36s \" \"rsync $TARGET_DATE/ → NAS\"\n rsync -a --ignore-existing \\\n \"$DATA_SRC/\" \\\n \"$NAS_DATA/$TARGET_DATE/\" \\\n 2>>\"$LOG_FILE\"\n RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))\n COPIED_FILES=$(ls \"$NAS_DATA/$TARGET_DATE\" | wc -l | tr -d ' ')\n SRC_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n COPIED_SIZE=$(du -sh \"$NAS_DATA/$TARGET_DATE\" | cut -f1)\n if [ \"$COPIED_FILES\" -eq \"$SRC_FILES\" ]; then\n printf \"\\r %-36s ✓ %dm%02ds (%s files, %s)\\n\" \\\n \"rsync $TARGET_DATE/ → NAS\" \\\n \"$(( RSYNC_DUR / 60 ))\" \"$(( RSYNC_DUR % 60 ))\" \\\n \"$COPIED_FILES\" \"$COPIED_SIZE\" | tee -a \"$LOG_FILE\"\n else\n printf \"\\r %-36s ✗ %s / %s files\\n\" \\\n \"rsync $TARGET_DATE/ → NAS\" \"$COPIED_FILES\" \"$SRC_FILES\" | tee -a \"$LOG_FILE\"\n fi\nelse\n printf \" %-36s %s\\n\" \"rsync $TARGET_DATE/ → NAS\" \"skipped (no source dir)\"\nfi\n\n# ─── COPY LOGS ────────────────────────────────────────────────────────────────\n# Screenpipe writes daily logs to ~/.screenpipe/screenpipe.YYYY-MM-DD.N.log\n# (N is a rotation counter, almost always 0). Mirror them to NAS so log\n# analysis can happen on the consumer side without SSH'ing back to the Mac.\nstep \"Copying screenpipe logs for $TARGET_DATE\"\n\nNAS_LOGS=\"$NAS_MOUNT/logs\"\nmkdir -p \"$NAS_LOGS\"\n\n# Use a glob with nullglob so an empty match doesn't expand to a literal pattern.\nshopt -s nullglob\nLOG_FILES=( \"$HOME/.screenpipe/screenpipe.$TARGET_DATE.\"*.log )\nshopt -u nullglob\n\nif [ ${#LOG_FILES[@]} -gt 0 ]; then\n printf \" %-36s \" \"rsync logs → NAS\"\n # No --ignore-existing here: logs grow during the day, so we want rsync's\n # default size+mtime check to refresh files that have changed.\n rsync -a \"${LOG_FILES[@]}\" \"$NAS_LOGS/\" 2>>\"$LOG_FILE\"\n COPIED=${#LOG_FILES[@]}\n TOTAL_SIZE=$(du -ch \"${LOG_FILES[@]}\" | tail -1 | cut -f1)\n printf \"✓ %d file(s), %s\\n\" \"$COPIED\" \"$TOTAL_SIZE\" | tee -a \"$LOG_FILE\"\nelse\n printf \" %-36s %s\\n\" \"rsync logs → NAS\" \"skipped (no matching logs)\"\nfi\n\n# ─── SUMMARY ──────────────────────────────────────────────────────────────────\nTOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))\nDB_SIZE=$(du -sh \"$NAS_DB\" | cut -f1)\n\necho \"\"\nlog \"Archive DB size: $DB_SIZE\"\nlog \"Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s\"\nlog \"Sync complete for $TARGET_DATE\"\nlog \"========================================\"\n\n# Mirror this script's own logbook to NAS so sync health can be monitored\n# from the consumer side. Done last so the summary lines above are included.\nrsync -a \"$HOME/.screenpipe/sync.log\" \"$NAS_LOGS/sync.log\" 2>/dev/null || true","depth":29,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Implement and run pipe l…, Editor Group 2","depth":28,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":false},{"role":"AXRadioButton","text":"Problems (⇧⌘M)","depth":22,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"PROBLEMS","depth":24,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Output (⇧⌘U)","depth":22,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUTPUT","depth":24,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Debug Console (⇧⌘Y)","depth":22,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"DEBUG CONSOLE","depth":24,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Terminal (⌃`)","depth":22,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":true},{"role":"AXStaticText","text":"TERMINAL","depth":24,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Ports - 1 forwarded port","depth":22,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"PORTS","depth":24,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":25,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"remote SSH: nas","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"SSH: nas","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"screenpipe (Git) - master*, Checkout Branch/Tag...","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"master*","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"screenpipe (Git) - Synchronize Changes","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"No Problems","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"0","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"0","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Forwarded Ports: 8766","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Notifications","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sign In","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Sign In","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Shell Script","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Editor Language Status: Inline Suggestions, next: $(copilot) No inline suggestion available, Inline suggestions","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"LF","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"UTF-8","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Spaces: 2","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Ln 480, Col 3","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"git-commit Not Committed Yet","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Not Committed Yet","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"No results found","depth":12,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Implement and run pipe logic","depth":19,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Session history","depth":19,"on_screen":true,"help_text":"Session history","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"New session","depth":19,"on_screen":true,"help_text":"New session","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Message actions","depth":24,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"main.py","depth":23,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"lets implement logic with pipes. how can I run it?","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Let me look at the current project structure to understand what's already in place.","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"List project files","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"find /volume1/screenpipe -type f | head -50 && echo \"---\" && ls /volume1/screenpipe","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"/volume1/screenpipe/.DS_Store\n/volume1/screenpipe/screenpipe.db\n/volume1/screenpipe/screenpipe_sync.sh\n/volume1/screenpipe/app_settings.json\n/volume1/screenpipe/.gitignore\n/volume1/screenpipe/archive.db\n/volume1/screenpipe/db.sqlite\n/volume1/screenpipe/db.sqlite-wal\n/volume1/screenpipe/db.sqlite-shm\n/volume1/screenpipe/#recycle/desktop.ini\n/volume1/screenpipe/#recycle/db.sqlite\n/volume1/screenpipe/#recycle/Copy #1 of db.sqlite\n/volume1/screenpipe/#recycle/.DS_Store\n/volume1/screenpipe/#recycle/Copy #2 of db.sqlite\n/volume1/screenpipe/#recycle/archive.db\n/volume1/screenpipe/#recycle/Copy #1 of archive.db\n/volume1/screenpipe/#recycle/Copy #2 of archive.db\n/volume1/screenpipe/#recycle/Copy #3 of archive.db\n/volume1/screenpipe/#recycle/Copy #4 of archive.db\n/volume1/screenpipe/#recycle/Copy #5 of archive.db\n/volume1/screenpipe/#recycle/Copy #3 of db.sqlite\n/volume1/screenpipe/#recycle/Copy #4 of db.sqlite\n/volume1/screenpipe/#recycle/Copy #6 of archive.db\n/volume1/screenpipe/#recycle/test.txt\n/volume1/screenpipe/#recycle/Copy #7 of archive.db\n/volume1/screenpipe/#recycle/Copy #8 of archive.db\n/volume1/screenpipe/#recycle/archive.db-journal\n/volume1/screenpipe/#recycle/Copy #1 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #2 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #3 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #4 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #5 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #6 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #7 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #5 of db.sqlite\n/volume1/screenpipe/pipes/.DS_Store\n/volume1/screenpipe/app/.env\n/volume1/screenpipe/app/cli.py\n/volume1/screenpipe/app/.DS_Store\n/volume1/screenpipe/app/db.py\n/volume1/screenpipe/app/docker-compose.yml\n/volume1/screenpipe/app/main.py\n/volume1/screenpipe/app/requirements.txt\n/volume1/screenpipe/app/Dockerfile\n/volume1/screenpipe/data/.DS_Store\n/volume1/screenpipe/.git/description\n/volume1/screenpipe/.git/HEAD\n/volume1/screenpipe/.git/index\n/volume1/screenpipe/.git/COMMIT_EDITMSG\n/volume1/screenpipe/#recycle/data/.DS_Store\n---\napp\napp_settings.json\narchive.db\ndata\ndb.sqlite\ndb.sqlite-shm\ndb.sqlite-wal\npipes\n#recycle\nscreenpipe.db\nscreenpipe_sync.sh","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"main.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Check pipes directory and docker-compose","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/pipes/ && ls /volume1/screenpipe/app/ && cat /volume1/screenpipe/app/docker-compose.yml","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ai-habits\nday-recap\nmeeting-summary\nstandup-update\ntime-breakdown\nvideo-export\ncli.py\nconsumers\ndb.py\ndocker-compose.yml\nDockerfile\nmain.py\n__pycache__\nrequirements.txt\nstatic\nservices:\n screenpipe-app:\n build: .\n container_name: screenpipe-app\n restart: unless-stopped\n ports:\n - \"8766:8000\"\n volumes:\n - /volume1/screenpipe:/data\n env_file:\n - .env\n environment:\n TZ: Europe/Sofia\n DB_PATH: /data/db.sqlite\n\n sqlite-web-archive:\n image: ghcr.io/coleifer/sqlite-web:latest\n container_name: screenpipe-sqlweb-archive\n restart: unless-stopped\n ports:\n - \"8767:8080\"\n volumes:\n - /volume1/screenpipe:/data\n command: [\"-H\", \"0.0.0.0\", \"-r\", \"/data/archive.db\"]\n\n sqlite-web-live:\n image: ghcr.io/coleifer/sqlite-web:latest\n container_name: screenpipe-sqlweb-live\n restart: unless-stopped\n ports:\n - \"8768:8080\"\n volumes:\n - /volume1/screenpipe:/data\n command: [\"-H\", \"0.0.0.0\", \"-r\", \"/data/db.sqlite\"]","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"requirements.txt","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"requirements.txt","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Inspect a pipe directory","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/pipes/day-recap/ && cat /volume1/screenpipe/pipes/day-recap/pipe.json 2>/dev/null || ls /volume1/screenpipe/pipes/day-recap/","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"pipe.md\npipe.md","depth":24,"on_screen":false,"role_description":"text"}]...
|
8435410644063420609
|
8363351146505899285
|
click
|
accessibility
|
NULL
|
Explorer (⇧⌘E) - 1 unsaved file
1
Search (⇧⌘F)
Explorer (⇧⌘E) - 1 unsaved file
1
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py
M
db.py
docker-compose.yml
Dockerfile
M
main.py
M
requirements.txt
M
data
logs
pipes
.gitignore
app_settings.json
archive.db
archive.db-bak
U
db.sqlite
db.sqlite-shm
db.sqlite-wal
screenpipe_sync_updated.sh
U
screenpipe_sync.sh
screenpipe.db
Outline Section
OUTLINE
OUTLINE
Timeline Section
TIMELINE
TIMELINE
app_settings.json, Editor Group 1
screenpipe_sync.sh, Editor Group 1
pipe.md, Editor Group 1
.env, Editor Group 1
#!/bin/bash
# screenpipe_sync.sh
# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).
# Also copies the day's video/frame data folder to the NAS.
#
# Schema-drift tolerant: if Screenpipe migrations add new columns to the source DB,
# the NAS archive gets ALTER TABLE'd to match. Inserts use explicit column lists,
# so positional mismatches can't occur.
#
# Usage:
# ./screenpipe_sync.sh # syncs yesterday (default)
# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date
# ./screenpipe_sync.sh today # syncs today so far
#
# Cron example (runs at 3am daily):
# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1
set -euo pipefail
# ─── CONFIG ───────────────────────────────────────────────────────────────────
DB_SRC="${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}"
NAS_MOUNT="${NAS_MOUNT:-/Volumes/screenpipe}"
NAS_DB="$NAS_MOUNT/archive.db"
NAS_DATA="$NAS_MOUNT/data"
LOG_FILE="$HOME/.screenpipe/sync.log"
# Tables that get schema drift handling. Order matters for FK-ish references
# (parents before children: video_chunks → frames → elements/ocr_text/ui_events).
SYNC_TABLES=(video_chunks frames elements ocr_text ui_events meetings)
# ──────────────────────────────────────────────────────────────────────────────
# ─── HELPERS ──────────────────────────────────────────────────────────────────
SCRIPT_START=$(date +%s)
log() {
local msg="[$(date '+%Y-%m-%d %H:%M:%S')] $*"
echo "$msg" | tee -a "$LOG_FILE"
}
step() {
local now=$(date +%s)
local elapsed=$(( now - SCRIPT_START ))
local min=$(( elapsed / 60 ))
local sec=$(( elapsed % 60 ))
printf "\n[+%02dm%02ds] ▶ %s\n" "$min" "$sec" "$*" | tee -a "$LOG_FILE"
}
run_sqlite_heredoc() {
local label="$1"
local sql="$2"
local start=$(date +%s)
printf " %-36s " "$label"
sqlite3 "$DB_SRC" <<< "$sql" &
local pid=$!
local spin=[PASSWORD] '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')
local i=0
while kill -0 "$pid" 2>/dev/null; do
printf "\r %-36s %s " "$label" "${spin[$i]}"
i=$(( (i + 1) % 10 ))
sleep 0.2
done
wait "$pid"
local rc=$?
if [ $rc -ne 0 ]; then
printf "\r %-36s ✗ FAILED\n" "$label" | tee -a "$LOG_FILE"
exit $rc
fi
local dur=$(( $(date +%s) - start ))
printf "\r %-36s ✓ %dm%02ds\n" "$label" "$(( dur / 60 ))" "$(( dur % 60 ))" | tee -a "$LOG_FILE"
}
check() {
local label="$1" got="$2" expected="$3"
if [ "$got" -eq "$expected" ]; then
printf " %-20s %s / %s ✓\n" "$label:" "$got" "$expected"
else
printf " %-20s %s / %s ✗ MISMATCH\n" "$label:" "$got" "$expected"
fi
}
# ─── SCHEMA HELPERS ───────────────────────────────────────────────────────────
# Echoes "name|type" lines for a table from a given DB.
table_columns_with_types() {
local db="$1" table="$2"
sqlite3 "$db" "PRAGMA table_info($table);" | awk -F'|' '{print $2 "|" $3}'
}
# Echoes just column names, one per line.
table_columns() {
local db="$1" table="$2"
sqlite3 "$db" "PRAGMA table_info($table);" | awk -F'|' '{print $2}'
}
# Returns true (0) if a table exists in the given DB.
table_exists() {
local db="$1" table="$2"
local count
count=$(sqlite3 "$db" "SELECT COUNT(*) FROM sqlite_master WHERE type='table' AND name='$table';")
[ "$count" -gt 0 ]
}
# Adds any columns present in source but missing in NAS for the given table.
# Uses ALTER TABLE ADD COLUMN, which is a fast metadata-only operation in SQLite.
ensure_columns() {
local table="$1"
local label="schema: $table"
printf " %-36s " "$label"
if ! table_exists "$DB_SRC" "$table"; then
printf "✗ source missing — skipping\n"
return 0
fi
if ! table_exists "$NAS_DB" "$table"; then
printf "✓ fresh (created above)\n"
return 0
fi
local src_cols
src_cols=$(table_columns_with_types "$DB_SRC" "$table")
local nas_cols
nas_cols=$(table_columns "$NAS_DB" "$table")
local added=0
local added_names=""
while IFS='|' read -r name type; do
[ -z "$name" ] && continue
# Use grep -F -x for fixed-string exact match (safe against regex chars).
if ! echo "$nas_cols" | grep -Fxq "$name"; then
# SQLite ALTER TABLE ADD COLUMN: type is optional, no NOT NULL allowed
# without a constant default. Default-NULL is exactly what we want for archive.
sqlite3 "$NAS_DB" "ALTER TABLE $table ADD COLUMN \"$name\" $type;"
added=$((added + 1))
added_names="$added_names $name"
fi
done <<< "$src_cols"
if [ "$added" -gt 0 ]; then
printf "✓ added %d:%s\n" "$added" "$added_names"
else
printf "✓ in sync\n"
fi
}
# Echoes a comma-separated list of source columns for a table, double-quoted
# so reserved words and hyphens are safe. If an alias is provided, columns are
# prefixed (e.g. `o."col"`). Used for both INSERT and SELECT sides; aliased
# form is required when SELECTing from a JOIN where column names collide
# (e.g. ocr_text and frames both have app_name, window_name).
build_col_list() {
local table="$1"
local alias="${2:-}"
local prefix=""
[ -n "$alias" ] && prefix="${alias}."
table_columns "$DB_SRC" "$table" | awk 'NF' | awk -v p="$prefix" '{print p "\"" $0 "\""}' | paste -sd, -
}
# ──────────────────────────────────────────────────────────────────────────────
# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────
if [ "${1:-}" = "today" ]; then
TARGET_DATE=$(date +%Y-%m-%d)
elif [ -n "${1:-}" ]; then
TARGET_DATE="$1"
if ! [[ "$TARGET_DATE" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then
echo "ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday."
exit 1
fi
else
TARGET_DATE=$(date -v-1d +%Y-%m-%d)
fi
log "========================================"
log "Screenpipe sync starting for: $TARGET_DATE"
log "========================================"
# ─── PREFLIGHT ────────────────────────────────────────────────────────────────
step "Preflight checks"
if [ ! -f "$DB_SRC" ]; then
log "ERROR: Source DB not found at $DB_SRC"; exit 1
fi
printf " %-20s %s (%s)\n" "Source DB:" "OK" "$(du -sh "$DB_SRC" | cut -f1)"
if [ ! -d "$NAS_MOUNT" ]; then
log "ERROR: NAS not mounted at $NAS_MOUNT"; exit 1
fi
printf " %-20s %s\n" "NAS mount:" "OK $NAS_MOUNT"
# Check if DB already synced for this date
DB_ALREADY_SYNCED=false
if [ -f "$NAS_DB" ]; then
if table_exists "$NAS_DB" "frames"; then
EXISTING=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';" 2>/dev/null || echo "0")
if [ "$EXISTING" -gt "0" ]; then
log "Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync"
DB_ALREADY_SYNCED=true
else
printf " %-20s %s (%s)\n" "Archive DB:" "exists" "$(du -sh "$NAS_DB" | cut -f1)"
fi
else
printf " %-20s %s\n" "Archive DB:" "exists, no frames table yet"
fi
else
printf " %-20s %s\n" "Archive DB:" "will be created"
fi
# Source data dir for this date
DATA_SRC="$HOME/.screenpipe/data/data/$TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
DATA_SIZE=$(du -sh "$DATA_SRC" | cut -f1)
DATA_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
printf " %-20s %s (%s files, %s)\n" "Data dir:" "OK" "$DATA_FILES" "$DATA_SIZE"
else
printf " %-20s %s\n" "Data dir:" "not found — skipping file copy"
fi
# ─── DB SYNC ──────────────────────────────────────────────────────────────────
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────
step "Counting source rows for $TARGET_DATE"
SRC_FRAMES=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
SRC_ELEMENTS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_UI=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
SRC_OCR=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_MEETINGS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';")
printf " %-20s %s\n" "frames:" "$SRC_FRAMES"
printf " %-20s %s\n" "elements:" "$SRC_ELEMENTS"
printf " %-20s %s\n" "ui_events:" "$SRC_UI"
printf " %-20s %s\n" "ocr_text:" "$SRC_OCR"
printf " %-20s %s\n" "meetings:" "$SRC_MEETINGS"
if [ "$SRC_FRAMES" -eq "0" ]; then
log "No frames found for $TARGET_DATE — skipping DB sync"
DB_ALREADY_SYNCED=true
fi
fi
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── INIT TABLES ──────────────────────────────────────────────────────────
step "Initialising tables (CREATE IF NOT EXISTS)"
run_sqlite_heredoc "creating tables" "
ATTACH '$NAS_DB' AS nas;
CREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;
CREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;
CREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;
CREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;
DETACH nas;
"
# ─── SCHEMA DRIFT FIX ─────────────────────────────────────────────────────
# Runs AFTER CREATE IF NOT EXISTS so newly-created tables are no-ops here,
# and pre-existing tables get any missing columns added.
step "Reconciling NAS schema with source"
for tbl in "${SYNC_TABLES[@]}"; do
ensure_columns "$tbl"
done
run_sqlite_heredoc "creating indexes" "
ATTACH '$NAS_DB' AS nas;
CREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);
CREATE INDEX IF NOT EXISTS nas.idx_frames_document_path ON frames(document_path) WHERE document_path IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_elements_onscreen_frame ON elements(frame_id) WHERE on_screen = 1 AND text IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);
CREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);
DETACH nas;
"
run_sqlite_heredoc "creating FTS tables" "
ATTACH '$NAS_DB' AS nas;
CREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(
text, role, frame_id UNINDEXED,
content='elements', content_rowid='id', tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(
full_text, app_name, window_name, browser_url, id UNINDEXED,
tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(
text_content,
app_name,
window_title,
element_name,
content='ui_events',
content_rowid='id',
tokenize='unicode61'
);
DETACH nas;
"
# ─── BUILD EXPLICIT COLUMN LISTS ──────────────────────────────────────────
# After ensure_columns, source ⊆ NAS for every synced table, so source's
# column list is a safe subset to use on both sides of the INSERT.
# For tables that JOIN frames (ocr_text, elements), the SELECT side needs
# alias-qualified columns because both tables share names (app_name, etc).
FRAMES_COLS=$(build_col_list frames)
ELEMENTS_COLS=$(build_col_list elements)
ELEMENTS_COLS_E=$(build_col_list elements e)
UI_EVENTS_COLS=$(build_col_list ui_events)
OCR_TEXT_COLS=$(build_col_list ocr_text)
OCR_TEXT_COLS_O=$(build_col_list ocr_text o)
VIDEO_CHUNKS_COLS=$(build_col_list video_chunks)
MEETINGS_COLS=$(build_col_list meetings)
# ─── SYNC DATA ────────────────────────────────────────────────────────────
step "Syncing data for $TARGET_DATE"
run_sqlite_heredoc "video_chunks" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.video_chunks ($VIDEO_CHUNKS_COLS)
SELECT $VIDEO_CHUNKS_COLS FROM main.video_chunks
WHERE id IN (
SELECT DISTINCT video_chunk_id FROM main.frames
WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL
);
DETACH nas;
"
run_sqlite_heredoc "frames ($SRC_FRAMES rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.frames ($FRAMES_COLS)
SELECT $FRAMES_COLS FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ocr_text ($SRC_OCR rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ocr_text ($OCR_TEXT_COLS)
SELECT $OCR_TEXT_COLS_O FROM main.ocr_text o
JOIN main.frames f ON o.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ui_events ($SRC_UI rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ui_events ($UI_EVENTS_COLS)
SELECT $UI_EVENTS_COLS FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "elements ($SRC_ELEMENTS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.elements ($ELEMENTS_COLS)
SELECT $ELEMENTS_COLS_E FROM main.elements e
JOIN main.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "meetings ($SRC_MEETINGS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.meetings ($MEETINGS_COLS)
SELECT $MEETINGS_COLS FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';
DETACH nas;
"
# ─── FTS UPDATE ───────────────────────────────────────────────────────────
step "Updating FTS indexes"
run_sqlite_heredoc "elements_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.elements_fts(rowid, text, role)
SELECT e.id, e.text, e.role
FROM nas.elements e
JOIN nas.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE'
AND e.text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "frames_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)
SELECT id, full_text, app_name, window_name, browser_url, id
FROM nas.frames
WHERE date(timestamp) = '$TARGET_DATE'
AND full_text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "ui_events_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)
SELECT id, text_content, app_name, window_title, element_name
FROM nas.ui_events
WHERE date(timestamp) = '$TARGET_DATE'
AND text_content IS NOT NULL;
DETACH nas;
"
# ─── VERIFY DB ────────────────────────────────────────────────────────────
step "Verifying DB"
V_FRAMES=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
V_ELEMENTS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_UI=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
V_OCR=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_MEETINGS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';")
check "frames" "$V_FRAMES" "$SRC_FRAMES"
check "elements" "$V_ELEMENTS" "$SRC_ELEMENTS"
check "ui_events" "$V_UI" "$SRC_UI"
check "ocr_text" "$V_OCR" "$SRC_OCR"
check "meetings" "$V_MEETINGS" "$SRC_MEETINGS"
fi
# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────
# Always runs regardless of DB sync status
step "Copying data folder for $TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
mkdir -p "$NAS_DATA/$TARGET_DATE"
RSYNC_START=$(date +%s)
printf " %-36s " "rsync $TARGET_DATE/ → NAS"
rsync -a --ignore-existing \
"$DATA_SRC/" \
"$NAS_DATA/$TARGET_DATE/" \
2>>"$LOG_FILE"
RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))
COPIED_FILES=$(ls "$NAS_DATA/$TARGET_DATE" | wc -l | tr -d ' ')
SRC_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
COPIED_SIZE=$(du -sh "$NAS_DATA/$TARGET_DATE" | cut -f1)
if [ "$COPIED_FILES" -eq "$SRC_FILES" ]; then
printf "\r %-36s ✓ %dm%02ds (%s files, %s)\n" \
"rsync $TARGET_DATE/ → NAS" \
"$(( RSYNC_DUR / 60 ))" "$(( RSYNC_DUR % 60 ))" \
"$COPIED_FILES" "$COPIED_SIZE" | tee -a "$LOG_FILE"
else
printf "\r %-36s ✗ %s / %s files\n" \
"rsync $TARGET_DATE/ → NAS" "$COPIED_FILES" "$SRC_FILES" | tee -a "$LOG_FILE"
fi
else
printf " %-36s %s\n" "rsync $TARGET_DATE/ → NAS" "skipped (no source dir)"
fi
# ─── COPY LOGS ────────────────────────────────────────────────────────────────
# Screenpipe writes daily logs to ~/.screenpipe/screenpipe.YYYY-MM-DD.N.log
# (N is a rotation counter, almost always 0). Mirror them to NAS so log
# analysis can happen on the consumer side without SSH'ing back to the Mac.
step "Copying screenpipe logs for $TARGET_DATE"
NAS_LOGS="$NAS_MOUNT/logs"
mkdir -p "$NAS_LOGS"
# Use a glob with nullglob so an empty match doesn't expand to a literal pattern.
shopt -s nullglob
LOG_FILES=( "$HOME/.screenpipe/screenpipe.$TARGET_DATE."*.log )
shopt -u nullglob
if [ ${#LOG_FILES[@]} -gt 0 ]; then
printf " %-36s " "rsync logs → NAS"
# No --ignore-existing here: logs grow during the day, so we want rsync's
# default size+mtime check to refresh files that have changed.
rsync -a "${LOG_FILES[@]}" "$NAS_LOGS/" 2>>"$LOG_FILE"
COPIED=${#LOG_FILES[@]}
TOTAL_SIZE=$(du -ch "${LOG_FILES[@]}" | tail -1 | cut -f1)
printf "✓ %d file(s), %s\n" "$COPIED" "$TOTAL_SIZE" | tee -a "$LOG_FILE"
else
printf " %-36s %s\n" "rsync logs → NAS" "skipped (no matching logs)"
fi
# ─── SUMMARY ──────────────────────────────────────────────────────────────────
TOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))
DB_SIZE=$(du -sh "$NAS_DB" | cut -f1)
echo ""
log "Archive DB size: $DB_SIZE"
log "Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s"
log "Sync complete for $TARGET_DATE"
log "========================================"
# Mirror this script's own logbook to NAS so sync health can be monitored
# from the consumer side. Done last so the summary lines above are included.
rsync -a "$HOME/.screenpipe/sync.log" "$NAS_LOGS/sync.log" 2>/dev/null || true
#!/bin/bash
# screenpipe_sync.sh
# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).
# Also copies the day's video/frame data folder to the NAS.
#
# Schema-drift tolerant: if Screenpipe migrations add new columns to the source DB,
# the NAS archive gets ALTER TABLE'd to match. Inserts use explicit column lists,
# so positional mismatches can't occur.
#
# Usage:
# ./screenpipe_sync.sh # syncs yesterday (default)
# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date
# ./screenpipe_sync.sh today # syncs today so far
#
# Cron example (runs at 3am daily):
# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1
set -euo pipefail
# ─── CONFIG ───────────────────────────────────────────────────────────────────
DB_SRC="${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}"
NAS_MOUNT="${NAS_MOUNT:-/Volumes/screenpipe}"
NAS_DB="$NAS_MOUNT/archive.db"
NAS_DATA="$NAS_MOUNT/data"
LOG_FILE="$HOME/.screenpipe/sync.log"
# Tables that get schema drift handling. Order matters for FK-ish references
# (parents before children: video_chunks → frames → elements/ocr_text/ui_events).
SYNC_TABLES=(video_chunks frames elements ocr_text ui_events meetings)
# ──────────────────────────────────────────────────────────────────────────────
# ─── HELPERS ──────────────────────────────────────────────────────────────────
SCRIPT_START=$(date +%s)
log() {
local msg="[$(date '+%Y-%m-%d %H:%M:%S')] $*"
echo "$msg" | tee -a "$LOG_FILE"
}
step() {
local now=$(date +%s)
local elapsed=$(( now - SCRIPT_START ))
local min=$(( elapsed / 60 ))
local sec=$(( elapsed % 60 ))
printf "\n[+%02dm%02ds] ▶ %s\n" "$min" "$sec" "$*" | tee -a "$LOG_FILE"
}
run_sqlite_heredoc() {
local label="$1"
local sql="$2"
local start=$(date +%s)
printf " %-36s " "$label"
sqlite3 "$DB_SRC" <<< "$sql" &
local pid=$!
local spin=[PASSWORD] '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')
local i=0
while kill -0 "$pid" 2>/dev/null; do
printf "\r %-36s %s " "$label" "${spin[$i]}"
i=$(( (i + 1) % 10 ))
sleep 0.2
done
wait "$pid"
local rc=$?
if [ $rc -ne 0 ]; then
printf "\r %-36s ✗ FAILED\n" "$label" | tee -a "$LOG_FILE"
exit $rc
fi
local dur=$(( $(date +%s) - start ))
printf "\r %-36s ✓ %dm%02ds\n" "$label" "$(( dur / 60 ))" "$(( dur % 60 ))" | tee -a "$LOG_FILE"
}
check() {
local label="$1" got="$2" expected="$3"
if [ "$got" -eq "$expected" ]; then
printf " %-20s %s / %s ✓\n" "$label:" "$got" "$expected"
else
printf " %-20s %s / %s ✗ MISMATCH\n" "$label:" "$got" "$expected"
fi
}
# ─── SCHEMA HELPERS ───────────────────────────────────────────────────────────
# Echoes "name|type" lines for a table from a given DB.
table_columns_with_types() {
local db="$1" table="$2"
sqlite3 "$db" "PRAGMA table_info($table);" | awk -F'|' '{print $2 "|" $3}'
}
# Echoes just column names, one per line.
table_columns() {
local db="$1" table="$2"
sqlite3 "$db" "PRAGMA table_info($table);" | awk -F'|' '{print $2}'
}
# Returns true (0) if a table exists in the given DB.
table_exists() {
local db="$1" table="$2"
local count
count=$(sqlite3 "$db" "SELECT COUNT(*) FROM sqlite_master WHERE type='table' AND name='$table';")
[ "$count" -gt 0 ]
}
# Adds any columns present in source but missing in NAS for the given table.
# Uses ALTER TABLE ADD COLUMN, which is a fast metadata-only operation in SQLite.
ensure_columns() {
local table="$1"
local label="schema: $table"
printf " %-36s " "$label"
if ! table_exists "$DB_SRC" "$table"; then
printf "✗ source missing — skipping\n"
return 0
fi
if ! table_exists "$NAS_DB" "$table"; then
printf "✓ fresh (created above)\n"
return 0
fi
local src_cols
src_cols=$(table_columns_with_types "$DB_SRC" "$table")
local nas_cols
nas_cols=$(table_columns "$NAS_DB" "$table")
local added=0
local added_names=""
while IFS='|' read -r name type; do
[ -z "$name" ] && continue
# Use grep -F -x for fixed-string exact match (safe against regex chars).
if ! echo "$nas_cols" | grep -Fxq "$name"; then
# SQLite ALTER TABLE ADD COLUMN: type is optional, no NOT NULL allowed
# without a constant default. Default-NULL is exactly what we want for archive.
sqlite3 "$NAS_DB" "ALTER TABLE $table ADD COLUMN \"$name\" $type;"
added=$((added + 1))
added_names="$added_names $name"
fi
done <<< "$src_cols"
if [ "$added" -gt 0 ]; then
printf "✓ added %d:%s\n" "$added" "$added_names"
else
printf "✓ in sync\n"
fi
}
# Echoes a comma-separated list of source columns for a table, double-quoted
# so reserved words and hyphens are safe. If an alias is provided, columns are
# prefixed (e.g. `o."col"`). Used for both INSERT and SELECT sides; aliased
# form is required when SELECTing from a JOIN where column names collide
# (e.g. ocr_text and frames both have app_name, window_name).
build_col_list() {
local table="$1"
local alias="${2:-}"
local prefix=""
[ -n "$alias" ] && prefix="${alias}."
table_columns "$DB_SRC" "$table" | awk 'NF' | awk -v p="$prefix" '{print p "\"" $0 "\""}' | paste -sd, -
}
# ──────────────────────────────────────────────────────────────────────────────
# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────
if [ "${1:-}" = "today" ]; then
TARGET_DATE=$(date +%Y-%m-%d)
elif [ -n "${1:-}" ]; then
TARGET_DATE="$1"
if ! [[ "$TARGET_DATE" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then
echo "ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday."
exit 1
fi
else
TARGET_DATE=$(date -v-1d +%Y-%m-%d)
fi
log "========================================"
log "Screenpipe sync starting for: $TARGET_DATE"
log "========================================"
# ─── PREFLIGHT ────────────────────────────────────────────────────────────────
step "Preflight checks"
if [ ! -f "$DB_SRC" ]; then
log "ERROR: Source DB not found at $DB_SRC"; exit 1
fi
printf " %-20s %s (%s)\n" "Source DB:" "OK" "$(du -sh "$DB_SRC" | cut -f1)"
if [ ! -d "$NAS_MOUNT" ]; then
log "ERROR: NAS not mounted at $NAS_MOUNT"; exit 1
fi
printf " %-20s %s\n" "NAS mount:" "OK $NAS_MOUNT"
# Check if DB already synced for this date
DB_ALREADY_SYNCED=false
if [ -f "$NAS_DB" ]; then
if table_exists "$NAS_DB" "frames"; then
EXISTING=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';" 2>/dev/null || echo "0")
if [ "$EXISTING" -gt "0" ]; then
log "Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync"
DB_ALREADY_SYNCED=true
else
printf " %-20s %s (%s)\n" "Archive DB:" "exists" "$(du -sh "$NAS_DB" | cut -f1)"
fi
else
printf " %-20s %s\n" "Archive DB:" "exists, no frames table yet"
fi
else
printf " %-20s %s\n" "Archive DB:" "will be created"
fi
# Source data dir for this date
DATA_SRC="$HOME/.screenpipe/data/data/$TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
DATA_SIZE=$(du -sh "$DATA_SRC" | cut -f1)
DATA_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
printf " %-20s %s (%s files, %s)\n" "Data dir:" "OK" "$DATA_FILES" "$DATA_SIZE"
else
printf " %-20s %s\n" "Data dir:" "not found — skipping file copy"
fi
# ─── DB SYNC ──────────────────────────────────────────────────────────────────
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────
step "Counting source rows for $TARGET_DATE"
SRC_FRAMES=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
SRC_ELEMENTS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_UI=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
SRC_OCR=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_MEETINGS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';")
printf " %-20s %s\n" "frames:" "$SRC_FRAMES"
printf " %-20s %s\n" "elements:" "$SRC_ELEMENTS"
printf " %-20s %s\n" "ui_events:" "$SRC_UI"
printf " %-20s %s\n" "ocr_text:" "$SRC_OCR"
printf " %-20s %s\n" "meetings:" "$SRC_MEETINGS"
if [ "$SRC_FRAMES" -eq "0" ]; then
log "No frames found for $TARGET_DATE — skipping DB sync"
DB_ALREADY_SYNCED=true
fi
fi
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── INIT TABLES ──────────────────────────────────────────────────────────
step "Initialising tables (CREATE IF NOT EXISTS)"
run_sqlite_heredoc "creating tables" "
ATTACH '$NAS_DB' AS nas;
CREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;
CREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;
CREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;
CREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;
DETACH nas;
"
# ─── SCHEMA DRIFT FIX ─────────────────────────────────────────────────────
# Runs AFTER CREATE IF NOT EXISTS so newly-created tables are no-ops here,
# and pre-existing tables get any missing columns added.
step "Reconciling NAS schema with source"
for tbl in "${SYNC_TABLES[@]}"; do
ensure_columns "$tbl"
done
run_sqlite_heredoc "creating indexes" "
ATTACH '$NAS_DB' AS nas;
CREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);
CREATE INDEX IF NOT EXISTS nas.idx_frames_document_path ON frames(document_path) WHERE document_path IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_elements_onscreen_frame ON elements(frame_id) WHERE on_screen = 1 AND text IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);
CREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);
DETACH nas;
"
run_sqlite_heredoc "creating FTS tables" "
ATTACH '$NAS_DB' AS nas;
CREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(
text, role, frame_id UNINDEXED,
content='elements', content_rowid='id', tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(
full_text, app_name, window_name, browser_url, id UNINDEXED,
tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(
text_content,
app_name,
window_title,
element_name,
content='ui_events',
content_rowid='id',
tokenize='unicode61'
);
DETACH nas;
"
# ─── BUILD EXPLICIT COLUMN LISTS ──────────────────────────────────────────
# After ensure_columns, source ⊆ NAS for every synced table, so source's
# column list is a safe subset to use on both sides of the INSERT.
# For tables that JOIN frames (ocr_text, elements), the SELECT side needs
# alias-qualified columns because both tables share names (app_name, etc).
FRAMES_COLS=$(build_col_list frames)
ELEMENTS_COLS=$(build_col_list elements)
ELEMENTS_COLS_E=$(build_col_list elements e)
UI_EVENTS_COLS=$(build_col_list ui_events)
OCR_TEXT_COLS=$(build_col_list ocr_text)
OCR_TEXT_COLS_O=$(build_col_list ocr_text o)
VIDEO_CHUNKS_COLS=$(build_col_list video_chunks)
MEETINGS_COLS=$(build_col_list meetings)
# ─── SYNC DATA ────────────────────────────────────────────────────────────
step "Syncing data for $TARGET_DATE"
run_sqlite_heredoc "video_chunks" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.video_chunks ($VIDEO_CHUNKS_COLS)
SELECT $VIDEO_CHUNKS_COLS FROM main.video_chunks
WHERE id IN (
SELECT DISTINCT video_chunk_id FROM main.frames
WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL
);
DETACH nas;
"
run_sqlite_heredoc "frames ($SRC_FRAMES rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.frames ($FRAMES_COLS)
SELECT $FRAMES_COLS FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ocr_text ($SRC_OCR rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ocr_text ($OCR_TEXT_COLS)
SELECT $OCR_TEXT_COLS_O FROM main.ocr_text o
JOIN main.frames f ON o.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ui_events ($SRC_UI rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ui_events ($UI_EVENTS_COLS)
SELECT $UI_EVENTS_COLS FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "elements ($SRC_ELEMENTS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.elements ($ELEMENTS_COLS)
SELECT $ELEMENTS_COLS_E FROM main.elements e
JOIN main.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "meetings ($SRC_MEETINGS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.meetings ($MEETINGS_COLS)
SELECT $MEETINGS_COLS FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';
DETACH nas;
"
# ─── FTS UPDATE ───────────────────────────────────────────────────────────
step "Updating FTS indexes"
run_sqlite_heredoc "elements_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.elements_fts(rowid, text, role)
SELECT e.id, e.text, e.role
FROM nas.elements e
JOIN nas.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE'
AND e.text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "frames_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)
SELECT id, full_text, app_name, window_name, browser_url, id
FROM nas.frames
WHERE date(timestamp) = '$TARGET_DATE'
AND full_text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "ui_events_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)
SELECT id, text_content, app_name, window_title, element_name
FROM nas.ui_events
WHERE date(timestamp) = '$TARGET_DATE'
AND text_content IS NOT NULL;
DETACH nas;
"
# ─── VERIFY DB ────────────────────────────────────────────────────────────
step "Verifying DB"
V_FRAMES=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
V_ELEMENTS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_UI=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
V_OCR=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_MEETINGS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';")
check "frames" "$V_FRAMES" "$SRC_FRAMES"
check "elements" "$V_ELEMENTS" "$SRC_ELEMENTS"
check "ui_events" "$V_UI" "$SRC_UI"
check "ocr_text" "$V_OCR" "$SRC_OCR"
check "meetings" "$V_MEETINGS" "$SRC_MEETINGS"
fi
# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────
# Always runs regardless of DB sync status
step "Copying data folder for $TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
mkdir -p "$NAS_DATA/$TARGET_DATE"
RSYNC_START=$(date +%s)
printf " %-36s " "rsync $TARGET_DATE/ → NAS"
rsync -a --ignore-existing \
"$DATA_SRC/" \
"$NAS_DATA/$TARGET_DATE/" \
2>>"$LOG_FILE"
RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))
COPIED_FILES=$(ls "$NAS_DATA/$TARGET_DATE" | wc -l | tr -d ' ')
SRC_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
COPIED_SIZE=$(du -sh "$NAS_DATA/$TARGET_DATE" | cut -f1)
if [ "$COPIED_FILES" -eq "$SRC_FILES" ]; then
printf "\r %-36s ✓ %dm%02ds (%s files, %s)\n" \
"rsync $TARGET_DATE/ → NAS" \
"$(( RSYNC_DUR / 60 ))" "$(( RSYNC_DUR % 60 ))" \
"$COPIED_FILES" "$COPIED_SIZE" | tee -a "$LOG_FILE"
else
printf "\r %-36s ✗ %s / %s files\n" \
"rsync $TARGET_DATE/ → NAS" "$COPIED_FILES" "$SRC_FILES" | tee -a "$LOG_FILE"
fi
else
printf " %-36s %s\n" "rsync $TARGET_DATE/ → NAS" "skipped (no source dir)"
fi
# ─── COPY LOGS ────────────────────────────────────────────────────────────────
# Screenpipe writes daily logs to ~/.screenpipe/screenpipe.YYYY-MM-DD.N.log
# (N is a rotation counter, almost always 0). Mirror them to NAS so log
# analysis can happen on the consumer side without SSH'ing back to the Mac.
step "Copying screenpipe logs for $TARGET_DATE"
NAS_LOGS="$NAS_MOUNT/logs"
mkdir -p "$NAS_LOGS"
# Use a glob with nullglob so an empty match doesn't expand to a literal pattern.
shopt -s nullglob
LOG_FILES=( "$HOME/.screenpipe/screenpipe.$TARGET_DATE."*.log )
shopt -u nullglob
if [ ${#LOG_FILES[@]} -gt 0 ]; then
printf " %-36s " "rsync logs → NAS"
# No --ignore-existing here: logs grow during the day, so we want rsync's
# default size+mtime check to refresh files that have changed.
rsync -a "${LOG_FILES[@]}" "$NAS_LOGS/" 2>>"$LOG_FILE"
COPIED=${#LOG_FILES[@]}
TOTAL_SIZE=$(du -ch "${LOG_FILES[@]}" | tail -1 | cut -f1)
printf "✓ %d file(s), %s\n" "$COPIED" "$TOTAL_SIZE" | tee -a "$LOG_FILE"
else
printf " %-36s %s\n" "rsync logs → NAS" "skipped (no matching logs)"
fi
# ─── SUMMARY ──────────────────────────────────────────────────────────────────
TOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))
DB_SIZE=$(du -sh "$NAS_DB" | cut -f1)
echo ""
log "Archive DB size: $DB_SIZE"
log "Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s"
log "Sync complete for $TARGET_DATE"
log "========================================"
# Mirror this script's own logbook to NAS so sync health can be monitored
# from the consumer side. Done last so the summary lines above are included.
rsync -a "$HOME/.screenpipe/sync.log" "$NAS_LOGS/sync.log" 2>/dev/null || true
Implement and run pipe l…, Editor Group 2
Problems (⇧⌘M)
PROBLEMS
Output (⇧⌘U)
OUTPUT
Debug Console (⇧⌘Y)
DEBUG CONSOLE
Terminal (⌃`)
TERMINAL
Ports - 1 forwarded port
PORTS
1
remote SSH: nas
SSH: nas
screenpipe (Git) - master*, Checkout Branch/Tag...
master*
screenpipe (Git) - Synchronize Changes
No Problems
0
0
Forwarded Ports: 8766
1
Notifications
Sign In
Sign In
Shell Script
Editor Language Status: Inline Suggestions, next: $(copilot) No inline suggestion available, Inline suggestions
LF
UTF-8
Spaces: 2
Ln 480, Col 3
git-commit Not Committed Yet
Not Committed Yet
No results found
Implement and run pipe logic
Session history
New session
Message actions
main.py
main.py
lets implement logic with pipes. how can I run it?
Thinking
Thinking
Let me look at the current project structure to understand what's already in place.
Bash
List project files
IN
find /volume1/screenpipe -type f | head -50 && echo "---" && ls /volume1/screenpipe
Copy code to clipboard
OUT
/volume1/screenpipe/.DS_Store
/volume1/screenpipe/screenpipe.db
/volume1/screenpipe/screenpipe_sync.sh
/volume1/screenpipe/app_settings.json
/volume1/screenpipe/.gitignore
/volume1/screenpipe/archive.db
/volume1/screenpipe/db.sqlite
/volume1/screenpipe/db.sqlite-wal
/volume1/screenpipe/db.sqlite-shm
/volume1/screenpipe/#recycle/desktop.ini
/volume1/screenpipe/#recycle/db.sqlite
/volume1/screenpipe/#recycle/Copy #1 of db.sqlite
/volume1/screenpipe/#recycle/.DS_Store
/volume1/screenpipe/#recycle/Copy #2 of db.sqlite
/volume1/screenpipe/#recycle/archive.db
/volume1/screenpipe/#recycle/Copy #1 of archive.db
/volume1/screenpipe/#recycle/Copy #2 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of archive.db
/volume1/screenpipe/#recycle/Copy #4 of archive.db
/volume1/screenpipe/#recycle/Copy #5 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of db.sqlite
/volume1/screenpipe/#recycle/Copy #4 of db.sqlite
/volume1/screenpipe/#recycle/Copy #6 of archive.db
/volume1/screenpipe/#recycle/test.txt
/volume1/screenpipe/#recycle/Copy #7 of archive.db
/volume1/screenpipe/#recycle/Copy #8 of archive.db
/volume1/screenpipe/#recycle/archive.db-journal
/volume1/screenpipe/#recycle/Copy #1 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #2 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #3 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #4 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #6 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #7 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of db.sqlite
/volume1/screenpipe/pipes/.DS_Store
/volume1/screenpipe/app/.env
/volume1/screenpipe/app/cli.py
/volume1/screenpipe/app/.DS_Store
/volume1/screenpipe/app/db.py
/volume1/screenpipe/app/docker-compose.yml
/volume1/screenpipe/app/main.py
/volume1/screenpipe/app/requirements.txt
/volume1/screenpipe/app/Dockerfile
/volume1/screenpipe/data/.DS_Store
/volume1/screenpipe/.git/description
/volume1/screenpipe/.git/HEAD
/volume1/screenpipe/.git/index
/volume1/screenpipe/.git/COMMIT_EDITMSG
/volume1/screenpipe/#recycle/data/.DS_Store
---
app
app_settings.json
archive.db
data
db.sqlite
db.sqlite-shm
db.sqlite-wal
pipes
#recycle
screenpipe.db
screenpipe_sync.sh
Read
main.py
main.py
Bash
Check pipes directory and docker-compose
IN
ls /volume1/screenpipe/pipes/ && ls /volume1/screenpipe/app/ && cat /volume1/screenpipe/app/docker-compose.yml
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
cli.py
consumers
db.py
docker-compose.yml
Dockerfile
main.py
__pycache__
requirements.txt
static
services:
screenpipe-app:
build: .
container_name: screenpipe-app
restart: unless-stopped
ports:
- "8766:8000"
volumes:
- /volume1/screenpipe:/data
env_file:
- .env
environment:
TZ: Europe/Sofia
DB_PATH: /data/db.sqlite
sqlite-web-archive:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-archive
restart: unless-stopped
ports:
- "8767:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/archive.db"]
sqlite-web-live:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-live
restart: unless-stopped
ports:
- "8768:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/db.sqlite"]
Read
requirements.txt
requirements.txt
Bash
Inspect a pipe directory
IN
ls /volume1/screenpipe/pipes/day-recap/ && cat /volume1/screenpipe/pipes/day-recap/pipe.json 2>/dev/null || ls /volume1/screenpipe/pipes/day-recap/
Copy code to clipboard
OUT
pipe.md
pipe.md...
|
21100
|
NULL
|
NULL
|
NULL
|
|
21105
|
923
|
13
|
2026-05-11T17:12:19.781002+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-11/1778 /Users/lukas/.screenpipe/data/data/2026-05-11/1778519539781_m2.jpg...
|
Code
|
screenpipe_sync.sh — screenpipe [SSH: nas]
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Explorer (⇧⌘E) - 1 unsaved file
1
Search (⇧⌘F)
Explorer (⇧⌘E) - 1 unsaved file
1
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py
M
db.py
docker-compose.yml
Dockerfile
M
main.py
M
requirements.txt
M
data
logs
pipes
.gitignore
app_settings.json
archive.db
archive.db-bak
U
db.sqlite
db.sqlite-shm
db.sqlite-wal
screenpipe_sync_updated.sh
U
screenpipe_sync.sh
screenpipe.db
Outline Section
OUTLINE
OUTLINE
Timeline Section
TIMELINE
TIMELINE
app_settings.json, Editor Group 1
screenpipe_sync.sh, Editor Group 1
pipe.md, Editor Group 1
.env, Editor Group 1
#!/bin/bash
# screenpipe_sync.sh
# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).
# Also copies the day's video/frame data folder to the NAS.
#
# Schema-drift tolerant: if Screenpipe migrations add new columns to the source DB,
# the NAS archive gets ALTER TABLE'd to match. Inserts use explicit column lists,
# so positional mismatches can't occur.
#
# Usage:
# ./screenpipe_sync.sh # syncs yesterday (default)
# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date
# ./screenpipe_sync.sh today # syncs today so far
#
# Cron example (runs at 3am daily):
# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1
set -euo pipefail
# ─── CONFIG ───────────────────────────────────────────────────────────────────
DB_SRC="${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}"
NAS_MOUNT="${NAS_MOUNT:-/Volumes/screenpipe}"
NAS_DB="$NAS_MOUNT/archive.db"
NAS_DATA="$NAS_MOUNT/data"
LOG_FILE="$HOME/.screenpipe/sync.log"
# Tables that get schema drift handling. Order matters for FK-ish references
# (parents before children: video_chunks → frames → elements/ocr_text/ui_events).
SYNC_TABLES=(video_chunks frames elements ocr_text ui_events meetings)
# ──────────────────────────────────────────────────────────────────────────────
# ─── HELPERS ──────────────────────────────────────────────────────────────────
SCRIPT_START=$(date +%s)
log() {
local msg="[$(date '+%Y-%m-%d %H:%M:%S')] $*"
echo "$msg" | tee -a "$LOG_FILE"
}
step() {
local now=$(date +%s)
local elapsed=$(( now - SCRIPT_START ))
local min=$(( elapsed / 60 ))
local sec=$(( elapsed % 60 ))
printf "\n[+%02dm%02ds] ▶ %s\n" "$min" "$sec" "$*" | tee -a "$LOG_FILE"
}
run_sqlite_heredoc() {
local label="$1"
local sql="$2"
local start=$(date +%s)
printf " %-36s " "$label"
sqlite3 "$DB_SRC" <<< "$sql" &
local pid=$!
local spin=[PASSWORD] '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')
local i=0
while kill -0 "$pid" 2>/dev/null; do
printf "\r %-36s %s " "$label" "${spin[$i]}"
i=$(( (i + 1) % 10 ))
sleep 0.2
done
wait "$pid"
local rc=$?
if [ $rc -ne 0 ]; then
printf "\r %-36s ✗ FAILED\n" "$label" | tee -a "$LOG_FILE"
exit $rc
fi
local dur=$(( $(date +%s) - start ))
printf "\r %-36s ✓ %dm%02ds\n" "$label" "$(( dur / 60 ))" "$(( dur % 60 ))" | tee -a "$LOG_FILE"
}
check() {
local label="$1" got="$2" expected="$3"
if [ "$got" -eq "$expected" ]; then
printf " %-20s %s / %s ✓\n" "$label:" "$got" "$expected"
else
printf " %-20s %s / %s ✗ MISMATCH\n" "$label:" "$got" "$expected"
fi
}
# ─── SCHEMA HELPERS ───────────────────────────────────────────────────────────
# Echoes "name|type" lines for a table from a given DB.
table_columns_with_types() {
local db="$1" table="$2"
sqlite3 "$db" "PRAGMA table_info($table);" | awk -F'|' '{print $2 "|" $3}'
}
# Echoes just column names, one per line.
table_columns() {
local db="$1" table="$2"
sqlite3 "$db" "PRAGMA table_info($table);" | awk -F'|' '{print $2}'
}
# Returns true (0) if a table exists in the given DB.
table_exists() {
local db="$1" table="$2"
local count
count=$(sqlite3 "$db" "SELECT COUNT(*) FROM sqlite_master WHERE type='table' AND name='$table';")
[ "$count" -gt 0 ]
}
# Adds any columns present in source but missing in NAS for the given table.
# Uses ALTER TABLE ADD COLUMN, which is a fast metadata-only operation in SQLite.
ensure_columns() {
local table="$1"
local label="schema: $table"
printf " %-36s " "$label"
if ! table_exists "$DB_SRC" "$table"; then
printf "✗ source missing — skipping\n"
return 0
fi
if ! table_exists "$NAS_DB" "$table"; then
printf "✓ fresh (created above)\n"
return 0
fi
local src_cols
src_cols=$(table_columns_with_types "$DB_SRC" "$table")
local nas_cols
nas_cols=$(table_columns "$NAS_DB" "$table")
local added=0
local added_names=""
while IFS='|' read -r name type; do
[ -z "$name" ] && continue
# Use grep -F -x for fixed-string exact match (safe against regex chars).
if ! echo "$nas_cols" | grep -Fxq "$name"; then
# SQLite ALTER TABLE ADD COLUMN: type is optional, no NOT NULL allowed
# without a constant default. Default-NULL is exactly what we want for archive.
sqlite3 "$NAS_DB" "ALTER TABLE $table ADD COLUMN \"$name\" $type;"
added=$((added + 1))
added_names="$added_names $name"
fi
done <<< "$src_cols"
if [ "$added" -gt 0 ]; then
printf "✓ added %d:%s\n" "$added" "$added_names"
else
printf "✓ in sync\n"
fi
}
# Echoes a comma-separated list of source columns for a table, double-quoted
# so reserved words and hyphens are safe. If an alias is provided, columns are
# prefixed (e.g. `o."col"`). Used for both INSERT and SELECT sides; aliased
# form is required when SELECTing from a JOIN where column names collide
# (e.g. ocr_text and frames both have app_name, window_name).
build_col_list() {
local table="$1"
local alias="${2:-}"
local prefix=""
[ -n "$alias" ] && prefix="${alias}."
table_columns "$DB_SRC" "$table" | awk 'NF' | awk -v p="$prefix" '{print p "\"" $0 "\""}' | paste -sd, -
}
# ──────────────────────────────────────────────────────────────────────────────
# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────
if [ "${1:-}" = "today" ]; then
TARGET_DATE=$(date +%Y-%m-%d)
elif [ -n "${1:-}" ]; then
TARGET_DATE="$1"
if ! [[ "$TARGET_DATE" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then
echo "ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday."
exit 1
fi
else
TARGET_DATE=$(date -v-1d +%Y-%m-%d)
fi
log "========================================"
log "Screenpipe sync starting for: $TARGET_DATE"
log "========================================"
# ─── PREFLIGHT ────────────────────────────────────────────────────────────────
step "Preflight checks"
if [ ! -f "$DB_SRC" ]; then
log "ERROR: Source DB not found at $DB_SRC"; exit 1
fi
printf " %-20s %s (%s)\n" "Source DB:" "OK" "$(du -sh "$DB_SRC" | cut -f1)"
if [ ! -d "$NAS_MOUNT" ]; then
log "ERROR: NAS not mounted at $NAS_MOUNT"; exit 1
fi
printf " %-20s %s\n" "NAS mount:" "OK $NAS_MOUNT"
# Check if DB already synced for this date
DB_ALREADY_SYNCED=false
if [ -f "$NAS_DB" ]; then
if table_exists "$NAS_DB" "frames"; then
EXISTING=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';" 2>/dev/null || echo "0")
if [ "$EXISTING" -gt "0" ]; then
log "Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync"
DB_ALREADY_SYNCED=true
else
printf " %-20s %s (%s)\n" "Archive DB:" "exists" "$(du -sh "$NAS_DB" | cut -f1)"
fi
else
printf " %-20s %s\n" "Archive DB:" "exists, no frames table yet"
fi
else
printf " %-20s %s\n" "Archive DB:" "will be created"
fi
# Source data dir for this date
DATA_SRC="$HOME/.screenpipe/data/data/$TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
DATA_SIZE=$(du -sh "$DATA_SRC" | cut -f1)
DATA_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
printf " %-20s %s (%s files, %s)\n" "Data dir:" "OK" "$DATA_FILES" "$DATA_SIZE"
else
printf " %-20s %s\n" "Data dir:" "not found — skipping file copy"
fi
# ─── DB SYNC ──────────────────────────────────────────────────────────────────
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────
step "Counting source rows for $TARGET_DATE"
SRC_FRAMES=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
SRC_ELEMENTS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_UI=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
SRC_OCR=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_MEETINGS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';")
printf " %-20s %s\n" "frames:" "$SRC_FRAMES"
printf " %-20s %s\n" "elements:" "$SRC_ELEMENTS"
printf " %-20s %s\n" "ui_events:" "$SRC_UI"
printf " %-20s %s\n" "ocr_text:" "$SRC_OCR"
printf " %-20s %s\n" "meetings:" "$SRC_MEETINGS"
if [ "$SRC_FRAMES" -eq "0" ]; then
log "No frames found for $TARGET_DATE — skipping DB sync"
DB_ALREADY_SYNCED=true
fi
fi
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── INIT TABLES ──────────────────────────────────────────────────────────
step "Initialising tables (CREATE IF NOT EXISTS)"
run_sqlite_heredoc "creating tables" "
ATTACH '$NAS_DB' AS nas;
CREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;
CREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;
CREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;
CREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;
DETACH nas;
"
# ─── SCHEMA DRIFT FIX ─────────────────────────────────────────────────────
# Runs AFTER CREATE IF NOT EXISTS so newly-created tables are no-ops here,
# and pre-existing tables get any missing columns added.
step "Reconciling NAS schema with source"
for tbl in "${SYNC_TABLES[@]}"; do
ensure_columns "$tbl"
done
run_sqlite_heredoc "creating indexes" "
ATTACH '$NAS_DB' AS nas;
CREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);
CREATE INDEX IF NOT EXISTS nas.idx_frames_document_path ON frames(document_path) WHERE document_path IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_elements_onscreen_frame ON elements(frame_id) WHERE on_screen = 1 AND text IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);
CREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);
DETACH nas;
"
run_sqlite_heredoc "creating FTS tables" "
ATTACH '$NAS_DB' AS nas;
CREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(
text, role, frame_id UNINDEXED,
content='elements', content_rowid='id', tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(
full_text, app_name, window_name, browser_url, id UNINDEXED,
tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(
text_content,
app_name,
window_title,
element_name,
content='ui_events',
content_rowid='id',
tokenize='unicode61'
);
DETACH nas;
"
# ─── BUILD EXPLICIT COLUMN LISTS ──────────────────────────────────────────
# After ensure_columns, source ⊆ NAS for every synced table, so source's
# column list is a safe subset to use on both sides of the INSERT.
# For tables that JOIN frames (ocr_text, elements), the SELECT side needs
# alias-qualified columns because both tables share names (app_name, etc).
FRAMES_COLS=$(build_col_list frames)
ELEMENTS_COLS=$(build_col_list elements)
ELEMENTS_COLS_E=$(build_col_list elements e)
UI_EVENTS_COLS=$(build_col_list ui_events)
OCR_TEXT_COLS=$(build_col_list ocr_text)
OCR_TEXT_COLS_O=$(build_col_list ocr_text o)
VIDEO_CHUNKS_COLS=$(build_col_list video_chunks)
MEETINGS_COLS=$(build_col_list meetings)
# ─── SYNC DATA ────────────────────────────────────────────────────────────
step "Syncing data for $TARGET_DATE"
run_sqlite_heredoc "video_chunks" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.video_chunks ($VIDEO_CHUNKS_COLS)
SELECT $VIDEO_CHUNKS_COLS FROM main.video_chunks
WHERE id IN (
SELECT DISTINCT video_chunk_id FROM main.frames
WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL
);
DETACH nas;
"
run_sqlite_heredoc "frames ($SRC_FRAMES rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.frames ($FRAMES_COLS)
SELECT $FRAMES_COLS FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ocr_text ($SRC_OCR rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ocr_text ($OCR_TEXT_COLS)
SELECT $OCR_TEXT_COLS_O FROM main.ocr_text o
JOIN main.frames f ON o.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ui_events ($SRC_UI rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ui_events ($UI_EVENTS_COLS)
SELECT $UI_EVENTS_COLS FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "elements ($SRC_ELEMENTS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.elements ($ELEMENTS_COLS)
SELECT $ELEMENTS_COLS_E FROM main.elements e
JOIN main.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "meetings ($SRC_MEETINGS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.meetings ($MEETINGS_COLS)
SELECT $MEETINGS_COLS FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';
DETACH nas;
"
# ─── FTS UPDATE ───────────────────────────────────────────────────────────
step "Updating FTS indexes"
run_sqlite_heredoc "elements_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.elements_fts(rowid, text, role)
SELECT e.id, e.text, e.role
FROM nas.elements e
JOIN nas.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE'
AND e.text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "frames_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)
SELECT id, full_text, app_name, window_name, browser_url, id
FROM nas.frames
WHERE date(timestamp) = '$TARGET_DATE'
AND full_text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "ui_events_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)
SELECT id, text_content, app_name, window_title, element_name
FROM nas.ui_events
WHERE date(timestamp) = '$TARGET_DATE'
AND text_content IS NOT NULL;
DETACH nas;
"
# ─── VERIFY DB ────────────────────────────────────────────────────────────
step "Verifying DB"
V_FRAMES=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
V_ELEMENTS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_UI=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
V_OCR=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_MEETINGS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';")
check "frames" "$V_FRAMES" "$SRC_FRAMES"
check "elements" "$V_ELEMENTS" "$SRC_ELEMENTS"
check "ui_events" "$V_UI" "$SRC_UI"
check "ocr_text" "$V_OCR" "$SRC_OCR"
check "meetings" "$V_MEETINGS" "$SRC_MEETINGS"
fi
# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────
# Always runs regardless of DB sync status
step "Copying data folder for $TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
mkdir -p "$NAS_DATA/$TARGET_DATE"
RSYNC_START=$(date +%s)
printf " %-36s " "rsync $TARGET_DATE/ → NAS"
rsync -a --ignore-existing \
"$DATA_SRC/" \
"$NAS_DATA/$TARGET_DATE/" \
2>>"$LOG_FILE"
RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))
COPIED_FILES=$(ls "$NAS_DATA/$TARGET_DATE" | wc -l | tr -d ' ')
SRC_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
COPIED_SIZE=$(du -sh "$NAS_DATA/$TARGET_DATE" | cut -f1)
if [ "$COPIED_FILES" -eq "$SRC_FILES" ]; then
printf "\r %-36s ✓ %dm%02ds (%s files, %s)\n" \
"rsync $TARGET_DATE/ → NAS" \
"$(( RSYNC_DUR / 60 ))" "$(( RSYNC_DUR % 60 ))" \
"$COPIED_FILES" "$COPIED_SIZE" | tee -a "$LOG_FILE"
else
printf "\r %-36s ✗ %s / %s files\n" \
"rsync $TARGET_DATE/ → NAS" "$COPIED_FILES" "$SRC_FILES" | tee -a "$LOG_FILE"
fi
else
printf " %-36s %s\n" "rsync $TARGET_DATE/ → NAS" "skipped (no source dir)"
fi
# ─── COPY LOGS ────────────────────────────────────────────────────────────────
# Screenpipe writes daily logs to ~/.screenpipe/screenpipe.YYYY-MM-DD.N.log
# (N is a rotation counter, almost always 0). Mirror them to NAS so log
# analysis can happen on the consumer side without SSH'ing back to the Mac.
step "Copying screenpipe logs for $TARGET_DATE"
NAS_LOGS="$NAS_MOUNT/logs"
mkdir -p "$NAS_LOGS"
# Use a glob with nullglob so an empty match doesn't expand to a literal pattern.
shopt -s nullglob
LOG_FILES=( "$HOME/.screenpipe/screenpipe.$TARGET_DATE."*.log )
shopt -u nullglob
if [ ${#LOG_FILES[@]} -gt 0 ]; then
printf " %-36s " "rsync logs → NAS"
# No --ignore-existing here: logs grow during the day, so we want rsync's
# default size+mtime check to refresh files that have changed.
rsync -a "${LOG_FILES[@]}" "$NAS_LOGS/" 2>>"$LOG_FILE"
COPIED=${#LOG_FILES[@]}
TOTAL_SIZE=$(du -ch "${LOG_FILES[@]}" | tail -1 | cut -f1)
printf "✓ %d file(s), %s\n" "$COPIED" "$TOTAL_SIZE" | tee -a "$LOG_FILE"
else
printf " %-36s %s\n" "rsync logs → NAS" "skipped (no matching logs)"
fi
# ─── SUMMARY ──────────────────────────────────────────────────────────────────
TOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))
DB_SIZE=$(du -sh "$NAS_DB" | cut -f1)
echo ""
log "Archive DB size: $DB_SIZE"
log "Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s"
log "Sync complete for $TARGET_DATE"
log "========================================"
# Mirror this script's own logbook to NAS so sync health can be monitored
# from the consumer side. Done last so the summary lines above are included.
rsync -a "$HOME/.screenpipe/sync.log" "$NAS_LOGS/sync.log" 2>/dev/null || true
#!/bin/bash
# screenpipe_sync.sh
# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).
# Also copies the day's video/frame data folder to the NAS.
#
# Schema-drift tolerant: if Screenpipe migrations add new columns to the source DB,
# the NAS archive gets ALTER TABLE'd to match. Inserts use explicit column lists,
# so positional mismatches can't occur.
#
# Usage:
# ./screenpipe_sync.sh # syncs yesterday (default)
# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date
# ./screenpipe_sync.sh today # syncs today so far
#
# Cron example (runs at 3am daily):
# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1
set -euo pipefail
# ─── CONFIG ───────────────────────────────────────────────────────────────────
DB_SRC="${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}"
NAS_MOUNT="${NAS_MOUNT:-/Volumes/screenpipe}"
NAS_DB="$NAS_MOUNT/archive.db"
NAS_DATA="$NAS_MOUNT/data"
LOG_FILE="$HOME/.screenpipe/sync.log"
# Tables that get schema drift handling. Order matters for FK-ish references
# (parents before children: video_chunks → frames → elements/ocr_text/ui_events).
SYNC_TABLES=(video_chunks frames elements ocr_text ui_events meetings)
# ──────────────────────────────────────────────────────────────────────────────
# ─── HELPERS ──────────────────────────────────────────────────────────────────
SCRIPT_START=$(date +%s)
log() {
local msg="[$(date '+%Y-%m-%d %H:%M:%S')] $*"
echo "$msg" | tee -a "$LOG_FILE"
}
step() {
local now=$(date +%s)
local elapsed=$(( now - SCRIPT_START ))
local min=$(( elapsed / 60 ))
local sec=$(( elapsed % 60 ))
printf "\n[+%02dm%02ds] ▶ %s\n" "$min" "$sec" "$*" | tee -a "$LOG_FILE"
}
run_sqlite_heredoc() {
local label="$1"
local sql="$2"
local start=$(date +%s)
printf " %-36s " "$label"
sqlite3 "$DB_SRC" <<< "$sql" &
local pid=$!
local spin=[PASSWORD] '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')
local i=0
while kill -0 "$pid" 2>/dev/null; do
printf "\r %-36s %s " "$label" "${spin[$i]}"
i=$(( (i + 1) % 10 ))
sleep 0.2
done
wait "$pid"
local rc=$?
if [ $rc -ne 0 ]; then
printf "\r %-36s ✗ FAILED\n" "$label" | tee -a "$LOG_FILE"
exit $rc
fi
local dur=$(( $(date +%s) - start ))
printf "\r %-36s ✓ %dm%02ds\n" "$label" "$(( dur / 60 ))" "$(( dur % 60 ))" | tee -a "$LOG_FILE"
}
check() {
local label="$1" got="$2" expected="$3"
if [ "$got" -eq "$expected" ]; then
printf " %-20s %s / %s ✓\n" "$label:" "$got" "$expected"
else
printf " %-20s %s / %s ✗ MISMATCH\n" "$label:" "$got" "$expected"
fi
}
# ─── SCHEMA HELPERS ───────────────────────────────────────────────────────────
# Echoes "name|type" lines for a table from a given DB.
table_columns_with_types() {
local db="$1" table="$2"
sqlite3 "$db" "PRAGMA table_info($table);" | awk -F'|' '{print $2 "|" $3}'
}
# Echoes just column names, one per line.
table_columns() {
local db="$1" table="$2"
sqlite3 "$db" "PRAGMA table_info($table);" | awk -F'|' '{print $2}'
}
# Returns true (0) if a table exists in the given DB.
table_exists() {
local db="$1" table="$2"
local count
count=$(sqlite3 "$db" "SELECT COUNT(*) FROM sqlite_master WHERE type='table' AND name='$table';")
[ "$count" -gt 0 ]
}
# Adds any columns present in source but missing in NAS for the given table.
# Uses ALTER TABLE ADD COLUMN, which is a fast metadata-only operation in SQLite.
ensure_columns() {
local table="$1"
local label="schema: $table"
printf " %-36s " "$label"
if ! table_exists "$DB_SRC" "$table"; then
printf "✗ source missing — skipping\n"
return 0
fi
if ! table_exists "$NAS_DB" "$table"; then
printf "✓ fresh (created above)\n"
return 0
fi
local src_cols
src_cols=$(table_columns_with_types "$DB_SRC" "$table")
local nas_cols
nas_cols=$(table_columns "$NAS_DB" "$table")
local added=0
local added_names=""
while IFS='|' read -r name type; do
[ -z "$name" ] && continue
# Use grep -F -x for fixed-string exact match (safe against regex chars).
if ! echo "$nas_cols" | grep -Fxq "$name"; then
# SQLite ALTER TABLE ADD COLUMN: type is optional, no NOT NULL allowed
# without a constant default. Default-NULL is exactly what we want for archive.
sqlite3 "$NAS_DB" "ALTER TABLE $table ADD COLUMN \"$name\" $type;"
added=$((added + 1))
added_names="$added_names $name"
fi
done <<< "$src_cols"
if [ "$added" -gt 0 ]; then
printf "✓ added %d:%s\n" "$added" "$added_names"
else
printf "✓ in sync\n"
fi
}
# Echoes a comma-separated list of source columns for a table, double-quoted
# so reserved words and hyphens are safe. If an alias is provided, columns are
# prefixed (e.g. `o."col"`). Used for both INSERT and SELECT sides; aliased
# form is required when SELECTing from a JOIN where column names collide
# (e.g. ocr_text and frames both have app_name, window_name).
build_col_list() {
local table="$1"
local alias="${2:-}"
local prefix=""
[ -n "$alias" ] && prefix="${alias}."
table_columns "$DB_SRC" "$table" | awk 'NF' | awk -v p="$prefix" '{print p "\"" $0 "\""}' | paste -sd, -
}
# ──────────────────────────────────────────────────────────────────────────────
# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────
if [ "${1:-}" = "today" ]; then
TARGET_DATE=$(date +%Y-%m-%d)
elif [ -n "${1:-}" ]; then
TARGET_DATE="$1"
if ! [[ "$TARGET_DATE" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then
echo "ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday."
exit 1
fi
else
TARGET_DATE=$(date -v-1d +%Y-%m-%d)
fi
log "========================================"
log "Screenpipe sync starting for: $TARGET_DATE"
log "========================================"
# ─── PREFLIGHT ────────────────────────────────────────────────────────────────
step "Preflight checks"
if [ ! -f "$DB_SRC" ]; then
log "ERROR: Source DB not found at $DB_SRC"; exit 1
fi
printf " %-20s %s (%s)\n" "Source DB:" "OK" "$(du -sh "$DB_SRC" | cut -f1)"
if [ ! -d "$NAS_MOUNT" ]; then
log "ERROR: NAS not mounted at $NAS_MOUNT"; exit 1
fi
printf " %-20s %s\n" "NAS mount:" "OK $NAS_MOUNT"
# Check if DB already synced for this date
DB_ALREADY_SYNCED=false
if [ -f "$NAS_DB" ]; then
if table_exists "$NAS_DB" "frames"; then
EXISTING=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';" 2>/dev/null || echo "0")
if [ "$EXISTING" -gt "0" ]; then
log "Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync"
DB_ALREADY_SYNCED=true
else
printf " %-20s %s (%s)\n" "Archive DB:" "exists" "$(du -sh "$NAS_DB" | cut -f1)"
fi
else
printf " %-20s %s\n" "Archive DB:" "exists, no frames table yet"
fi
else
printf " %-20s %s\n" "Archive DB:" "will be created"
fi
# Source data dir for this date
DATA_SRC="$HOME/.screenpipe/data/data/$TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
DATA_SIZE=$(du -sh "$DATA_SRC" | cut -f1)
DATA_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
printf " %-20s %s (%s files, %s)\n" "Data dir:" "OK" "$DATA_FILES" "$DATA_SIZE"
else
printf " %-20s %s\n" "Data dir:" "not found — skipping file copy"
fi
# ─── DB SYNC ──────────────────────────────────────────────────────────────────
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────
step "Counting source rows for $TARGET_DATE"
SRC_FRAMES=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
SRC_ELEMENTS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_UI=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
SRC_OCR=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_MEETINGS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';")
printf " %-20s %s\n" "frames:" "$SRC_FRAMES"
printf " %-20s %s\n" "elements:" "$SRC_ELEMENTS"
printf " %-20s %s\n" "ui_events:" "$SRC_UI"
printf " %-20s %s\n" "ocr_text:" "$SRC_OCR"
printf " %-20s %s\n" "meetings:" "$SRC_MEETINGS"
if [ "$SRC_FRAMES" -eq "0" ]; then
log "No frames found for $TARGET_DATE — skipping DB sync"
DB_ALREADY_SYNCED=true
fi
fi
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── INIT TABLES ──────────────────────────────────────────────────────────
step "Initialising tables (CREATE IF NOT EXISTS)"
run_sqlite_heredoc "creating tables" "
ATTACH '$NAS_DB' AS nas;
CREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;
CREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;
CREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;
CREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;
DETACH nas;
"
# ─── SCHEMA DRIFT FIX ─────────────────────────────────────────────────────
# Runs AFTER CREATE IF NOT EXISTS so newly-created tables are no-ops here,
# and pre-existing tables get any missing columns added.
step "Reconciling NAS schema with source"
for tbl in "${SYNC_TABLES[@]}"; do
ensure_columns "$tbl"
done
run_sqlite_heredoc "creating indexes" "
ATTACH '$NAS_DB' AS nas;
CREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);
CREATE INDEX IF NOT EXISTS nas.idx_frames_document_path ON frames(document_path) WHERE document_path IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_elements_onscreen_frame ON elements(frame_id) WHERE on_screen = 1 AND text IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);
CREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);
DETACH nas;
"
run_sqlite_heredoc "creating FTS tables" "
ATTACH '$NAS_DB' AS nas;
CREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(
text, role, frame_id UNINDEXED,
content='elements', content_rowid='id', tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(
full_text, app_name, window_name, browser_url, id UNINDEXED,
tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(
text_content,
app_name,
window_title,
element_name,
content='ui_events',
content_rowid='id',
tokenize='unicode61'
);
DETACH nas;
"
# ─── BUILD EXPLICIT COLUMN LISTS ──────────────────────────────────────────
# After ensure_columns, source ⊆ NAS for every synced table, so source's
# column list is a safe subset to use on both sides of the INSERT.
# For tables that JOIN frames (ocr_text, elements), the SELECT side needs
# alias-qualified columns because both tables share names (app_name, etc).
FRAMES_COLS=$(build_col_list frames)
ELEMENTS_COLS=$(build_col_list elements)
ELEMENTS_COLS_E=$(build_col_list elements e)
UI_EVENTS_COLS=$(build_col_list ui_events)
OCR_TEXT_COLS=$(build_col_list ocr_text)
OCR_TEXT_COLS_O=$(build_col_list ocr_text o)
VIDEO_CHUNKS_COLS=$(build_col_list video_chunks)
MEETINGS_COLS=$(build_col_list meetings)
# ─── SYNC DATA ────────────────────────────────────────────────────────────
step "Syncing data for $TARGET_DATE"
run_sqlite_heredoc "video_chunks" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.video_chunks ($VIDEO_CHUNKS_COLS)
SELECT $VIDEO_CHUNKS_COLS FROM main.video_chunks
WHERE id IN (
SELECT DISTINCT video_chunk_id FROM main.frames
WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL
);
DETACH nas;
"
run_sqlite_heredoc "frames ($SRC_FRAMES rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.frames ($FRAMES_COLS)
SELECT $FRAMES_COLS FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ocr_text ($SRC_OCR rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ocr_text ($OCR_TEXT_COLS)
SELECT $OCR_TEXT_COLS_O FROM main.ocr_text o
JOIN main.frames f ON o.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ui_events ($SRC_UI rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ui_events ($UI_EVENTS_COLS)
SELECT $UI_EVENTS_COLS FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "elements ($SRC_ELEMENTS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.elements ($ELEMENTS_COLS)
SELECT $ELEMENTS_COLS_E FROM main.elements e
JOIN main.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "meetings ($SRC_MEETINGS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.meetings ($MEETINGS_COLS)
SELECT $MEETINGS_COLS FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';
DETACH nas;
"
# ─── FTS UPDATE ───────────────────────────────────────────────────────────
step "Updating FTS indexes"
run_sqlite_heredoc "elements_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.elements_fts(rowid, text, role)
SELECT e.id, e.text, e.role
FROM nas.elements e
JOIN nas.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE'
AND e.text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "frames_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)
SELECT id, full_text, app_name, window_name, browser_url, id
FROM nas.frames
WHERE date(timestamp) = '$TARGET_DATE'
AND full_text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "ui_events_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)
SELECT id, text_content, app_name, window_title, element_name
FROM nas.ui_events
WHERE date(timestamp) = '$TARGET_DATE'
AND text_content IS NOT NULL;
DETACH nas;
"
# ─── VERIFY DB ────────────────────────────────────────────────────────────
step "Verifying DB"
V_FRAMES=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
V_ELEMENTS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_UI=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
V_OCR=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_MEETINGS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';")
check "frames" "$V_FRAMES" "$SRC_FRAMES"
check "elements" "$V_ELEMENTS" "$SRC_ELEMENTS"
check "ui_events" "$V_UI" "$SRC_UI"
check "ocr_text" "$V_OCR" "$SRC_OCR"
check "meetings" "$V_MEETINGS" "$SRC_MEETINGS"
fi
# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────
# Always runs regardless of DB sync status
step "Copying data folder for $TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
mkdir -p "$NAS_DATA/$TARGET_DATE"
RSYNC_START=$(date +%s)
printf " %-36s " "rsync $TARGET_DATE/ → NAS"
rsync -a --ignore-existing \
"$DATA_SRC/" \
"$NAS_DATA/$TARGET_DATE/" \
2>>"$LOG_FILE"
RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))
COPIED_FILES=$(ls "$NAS_DATA/$TARGET_DATE" | wc -l | tr -d ' ')
SRC_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
COPIED_SIZE=$(du -sh "$NAS_DATA/$TARGET_DATE" | cut -f1)
if [ "$COPIED_FILES" -eq "$SRC_FILES" ]; then
printf "\r %-36s ✓ %dm%02ds (%s files, %s)\n" \
"rsync $TARGET_DATE/ → NAS" \
"$(( RSYNC_DUR / 60 ))" "$(( RSYNC_DUR % 60 ))" \
"$COPIED_FILES" "$COPIED_SIZE" | tee -a "$LOG_FILE"
else
printf "\r %-36s ✗ %s / %s files\n" \
"rsync $TARGET_DATE/ → NAS" "$COPIED_FILES" "$SRC_FILES" | tee -a "$LOG_FILE"
fi
else
printf " %-36s %s\n" "rsync $TARGET_DATE/ → NAS" "skipped (no source dir)"
fi
# ─── COPY LOGS ────────────────────────────────────────────────────────────────
# Screenpipe writes daily logs to ~/.screenpipe/screenpipe.YYYY-MM-DD.N.log
# (N is a rotation counter, almost always 0). Mirror them to NAS so log
# analysis can happen on the consumer side without SSH'ing back to the Mac.
step "Copying screenpipe logs for $TARGET_DATE"
NAS_LOGS="$NAS_MOUNT/logs"
mkdir -p "$NAS_LOGS"
# Use a glob with nullglob so an empty match doesn't expand to a literal pattern.
shopt -s nullglob
LOG_FILES=( "$HOME/.screenpipe/screenpipe.$TARGET_DATE."*.log )
shopt -u nullglob
if [ ${#LOG_FILES[@]} -gt 0 ]; then
printf " %-36s " "rsync logs → NAS"
# No --ignore-existing here: logs grow during the day, so we want rsync's
# default size+mtime check to refresh files that have changed.
rsync -a "${LOG_FILES[@]}" "$NAS_LOGS/" 2>>"$LOG_FILE"
COPIED=${#LOG_FILES[@]}
TOTAL_SIZE=$(du -ch "${LOG_FILES[@]}" | tail -1 | cut -f1)
printf "✓ %d file(s), %s\n" "$COPIED" "$TOTAL_SIZE" | tee -a "$LOG_FILE"
else
printf " %-36s %s\n" "rsync logs → NAS" "skipped (no matching logs)"
fi
# ─── SUMMARY ──────────────────────────────────────────────────────────────────
TOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))
DB_SIZE=$(du -sh "$NAS_DB" | cut -f1)
echo ""
log "Archive DB size: $DB_SIZE"
log "Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s"
log "Sync complete for $TARGET_DATE"
log "========================================"
# Mirror this script's own logbook to NAS so sync health can be monitored
# from the consumer side. Done last so the summary lines above are included.
rsync -a "$HOME/.screenpipe/sync.log" "$NAS_LOGS/sync.log" 2>/dev/null || true
Implement and run pipe l…, Editor Group 2
Problems (⇧⌘M)
PROBLEMS
Output (⇧⌘U)
OUTPUT
Debug Console (⇧⌘Y)
DEBUG CONSOLE
Terminal (⌃`)
TERMINAL
Ports - 1 forwarded port
PORTS
1
remote SSH: nas
SSH: nas
screenpipe (Git) - master*, Checkout Branch/Tag...
master*
screenpipe (Git) - Synchronize Changes
No Problems
0
0
Forwarded Ports: 8766
1
Notifications
Sign In
Sign In
Shell Script
Editor Language Status: Inline Suggestions, next: $(copilot) No inline suggestion available, Inline suggestions
LF
UTF-8
Spaces: 2
Ln 480, Col 3
git-commit Not Committed Yet...
|
[{"role":"AXRadioButton","text [{"role":"AXRadioButton","text":"Explorer (⇧⌘E) - 1 unsaved file","depth":19,"bounds":{"left":0.0,"top":0.047885075,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":true},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.057462092,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":22,"bounds":{"left":0.009640957,"top":0.06863528,"width":0.0016622341,"height":0.008778931},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Search (⇧⌘F)","depth":19,"bounds":{"left":0.0,"top":0.08619314,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.09577015,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Source Control (⌃⇧G) - 10 pending changes","depth":19,"bounds":{"left":0.0,"top":0.1245012,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.13407822,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"10","depth":22,"bounds":{"left":0.00831117,"top":0.1452514,"width":0.003656915,"height":0.008778931},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.00831117,"top":0.14604948,"width":0.0016622341,"height":0.007980846}},{"char_start":1,"char_count":1,"bounds":{"left":0.009973404,"top":0.14604948,"width":0.0023271276,"height":0.007980846}}],"role_description":"text"},{"role":"AXRadioButton","text":"Run and Debug (⇧⌘D)","depth":19,"bounds":{"left":0.0,"top":0.16280925,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.17238627,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Remote Explorer","depth":19,"bounds":{"left":0.0,"top":0.20111732,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.21069433,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Extensions (⇧⌘X) - 2 require update","depth":19,"bounds":{"left":0.0,"top":0.23942538,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.2490024,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"2","depth":22,"bounds":{"left":0.009640957,"top":0.2601756,"width":0.0019946808,"height":0.008778931},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Claude Code","depth":19,"bounds":{"left":0.0,"top":0.27773345,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"Containers","depth":19,"bounds":{"left":0.0,"top":0.3160415,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXHeading","text":"EXPLORER","depth":17,"bounds":{"left":0.022606382,"top":0.047885075,"width":0.018949468,"height":0.02793296},"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"EXPLORER","depth":18,"bounds":{"left":0.022606382,"top":0.056664005,"width":0.018949468,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.022606382,"top":0.056664005,"width":0.0023271276,"height":0.0103751}},{"char_start":1,"char_count":7,"bounds":{"left":0.024933511,"top":0.056664005,"width":0.01662234,"height":0.0103751}}],"role_description":"text"},{"role":"AXButton","text":"Explorer Section: screenpipe [SSH: nas]","depth":21,"bounds":{"left":0.015957447,"top":0.07581804,"width":0.09940159,"height":0.017557861},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":true},{"role":"AXStaticText","text":"","depth":23,"bounds":{"left":0.01662234,"top":0.07821229,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"Explorer Section: screenpipe [SSH: nas]","depth":22,"bounds":{"left":0.022606382,"top":0.07581804,"width":0.045877658,"height":0.017557861},"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"SCREENPIPE [SSH: NAS]","depth":23,"bounds":{"left":0.022606382,"top":0.079010375,"width":0.045877658,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.022606382,"top":0.07980846,"width":0.0026595744,"height":0.0103751}},{"char_start":1,"char_count":20,"bounds":{"left":0.025265958,"top":0.07980846,"width":0.043218084,"height":0.0103751}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.09577015,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"#recycle","depth":27,"bounds":{"left":0.025930852,"top":0.09577015,"width":0.017287234,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.096568234,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":7,"bounds":{"left":0.028590426,"top":0.096568234,"width":0.01462766,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.11332801,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"app","depth":27,"bounds":{"left":0.025930852,"top":0.11332801,"width":0.0076462766,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.11412609,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":2,"bounds":{"left":0.02825798,"top":0.11412609,"width":0.005319149,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.11412609,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.022273935,"top":0.13088587,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"__pycache__","depth":27,"bounds":{"left":0.028590426,"top":0.13088587,"width":0.026595745,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.13168396,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":10,"bounds":{"left":0.030917553,"top":0.13168396,"width":0.024268618,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.022273935,"top":0.14844373,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"consumers","depth":27,"bounds":{"left":0.028590426,"top":0.14844373,"width":0.022273935,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.14924182,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":8,"bounds":{"left":0.030917553,"top":0.14924182,"width":0.019946808,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.14924182,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.022273935,"top":0.1660016,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"static","depth":27,"bounds":{"left":0.028590426,"top":0.1660016,"width":0.010970744,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.16679968,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":5,"bounds":{"left":0.030917553,"top":0.16679968,"width":0.008976064,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.16679968,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.1819633,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":".env","depth":27,"bounds":{"left":0.028590426,"top":0.18355946,"width":0.00831117,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.18435754,"width":0.0013297872,"height":0.011971269}},{"char_start":1,"char_count":3,"bounds":{"left":0.029920213,"top":0.18435754,"width":0.006981383,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.19952115,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"cli.py","depth":27,"bounds":{"left":0.028590426,"top":0.20111732,"width":0.010638298,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.2019154,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":5,"bounds":{"left":0.030917553,"top":0.2019154,"width":0.00831117,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.2019154,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.21707901,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.py","depth":27,"bounds":{"left":0.028590426,"top":0.21867518,"width":0.011303191,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.21947326,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":4,"bounds":{"left":0.03125,"top":0.21947326,"width":0.008643617,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.23463687,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"docker-compose.yml","depth":27,"bounds":{"left":0.028590426,"top":0.23623304,"width":0.042220745,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.23703113,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":17,"bounds":{"left":0.03125,"top":0.23703113,"width":0.03956117,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.25219473,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Dockerfile","depth":27,"bounds":{"left":0.028590426,"top":0.25379092,"width":0.020611702,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.254589,"width":0.0033244682,"height":0.011971269}},{"char_start":1,"char_count":9,"bounds":{"left":0.031914894,"top":0.254589,"width":0.017287234,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.254589,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.2697526,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"main.py","depth":27,"bounds":{"left":0.028590426,"top":0.27134877,"width":0.015625,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.27214685,"width":0.003656915,"height":0.011971269}},{"char_start":1,"char_count":6,"bounds":{"left":0.032247342,"top":0.27214685,"width":0.012300532,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.27214685,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.28731045,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"requirements.txt","depth":27,"bounds":{"left":0.028590426,"top":0.28890663,"width":0.032912236,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.2897047,"width":0.0016622341,"height":0.011971269}},{"char_start":1,"char_count":15,"bounds":{"left":0.03025266,"top":0.2897047,"width":0.03158245,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.2897047,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.3064645,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"data","depth":27,"bounds":{"left":0.025930852,"top":0.3064645,"width":0.008976064,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.30726257,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":3,"bounds":{"left":0.028590426,"top":0.30726257,"width":0.0063164895,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.32402235,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"logs","depth":27,"bounds":{"left":0.025930852,"top":0.32402235,"width":0.00831117,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.32482043,"width":0.0009973404,"height":0.011971269}},{"char_start":1,"char_count":3,"bounds":{"left":0.026928192,"top":0.32482043,"width":0.0076462766,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.32482043,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.3415802,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"pipes","depth":27,"bounds":{"left":0.025930852,"top":0.3415802,"width":0.010970744,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.3423783,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":4,"bounds":{"left":0.028590426,"top":0.3423783,"width":0.00831117,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.3575419,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":".gitignore","depth":27,"bounds":{"left":0.025930852,"top":0.35913807,"width":0.018949468,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.35993615,"width":0.0013297872,"height":0.011971269}},{"char_start":1,"char_count":9,"bounds":{"left":0.027260639,"top":0.35993615,"width":0.017952127,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.37509975,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"app_settings.json","depth":27,"bounds":{"left":0.025930852,"top":0.37669593,"width":0.03557181,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.377494,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":16,"bounds":{"left":0.02825798,"top":0.377494,"width":0.03324468,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.3926576,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"archive.db","depth":27,"bounds":{"left":0.025930852,"top":0.3942538,"width":0.020944148,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.39505187,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":9,"bounds":{"left":0.02825798,"top":0.39505187,"width":0.01861702,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.4102155,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"archive.db-bak","depth":27,"bounds":{"left":0.025930852,"top":0.41181165,"width":0.03025266,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.41260973,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":13,"bounds":{"left":0.02825798,"top":0.41260973,"width":0.027925532,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"U","depth":27,"bounds":{"left":0.10704787,"top":0.41260973,"width":0.0029920214,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.42777336,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite","depth":27,"bounds":{"left":0.025930852,"top":0.4293695,"width":0.017287234,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.4301676,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":8,"bounds":{"left":0.028590426,"top":0.4301676,"width":0.014960106,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.44533122,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite-shm","depth":27,"bounds":{"left":0.025930852,"top":0.44692737,"width":0.027925532,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.44772545,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":12,"bounds":{"left":0.028590426,"top":0.44772545,"width":0.025265958,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.46288908,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite-wal","depth":27,"bounds":{"left":0.025930852,"top":0.46448523,"width":0.025930852,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.46528333,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":12,"bounds":{"left":0.028590426,"top":0.46528333,"width":0.023603724,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.48044693,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe_sync_updated.sh","depth":27,"bounds":{"left":0.025930852,"top":0.4820431,"width":0.059175532,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.4828412,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":25,"bounds":{"left":0.02825798,"top":0.4828412,"width":0.056848403,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"U","depth":27,"bounds":{"left":0.10704787,"top":0.4828412,"width":0.0029920214,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.4980048,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe_sync.sh","depth":27,"bounds":{"left":0.025930852,"top":0.49960095,"width":0.039893616,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.50039905,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":17,"bounds":{"left":0.02825798,"top":0.50039905,"width":0.037898935,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.51556265,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe.db","depth":27,"bounds":{"left":0.025930852,"top":0.5171588,"width":0.028590426,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.5179569,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":12,"bounds":{"left":0.02825798,"top":0.5179569,"width":0.026595745,"height":0.011971269}}],"role_description":"text"},{"role":"AXButton","text":"Outline Section","depth":21,"bounds":{"left":0.015957447,"top":0.9473264,"width":0.09940159,"height":0.017557861},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":23,"bounds":{"left":0.01662234,"top":0.9497207,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"OUTLINE","depth":22,"bounds":{"left":0.022606382,"top":0.9473264,"width":0.01662234,"height":0.017557861},"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"OUTLINE","depth":23,"bounds":{"left":0.022606382,"top":0.95131683,"width":0.01662234,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.022606382,"top":0.95131683,"width":0.0029920214,"height":0.0103751}},{"char_start":1,"char_count":6,"bounds":{"left":0.025598405,"top":0.95131683,"width":0.013630319,"height":0.0103751}}],"role_description":"text"},{"role":"AXButton","text":"Timeline Section","depth":21,"bounds":{"left":0.015957447,"top":0.9648843,"width":0.09940159,"height":0.017557861},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":23,"bounds":{"left":0.01662234,"top":0.96727854,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"TIMELINE","depth":22,"bounds":{"left":0.022606382,"top":0.9648843,"width":0.01761968,"height":0.017557861},"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"TIMELINE","depth":23,"bounds":{"left":0.022606382,"top":0.9688747,"width":0.01761968,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.022606382,"top":0.9688747,"width":0.0026595744,"height":0.0103751}},{"char_start":1,"char_count":7,"bounds":{"left":0.025265958,"top":0.9688747,"width":0.015292553,"height":0.0103751}}],"role_description":"text"},{"role":"AXRadioButton","text":"app_settings.json, Editor Group 1","depth":28,"bounds":{"left":0.11569149,"top":0.047885075,"width":0.055851065,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"screenpipe_sync.sh, Editor Group 1","depth":28,"bounds":{"left":0.17154256,"top":0.047885075,"width":0.06050532,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":false},{"role":"AXRadioButton","text":"pipe.md, Editor Group 1","depth":28,"bounds":{"left":0.23171543,"top":0.047885075,"width":0.040226065,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":".env, Editor Group 1","depth":28,"bounds":{"left":0.27194148,"top":0.047885075,"width":0.039893616,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"#!/bin/bash\n# screenpipe_sync.sh\n# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).\n# Also copies the day's video/frame data folder to the NAS.\n#\n# Schema-drift tolerant: if Screenpipe migrations add new columns to the source DB,\n# the NAS archive gets ALTER TABLE'd to match. Inserts use explicit column lists,\n# so positional mismatches can't occur.\n#\n# Usage:\n# ./screenpipe_sync.sh # syncs yesterday (default)\n# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date\n# ./screenpipe_sync.sh today # syncs today so far\n#\n# Cron example (runs at 3am daily):\n# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1\n\nset -euo pipefail\n\n# ─── CONFIG ───────────────────────────────────────────────────────────────────\nDB_SRC=\"${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}\"\nNAS_MOUNT=\"${NAS_MOUNT:-/Volumes/screenpipe}\"\nNAS_DB=\"$NAS_MOUNT/archive.db\"\nNAS_DATA=\"$NAS_MOUNT/data\"\nLOG_FILE=\"$HOME/.screenpipe/sync.log\"\n# Tables that get schema drift handling. Order matters for FK-ish references\n# (parents before children: video_chunks → frames → elements/ocr_text/ui_events).\nSYNC_TABLES=(video_chunks frames elements ocr_text ui_events meetings)\n# ──────────────────────────────────────────────────────────────────────────────\n\n# ─── HELPERS ──────────────────────────────────────────────────────────────────\nSCRIPT_START=$(date +%s)\n\nlog() {\n local msg=\"[$(date '+%Y-%m-%d %H:%M:%S')] $*\"\n echo \"$msg\" | tee -a \"$LOG_FILE\"\n}\n\nstep() {\n local now=$(date +%s)\n local elapsed=$(( now - SCRIPT_START ))\n local min=$(( elapsed / 60 ))\n local sec=$(( elapsed % 60 ))\n printf \"\\n[+%02dm%02ds] ▶ %s\\n\" \"$min\" \"$sec\" \"$*\" | tee -a \"$LOG_FILE\"\n}\n\nrun_sqlite_heredoc() {\n local label=\"$1\"\n local sql=\"$2\"\n local start=$(date +%s)\n\n printf \" %-36s \" \"$label\"\n\n sqlite3 \"$DB_SRC\" <<< \"$sql\" &\n local pid=$!\n local spin=('⠋' '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')\n local i=0\n while kill -0 \"$pid\" 2>/dev/null; do\n printf \"\\r %-36s %s \" \"$label\" \"${spin[$i]}\"\n i=$(( (i + 1) % 10 ))\n sleep 0.2\n done\n wait \"$pid\"\n local rc=$?\n if [ $rc -ne 0 ]; then\n printf \"\\r %-36s ✗ FAILED\\n\" \"$label\" | tee -a \"$LOG_FILE\"\n exit $rc\n fi\n\n local dur=$(( $(date +%s) - start ))\n printf \"\\r %-36s ✓ %dm%02ds\\n\" \"$label\" \"$(( dur / 60 ))\" \"$(( dur % 60 ))\" | tee -a \"$LOG_FILE\"\n}\n\ncheck() {\n local label=\"$1\" got=\"$2\" expected=\"$3\"\n if [ \"$got\" -eq \"$expected\" ]; then\n printf \" %-20s %s / %s ✓\\n\" \"$label:\" \"$got\" \"$expected\"\n else\n printf \" %-20s %s / %s ✗ MISMATCH\\n\" \"$label:\" \"$got\" \"$expected\"\n fi\n}\n\n# ─── SCHEMA HELPERS ───────────────────────────────────────────────────────────\n# Echoes \"name|type\" lines for a table from a given DB.\ntable_columns_with_types() {\n local db=\"$1\" table=\"$2\"\n sqlite3 \"$db\" \"PRAGMA table_info($table);\" | awk -F'|' '{print $2 \"|\" $3}'\n}\n\n# Echoes just column names, one per line.\ntable_columns() {\n local db=\"$1\" table=\"$2\"\n sqlite3 \"$db\" \"PRAGMA table_info($table);\" | awk -F'|' '{print $2}'\n}\n\n# Returns true (0) if a table exists in the given DB.\ntable_exists() {\n local db=\"$1\" table=\"$2\"\n local count\n count=$(sqlite3 \"$db\" \"SELECT COUNT(*) FROM sqlite_master WHERE type='table' AND name='$table';\")\n [ \"$count\" -gt 0 ]\n}\n\n# Adds any columns present in source but missing in NAS for the given table.\n# Uses ALTER TABLE ADD COLUMN, which is a fast metadata-only operation in SQLite.\nensure_columns() {\n local table=\"$1\"\n local label=\"schema: $table\"\n printf \" %-36s \" \"$label\"\n\n if ! table_exists \"$DB_SRC\" \"$table\"; then\n printf \"✗ source missing — skipping\\n\"\n return 0\n fi\n\n if ! table_exists \"$NAS_DB\" \"$table\"; then\n printf \"✓ fresh (created above)\\n\"\n return 0\n fi\n\n local src_cols\n src_cols=$(table_columns_with_types \"$DB_SRC\" \"$table\")\n local nas_cols\n nas_cols=$(table_columns \"$NAS_DB\" \"$table\")\n\n local added=0\n local added_names=\"\"\n while IFS='|' read -r name type; do\n [ -z \"$name\" ] && continue\n # Use grep -F -x for fixed-string exact match (safe against regex chars).\n if ! echo \"$nas_cols\" | grep -Fxq \"$name\"; then\n # SQLite ALTER TABLE ADD COLUMN: type is optional, no NOT NULL allowed\n # without a constant default. Default-NULL is exactly what we want for archive.\n sqlite3 \"$NAS_DB\" \"ALTER TABLE $table ADD COLUMN \\\"$name\\\" $type;\"\n added=$((added + 1))\n added_names=\"$added_names $name\"\n fi\n done <<< \"$src_cols\"\n\n if [ \"$added\" -gt 0 ]; then\n printf \"✓ added %d:%s\\n\" \"$added\" \"$added_names\"\n else\n printf \"✓ in sync\\n\"\n fi\n}\n\n# Echoes a comma-separated list of source columns for a table, double-quoted\n# so reserved words and hyphens are safe. If an alias is provided, columns are\n# prefixed (e.g. `o.\"col\"`). Used for both INSERT and SELECT sides; aliased\n# form is required when SELECTing from a JOIN where column names collide\n# (e.g. ocr_text and frames both have app_name, window_name).\nbuild_col_list() {\n local table=\"$1\"\n local alias=\"${2:-}\"\n local prefix=\"\"\n [ -n \"$alias\" ] && prefix=\"${alias}.\"\n table_columns \"$DB_SRC\" \"$table\" | awk 'NF' | awk -v p=\"$prefix\" '{print p \"\\\"\" $0 \"\\\"\"}' | paste -sd, -\n}\n# ──────────────────────────────────────────────────────────────────────────────\n\n# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────\nif [ \"${1:-}\" = \"today\" ]; then\n TARGET_DATE=$(date +%Y-%m-%d)\nelif [ -n \"${1:-}\" ]; then\n TARGET_DATE=\"$1\"\n if ! [[ \"$TARGET_DATE\" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then\n echo \"ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday.\"\n exit 1\n fi\nelse\n TARGET_DATE=$(date -v-1d +%Y-%m-%d)\nfi\n\nlog \"========================================\"\nlog \"Screenpipe sync starting for: $TARGET_DATE\"\nlog \"========================================\"\n\n# ─── PREFLIGHT ────────────────────────────────────────────────────────────────\nstep \"Preflight checks\"\n\nif [ ! -f \"$DB_SRC\" ]; then\n log \"ERROR: Source DB not found at $DB_SRC\"; exit 1\nfi\nprintf \" %-20s %s (%s)\\n\" \"Source DB:\" \"OK\" \"$(du -sh \"$DB_SRC\" | cut -f1)\"\n\nif [ ! -d \"$NAS_MOUNT\" ]; then\n log \"ERROR: NAS not mounted at $NAS_MOUNT\"; exit 1\nfi\nprintf \" %-20s %s\\n\" \"NAS mount:\" \"OK $NAS_MOUNT\"\n\n# Check if DB already synced for this date\nDB_ALREADY_SYNCED=false\nif [ -f \"$NAS_DB\" ]; then\n if table_exists \"$NAS_DB\" \"frames\"; then\n EXISTING=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\" 2>/dev/null || echo \"0\")\n if [ \"$EXISTING\" -gt \"0\" ]; then\n log \"Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync\"\n DB_ALREADY_SYNCED=true\n else\n printf \" %-20s %s (%s)\\n\" \"Archive DB:\" \"exists\" \"$(du -sh \"$NAS_DB\" | cut -f1)\"\n fi\n else\n printf \" %-20s %s\\n\" \"Archive DB:\" \"exists, no frames table yet\"\n fi\nelse\n printf \" %-20s %s\\n\" \"Archive DB:\" \"will be created\"\nfi\n\n# Source data dir for this date\nDATA_SRC=\"$HOME/.screenpipe/data/data/$TARGET_DATE\"\nif [ -d \"$DATA_SRC\" ]; then\n DATA_SIZE=$(du -sh \"$DATA_SRC\" | cut -f1)\n DATA_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n printf \" %-20s %s (%s files, %s)\\n\" \"Data dir:\" \"OK\" \"$DATA_FILES\" \"$DATA_SIZE\"\nelse\n printf \" %-20s %s\\n\" \"Data dir:\" \"not found — skipping file copy\"\nfi\n\n# ─── DB SYNC ──────────────────────────────────────────────────────────────────\nif [ \"$DB_ALREADY_SYNCED\" = false ]; then\n\n # ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────\n step \"Counting source rows for $TARGET_DATE\"\n\n SRC_FRAMES=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\")\n SRC_ELEMENTS=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n SRC_UI=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';\")\n SRC_OCR=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n SRC_MEETINGS=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';\")\n\n printf \" %-20s %s\\n\" \"frames:\" \"$SRC_FRAMES\"\n printf \" %-20s %s\\n\" \"elements:\" \"$SRC_ELEMENTS\"\n printf \" %-20s %s\\n\" \"ui_events:\" \"$SRC_UI\"\n printf \" %-20s %s\\n\" \"ocr_text:\" \"$SRC_OCR\"\n printf \" %-20s %s\\n\" \"meetings:\" \"$SRC_MEETINGS\"\n\n if [ \"$SRC_FRAMES\" -eq \"0\" ]; then\n log \"No frames found for $TARGET_DATE — skipping DB sync\"\n DB_ALREADY_SYNCED=true\n fi\n\nfi\n\nif [ \"$DB_ALREADY_SYNCED\" = false ]; then\n\n # ─── INIT TABLES ──────────────────────────────────────────────────────────\n step \"Initialising tables (CREATE IF NOT EXISTS)\"\n\n run_sqlite_heredoc \"creating tables\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;\nDETACH nas;\n\"\n\n # ─── SCHEMA DRIFT FIX ─────────────────────────────────────────────────────\n # Runs AFTER CREATE IF NOT EXISTS so newly-created tables are no-ops here,\n # and pre-existing tables get any missing columns added.\n step \"Reconciling NAS schema with source\"\n for tbl in \"${SYNC_TABLES[@]}\"; do\n ensure_columns \"$tbl\"\n done\n\n run_sqlite_heredoc \"creating indexes\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_document_path ON frames(document_path) WHERE document_path IS NOT NULL;\nCREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;\nCREATE INDEX IF NOT EXISTS nas.idx_elements_onscreen_frame ON elements(frame_id) WHERE on_screen = 1 AND text IS NOT NULL;\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);\nCREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"creating FTS tables\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(\n text, role, frame_id UNINDEXED,\n content='elements', content_rowid='id', tokenize='unicode61'\n);\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(\n full_text, app_name, window_name, browser_url, id UNINDEXED,\n tokenize='unicode61'\n);\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(\n text_content,\n app_name,\n window_title,\n element_name,\n content='ui_events',\n content_rowid='id',\n tokenize='unicode61'\n);\nDETACH nas;\n\"\n\n # ─── BUILD EXPLICIT COLUMN LISTS ──────────────────────────────────────────\n # After ensure_columns, source ⊆ NAS for every synced table, so source's\n # column list is a safe subset to use on both sides of the INSERT.\n # For tables that JOIN frames (ocr_text, elements), the SELECT side needs\n # alias-qualified columns because both tables share names (app_name, etc).\n FRAMES_COLS=$(build_col_list frames)\n ELEMENTS_COLS=$(build_col_list elements)\n ELEMENTS_COLS_E=$(build_col_list elements e)\n UI_EVENTS_COLS=$(build_col_list ui_events)\n OCR_TEXT_COLS=$(build_col_list ocr_text)\n OCR_TEXT_COLS_O=$(build_col_list ocr_text o)\n VIDEO_CHUNKS_COLS=$(build_col_list video_chunks)\n MEETINGS_COLS=$(build_col_list meetings)\n\n # ─── SYNC DATA ────────────────────────────────────────────────────────────\n step \"Syncing data for $TARGET_DATE\"\n\n run_sqlite_heredoc \"video_chunks\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.video_chunks ($VIDEO_CHUNKS_COLS)\n SELECT $VIDEO_CHUNKS_COLS FROM main.video_chunks\n WHERE id IN (\n SELECT DISTINCT video_chunk_id FROM main.frames\n WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL\n );\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames ($SRC_FRAMES rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.frames ($FRAMES_COLS)\n SELECT $FRAMES_COLS FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ocr_text ($SRC_OCR rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ocr_text ($OCR_TEXT_COLS)\n SELECT $OCR_TEXT_COLS_O FROM main.ocr_text o\n JOIN main.frames f ON o.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events ($SRC_UI rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ui_events ($UI_EVENTS_COLS)\n SELECT $UI_EVENTS_COLS FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"elements ($SRC_ELEMENTS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.elements ($ELEMENTS_COLS)\n SELECT $ELEMENTS_COLS_E FROM main.elements e\n JOIN main.frames f ON e.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"meetings ($SRC_MEETINGS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.meetings ($MEETINGS_COLS)\n SELECT $MEETINGS_COLS FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n # ─── FTS UPDATE ───────────────────────────────────────────────────────────\n step \"Updating FTS indexes\"\n\n run_sqlite_heredoc \"elements_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.elements_fts(rowid, text, role)\n SELECT e.id, e.text, e.role\n FROM nas.elements e\n JOIN nas.frames f ON e.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE'\n AND e.text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)\n SELECT id, full_text, app_name, window_name, browser_url, id\n FROM nas.frames\n WHERE date(timestamp) = '$TARGET_DATE'\n AND full_text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)\n SELECT id, text_content, app_name, window_title, element_name\n FROM nas.ui_events\n WHERE date(timestamp) = '$TARGET_DATE'\n AND text_content IS NOT NULL;\nDETACH nas;\n\"\n\n # ─── VERIFY DB ────────────────────────────────────────────────────────────\n step \"Verifying DB\"\n\n V_FRAMES=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\")\n V_ELEMENTS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n V_UI=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';\")\n V_OCR=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n V_MEETINGS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';\")\n\n check \"frames\" \"$V_FRAMES\" \"$SRC_FRAMES\"\n check \"elements\" \"$V_ELEMENTS\" \"$SRC_ELEMENTS\"\n check \"ui_events\" \"$V_UI\" \"$SRC_UI\"\n check \"ocr_text\" \"$V_OCR\" \"$SRC_OCR\"\n check \"meetings\" \"$V_MEETINGS\" \"$SRC_MEETINGS\"\n\nfi\n\n# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────\n# Always runs regardless of DB sync status\nstep \"Copying data folder for $TARGET_DATE\"\n\nif [ -d \"$DATA_SRC\" ]; then\n mkdir -p \"$NAS_DATA/$TARGET_DATE\"\n RSYNC_START=$(date +%s)\n printf \" %-36s \" \"rsync $TARGET_DATE/ → NAS\"\n rsync -a --ignore-existing \\\n \"$DATA_SRC/\" \\\n \"$NAS_DATA/$TARGET_DATE/\" \\\n 2>>\"$LOG_FILE\"\n RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))\n COPIED_FILES=$(ls \"$NAS_DATA/$TARGET_DATE\" | wc -l | tr -d ' ')\n SRC_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n COPIED_SIZE=$(du -sh \"$NAS_DATA/$TARGET_DATE\" | cut -f1)\n if [ \"$COPIED_FILES\" -eq \"$SRC_FILES\" ]; then\n printf \"\\r %-36s ✓ %dm%02ds (%s files, %s)\\n\" \\\n \"rsync $TARGET_DATE/ → NAS\" \\\n \"$(( RSYNC_DUR / 60 ))\" \"$(( RSYNC_DUR % 60 ))\" \\\n \"$COPIED_FILES\" \"$COPIED_SIZE\" | tee -a \"$LOG_FILE\"\n else\n printf \"\\r %-36s ✗ %s / %s files\\n\" \\\n \"rsync $TARGET_DATE/ → NAS\" \"$COPIED_FILES\" \"$SRC_FILES\" | tee -a \"$LOG_FILE\"\n fi\nelse\n printf \" %-36s %s\\n\" \"rsync $TARGET_DATE/ → NAS\" \"skipped (no source dir)\"\nfi\n\n# ─── COPY LOGS ────────────────────────────────────────────────────────────────\n# Screenpipe writes daily logs to ~/.screenpipe/screenpipe.YYYY-MM-DD.N.log\n# (N is a rotation counter, almost always 0). Mirror them to NAS so log\n# analysis can happen on the consumer side without SSH'ing back to the Mac.\nstep \"Copying screenpipe logs for $TARGET_DATE\"\n\nNAS_LOGS=\"$NAS_MOUNT/logs\"\nmkdir -p \"$NAS_LOGS\"\n\n# Use a glob with nullglob so an empty match doesn't expand to a literal pattern.\nshopt -s nullglob\nLOG_FILES=( \"$HOME/.screenpipe/screenpipe.$TARGET_DATE.\"*.log )\nshopt -u nullglob\n\nif [ ${#LOG_FILES[@]} -gt 0 ]; then\n printf \" %-36s \" \"rsync logs → NAS\"\n # No --ignore-existing here: logs grow during the day, so we want rsync's\n # default size+mtime check to refresh files that have changed.\n rsync -a \"${LOG_FILES[@]}\" \"$NAS_LOGS/\" 2>>\"$LOG_FILE\"\n COPIED=${#LOG_FILES[@]}\n TOTAL_SIZE=$(du -ch \"${LOG_FILES[@]}\" | tail -1 | cut -f1)\n printf \"✓ %d file(s), %s\\n\" \"$COPIED\" \"$TOTAL_SIZE\" | tee -a \"$LOG_FILE\"\nelse\n printf \" %-36s %s\\n\" \"rsync logs → NAS\" \"skipped (no matching logs)\"\nfi\n\n# ─── SUMMARY ──────────────────────────────────────────────────────────────────\nTOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))\nDB_SIZE=$(du -sh \"$NAS_DB\" | cut -f1)\n\necho \"\"\nlog \"Archive DB size: $DB_SIZE\"\nlog \"Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s\"\nlog \"Sync complete for $TARGET_DATE\"\nlog \"========================================\"\n\n# Mirror this script's own logbook to NAS so sync health can be monitored\n# from the consumer side. Done last so the summary lines above are included.\nrsync -a \"$HOME/.screenpipe/sync.log\" \"$NAS_LOGS/sync.log\" 2>/dev/null || true","depth":28,"bounds":{"left":0.13763298,"top":0.42617717,"width":0.38031915,"height":0.014365523},"on_screen":true,"value":"#!/bin/bash\n# screenpipe_sync.sh\n# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).\n# Also copies the day's video/frame data folder to the NAS.\n#\n# Schema-drift tolerant: if Screenpipe migrations add new columns to the source DB,\n# the NAS archive gets ALTER TABLE'd to match. Inserts use explicit column lists,\n# so positional mismatches can't occur.\n#\n# Usage:\n# ./screenpipe_sync.sh # syncs yesterday (default)\n# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date\n# ./screenpipe_sync.sh today # syncs today so far\n#\n# Cron example (runs at 3am daily):\n# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1\n\nset -euo pipefail\n\n# ─── CONFIG ───────────────────────────────────────────────────────────────────\nDB_SRC=\"${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}\"\nNAS_MOUNT=\"${NAS_MOUNT:-/Volumes/screenpipe}\"\nNAS_DB=\"$NAS_MOUNT/archive.db\"\nNAS_DATA=\"$NAS_MOUNT/data\"\nLOG_FILE=\"$HOME/.screenpipe/sync.log\"\n# Tables that get schema drift handling. Order matters for FK-ish references\n# (parents before children: video_chunks → frames → elements/ocr_text/ui_events).\nSYNC_TABLES=(video_chunks frames elements ocr_text ui_events meetings)\n# ──────────────────────────────────────────────────────────────────────────────\n\n# ─── HELPERS ──────────────────────────────────────────────────────────────────\nSCRIPT_START=$(date +%s)\n\nlog() {\n local msg=\"[$(date '+%Y-%m-%d %H:%M:%S')] $*\"\n echo \"$msg\" | tee -a \"$LOG_FILE\"\n}\n\nstep() {\n local now=$(date +%s)\n local elapsed=$(( now - SCRIPT_START ))\n local min=$(( elapsed / 60 ))\n local sec=$(( elapsed % 60 ))\n printf \"\\n[+%02dm%02ds] ▶ %s\\n\" \"$min\" \"$sec\" \"$*\" | tee -a \"$LOG_FILE\"\n}\n\nrun_sqlite_heredoc() {\n local label=\"$1\"\n local sql=\"$2\"\n local start=$(date +%s)\n\n printf \" %-36s \" \"$label\"\n\n sqlite3 \"$DB_SRC\" <<< \"$sql\" &\n local pid=$!\n local spin=('⠋' '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')\n local i=0\n while kill -0 \"$pid\" 2>/dev/null; do\n printf \"\\r %-36s %s \" \"$label\" \"${spin[$i]}\"\n i=$(( (i + 1) % 10 ))\n sleep 0.2\n done\n wait \"$pid\"\n local rc=$?\n if [ $rc -ne 0 ]; then\n printf \"\\r %-36s ✗ FAILED\\n\" \"$label\" | tee -a \"$LOG_FILE\"\n exit $rc\n fi\n\n local dur=$(( $(date +%s) - start ))\n printf \"\\r %-36s ✓ %dm%02ds\\n\" \"$label\" \"$(( dur / 60 ))\" \"$(( dur % 60 ))\" | tee -a \"$LOG_FILE\"\n}\n\ncheck() {\n local label=\"$1\" got=\"$2\" expected=\"$3\"\n if [ \"$got\" -eq \"$expected\" ]; then\n printf \" %-20s %s / %s ✓\\n\" \"$label:\" \"$got\" \"$expected\"\n else\n printf \" %-20s %s / %s ✗ MISMATCH\\n\" \"$label:\" \"$got\" \"$expected\"\n fi\n}\n\n# ─── SCHEMA HELPERS ───────────────────────────────────────────────────────────\n# Echoes \"name|type\" lines for a table from a given DB.\ntable_columns_with_types() {\n local db=\"$1\" table=\"$2\"\n sqlite3 \"$db\" \"PRAGMA table_info($table);\" | awk -F'|' '{print $2 \"|\" $3}'\n}\n\n# Echoes just column names, one per line.\ntable_columns() {\n local db=\"$1\" table=\"$2\"\n sqlite3 \"$db\" \"PRAGMA table_info($table);\" | awk -F'|' '{print $2}'\n}\n\n# Returns true (0) if a table exists in the given DB.\ntable_exists() {\n local db=\"$1\" table=\"$2\"\n local count\n count=$(sqlite3 \"$db\" \"SELECT COUNT(*) FROM sqlite_master WHERE type='table' AND name='$table';\")\n [ \"$count\" -gt 0 ]\n}\n\n# Adds any columns present in source but missing in NAS for the given table.\n# Uses ALTER TABLE ADD COLUMN, which is a fast metadata-only operation in SQLite.\nensure_columns() {\n local table=\"$1\"\n local label=\"schema: $table\"\n printf \" %-36s \" \"$label\"\n\n if ! table_exists \"$DB_SRC\" \"$table\"; then\n printf \"✗ source missing — skipping\\n\"\n return 0\n fi\n\n if ! table_exists \"$NAS_DB\" \"$table\"; then\n printf \"✓ fresh (created above)\\n\"\n return 0\n fi\n\n local src_cols\n src_cols=$(table_columns_with_types \"$DB_SRC\" \"$table\")\n local nas_cols\n nas_cols=$(table_columns \"$NAS_DB\" \"$table\")\n\n local added=0\n local added_names=\"\"\n while IFS='|' read -r name type; do\n [ -z \"$name\" ] && continue\n # Use grep -F -x for fixed-string exact match (safe against regex chars).\n if ! echo \"$nas_cols\" | grep -Fxq \"$name\"; then\n # SQLite ALTER TABLE ADD COLUMN: type is optional, no NOT NULL allowed\n # without a constant default. Default-NULL is exactly what we want for archive.\n sqlite3 \"$NAS_DB\" \"ALTER TABLE $table ADD COLUMN \\\"$name\\\" $type;\"\n added=$((added + 1))\n added_names=\"$added_names $name\"\n fi\n done <<< \"$src_cols\"\n\n if [ \"$added\" -gt 0 ]; then\n printf \"✓ added %d:%s\\n\" \"$added\" \"$added_names\"\n else\n printf \"✓ in sync\\n\"\n fi\n}\n\n# Echoes a comma-separated list of source columns for a table, double-quoted\n# so reserved words and hyphens are safe. If an alias is provided, columns are\n# prefixed (e.g. `o.\"col\"`). Used for both INSERT and SELECT sides; aliased\n# form is required when SELECTing from a JOIN where column names collide\n# (e.g. ocr_text and frames both have app_name, window_name).\nbuild_col_list() {\n local table=\"$1\"\n local alias=\"${2:-}\"\n local prefix=\"\"\n [ -n \"$alias\" ] && prefix=\"${alias}.\"\n table_columns \"$DB_SRC\" \"$table\" | awk 'NF' | awk -v p=\"$prefix\" '{print p \"\\\"\" $0 \"\\\"\"}' | paste -sd, -\n}\n# ──────────────────────────────────────────────────────────────────────────────\n\n# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────\nif [ \"${1:-}\" = \"today\" ]; then\n TARGET_DATE=$(date +%Y-%m-%d)\nelif [ -n \"${1:-}\" ]; then\n TARGET_DATE=\"$1\"\n if ! [[ \"$TARGET_DATE\" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then\n echo \"ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday.\"\n exit 1\n fi\nelse\n TARGET_DATE=$(date -v-1d +%Y-%m-%d)\nfi\n\nlog \"========================================\"\nlog \"Screenpipe sync starting for: $TARGET_DATE\"\nlog \"========================================\"\n\n# ─── PREFLIGHT ────────────────────────────────────────────────────────────────\nstep \"Preflight checks\"\n\nif [ ! -f \"$DB_SRC\" ]; then\n log \"ERROR: Source DB not found at $DB_SRC\"; exit 1\nfi\nprintf \" %-20s %s (%s)\\n\" \"Source DB:\" \"OK\" \"$(du -sh \"$DB_SRC\" | cut -f1)\"\n\nif [ ! -d \"$NAS_MOUNT\" ]; then\n log \"ERROR: NAS not mounted at $NAS_MOUNT\"; exit 1\nfi\nprintf \" %-20s %s\\n\" \"NAS mount:\" \"OK $NAS_MOUNT\"\n\n# Check if DB already synced for this date\nDB_ALREADY_SYNCED=false\nif [ -f \"$NAS_DB\" ]; then\n if table_exists \"$NAS_DB\" \"frames\"; then\n EXISTING=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\" 2>/dev/null || echo \"0\")\n if [ \"$EXISTING\" -gt \"0\" ]; then\n log \"Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync\"\n DB_ALREADY_SYNCED=true\n else\n printf \" %-20s %s (%s)\\n\" \"Archive DB:\" \"exists\" \"$(du -sh \"$NAS_DB\" | cut -f1)\"\n fi\n else\n printf \" %-20s %s\\n\" \"Archive DB:\" \"exists, no frames table yet\"\n fi\nelse\n printf \" %-20s %s\\n\" \"Archive DB:\" \"will be created\"\nfi\n\n# Source data dir for this date\nDATA_SRC=\"$HOME/.screenpipe/data/data/$TARGET_DATE\"\nif [ -d \"$DATA_SRC\" ]; then\n DATA_SIZE=$(du -sh \"$DATA_SRC\" | cut -f1)\n DATA_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n printf \" %-20s %s (%s files, %s)\\n\" \"Data dir:\" \"OK\" \"$DATA_FILES\" \"$DATA_SIZE\"\nelse\n printf \" %-20s %s\\n\" \"Data dir:\" \"not found — skipping file copy\"\nfi\n\n# ─── DB SYNC ──────────────────────────────────────────────────────────────────\nif [ \"$DB_ALREADY_SYNCED\" = false ]; then\n\n # ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────\n step \"Counting source rows for $TARGET_DATE\"\n\n SRC_FRAMES=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\")\n SRC_ELEMENTS=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n SRC_UI=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';\")\n SRC_OCR=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n SRC_MEETINGS=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';\")\n\n printf \" %-20s %s\\n\" \"frames:\" \"$SRC_FRAMES\"\n printf \" %-20s %s\\n\" \"elements:\" \"$SRC_ELEMENTS\"\n printf \" %-20s %s\\n\" \"ui_events:\" \"$SRC_UI\"\n printf \" %-20s %s\\n\" \"ocr_text:\" \"$SRC_OCR\"\n printf \" %-20s %s\\n\" \"meetings:\" \"$SRC_MEETINGS\"\n\n if [ \"$SRC_FRAMES\" -eq \"0\" ]; then\n log \"No frames found for $TARGET_DATE — skipping DB sync\"\n DB_ALREADY_SYNCED=true\n fi\n\nfi\n\nif [ \"$DB_ALREADY_SYNCED\" = false ]; then\n\n # ─── INIT TABLES ──────────────────────────────────────────────────────────\n step \"Initialising tables (CREATE IF NOT EXISTS)\"\n\n run_sqlite_heredoc \"creating tables\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;\nDETACH nas;\n\"\n\n # ─── SCHEMA DRIFT FIX ─────────────────────────────────────────────────────\n # Runs AFTER CREATE IF NOT EXISTS so newly-created tables are no-ops here,\n # and pre-existing tables get any missing columns added.\n step \"Reconciling NAS schema with source\"\n for tbl in \"${SYNC_TABLES[@]}\"; do\n ensure_columns \"$tbl\"\n done\n\n run_sqlite_heredoc \"creating indexes\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_document_path ON frames(document_path) WHERE document_path IS NOT NULL;\nCREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;\nCREATE INDEX IF NOT EXISTS nas.idx_elements_onscreen_frame ON elements(frame_id) WHERE on_screen = 1 AND text IS NOT NULL;\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);\nCREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"creating FTS tables\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(\n text, role, frame_id UNINDEXED,\n content='elements', content_rowid='id', tokenize='unicode61'\n);\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(\n full_text, app_name, window_name, browser_url, id UNINDEXED,\n tokenize='unicode61'\n);\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(\n text_content,\n app_name,\n window_title,\n element_name,\n content='ui_events',\n content_rowid='id',\n tokenize='unicode61'\n);\nDETACH nas;\n\"\n\n # ─── BUILD EXPLICIT COLUMN LISTS ──────────────────────────────────────────\n # After ensure_columns, source ⊆ NAS for every synced table, so source's\n # column list is a safe subset to use on both sides of the INSERT.\n # For tables that JOIN frames (ocr_text, elements), the SELECT side needs\n # alias-qualified columns because both tables share names (app_name, etc).\n FRAMES_COLS=$(build_col_list frames)\n ELEMENTS_COLS=$(build_col_list elements)\n ELEMENTS_COLS_E=$(build_col_list elements e)\n UI_EVENTS_COLS=$(build_col_list ui_events)\n OCR_TEXT_COLS=$(build_col_list ocr_text)\n OCR_TEXT_COLS_O=$(build_col_list ocr_text o)\n VIDEO_CHUNKS_COLS=$(build_col_list video_chunks)\n MEETINGS_COLS=$(build_col_list meetings)\n\n # ─── SYNC DATA ────────────────────────────────────────────────────────────\n step \"Syncing data for $TARGET_DATE\"\n\n run_sqlite_heredoc \"video_chunks\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.video_chunks ($VIDEO_CHUNKS_COLS)\n SELECT $VIDEO_CHUNKS_COLS FROM main.video_chunks\n WHERE id IN (\n SELECT DISTINCT video_chunk_id FROM main.frames\n WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL\n );\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames ($SRC_FRAMES rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.frames ($FRAMES_COLS)\n SELECT $FRAMES_COLS FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ocr_text ($SRC_OCR rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ocr_text ($OCR_TEXT_COLS)\n SELECT $OCR_TEXT_COLS_O FROM main.ocr_text o\n JOIN main.frames f ON o.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events ($SRC_UI rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ui_events ($UI_EVENTS_COLS)\n SELECT $UI_EVENTS_COLS FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"elements ($SRC_ELEMENTS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.elements ($ELEMENTS_COLS)\n SELECT $ELEMENTS_COLS_E FROM main.elements e\n JOIN main.frames f ON e.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"meetings ($SRC_MEETINGS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.meetings ($MEETINGS_COLS)\n SELECT $MEETINGS_COLS FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n # ─── FTS UPDATE ───────────────────────────────────────────────────────────\n step \"Updating FTS indexes\"\n\n run_sqlite_heredoc \"elements_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.elements_fts(rowid, text, role)\n SELECT e.id, e.text, e.role\n FROM nas.elements e\n JOIN nas.frames f ON e.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE'\n AND e.text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)\n SELECT id, full_text, app_name, window_name, browser_url, id\n FROM nas.frames\n WHERE date(timestamp) = '$TARGET_DATE'\n AND full_text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)\n SELECT id, text_content, app_name, window_title, element_name\n FROM nas.ui_events\n WHERE date(timestamp) = '$TARGET_DATE'\n AND text_content IS NOT NULL;\nDETACH nas;\n\"\n\n # ─── VERIFY DB ────────────────────────────────────────────────────────────\n step \"Verifying DB\"\n\n V_FRAMES=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\")\n V_ELEMENTS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n V_UI=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';\")\n V_OCR=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n V_MEETINGS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';\")\n\n check \"frames\" \"$V_FRAMES\" \"$SRC_FRAMES\"\n check \"elements\" \"$V_ELEMENTS\" \"$SRC_ELEMENTS\"\n check \"ui_events\" \"$V_UI\" \"$SRC_UI\"\n check \"ocr_text\" \"$V_OCR\" \"$SRC_OCR\"\n check \"meetings\" \"$V_MEETINGS\" \"$SRC_MEETINGS\"\n\nfi\n\n# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────\n# Always runs regardless of DB sync status\nstep \"Copying data folder for $TARGET_DATE\"\n\nif [ -d \"$DATA_SRC\" ]; then\n mkdir -p \"$NAS_DATA/$TARGET_DATE\"\n RSYNC_START=$(date +%s)\n printf \" %-36s \" \"rsync $TARGET_DATE/ → NAS\"\n rsync -a --ignore-existing \\\n \"$DATA_SRC/\" \\\n \"$NAS_DATA/$TARGET_DATE/\" \\\n 2>>\"$LOG_FILE\"\n RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))\n COPIED_FILES=$(ls \"$NAS_DATA/$TARGET_DATE\" | wc -l | tr -d ' ')\n SRC_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n COPIED_SIZE=$(du -sh \"$NAS_DATA/$TARGET_DATE\" | cut -f1)\n if [ \"$COPIED_FILES\" -eq \"$SRC_FILES\" ]; then\n printf \"\\r %-36s ✓ %dm%02ds (%s files, %s)\\n\" \\\n \"rsync $TARGET_DATE/ → NAS\" \\\n \"$(( RSYNC_DUR / 60 ))\" \"$(( RSYNC_DUR % 60 ))\" \\\n \"$COPIED_FILES\" \"$COPIED_SIZE\" | tee -a \"$LOG_FILE\"\n else\n printf \"\\r %-36s ✗ %s / %s files\\n\" \\\n \"rsync $TARGET_DATE/ → NAS\" \"$COPIED_FILES\" \"$SRC_FILES\" | tee -a \"$LOG_FILE\"\n fi\nelse\n printf \" %-36s %s\\n\" \"rsync $TARGET_DATE/ → NAS\" \"skipped (no source dir)\"\nfi\n\n# ─── COPY LOGS ────────────────────────────────────────────────────────────────\n# Screenpipe writes daily logs to ~/.screenpipe/screenpipe.YYYY-MM-DD.N.log\n# (N is a rotation counter, almost always 0). Mirror them to NAS so log\n# analysis can happen on the consumer side without SSH'ing back to the Mac.\nstep \"Copying screenpipe logs for $TARGET_DATE\"\n\nNAS_LOGS=\"$NAS_MOUNT/logs\"\nmkdir -p \"$NAS_LOGS\"\n\n# Use a glob with nullglob so an empty match doesn't expand to a literal pattern.\nshopt -s nullglob\nLOG_FILES=( \"$HOME/.screenpipe/screenpipe.$TARGET_DATE.\"*.log )\nshopt -u nullglob\n\nif [ ${#LOG_FILES[@]} -gt 0 ]; then\n printf \" %-36s \" \"rsync logs → NAS\"\n # No --ignore-existing here: logs grow during the day, so we want rsync's\n # default size+mtime check to refresh files that have changed.\n rsync -a \"${LOG_FILES[@]}\" \"$NAS_LOGS/\" 2>>\"$LOG_FILE\"\n COPIED=${#LOG_FILES[@]}\n TOTAL_SIZE=$(du -ch \"${LOG_FILES[@]}\" | tail -1 | cut -f1)\n printf \"✓ %d file(s), %s\\n\" \"$COPIED\" \"$TOTAL_SIZE\" | tee -a \"$LOG_FILE\"\nelse\n printf \" %-36s %s\\n\" \"rsync logs → NAS\" \"skipped (no matching logs)\"\nfi\n\n# ─── SUMMARY ──────────────────────────────────────────────────────────────────\nTOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))\nDB_SIZE=$(du -sh \"$NAS_DB\" | cut -f1)\n\necho \"\"\nlog \"Archive DB size: $DB_SIZE\"\nlog \"Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s\"\nlog \"Sync complete for $TARGET_DATE\"\nlog \"========================================\"\n\n# Mirror this script's own logbook to NAS so sync health can be monitored\n# from the consumer side. Done last so the summary lines above are included.\nrsync -a \"$HOME/.screenpipe/sync.log\" \"$NAS_LOGS/sync.log\" 2>/dev/null || true","role_description":"editor","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"#!/bin/bash\n# screenpipe_sync.sh\n# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).\n# Also copies the day's video/frame data folder to the NAS.\n#\n# Schema-drift tolerant: if Screenpipe migrations add new columns to the source DB,\n# the NAS archive gets ALTER TABLE'd to match. Inserts use explicit column lists,\n# so positional mismatches can't occur.\n#\n# Usage:\n# ./screenpipe_sync.sh # syncs yesterday (default)\n# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date\n# ./screenpipe_sync.sh today # syncs today so far\n#\n# Cron example (runs at 3am daily):\n# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1\n\nset -euo pipefail\n\n# ─── CONFIG ───────────────────────────────────────────────────────────────────\nDB_SRC=\"${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}\"\nNAS_MOUNT=\"${NAS_MOUNT:-/Volumes/screenpipe}\"\nNAS_DB=\"$NAS_MOUNT/archive.db\"\nNAS_DATA=\"$NAS_MOUNT/data\"\nLOG_FILE=\"$HOME/.screenpipe/sync.log\"\n# Tables that get schema drift handling. Order matters for FK-ish references\n# (parents before children: video_chunks → frames → elements/ocr_text/ui_events).\nSYNC_TABLES=(video_chunks frames elements ocr_text ui_events meetings)\n# ──────────────────────────────────────────────────────────────────────────────\n\n# ─── HELPERS ──────────────────────────────────────────────────────────────────\nSCRIPT_START=$(date +%s)\n\nlog() {\n local msg=\"[$(date '+%Y-%m-%d %H:%M:%S')] $*\"\n echo \"$msg\" | tee -a \"$LOG_FILE\"\n}\n\nstep() {\n local now=$(date +%s)\n local elapsed=$(( now - SCRIPT_START ))\n local min=$(( elapsed / 60 ))\n local sec=$(( elapsed % 60 ))\n printf \"\\n[+%02dm%02ds] ▶ %s\\n\" \"$min\" \"$sec\" \"$*\" | tee -a \"$LOG_FILE\"\n}\n\nrun_sqlite_heredoc() {\n local label=\"$1\"\n local sql=\"$2\"\n local start=$(date +%s)\n\n printf \" %-36s \" \"$label\"\n\n sqlite3 \"$DB_SRC\" <<< \"$sql\" &\n local pid=$!\n local spin=('⠋' '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')\n local i=0\n while kill -0 \"$pid\" 2>/dev/null; do\n printf \"\\r %-36s %s \" \"$label\" \"${spin[$i]}\"\n i=$(( (i + 1) % 10 ))\n sleep 0.2\n done\n wait \"$pid\"\n local rc=$?\n if [ $rc -ne 0 ]; then\n printf \"\\r %-36s ✗ FAILED\\n\" \"$label\" | tee -a \"$LOG_FILE\"\n exit $rc\n fi\n\n local dur=$(( $(date +%s) - start ))\n printf \"\\r %-36s ✓ %dm%02ds\\n\" \"$label\" \"$(( dur / 60 ))\" \"$(( dur % 60 ))\" | tee -a \"$LOG_FILE\"\n}\n\ncheck() {\n local label=\"$1\" got=\"$2\" expected=\"$3\"\n if [ \"$got\" -eq \"$expected\" ]; then\n printf \" %-20s %s / %s ✓\\n\" \"$label:\" \"$got\" \"$expected\"\n else\n printf \" %-20s %s / %s ✗ MISMATCH\\n\" \"$label:\" \"$got\" \"$expected\"\n fi\n}\n\n# ─── SCHEMA HELPERS ───────────────────────────────────────────────────────────\n# Echoes \"name|type\" lines for a table from a given DB.\ntable_columns_with_types() {\n local db=\"$1\" table=\"$2\"\n sqlite3 \"$db\" \"PRAGMA table_info($table);\" | awk -F'|' '{print $2 \"|\" $3}'\n}\n\n# Echoes just column names, one per line.\ntable_columns() {\n local db=\"$1\" table=\"$2\"\n sqlite3 \"$db\" \"PRAGMA table_info($table);\" | awk -F'|' '{print $2}'\n}\n\n# Returns true (0) if a table exists in the given DB.\ntable_exists() {\n local db=\"$1\" table=\"$2\"\n local count\n count=$(sqlite3 \"$db\" \"SELECT COUNT(*) FROM sqlite_master WHERE type='table' AND name='$table';\")\n [ \"$count\" -gt 0 ]\n}\n\n# Adds any columns present in source but missing in NAS for the given table.\n# Uses ALTER TABLE ADD COLUMN, which is a fast metadata-only operation in SQLite.\nensure_columns() {\n local table=\"$1\"\n local label=\"schema: $table\"\n printf \" %-36s \" \"$label\"\n\n if ! table_exists \"$DB_SRC\" \"$table\"; then\n printf \"✗ source missing — skipping\\n\"\n return 0\n fi\n\n if ! table_exists \"$NAS_DB\" \"$table\"; then\n printf \"✓ fresh (created above)\\n\"\n return 0\n fi\n\n local src_cols\n src_cols=$(table_columns_with_types \"$DB_SRC\" \"$table\")\n local nas_cols\n nas_cols=$(table_columns \"$NAS_DB\" \"$table\")\n\n local added=0\n local added_names=\"\"\n while IFS='|' read -r name type; do\n [ -z \"$name\" ] && continue\n # Use grep -F -x for fixed-string exact match (safe against regex chars).\n if ! echo \"$nas_cols\" | grep -Fxq \"$name\"; then\n # SQLite ALTER TABLE ADD COLUMN: type is optional, no NOT NULL allowed\n # without a constant default. Default-NULL is exactly what we want for archive.\n sqlite3 \"$NAS_DB\" \"ALTER TABLE $table ADD COLUMN \\\"$name\\\" $type;\"\n added=$((added + 1))\n added_names=\"$added_names $name\"\n fi\n done <<< \"$src_cols\"\n\n if [ \"$added\" -gt 0 ]; then\n printf \"✓ added %d:%s\\n\" \"$added\" \"$added_names\"\n else\n printf \"✓ in sync\\n\"\n fi\n}\n\n# Echoes a comma-separated list of source columns for a table, double-quoted\n# so reserved words and hyphens are safe. If an alias is provided, columns are\n# prefixed (e.g. `o.\"col\"`). Used for both INSERT and SELECT sides; aliased\n# form is required when SELECTing from a JOIN where column names collide\n# (e.g. ocr_text and frames both have app_name, window_name).\nbuild_col_list() {\n local table=\"$1\"\n local alias=\"${2:-}\"\n local prefix=\"\"\n [ -n \"$alias\" ] && prefix=\"${alias}.\"\n table_columns \"$DB_SRC\" \"$table\" | awk 'NF' | awk -v p=\"$prefix\" '{print p \"\\\"\" $0 \"\\\"\"}' | paste -sd, -\n}\n# ──────────────────────────────────────────────────────────────────────────────\n\n# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────\nif [ \"${1:-}\" = \"today\" ]; then\n TARGET_DATE=$(date +%Y-%m-%d)\nelif [ -n \"${1:-}\" ]; then\n TARGET_DATE=\"$1\"\n if ! [[ \"$TARGET_DATE\" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then\n echo \"ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday.\"\n exit 1\n fi\nelse\n TARGET_DATE=$(date -v-1d +%Y-%m-%d)\nfi\n\nlog \"========================================\"\nlog \"Screenpipe sync starting for: $TARGET_DATE\"\nlog \"========================================\"\n\n# ─── PREFLIGHT ────────────────────────────────────────────────────────────────\nstep \"Preflight checks\"\n\nif [ ! -f \"$DB_SRC\" ]; then\n log \"ERROR: Source DB not found at $DB_SRC\"; exit 1\nfi\nprintf \" %-20s %s (%s)\\n\" \"Source DB:\" \"OK\" \"$(du -sh \"$DB_SRC\" | cut -f1)\"\n\nif [ ! -d \"$NAS_MOUNT\" ]; then\n log \"ERROR: NAS not mounted at $NAS_MOUNT\"; exit 1\nfi\nprintf \" %-20s %s\\n\" \"NAS mount:\" \"OK $NAS_MOUNT\"\n\n# Check if DB already synced for this date\nDB_ALREADY_SYNCED=false\nif [ -f \"$NAS_DB\" ]; then\n if table_exists \"$NAS_DB\" \"frames\"; then\n EXISTING=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\" 2>/dev/null || echo \"0\")\n if [ \"$EXISTING\" -gt \"0\" ]; then\n log \"Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync\"\n DB_ALREADY_SYNCED=true\n else\n printf \" %-20s %s (%s)\\n\" \"Archive DB:\" \"exists\" \"$(du -sh \"$NAS_DB\" | cut -f1)\"\n fi\n else\n printf \" %-20s %s\\n\" \"Archive DB:\" \"exists, no frames table yet\"\n fi\nelse\n printf \" %-20s %s\\n\" \"Archive DB:\" \"will be created\"\nfi\n\n# Source data dir for this date\nDATA_SRC=\"$HOME/.screenpipe/data/data/$TARGET_DATE\"\nif [ -d \"$DATA_SRC\" ]; then\n DATA_SIZE=$(du -sh \"$DATA_SRC\" | cut -f1)\n DATA_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n printf \" %-20s %s (%s files, %s)\\n\" \"Data dir:\" \"OK\" \"$DATA_FILES\" \"$DATA_SIZE\"\nelse\n printf \" %-20s %s\\n\" \"Data dir:\" \"not found — skipping file copy\"\nfi\n\n# ─── DB SYNC ──────────────────────────────────────────────────────────────────\nif [ \"$DB_ALREADY_SYNCED\" = false ]; then\n\n # ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────\n step \"Counting source rows for $TARGET_DATE\"\n\n SRC_FRAMES=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\")\n SRC_ELEMENTS=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n SRC_UI=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';\")\n SRC_OCR=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n SRC_MEETINGS=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';\")\n\n printf \" %-20s %s\\n\" \"frames:\" \"$SRC_FRAMES\"\n printf \" %-20s %s\\n\" \"elements:\" \"$SRC_ELEMENTS\"\n printf \" %-20s %s\\n\" \"ui_events:\" \"$SRC_UI\"\n printf \" %-20s %s\\n\" \"ocr_text:\" \"$SRC_OCR\"\n printf \" %-20s %s\\n\" \"meetings:\" \"$SRC_MEETINGS\"\n\n if [ \"$SRC_FRAMES\" -eq \"0\" ]; then\n log \"No frames found for $TARGET_DATE — skipping DB sync\"\n DB_ALREADY_SYNCED=true\n fi\n\nfi\n\nif [ \"$DB_ALREADY_SYNCED\" = false ]; then\n\n # ─── INIT TABLES ──────────────────────────────────────────────────────────\n step \"Initialising tables (CREATE IF NOT EXISTS)\"\n\n run_sqlite_heredoc \"creating tables\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;\nDETACH nas;\n\"\n\n # ─── SCHEMA DRIFT FIX ─────────────────────────────────────────────────────\n # Runs AFTER CREATE IF NOT EXISTS so newly-created tables are no-ops here,\n # and pre-existing tables get any missing columns added.\n step \"Reconciling NAS schema with source\"\n for tbl in \"${SYNC_TABLES[@]}\"; do\n ensure_columns \"$tbl\"\n done\n\n run_sqlite_heredoc \"creating indexes\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_document_path ON frames(document_path) WHERE document_path IS NOT NULL;\nCREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;\nCREATE INDEX IF NOT EXISTS nas.idx_elements_onscreen_frame ON elements(frame_id) WHERE on_screen = 1 AND text IS NOT NULL;\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);\nCREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"creating FTS tables\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(\n text, role, frame_id UNINDEXED,\n content='elements', content_rowid='id', tokenize='unicode61'\n);\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(\n full_text, app_name, window_name, browser_url, id UNINDEXED,\n tokenize='unicode61'\n);\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(\n text_content,\n app_name,\n window_title,\n element_name,\n content='ui_events',\n content_rowid='id',\n tokenize='unicode61'\n);\nDETACH nas;\n\"\n\n # ─── BUILD EXPLICIT COLUMN LISTS ──────────────────────────────────────────\n # After ensure_columns, source ⊆ NAS for every synced table, so source's\n # column list is a safe subset to use on both sides of the INSERT.\n # For tables that JOIN frames (ocr_text, elements), the SELECT side needs\n # alias-qualified columns because both tables share names (app_name, etc).\n FRAMES_COLS=$(build_col_list frames)\n ELEMENTS_COLS=$(build_col_list elements)\n ELEMENTS_COLS_E=$(build_col_list elements e)\n UI_EVENTS_COLS=$(build_col_list ui_events)\n OCR_TEXT_COLS=$(build_col_list ocr_text)\n OCR_TEXT_COLS_O=$(build_col_list ocr_text o)\n VIDEO_CHUNKS_COLS=$(build_col_list video_chunks)\n MEETINGS_COLS=$(build_col_list meetings)\n\n # ─── SYNC DATA ────────────────────────────────────────────────────────────\n step \"Syncing data for $TARGET_DATE\"\n\n run_sqlite_heredoc \"video_chunks\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.video_chunks ($VIDEO_CHUNKS_COLS)\n SELECT $VIDEO_CHUNKS_COLS FROM main.video_chunks\n WHERE id IN (\n SELECT DISTINCT video_chunk_id FROM main.frames\n WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL\n );\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames ($SRC_FRAMES rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.frames ($FRAMES_COLS)\n SELECT $FRAMES_COLS FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ocr_text ($SRC_OCR rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ocr_text ($OCR_TEXT_COLS)\n SELECT $OCR_TEXT_COLS_O FROM main.ocr_text o\n JOIN main.frames f ON o.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events ($SRC_UI rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ui_events ($UI_EVENTS_COLS)\n SELECT $UI_EVENTS_COLS FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"elements ($SRC_ELEMENTS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.elements ($ELEMENTS_COLS)\n SELECT $ELEMENTS_COLS_E FROM main.elements e\n JOIN main.frames f ON e.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"meetings ($SRC_MEETINGS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.meetings ($MEETINGS_COLS)\n SELECT $MEETINGS_COLS FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n # ─── FTS UPDATE ───────────────────────────────────────────────────────────\n step \"Updating FTS indexes\"\n\n run_sqlite_heredoc \"elements_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.elements_fts(rowid, text, role)\n SELECT e.id, e.text, e.role\n FROM nas.elements e\n JOIN nas.frames f ON e.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE'\n AND e.text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)\n SELECT id, full_text, app_name, window_name, browser_url, id\n FROM nas.frames\n WHERE date(timestamp) = '$TARGET_DATE'\n AND full_text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)\n SELECT id, text_content, app_name, window_title, element_name\n FROM nas.ui_events\n WHERE date(timestamp) = '$TARGET_DATE'\n AND text_content IS NOT NULL;\nDETACH nas;\n\"\n\n # ─── VERIFY DB ────────────────────────────────────────────────────────────\n step \"Verifying DB\"\n\n V_FRAMES=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\")\n V_ELEMENTS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n V_UI=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';\")\n V_OCR=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n V_MEETINGS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';\")\n\n check \"frames\" \"$V_FRAMES\" \"$SRC_FRAMES\"\n check \"elements\" \"$V_ELEMENTS\" \"$SRC_ELEMENTS\"\n check \"ui_events\" \"$V_UI\" \"$SRC_UI\"\n check \"ocr_text\" \"$V_OCR\" \"$SRC_OCR\"\n check \"meetings\" \"$V_MEETINGS\" \"$SRC_MEETINGS\"\n\nfi\n\n# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────\n# Always runs regardless of DB sync status\nstep \"Copying data folder for $TARGET_DATE\"\n\nif [ -d \"$DATA_SRC\" ]; then\n mkdir -p \"$NAS_DATA/$TARGET_DATE\"\n RSYNC_START=$(date +%s)\n printf \" %-36s \" \"rsync $TARGET_DATE/ → NAS\"\n rsync -a --ignore-existing \\\n \"$DATA_SRC/\" \\\n \"$NAS_DATA/$TARGET_DATE/\" \\\n 2>>\"$LOG_FILE\"\n RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))\n COPIED_FILES=$(ls \"$NAS_DATA/$TARGET_DATE\" | wc -l | tr -d ' ')\n SRC_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n COPIED_SIZE=$(du -sh \"$NAS_DATA/$TARGET_DATE\" | cut -f1)\n if [ \"$COPIED_FILES\" -eq \"$SRC_FILES\" ]; then\n printf \"\\r %-36s ✓ %dm%02ds (%s files, %s)\\n\" \\\n \"rsync $TARGET_DATE/ → NAS\" \\\n \"$(( RSYNC_DUR / 60 ))\" \"$(( RSYNC_DUR % 60 ))\" \\\n \"$COPIED_FILES\" \"$COPIED_SIZE\" | tee -a \"$LOG_FILE\"\n else\n printf \"\\r %-36s ✗ %s / %s files\\n\" \\\n \"rsync $TARGET_DATE/ → NAS\" \"$COPIED_FILES\" \"$SRC_FILES\" | tee -a \"$LOG_FILE\"\n fi\nelse\n printf \" %-36s %s\\n\" \"rsync $TARGET_DATE/ → NAS\" \"skipped (no source dir)\"\nfi\n\n# ─── COPY LOGS ────────────────────────────────────────────────────────────────\n# Screenpipe writes daily logs to ~/.screenpipe/screenpipe.YYYY-MM-DD.N.log\n# (N is a rotation counter, almost always 0). Mirror them to NAS so log\n# analysis can happen on the consumer side without SSH'ing back to the Mac.\nstep \"Copying screenpipe logs for $TARGET_DATE\"\n\nNAS_LOGS=\"$NAS_MOUNT/logs\"\nmkdir -p \"$NAS_LOGS\"\n\n# Use a glob with nullglob so an empty match doesn't expand to a literal pattern.\nshopt -s nullglob\nLOG_FILES=( \"$HOME/.screenpipe/screenpipe.$TARGET_DATE.\"*.log )\nshopt -u nullglob\n\nif [ ${#LOG_FILES[@]} -gt 0 ]; then\n printf \" %-36s \" \"rsync logs → NAS\"\n # No --ignore-existing here: logs grow during the day, so we want rsync's\n # default size+mtime check to refresh files that have changed.\n rsync -a \"${LOG_FILES[@]}\" \"$NAS_LOGS/\" 2>>\"$LOG_FILE\"\n COPIED=${#LOG_FILES[@]}\n TOTAL_SIZE=$(du -ch \"${LOG_FILES[@]}\" | tail -1 | cut -f1)\n printf \"✓ %d file(s), %s\\n\" \"$COPIED\" \"$TOTAL_SIZE\" | tee -a \"$LOG_FILE\"\nelse\n printf \" %-36s %s\\n\" \"rsync logs → NAS\" \"skipped (no matching logs)\"\nfi\n\n# ─── SUMMARY ──────────────────────────────────────────────────────────────────\nTOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))\nDB_SIZE=$(du -sh \"$NAS_DB\" | cut -f1)\n\necho \"\"\nlog \"Archive DB size: $DB_SIZE\"\nlog \"Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s\"\nlog \"Sync complete for $TARGET_DATE\"\nlog \"========================================\"\n\n# Mirror this script's own logbook to NAS so sync health can be monitored\n# from the consumer side. Done last so the summary lines above are included.\nrsync -a \"$HOME/.screenpipe/sync.log\" \"$NAS_LOGS/sync.log\" 2>/dev/null || true","depth":29,"bounds":{"left":0.13763298,"top":0.42617717,"width":0.35804522,"height":0.014365523},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Implement and run pipe l…, Editor Group 2","depth":28,"bounds":{"left":0.5578458,"top":0.047885075,"width":0.073803194,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":false},{"role":"AXRadioButton","text":"Problems (⇧⌘M)","depth":22,"bounds":{"left":0.118351065,"top":0.7278532,"width":0.027925532,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"PROBLEMS","depth":24,"bounds":{"left":0.122340426,"top":0.7366321,"width":0.019946808,"height":0.0103751},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Output (⇧⌘U)","depth":22,"bounds":{"left":0.14594415,"top":0.7278532,"width":0.023603724,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUTPUT","depth":24,"bounds":{"left":0.14993352,"top":0.7366321,"width":0.015625,"height":0.0103751},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Debug Console (⇧⌘Y)","depth":22,"bounds":{"left":0.16921543,"top":0.7278532,"width":0.039893616,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"DEBUG CONSOLE","depth":24,"bounds":{"left":0.1732048,"top":0.7366321,"width":0.031914894,"height":0.0103751},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Terminal (⌃`)","depth":22,"bounds":{"left":0.2087766,"top":0.7278532,"width":0.026595745,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":true},{"role":"AXStaticText","text":"TERMINAL","depth":24,"bounds":{"left":0.21276596,"top":0.7366321,"width":0.01861702,"height":0.0103751},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Ports - 1 forwarded port","depth":22,"bounds":{"left":0.23537233,"top":0.7278532,"width":0.026263298,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"PORTS","depth":24,"bounds":{"left":0.2393617,"top":0.7366321,"width":0.012300532,"height":0.0103751},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":25,"bounds":{"left":0.25465426,"top":0.73743016,"width":0.0019946808,"height":0.008778931},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"remote SSH: nas","depth":16,"bounds":{"left":0.0006648936,"top":0.98244214,"width":0.028590426,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.0033244682,"top":0.9848364,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"SSH: nas","depth":17,"bounds":{"left":0.008643617,"top":0.9856345,"width":0.017952127,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"screenpipe (Git) - master*, Checkout Branch/Tag...","depth":16,"bounds":{"left":0.030917553,"top":0.98244214,"width":0.023271276,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.031914894,"top":0.9848364,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"master*","depth":17,"bounds":{"left":0.03723404,"top":0.9856345,"width":0.015957447,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"screenpipe (Git) - Synchronize Changes","depth":16,"bounds":{"left":0.05418883,"top":0.98244214,"width":0.00731383,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"No Problems","depth":16,"bounds":{"left":0.06416223,"top":0.98244214,"width":0.022606382,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.06582447,"top":0.9848364,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"0","depth":17,"bounds":{"left":0.07114362,"top":0.9856345,"width":0.004986702,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.07579787,"top":0.9848364,"width":0.0056515955,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"0","depth":17,"bounds":{"left":0.08111702,"top":0.9856345,"width":0.0039893617,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Forwarded Ports: 8766","depth":16,"bounds":{"left":0.08843085,"top":0.98244214,"width":0.012632979,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.09009308,"top":0.9848364,"width":0.0056515955,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":17,"bounds":{"left":0.09541223,"top":0.9856345,"width":0.0039893617,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Notifications","depth":16,"bounds":{"left":0.9886968,"top":0.98244214,"width":0.010638298,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sign In","depth":16,"bounds":{"left":0.9650931,"top":0.98244214,"width":0.022606382,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.96675533,"top":0.9848364,"width":0.0056515955,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Sign In","depth":17,"bounds":{"left":0.97207445,"top":0.9856345,"width":0.013962766,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Shell Script","depth":16,"bounds":{"left":0.93916225,"top":0.98244214,"width":0.023603724,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Editor Language Status: Inline Suggestions, next: $(copilot) No inline suggestion available, Inline suggestions","depth":16,"bounds":{"left":0.9318484,"top":0.98244214,"width":0.00731383,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"LF","depth":16,"bounds":{"left":0.9212101,"top":0.98244214,"width":0.007978723,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"UTF-8","depth":16,"bounds":{"left":0.90359044,"top":0.98244214,"width":0.015625,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Spaces: 2","depth":16,"bounds":{"left":0.8796542,"top":0.98244214,"width":0.022273935,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Ln 480, Col 3","depth":16,"bounds":{"left":0.8490692,"top":0.98244214,"width":0.028922873,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"git-commit Not Committed Yet","depth":16,"bounds":{"left":0.8015292,"top":0.98244214,"width":0.045545213,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
4716733703179197424
|
8363351146505899285
|
click
|
accessibility
|
NULL
|
Explorer (⇧⌘E) - 1 unsaved file
1
Search (⇧⌘F)
Explorer (⇧⌘E) - 1 unsaved file
1
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py
M
db.py
docker-compose.yml
Dockerfile
M
main.py
M
requirements.txt
M
data
logs
pipes
.gitignore
app_settings.json
archive.db
archive.db-bak
U
db.sqlite
db.sqlite-shm
db.sqlite-wal
screenpipe_sync_updated.sh
U
screenpipe_sync.sh
screenpipe.db
Outline Section
OUTLINE
OUTLINE
Timeline Section
TIMELINE
TIMELINE
app_settings.json, Editor Group 1
screenpipe_sync.sh, Editor Group 1
pipe.md, Editor Group 1
.env, Editor Group 1
#!/bin/bash
# screenpipe_sync.sh
# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).
# Also copies the day's video/frame data folder to the NAS.
#
# Schema-drift tolerant: if Screenpipe migrations add new columns to the source DB,
# the NAS archive gets ALTER TABLE'd to match. Inserts use explicit column lists,
# so positional mismatches can't occur.
#
# Usage:
# ./screenpipe_sync.sh # syncs yesterday (default)
# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date
# ./screenpipe_sync.sh today # syncs today so far
#
# Cron example (runs at 3am daily):
# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1
set -euo pipefail
# ─── CONFIG ───────────────────────────────────────────────────────────────────
DB_SRC="${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}"
NAS_MOUNT="${NAS_MOUNT:-/Volumes/screenpipe}"
NAS_DB="$NAS_MOUNT/archive.db"
NAS_DATA="$NAS_MOUNT/data"
LOG_FILE="$HOME/.screenpipe/sync.log"
# Tables that get schema drift handling. Order matters for FK-ish references
# (parents before children: video_chunks → frames → elements/ocr_text/ui_events).
SYNC_TABLES=(video_chunks frames elements ocr_text ui_events meetings)
# ──────────────────────────────────────────────────────────────────────────────
# ─── HELPERS ──────────────────────────────────────────────────────────────────
SCRIPT_START=$(date +%s)
log() {
local msg="[$(date '+%Y-%m-%d %H:%M:%S')] $*"
echo "$msg" | tee -a "$LOG_FILE"
}
step() {
local now=$(date +%s)
local elapsed=$(( now - SCRIPT_START ))
local min=$(( elapsed / 60 ))
local sec=$(( elapsed % 60 ))
printf "\n[+%02dm%02ds] ▶ %s\n" "$min" "$sec" "$*" | tee -a "$LOG_FILE"
}
run_sqlite_heredoc() {
local label="$1"
local sql="$2"
local start=$(date +%s)
printf " %-36s " "$label"
sqlite3 "$DB_SRC" <<< "$sql" &
local pid=$!
local spin=[PASSWORD] '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')
local i=0
while kill -0 "$pid" 2>/dev/null; do
printf "\r %-36s %s " "$label" "${spin[$i]}"
i=$(( (i + 1) % 10 ))
sleep 0.2
done
wait "$pid"
local rc=$?
if [ $rc -ne 0 ]; then
printf "\r %-36s ✗ FAILED\n" "$label" | tee -a "$LOG_FILE"
exit $rc
fi
local dur=$(( $(date +%s) - start ))
printf "\r %-36s ✓ %dm%02ds\n" "$label" "$(( dur / 60 ))" "$(( dur % 60 ))" | tee -a "$LOG_FILE"
}
check() {
local label="$1" got="$2" expected="$3"
if [ "$got" -eq "$expected" ]; then
printf " %-20s %s / %s ✓\n" "$label:" "$got" "$expected"
else
printf " %-20s %s / %s ✗ MISMATCH\n" "$label:" "$got" "$expected"
fi
}
# ─── SCHEMA HELPERS ───────────────────────────────────────────────────────────
# Echoes "name|type" lines for a table from a given DB.
table_columns_with_types() {
local db="$1" table="$2"
sqlite3 "$db" "PRAGMA table_info($table);" | awk -F'|' '{print $2 "|" $3}'
}
# Echoes just column names, one per line.
table_columns() {
local db="$1" table="$2"
sqlite3 "$db" "PRAGMA table_info($table);" | awk -F'|' '{print $2}'
}
# Returns true (0) if a table exists in the given DB.
table_exists() {
local db="$1" table="$2"
local count
count=$(sqlite3 "$db" "SELECT COUNT(*) FROM sqlite_master WHERE type='table' AND name='$table';")
[ "$count" -gt 0 ]
}
# Adds any columns present in source but missing in NAS for the given table.
# Uses ALTER TABLE ADD COLUMN, which is a fast metadata-only operation in SQLite.
ensure_columns() {
local table="$1"
local label="schema: $table"
printf " %-36s " "$label"
if ! table_exists "$DB_SRC" "$table"; then
printf "✗ source missing — skipping\n"
return 0
fi
if ! table_exists "$NAS_DB" "$table"; then
printf "✓ fresh (created above)\n"
return 0
fi
local src_cols
src_cols=$(table_columns_with_types "$DB_SRC" "$table")
local nas_cols
nas_cols=$(table_columns "$NAS_DB" "$table")
local added=0
local added_names=""
while IFS='|' read -r name type; do
[ -z "$name" ] && continue
# Use grep -F -x for fixed-string exact match (safe against regex chars).
if ! echo "$nas_cols" | grep -Fxq "$name"; then
# SQLite ALTER TABLE ADD COLUMN: type is optional, no NOT NULL allowed
# without a constant default. Default-NULL is exactly what we want for archive.
sqlite3 "$NAS_DB" "ALTER TABLE $table ADD COLUMN \"$name\" $type;"
added=$((added + 1))
added_names="$added_names $name"
fi
done <<< "$src_cols"
if [ "$added" -gt 0 ]; then
printf "✓ added %d:%s\n" "$added" "$added_names"
else
printf "✓ in sync\n"
fi
}
# Echoes a comma-separated list of source columns for a table, double-quoted
# so reserved words and hyphens are safe. If an alias is provided, columns are
# prefixed (e.g. `o."col"`). Used for both INSERT and SELECT sides; aliased
# form is required when SELECTing from a JOIN where column names collide
# (e.g. ocr_text and frames both have app_name, window_name).
build_col_list() {
local table="$1"
local alias="${2:-}"
local prefix=""
[ -n "$alias" ] && prefix="${alias}."
table_columns "$DB_SRC" "$table" | awk 'NF' | awk -v p="$prefix" '{print p "\"" $0 "\""}' | paste -sd, -
}
# ──────────────────────────────────────────────────────────────────────────────
# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────
if [ "${1:-}" = "today" ]; then
TARGET_DATE=$(date +%Y-%m-%d)
elif [ -n "${1:-}" ]; then
TARGET_DATE="$1"
if ! [[ "$TARGET_DATE" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then
echo "ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday."
exit 1
fi
else
TARGET_DATE=$(date -v-1d +%Y-%m-%d)
fi
log "========================================"
log "Screenpipe sync starting for: $TARGET_DATE"
log "========================================"
# ─── PREFLIGHT ────────────────────────────────────────────────────────────────
step "Preflight checks"
if [ ! -f "$DB_SRC" ]; then
log "ERROR: Source DB not found at $DB_SRC"; exit 1
fi
printf " %-20s %s (%s)\n" "Source DB:" "OK" "$(du -sh "$DB_SRC" | cut -f1)"
if [ ! -d "$NAS_MOUNT" ]; then
log "ERROR: NAS not mounted at $NAS_MOUNT"; exit 1
fi
printf " %-20s %s\n" "NAS mount:" "OK $NAS_MOUNT"
# Check if DB already synced for this date
DB_ALREADY_SYNCED=false
if [ -f "$NAS_DB" ]; then
if table_exists "$NAS_DB" "frames"; then
EXISTING=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';" 2>/dev/null || echo "0")
if [ "$EXISTING" -gt "0" ]; then
log "Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync"
DB_ALREADY_SYNCED=true
else
printf " %-20s %s (%s)\n" "Archive DB:" "exists" "$(du -sh "$NAS_DB" | cut -f1)"
fi
else
printf " %-20s %s\n" "Archive DB:" "exists, no frames table yet"
fi
else
printf " %-20s %s\n" "Archive DB:" "will be created"
fi
# Source data dir for this date
DATA_SRC="$HOME/.screenpipe/data/data/$TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
DATA_SIZE=$(du -sh "$DATA_SRC" | cut -f1)
DATA_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
printf " %-20s %s (%s files, %s)\n" "Data dir:" "OK" "$DATA_FILES" "$DATA_SIZE"
else
printf " %-20s %s\n" "Data dir:" "not found — skipping file copy"
fi
# ─── DB SYNC ──────────────────────────────────────────────────────────────────
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────
step "Counting source rows for $TARGET_DATE"
SRC_FRAMES=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
SRC_ELEMENTS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_UI=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
SRC_OCR=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_MEETINGS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';")
printf " %-20s %s\n" "frames:" "$SRC_FRAMES"
printf " %-20s %s\n" "elements:" "$SRC_ELEMENTS"
printf " %-20s %s\n" "ui_events:" "$SRC_UI"
printf " %-20s %s\n" "ocr_text:" "$SRC_OCR"
printf " %-20s %s\n" "meetings:" "$SRC_MEETINGS"
if [ "$SRC_FRAMES" -eq "0" ]; then
log "No frames found for $TARGET_DATE — skipping DB sync"
DB_ALREADY_SYNCED=true
fi
fi
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── INIT TABLES ──────────────────────────────────────────────────────────
step "Initialising tables (CREATE IF NOT EXISTS)"
run_sqlite_heredoc "creating tables" "
ATTACH '$NAS_DB' AS nas;
CREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;
CREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;
CREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;
CREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;
DETACH nas;
"
# ─── SCHEMA DRIFT FIX ─────────────────────────────────────────────────────
# Runs AFTER CREATE IF NOT EXISTS so newly-created tables are no-ops here,
# and pre-existing tables get any missing columns added.
step "Reconciling NAS schema with source"
for tbl in "${SYNC_TABLES[@]}"; do
ensure_columns "$tbl"
done
run_sqlite_heredoc "creating indexes" "
ATTACH '$NAS_DB' AS nas;
CREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);
CREATE INDEX IF NOT EXISTS nas.idx_frames_document_path ON frames(document_path) WHERE document_path IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_elements_onscreen_frame ON elements(frame_id) WHERE on_screen = 1 AND text IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);
CREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);
DETACH nas;
"
run_sqlite_heredoc "creating FTS tables" "
ATTACH '$NAS_DB' AS nas;
CREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(
text, role, frame_id UNINDEXED,
content='elements', content_rowid='id', tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(
full_text, app_name, window_name, browser_url, id UNINDEXED,
tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(
text_content,
app_name,
window_title,
element_name,
content='ui_events',
content_rowid='id',
tokenize='unicode61'
);
DETACH nas;
"
# ─── BUILD EXPLICIT COLUMN LISTS ──────────────────────────────────────────
# After ensure_columns, source ⊆ NAS for every synced table, so source's
# column list is a safe subset to use on both sides of the INSERT.
# For tables that JOIN frames (ocr_text, elements), the SELECT side needs
# alias-qualified columns because both tables share names (app_name, etc).
FRAMES_COLS=$(build_col_list frames)
ELEMENTS_COLS=$(build_col_list elements)
ELEMENTS_COLS_E=$(build_col_list elements e)
UI_EVENTS_COLS=$(build_col_list ui_events)
OCR_TEXT_COLS=$(build_col_list ocr_text)
OCR_TEXT_COLS_O=$(build_col_list ocr_text o)
VIDEO_CHUNKS_COLS=$(build_col_list video_chunks)
MEETINGS_COLS=$(build_col_list meetings)
# ─── SYNC DATA ────────────────────────────────────────────────────────────
step "Syncing data for $TARGET_DATE"
run_sqlite_heredoc "video_chunks" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.video_chunks ($VIDEO_CHUNKS_COLS)
SELECT $VIDEO_CHUNKS_COLS FROM main.video_chunks
WHERE id IN (
SELECT DISTINCT video_chunk_id FROM main.frames
WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL
);
DETACH nas;
"
run_sqlite_heredoc "frames ($SRC_FRAMES rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.frames ($FRAMES_COLS)
SELECT $FRAMES_COLS FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ocr_text ($SRC_OCR rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ocr_text ($OCR_TEXT_COLS)
SELECT $OCR_TEXT_COLS_O FROM main.ocr_text o
JOIN main.frames f ON o.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ui_events ($SRC_UI rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ui_events ($UI_EVENTS_COLS)
SELECT $UI_EVENTS_COLS FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "elements ($SRC_ELEMENTS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.elements ($ELEMENTS_COLS)
SELECT $ELEMENTS_COLS_E FROM main.elements e
JOIN main.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "meetings ($SRC_MEETINGS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.meetings ($MEETINGS_COLS)
SELECT $MEETINGS_COLS FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';
DETACH nas;
"
# ─── FTS UPDATE ───────────────────────────────────────────────────────────
step "Updating FTS indexes"
run_sqlite_heredoc "elements_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.elements_fts(rowid, text, role)
SELECT e.id, e.text, e.role
FROM nas.elements e
JOIN nas.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE'
AND e.text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "frames_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)
SELECT id, full_text, app_name, window_name, browser_url, id
FROM nas.frames
WHERE date(timestamp) = '$TARGET_DATE'
AND full_text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "ui_events_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)
SELECT id, text_content, app_name, window_title, element_name
FROM nas.ui_events
WHERE date(timestamp) = '$TARGET_DATE'
AND text_content IS NOT NULL;
DETACH nas;
"
# ─── VERIFY DB ────────────────────────────────────────────────────────────
step "Verifying DB"
V_FRAMES=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
V_ELEMENTS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_UI=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
V_OCR=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_MEETINGS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';")
check "frames" "$V_FRAMES" "$SRC_FRAMES"
check "elements" "$V_ELEMENTS" "$SRC_ELEMENTS"
check "ui_events" "$V_UI" "$SRC_UI"
check "ocr_text" "$V_OCR" "$SRC_OCR"
check "meetings" "$V_MEETINGS" "$SRC_MEETINGS"
fi
# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────
# Always runs regardless of DB sync status
step "Copying data folder for $TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
mkdir -p "$NAS_DATA/$TARGET_DATE"
RSYNC_START=$(date +%s)
printf " %-36s " "rsync $TARGET_DATE/ → NAS"
rsync -a --ignore-existing \
"$DATA_SRC/" \
"$NAS_DATA/$TARGET_DATE/" \
2>>"$LOG_FILE"
RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))
COPIED_FILES=$(ls "$NAS_DATA/$TARGET_DATE" | wc -l | tr -d ' ')
SRC_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
COPIED_SIZE=$(du -sh "$NAS_DATA/$TARGET_DATE" | cut -f1)
if [ "$COPIED_FILES" -eq "$SRC_FILES" ]; then
printf "\r %-36s ✓ %dm%02ds (%s files, %s)\n" \
"rsync $TARGET_DATE/ → NAS" \
"$(( RSYNC_DUR / 60 ))" "$(( RSYNC_DUR % 60 ))" \
"$COPIED_FILES" "$COPIED_SIZE" | tee -a "$LOG_FILE"
else
printf "\r %-36s ✗ %s / %s files\n" \
"rsync $TARGET_DATE/ → NAS" "$COPIED_FILES" "$SRC_FILES" | tee -a "$LOG_FILE"
fi
else
printf " %-36s %s\n" "rsync $TARGET_DATE/ → NAS" "skipped (no source dir)"
fi
# ─── COPY LOGS ────────────────────────────────────────────────────────────────
# Screenpipe writes daily logs to ~/.screenpipe/screenpipe.YYYY-MM-DD.N.log
# (N is a rotation counter, almost always 0). Mirror them to NAS so log
# analysis can happen on the consumer side without SSH'ing back to the Mac.
step "Copying screenpipe logs for $TARGET_DATE"
NAS_LOGS="$NAS_MOUNT/logs"
mkdir -p "$NAS_LOGS"
# Use a glob with nullglob so an empty match doesn't expand to a literal pattern.
shopt -s nullglob
LOG_FILES=( "$HOME/.screenpipe/screenpipe.$TARGET_DATE."*.log )
shopt -u nullglob
if [ ${#LOG_FILES[@]} -gt 0 ]; then
printf " %-36s " "rsync logs → NAS"
# No --ignore-existing here: logs grow during the day, so we want rsync's
# default size+mtime check to refresh files that have changed.
rsync -a "${LOG_FILES[@]}" "$NAS_LOGS/" 2>>"$LOG_FILE"
COPIED=${#LOG_FILES[@]}
TOTAL_SIZE=$(du -ch "${LOG_FILES[@]}" | tail -1 | cut -f1)
printf "✓ %d file(s), %s\n" "$COPIED" "$TOTAL_SIZE" | tee -a "$LOG_FILE"
else
printf " %-36s %s\n" "rsync logs → NAS" "skipped (no matching logs)"
fi
# ─── SUMMARY ──────────────────────────────────────────────────────────────────
TOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))
DB_SIZE=$(du -sh "$NAS_DB" | cut -f1)
echo ""
log "Archive DB size: $DB_SIZE"
log "Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s"
log "Sync complete for $TARGET_DATE"
log "========================================"
# Mirror this script's own logbook to NAS so sync health can be monitored
# from the consumer side. Done last so the summary lines above are included.
rsync -a "$HOME/.screenpipe/sync.log" "$NAS_LOGS/sync.log" 2>/dev/null || true
#!/bin/bash
# screenpipe_sync.sh
# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).
# Also copies the day's video/frame data folder to the NAS.
#
# Schema-drift tolerant: if Screenpipe migrations add new columns to the source DB,
# the NAS archive gets ALTER TABLE'd to match. Inserts use explicit column lists,
# so positional mismatches can't occur.
#
# Usage:
# ./screenpipe_sync.sh # syncs yesterday (default)
# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date
# ./screenpipe_sync.sh today # syncs today so far
#
# Cron example (runs at 3am daily):
# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1
set -euo pipefail
# ─── CONFIG ───────────────────────────────────────────────────────────────────
DB_SRC="${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}"
NAS_MOUNT="${NAS_MOUNT:-/Volumes/screenpipe}"
NAS_DB="$NAS_MOUNT/archive.db"
NAS_DATA="$NAS_MOUNT/data"
LOG_FILE="$HOME/.screenpipe/sync.log"
# Tables that get schema drift handling. Order matters for FK-ish references
# (parents before children: video_chunks → frames → elements/ocr_text/ui_events).
SYNC_TABLES=(video_chunks frames elements ocr_text ui_events meetings)
# ──────────────────────────────────────────────────────────────────────────────
# ─── HELPERS ──────────────────────────────────────────────────────────────────
SCRIPT_START=$(date +%s)
log() {
local msg="[$(date '+%Y-%m-%d %H:%M:%S')] $*"
echo "$msg" | tee -a "$LOG_FILE"
}
step() {
local now=$(date +%s)
local elapsed=$(( now - SCRIPT_START ))
local min=$(( elapsed / 60 ))
local sec=$(( elapsed % 60 ))
printf "\n[+%02dm%02ds] ▶ %s\n" "$min" "$sec" "$*" | tee -a "$LOG_FILE"
}
run_sqlite_heredoc() {
local label="$1"
local sql="$2"
local start=$(date +%s)
printf " %-36s " "$label"
sqlite3 "$DB_SRC" <<< "$sql" &
local pid=$!
local spin=[PASSWORD] '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')
local i=0
while kill -0 "$pid" 2>/dev/null; do
printf "\r %-36s %s " "$label" "${spin[$i]}"
i=$(( (i + 1) % 10 ))
sleep 0.2
done
wait "$pid"
local rc=$?
if [ $rc -ne 0 ]; then
printf "\r %-36s ✗ FAILED\n" "$label" | tee -a "$LOG_FILE"
exit $rc
fi
local dur=$(( $(date +%s) - start ))
printf "\r %-36s ✓ %dm%02ds\n" "$label" "$(( dur / 60 ))" "$(( dur % 60 ))" | tee -a "$LOG_FILE"
}
check() {
local label="$1" got="$2" expected="$3"
if [ "$got" -eq "$expected" ]; then
printf " %-20s %s / %s ✓\n" "$label:" "$got" "$expected"
else
printf " %-20s %s / %s ✗ MISMATCH\n" "$label:" "$got" "$expected"
fi
}
# ─── SCHEMA HELPERS ───────────────────────────────────────────────────────────
# Echoes "name|type" lines for a table from a given DB.
table_columns_with_types() {
local db="$1" table="$2"
sqlite3 "$db" "PRAGMA table_info($table);" | awk -F'|' '{print $2 "|" $3}'
}
# Echoes just column names, one per line.
table_columns() {
local db="$1" table="$2"
sqlite3 "$db" "PRAGMA table_info($table);" | awk -F'|' '{print $2}'
}
# Returns true (0) if a table exists in the given DB.
table_exists() {
local db="$1" table="$2"
local count
count=$(sqlite3 "$db" "SELECT COUNT(*) FROM sqlite_master WHERE type='table' AND name='$table';")
[ "$count" -gt 0 ]
}
# Adds any columns present in source but missing in NAS for the given table.
# Uses ALTER TABLE ADD COLUMN, which is a fast metadata-only operation in SQLite.
ensure_columns() {
local table="$1"
local label="schema: $table"
printf " %-36s " "$label"
if ! table_exists "$DB_SRC" "$table"; then
printf "✗ source missing — skipping\n"
return 0
fi
if ! table_exists "$NAS_DB" "$table"; then
printf "✓ fresh (created above)\n"
return 0
fi
local src_cols
src_cols=$(table_columns_with_types "$DB_SRC" "$table")
local nas_cols
nas_cols=$(table_columns "$NAS_DB" "$table")
local added=0
local added_names=""
while IFS='|' read -r name type; do
[ -z "$name" ] && continue
# Use grep -F -x for fixed-string exact match (safe against regex chars).
if ! echo "$nas_cols" | grep -Fxq "$name"; then
# SQLite ALTER TABLE ADD COLUMN: type is optional, no NOT NULL allowed
# without a constant default. Default-NULL is exactly what we want for archive.
sqlite3 "$NAS_DB" "ALTER TABLE $table ADD COLUMN \"$name\" $type;"
added=$((added + 1))
added_names="$added_names $name"
fi
done <<< "$src_cols"
if [ "$added" -gt 0 ]; then
printf "✓ added %d:%s\n" "$added" "$added_names"
else
printf "✓ in sync\n"
fi
}
# Echoes a comma-separated list of source columns for a table, double-quoted
# so reserved words and hyphens are safe. If an alias is provided, columns are
# prefixed (e.g. `o."col"`). Used for both INSERT and SELECT sides; aliased
# form is required when SELECTing from a JOIN where column names collide
# (e.g. ocr_text and frames both have app_name, window_name).
build_col_list() {
local table="$1"
local alias="${2:-}"
local prefix=""
[ -n "$alias" ] && prefix="${alias}."
table_columns "$DB_SRC" "$table" | awk 'NF' | awk -v p="$prefix" '{print p "\"" $0 "\""}' | paste -sd, -
}
# ──────────────────────────────────────────────────────────────────────────────
# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────
if [ "${1:-}" = "today" ]; then
TARGET_DATE=$(date +%Y-%m-%d)
elif [ -n "${1:-}" ]; then
TARGET_DATE="$1"
if ! [[ "$TARGET_DATE" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then
echo "ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday."
exit 1
fi
else
TARGET_DATE=$(date -v-1d +%Y-%m-%d)
fi
log "========================================"
log "Screenpipe sync starting for: $TARGET_DATE"
log "========================================"
# ─── PREFLIGHT ────────────────────────────────────────────────────────────────
step "Preflight checks"
if [ ! -f "$DB_SRC" ]; then
log "ERROR: Source DB not found at $DB_SRC"; exit 1
fi
printf " %-20s %s (%s)\n" "Source DB:" "OK" "$(du -sh "$DB_SRC" | cut -f1)"
if [ ! -d "$NAS_MOUNT" ]; then
log "ERROR: NAS not mounted at $NAS_MOUNT"; exit 1
fi
printf " %-20s %s\n" "NAS mount:" "OK $NAS_MOUNT"
# Check if DB already synced for this date
DB_ALREADY_SYNCED=false
if [ -f "$NAS_DB" ]; then
if table_exists "$NAS_DB" "frames"; then
EXISTING=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';" 2>/dev/null || echo "0")
if [ "$EXISTING" -gt "0" ]; then
log "Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync"
DB_ALREADY_SYNCED=true
else
printf " %-20s %s (%s)\n" "Archive DB:" "exists" "$(du -sh "$NAS_DB" | cut -f1)"
fi
else
printf " %-20s %s\n" "Archive DB:" "exists, no frames table yet"
fi
else
printf " %-20s %s\n" "Archive DB:" "will be created"
fi
# Source data dir for this date
DATA_SRC="$HOME/.screenpipe/data/data/$TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
DATA_SIZE=$(du -sh "$DATA_SRC" | cut -f1)
DATA_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
printf " %-20s %s (%s files, %s)\n" "Data dir:" "OK" "$DATA_FILES" "$DATA_SIZE"
else
printf " %-20s %s\n" "Data dir:" "not found — skipping file copy"
fi
# ─── DB SYNC ──────────────────────────────────────────────────────────────────
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────
step "Counting source rows for $TARGET_DATE"
SRC_FRAMES=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
SRC_ELEMENTS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_UI=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
SRC_OCR=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_MEETINGS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';")
printf " %-20s %s\n" "frames:" "$SRC_FRAMES"
printf " %-20s %s\n" "elements:" "$SRC_ELEMENTS"
printf " %-20s %s\n" "ui_events:" "$SRC_UI"
printf " %-20s %s\n" "ocr_text:" "$SRC_OCR"
printf " %-20s %s\n" "meetings:" "$SRC_MEETINGS"
if [ "$SRC_FRAMES" -eq "0" ]; then
log "No frames found for $TARGET_DATE — skipping DB sync"
DB_ALREADY_SYNCED=true
fi
fi
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── INIT TABLES ──────────────────────────────────────────────────────────
step "Initialising tables (CREATE IF NOT EXISTS)"
run_sqlite_heredoc "creating tables" "
ATTACH '$NAS_DB' AS nas;
CREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;
CREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;
CREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;
CREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;
DETACH nas;
"
# ─── SCHEMA DRIFT FIX ─────────────────────────────────────────────────────
# Runs AFTER CREATE IF NOT EXISTS so newly-created tables are no-ops here,
# and pre-existing tables get any missing columns added.
step "Reconciling NAS schema with source"
for tbl in "${SYNC_TABLES[@]}"; do
ensure_columns "$tbl"
done
run_sqlite_heredoc "creating indexes" "
ATTACH '$NAS_DB' AS nas;
CREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);
CREATE INDEX IF NOT EXISTS nas.idx_frames_document_path ON frames(document_path) WHERE document_path IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_elements_onscreen_frame ON elements(frame_id) WHERE on_screen = 1 AND text IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);
CREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);
DETACH nas;
"
run_sqlite_heredoc "creating FTS tables" "
ATTACH '$NAS_DB' AS nas;
CREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(
text, role, frame_id UNINDEXED,
content='elements', content_rowid='id', tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(
full_text, app_name, window_name, browser_url, id UNINDEXED,
tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(
text_content,
app_name,
window_title,
element_name,
content='ui_events',
content_rowid='id',
tokenize='unicode61'
);
DETACH nas;
"
# ─── BUILD EXPLICIT COLUMN LISTS ──────────────────────────────────────────
# After ensure_columns, source ⊆ NAS for every synced table, so source's
# column list is a safe subset to use on both sides of the INSERT.
# For tables that JOIN frames (ocr_text, elements), the SELECT side needs
# alias-qualified columns because both tables share names (app_name, etc).
FRAMES_COLS=$(build_col_list frames)
ELEMENTS_COLS=$(build_col_list elements)
ELEMENTS_COLS_E=$(build_col_list elements e)
UI_EVENTS_COLS=$(build_col_list ui_events)
OCR_TEXT_COLS=$(build_col_list ocr_text)
OCR_TEXT_COLS_O=$(build_col_list ocr_text o)
VIDEO_CHUNKS_COLS=$(build_col_list video_chunks)
MEETINGS_COLS=$(build_col_list meetings)
# ─── SYNC DATA ────────────────────────────────────────────────────────────
step "Syncing data for $TARGET_DATE"
run_sqlite_heredoc "video_chunks" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.video_chunks ($VIDEO_CHUNKS_COLS)
SELECT $VIDEO_CHUNKS_COLS FROM main.video_chunks
WHERE id IN (
SELECT DISTINCT video_chunk_id FROM main.frames
WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL
);
DETACH nas;
"
run_sqlite_heredoc "frames ($SRC_FRAMES rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.frames ($FRAMES_COLS)
SELECT $FRAMES_COLS FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ocr_text ($SRC_OCR rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ocr_text ($OCR_TEXT_COLS)
SELECT $OCR_TEXT_COLS_O FROM main.ocr_text o
JOIN main.frames f ON o.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ui_events ($SRC_UI rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ui_events ($UI_EVENTS_COLS)
SELECT $UI_EVENTS_COLS FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "elements ($SRC_ELEMENTS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.elements ($ELEMENTS_COLS)
SELECT $ELEMENTS_COLS_E FROM main.elements e
JOIN main.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "meetings ($SRC_MEETINGS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.meetings ($MEETINGS_COLS)
SELECT $MEETINGS_COLS FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';
DETACH nas;
"
# ─── FTS UPDATE ───────────────────────────────────────────────────────────
step "Updating FTS indexes"
run_sqlite_heredoc "elements_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.elements_fts(rowid, text, role)
SELECT e.id, e.text, e.role
FROM nas.elements e
JOIN nas.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE'
AND e.text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "frames_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)
SELECT id, full_text, app_name, window_name, browser_url, id
FROM nas.frames
WHERE date(timestamp) = '$TARGET_DATE'
AND full_text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "ui_events_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)
SELECT id, text_content, app_name, window_title, element_name
FROM nas.ui_events
WHERE date(timestamp) = '$TARGET_DATE'
AND text_content IS NOT NULL;
DETACH nas;
"
# ─── VERIFY DB ────────────────────────────────────────────────────────────
step "Verifying DB"
V_FRAMES=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
V_ELEMENTS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_UI=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
V_OCR=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_MEETINGS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';")
check "frames" "$V_FRAMES" "$SRC_FRAMES"
check "elements" "$V_ELEMENTS" "$SRC_ELEMENTS"
check "ui_events" "$V_UI" "$SRC_UI"
check "ocr_text" "$V_OCR" "$SRC_OCR"
check "meetings" "$V_MEETINGS" "$SRC_MEETINGS"
fi
# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────
# Always runs regardless of DB sync status
step "Copying data folder for $TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
mkdir -p "$NAS_DATA/$TARGET_DATE"
RSYNC_START=$(date +%s)
printf " %-36s " "rsync $TARGET_DATE/ → NAS"
rsync -a --ignore-existing \
"$DATA_SRC/" \
"$NAS_DATA/$TARGET_DATE/" \
2>>"$LOG_FILE"
RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))
COPIED_FILES=$(ls "$NAS_DATA/$TARGET_DATE" | wc -l | tr -d ' ')
SRC_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
COPIED_SIZE=$(du -sh "$NAS_DATA/$TARGET_DATE" | cut -f1)
if [ "$COPIED_FILES" -eq "$SRC_FILES" ]; then
printf "\r %-36s ✓ %dm%02ds (%s files, %s)\n" \
"rsync $TARGET_DATE/ → NAS" \
"$(( RSYNC_DUR / 60 ))" "$(( RSYNC_DUR % 60 ))" \
"$COPIED_FILES" "$COPIED_SIZE" | tee -a "$LOG_FILE"
else
printf "\r %-36s ✗ %s / %s files\n" \
"rsync $TARGET_DATE/ → NAS" "$COPIED_FILES" "$SRC_FILES" | tee -a "$LOG_FILE"
fi
else
printf " %-36s %s\n" "rsync $TARGET_DATE/ → NAS" "skipped (no source dir)"
fi
# ─── COPY LOGS ────────────────────────────────────────────────────────────────
# Screenpipe writes daily logs to ~/.screenpipe/screenpipe.YYYY-MM-DD.N.log
# (N is a rotation counter, almost always 0). Mirror them to NAS so log
# analysis can happen on the consumer side without SSH'ing back to the Mac.
step "Copying screenpipe logs for $TARGET_DATE"
NAS_LOGS="$NAS_MOUNT/logs"
mkdir -p "$NAS_LOGS"
# Use a glob with nullglob so an empty match doesn't expand to a literal pattern.
shopt -s nullglob
LOG_FILES=( "$HOME/.screenpipe/screenpipe.$TARGET_DATE."*.log )
shopt -u nullglob
if [ ${#LOG_FILES[@]} -gt 0 ]; then
printf " %-36s " "rsync logs → NAS"
# No --ignore-existing here: logs grow during the day, so we want rsync's
# default size+mtime check to refresh files that have changed.
rsync -a "${LOG_FILES[@]}" "$NAS_LOGS/" 2>>"$LOG_FILE"
COPIED=${#LOG_FILES[@]}
TOTAL_SIZE=$(du -ch "${LOG_FILES[@]}" | tail -1 | cut -f1)
printf "✓ %d file(s), %s\n" "$COPIED" "$TOTAL_SIZE" | tee -a "$LOG_FILE"
else
printf " %-36s %s\n" "rsync logs → NAS" "skipped (no matching logs)"
fi
# ─── SUMMARY ──────────────────────────────────────────────────────────────────
TOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))
DB_SIZE=$(du -sh "$NAS_DB" | cut -f1)
echo ""
log "Archive DB size: $DB_SIZE"
log "Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s"
log "Sync complete for $TARGET_DATE"
log "========================================"
# Mirror this script's own logbook to NAS so sync health can be monitored
# from the consumer side. Done last so the summary lines above are included.
rsync -a "$HOME/.screenpipe/sync.log" "$NAS_LOGS/sync.log" 2>/dev/null || true
Implement and run pipe l…, Editor Group 2
Problems (⇧⌘M)
PROBLEMS
Output (⇧⌘U)
OUTPUT
Debug Console (⇧⌘Y)
DEBUG CONSOLE
Terminal (⌃`)
TERMINAL
Ports - 1 forwarded port
PORTS
1
remote SSH: nas
SSH: nas
screenpipe (Git) - master*, Checkout Branch/Tag...
master*
screenpipe (Git) - Synchronize Changes
No Problems
0
0
Forwarded Ports: 8766
1
Notifications
Sign In
Sign In
Shell Script
Editor Language Status: Inline Suggestions, next: $(copilot) No inline suggestion available, Inline suggestions
LF
UTF-8
Spaces: 2
Ln 480, Col 3
git-commit Not Committed Yet...
|
21103
|
NULL
|
NULL
|
NULL
|
|
21106
|
922
|
13
|
2026-05-11T17:12:23.695816+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-11/1778 /Users/lukas/.screenpipe/data/data/2026-05-11/1778519543695_m1.jpg...
|
Code
|
screenpipe_sync.sh — screenpipe [SSH: nas]
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Explorer (⇧⌘E) - 1 unsaved file
1
Search (⇧⌘F)
Explorer (⇧⌘E) - 1 unsaved file
1
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py
M
db.py
docker-compose.yml
Dockerfile
M
main.py
M
requirements.txt
M
data
logs
pipes
.gitignore
app_settings.json
archive.db
archive.db-bak
U
db.sqlite
db.sqlite-shm
db.sqlite-wal
screenpipe_sync_updated.sh
U
screenpipe_sync.sh
screenpipe.db
Outline Section
OUTLINE
OUTLINE
Timeline Section
TIMELINE
TIMELINE
app_settings.json, Editor Group 1
screenpipe_sync.sh, Editor Group 1
pipe.md, Editor Group 1
.env, Editor Group 1
#!/bin/bash
# screenpipe_sync.sh
# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).
# Also copies the day's video/frame data folder to the NAS.
#
# Schema-drift tolerant: if Screenpipe migrations add new columns to the source DB,
# the NAS archive gets ALTER TABLE'd to match. Inserts use explicit column lists,
# so positional mismatches can't occur.
#
# Usage:
# ./screenpipe_sync.sh # syncs yesterday (default)
# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date
# ./screenpipe_sync.sh today # syncs today so far
#
# Cron example (runs at 3am daily):
# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1
set -euo pipefail
# ─── CONFIG ───────────────────────────────────────────────────────────────────
DB_SRC="${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}"
NAS_MOUNT="${NAS_MOUNT:-/Volumes/screenpipe}"
NAS_DB="$NAS_MOUNT/archive.db"
NAS_DATA="$NAS_MOUNT/data"
LOG_FILE="$HOME/.screenpipe/sync.log"
# Tables that get schema drift handling. Order matters for FK-ish references
# (parents before children: video_chunks → frames → elements/ocr_text/ui_events).
SYNC_TABLES=(video_chunks frames elements ocr_text ui_events meetings)
# ──────────────────────────────────────────────────────────────────────────────
# ─── HELPERS ──────────────────────────────────────────────────────────────────
SCRIPT_START=$(date +%s)
log() {
local msg="[$(date '+%Y-%m-%d %H:%M:%S')] $*"
echo "$msg" | tee -a "$LOG_FILE"
}
step() {
local now=$(date +%s)
local elapsed=$(( now - SCRIPT_START ))
local min=$(( elapsed / 60 ))
local sec=$(( elapsed % 60 ))
printf "\n[+%02dm%02ds] ▶ %s\n" "$min" "$sec" "$*" | tee -a "$LOG_FILE"
}
run_sqlite_heredoc() {
local label="$1"
local sql="$2"
local start=$(date +%s)
printf " %-36s " "$label"
sqlite3 "$DB_SRC" <<< "$sql" &
local pid=$!
local spin=[PASSWORD] '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')
local i=0
while kill -0 "$pid" 2>/dev/null; do
printf "\r %-36s %s " "$label" "${spin[$i]}"
i=$(( (i + 1) % 10 ))
sleep 0.2
done
wait "$pid"
local rc=$?
if [ $rc -ne 0 ]; then
printf "\r %-36s ✗ FAILED\n" "$label" | tee -a "$LOG_FILE"
exit $rc
fi
local dur=$(( $(date +%s) - start ))
printf "\r %-36s ✓ %dm%02ds\n" "$label" "$(( dur / 60 ))" "$(( dur % 60 ))" | tee -a "$LOG_FILE"
}
check() {
local label="$1" got="$2" expected="$3"
if [ "$got" -eq "$expected" ]; then
printf " %-20s %s / %s ✓\n" "$label:" "$got" "$expected"
else
printf " %-20s %s / %s ✗ MISMATCH\n" "$label:" "$got" "$expected"
fi
}
# ─── SCHEMA HELPERS ───────────────────────────────────────────────────────────
# Echoes "name|type" lines for a table from a given DB.
table_columns_with_types() {
local db="$1" table="$2"
sqlite3 "$db" "PRAGMA table_info($table);" | awk -F'|' '{print $2 "|" $3}'
}
# Echoes just column names, one per line.
table_columns() {
local db="$1" table="$2"
sqlite3 "$db" "PRAGMA table_info($table);" | awk -F'|' '{print $2}'
}
# Returns true (0) if a table exists in the given DB.
table_exists() {
local db="$1" table="$2"
local count
count=$(sqlite3 "$db" "SELECT COUNT(*) FROM sqlite_master WHERE type='table' AND name='$table';")
[ "$count" -gt 0 ]
}
# Adds any columns present in source but missing in NAS for the given table.
# Uses ALTER TABLE ADD COLUMN, which is a fast metadata-only operation in SQLite.
ensure_columns() {
local table="$1"
local label="schema: $table"
printf " %-36s " "$label"
if ! table_exists "$DB_SRC" "$table"; then
printf "✗ source missing — skipping\n"
return 0
fi
if ! table_exists "$NAS_DB" "$table"; then
printf "✓ fresh (created above)\n"
return 0
fi
local src_cols
src_cols=$(table_columns_with_types "$DB_SRC" "$table")
local nas_cols
nas_cols=$(table_columns "$NAS_DB" "$table")
local added=0
local added_names=""
while IFS='|' read -r name type; do
[ -z "$name" ] && continue
# Use grep -F -x for fixed-string exact match (safe against regex chars).
if ! echo "$nas_cols" | grep -Fxq "$name"; then
# SQLite ALTER TABLE ADD COLUMN: type is optional, no NOT NULL allowed
# without a constant default. Default-NULL is exactly what we want for archive.
sqlite3 "$NAS_DB" "ALTER TABLE $table ADD COLUMN \"$name\" $type;"
added=$((added + 1))
added_names="$added_names $name"
fi
done <<< "$src_cols"
if [ "$added" -gt 0 ]; then
printf "✓ added %d:%s\n" "$added" "$added_names"
else
printf "✓ in sync\n"
fi
}
# Echoes a comma-separated list of source columns for a table, double-quoted
# so reserved words and hyphens are safe. If an alias is provided, columns are
# prefixed (e.g. `o."col"`). Used for both INSERT and SELECT sides; aliased
# form is required when SELECTing from a JOIN where column names collide
# (e.g. ocr_text and frames both have app_name, window_name).
build_col_list() {
local table="$1"
local alias="${2:-}"
local prefix=""
[ -n "$alias" ] && prefix="${alias}."
table_columns "$DB_SRC" "$table" | awk 'NF' | awk -v p="$prefix" '{print p "\"" $0 "\""}' | paste -sd, -
}
# ──────────────────────────────────────────────────────────────────────────────
# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────
if [ "${1:-}" = "today" ]; then
TARGET_DATE=$(date +%Y-%m-%d)
elif [ -n "${1:-}" ]; then
TARGET_DATE="$1"
if ! [[ "$TARGET_DATE" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then
echo "ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday."
exit 1
fi
else
TARGET_DATE=$(date -v-1d +%Y-%m-%d)
fi
log "========================================"
log "Screenpipe sync starting for: $TARGET_DATE"
log "========================================"
# ─── PREFLIGHT ────────────────────────────────────────────────────────────────
step "Preflight checks"
if [ ! -f "$DB_SRC" ]; then
log "ERROR: Source DB not found at $DB_SRC"; exit 1
fi
printf " %-20s %s (%s)\n" "Source DB:" "OK" "$(du -sh "$DB_SRC" | cut -f1)"
if [ ! -d "$NAS_MOUNT" ]; then
log "ERROR: NAS not mounted at $NAS_MOUNT"; exit 1
fi
printf " %-20s %s\n" "NAS mount:" "OK $NAS_MOUNT"
# Check if DB already synced for this date
DB_ALREADY_SYNCED=false
if [ -f "$NAS_DB" ]; then
if table_exists "$NAS_DB" "frames"; then
EXISTING=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';" 2>/dev/null || echo "0")
if [ "$EXISTING" -gt "0" ]; then
log "Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync"
DB_ALREADY_SYNCED=true
else
printf " %-20s %s (%s)\n" "Archive DB:" "exists" "$(du -sh "$NAS_DB" | cut -f1)"
fi
else
printf " %-20s %s\n" "Archive DB:" "exists, no frames table yet"
fi
else
printf " %-20s %s\n" "Archive DB:" "will be created"
fi
# Source data dir for this date
DATA_SRC="$HOME/.screenpipe/data/data/$TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
DATA_SIZE=$(du -sh "$DATA_SRC" | cut -f1)
DATA_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
printf " %-20s %s (%s files, %s)\n" "Data dir:" "OK" "$DATA_FILES" "$DATA_SIZE"
else
printf " %-20s %s\n" "Data dir:" "not found — skipping file copy"
fi
# ─── DB SYNC ──────────────────────────────────────────────────────────────────
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────
step "Counting source rows for $TARGET_DATE"
SRC_FRAMES=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
SRC_ELEMENTS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_UI=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
SRC_OCR=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_MEETINGS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';")
printf " %-20s %s\n" "frames:" "$SRC_FRAMES"
printf " %-20s %s\n" "elements:" "$SRC_ELEMENTS"
printf " %-20s %s\n" "ui_events:" "$SRC_UI"
printf " %-20s %s\n" "ocr_text:" "$SRC_OCR"
printf " %-20s %s\n" "meetings:" "$SRC_MEETINGS"
if [ "$SRC_FRAMES" -eq "0" ]; then
log "No frames found for $TARGET_DATE — skipping DB sync"
DB_ALREADY_SYNCED=true
fi
fi
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── INIT TABLES ──────────────────────────────────────────────────────────
step "Initialising tables (CREATE IF NOT EXISTS)"
run_sqlite_heredoc "creating tables" "
ATTACH '$NAS_DB' AS nas;
CREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;
CREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;
CREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;
CREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;
DETACH nas;
"
# ─── SCHEMA DRIFT FIX ─────────────────────────────────────────────────────
# Runs AFTER CREATE IF NOT EXISTS so newly-created tables are no-ops here,
# and pre-existing tables get any missing columns added.
step "Reconciling NAS schema with source"
for tbl in "${SYNC_TABLES[@]}"; do
ensure_columns "$tbl"
done
run_sqlite_heredoc "creating indexes" "
ATTACH '$NAS_DB' AS nas;
CREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);
CREATE INDEX IF NOT EXISTS nas.idx_frames_document_path ON frames(document_path) WHERE document_path IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_elements_onscreen_frame ON elements(frame_id) WHERE on_screen = 1 AND text IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);
CREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);
DETACH nas;
"
run_sqlite_heredoc "creating FTS tables" "
ATTACH '$NAS_DB' AS nas;
CREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(
text, role, frame_id UNINDEXED,
content='elements', content_rowid='id', tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(
full_text, app_name, window_name, browser_url, id UNINDEXED,
tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(
text_content,
app_name,
window_title,
element_name,
content='ui_events',
content_rowid='id',
tokenize='unicode61'
);
DETACH nas;
"
# ─── BUILD EXPLICIT COLUMN LISTS ──────────────────────────────────────────
# After ensure_columns, source ⊆ NAS for every synced table, so source's
# column list is a safe subset to use on both sides of the INSERT.
# For tables that JOIN frames (ocr_text, elements), the SELECT side needs
# alias-qualified columns because both tables share names (app_name, etc).
FRAMES_COLS=$(build_col_list frames)
ELEMENTS_COLS=$(build_col_list elements)
ELEMENTS_COLS_E=$(build_col_list elements e)
UI_EVENTS_COLS=$(build_col_list ui_events)
OCR_TEXT_COLS=$(build_col_list ocr_text)
OCR_TEXT_COLS_O=$(build_col_list ocr_text o)
VIDEO_CHUNKS_COLS=$(build_col_list video_chunks)
MEETINGS_COLS=$(build_col_list meetings)
# ─── SYNC DATA ────────────────────────────────────────────────────────────
step "Syncing data for $TARGET_DATE"
run_sqlite_heredoc "video_chunks" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.video_chunks ($VIDEO_CHUNKS_COLS)
SELECT $VIDEO_CHUNKS_COLS FROM main.video_chunks
WHERE id IN (
SELECT DISTINCT video_chunk_id FROM main.frames
WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL
);
DETACH nas;
"
run_sqlite_heredoc "frames ($SRC_FRAMES rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.frames ($FRAMES_COLS)
SELECT $FRAMES_COLS FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ocr_text ($SRC_OCR rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ocr_text ($OCR_TEXT_COLS)
SELECT $OCR_TEXT_COLS_O FROM main.ocr_text o
JOIN main.frames f ON o.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ui_events ($SRC_UI rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ui_events ($UI_EVENTS_COLS)
SELECT $UI_EVENTS_COLS FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "elements ($SRC_ELEMENTS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.elements ($ELEMENTS_COLS)
SELECT $ELEMENTS_COLS_E FROM main.elements e
JOIN main.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "meetings ($SRC_MEETINGS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.meetings ($MEETINGS_COLS)
SELECT $MEETINGS_COLS FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';
DETACH nas;
"
# ─── FTS UPDATE ───────────────────────────────────────────────────────────
step "Updating FTS indexes"
run_sqlite_heredoc "elements_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.elements_fts(rowid, text, role)
SELECT e.id, e.text, e.role
FROM nas.elements e
JOIN nas.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE'
AND e.text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "frames_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)
SELECT id, full_text, app_name, window_name, browser_url, id
FROM nas.frames
WHERE date(timestamp) = '$TARGET_DATE'
AND full_text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "ui_events_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)
SELECT id, text_content, app_name, window_title, element_name
FROM nas.ui_events
WHERE date(timestamp) = '$TARGET_DATE'
AND text_content IS NOT NULL;
DETACH nas;
"
# ─── VERIFY DB ────────────────────────────────────────────────────────────
step "Verifying DB"
V_FRAMES=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
V_ELEMENTS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_UI=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
V_OCR=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_MEETINGS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';")
check "frames" "$V_FRAMES" "$SRC_FRAMES"
check "elements" "$V_ELEMENTS" "$SRC_ELEMENTS"
check "ui_events" "$V_UI" "$SRC_UI"
check "ocr_text" "$V_OCR" "$SRC_OCR"
check "meetings" "$V_MEETINGS" "$SRC_MEETINGS"
fi
# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────
# Always runs regardless of DB sync status
step "Copying data folder for $TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
mkdir -p "$NAS_DATA/$TARGET_DATE"
RSYNC_START=$(date +%s)
printf " %-36s " "rsync $TARGET_DATE/ → NAS"
rsync -a --ignore-existing \
"$DATA_SRC/" \
"$NAS_DATA/$TARGET_DATE/" \
2>>"$LOG_FILE"
RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))
COPIED_FILES=$(ls "$NAS_DATA/$TARGET_DATE" | wc -l | tr -d ' ')
SRC_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
COPIED_SIZE=$(du -sh "$NAS_DATA/$TARGET_DATE" | cut -f1)
if [ "$COPIED_FILES" -eq "$SRC_FILES" ]; then
printf "\r %-36s ✓ %dm%02ds (%s files, %s)\n" \
"rsync $TARGET_DATE/ → NAS" \
"$(( RSYNC_DUR / 60 ))" "$(( RSYNC_DUR % 60 ))" \
"$COPIED_FILES" "$COPIED_SIZE" | tee -a "$LOG_FILE"
else
printf "\r %-36s ✗ %s / %s files\n" \
"rsync $TARGET_DATE/ → NAS" "$COPIED_FILES" "$SRC_FILES" | tee -a "$LOG_FILE"
fi
else
printf " %-36s %s\n" "rsync $TARGET_DATE/ → NAS" "skipped (no source dir)"
fi
# ─── COPY LOGS ────────────────────────────────────────────────────────────────
# Screenpipe writes daily logs to ~/.screenpipe/screenpipe.YYYY-MM-DD.N.log
# (N is a rotation counter, almost always 0). Mirror them to NAS so log
# analysis can happen on the consumer side without SSH'ing back to the Mac.
step "Copying screenpipe logs for $TARGET_DATE"
NAS_LOGS="$NAS_MOUNT/logs"
mkdir -p "$NAS_LOGS"
# Use a glob with nullglob so an empty match doesn't expand to a literal pattern.
shopt -s nullglob
LOG_FILES=( "$HOME/.screenpipe/screenpipe.$TARGET_DATE."*.log )
shopt -u nullglob
if [ ${#LOG_FILES[@]} -gt 0 ]; then
printf " %-36s " "rsync logs → NAS"
# No --ignore-existing here: logs grow during the day, so we want rsync's
# default size+mtime check to refresh files that have changed.
rsync -a "${LOG_FILES[@]}" "$NAS_LOGS/" 2>>"$LOG_FILE"
COPIED=${#LOG_FILES[@]}
TOTAL_SIZE=$(du -ch "${LOG_FILES[@]}" | tail -1 | cut -f1)
printf "✓ %d file(s), %s\n" "$COPIED" "$TOTAL_SIZE" | tee -a "$LOG_FILE"
else
printf " %-36s %s\n" "rsync logs → NAS" "skipped (no matching logs)"
fi
# ─── SUMMARY ──────────────────────────────────────────────────────────────────
TOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))
DB_SIZE=$(du -sh "$NAS_DB" | cut -f1)
echo ""
log "Archive DB size: $DB_SIZE"
log "Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s"
log "Sync complete for $TARGET_DATE"
log "========================================"
# Mirror this script's own logbook to NAS so sync health can be monitored
# from the consumer side. Done last so the summary lines above are included.
rsync -a "$HOME/.screenpipe/sync.log" "$NAS_LOGS/sync.log" 2>/dev/null || true
#!/bin/bash
# screenpipe_sync.sh
# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).
# Also copies the day's video/frame data folder to the NAS.
#
# Schema-drift tolerant: if Screenpipe migrations add new columns to the source DB,
# the NAS archive gets ALTER TABLE'd to match. Inserts use explicit column lists,
# so positional mismatches can't occur.
#
# Usage:
# ./screenpipe_sync.sh # syncs yesterday (default)
# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date
# ./screenpipe_sync.sh today # syncs today so far
#
# Cron example (runs at 3am daily):
# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1
set -euo pipefail
# ─── CONFIG ───────────────────────────────────────────────────────────────────
DB_SRC="${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}"
NAS_MOUNT="${NAS_MOUNT:-/Volumes/screenpipe}"
NAS_DB="$NAS_MOUNT/archive.db"
NAS_DATA="$NAS_MOUNT/data"
LOG_FILE="$HOME/.screenpipe/sync.log"
# Tables that get schema drift handling. Order matters for FK-ish references
# (parents before children: video_chunks → frames → elements/ocr_text/ui_events).
SYNC_TABLES=(video_chunks frames elements ocr_text ui_events meetings)
# ──────────────────────────────────────────────────────────────────────────────
# ─── HELPERS ──────────────────────────────────────────────────────────────────
SCRIPT_START=$(date +%s)
log() {
local msg="[$(date '+%Y-%m-%d %H:%M:%S')] $*"
echo "$msg" | tee -a "$LOG_FILE"
}
step() {
local now=$(date +%s)
local elapsed=$(( now - SCRIPT_START ))
local min=$(( elapsed / 60 ))
local sec=$(( elapsed % 60 ))
printf "\n[+%02dm%02ds] ▶ %s\n" "$min" "$sec" "$*" | tee -a "$LOG_FILE"
}
run_sqlite_heredoc() {
local label="$1"
local sql="$2"
local start=$(date +%s)
printf " %-36s " "$label"
sqlite3 "$DB_SRC" <<< "$sql" &
local pid=$!
local spin=[PASSWORD] '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')
local i=0
while kill -0 "$pid" 2>/dev/null; do
printf "\r %-36s %s " "$label" "${spin[$i]}"
i=$(( (i + 1) % 10 ))
sleep 0.2
done
wait "$pid"
local rc=$?
if [ $rc -ne 0 ]; then
printf "\r %-36s ✗ FAILED\n" "$label" | tee -a "$LOG_FILE"
exit $rc
fi
local dur=$(( $(date +%s) - start ))
printf "\r %-36s ✓ %dm%02ds\n" "$label" "$(( dur / 60 ))" "$(( dur % 60 ))" | tee -a "$LOG_FILE"
}
check() {
local label="$1" got="$2" expected="$3"
if [ "$got" -eq "$expected" ]; then
printf " %-20s %s / %s ✓\n" "$label:" "$got" "$expected"
else
printf " %-20s %s / %s ✗ MISMATCH\n" "$label:" "$got" "$expected"
fi
}
# ─── SCHEMA HELPERS ───────────────────────────────────────────────────────────
# Echoes "name|type" lines for a table from a given DB.
table_columns_with_types() {
local db="$1" table="$2"
sqlite3 "$db" "PRAGMA table_info($table);" | awk -F'|' '{print $2 "|" $3}'
}
# Echoes just column names, one per line.
table_columns() {
local db="$1" table="$2"
sqlite3 "$db" "PRAGMA table_info($table);" | awk -F'|' '{print $2}'
}
# Returns true (0) if a table exists in the given DB.
table_exists() {
local db="$1" table="$2"
local count
count=$(sqlite3 "$db" "SELECT COUNT(*) FROM sqlite_master WHERE type='table' AND name='$table';")
[ "$count" -gt 0 ]
}
# Adds any columns present in source but missing in NAS for the given table.
# Uses ALTER TABLE ADD COLUMN, which is a fast metadata-only operation in SQLite.
ensure_columns() {
local table="$1"
local label="schema: $table"
printf " %-36s " "$label"
if ! table_exists "$DB_SRC" "$table"; then
printf "✗ source missing — skipping\n"
return 0
fi
if ! table_exists "$NAS_DB" "$table"; then
printf "✓ fresh (created above)\n"
return 0
fi
local src_cols
src_cols=$(table_columns_with_types "$DB_SRC" "$table")
local nas_cols
nas_cols=$(table_columns "$NAS_DB" "$table")
local added=0
local added_names=""
while IFS='|' read -r name type; do
[ -z "$name" ] && continue
# Use grep -F -x for fixed-string exact match (safe against regex chars).
if ! echo "$nas_cols" | grep -Fxq "$name"; then
# SQLite ALTER TABLE ADD COLUMN: type is optional, no NOT NULL allowed
# without a constant default. Default-NULL is exactly what we want for archive.
sqlite3 "$NAS_DB" "ALTER TABLE $table ADD COLUMN \"$name\" $type;"
added=$((added + 1))
added_names="$added_names $name"
fi
done <<< "$src_cols"
if [ "$added" -gt 0 ]; then
printf "✓ added %d:%s\n" "$added" "$added_names"
else
printf "✓ in sync\n"
fi
}
# Echoes a comma-separated list of source columns for a table, double-quoted
# so reserved words and hyphens are safe. If an alias is provided, columns are
# prefixed (e.g. `o."col"`). Used for both INSERT and SELECT sides; aliased
# form is required when SELECTing from a JOIN where column names collide
# (e.g. ocr_text and frames both have app_name, window_name).
build_col_list() {
local table="$1"
local alias="${2:-}"
local prefix=""
[ -n "$alias" ] && prefix="${alias}."
table_columns "$DB_SRC" "$table" | awk 'NF' | awk -v p="$prefix" '{print p "\"" $0 "\""}' | paste -sd, -
}
# ──────────────────────────────────────────────────────────────────────────────
# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────
if [ "${1:-}" = "today" ]; then
TARGET_DATE=$(date +%Y-%m-%d)
elif [ -n "${1:-}" ]; then
TARGET_DATE="$1"
if ! [[ "$TARGET_DATE" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then
echo "ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday."
exit 1
fi
else
TARGET_DATE=$(date -v-1d +%Y-%m-%d)
fi
log "========================================"
log "Screenpipe sync starting for: $TARGET_DATE"
log "========================================"
# ─── PREFLIGHT ────────────────────────────────────────────────────────────────
step "Preflight checks"
if [ ! -f "$DB_SRC" ]; then
log "ERROR: Source DB not found at $DB_SRC"; exit 1
fi
printf " %-20s %s (%s)\n" "Source DB:" "OK" "$(du -sh "$DB_SRC" | cut -f1)"
if [ ! -d "$NAS_MOUNT" ]; then
log "ERROR: NAS not mounted at $NAS_MOUNT"; exit 1
fi
printf " %-20s %s\n" "NAS mount:" "OK $NAS_MOUNT"
# Check if DB already synced for this date
DB_ALREADY_SYNCED=false
if [ -f "$NAS_DB" ]; then
if table_exists "$NAS_DB" "frames"; then
EXISTING=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';" 2>/dev/null || echo "0")
if [ "$EXISTING" -gt "0" ]; then
log "Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync"
DB_ALREADY_SYNCED=true
else
printf " %-20s %s (%s)\n" "Archive DB:" "exists" "$(du -sh "$NAS_DB" | cut -f1)"
fi
else
printf " %-20s %s\n" "Archive DB:" "exists, no frames table yet"
fi
else
printf " %-20s %s\n" "Archive DB:" "will be created"
fi
# Source data dir for this date
DATA_SRC="$HOME/.screenpipe/data/data/$TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
DATA_SIZE=$(du -sh "$DATA_SRC" | cut -f1)
DATA_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
printf " %-20s %s (%s files, %s)\n" "Data dir:" "OK" "$DATA_FILES" "$DATA_SIZE"
else
printf " %-20s %s\n" "Data dir:" "not found — skipping file copy"
fi
# ─── DB SYNC ──────────────────────────────────────────────────────────────────
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────
step "Counting source rows for $TARGET_DATE"
SRC_FRAMES=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
SRC_ELEMENTS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_UI=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
SRC_OCR=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_MEETINGS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';")
printf " %-20s %s\n" "frames:" "$SRC_FRAMES"
printf " %-20s %s\n" "elements:" "$SRC_ELEMENTS"
printf " %-20s %s\n" "ui_events:" "$SRC_UI"
printf " %-20s %s\n" "ocr_text:" "$SRC_OCR"
printf " %-20s %s\n" "meetings:" "$SRC_MEETINGS"
if [ "$SRC_FRAMES" -eq "0" ]; then
log "No frames found for $TARGET_DATE — skipping DB sync"
DB_ALREADY_SYNCED=true
fi
fi
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── INIT TABLES ──────────────────────────────────────────────────────────
step "Initialising tables (CREATE IF NOT EXISTS)"
run_sqlite_heredoc "creating tables" "
ATTACH '$NAS_DB' AS nas;
CREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;
CREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;
CREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;
CREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;
DETACH nas;
"
# ─── SCHEMA DRIFT FIX ─────────────────────────────────────────────────────
# Runs AFTER CREATE IF NOT EXISTS so newly-created tables are no-ops here,
# and pre-existing tables get any missing columns added.
step "Reconciling NAS schema with source"
for tbl in "${SYNC_TABLES[@]}"; do
ensure_columns "$tbl"
done
run_sqlite_heredoc "creating indexes" "
ATTACH '$NAS_DB' AS nas;
CREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);
CREATE INDEX IF NOT EXISTS nas.idx_frames_document_path ON frames(document_path) WHERE document_path IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_elements_onscreen_frame ON elements(frame_id) WHERE on_screen = 1 AND text IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);
CREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);
DETACH nas;
"
run_sqlite_heredoc "creating FTS tables" "
ATTACH '$NAS_DB' AS nas;
CREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(
text, role, frame_id UNINDEXED,
content='elements', content_rowid='id', tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(
full_text, app_name, window_name, browser_url, id UNINDEXED,
tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(
text_content,
app_name,
window_title,
element_name,
content='ui_events',
content_rowid='id',
tokenize='unicode61'
);
DETACH nas;
"
# ─── BUILD EXPLICIT COLUMN LISTS ──────────────────────────────────────────
# After ensure_columns, source ⊆ NAS for every synced table, so source's
# column list is a safe subset to use on both sides of the INSERT.
# For tables that JOIN frames (ocr_text, elements), the SELECT side needs
# alias-qualified columns because both tables share names (app_name, etc).
FRAMES_COLS=$(build_col_list frames)
ELEMENTS_COLS=$(build_col_list elements)
ELEMENTS_COLS_E=$(build_col_list elements e)
UI_EVENTS_COLS=$(build_col_list ui_events)
OCR_TEXT_COLS=$(build_col_list ocr_text)
OCR_TEXT_COLS_O=$(build_col_list ocr_text o)
VIDEO_CHUNKS_COLS=$(build_col_list video_chunks)
MEETINGS_COLS=$(build_col_list meetings)
# ─── SYNC DATA ────────────────────────────────────────────────────────────
step "Syncing data for $TARGET_DATE"
run_sqlite_heredoc "video_chunks" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.video_chunks ($VIDEO_CHUNKS_COLS)
SELECT $VIDEO_CHUNKS_COLS FROM main.video_chunks
WHERE id IN (
SELECT DISTINCT video_chunk_id FROM main.frames
WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL
);
DETACH nas;
"
run_sqlite_heredoc "frames ($SRC_FRAMES rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.frames ($FRAMES_COLS)
SELECT $FRAMES_COLS FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ocr_text ($SRC_OCR rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ocr_text ($OCR_TEXT_COLS)
SELECT $OCR_TEXT_COLS_O FROM main.ocr_text o
JOIN main.frames f ON o.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ui_events ($SRC_UI rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ui_events ($UI_EVENTS_COLS)
SELECT $UI_EVENTS_COLS FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "elements ($SRC_ELEMENTS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.elements ($ELEMENTS_COLS)
SELECT $ELEMENTS_COLS_E FROM main.elements e
JOIN main.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "meetings ($SRC_MEETINGS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.meetings ($MEETINGS_COLS)
SELECT $MEETINGS_COLS FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';
DETACH nas;
"
# ─── FTS UPDATE ───────────────────────────────────────────────────────────
step "Updating FTS indexes"
run_sqlite_heredoc "elements_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.elements_fts(rowid, text, role)
SELECT e.id, e.text, e.role
FROM nas.elements e
JOIN nas.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE'
AND e.text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "frames_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)
SELECT id, full_text, app_name, window_name, browser_url, id
FROM nas.frames
WHERE date(timestamp) = '$TARGET_DATE'
AND full_text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "ui_events_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)
SELECT id, text_content, app_name, window_title, element_name
FROM nas.ui_events
WHERE date(timestamp) = '$TARGET_DATE'
AND text_content IS NOT NULL;
DETACH nas;
"
# ─── VERIFY DB ────────────────────────────────────────────────────────────
step "Verifying DB"
V_FRAMES=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
V_ELEMENTS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_UI=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
V_OCR=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_MEETINGS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';")
check "frames" "$V_FRAMES" "$SRC_FRAMES"
check "elements" "$V_ELEMENTS" "$SRC_ELEMENTS"
check "ui_events" "$V_UI" "$SRC_UI"
check "ocr_text" "$V_OCR" "$SRC_OCR"
check "meetings" "$V_MEETINGS" "$SRC_MEETINGS"
fi
# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────
# Always runs regardless of DB sync status
step "Copying data folder for $TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
mkdir -p "$NAS_DATA/$TARGET_DATE"
RSYNC_START=$(date +%s)
printf " %-36s " "rsync $TARGET_DATE/ → NAS"
rsync -a --ignore-existing \
"$DATA_SRC/" \
"$NAS_DATA/$TARGET_DATE/" \
2>>"$LOG_FILE"
RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))
COPIED_FILES=$(ls "$NAS_DATA/$TARGET_DATE" | wc -l | tr -d ' ')
SRC_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
COPIED_SIZE=$(du -sh "$NAS_DATA/$TARGET_DATE" | cut -f1)
if [ "$COPIED_FILES" -eq "$SRC_FILES" ]; then
printf "\r %-36s ✓ %dm%02ds (%s files, %s)\n" \
"rsync $TARGET_DATE/ → NAS" \
"$(( RSYNC_DUR / 60 ))" "$(( RSYNC_DUR % 60 ))" \
"$COPIED_FILES" "$COPIED_SIZE" | tee -a "$LOG_FILE"
else
printf "\r %-36s ✗ %s / %s files\n" \
"rsync $TARGET_DATE/ → NAS" "$COPIED_FILES" "$SRC_FILES" | tee -a "$LOG_FILE"
fi
else
printf " %-36s %s\n" "rsync $TARGET_DATE/ → NAS" "skipped (no source dir)"
fi
# ─── COPY LOGS ────────────────────────────────────────────────────────────────
# Screenpipe writes daily logs to ~/.screenpipe/screenpipe.YYYY-MM-DD.N.log
# (N is a rotation counter, almost always 0). Mirror them to NAS so log
# analysis can happen on the consumer side without SSH'ing back to the Mac.
step "Copying screenpipe logs for $TARGET_DATE"
NAS_LOGS="$NAS_MOUNT/logs"
mkdir -p "$NAS_LOGS"
# Use a glob with nullglob so an empty match doesn't expand to a literal pattern.
shopt -s nullglob
LOG_FILES=( "$HOME/.screenpipe/screenpipe.$TARGET_DATE."*.log )
shopt -u nullglob
if [ ${#LOG_FILES[@]} -gt 0 ]; then
printf " %-36s " "rsync logs → NAS"
# No --ignore-existing here: logs grow during the day, so we want rsync's
# default size+mtime check to refresh files that have changed.
rsync -a "${LOG_FILES[@]}" "$NAS_LOGS/" 2>>"$LOG_FILE"
COPIED=${#LOG_FILES[@]}
TOTAL_SIZE=$(du -ch "${LOG_FILES[@]}" | tail -1 | cut -f1)
printf "✓ %d file(s), %s\n" "$COPIED" "$TOTAL_SIZE" | tee -a "$LOG_FILE"
else
printf " %-36s %s\n" "rsync logs → NAS" "skipped (no matching logs)"
fi
# ─── SUMMARY ──────────────────────────────────────────────────────────────────
TOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))
DB_SIZE=$(du -sh "$NAS_DB" | cut -f1)
echo ""
log "Archive DB size: $DB_SIZE"
log "Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s"
log "Sync complete for $TARGET_DATE"
log "========================================"
# Mirror this script's own logbook to NAS so sync health can be monitored
# from the consumer side. Done last so the summary lines above are included.
rsync -a "$HOME/.screenpipe/sync.log" "$NAS_LOGS/sync.log" 2>/dev/null || true
Implement and run pipe l…, Editor Group 2
Problems (⇧⌘M)
PROBLEMS
Output (⇧⌘U)
OUTPUT
Debug Console (⇧⌘Y)
DEBUG CONSOLE
Terminal (⌃`)
TERMINAL
Ports - 1 forwarded port
PORTS
1
remote SSH: nas
...
|
[{"role":"AXRadioButton","text [{"role":"AXRadioButton","text":"Explorer (⇧⌘E) - 1 unsaved file","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":true},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Search (⇧⌘F)","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Source Control (⌃⇧G) - 10 pending changes","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"10","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Run and Debug (⇧⌘D)","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Remote Explorer","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Extensions (⇧⌘X) - 2 require update","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"2","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Claude Code","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"Containers","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXHeading","text":"EXPLORER","depth":17,"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"EXPLORER","depth":18,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Explorer Section: screenpipe [SSH: nas]","depth":21,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":true},{"role":"AXStaticText","text":"","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"Explorer Section: screenpipe [SSH: nas]","depth":22,"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"SCREENPIPE [SSH: NAS]","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"#recycle","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"app","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"__pycache__","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"consumers","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"static","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":".env","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"cli.py","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.py","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"docker-compose.yml","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Dockerfile","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"main.py","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"requirements.txt","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"data","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"logs","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"pipes","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":".gitignore","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"app_settings.json","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"archive.db","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"archive.db-bak","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"U","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite-shm","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite-wal","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe_sync_updated.sh","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"U","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe_sync.sh","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe.db","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Outline Section","depth":21,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"OUTLINE","depth":22,"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"OUTLINE","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Timeline Section","depth":21,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"TIMELINE","depth":22,"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"TIMELINE","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"app_settings.json, Editor Group 1","depth":28,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"screenpipe_sync.sh, Editor Group 1","depth":28,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":false},{"role":"AXRadioButton","text":"pipe.md, Editor Group 1","depth":28,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":".env, Editor Group 1","depth":28,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"#!/bin/bash\n# screenpipe_sync.sh\n# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).\n# Also copies the day's video/frame data folder to the NAS.\n#\n# Schema-drift tolerant: if Screenpipe migrations add new columns to the source DB,\n# the NAS archive gets ALTER TABLE'd to match. Inserts use explicit column lists,\n# so positional mismatches can't occur.\n#\n# Usage:\n# ./screenpipe_sync.sh # syncs yesterday (default)\n# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date\n# ./screenpipe_sync.sh today # syncs today so far\n#\n# Cron example (runs at 3am daily):\n# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1\n\nset -euo pipefail\n\n# ─── CONFIG ───────────────────────────────────────────────────────────────────\nDB_SRC=\"${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}\"\nNAS_MOUNT=\"${NAS_MOUNT:-/Volumes/screenpipe}\"\nNAS_DB=\"$NAS_MOUNT/archive.db\"\nNAS_DATA=\"$NAS_MOUNT/data\"\nLOG_FILE=\"$HOME/.screenpipe/sync.log\"\n# Tables that get schema drift handling. Order matters for FK-ish references\n# (parents before children: video_chunks → frames → elements/ocr_text/ui_events).\nSYNC_TABLES=(video_chunks frames elements ocr_text ui_events meetings)\n# ──────────────────────────────────────────────────────────────────────────────\n\n# ─── HELPERS ──────────────────────────────────────────────────────────────────\nSCRIPT_START=$(date +%s)\n\nlog() {\n local msg=\"[$(date '+%Y-%m-%d %H:%M:%S')] $*\"\n echo \"$msg\" | tee -a \"$LOG_FILE\"\n}\n\nstep() {\n local now=$(date +%s)\n local elapsed=$(( now - SCRIPT_START ))\n local min=$(( elapsed / 60 ))\n local sec=$(( elapsed % 60 ))\n printf \"\\n[+%02dm%02ds] ▶ %s\\n\" \"$min\" \"$sec\" \"$*\" | tee -a \"$LOG_FILE\"\n}\n\nrun_sqlite_heredoc() {\n local label=\"$1\"\n local sql=\"$2\"\n local start=$(date +%s)\n\n printf \" %-36s \" \"$label\"\n\n sqlite3 \"$DB_SRC\" <<< \"$sql\" &\n local pid=$!\n local spin=('⠋' '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')\n local i=0\n while kill -0 \"$pid\" 2>/dev/null; do\n printf \"\\r %-36s %s \" \"$label\" \"${spin[$i]}\"\n i=$(( (i + 1) % 10 ))\n sleep 0.2\n done\n wait \"$pid\"\n local rc=$?\n if [ $rc -ne 0 ]; then\n printf \"\\r %-36s ✗ FAILED\\n\" \"$label\" | tee -a \"$LOG_FILE\"\n exit $rc\n fi\n\n local dur=$(( $(date +%s) - start ))\n printf \"\\r %-36s ✓ %dm%02ds\\n\" \"$label\" \"$(( dur / 60 ))\" \"$(( dur % 60 ))\" | tee -a \"$LOG_FILE\"\n}\n\ncheck() {\n local label=\"$1\" got=\"$2\" expected=\"$3\"\n if [ \"$got\" -eq \"$expected\" ]; then\n printf \" %-20s %s / %s ✓\\n\" \"$label:\" \"$got\" \"$expected\"\n else\n printf \" %-20s %s / %s ✗ MISMATCH\\n\" \"$label:\" \"$got\" \"$expected\"\n fi\n}\n\n# ─── SCHEMA HELPERS ───────────────────────────────────────────────────────────\n# Echoes \"name|type\" lines for a table from a given DB.\ntable_columns_with_types() {\n local db=\"$1\" table=\"$2\"\n sqlite3 \"$db\" \"PRAGMA table_info($table);\" | awk -F'|' '{print $2 \"|\" $3}'\n}\n\n# Echoes just column names, one per line.\ntable_columns() {\n local db=\"$1\" table=\"$2\"\n sqlite3 \"$db\" \"PRAGMA table_info($table);\" | awk -F'|' '{print $2}'\n}\n\n# Returns true (0) if a table exists in the given DB.\ntable_exists() {\n local db=\"$1\" table=\"$2\"\n local count\n count=$(sqlite3 \"$db\" \"SELECT COUNT(*) FROM sqlite_master WHERE type='table' AND name='$table';\")\n [ \"$count\" -gt 0 ]\n}\n\n# Adds any columns present in source but missing in NAS for the given table.\n# Uses ALTER TABLE ADD COLUMN, which is a fast metadata-only operation in SQLite.\nensure_columns() {\n local table=\"$1\"\n local label=\"schema: $table\"\n printf \" %-36s \" \"$label\"\n\n if ! table_exists \"$DB_SRC\" \"$table\"; then\n printf \"✗ source missing — skipping\\n\"\n return 0\n fi\n\n if ! table_exists \"$NAS_DB\" \"$table\"; then\n printf \"✓ fresh (created above)\\n\"\n return 0\n fi\n\n local src_cols\n src_cols=$(table_columns_with_types \"$DB_SRC\" \"$table\")\n local nas_cols\n nas_cols=$(table_columns \"$NAS_DB\" \"$table\")\n\n local added=0\n local added_names=\"\"\n while IFS='|' read -r name type; do\n [ -z \"$name\" ] && continue\n # Use grep -F -x for fixed-string exact match (safe against regex chars).\n if ! echo \"$nas_cols\" | grep -Fxq \"$name\"; then\n # SQLite ALTER TABLE ADD COLUMN: type is optional, no NOT NULL allowed\n # without a constant default. Default-NULL is exactly what we want for archive.\n sqlite3 \"$NAS_DB\" \"ALTER TABLE $table ADD COLUMN \\\"$name\\\" $type;\"\n added=$((added + 1))\n added_names=\"$added_names $name\"\n fi\n done <<< \"$src_cols\"\n\n if [ \"$added\" -gt 0 ]; then\n printf \"✓ added %d:%s\\n\" \"$added\" \"$added_names\"\n else\n printf \"✓ in sync\\n\"\n fi\n}\n\n# Echoes a comma-separated list of source columns for a table, double-quoted\n# so reserved words and hyphens are safe. If an alias is provided, columns are\n# prefixed (e.g. `o.\"col\"`). Used for both INSERT and SELECT sides; aliased\n# form is required when SELECTing from a JOIN where column names collide\n# (e.g. ocr_text and frames both have app_name, window_name).\nbuild_col_list() {\n local table=\"$1\"\n local alias=\"${2:-}\"\n local prefix=\"\"\n [ -n \"$alias\" ] && prefix=\"${alias}.\"\n table_columns \"$DB_SRC\" \"$table\" | awk 'NF' | awk -v p=\"$prefix\" '{print p \"\\\"\" $0 \"\\\"\"}' | paste -sd, -\n}\n# ──────────────────────────────────────────────────────────────────────────────\n\n# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────\nif [ \"${1:-}\" = \"today\" ]; then\n TARGET_DATE=$(date +%Y-%m-%d)\nelif [ -n \"${1:-}\" ]; then\n TARGET_DATE=\"$1\"\n if ! [[ \"$TARGET_DATE\" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then\n echo \"ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday.\"\n exit 1\n fi\nelse\n TARGET_DATE=$(date -v-1d +%Y-%m-%d)\nfi\n\nlog \"========================================\"\nlog \"Screenpipe sync starting for: $TARGET_DATE\"\nlog \"========================================\"\n\n# ─── PREFLIGHT ────────────────────────────────────────────────────────────────\nstep \"Preflight checks\"\n\nif [ ! -f \"$DB_SRC\" ]; then\n log \"ERROR: Source DB not found at $DB_SRC\"; exit 1\nfi\nprintf \" %-20s %s (%s)\\n\" \"Source DB:\" \"OK\" \"$(du -sh \"$DB_SRC\" | cut -f1)\"\n\nif [ ! -d \"$NAS_MOUNT\" ]; then\n log \"ERROR: NAS not mounted at $NAS_MOUNT\"; exit 1\nfi\nprintf \" %-20s %s\\n\" \"NAS mount:\" \"OK $NAS_MOUNT\"\n\n# Check if DB already synced for this date\nDB_ALREADY_SYNCED=false\nif [ -f \"$NAS_DB\" ]; then\n if table_exists \"$NAS_DB\" \"frames\"; then\n EXISTING=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\" 2>/dev/null || echo \"0\")\n if [ \"$EXISTING\" -gt \"0\" ]; then\n log \"Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync\"\n DB_ALREADY_SYNCED=true\n else\n printf \" %-20s %s (%s)\\n\" \"Archive DB:\" \"exists\" \"$(du -sh \"$NAS_DB\" | cut -f1)\"\n fi\n else\n printf \" %-20s %s\\n\" \"Archive DB:\" \"exists, no frames table yet\"\n fi\nelse\n printf \" %-20s %s\\n\" \"Archive DB:\" \"will be created\"\nfi\n\n# Source data dir for this date\nDATA_SRC=\"$HOME/.screenpipe/data/data/$TARGET_DATE\"\nif [ -d \"$DATA_SRC\" ]; then\n DATA_SIZE=$(du -sh \"$DATA_SRC\" | cut -f1)\n DATA_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n printf \" %-20s %s (%s files, %s)\\n\" \"Data dir:\" \"OK\" \"$DATA_FILES\" \"$DATA_SIZE\"\nelse\n printf \" %-20s %s\\n\" \"Data dir:\" \"not found — skipping file copy\"\nfi\n\n# ─── DB SYNC ──────────────────────────────────────────────────────────────────\nif [ \"$DB_ALREADY_SYNCED\" = false ]; then\n\n # ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────\n step \"Counting source rows for $TARGET_DATE\"\n\n SRC_FRAMES=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\")\n SRC_ELEMENTS=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n SRC_UI=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';\")\n SRC_OCR=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n SRC_MEETINGS=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';\")\n\n printf \" %-20s %s\\n\" \"frames:\" \"$SRC_FRAMES\"\n printf \" %-20s %s\\n\" \"elements:\" \"$SRC_ELEMENTS\"\n printf \" %-20s %s\\n\" \"ui_events:\" \"$SRC_UI\"\n printf \" %-20s %s\\n\" \"ocr_text:\" \"$SRC_OCR\"\n printf \" %-20s %s\\n\" \"meetings:\" \"$SRC_MEETINGS\"\n\n if [ \"$SRC_FRAMES\" -eq \"0\" ]; then\n log \"No frames found for $TARGET_DATE — skipping DB sync\"\n DB_ALREADY_SYNCED=true\n fi\n\nfi\n\nif [ \"$DB_ALREADY_SYNCED\" = false ]; then\n\n # ─── INIT TABLES ──────────────────────────────────────────────────────────\n step \"Initialising tables (CREATE IF NOT EXISTS)\"\n\n run_sqlite_heredoc \"creating tables\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;\nDETACH nas;\n\"\n\n # ─── SCHEMA DRIFT FIX ─────────────────────────────────────────────────────\n # Runs AFTER CREATE IF NOT EXISTS so newly-created tables are no-ops here,\n # and pre-existing tables get any missing columns added.\n step \"Reconciling NAS schema with source\"\n for tbl in \"${SYNC_TABLES[@]}\"; do\n ensure_columns \"$tbl\"\n done\n\n run_sqlite_heredoc \"creating indexes\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_document_path ON frames(document_path) WHERE document_path IS NOT NULL;\nCREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;\nCREATE INDEX IF NOT EXISTS nas.idx_elements_onscreen_frame ON elements(frame_id) WHERE on_screen = 1 AND text IS NOT NULL;\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);\nCREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"creating FTS tables\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(\n text, role, frame_id UNINDEXED,\n content='elements', content_rowid='id', tokenize='unicode61'\n);\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(\n full_text, app_name, window_name, browser_url, id UNINDEXED,\n tokenize='unicode61'\n);\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(\n text_content,\n app_name,\n window_title,\n element_name,\n content='ui_events',\n content_rowid='id',\n tokenize='unicode61'\n);\nDETACH nas;\n\"\n\n # ─── BUILD EXPLICIT COLUMN LISTS ──────────────────────────────────────────\n # After ensure_columns, source ⊆ NAS for every synced table, so source's\n # column list is a safe subset to use on both sides of the INSERT.\n # For tables that JOIN frames (ocr_text, elements), the SELECT side needs\n # alias-qualified columns because both tables share names (app_name, etc).\n FRAMES_COLS=$(build_col_list frames)\n ELEMENTS_COLS=$(build_col_list elements)\n ELEMENTS_COLS_E=$(build_col_list elements e)\n UI_EVENTS_COLS=$(build_col_list ui_events)\n OCR_TEXT_COLS=$(build_col_list ocr_text)\n OCR_TEXT_COLS_O=$(build_col_list ocr_text o)\n VIDEO_CHUNKS_COLS=$(build_col_list video_chunks)\n MEETINGS_COLS=$(build_col_list meetings)\n\n # ─── SYNC DATA ────────────────────────────────────────────────────────────\n step \"Syncing data for $TARGET_DATE\"\n\n run_sqlite_heredoc \"video_chunks\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.video_chunks ($VIDEO_CHUNKS_COLS)\n SELECT $VIDEO_CHUNKS_COLS FROM main.video_chunks\n WHERE id IN (\n SELECT DISTINCT video_chunk_id FROM main.frames\n WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL\n );\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames ($SRC_FRAMES rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.frames ($FRAMES_COLS)\n SELECT $FRAMES_COLS FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ocr_text ($SRC_OCR rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ocr_text ($OCR_TEXT_COLS)\n SELECT $OCR_TEXT_COLS_O FROM main.ocr_text o\n JOIN main.frames f ON o.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events ($SRC_UI rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ui_events ($UI_EVENTS_COLS)\n SELECT $UI_EVENTS_COLS FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"elements ($SRC_ELEMENTS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.elements ($ELEMENTS_COLS)\n SELECT $ELEMENTS_COLS_E FROM main.elements e\n JOIN main.frames f ON e.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"meetings ($SRC_MEETINGS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.meetings ($MEETINGS_COLS)\n SELECT $MEETINGS_COLS FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n # ─── FTS UPDATE ───────────────────────────────────────────────────────────\n step \"Updating FTS indexes\"\n\n run_sqlite_heredoc \"elements_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.elements_fts(rowid, text, role)\n SELECT e.id, e.text, e.role\n FROM nas.elements e\n JOIN nas.frames f ON e.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE'\n AND e.text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)\n SELECT id, full_text, app_name, window_name, browser_url, id\n FROM nas.frames\n WHERE date(timestamp) = '$TARGET_DATE'\n AND full_text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)\n SELECT id, text_content, app_name, window_title, element_name\n FROM nas.ui_events\n WHERE date(timestamp) = '$TARGET_DATE'\n AND text_content IS NOT NULL;\nDETACH nas;\n\"\n\n # ─── VERIFY DB ────────────────────────────────────────────────────────────\n step \"Verifying DB\"\n\n V_FRAMES=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\")\n V_ELEMENTS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n V_UI=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';\")\n V_OCR=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n V_MEETINGS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';\")\n\n check \"frames\" \"$V_FRAMES\" \"$SRC_FRAMES\"\n check \"elements\" \"$V_ELEMENTS\" \"$SRC_ELEMENTS\"\n check \"ui_events\" \"$V_UI\" \"$SRC_UI\"\n check \"ocr_text\" \"$V_OCR\" \"$SRC_OCR\"\n check \"meetings\" \"$V_MEETINGS\" \"$SRC_MEETINGS\"\n\nfi\n\n# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────\n# Always runs regardless of DB sync status\nstep \"Copying data folder for $TARGET_DATE\"\n\nif [ -d \"$DATA_SRC\" ]; then\n mkdir -p \"$NAS_DATA/$TARGET_DATE\"\n RSYNC_START=$(date +%s)\n printf \" %-36s \" \"rsync $TARGET_DATE/ → NAS\"\n rsync -a --ignore-existing \\\n \"$DATA_SRC/\" \\\n \"$NAS_DATA/$TARGET_DATE/\" \\\n 2>>\"$LOG_FILE\"\n RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))\n COPIED_FILES=$(ls \"$NAS_DATA/$TARGET_DATE\" | wc -l | tr -d ' ')\n SRC_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n COPIED_SIZE=$(du -sh \"$NAS_DATA/$TARGET_DATE\" | cut -f1)\n if [ \"$COPIED_FILES\" -eq \"$SRC_FILES\" ]; then\n printf \"\\r %-36s ✓ %dm%02ds (%s files, %s)\\n\" \\\n \"rsync $TARGET_DATE/ → NAS\" \\\n \"$(( RSYNC_DUR / 60 ))\" \"$(( RSYNC_DUR % 60 ))\" \\\n \"$COPIED_FILES\" \"$COPIED_SIZE\" | tee -a \"$LOG_FILE\"\n else\n printf \"\\r %-36s ✗ %s / %s files\\n\" \\\n \"rsync $TARGET_DATE/ → NAS\" \"$COPIED_FILES\" \"$SRC_FILES\" | tee -a \"$LOG_FILE\"\n fi\nelse\n printf \" %-36s %s\\n\" \"rsync $TARGET_DATE/ → NAS\" \"skipped (no source dir)\"\nfi\n\n# ─── COPY LOGS ────────────────────────────────────────────────────────────────\n# Screenpipe writes daily logs to ~/.screenpipe/screenpipe.YYYY-MM-DD.N.log\n# (N is a rotation counter, almost always 0). Mirror them to NAS so log\n# analysis can happen on the consumer side without SSH'ing back to the Mac.\nstep \"Copying screenpipe logs for $TARGET_DATE\"\n\nNAS_LOGS=\"$NAS_MOUNT/logs\"\nmkdir -p \"$NAS_LOGS\"\n\n# Use a glob with nullglob so an empty match doesn't expand to a literal pattern.\nshopt -s nullglob\nLOG_FILES=( \"$HOME/.screenpipe/screenpipe.$TARGET_DATE.\"*.log )\nshopt -u nullglob\n\nif [ ${#LOG_FILES[@]} -gt 0 ]; then\n printf \" %-36s \" \"rsync logs → NAS\"\n # No --ignore-existing here: logs grow during the day, so we want rsync's\n # default size+mtime check to refresh files that have changed.\n rsync -a \"${LOG_FILES[@]}\" \"$NAS_LOGS/\" 2>>\"$LOG_FILE\"\n COPIED=${#LOG_FILES[@]}\n TOTAL_SIZE=$(du -ch \"${LOG_FILES[@]}\" | tail -1 | cut -f1)\n printf \"✓ %d file(s), %s\\n\" \"$COPIED\" \"$TOTAL_SIZE\" | tee -a \"$LOG_FILE\"\nelse\n printf \" %-36s %s\\n\" \"rsync logs → NAS\" \"skipped (no matching logs)\"\nfi\n\n# ─── SUMMARY ──────────────────────────────────────────────────────────────────\nTOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))\nDB_SIZE=$(du -sh \"$NAS_DB\" | cut -f1)\n\necho \"\"\nlog \"Archive DB size: $DB_SIZE\"\nlog \"Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s\"\nlog \"Sync complete for $TARGET_DATE\"\nlog \"========================================\"\n\n# Mirror this script's own logbook to NAS so sync health can be monitored\n# from the consumer side. Done last so the summary lines above are included.\nrsync -a \"$HOME/.screenpipe/sync.log\" \"$NAS_LOGS/sync.log\" 2>/dev/null || true","depth":28,"on_screen":true,"value":"#!/bin/bash\n# screenpipe_sync.sh\n# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).\n# Also copies the day's video/frame data folder to the NAS.\n#\n# Schema-drift tolerant: if Screenpipe migrations add new columns to the source DB,\n# the NAS archive gets ALTER TABLE'd to match. Inserts use explicit column lists,\n# so positional mismatches can't occur.\n#\n# Usage:\n# ./screenpipe_sync.sh # syncs yesterday (default)\n# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date\n# ./screenpipe_sync.sh today # syncs today so far\n#\n# Cron example (runs at 3am daily):\n# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1\n\nset -euo pipefail\n\n# ─── CONFIG ───────────────────────────────────────────────────────────────────\nDB_SRC=\"${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}\"\nNAS_MOUNT=\"${NAS_MOUNT:-/Volumes/screenpipe}\"\nNAS_DB=\"$NAS_MOUNT/archive.db\"\nNAS_DATA=\"$NAS_MOUNT/data\"\nLOG_FILE=\"$HOME/.screenpipe/sync.log\"\n# Tables that get schema drift handling. Order matters for FK-ish references\n# (parents before children: video_chunks → frames → elements/ocr_text/ui_events).\nSYNC_TABLES=(video_chunks frames elements ocr_text ui_events meetings)\n# ──────────────────────────────────────────────────────────────────────────────\n\n# ─── HELPERS ──────────────────────────────────────────────────────────────────\nSCRIPT_START=$(date +%s)\n\nlog() {\n local msg=\"[$(date '+%Y-%m-%d %H:%M:%S')] $*\"\n echo \"$msg\" | tee -a \"$LOG_FILE\"\n}\n\nstep() {\n local now=$(date +%s)\n local elapsed=$(( now - SCRIPT_START ))\n local min=$(( elapsed / 60 ))\n local sec=$(( elapsed % 60 ))\n printf \"\\n[+%02dm%02ds] ▶ %s\\n\" \"$min\" \"$sec\" \"$*\" | tee -a \"$LOG_FILE\"\n}\n\nrun_sqlite_heredoc() {\n local label=\"$1\"\n local sql=\"$2\"\n local start=$(date +%s)\n\n printf \" %-36s \" \"$label\"\n\n sqlite3 \"$DB_SRC\" <<< \"$sql\" &\n local pid=$!\n local spin=('⠋' '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')\n local i=0\n while kill -0 \"$pid\" 2>/dev/null; do\n printf \"\\r %-36s %s \" \"$label\" \"${spin[$i]}\"\n i=$(( (i + 1) % 10 ))\n sleep 0.2\n done\n wait \"$pid\"\n local rc=$?\n if [ $rc -ne 0 ]; then\n printf \"\\r %-36s ✗ FAILED\\n\" \"$label\" | tee -a \"$LOG_FILE\"\n exit $rc\n fi\n\n local dur=$(( $(date +%s) - start ))\n printf \"\\r %-36s ✓ %dm%02ds\\n\" \"$label\" \"$(( dur / 60 ))\" \"$(( dur % 60 ))\" | tee -a \"$LOG_FILE\"\n}\n\ncheck() {\n local label=\"$1\" got=\"$2\" expected=\"$3\"\n if [ \"$got\" -eq \"$expected\" ]; then\n printf \" %-20s %s / %s ✓\\n\" \"$label:\" \"$got\" \"$expected\"\n else\n printf \" %-20s %s / %s ✗ MISMATCH\\n\" \"$label:\" \"$got\" \"$expected\"\n fi\n}\n\n# ─── SCHEMA HELPERS ───────────────────────────────────────────────────────────\n# Echoes \"name|type\" lines for a table from a given DB.\ntable_columns_with_types() {\n local db=\"$1\" table=\"$2\"\n sqlite3 \"$db\" \"PRAGMA table_info($table);\" | awk -F'|' '{print $2 \"|\" $3}'\n}\n\n# Echoes just column names, one per line.\ntable_columns() {\n local db=\"$1\" table=\"$2\"\n sqlite3 \"$db\" \"PRAGMA table_info($table);\" | awk -F'|' '{print $2}'\n}\n\n# Returns true (0) if a table exists in the given DB.\ntable_exists() {\n local db=\"$1\" table=\"$2\"\n local count\n count=$(sqlite3 \"$db\" \"SELECT COUNT(*) FROM sqlite_master WHERE type='table' AND name='$table';\")\n [ \"$count\" -gt 0 ]\n}\n\n# Adds any columns present in source but missing in NAS for the given table.\n# Uses ALTER TABLE ADD COLUMN, which is a fast metadata-only operation in SQLite.\nensure_columns() {\n local table=\"$1\"\n local label=\"schema: $table\"\n printf \" %-36s \" \"$label\"\n\n if ! table_exists \"$DB_SRC\" \"$table\"; then\n printf \"✗ source missing — skipping\\n\"\n return 0\n fi\n\n if ! table_exists \"$NAS_DB\" \"$table\"; then\n printf \"✓ fresh (created above)\\n\"\n return 0\n fi\n\n local src_cols\n src_cols=$(table_columns_with_types \"$DB_SRC\" \"$table\")\n local nas_cols\n nas_cols=$(table_columns \"$NAS_DB\" \"$table\")\n\n local added=0\n local added_names=\"\"\n while IFS='|' read -r name type; do\n [ -z \"$name\" ] && continue\n # Use grep -F -x for fixed-string exact match (safe against regex chars).\n if ! echo \"$nas_cols\" | grep -Fxq \"$name\"; then\n # SQLite ALTER TABLE ADD COLUMN: type is optional, no NOT NULL allowed\n # without a constant default. Default-NULL is exactly what we want for archive.\n sqlite3 \"$NAS_DB\" \"ALTER TABLE $table ADD COLUMN \\\"$name\\\" $type;\"\n added=$((added + 1))\n added_names=\"$added_names $name\"\n fi\n done <<< \"$src_cols\"\n\n if [ \"$added\" -gt 0 ]; then\n printf \"✓ added %d:%s\\n\" \"$added\" \"$added_names\"\n else\n printf \"✓ in sync\\n\"\n fi\n}\n\n# Echoes a comma-separated list of source columns for a table, double-quoted\n# so reserved words and hyphens are safe. If an alias is provided, columns are\n# prefixed (e.g. `o.\"col\"`). Used for both INSERT and SELECT sides; aliased\n# form is required when SELECTing from a JOIN where column names collide\n# (e.g. ocr_text and frames both have app_name, window_name).\nbuild_col_list() {\n local table=\"$1\"\n local alias=\"${2:-}\"\n local prefix=\"\"\n [ -n \"$alias\" ] && prefix=\"${alias}.\"\n table_columns \"$DB_SRC\" \"$table\" | awk 'NF' | awk -v p=\"$prefix\" '{print p \"\\\"\" $0 \"\\\"\"}' | paste -sd, -\n}\n# ──────────────────────────────────────────────────────────────────────────────\n\n# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────\nif [ \"${1:-}\" = \"today\" ]; then\n TARGET_DATE=$(date +%Y-%m-%d)\nelif [ -n \"${1:-}\" ]; then\n TARGET_DATE=\"$1\"\n if ! [[ \"$TARGET_DATE\" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then\n echo \"ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday.\"\n exit 1\n fi\nelse\n TARGET_DATE=$(date -v-1d +%Y-%m-%d)\nfi\n\nlog \"========================================\"\nlog \"Screenpipe sync starting for: $TARGET_DATE\"\nlog \"========================================\"\n\n# ─── PREFLIGHT ────────────────────────────────────────────────────────────────\nstep \"Preflight checks\"\n\nif [ ! -f \"$DB_SRC\" ]; then\n log \"ERROR: Source DB not found at $DB_SRC\"; exit 1\nfi\nprintf \" %-20s %s (%s)\\n\" \"Source DB:\" \"OK\" \"$(du -sh \"$DB_SRC\" | cut -f1)\"\n\nif [ ! -d \"$NAS_MOUNT\" ]; then\n log \"ERROR: NAS not mounted at $NAS_MOUNT\"; exit 1\nfi\nprintf \" %-20s %s\\n\" \"NAS mount:\" \"OK $NAS_MOUNT\"\n\n# Check if DB already synced for this date\nDB_ALREADY_SYNCED=false\nif [ -f \"$NAS_DB\" ]; then\n if table_exists \"$NAS_DB\" \"frames\"; then\n EXISTING=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\" 2>/dev/null || echo \"0\")\n if [ \"$EXISTING\" -gt \"0\" ]; then\n log \"Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync\"\n DB_ALREADY_SYNCED=true\n else\n printf \" %-20s %s (%s)\\n\" \"Archive DB:\" \"exists\" \"$(du -sh \"$NAS_DB\" | cut -f1)\"\n fi\n else\n printf \" %-20s %s\\n\" \"Archive DB:\" \"exists, no frames table yet\"\n fi\nelse\n printf \" %-20s %s\\n\" \"Archive DB:\" \"will be created\"\nfi\n\n# Source data dir for this date\nDATA_SRC=\"$HOME/.screenpipe/data/data/$TARGET_DATE\"\nif [ -d \"$DATA_SRC\" ]; then\n DATA_SIZE=$(du -sh \"$DATA_SRC\" | cut -f1)\n DATA_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n printf \" %-20s %s (%s files, %s)\\n\" \"Data dir:\" \"OK\" \"$DATA_FILES\" \"$DATA_SIZE\"\nelse\n printf \" %-20s %s\\n\" \"Data dir:\" \"not found — skipping file copy\"\nfi\n\n# ─── DB SYNC ──────────────────────────────────────────────────────────────────\nif [ \"$DB_ALREADY_SYNCED\" = false ]; then\n\n # ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────\n step \"Counting source rows for $TARGET_DATE\"\n\n SRC_FRAMES=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\")\n SRC_ELEMENTS=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n SRC_UI=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';\")\n SRC_OCR=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n SRC_MEETINGS=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';\")\n\n printf \" %-20s %s\\n\" \"frames:\" \"$SRC_FRAMES\"\n printf \" %-20s %s\\n\" \"elements:\" \"$SRC_ELEMENTS\"\n printf \" %-20s %s\\n\" \"ui_events:\" \"$SRC_UI\"\n printf \" %-20s %s\\n\" \"ocr_text:\" \"$SRC_OCR\"\n printf \" %-20s %s\\n\" \"meetings:\" \"$SRC_MEETINGS\"\n\n if [ \"$SRC_FRAMES\" -eq \"0\" ]; then\n log \"No frames found for $TARGET_DATE — skipping DB sync\"\n DB_ALREADY_SYNCED=true\n fi\n\nfi\n\nif [ \"$DB_ALREADY_SYNCED\" = false ]; then\n\n # ─── INIT TABLES ──────────────────────────────────────────────────────────\n step \"Initialising tables (CREATE IF NOT EXISTS)\"\n\n run_sqlite_heredoc \"creating tables\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;\nDETACH nas;\n\"\n\n # ─── SCHEMA DRIFT FIX ─────────────────────────────────────────────────────\n # Runs AFTER CREATE IF NOT EXISTS so newly-created tables are no-ops here,\n # and pre-existing tables get any missing columns added.\n step \"Reconciling NAS schema with source\"\n for tbl in \"${SYNC_TABLES[@]}\"; do\n ensure_columns \"$tbl\"\n done\n\n run_sqlite_heredoc \"creating indexes\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_document_path ON frames(document_path) WHERE document_path IS NOT NULL;\nCREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;\nCREATE INDEX IF NOT EXISTS nas.idx_elements_onscreen_frame ON elements(frame_id) WHERE on_screen = 1 AND text IS NOT NULL;\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);\nCREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"creating FTS tables\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(\n text, role, frame_id UNINDEXED,\n content='elements', content_rowid='id', tokenize='unicode61'\n);\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(\n full_text, app_name, window_name, browser_url, id UNINDEXED,\n tokenize='unicode61'\n);\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(\n text_content,\n app_name,\n window_title,\n element_name,\n content='ui_events',\n content_rowid='id',\n tokenize='unicode61'\n);\nDETACH nas;\n\"\n\n # ─── BUILD EXPLICIT COLUMN LISTS ──────────────────────────────────────────\n # After ensure_columns, source ⊆ NAS for every synced table, so source's\n # column list is a safe subset to use on both sides of the INSERT.\n # For tables that JOIN frames (ocr_text, elements), the SELECT side needs\n # alias-qualified columns because both tables share names (app_name, etc).\n FRAMES_COLS=$(build_col_list frames)\n ELEMENTS_COLS=$(build_col_list elements)\n ELEMENTS_COLS_E=$(build_col_list elements e)\n UI_EVENTS_COLS=$(build_col_list ui_events)\n OCR_TEXT_COLS=$(build_col_list ocr_text)\n OCR_TEXT_COLS_O=$(build_col_list ocr_text o)\n VIDEO_CHUNKS_COLS=$(build_col_list video_chunks)\n MEETINGS_COLS=$(build_col_list meetings)\n\n # ─── SYNC DATA ────────────────────────────────────────────────────────────\n step \"Syncing data for $TARGET_DATE\"\n\n run_sqlite_heredoc \"video_chunks\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.video_chunks ($VIDEO_CHUNKS_COLS)\n SELECT $VIDEO_CHUNKS_COLS FROM main.video_chunks\n WHERE id IN (\n SELECT DISTINCT video_chunk_id FROM main.frames\n WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL\n );\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames ($SRC_FRAMES rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.frames ($FRAMES_COLS)\n SELECT $FRAMES_COLS FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ocr_text ($SRC_OCR rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ocr_text ($OCR_TEXT_COLS)\n SELECT $OCR_TEXT_COLS_O FROM main.ocr_text o\n JOIN main.frames f ON o.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events ($SRC_UI rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ui_events ($UI_EVENTS_COLS)\n SELECT $UI_EVENTS_COLS FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"elements ($SRC_ELEMENTS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.elements ($ELEMENTS_COLS)\n SELECT $ELEMENTS_COLS_E FROM main.elements e\n JOIN main.frames f ON e.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"meetings ($SRC_MEETINGS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.meetings ($MEETINGS_COLS)\n SELECT $MEETINGS_COLS FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n # ─── FTS UPDATE ───────────────────────────────────────────────────────────\n step \"Updating FTS indexes\"\n\n run_sqlite_heredoc \"elements_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.elements_fts(rowid, text, role)\n SELECT e.id, e.text, e.role\n FROM nas.elements e\n JOIN nas.frames f ON e.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE'\n AND e.text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)\n SELECT id, full_text, app_name, window_name, browser_url, id\n FROM nas.frames\n WHERE date(timestamp) = '$TARGET_DATE'\n AND full_text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)\n SELECT id, text_content, app_name, window_title, element_name\n FROM nas.ui_events\n WHERE date(timestamp) = '$TARGET_DATE'\n AND text_content IS NOT NULL;\nDETACH nas;\n\"\n\n # ─── VERIFY DB ────────────────────────────────────────────────────────────\n step \"Verifying DB\"\n\n V_FRAMES=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\")\n V_ELEMENTS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n V_UI=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';\")\n V_OCR=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n V_MEETINGS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';\")\n\n check \"frames\" \"$V_FRAMES\" \"$SRC_FRAMES\"\n check \"elements\" \"$V_ELEMENTS\" \"$SRC_ELEMENTS\"\n check \"ui_events\" \"$V_UI\" \"$SRC_UI\"\n check \"ocr_text\" \"$V_OCR\" \"$SRC_OCR\"\n check \"meetings\" \"$V_MEETINGS\" \"$SRC_MEETINGS\"\n\nfi\n\n# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────\n# Always runs regardless of DB sync status\nstep \"Copying data folder for $TARGET_DATE\"\n\nif [ -d \"$DATA_SRC\" ]; then\n mkdir -p \"$NAS_DATA/$TARGET_DATE\"\n RSYNC_START=$(date +%s)\n printf \" %-36s \" \"rsync $TARGET_DATE/ → NAS\"\n rsync -a --ignore-existing \\\n \"$DATA_SRC/\" \\\n \"$NAS_DATA/$TARGET_DATE/\" \\\n 2>>\"$LOG_FILE\"\n RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))\n COPIED_FILES=$(ls \"$NAS_DATA/$TARGET_DATE\" | wc -l | tr -d ' ')\n SRC_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n COPIED_SIZE=$(du -sh \"$NAS_DATA/$TARGET_DATE\" | cut -f1)\n if [ \"$COPIED_FILES\" -eq \"$SRC_FILES\" ]; then\n printf \"\\r %-36s ✓ %dm%02ds (%s files, %s)\\n\" \\\n \"rsync $TARGET_DATE/ → NAS\" \\\n \"$(( RSYNC_DUR / 60 ))\" \"$(( RSYNC_DUR % 60 ))\" \\\n \"$COPIED_FILES\" \"$COPIED_SIZE\" | tee -a \"$LOG_FILE\"\n else\n printf \"\\r %-36s ✗ %s / %s files\\n\" \\\n \"rsync $TARGET_DATE/ → NAS\" \"$COPIED_FILES\" \"$SRC_FILES\" | tee -a \"$LOG_FILE\"\n fi\nelse\n printf \" %-36s %s\\n\" \"rsync $TARGET_DATE/ → NAS\" \"skipped (no source dir)\"\nfi\n\n# ─── COPY LOGS ────────────────────────────────────────────────────────────────\n# Screenpipe writes daily logs to ~/.screenpipe/screenpipe.YYYY-MM-DD.N.log\n# (N is a rotation counter, almost always 0). Mirror them to NAS so log\n# analysis can happen on the consumer side without SSH'ing back to the Mac.\nstep \"Copying screenpipe logs for $TARGET_DATE\"\n\nNAS_LOGS=\"$NAS_MOUNT/logs\"\nmkdir -p \"$NAS_LOGS\"\n\n# Use a glob with nullglob so an empty match doesn't expand to a literal pattern.\nshopt -s nullglob\nLOG_FILES=( \"$HOME/.screenpipe/screenpipe.$TARGET_DATE.\"*.log )\nshopt -u nullglob\n\nif [ ${#LOG_FILES[@]} -gt 0 ]; then\n printf \" %-36s \" \"rsync logs → NAS\"\n # No --ignore-existing here: logs grow during the day, so we want rsync's\n # default size+mtime check to refresh files that have changed.\n rsync -a \"${LOG_FILES[@]}\" \"$NAS_LOGS/\" 2>>\"$LOG_FILE\"\n COPIED=${#LOG_FILES[@]}\n TOTAL_SIZE=$(du -ch \"${LOG_FILES[@]}\" | tail -1 | cut -f1)\n printf \"✓ %d file(s), %s\\n\" \"$COPIED\" \"$TOTAL_SIZE\" | tee -a \"$LOG_FILE\"\nelse\n printf \" %-36s %s\\n\" \"rsync logs → NAS\" \"skipped (no matching logs)\"\nfi\n\n# ─── SUMMARY ──────────────────────────────────────────────────────────────────\nTOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))\nDB_SIZE=$(du -sh \"$NAS_DB\" | cut -f1)\n\necho \"\"\nlog \"Archive DB size: $DB_SIZE\"\nlog \"Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s\"\nlog \"Sync complete for $TARGET_DATE\"\nlog \"========================================\"\n\n# Mirror this script's own logbook to NAS so sync health can be monitored\n# from the consumer side. Done last so the summary lines above are included.\nrsync -a \"$HOME/.screenpipe/sync.log\" \"$NAS_LOGS/sync.log\" 2>/dev/null || true","role_description":"editor","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"#!/bin/bash\n# screenpipe_sync.sh\n# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).\n# Also copies the day's video/frame data folder to the NAS.\n#\n# Schema-drift tolerant: if Screenpipe migrations add new columns to the source DB,\n# the NAS archive gets ALTER TABLE'd to match. Inserts use explicit column lists,\n# so positional mismatches can't occur.\n#\n# Usage:\n# ./screenpipe_sync.sh # syncs yesterday (default)\n# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date\n# ./screenpipe_sync.sh today # syncs today so far\n#\n# Cron example (runs at 3am daily):\n# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1\n\nset -euo pipefail\n\n# ─── CONFIG ───────────────────────────────────────────────────────────────────\nDB_SRC=\"${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}\"\nNAS_MOUNT=\"${NAS_MOUNT:-/Volumes/screenpipe}\"\nNAS_DB=\"$NAS_MOUNT/archive.db\"\nNAS_DATA=\"$NAS_MOUNT/data\"\nLOG_FILE=\"$HOME/.screenpipe/sync.log\"\n# Tables that get schema drift handling. Order matters for FK-ish references\n# (parents before children: video_chunks → frames → elements/ocr_text/ui_events).\nSYNC_TABLES=(video_chunks frames elements ocr_text ui_events meetings)\n# ──────────────────────────────────────────────────────────────────────────────\n\n# ─── HELPERS ──────────────────────────────────────────────────────────────────\nSCRIPT_START=$(date +%s)\n\nlog() {\n local msg=\"[$(date '+%Y-%m-%d %H:%M:%S')] $*\"\n echo \"$msg\" | tee -a \"$LOG_FILE\"\n}\n\nstep() {\n local now=$(date +%s)\n local elapsed=$(( now - SCRIPT_START ))\n local min=$(( elapsed / 60 ))\n local sec=$(( elapsed % 60 ))\n printf \"\\n[+%02dm%02ds] ▶ %s\\n\" \"$min\" \"$sec\" \"$*\" | tee -a \"$LOG_FILE\"\n}\n\nrun_sqlite_heredoc() {\n local label=\"$1\"\n local sql=\"$2\"\n local start=$(date +%s)\n\n printf \" %-36s \" \"$label\"\n\n sqlite3 \"$DB_SRC\" <<< \"$sql\" &\n local pid=$!\n local spin=('⠋' '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')\n local i=0\n while kill -0 \"$pid\" 2>/dev/null; do\n printf \"\\r %-36s %s \" \"$label\" \"${spin[$i]}\"\n i=$(( (i + 1) % 10 ))\n sleep 0.2\n done\n wait \"$pid\"\n local rc=$?\n if [ $rc -ne 0 ]; then\n printf \"\\r %-36s ✗ FAILED\\n\" \"$label\" | tee -a \"$LOG_FILE\"\n exit $rc\n fi\n\n local dur=$(( $(date +%s) - start ))\n printf \"\\r %-36s ✓ %dm%02ds\\n\" \"$label\" \"$(( dur / 60 ))\" \"$(( dur % 60 ))\" | tee -a \"$LOG_FILE\"\n}\n\ncheck() {\n local label=\"$1\" got=\"$2\" expected=\"$3\"\n if [ \"$got\" -eq \"$expected\" ]; then\n printf \" %-20s %s / %s ✓\\n\" \"$label:\" \"$got\" \"$expected\"\n else\n printf \" %-20s %s / %s ✗ MISMATCH\\n\" \"$label:\" \"$got\" \"$expected\"\n fi\n}\n\n# ─── SCHEMA HELPERS ───────────────────────────────────────────────────────────\n# Echoes \"name|type\" lines for a table from a given DB.\ntable_columns_with_types() {\n local db=\"$1\" table=\"$2\"\n sqlite3 \"$db\" \"PRAGMA table_info($table);\" | awk -F'|' '{print $2 \"|\" $3}'\n}\n\n# Echoes just column names, one per line.\ntable_columns() {\n local db=\"$1\" table=\"$2\"\n sqlite3 \"$db\" \"PRAGMA table_info($table);\" | awk -F'|' '{print $2}'\n}\n\n# Returns true (0) if a table exists in the given DB.\ntable_exists() {\n local db=\"$1\" table=\"$2\"\n local count\n count=$(sqlite3 \"$db\" \"SELECT COUNT(*) FROM sqlite_master WHERE type='table' AND name='$table';\")\n [ \"$count\" -gt 0 ]\n}\n\n# Adds any columns present in source but missing in NAS for the given table.\n# Uses ALTER TABLE ADD COLUMN, which is a fast metadata-only operation in SQLite.\nensure_columns() {\n local table=\"$1\"\n local label=\"schema: $table\"\n printf \" %-36s \" \"$label\"\n\n if ! table_exists \"$DB_SRC\" \"$table\"; then\n printf \"✗ source missing — skipping\\n\"\n return 0\n fi\n\n if ! table_exists \"$NAS_DB\" \"$table\"; then\n printf \"✓ fresh (created above)\\n\"\n return 0\n fi\n\n local src_cols\n src_cols=$(table_columns_with_types \"$DB_SRC\" \"$table\")\n local nas_cols\n nas_cols=$(table_columns \"$NAS_DB\" \"$table\")\n\n local added=0\n local added_names=\"\"\n while IFS='|' read -r name type; do\n [ -z \"$name\" ] && continue\n # Use grep -F -x for fixed-string exact match (safe against regex chars).\n if ! echo \"$nas_cols\" | grep -Fxq \"$name\"; then\n # SQLite ALTER TABLE ADD COLUMN: type is optional, no NOT NULL allowed\n # without a constant default. Default-NULL is exactly what we want for archive.\n sqlite3 \"$NAS_DB\" \"ALTER TABLE $table ADD COLUMN \\\"$name\\\" $type;\"\n added=$((added + 1))\n added_names=\"$added_names $name\"\n fi\n done <<< \"$src_cols\"\n\n if [ \"$added\" -gt 0 ]; then\n printf \"✓ added %d:%s\\n\" \"$added\" \"$added_names\"\n else\n printf \"✓ in sync\\n\"\n fi\n}\n\n# Echoes a comma-separated list of source columns for a table, double-quoted\n# so reserved words and hyphens are safe. If an alias is provided, columns are\n# prefixed (e.g. `o.\"col\"`). Used for both INSERT and SELECT sides; aliased\n# form is required when SELECTing from a JOIN where column names collide\n# (e.g. ocr_text and frames both have app_name, window_name).\nbuild_col_list() {\n local table=\"$1\"\n local alias=\"${2:-}\"\n local prefix=\"\"\n [ -n \"$alias\" ] && prefix=\"${alias}.\"\n table_columns \"$DB_SRC\" \"$table\" | awk 'NF' | awk -v p=\"$prefix\" '{print p \"\\\"\" $0 \"\\\"\"}' | paste -sd, -\n}\n# ──────────────────────────────────────────────────────────────────────────────\n\n# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────\nif [ \"${1:-}\" = \"today\" ]; then\n TARGET_DATE=$(date +%Y-%m-%d)\nelif [ -n \"${1:-}\" ]; then\n TARGET_DATE=\"$1\"\n if ! [[ \"$TARGET_DATE\" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then\n echo \"ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday.\"\n exit 1\n fi\nelse\n TARGET_DATE=$(date -v-1d +%Y-%m-%d)\nfi\n\nlog \"========================================\"\nlog \"Screenpipe sync starting for: $TARGET_DATE\"\nlog \"========================================\"\n\n# ─── PREFLIGHT ────────────────────────────────────────────────────────────────\nstep \"Preflight checks\"\n\nif [ ! -f \"$DB_SRC\" ]; then\n log \"ERROR: Source DB not found at $DB_SRC\"; exit 1\nfi\nprintf \" %-20s %s (%s)\\n\" \"Source DB:\" \"OK\" \"$(du -sh \"$DB_SRC\" | cut -f1)\"\n\nif [ ! -d \"$NAS_MOUNT\" ]; then\n log \"ERROR: NAS not mounted at $NAS_MOUNT\"; exit 1\nfi\nprintf \" %-20s %s\\n\" \"NAS mount:\" \"OK $NAS_MOUNT\"\n\n# Check if DB already synced for this date\nDB_ALREADY_SYNCED=false\nif [ -f \"$NAS_DB\" ]; then\n if table_exists \"$NAS_DB\" \"frames\"; then\n EXISTING=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\" 2>/dev/null || echo \"0\")\n if [ \"$EXISTING\" -gt \"0\" ]; then\n log \"Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync\"\n DB_ALREADY_SYNCED=true\n else\n printf \" %-20s %s (%s)\\n\" \"Archive DB:\" \"exists\" \"$(du -sh \"$NAS_DB\" | cut -f1)\"\n fi\n else\n printf \" %-20s %s\\n\" \"Archive DB:\" \"exists, no frames table yet\"\n fi\nelse\n printf \" %-20s %s\\n\" \"Archive DB:\" \"will be created\"\nfi\n\n# Source data dir for this date\nDATA_SRC=\"$HOME/.screenpipe/data/data/$TARGET_DATE\"\nif [ -d \"$DATA_SRC\" ]; then\n DATA_SIZE=$(du -sh \"$DATA_SRC\" | cut -f1)\n DATA_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n printf \" %-20s %s (%s files, %s)\\n\" \"Data dir:\" \"OK\" \"$DATA_FILES\" \"$DATA_SIZE\"\nelse\n printf \" %-20s %s\\n\" \"Data dir:\" \"not found — skipping file copy\"\nfi\n\n# ─── DB SYNC ──────────────────────────────────────────────────────────────────\nif [ \"$DB_ALREADY_SYNCED\" = false ]; then\n\n # ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────\n step \"Counting source rows for $TARGET_DATE\"\n\n SRC_FRAMES=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\")\n SRC_ELEMENTS=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n SRC_UI=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';\")\n SRC_OCR=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n SRC_MEETINGS=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';\")\n\n printf \" %-20s %s\\n\" \"frames:\" \"$SRC_FRAMES\"\n printf \" %-20s %s\\n\" \"elements:\" \"$SRC_ELEMENTS\"\n printf \" %-20s %s\\n\" \"ui_events:\" \"$SRC_UI\"\n printf \" %-20s %s\\n\" \"ocr_text:\" \"$SRC_OCR\"\n printf \" %-20s %s\\n\" \"meetings:\" \"$SRC_MEETINGS\"\n\n if [ \"$SRC_FRAMES\" -eq \"0\" ]; then\n log \"No frames found for $TARGET_DATE — skipping DB sync\"\n DB_ALREADY_SYNCED=true\n fi\n\nfi\n\nif [ \"$DB_ALREADY_SYNCED\" = false ]; then\n\n # ─── INIT TABLES ──────────────────────────────────────────────────────────\n step \"Initialising tables (CREATE IF NOT EXISTS)\"\n\n run_sqlite_heredoc \"creating tables\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;\nDETACH nas;\n\"\n\n # ─── SCHEMA DRIFT FIX ─────────────────────────────────────────────────────\n # Runs AFTER CREATE IF NOT EXISTS so newly-created tables are no-ops here,\n # and pre-existing tables get any missing columns added.\n step \"Reconciling NAS schema with source\"\n for tbl in \"${SYNC_TABLES[@]}\"; do\n ensure_columns \"$tbl\"\n done\n\n run_sqlite_heredoc \"creating indexes\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_document_path ON frames(document_path) WHERE document_path IS NOT NULL;\nCREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;\nCREATE INDEX IF NOT EXISTS nas.idx_elements_onscreen_frame ON elements(frame_id) WHERE on_screen = 1 AND text IS NOT NULL;\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);\nCREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"creating FTS tables\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(\n text, role, frame_id UNINDEXED,\n content='elements', content_rowid='id', tokenize='unicode61'\n);\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(\n full_text, app_name, window_name, browser_url, id UNINDEXED,\n tokenize='unicode61'\n);\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(\n text_content,\n app_name,\n window_title,\n element_name,\n content='ui_events',\n content_rowid='id',\n tokenize='unicode61'\n);\nDETACH nas;\n\"\n\n # ─── BUILD EXPLICIT COLUMN LISTS ──────────────────────────────────────────\n # After ensure_columns, source ⊆ NAS for every synced table, so source's\n # column list is a safe subset to use on both sides of the INSERT.\n # For tables that JOIN frames (ocr_text, elements), the SELECT side needs\n # alias-qualified columns because both tables share names (app_name, etc).\n FRAMES_COLS=$(build_col_list frames)\n ELEMENTS_COLS=$(build_col_list elements)\n ELEMENTS_COLS_E=$(build_col_list elements e)\n UI_EVENTS_COLS=$(build_col_list ui_events)\n OCR_TEXT_COLS=$(build_col_list ocr_text)\n OCR_TEXT_COLS_O=$(build_col_list ocr_text o)\n VIDEO_CHUNKS_COLS=$(build_col_list video_chunks)\n MEETINGS_COLS=$(build_col_list meetings)\n\n # ─── SYNC DATA ────────────────────────────────────────────────────────────\n step \"Syncing data for $TARGET_DATE\"\n\n run_sqlite_heredoc \"video_chunks\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.video_chunks ($VIDEO_CHUNKS_COLS)\n SELECT $VIDEO_CHUNKS_COLS FROM main.video_chunks\n WHERE id IN (\n SELECT DISTINCT video_chunk_id FROM main.frames\n WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL\n );\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames ($SRC_FRAMES rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.frames ($FRAMES_COLS)\n SELECT $FRAMES_COLS FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ocr_text ($SRC_OCR rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ocr_text ($OCR_TEXT_COLS)\n SELECT $OCR_TEXT_COLS_O FROM main.ocr_text o\n JOIN main.frames f ON o.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events ($SRC_UI rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ui_events ($UI_EVENTS_COLS)\n SELECT $UI_EVENTS_COLS FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"elements ($SRC_ELEMENTS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.elements ($ELEMENTS_COLS)\n SELECT $ELEMENTS_COLS_E FROM main.elements e\n JOIN main.frames f ON e.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"meetings ($SRC_MEETINGS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.meetings ($MEETINGS_COLS)\n SELECT $MEETINGS_COLS FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n # ─── FTS UPDATE ───────────────────────────────────────────────────────────\n step \"Updating FTS indexes\"\n\n run_sqlite_heredoc \"elements_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.elements_fts(rowid, text, role)\n SELECT e.id, e.text, e.role\n FROM nas.elements e\n JOIN nas.frames f ON e.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE'\n AND e.text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)\n SELECT id, full_text, app_name, window_name, browser_url, id\n FROM nas.frames\n WHERE date(timestamp) = '$TARGET_DATE'\n AND full_text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)\n SELECT id, text_content, app_name, window_title, element_name\n FROM nas.ui_events\n WHERE date(timestamp) = '$TARGET_DATE'\n AND text_content IS NOT NULL;\nDETACH nas;\n\"\n\n # ─── VERIFY DB ────────────────────────────────────────────────────────────\n step \"Verifying DB\"\n\n V_FRAMES=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\")\n V_ELEMENTS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n V_UI=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';\")\n V_OCR=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n V_MEETINGS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';\")\n\n check \"frames\" \"$V_FRAMES\" \"$SRC_FRAMES\"\n check \"elements\" \"$V_ELEMENTS\" \"$SRC_ELEMENTS\"\n check \"ui_events\" \"$V_UI\" \"$SRC_UI\"\n check \"ocr_text\" \"$V_OCR\" \"$SRC_OCR\"\n check \"meetings\" \"$V_MEETINGS\" \"$SRC_MEETINGS\"\n\nfi\n\n# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────\n# Always runs regardless of DB sync status\nstep \"Copying data folder for $TARGET_DATE\"\n\nif [ -d \"$DATA_SRC\" ]; then\n mkdir -p \"$NAS_DATA/$TARGET_DATE\"\n RSYNC_START=$(date +%s)\n printf \" %-36s \" \"rsync $TARGET_DATE/ → NAS\"\n rsync -a --ignore-existing \\\n \"$DATA_SRC/\" \\\n \"$NAS_DATA/$TARGET_DATE/\" \\\n 2>>\"$LOG_FILE\"\n RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))\n COPIED_FILES=$(ls \"$NAS_DATA/$TARGET_DATE\" | wc -l | tr -d ' ')\n SRC_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n COPIED_SIZE=$(du -sh \"$NAS_DATA/$TARGET_DATE\" | cut -f1)\n if [ \"$COPIED_FILES\" -eq \"$SRC_FILES\" ]; then\n printf \"\\r %-36s ✓ %dm%02ds (%s files, %s)\\n\" \\\n \"rsync $TARGET_DATE/ → NAS\" \\\n \"$(( RSYNC_DUR / 60 ))\" \"$(( RSYNC_DUR % 60 ))\" \\\n \"$COPIED_FILES\" \"$COPIED_SIZE\" | tee -a \"$LOG_FILE\"\n else\n printf \"\\r %-36s ✗ %s / %s files\\n\" \\\n \"rsync $TARGET_DATE/ → NAS\" \"$COPIED_FILES\" \"$SRC_FILES\" | tee -a \"$LOG_FILE\"\n fi\nelse\n printf \" %-36s %s\\n\" \"rsync $TARGET_DATE/ → NAS\" \"skipped (no source dir)\"\nfi\n\n# ─── COPY LOGS ────────────────────────────────────────────────────────────────\n# Screenpipe writes daily logs to ~/.screenpipe/screenpipe.YYYY-MM-DD.N.log\n# (N is a rotation counter, almost always 0). Mirror them to NAS so log\n# analysis can happen on the consumer side without SSH'ing back to the Mac.\nstep \"Copying screenpipe logs for $TARGET_DATE\"\n\nNAS_LOGS=\"$NAS_MOUNT/logs\"\nmkdir -p \"$NAS_LOGS\"\n\n# Use a glob with nullglob so an empty match doesn't expand to a literal pattern.\nshopt -s nullglob\nLOG_FILES=( \"$HOME/.screenpipe/screenpipe.$TARGET_DATE.\"*.log )\nshopt -u nullglob\n\nif [ ${#LOG_FILES[@]} -gt 0 ]; then\n printf \" %-36s \" \"rsync logs → NAS\"\n # No --ignore-existing here: logs grow during the day, so we want rsync's\n # default size+mtime check to refresh files that have changed.\n rsync -a \"${LOG_FILES[@]}\" \"$NAS_LOGS/\" 2>>\"$LOG_FILE\"\n COPIED=${#LOG_FILES[@]}\n TOTAL_SIZE=$(du -ch \"${LOG_FILES[@]}\" | tail -1 | cut -f1)\n printf \"✓ %d file(s), %s\\n\" \"$COPIED\" \"$TOTAL_SIZE\" | tee -a \"$LOG_FILE\"\nelse\n printf \" %-36s %s\\n\" \"rsync logs → NAS\" \"skipped (no matching logs)\"\nfi\n\n# ─── SUMMARY ──────────────────────────────────────────────────────────────────\nTOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))\nDB_SIZE=$(du -sh \"$NAS_DB\" | cut -f1)\n\necho \"\"\nlog \"Archive DB size: $DB_SIZE\"\nlog \"Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s\"\nlog \"Sync complete for $TARGET_DATE\"\nlog \"========================================\"\n\n# Mirror this script's own logbook to NAS so sync health can be monitored\n# from the consumer side. Done last so the summary lines above are included.\nrsync -a \"$HOME/.screenpipe/sync.log\" \"$NAS_LOGS/sync.log\" 2>/dev/null || true","depth":29,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Implement and run pipe l…, Editor Group 2","depth":28,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":false},{"role":"AXRadioButton","text":"Problems (⇧⌘M)","depth":22,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"PROBLEMS","depth":24,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Output (⇧⌘U)","depth":22,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUTPUT","depth":24,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Debug Console (⇧⌘Y)","depth":22,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"DEBUG CONSOLE","depth":24,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Terminal (⌃`)","depth":22,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":true},{"role":"AXStaticText","text":"TERMINAL","depth":24,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Ports - 1 forwarded port","depth":22,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"PORTS","depth":24,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":25,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"remote SSH: nas","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"}]...
|
-5423942173947137579
|
8363351146505899285
|
click
|
accessibility
|
NULL
|
Explorer (⇧⌘E) - 1 unsaved file
1
Search (⇧⌘F)
Explorer (⇧⌘E) - 1 unsaved file
1
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py
M
db.py
docker-compose.yml
Dockerfile
M
main.py
M
requirements.txt
M
data
logs
pipes
.gitignore
app_settings.json
archive.db
archive.db-bak
U
db.sqlite
db.sqlite-shm
db.sqlite-wal
screenpipe_sync_updated.sh
U
screenpipe_sync.sh
screenpipe.db
Outline Section
OUTLINE
OUTLINE
Timeline Section
TIMELINE
TIMELINE
app_settings.json, Editor Group 1
screenpipe_sync.sh, Editor Group 1
pipe.md, Editor Group 1
.env, Editor Group 1
#!/bin/bash
# screenpipe_sync.sh
# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).
# Also copies the day's video/frame data folder to the NAS.
#
# Schema-drift tolerant: if Screenpipe migrations add new columns to the source DB,
# the NAS archive gets ALTER TABLE'd to match. Inserts use explicit column lists,
# so positional mismatches can't occur.
#
# Usage:
# ./screenpipe_sync.sh # syncs yesterday (default)
# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date
# ./screenpipe_sync.sh today # syncs today so far
#
# Cron example (runs at 3am daily):
# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1
set -euo pipefail
# ─── CONFIG ───────────────────────────────────────────────────────────────────
DB_SRC="${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}"
NAS_MOUNT="${NAS_MOUNT:-/Volumes/screenpipe}"
NAS_DB="$NAS_MOUNT/archive.db"
NAS_DATA="$NAS_MOUNT/data"
LOG_FILE="$HOME/.screenpipe/sync.log"
# Tables that get schema drift handling. Order matters for FK-ish references
# (parents before children: video_chunks → frames → elements/ocr_text/ui_events).
SYNC_TABLES=(video_chunks frames elements ocr_text ui_events meetings)
# ──────────────────────────────────────────────────────────────────────────────
# ─── HELPERS ──────────────────────────────────────────────────────────────────
SCRIPT_START=$(date +%s)
log() {
local msg="[$(date '+%Y-%m-%d %H:%M:%S')] $*"
echo "$msg" | tee -a "$LOG_FILE"
}
step() {
local now=$(date +%s)
local elapsed=$(( now - SCRIPT_START ))
local min=$(( elapsed / 60 ))
local sec=$(( elapsed % 60 ))
printf "\n[+%02dm%02ds] ▶ %s\n" "$min" "$sec" "$*" | tee -a "$LOG_FILE"
}
run_sqlite_heredoc() {
local label="$1"
local sql="$2"
local start=$(date +%s)
printf " %-36s " "$label"
sqlite3 "$DB_SRC" <<< "$sql" &
local pid=$!
local spin=[PASSWORD] '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')
local i=0
while kill -0 "$pid" 2>/dev/null; do
printf "\r %-36s %s " "$label" "${spin[$i]}"
i=$(( (i + 1) % 10 ))
sleep 0.2
done
wait "$pid"
local rc=$?
if [ $rc -ne 0 ]; then
printf "\r %-36s ✗ FAILED\n" "$label" | tee -a "$LOG_FILE"
exit $rc
fi
local dur=$(( $(date +%s) - start ))
printf "\r %-36s ✓ %dm%02ds\n" "$label" "$(( dur / 60 ))" "$(( dur % 60 ))" | tee -a "$LOG_FILE"
}
check() {
local label="$1" got="$2" expected="$3"
if [ "$got" -eq "$expected" ]; then
printf " %-20s %s / %s ✓\n" "$label:" "$got" "$expected"
else
printf " %-20s %s / %s ✗ MISMATCH\n" "$label:" "$got" "$expected"
fi
}
# ─── SCHEMA HELPERS ───────────────────────────────────────────────────────────
# Echoes "name|type" lines for a table from a given DB.
table_columns_with_types() {
local db="$1" table="$2"
sqlite3 "$db" "PRAGMA table_info($table);" | awk -F'|' '{print $2 "|" $3}'
}
# Echoes just column names, one per line.
table_columns() {
local db="$1" table="$2"
sqlite3 "$db" "PRAGMA table_info($table);" | awk -F'|' '{print $2}'
}
# Returns true (0) if a table exists in the given DB.
table_exists() {
local db="$1" table="$2"
local count
count=$(sqlite3 "$db" "SELECT COUNT(*) FROM sqlite_master WHERE type='table' AND name='$table';")
[ "$count" -gt 0 ]
}
# Adds any columns present in source but missing in NAS for the given table.
# Uses ALTER TABLE ADD COLUMN, which is a fast metadata-only operation in SQLite.
ensure_columns() {
local table="$1"
local label="schema: $table"
printf " %-36s " "$label"
if ! table_exists "$DB_SRC" "$table"; then
printf "✗ source missing — skipping\n"
return 0
fi
if ! table_exists "$NAS_DB" "$table"; then
printf "✓ fresh (created above)\n"
return 0
fi
local src_cols
src_cols=$(table_columns_with_types "$DB_SRC" "$table")
local nas_cols
nas_cols=$(table_columns "$NAS_DB" "$table")
local added=0
local added_names=""
while IFS='|' read -r name type; do
[ -z "$name" ] && continue
# Use grep -F -x for fixed-string exact match (safe against regex chars).
if ! echo "$nas_cols" | grep -Fxq "$name"; then
# SQLite ALTER TABLE ADD COLUMN: type is optional, no NOT NULL allowed
# without a constant default. Default-NULL is exactly what we want for archive.
sqlite3 "$NAS_DB" "ALTER TABLE $table ADD COLUMN \"$name\" $type;"
added=$((added + 1))
added_names="$added_names $name"
fi
done <<< "$src_cols"
if [ "$added" -gt 0 ]; then
printf "✓ added %d:%s\n" "$added" "$added_names"
else
printf "✓ in sync\n"
fi
}
# Echoes a comma-separated list of source columns for a table, double-quoted
# so reserved words and hyphens are safe. If an alias is provided, columns are
# prefixed (e.g. `o."col"`). Used for both INSERT and SELECT sides; aliased
# form is required when SELECTing from a JOIN where column names collide
# (e.g. ocr_text and frames both have app_name, window_name).
build_col_list() {
local table="$1"
local alias="${2:-}"
local prefix=""
[ -n "$alias" ] && prefix="${alias}."
table_columns "$DB_SRC" "$table" | awk 'NF' | awk -v p="$prefix" '{print p "\"" $0 "\""}' | paste -sd, -
}
# ──────────────────────────────────────────────────────────────────────────────
# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────
if [ "${1:-}" = "today" ]; then
TARGET_DATE=$(date +%Y-%m-%d)
elif [ -n "${1:-}" ]; then
TARGET_DATE="$1"
if ! [[ "$TARGET_DATE" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then
echo "ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday."
exit 1
fi
else
TARGET_DATE=$(date -v-1d +%Y-%m-%d)
fi
log "========================================"
log "Screenpipe sync starting for: $TARGET_DATE"
log "========================================"
# ─── PREFLIGHT ────────────────────────────────────────────────────────────────
step "Preflight checks"
if [ ! -f "$DB_SRC" ]; then
log "ERROR: Source DB not found at $DB_SRC"; exit 1
fi
printf " %-20s %s (%s)\n" "Source DB:" "OK" "$(du -sh "$DB_SRC" | cut -f1)"
if [ ! -d "$NAS_MOUNT" ]; then
log "ERROR: NAS not mounted at $NAS_MOUNT"; exit 1
fi
printf " %-20s %s\n" "NAS mount:" "OK $NAS_MOUNT"
# Check if DB already synced for this date
DB_ALREADY_SYNCED=false
if [ -f "$NAS_DB" ]; then
if table_exists "$NAS_DB" "frames"; then
EXISTING=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';" 2>/dev/null || echo "0")
if [ "$EXISTING" -gt "0" ]; then
log "Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync"
DB_ALREADY_SYNCED=true
else
printf " %-20s %s (%s)\n" "Archive DB:" "exists" "$(du -sh "$NAS_DB" | cut -f1)"
fi
else
printf " %-20s %s\n" "Archive DB:" "exists, no frames table yet"
fi
else
printf " %-20s %s\n" "Archive DB:" "will be created"
fi
# Source data dir for this date
DATA_SRC="$HOME/.screenpipe/data/data/$TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
DATA_SIZE=$(du -sh "$DATA_SRC" | cut -f1)
DATA_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
printf " %-20s %s (%s files, %s)\n" "Data dir:" "OK" "$DATA_FILES" "$DATA_SIZE"
else
printf " %-20s %s\n" "Data dir:" "not found — skipping file copy"
fi
# ─── DB SYNC ──────────────────────────────────────────────────────────────────
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────
step "Counting source rows for $TARGET_DATE"
SRC_FRAMES=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
SRC_ELEMENTS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_UI=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
SRC_OCR=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_MEETINGS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';")
printf " %-20s %s\n" "frames:" "$SRC_FRAMES"
printf " %-20s %s\n" "elements:" "$SRC_ELEMENTS"
printf " %-20s %s\n" "ui_events:" "$SRC_UI"
printf " %-20s %s\n" "ocr_text:" "$SRC_OCR"
printf " %-20s %s\n" "meetings:" "$SRC_MEETINGS"
if [ "$SRC_FRAMES" -eq "0" ]; then
log "No frames found for $TARGET_DATE — skipping DB sync"
DB_ALREADY_SYNCED=true
fi
fi
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── INIT TABLES ──────────────────────────────────────────────────────────
step "Initialising tables (CREATE IF NOT EXISTS)"
run_sqlite_heredoc "creating tables" "
ATTACH '$NAS_DB' AS nas;
CREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;
CREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;
CREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;
CREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;
DETACH nas;
"
# ─── SCHEMA DRIFT FIX ─────────────────────────────────────────────────────
# Runs AFTER CREATE IF NOT EXISTS so newly-created tables are no-ops here,
# and pre-existing tables get any missing columns added.
step "Reconciling NAS schema with source"
for tbl in "${SYNC_TABLES[@]}"; do
ensure_columns "$tbl"
done
run_sqlite_heredoc "creating indexes" "
ATTACH '$NAS_DB' AS nas;
CREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);
CREATE INDEX IF NOT EXISTS nas.idx_frames_document_path ON frames(document_path) WHERE document_path IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_elements_onscreen_frame ON elements(frame_id) WHERE on_screen = 1 AND text IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);
CREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);
DETACH nas;
"
run_sqlite_heredoc "creating FTS tables" "
ATTACH '$NAS_DB' AS nas;
CREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(
text, role, frame_id UNINDEXED,
content='elements', content_rowid='id', tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(
full_text, app_name, window_name, browser_url, id UNINDEXED,
tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(
text_content,
app_name,
window_title,
element_name,
content='ui_events',
content_rowid='id',
tokenize='unicode61'
);
DETACH nas;
"
# ─── BUILD EXPLICIT COLUMN LISTS ──────────────────────────────────────────
# After ensure_columns, source ⊆ NAS for every synced table, so source's
# column list is a safe subset to use on both sides of the INSERT.
# For tables that JOIN frames (ocr_text, elements), the SELECT side needs
# alias-qualified columns because both tables share names (app_name, etc).
FRAMES_COLS=$(build_col_list frames)
ELEMENTS_COLS=$(build_col_list elements)
ELEMENTS_COLS_E=$(build_col_list elements e)
UI_EVENTS_COLS=$(build_col_list ui_events)
OCR_TEXT_COLS=$(build_col_list ocr_text)
OCR_TEXT_COLS_O=$(build_col_list ocr_text o)
VIDEO_CHUNKS_COLS=$(build_col_list video_chunks)
MEETINGS_COLS=$(build_col_list meetings)
# ─── SYNC DATA ────────────────────────────────────────────────────────────
step "Syncing data for $TARGET_DATE"
run_sqlite_heredoc "video_chunks" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.video_chunks ($VIDEO_CHUNKS_COLS)
SELECT $VIDEO_CHUNKS_COLS FROM main.video_chunks
WHERE id IN (
SELECT DISTINCT video_chunk_id FROM main.frames
WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL
);
DETACH nas;
"
run_sqlite_heredoc "frames ($SRC_FRAMES rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.frames ($FRAMES_COLS)
SELECT $FRAMES_COLS FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ocr_text ($SRC_OCR rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ocr_text ($OCR_TEXT_COLS)
SELECT $OCR_TEXT_COLS_O FROM main.ocr_text o
JOIN main.frames f ON o.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ui_events ($SRC_UI rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ui_events ($UI_EVENTS_COLS)
SELECT $UI_EVENTS_COLS FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "elements ($SRC_ELEMENTS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.elements ($ELEMENTS_COLS)
SELECT $ELEMENTS_COLS_E FROM main.elements e
JOIN main.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "meetings ($SRC_MEETINGS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.meetings ($MEETINGS_COLS)
SELECT $MEETINGS_COLS FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';
DETACH nas;
"
# ─── FTS UPDATE ───────────────────────────────────────────────────────────
step "Updating FTS indexes"
run_sqlite_heredoc "elements_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.elements_fts(rowid, text, role)
SELECT e.id, e.text, e.role
FROM nas.elements e
JOIN nas.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE'
AND e.text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "frames_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)
SELECT id, full_text, app_name, window_name, browser_url, id
FROM nas.frames
WHERE date(timestamp) = '$TARGET_DATE'
AND full_text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "ui_events_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)
SELECT id, text_content, app_name, window_title, element_name
FROM nas.ui_events
WHERE date(timestamp) = '$TARGET_DATE'
AND text_content IS NOT NULL;
DETACH nas;
"
# ─── VERIFY DB ────────────────────────────────────────────────────────────
step "Verifying DB"
V_FRAMES=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
V_ELEMENTS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_UI=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
V_OCR=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_MEETINGS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';")
check "frames" "$V_FRAMES" "$SRC_FRAMES"
check "elements" "$V_ELEMENTS" "$SRC_ELEMENTS"
check "ui_events" "$V_UI" "$SRC_UI"
check "ocr_text" "$V_OCR" "$SRC_OCR"
check "meetings" "$V_MEETINGS" "$SRC_MEETINGS"
fi
# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────
# Always runs regardless of DB sync status
step "Copying data folder for $TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
mkdir -p "$NAS_DATA/$TARGET_DATE"
RSYNC_START=$(date +%s)
printf " %-36s " "rsync $TARGET_DATE/ → NAS"
rsync -a --ignore-existing \
"$DATA_SRC/" \
"$NAS_DATA/$TARGET_DATE/" \
2>>"$LOG_FILE"
RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))
COPIED_FILES=$(ls "$NAS_DATA/$TARGET_DATE" | wc -l | tr -d ' ')
SRC_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
COPIED_SIZE=$(du -sh "$NAS_DATA/$TARGET_DATE" | cut -f1)
if [ "$COPIED_FILES" -eq "$SRC_FILES" ]; then
printf "\r %-36s ✓ %dm%02ds (%s files, %s)\n" \
"rsync $TARGET_DATE/ → NAS" \
"$(( RSYNC_DUR / 60 ))" "$(( RSYNC_DUR % 60 ))" \
"$COPIED_FILES" "$COPIED_SIZE" | tee -a "$LOG_FILE"
else
printf "\r %-36s ✗ %s / %s files\n" \
"rsync $TARGET_DATE/ → NAS" "$COPIED_FILES" "$SRC_FILES" | tee -a "$LOG_FILE"
fi
else
printf " %-36s %s\n" "rsync $TARGET_DATE/ → NAS" "skipped (no source dir)"
fi
# ─── COPY LOGS ────────────────────────────────────────────────────────────────
# Screenpipe writes daily logs to ~/.screenpipe/screenpipe.YYYY-MM-DD.N.log
# (N is a rotation counter, almost always 0). Mirror them to NAS so log
# analysis can happen on the consumer side without SSH'ing back to the Mac.
step "Copying screenpipe logs for $TARGET_DATE"
NAS_LOGS="$NAS_MOUNT/logs"
mkdir -p "$NAS_LOGS"
# Use a glob with nullglob so an empty match doesn't expand to a literal pattern.
shopt -s nullglob
LOG_FILES=( "$HOME/.screenpipe/screenpipe.$TARGET_DATE."*.log )
shopt -u nullglob
if [ ${#LOG_FILES[@]} -gt 0 ]; then
printf " %-36s " "rsync logs → NAS"
# No --ignore-existing here: logs grow during the day, so we want rsync's
# default size+mtime check to refresh files that have changed.
rsync -a "${LOG_FILES[@]}" "$NAS_LOGS/" 2>>"$LOG_FILE"
COPIED=${#LOG_FILES[@]}
TOTAL_SIZE=$(du -ch "${LOG_FILES[@]}" | tail -1 | cut -f1)
printf "✓ %d file(s), %s\n" "$COPIED" "$TOTAL_SIZE" | tee -a "$LOG_FILE"
else
printf " %-36s %s\n" "rsync logs → NAS" "skipped (no matching logs)"
fi
# ─── SUMMARY ──────────────────────────────────────────────────────────────────
TOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))
DB_SIZE=$(du -sh "$NAS_DB" | cut -f1)
echo ""
log "Archive DB size: $DB_SIZE"
log "Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s"
log "Sync complete for $TARGET_DATE"
log "========================================"
# Mirror this script's own logbook to NAS so sync health can be monitored
# from the consumer side. Done last so the summary lines above are included.
rsync -a "$HOME/.screenpipe/sync.log" "$NAS_LOGS/sync.log" 2>/dev/null || true
#!/bin/bash
# screenpipe_sync.sh
# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).
# Also copies the day's video/frame data folder to the NAS.
#
# Schema-drift tolerant: if Screenpipe migrations add new columns to the source DB,
# the NAS archive gets ALTER TABLE'd to match. Inserts use explicit column lists,
# so positional mismatches can't occur.
#
# Usage:
# ./screenpipe_sync.sh # syncs yesterday (default)
# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date
# ./screenpipe_sync.sh today # syncs today so far
#
# Cron example (runs at 3am daily):
# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1
set -euo pipefail
# ─── CONFIG ───────────────────────────────────────────────────────────────────
DB_SRC="${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}"
NAS_MOUNT="${NAS_MOUNT:-/Volumes/screenpipe}"
NAS_DB="$NAS_MOUNT/archive.db"
NAS_DATA="$NAS_MOUNT/data"
LOG_FILE="$HOME/.screenpipe/sync.log"
# Tables that get schema drift handling. Order matters for FK-ish references
# (parents before children: video_chunks → frames → elements/ocr_text/ui_events).
SYNC_TABLES=(video_chunks frames elements ocr_text ui_events meetings)
# ──────────────────────────────────────────────────────────────────────────────
# ─── HELPERS ──────────────────────────────────────────────────────────────────
SCRIPT_START=$(date +%s)
log() {
local msg="[$(date '+%Y-%m-%d %H:%M:%S')] $*"
echo "$msg" | tee -a "$LOG_FILE"
}
step() {
local now=$(date +%s)
local elapsed=$(( now - SCRIPT_START ))
local min=$(( elapsed / 60 ))
local sec=$(( elapsed % 60 ))
printf "\n[+%02dm%02ds] ▶ %s\n" "$min" "$sec" "$*" | tee -a "$LOG_FILE"
}
run_sqlite_heredoc() {
local label="$1"
local sql="$2"
local start=$(date +%s)
printf " %-36s " "$label"
sqlite3 "$DB_SRC" <<< "$sql" &
local pid=$!
local spin=[PASSWORD] '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')
local i=0
while kill -0 "$pid" 2>/dev/null; do
printf "\r %-36s %s " "$label" "${spin[$i]}"
i=$(( (i + 1) % 10 ))
sleep 0.2
done
wait "$pid"
local rc=$?
if [ $rc -ne 0 ]; then
printf "\r %-36s ✗ FAILED\n" "$label" | tee -a "$LOG_FILE"
exit $rc
fi
local dur=$(( $(date +%s) - start ))
printf "\r %-36s ✓ %dm%02ds\n" "$label" "$(( dur / 60 ))" "$(( dur % 60 ))" | tee -a "$LOG_FILE"
}
check() {
local label="$1" got="$2" expected="$3"
if [ "$got" -eq "$expected" ]; then
printf " %-20s %s / %s ✓\n" "$label:" "$got" "$expected"
else
printf " %-20s %s / %s ✗ MISMATCH\n" "$label:" "$got" "$expected"
fi
}
# ─── SCHEMA HELPERS ───────────────────────────────────────────────────────────
# Echoes "name|type" lines for a table from a given DB.
table_columns_with_types() {
local db="$1" table="$2"
sqlite3 "$db" "PRAGMA table_info($table);" | awk -F'|' '{print $2 "|" $3}'
}
# Echoes just column names, one per line.
table_columns() {
local db="$1" table="$2"
sqlite3 "$db" "PRAGMA table_info($table);" | awk -F'|' '{print $2}'
}
# Returns true (0) if a table exists in the given DB.
table_exists() {
local db="$1" table="$2"
local count
count=$(sqlite3 "$db" "SELECT COUNT(*) FROM sqlite_master WHERE type='table' AND name='$table';")
[ "$count" -gt 0 ]
}
# Adds any columns present in source but missing in NAS for the given table.
# Uses ALTER TABLE ADD COLUMN, which is a fast metadata-only operation in SQLite.
ensure_columns() {
local table="$1"
local label="schema: $table"
printf " %-36s " "$label"
if ! table_exists "$DB_SRC" "$table"; then
printf "✗ source missing — skipping\n"
return 0
fi
if ! table_exists "$NAS_DB" "$table"; then
printf "✓ fresh (created above)\n"
return 0
fi
local src_cols
src_cols=$(table_columns_with_types "$DB_SRC" "$table")
local nas_cols
nas_cols=$(table_columns "$NAS_DB" "$table")
local added=0
local added_names=""
while IFS='|' read -r name type; do
[ -z "$name" ] && continue
# Use grep -F -x for fixed-string exact match (safe against regex chars).
if ! echo "$nas_cols" | grep -Fxq "$name"; then
# SQLite ALTER TABLE ADD COLUMN: type is optional, no NOT NULL allowed
# without a constant default. Default-NULL is exactly what we want for archive.
sqlite3 "$NAS_DB" "ALTER TABLE $table ADD COLUMN \"$name\" $type;"
added=$((added + 1))
added_names="$added_names $name"
fi
done <<< "$src_cols"
if [ "$added" -gt 0 ]; then
printf "✓ added %d:%s\n" "$added" "$added_names"
else
printf "✓ in sync\n"
fi
}
# Echoes a comma-separated list of source columns for a table, double-quoted
# so reserved words and hyphens are safe. If an alias is provided, columns are
# prefixed (e.g. `o."col"`). Used for both INSERT and SELECT sides; aliased
# form is required when SELECTing from a JOIN where column names collide
# (e.g. ocr_text and frames both have app_name, window_name).
build_col_list() {
local table="$1"
local alias="${2:-}"
local prefix=""
[ -n "$alias" ] && prefix="${alias}."
table_columns "$DB_SRC" "$table" | awk 'NF' | awk -v p="$prefix" '{print p "\"" $0 "\""}' | paste -sd, -
}
# ──────────────────────────────────────────────────────────────────────────────
# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────
if [ "${1:-}" = "today" ]; then
TARGET_DATE=$(date +%Y-%m-%d)
elif [ -n "${1:-}" ]; then
TARGET_DATE="$1"
if ! [[ "$TARGET_DATE" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then
echo "ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday."
exit 1
fi
else
TARGET_DATE=$(date -v-1d +%Y-%m-%d)
fi
log "========================================"
log "Screenpipe sync starting for: $TARGET_DATE"
log "========================================"
# ─── PREFLIGHT ────────────────────────────────────────────────────────────────
step "Preflight checks"
if [ ! -f "$DB_SRC" ]; then
log "ERROR: Source DB not found at $DB_SRC"; exit 1
fi
printf " %-20s %s (%s)\n" "Source DB:" "OK" "$(du -sh "$DB_SRC" | cut -f1)"
if [ ! -d "$NAS_MOUNT" ]; then
log "ERROR: NAS not mounted at $NAS_MOUNT"; exit 1
fi
printf " %-20s %s\n" "NAS mount:" "OK $NAS_MOUNT"
# Check if DB already synced for this date
DB_ALREADY_SYNCED=false
if [ -f "$NAS_DB" ]; then
if table_exists "$NAS_DB" "frames"; then
EXISTING=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';" 2>/dev/null || echo "0")
if [ "$EXISTING" -gt "0" ]; then
log "Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync"
DB_ALREADY_SYNCED=true
else
printf " %-20s %s (%s)\n" "Archive DB:" "exists" "$(du -sh "$NAS_DB" | cut -f1)"
fi
else
printf " %-20s %s\n" "Archive DB:" "exists, no frames table yet"
fi
else
printf " %-20s %s\n" "Archive DB:" "will be created"
fi
# Source data dir for this date
DATA_SRC="$HOME/.screenpipe/data/data/$TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
DATA_SIZE=$(du -sh "$DATA_SRC" | cut -f1)
DATA_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
printf " %-20s %s (%s files, %s)\n" "Data dir:" "OK" "$DATA_FILES" "$DATA_SIZE"
else
printf " %-20s %s\n" "Data dir:" "not found — skipping file copy"
fi
# ─── DB SYNC ──────────────────────────────────────────────────────────────────
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────
step "Counting source rows for $TARGET_DATE"
SRC_FRAMES=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
SRC_ELEMENTS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_UI=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
SRC_OCR=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_MEETINGS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';")
printf " %-20s %s\n" "frames:" "$SRC_FRAMES"
printf " %-20s %s\n" "elements:" "$SRC_ELEMENTS"
printf " %-20s %s\n" "ui_events:" "$SRC_UI"
printf " %-20s %s\n" "ocr_text:" "$SRC_OCR"
printf " %-20s %s\n" "meetings:" "$SRC_MEETINGS"
if [ "$SRC_FRAMES" -eq "0" ]; then
log "No frames found for $TARGET_DATE — skipping DB sync"
DB_ALREADY_SYNCED=true
fi
fi
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── INIT TABLES ──────────────────────────────────────────────────────────
step "Initialising tables (CREATE IF NOT EXISTS)"
run_sqlite_heredoc "creating tables" "
ATTACH '$NAS_DB' AS nas;
CREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;
CREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;
CREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;
CREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;
DETACH nas;
"
# ─── SCHEMA DRIFT FIX ─────────────────────────────────────────────────────
# Runs AFTER CREATE IF NOT EXISTS so newly-created tables are no-ops here,
# and pre-existing tables get any missing columns added.
step "Reconciling NAS schema with source"
for tbl in "${SYNC_TABLES[@]}"; do
ensure_columns "$tbl"
done
run_sqlite_heredoc "creating indexes" "
ATTACH '$NAS_DB' AS nas;
CREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);
CREATE INDEX IF NOT EXISTS nas.idx_frames_document_path ON frames(document_path) WHERE document_path IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_elements_onscreen_frame ON elements(frame_id) WHERE on_screen = 1 AND text IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);
CREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);
DETACH nas;
"
run_sqlite_heredoc "creating FTS tables" "
ATTACH '$NAS_DB' AS nas;
CREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(
text, role, frame_id UNINDEXED,
content='elements', content_rowid='id', tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(
full_text, app_name, window_name, browser_url, id UNINDEXED,
tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(
text_content,
app_name,
window_title,
element_name,
content='ui_events',
content_rowid='id',
tokenize='unicode61'
);
DETACH nas;
"
# ─── BUILD EXPLICIT COLUMN LISTS ──────────────────────────────────────────
# After ensure_columns, source ⊆ NAS for every synced table, so source's
# column list is a safe subset to use on both sides of the INSERT.
# For tables that JOIN frames (ocr_text, elements), the SELECT side needs
# alias-qualified columns because both tables share names (app_name, etc).
FRAMES_COLS=$(build_col_list frames)
ELEMENTS_COLS=$(build_col_list elements)
ELEMENTS_COLS_E=$(build_col_list elements e)
UI_EVENTS_COLS=$(build_col_list ui_events)
OCR_TEXT_COLS=$(build_col_list ocr_text)
OCR_TEXT_COLS_O=$(build_col_list ocr_text o)
VIDEO_CHUNKS_COLS=$(build_col_list video_chunks)
MEETINGS_COLS=$(build_col_list meetings)
# ─── SYNC DATA ────────────────────────────────────────────────────────────
step "Syncing data for $TARGET_DATE"
run_sqlite_heredoc "video_chunks" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.video_chunks ($VIDEO_CHUNKS_COLS)
SELECT $VIDEO_CHUNKS_COLS FROM main.video_chunks
WHERE id IN (
SELECT DISTINCT video_chunk_id FROM main.frames
WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL
);
DETACH nas;
"
run_sqlite_heredoc "frames ($SRC_FRAMES rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.frames ($FRAMES_COLS)
SELECT $FRAMES_COLS FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ocr_text ($SRC_OCR rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ocr_text ($OCR_TEXT_COLS)
SELECT $OCR_TEXT_COLS_O FROM main.ocr_text o
JOIN main.frames f ON o.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ui_events ($SRC_UI rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ui_events ($UI_EVENTS_COLS)
SELECT $UI_EVENTS_COLS FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "elements ($SRC_ELEMENTS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.elements ($ELEMENTS_COLS)
SELECT $ELEMENTS_COLS_E FROM main.elements e
JOIN main.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "meetings ($SRC_MEETINGS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.meetings ($MEETINGS_COLS)
SELECT $MEETINGS_COLS FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';
DETACH nas;
"
# ─── FTS UPDATE ───────────────────────────────────────────────────────────
step "Updating FTS indexes"
run_sqlite_heredoc "elements_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.elements_fts(rowid, text, role)
SELECT e.id, e.text, e.role
FROM nas.elements e
JOIN nas.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE'
AND e.text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "frames_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)
SELECT id, full_text, app_name, window_name, browser_url, id
FROM nas.frames
WHERE date(timestamp) = '$TARGET_DATE'
AND full_text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "ui_events_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)
SELECT id, text_content, app_name, window_title, element_name
FROM nas.ui_events
WHERE date(timestamp) = '$TARGET_DATE'
AND text_content IS NOT NULL;
DETACH nas;
"
# ─── VERIFY DB ────────────────────────────────────────────────────────────
step "Verifying DB"
V_FRAMES=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
V_ELEMENTS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_UI=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
V_OCR=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_MEETINGS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';")
check "frames" "$V_FRAMES" "$SRC_FRAMES"
check "elements" "$V_ELEMENTS" "$SRC_ELEMENTS"
check "ui_events" "$V_UI" "$SRC_UI"
check "ocr_text" "$V_OCR" "$SRC_OCR"
check "meetings" "$V_MEETINGS" "$SRC_MEETINGS"
fi
# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────
# Always runs regardless of DB sync status
step "Copying data folder for $TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
mkdir -p "$NAS_DATA/$TARGET_DATE"
RSYNC_START=$(date +%s)
printf " %-36s " "rsync $TARGET_DATE/ → NAS"
rsync -a --ignore-existing \
"$DATA_SRC/" \
"$NAS_DATA/$TARGET_DATE/" \
2>>"$LOG_FILE"
RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))
COPIED_FILES=$(ls "$NAS_DATA/$TARGET_DATE" | wc -l | tr -d ' ')
SRC_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
COPIED_SIZE=$(du -sh "$NAS_DATA/$TARGET_DATE" | cut -f1)
if [ "$COPIED_FILES" -eq "$SRC_FILES" ]; then
printf "\r %-36s ✓ %dm%02ds (%s files, %s)\n" \
"rsync $TARGET_DATE/ → NAS" \
"$(( RSYNC_DUR / 60 ))" "$(( RSYNC_DUR % 60 ))" \
"$COPIED_FILES" "$COPIED_SIZE" | tee -a "$LOG_FILE"
else
printf "\r %-36s ✗ %s / %s files\n" \
"rsync $TARGET_DATE/ → NAS" "$COPIED_FILES" "$SRC_FILES" | tee -a "$LOG_FILE"
fi
else
printf " %-36s %s\n" "rsync $TARGET_DATE/ → NAS" "skipped (no source dir)"
fi
# ─── COPY LOGS ────────────────────────────────────────────────────────────────
# Screenpipe writes daily logs to ~/.screenpipe/screenpipe.YYYY-MM-DD.N.log
# (N is a rotation counter, almost always 0). Mirror them to NAS so log
# analysis can happen on the consumer side without SSH'ing back to the Mac.
step "Copying screenpipe logs for $TARGET_DATE"
NAS_LOGS="$NAS_MOUNT/logs"
mkdir -p "$NAS_LOGS"
# Use a glob with nullglob so an empty match doesn't expand to a literal pattern.
shopt -s nullglob
LOG_FILES=( "$HOME/.screenpipe/screenpipe.$TARGET_DATE."*.log )
shopt -u nullglob
if [ ${#LOG_FILES[@]} -gt 0 ]; then
printf " %-36s " "rsync logs → NAS"
# No --ignore-existing here: logs grow during the day, so we want rsync's
# default size+mtime check to refresh files that have changed.
rsync -a "${LOG_FILES[@]}" "$NAS_LOGS/" 2>>"$LOG_FILE"
COPIED=${#LOG_FILES[@]}
TOTAL_SIZE=$(du -ch "${LOG_FILES[@]}" | tail -1 | cut -f1)
printf "✓ %d file(s), %s\n" "$COPIED" "$TOTAL_SIZE" | tee -a "$LOG_FILE"
else
printf " %-36s %s\n" "rsync logs → NAS" "skipped (no matching logs)"
fi
# ─── SUMMARY ──────────────────────────────────────────────────────────────────
TOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))
DB_SIZE=$(du -sh "$NAS_DB" | cut -f1)
echo ""
log "Archive DB size: $DB_SIZE"
log "Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s"
log "Sync complete for $TARGET_DATE"
log "========================================"
# Mirror this script's own logbook to NAS so sync health can be monitored
# from the consumer side. Done last so the summary lines above are included.
rsync -a "$HOME/.screenpipe/sync.log" "$NAS_LOGS/sync.log" 2>/dev/null || true
Implement and run pipe l…, Editor Group 2
Problems (⇧⌘M)
PROBLEMS
Output (⇧⌘U)
OUTPUT
Debug Console (⇧⌘Y)
DEBUG CONSOLE
Terminal (⌃`)
TERMINAL
Ports - 1 forwarded port
PORTS
1
remote SSH: nas
...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
21107
|
923
|
14
|
2026-05-11T17:12:23.726035+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-11/1778 /Users/lukas/.screenpipe/data/data/2026-05-11/1778519543726_m2.jpg...
|
Code
|
screenpipe_sync.sh — screenpipe [SSH: nas]
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Explorer (⇧⌘E) - 1 unsaved file
1
Search (⇧⌘F)
Explorer (⇧⌘E) - 1 unsaved file
1
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py
M
db.py
docker-compose.yml
Dockerfile
M
main.py
M
requirements.txt
M
data
logs
pipes
.gitignore
app_settings.json
archive.db
archive.db-bak
U
db.sqlite
db.sqlite-shm
db.sqlite-wal
screenpipe_sync_updated.sh
U
screenpipe_sync.sh
screenpipe.db
Outline Section
OUTLINE
OUTLINE
Timeline Section
TIMELINE
TIMELINE...
|
[{"role":"AXRadioButton","text [{"role":"AXRadioButton","text":"Explorer (⇧⌘E) - 1 unsaved file","depth":19,"bounds":{"left":0.0,"top":0.047885075,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":true},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.057462092,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":22,"bounds":{"left":0.009640957,"top":0.06863528,"width":0.0016622341,"height":0.008778931},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Search (⇧⌘F)","depth":19,"bounds":{"left":0.0,"top":0.08619314,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.09577015,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Source Control (⌃⇧G) - 10 pending changes","depth":19,"bounds":{"left":0.0,"top":0.1245012,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.13407822,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"10","depth":22,"bounds":{"left":0.00831117,"top":0.1452514,"width":0.003656915,"height":0.008778931},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.00831117,"top":0.14604948,"width":0.0016622341,"height":0.007980846}},{"char_start":1,"char_count":1,"bounds":{"left":0.009973404,"top":0.14604948,"width":0.0023271276,"height":0.007980846}}],"role_description":"text"},{"role":"AXRadioButton","text":"Run and Debug (⇧⌘D)","depth":19,"bounds":{"left":0.0,"top":0.16280925,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.17238627,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Remote Explorer","depth":19,"bounds":{"left":0.0,"top":0.20111732,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.21069433,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Extensions (⇧⌘X) - 2 require update","depth":19,"bounds":{"left":0.0,"top":0.23942538,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.2490024,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"2","depth":22,"bounds":{"left":0.009640957,"top":0.2601756,"width":0.0019946808,"height":0.008778931},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Claude Code","depth":19,"bounds":{"left":0.0,"top":0.27773345,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"Containers","depth":19,"bounds":{"left":0.0,"top":0.3160415,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXHeading","text":"EXPLORER","depth":17,"bounds":{"left":0.022606382,"top":0.047885075,"width":0.018949468,"height":0.02793296},"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"EXPLORER","depth":18,"bounds":{"left":0.022606382,"top":0.056664005,"width":0.018949468,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.022606382,"top":0.056664005,"width":0.0023271276,"height":0.0103751}},{"char_start":1,"char_count":7,"bounds":{"left":0.024933511,"top":0.056664005,"width":0.01662234,"height":0.0103751}}],"role_description":"text"},{"role":"AXButton","text":"Explorer Section: screenpipe [SSH: nas]","depth":21,"bounds":{"left":0.015957447,"top":0.07581804,"width":0.09940159,"height":0.017557861},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":true},{"role":"AXStaticText","text":"","depth":23,"bounds":{"left":0.01662234,"top":0.07821229,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"Explorer Section: screenpipe [SSH: nas]","depth":22,"bounds":{"left":0.022606382,"top":0.07581804,"width":0.045877658,"height":0.017557861},"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"SCREENPIPE [SSH: NAS]","depth":23,"bounds":{"left":0.022606382,"top":0.079010375,"width":0.045877658,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.022606382,"top":0.07980846,"width":0.0026595744,"height":0.0103751}},{"char_start":1,"char_count":20,"bounds":{"left":0.025265958,"top":0.07980846,"width":0.043218084,"height":0.0103751}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.09577015,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"#recycle","depth":27,"bounds":{"left":0.025930852,"top":0.09577015,"width":0.017287234,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.096568234,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":7,"bounds":{"left":0.028590426,"top":0.096568234,"width":0.01462766,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.11332801,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"app","depth":27,"bounds":{"left":0.025930852,"top":0.11332801,"width":0.0076462766,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.11412609,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":2,"bounds":{"left":0.02825798,"top":0.11412609,"width":0.005319149,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.11412609,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.022273935,"top":0.13088587,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"__pycache__","depth":27,"bounds":{"left":0.028590426,"top":0.13088587,"width":0.026595745,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.13168396,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":10,"bounds":{"left":0.030917553,"top":0.13168396,"width":0.024268618,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.022273935,"top":0.14844373,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"consumers","depth":27,"bounds":{"left":0.028590426,"top":0.14844373,"width":0.022273935,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.14924182,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":8,"bounds":{"left":0.030917553,"top":0.14924182,"width":0.019946808,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.14924182,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.022273935,"top":0.1660016,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"static","depth":27,"bounds":{"left":0.028590426,"top":0.1660016,"width":0.010970744,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.16679968,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":5,"bounds":{"left":0.030917553,"top":0.16679968,"width":0.008976064,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.16679968,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.1819633,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":".env","depth":27,"bounds":{"left":0.028590426,"top":0.18355946,"width":0.00831117,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.18435754,"width":0.0013297872,"height":0.011971269}},{"char_start":1,"char_count":3,"bounds":{"left":0.029920213,"top":0.18435754,"width":0.006981383,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.19952115,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"cli.py","depth":27,"bounds":{"left":0.028590426,"top":0.20111732,"width":0.010638298,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.2019154,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":5,"bounds":{"left":0.030917553,"top":0.2019154,"width":0.00831117,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.2019154,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.21707901,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.py","depth":27,"bounds":{"left":0.028590426,"top":0.21867518,"width":0.011303191,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.21947326,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":4,"bounds":{"left":0.03125,"top":0.21947326,"width":0.008643617,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.23463687,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"docker-compose.yml","depth":27,"bounds":{"left":0.028590426,"top":0.23623304,"width":0.042220745,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.23703113,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":17,"bounds":{"left":0.03125,"top":0.23703113,"width":0.03956117,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.25219473,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Dockerfile","depth":27,"bounds":{"left":0.028590426,"top":0.25379092,"width":0.020611702,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.254589,"width":0.0033244682,"height":0.011971269}},{"char_start":1,"char_count":9,"bounds":{"left":0.031914894,"top":0.254589,"width":0.017287234,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.254589,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.2697526,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"main.py","depth":27,"bounds":{"left":0.028590426,"top":0.27134877,"width":0.015625,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.27214685,"width":0.003656915,"height":0.011971269}},{"char_start":1,"char_count":6,"bounds":{"left":0.032247342,"top":0.27214685,"width":0.012300532,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.27214685,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.28731045,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"requirements.txt","depth":27,"bounds":{"left":0.028590426,"top":0.28890663,"width":0.032912236,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.2897047,"width":0.0016622341,"height":0.011971269}},{"char_start":1,"char_count":15,"bounds":{"left":0.03025266,"top":0.2897047,"width":0.03158245,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.2897047,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.3064645,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"data","depth":27,"bounds":{"left":0.025930852,"top":0.3064645,"width":0.008976064,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.30726257,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":3,"bounds":{"left":0.028590426,"top":0.30726257,"width":0.0063164895,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.32402235,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"logs","depth":27,"bounds":{"left":0.025930852,"top":0.32402235,"width":0.00831117,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.32482043,"width":0.0009973404,"height":0.011971269}},{"char_start":1,"char_count":3,"bounds":{"left":0.026928192,"top":0.32482043,"width":0.0076462766,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.32482043,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.3415802,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"pipes","depth":27,"bounds":{"left":0.025930852,"top":0.3415802,"width":0.010970744,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.3423783,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":4,"bounds":{"left":0.028590426,"top":0.3423783,"width":0.00831117,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.3575419,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":".gitignore","depth":27,"bounds":{"left":0.025930852,"top":0.35913807,"width":0.018949468,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.35993615,"width":0.0013297872,"height":0.011971269}},{"char_start":1,"char_count":9,"bounds":{"left":0.027260639,"top":0.35993615,"width":0.017952127,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.37509975,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"app_settings.json","depth":27,"bounds":{"left":0.025930852,"top":0.37669593,"width":0.03557181,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.377494,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":16,"bounds":{"left":0.02825798,"top":0.377494,"width":0.03324468,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.3926576,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"archive.db","depth":27,"bounds":{"left":0.025930852,"top":0.3942538,"width":0.020944148,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.39505187,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":9,"bounds":{"left":0.02825798,"top":0.39505187,"width":0.01861702,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.4102155,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"archive.db-bak","depth":27,"bounds":{"left":0.025930852,"top":0.41181165,"width":0.03025266,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.41260973,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":13,"bounds":{"left":0.02825798,"top":0.41260973,"width":0.027925532,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"U","depth":27,"bounds":{"left":0.10704787,"top":0.41260973,"width":0.0029920214,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.42777336,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite","depth":27,"bounds":{"left":0.025930852,"top":0.4293695,"width":0.017287234,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.4301676,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":8,"bounds":{"left":0.028590426,"top":0.4301676,"width":0.014960106,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.44533122,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite-shm","depth":27,"bounds":{"left":0.025930852,"top":0.44692737,"width":0.027925532,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.44772545,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":12,"bounds":{"left":0.028590426,"top":0.44772545,"width":0.025265958,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.46288908,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite-wal","depth":27,"bounds":{"left":0.025930852,"top":0.46448523,"width":0.025930852,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.46528333,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":12,"bounds":{"left":0.028590426,"top":0.46528333,"width":0.023603724,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.48044693,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe_sync_updated.sh","depth":27,"bounds":{"left":0.025930852,"top":0.4820431,"width":0.059175532,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.4828412,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":25,"bounds":{"left":0.02825798,"top":0.4828412,"width":0.056848403,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"U","depth":27,"bounds":{"left":0.10704787,"top":0.4828412,"width":0.0029920214,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.4980048,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe_sync.sh","depth":27,"bounds":{"left":0.025930852,"top":0.49960095,"width":0.039893616,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.50039905,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":17,"bounds":{"left":0.02825798,"top":0.50039905,"width":0.037898935,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.51556265,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe.db","depth":27,"bounds":{"left":0.025930852,"top":0.5171588,"width":0.028590426,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.5179569,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":12,"bounds":{"left":0.02825798,"top":0.5179569,"width":0.026595745,"height":0.011971269}}],"role_description":"text"},{"role":"AXButton","text":"Outline Section","depth":21,"bounds":{"left":0.015957447,"top":0.9473264,"width":0.09940159,"height":0.017557861},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":23,"bounds":{"left":0.01662234,"top":0.9497207,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"OUTLINE","depth":22,"bounds":{"left":0.022606382,"top":0.9473264,"width":0.01662234,"height":0.017557861},"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"OUTLINE","depth":23,"bounds":{"left":0.022606382,"top":0.95131683,"width":0.01662234,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.022606382,"top":0.95131683,"width":0.0029920214,"height":0.0103751}},{"char_start":1,"char_count":6,"bounds":{"left":0.025598405,"top":0.95131683,"width":0.013630319,"height":0.0103751}}],"role_description":"text"},{"role":"AXButton","text":"Timeline Section","depth":21,"bounds":{"left":0.015957447,"top":0.9648843,"width":0.09940159,"height":0.017557861},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":23,"bounds":{"left":0.01662234,"top":0.96727854,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"TIMELINE","depth":22,"bounds":{"left":0.022606382,"top":0.9648843,"width":0.01761968,"height":0.017557861},"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"TIMELINE","depth":23,"bounds":{"left":0.022606382,"top":0.9688747,"width":0.01761968,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.022606382,"top":0.9688747,"width":0.0026595744,"height":0.0103751}},{"char_start":1,"char_count":7,"bounds":{"left":0.025265958,"top":0.9688747,"width":0.015292553,"height":0.0103751}}],"role_description":"text"}]...
|
-6510943892019973747
|
-5498275134764838528
|
click
|
accessibility
|
NULL
|
Explorer (⇧⌘E) - 1 unsaved file
1
Search (⇧⌘F)
Explorer (⇧⌘E) - 1 unsaved file
1
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py
M
db.py
docker-compose.yml
Dockerfile
M
main.py
M
requirements.txt
M
data
logs
pipes
.gitignore
app_settings.json
archive.db
archive.db-bak
U
db.sqlite
db.sqlite-shm
db.sqlite-wal
screenpipe_sync_updated.sh
U
screenpipe_sync.sh
screenpipe.db
Outline Section
OUTLINE
OUTLINE
Timeline Section
TIMELINE
TIMELINE...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
21108
|
922
|
14
|
2026-05-11T17:12:28.074375+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-11/1778 /Users/lukas/.screenpipe/data/data/2026-05-11/1778519548074_m1.jpg...
|
Code
|
screenpipe_sync.sh — screenpipe [SSH: nas]
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Explorer (⇧⌘E) - 1 unsaved file
1
Search (⇧⌘F)
Explorer (⇧⌘E) - 1 unsaved file
1
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py
M
db.py...
|
[{"role":"AXRadioButton","text [{"role":"AXRadioButton","text":"Explorer (⇧⌘E) - 1 unsaved file","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":true},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Search (⇧⌘F)","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Source Control (⌃⇧G) - 10 pending changes","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"10","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Run and Debug (⇧⌘D)","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Remote Explorer","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Extensions (⇧⌘X) - 2 require update","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"2","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Claude Code","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"Containers","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXHeading","text":"EXPLORER","depth":17,"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"EXPLORER","depth":18,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Explorer Section: screenpipe [SSH: nas]","depth":21,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":true},{"role":"AXStaticText","text":"","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"Explorer Section: screenpipe [SSH: nas]","depth":22,"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"SCREENPIPE [SSH: NAS]","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"#recycle","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"app","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"__pycache__","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"consumers","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"static","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":".env","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"cli.py","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.py","depth":27,"on_screen":true,"role_description":"text"}]...
|
-2891033575869614174
|
-5587990885544770168
|
click
|
accessibility
|
NULL
|
Explorer (⇧⌘E) - 1 unsaved file
1
Search (⇧⌘F)
Explorer (⇧⌘E) - 1 unsaved file
1
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py
M
db.py...
|
21106
|
NULL
|
NULL
|
NULL
|
|
21109
|
923
|
15
|
2026-05-11T17:12:28.091350+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-11/1778 /Users/lukas/.screenpipe/data/data/2026-05-11/1778519548091_m2.jpg...
|
Code
|
screenpipe_sync.sh — screenpipe [SSH: nas]
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Explorer (⇧⌘E) - 1 unsaved file
1
Search (⇧⌘F)
Explorer (⇧⌘E) - 1 unsaved file
1
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py
M
db.py
docker-compose.yml
Dockerfile
M
main.py
M
requirements.txt
M
data
logs
pipes
.gitignore
app_settings.json
archive.db
archive.db-bak
U
db.sqlite
db.sqlite-shm...
|
[{"role":"AXRadioButton","text [{"role":"AXRadioButton","text":"Explorer (⇧⌘E) - 1 unsaved file","depth":19,"bounds":{"left":0.0,"top":0.047885075,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":true},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.057462092,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":22,"bounds":{"left":0.009640957,"top":0.06863528,"width":0.0016622341,"height":0.008778931},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Search (⇧⌘F)","depth":19,"bounds":{"left":0.0,"top":0.08619314,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.09577015,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Source Control (⌃⇧G) - 10 pending changes","depth":19,"bounds":{"left":0.0,"top":0.1245012,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.13407822,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"10","depth":22,"bounds":{"left":0.00831117,"top":0.1452514,"width":0.003656915,"height":0.008778931},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.00831117,"top":0.14604948,"width":0.0016622341,"height":0.007980846}},{"char_start":1,"char_count":1,"bounds":{"left":0.009973404,"top":0.14604948,"width":0.0023271276,"height":0.007980846}}],"role_description":"text"},{"role":"AXRadioButton","text":"Run and Debug (⇧⌘D)","depth":19,"bounds":{"left":0.0,"top":0.16280925,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.17238627,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Remote Explorer","depth":19,"bounds":{"left":0.0,"top":0.20111732,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.21069433,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Extensions (⇧⌘X) - 2 require update","depth":19,"bounds":{"left":0.0,"top":0.23942538,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.2490024,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"2","depth":22,"bounds":{"left":0.009640957,"top":0.2601756,"width":0.0019946808,"height":0.008778931},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Claude Code","depth":19,"bounds":{"left":0.0,"top":0.27773345,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"Containers","depth":19,"bounds":{"left":0.0,"top":0.3160415,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXHeading","text":"EXPLORER","depth":17,"bounds":{"left":0.022606382,"top":0.047885075,"width":0.018949468,"height":0.02793296},"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"EXPLORER","depth":18,"bounds":{"left":0.022606382,"top":0.056664005,"width":0.018949468,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.022606382,"top":0.056664005,"width":0.0023271276,"height":0.0103751}},{"char_start":1,"char_count":7,"bounds":{"left":0.024933511,"top":0.056664005,"width":0.01662234,"height":0.0103751}}],"role_description":"text"},{"role":"AXButton","text":"Explorer Section: screenpipe [SSH: nas]","depth":21,"bounds":{"left":0.015957447,"top":0.07581804,"width":0.09940159,"height":0.017557861},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":true},{"role":"AXStaticText","text":"","depth":23,"bounds":{"left":0.01662234,"top":0.07821229,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"Explorer Section: screenpipe [SSH: nas]","depth":22,"bounds":{"left":0.022606382,"top":0.07581804,"width":0.045877658,"height":0.017557861},"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"SCREENPIPE [SSH: NAS]","depth":23,"bounds":{"left":0.022606382,"top":0.079010375,"width":0.045877658,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.022606382,"top":0.07980846,"width":0.0026595744,"height":0.0103751}},{"char_start":1,"char_count":20,"bounds":{"left":0.025265958,"top":0.07980846,"width":0.043218084,"height":0.0103751}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.09577015,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"#recycle","depth":27,"bounds":{"left":0.025930852,"top":0.09577015,"width":0.017287234,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.096568234,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":7,"bounds":{"left":0.028590426,"top":0.096568234,"width":0.01462766,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.11332801,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"app","depth":27,"bounds":{"left":0.025930852,"top":0.11332801,"width":0.0076462766,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.11412609,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":2,"bounds":{"left":0.02825798,"top":0.11412609,"width":0.005319149,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.11412609,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.022273935,"top":0.13088587,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"__pycache__","depth":27,"bounds":{"left":0.028590426,"top":0.13088587,"width":0.026595745,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.13168396,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":10,"bounds":{"left":0.030917553,"top":0.13168396,"width":0.024268618,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.022273935,"top":0.14844373,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"consumers","depth":27,"bounds":{"left":0.028590426,"top":0.14844373,"width":0.022273935,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.14924182,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":8,"bounds":{"left":0.030917553,"top":0.14924182,"width":0.019946808,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.14924182,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.022273935,"top":0.1660016,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"static","depth":27,"bounds":{"left":0.028590426,"top":0.1660016,"width":0.010970744,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.16679968,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":5,"bounds":{"left":0.030917553,"top":0.16679968,"width":0.008976064,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.16679968,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.1819633,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":".env","depth":27,"bounds":{"left":0.028590426,"top":0.18355946,"width":0.00831117,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.18435754,"width":0.0013297872,"height":0.011971269}},{"char_start":1,"char_count":3,"bounds":{"left":0.029920213,"top":0.18435754,"width":0.006981383,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.19952115,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"cli.py","depth":27,"bounds":{"left":0.028590426,"top":0.20111732,"width":0.010638298,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.2019154,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":5,"bounds":{"left":0.030917553,"top":0.2019154,"width":0.00831117,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.2019154,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.21707901,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.py","depth":27,"bounds":{"left":0.028590426,"top":0.21867518,"width":0.011303191,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.21947326,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":4,"bounds":{"left":0.03125,"top":0.21947326,"width":0.008643617,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.23463687,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"docker-compose.yml","depth":27,"bounds":{"left":0.028590426,"top":0.23623304,"width":0.042220745,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.23703113,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":17,"bounds":{"left":0.03125,"top":0.23703113,"width":0.03956117,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.25219473,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Dockerfile","depth":27,"bounds":{"left":0.028590426,"top":0.25379092,"width":0.020611702,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.254589,"width":0.0033244682,"height":0.011971269}},{"char_start":1,"char_count":9,"bounds":{"left":0.031914894,"top":0.254589,"width":0.017287234,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.254589,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.2697526,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"main.py","depth":27,"bounds":{"left":0.028590426,"top":0.27134877,"width":0.015625,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.27214685,"width":0.003656915,"height":0.011971269}},{"char_start":1,"char_count":6,"bounds":{"left":0.032247342,"top":0.27214685,"width":0.012300532,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.27214685,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.28731045,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"requirements.txt","depth":27,"bounds":{"left":0.028590426,"top":0.28890663,"width":0.032912236,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.2897047,"width":0.0016622341,"height":0.011971269}},{"char_start":1,"char_count":15,"bounds":{"left":0.03025266,"top":0.2897047,"width":0.03158245,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.2897047,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.3064645,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"data","depth":27,"bounds":{"left":0.025930852,"top":0.3064645,"width":0.008976064,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.30726257,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":3,"bounds":{"left":0.028590426,"top":0.30726257,"width":0.0063164895,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.32402235,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"logs","depth":27,"bounds":{"left":0.025930852,"top":0.32402235,"width":0.00831117,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.32482043,"width":0.0009973404,"height":0.011971269}},{"char_start":1,"char_count":3,"bounds":{"left":0.026928192,"top":0.32482043,"width":0.0076462766,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.32482043,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.3415802,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"pipes","depth":27,"bounds":{"left":0.025930852,"top":0.3415802,"width":0.010970744,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.3423783,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":4,"bounds":{"left":0.028590426,"top":0.3423783,"width":0.00831117,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.3575419,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":".gitignore","depth":27,"bounds":{"left":0.025930852,"top":0.35913807,"width":0.018949468,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.35993615,"width":0.0013297872,"height":0.011971269}},{"char_start":1,"char_count":9,"bounds":{"left":0.027260639,"top":0.35993615,"width":0.017952127,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.37509975,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"app_settings.json","depth":27,"bounds":{"left":0.025930852,"top":0.37669593,"width":0.03557181,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.377494,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":16,"bounds":{"left":0.02825798,"top":0.377494,"width":0.03324468,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.3926576,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"archive.db","depth":27,"bounds":{"left":0.025930852,"top":0.3942538,"width":0.020944148,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.39505187,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":9,"bounds":{"left":0.02825798,"top":0.39505187,"width":0.01861702,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.4102155,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"archive.db-bak","depth":27,"bounds":{"left":0.025930852,"top":0.41181165,"width":0.03025266,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.41260973,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":13,"bounds":{"left":0.02825798,"top":0.41260973,"width":0.027925532,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"U","depth":27,"bounds":{"left":0.10704787,"top":0.41260973,"width":0.0029920214,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.42777336,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite","depth":27,"bounds":{"left":0.025930852,"top":0.4293695,"width":0.017287234,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.4301676,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":8,"bounds":{"left":0.028590426,"top":0.4301676,"width":0.014960106,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.44533122,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite-shm","depth":27,"bounds":{"left":0.025930852,"top":0.44692737,"width":0.027925532,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.44772545,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":12,"bounds":{"left":0.028590426,"top":0.44772545,"width":0.025265958,"height":0.011971269}}],"role_description":"text"}]...
|
7143970419026987193
|
-5570049054802798208
|
click
|
accessibility
|
NULL
|
Explorer (⇧⌘E) - 1 unsaved file
1
Search (⇧⌘F)
Explorer (⇧⌘E) - 1 unsaved file
1
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py
M
db.py
docker-compose.yml
Dockerfile
M
main.py
M
requirements.txt
M
data
logs
pipes
.gitignore
app_settings.json
archive.db
archive.db-bak
U
db.sqlite
db.sqlite-shm...
|
21107
|
NULL
|
NULL
|
NULL
|
|
21110
|
923
|
16
|
2026-05-11T17:12:36.804928+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-11/1778 /Users/lukas/.screenpipe/data/data/2026-05-11/1778519556804_m2.jpg...
|
Code
|
Implement and run pipe l… — screenpipe [SSH: nas]
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Explorer (⇧⌘E) - 1 unsaved file
1
Search (⇧⌘F)
Explorer (⇧⌘E) - 1 unsaved file
1
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py
M
db.py
docker-compose.yml
Dockerfile
M
main.py
M
requirements.txt
M
data
logs
pipes
.gitignore
app_settings.json
archive.db
archive.db-bak
U
db.sqlite
db.sqlite-shm
db.sqlite-wal
screenpipe_sync_updated.sh
U
screenpipe_sync.sh
screenpipe.db
Outline Section
OUTLINE
OUTLINE
Timeline Section
TIMELINE
TIMELINE
app_settings.json, Editor Group 1
screenpipe_sync.sh, Editor Group 1
pipe.md, Editor Group 1
.env, Editor Group 1
#!/bin/bash
# screenpipe_sync.sh
# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).
# Also copies the day's video/frame data folder to the NAS.
#
# Schema-drift tolerant: if Screenpipe migrations add new columns to the source DB,
# the NAS archive gets ALTER TABLE'd to match. Inserts use explicit column lists,
# so positional mismatches can't occur.
#
# Usage:
# ./screenpipe_sync.sh # syncs yesterday (default)
# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date
# ./screenpipe_sync.sh today # syncs today so far
#
# Cron example (runs at 3am daily):
# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1
set -euo pipefail
# ─── CONFIG ───────────────────────────────────────────────────────────────────
DB_SRC="${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}"
NAS_MOUNT="${NAS_MOUNT:-/Volumes/screenpipe}"
NAS_DB="$NAS_MOUNT/archive.db"
NAS_DATA="$NAS_MOUNT/data"
LOG_FILE="$HOME/.screenpipe/sync.log"
# Tables that get schema drift handling. Order matters for FK-ish references
# (parents before children: video_chunks → frames → elements/ocr_text/ui_events).
SYNC_TABLES=(video_chunks frames elements ocr_text ui_events meetings)
# ──────────────────────────────────────────────────────────────────────────────
# ─── HELPERS ──────────────────────────────────────────────────────────────────
SCRIPT_START=$(date +%s)
log() {
local msg="[$(date '+%Y-%m-%d %H:%M:%S')] $*"
echo "$msg" | tee -a "$LOG_FILE"
}
step() {
local now=$(date +%s)
local elapsed=$(( now - SCRIPT_START ))
local min=$(( elapsed / 60 ))
local sec=$(( elapsed % 60 ))
printf "\n[+%02dm%02ds] ▶ %s\n" "$min" "$sec" "$*" | tee -a "$LOG_FILE"
}
run_sqlite_heredoc() {
local label="$1"
local sql="$2"
local start=$(date +%s)
printf " %-36s " "$label"
sqlite3 "$DB_SRC" <<< "$sql" &
local pid=$!
local spin=[PASSWORD] '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')
local i=0
while kill -0 "$pid" 2>/dev/null; do
printf "\r %-36s %s " "$label" "${spin[$i]}"
i=$(( (i + 1) % 10 ))
sleep 0.2
done
wait "$pid"
local rc=$?
if [ $rc -ne 0 ]; then
printf "\r %-36s ✗ FAILED\n" "$label" | tee -a "$LOG_FILE"
exit $rc
fi
local dur=$(( $(date +%s) - start ))
printf "\r %-36s ✓ %dm%02ds\n" "$label" "$(( dur / 60 ))" "$(( dur % 60 ))" | tee -a "$LOG_FILE"
}
check() {
local label="$1" got="$2" expected="$3"
if [ "$got" -eq "$expected" ]; then
printf " %-20s %s / %s ✓\n" "$label:" "$got" "$expected"
else
printf " %-20s %s / %s ✗ MISMATCH\n" "$label:" "$got" "$expected"
fi
}
# ─── SCHEMA HELPERS ───────────────────────────────────────────────────────────
# Echoes "name|type" lines for a table from a given DB.
table_columns_with_types() {
local db="$1" table="$2"
sqlite3 "$db" "PRAGMA table_info($table);" | awk -F'|' '{print $2 "|" $3}'
}
# Echoes just column names, one per line.
table_columns() {
local db="$1" table="$2"
sqlite3 "$db" "PRAGMA table_info($table);" | awk -F'|' '{print $2}'
}
# Returns true (0) if a table exists in the given DB.
table_exists() {
local db="$1" table="$2"
local count
count=$(sqlite3 "$db" "SELECT COUNT(*) FROM sqlite_master WHERE type='table' AND name='$table';")
[ "$count" -gt 0 ]
}
# Adds any columns present in source but missing in NAS for the given table.
# Uses ALTER TABLE ADD COLUMN, which is a fast metadata-only operation in SQLite.
ensure_columns() {
local table="$1"
local label="schema: $table"
printf " %-36s " "$label"
if ! table_exists "$DB_SRC" "$table"; then
printf "✗ source missing — skipping\n"
return 0
fi
if ! table_exists "$NAS_DB" "$table"; then
printf "✓ fresh (created above)\n"
return 0
fi
local src_cols
src_cols=$(table_columns_with_types "$DB_SRC" "$table")
local nas_cols
nas_cols=$(table_columns "$NAS_DB" "$table")
local added=0
local added_names=""
while IFS='|' read -r name type; do
[ -z "$name" ] && continue
# Use grep -F -x for fixed-string exact match (safe against regex chars).
if ! echo "$nas_cols" | grep -Fxq "$name"; then
# SQLite ALTER TABLE ADD COLUMN: type is optional, no NOT NULL allowed
# without a constant default. Default-NULL is exactly what we want for archive.
sqlite3 "$NAS_DB" "ALTER TABLE $table ADD COLUMN \"$name\" $type;"
added=$((added + 1))
added_names="$added_names $name"
fi
done <<< "$src_cols"
if [ "$added" -gt 0 ]; then
printf "✓ added %d:%s\n" "$added" "$added_names"
else
printf "✓ in sync\n"
fi
}
# Echoes a comma-separated list of source columns for a table, double-quoted
# so reserved words and hyphens are safe. If an alias is provided, columns are
# prefixed (e.g. `o."col"`). Used for both INSERT and SELECT sides; aliased
# form is required when SELECTing from a JOIN where column names collide
# (e.g. ocr_text and frames both have app_name, window_name).
build_col_list() {
local table="$1"
local alias="${2:-}"
local prefix=""
[ -n "$alias" ] && prefix="${alias}."
table_columns "$DB_SRC" "$table" | awk 'NF' | awk -v p="$prefix" '{print p "\"" $0 "\""}' | paste -sd, -
}
# ──────────────────────────────────────────────────────────────────────────────
# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────
if [ "${1:-}" = "today" ]; then
TARGET_DATE=$(date +%Y-%m-%d)
elif [ -n "${1:-}" ]; then
TARGET_DATE="$1"
if ! [[ "$TARGET_DATE" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then
echo "ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday."
exit 1
fi
else
TARGET_DATE=$(date -v-1d +%Y-%m-%d)
fi
log "========================================"
log "Screenpipe sync starting for: $TARGET_DATE"
log "========================================"
# ─── PREFLIGHT ────────────────────────────────────────────────────────────────
step "Preflight checks"
if [ ! -f "$DB_SRC" ]; then
log "ERROR: Source DB not found at $DB_SRC"; exit 1
fi
printf " %-20s %s (%s)\n" "Source DB:" "OK" "$(du -sh "$DB_SRC" | cut -f1)"
if [ ! -d "$NAS_MOUNT" ]; then
log "ERROR: NAS not mounted at $NAS_MOUNT"; exit 1
fi
printf " %-20s %s\n" "NAS mount:" "OK $NAS_MOUNT"
# Check if DB already synced for this date
DB_ALREADY_SYNCED=false
if [ -f "$NAS_DB" ]; then
if table_exists "$NAS_DB" "frames"; then
EXISTING=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';" 2>/dev/null || echo "0")
if [ "$EXISTING" -gt "0" ]; then
log "Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync"
DB_ALREADY_SYNCED=true
else
printf " %-20s %s (%s)\n" "Archive DB:" "exists" "$(du -sh "$NAS_DB" | cut -f1)"
fi
else
printf " %-20s %s\n" "Archive DB:" "exists, no frames table yet"
fi
else
printf " %-20s %s\n" "Archive DB:" "will be created"
fi
# Source data dir for this date
DATA_SRC="$HOME/.screenpipe/data/data/$TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
DATA_SIZE=$(du -sh "$DATA_SRC" | cut -f1)
DATA_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
printf " %-20s %s (%s files, %s)\n" "Data dir:" "OK" "$DATA_FILES" "$DATA_SIZE"
else
printf " %-20s %s\n" "Data dir:" "not found — skipping file copy"
fi
# ─── DB SYNC ──────────────────────────────────────────────────────────────────
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────
step "Counting source rows for $TARGET_DATE"
SRC_FRAMES=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
SRC_ELEMENTS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_UI=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
SRC_OCR=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_MEETINGS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';")
printf " %-20s %s\n" "frames:" "$SRC_FRAMES"
printf " %-20s %s\n" "elements:" "$SRC_ELEMENTS"
printf " %-20s %s\n" "ui_events:" "$SRC_UI"
printf " %-20s %s\n" "ocr_text:" "$SRC_OCR"
printf " %-20s %s\n" "meetings:" "$SRC_MEETINGS"
if [ "$SRC_FRAMES" -eq "0" ]; then
log "No frames found for $TARGET_DATE — skipping DB sync"
DB_ALREADY_SYNCED=true
fi
fi
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── INIT TABLES ──────────────────────────────────────────────────────────
step "Initialising tables (CREATE IF NOT EXISTS)"
run_sqlite_heredoc "creating tables" "
ATTACH '$NAS_DB' AS nas;
CREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;
CREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;
CREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;
CREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;
DETACH nas;
"
# ─── SCHEMA DRIFT FIX ─────────────────────────────────────────────────────
# Runs AFTER CREATE IF NOT EXISTS so newly-created tables are no-ops here,
# and pre-existing tables get any missing columns added.
step "Reconciling NAS schema with source"
for tbl in "${SYNC_TABLES[@]}"; do
ensure_columns "$tbl"
done
run_sqlite_heredoc "creating indexes" "
ATTACH '$NAS_DB' AS nas;
CREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);
CREATE INDEX IF NOT EXISTS nas.idx_frames_document_path ON frames(document_path) WHERE document_path IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_elements_onscreen_frame ON elements(frame_id) WHERE on_screen = 1 AND text IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);
CREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);
DETACH nas;
"
run_sqlite_heredoc "creating FTS tables" "
ATTACH '$NAS_DB' AS nas;
CREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(
text, role, frame_id UNINDEXED,
content='elements', content_rowid='id', tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(
full_text, app_name, window_name, browser_url, id UNINDEXED,
tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(
text_content,
app_name,
window_title,
element_name,
content='ui_events',
content_rowid='id',
tokenize='unicode61'
);
DETACH nas;
"
# ─── BUILD EXPLICIT COLUMN LISTS ──────────────────────────────────────────
# After ensure_columns, source ⊆ NAS for every synced table, so source's
# column list is a safe subset to use on both sides of the INSERT.
# For tables that JOIN frames (ocr_text, elements), the SELECT side needs
# alias-qualified columns because both tables share names (app_name, etc).
FRAMES_COLS=$(build_col_list frames)
ELEMENTS_COLS=$(build_col_list elements)
ELEMENTS_COLS_E=$(build_col_list elements e)
UI_EVENTS_COLS=$(build_col_list ui_events)
OCR_TEXT_COLS=$(build_col_list ocr_text)
OCR_TEXT_COLS_O=$(build_col_list ocr_text o)
VIDEO_CHUNKS_COLS=$(build_col_list video_chunks)
MEETINGS_COLS=$(build_col_list meetings)
# ─── SYNC DATA ────────────────────────────────────────────────────────────
step "Syncing data for $TARGET_DATE"
run_sqlite_heredoc "video_chunks" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.video_chunks ($VIDEO_CHUNKS_COLS)
SELECT $VIDEO_CHUNKS_COLS FROM main.video_chunks
WHERE id IN (
SELECT DISTINCT video_chunk_id FROM main.frames
WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL
);
DETACH nas;
"
run_sqlite_heredoc "frames ($SRC_FRAMES rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.frames ($FRAMES_COLS)
SELECT $FRAMES_COLS FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ocr_text ($SRC_OCR rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ocr_text ($OCR_TEXT_COLS)
SELECT $OCR_TEXT_COLS_O FROM main.ocr_text o
JOIN main.frames f ON o.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ui_events ($SRC_UI rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ui_events ($UI_EVENTS_COLS)
SELECT $UI_EVENTS_COLS FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "elements ($SRC_ELEMENTS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.elements ($ELEMENTS_COLS)
SELECT $ELEMENTS_COLS_E FROM main.elements e
JOIN main.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "meetings ($SRC_MEETINGS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.meetings ($MEETINGS_COLS)
SELECT $MEETINGS_COLS FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';
DETACH nas;
"
# ─── FTS UPDATE ───────────────────────────────────────────────────────────
step "Updating FTS indexes"
run_sqlite_heredoc "elements_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.elements_fts(rowid, text, role)
SELECT e.id, e.text, e.role
FROM nas.elements e
JOIN nas.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE'
AND e.text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "frames_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)
SELECT id, full_text, app_name, window_name, browser_url, id
FROM nas.frames
WHERE date(timestamp) = '$TARGET_DATE'
AND full_text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "ui_events_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)
SELECT id, text_content, app_name, window_title, element_name
FROM nas.ui_events
WHERE date(timestamp) = '$TARGET_DATE'
AND text_content IS NOT NULL;
DETACH nas;
"
# ─── VERIFY DB ────────────────────────────────────────────────────────────
step "Verifying DB"
V_FRAMES=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
V_ELEMENTS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_UI=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
V_OCR=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_MEETINGS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';")
check "frames" "$V_FRAMES" "$SRC_FRAMES"
check "elements" "$V_ELEMENTS" "$SRC_ELEMENTS"
check "ui_events" "$V_UI" "$SRC_UI"
check "ocr_text" "$V_OCR" "$SRC_OCR"
check "meetings" "$V_MEETINGS" "$SRC_MEETINGS"
fi
# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────
# Always runs regardless of DB sync status
step "Copying data folder for $TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
mkdir -p "$NAS_DATA/$TARGET_DATE"
RSYNC_START=$(date +%s)
printf " %-36s " "rsync $TARGET_DATE/ → NAS"
rsync -a --ignore-existing \
"$DATA_SRC/" \
"$NAS_DATA/$TARGET_DATE/" \
2>>"$LOG_FILE"
RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))
COPIED_FILES=$(ls "$NAS_DATA/$TARGET_DATE" | wc -l | tr -d ' ')
SRC_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
COPIED_SIZE=$(du -sh "$NAS_DATA/$TARGET_DATE" | cut -f1)
if [ "$COPIED_FILES" -eq "$SRC_FILES" ]; then
printf "\r %-36s ✓ %dm%02ds (%s files, %s)\n" \
"rsync $TARGET_DATE/ → NAS" \
"$(( RSYNC_DUR / 60 ))" "$(( RSYNC_DUR % 60 ))" \
"$COPIED_FILES" "$COPIED_SIZE" | tee -a "$LOG_FILE"
else
printf "\r %-36s ✗ %s / %s files\n" \
"rsync $TARGET_DATE/ → NAS" "$COPIED_FILES" "$SRC_FILES" | tee -a "$LOG_FILE"
fi
else
printf " %-36s %s\n" "rsync $TARGET_DATE/ → NAS" "skipped (no source dir)"
fi
# ─── COPY LOGS ────────────────────────────────────────────────────────────────
# Screenpipe writes daily logs to ~/.screenpipe/screenpipe.YYYY-MM-DD.N.log
# (N is a rotation counter, almost always 0). Mirror them to NAS so log
# analysis can happen on the consumer side without SSH'ing back to the Mac.
step "Copying screenpipe logs for $TARGET_DATE"
NAS_LOGS="$NAS_MOUNT/logs"
mkdir -p "$NAS_LOGS"
# Use a glob with nullglob so an empty match doesn't expand to a literal pattern.
shopt -s nullglob
LOG_FILES=( "$HOME/.screenpipe/screenpipe.$TARGET_DATE."*.log )
shopt -u nullglob
if [ ${#LOG_FILES[@]} -gt 0 ]; then
printf " %-36s " "rsync logs → NAS"
# No --ignore-existing here: logs grow during the day, so we want rsync's
# default size+mtime check to refresh files that have changed.
rsync -a "${LOG_FILES[@]}" "$NAS_LOGS/" 2>>"$LOG_FILE"
COPIED=${#LOG_FILES[@]}
TOTAL_SIZE=$(du -ch "${LOG_FILES[@]}" | tail -1 | cut -f1)
printf "✓ %d file(s), %s\n" "$COPIED" "$TOTAL_SIZE" | tee -a "$LOG_FILE"
else
printf " %-36s %s\n" "rsync logs → NAS" "skipped (no matching logs)"
fi
# ─── SUMMARY ──────────────────────────────────────────────────────────────────
TOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))
DB_SIZE=$(du -sh "$NAS_DB" | cut -f1)
echo ""
log "Archive DB size: $DB_SIZE"
log "Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s"
log "Sync complete for $TARGET_DATE"
log "========================================"
# Mirror this script's own logbook to NAS so sync health can be monitored
# from the consumer side. Done last so the summary lines above are included.
rsync -a "$HOME/.screenpipe/sync.log" "$NAS_LOGS/sync.log" 2>/dev/null || true
#!/bin/bash
# screenpipe_sync.sh
# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).
# Also copies the day's video/frame data folder to the NAS.
#
# Schema-drift tolerant: if Screenpipe migrations add new columns to the source DB,
# the NAS archive gets ALTER TABLE'd to match. Inserts use explicit column lists,
# so positional mismatches can't occur.
#
# Usage:
# ./screenpipe_sync.sh # syncs yesterday (default)
# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date
# ./screenpipe_sync.sh today # syncs today so far
#
# Cron example (runs at 3am daily):
# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1
set -euo pipefail
# ─── CONFIG ───────────────────────────────────────────────────────────────────
DB_SRC="${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}"
NAS_MOUNT="${NAS_MOUNT:-/Volumes/screenpipe}"
NAS_DB="$NAS_MOUNT/archive.db"
NAS_DATA="$NAS_MOUNT/data"
LOG_FILE="$HOME/.screenpipe/sync.log"
# Tables that get schema drift handling. Order matters for FK-ish references
# (parents before children: video_chunks → frames → elements/ocr_text/ui_events).
SYNC_TABLES=(video_chunks frames elements ocr_text ui_events meetings)
# ──────────────────────────────────────────────────────────────────────────────
# ─── HELPERS ──────────────────────────────────────────────────────────────────
SCRIPT_START=$(date +%s)
log() {
local msg="[$(date '+%Y-%m-%d %H:%M:%S')] $*"
echo "$msg" | tee -a "$LOG_FILE"
}
step() {
local now=$(date +%s)
local elapsed=$(( now - SCRIPT_START ))
local min=$(( elapsed / 60 ))
local sec=$(( elapsed % 60 ))
printf "\n[+%02dm%02ds] ▶ %s\n" "$min" "$sec" "$*" | tee -a "$LOG_FILE"
}
run_sqlite_heredoc() {
local label="$1"
local sql="$2"
local start=$(date +%s)
printf " %-36s " "$label"
sqlite3 "$DB_SRC" <<< "$sql" &
local pid=$!
local spin=[PASSWORD] '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')
local i=0
while kill -0 "$pid" 2>/dev/null; do
printf "\r %-36s %s " "$label" "${spin[$i]}"
i=$(( (i + 1) % 10 ))
sleep 0.2
done
wait "$pid"
local rc=$?
if [ $rc -ne 0 ]; then
printf "\r %-36s ✗ FAILED\n" "$label" | tee -a "$LOG_FILE"
exit $rc
fi
local dur=$(( $(date +%s) - start ))
printf "\r %-36s ✓ %dm%02ds\n" "$label" "$(( dur / 60 ))" "$(( dur % 60 ))" | tee -a "$LOG_FILE"
}
check() {
local label="$1" got="$2" expected="$3"
if [ "$got" -eq "$expected" ]; then
printf " %-20s %s / %s ✓\n" "$label:" "$got" "$expected"
else
printf " %-20s %s / %s ✗ MISMATCH\n" "$label:" "$got" "$expected"
fi
}
# ─── SCHEMA HELPERS ───────────────────────────────────────────────────────────
# Echoes "name|type" lines for a table from a given DB.
table_columns_with_types() {
local db="$1" table="$2"
sqlite3 "$db" "PRAGMA table_info($table);" | awk -F'|' '{print $2 "|" $3}'
}
# Echoes just column names, one per line.
table_columns() {
local db="$1" table="$2"
sqlite3 "$db" "PRAGMA table_info($table);" | awk -F'|' '{print $2}'
}
# Returns true (0) if a table exists in the given DB.
table_exists() {
local db="$1" table="$2"
local count
count=$(sqlite3 "$db" "SELECT COUNT(*) FROM sqlite_master WHERE type='table' AND name='$table';")
[ "$count" -gt 0 ]
}
# Adds any columns present in source but missing in NAS for the given table.
# Uses ALTER TABLE ADD COLUMN, which is a fast metadata-only operation in SQLite.
ensure_columns() {
local table="$1"
local label="schema: $table"
printf " %-36s " "$label"
if ! table_exists "$DB_SRC" "$table"; then
printf "✗ source missing — skipping\n"
return 0
fi
if ! table_exists "$NAS_DB" "$table"; then
printf "✓ fresh (created above)\n"
return 0
fi
local src_cols
src_cols=$(table_columns_with_types "$DB_SRC" "$table")
local nas_cols
nas_cols=$(table_columns "$NAS_DB" "$table")
local added=0
local added_names=""
while IFS='|' read -r name type; do
[ -z "$name" ] && continue
# Use grep -F -x for fixed-string exact match (safe against regex chars).
if ! echo "$nas_cols" | grep -Fxq "$name"; then
# SQLite ALTER TABLE ADD COLUMN: type is optional, no NOT NULL allowed
# without a constant default. Default-NULL is exactly what we want for archive.
sqlite3 "$NAS_DB" "ALTER TABLE $table ADD COLUMN \"$name\" $type;"
added=$((added + 1))
added_names="$added_names $name"
fi
done <<< "$src_cols"
if [ "$added" -gt 0 ]; then
printf "✓ added %d:%s\n" "$added" "$added_names"
else
printf "✓ in sync\n"
fi
}
# Echoes a comma-separated list of source columns for a table, double-quoted
# so reserved words and hyphens are safe. If an alias is provided, columns are
# prefixed (e.g. `o."col"`). Used for both INSERT and SELECT sides; aliased
# form is required when SELECTing from a JOIN where column names collide
# (e.g. ocr_text and frames both have app_name, window_name).
build_col_list() {
local table="$1"
local alias="${2:-}"
local prefix=""
[ -n "$alias" ] && prefix="${alias}."
table_columns "$DB_SRC" "$table" | awk 'NF' | awk -v p="$prefix" '{print p "\"" $0 "\""}' | paste -sd, -
}
# ──────────────────────────────────────────────────────────────────────────────
# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────
if [ "${1:-}" = "today" ]; then
TARGET_DATE=$(date +%Y-%m-%d)
elif [ -n "${1:-}" ]; then
TARGET_DATE="$1"
if ! [[ "$TARGET_DATE" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then
echo "ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday."
exit 1
fi
else
TARGET_DATE=$(date -v-1d +%Y-%m-%d)
fi
log "========================================"
log "Screenpipe sync starting for: $TARGET_DATE"
log "========================================"
# ─── PREFLIGHT ────────────────────────────────────────────────────────────────
step "Preflight checks"
if [ ! -f "$DB_SRC" ]; then
log "ERROR: Source DB not found at $DB_SRC"; exit 1
fi
printf " %-20s %s (%s)\n" "Source DB:" "OK" "$(du -sh "$DB_SRC" | cut -f1)"
if [ ! -d "$NAS_MOUNT" ]; then
log "ERROR: NAS not mounted at $NAS_MOUNT"; exit 1
fi
printf " %-20s %s\n" "NAS mount:" "OK $NAS_MOUNT"
# Check if DB already synced for this date
DB_ALREADY_SYNCED=false
if [ -f "$NAS_DB" ]; then
if table_exists "$NAS_DB" "frames"; then
EXISTING=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';" 2>/dev/null || echo "0")
if [ "$EXISTING" -gt "0" ]; then
log "Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync"
DB_ALREADY_SYNCED=true
else
printf " %-20s %s (%s)\n" "Archive DB:" "exists" "$(du -sh "$NAS_DB" | cut -f1)"
fi
else
printf " %-20s %s\n" "Archive DB:" "exists, no frames table yet"
fi
else
printf " %-20s %s\n" "Archive DB:" "will be created"
fi
# Source data dir for this date
DATA_SRC="$HOME/.screenpipe/data/data/$TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
DATA_SIZE=$(du -sh "$DATA_SRC" | cut -f1)
DATA_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
printf " %-20s %s (%s files, %s)\n" "Data dir:" "OK" "$DATA_FILES" "$DATA_SIZE"
else
printf " %-20s %s\n" "Data dir:" "not found — skipping file copy"
fi
# ─── DB SYNC ──────────────────────────────────────────────────────────────────
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────
step "Counting source rows for $TARGET_DATE"
SRC_FRAMES=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
SRC_ELEMENTS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_UI=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
SRC_OCR=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_MEETINGS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';")
printf " %-20s %s\n" "frames:" "$SRC_FRAMES"
printf " %-20s %s\n" "elements:" "$SRC_ELEMENTS"
printf " %-20s %s\n" "ui_events:" "$SRC_UI"
printf " %-20s %s\n" "ocr_text:" "$SRC_OCR"
printf " %-20s %s\n" "meetings:" "$SRC_MEETINGS"
if [ "$SRC_FRAMES" -eq "0" ]; then
log "No frames found for $TARGET_DATE — skipping DB sync"
DB_ALREADY_SYNCED=true
fi
fi
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── INIT TABLES ──────────────────────────────────────────────────────────
step "Initialising tables (CREATE IF NOT EXISTS)"
run_sqlite_heredoc "creating tables" "
ATTACH '$NAS_DB' AS nas;
CREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;
CREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;
CREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;
CREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;
DETACH nas;
"
# ─── SCHEMA DRIFT FIX ─────────────────────────────────────────────────────
# Runs AFTER CREATE IF NOT EXISTS so newly-created tables are no-ops here,
# and pre-existing tables get any missing columns added.
step "Reconciling NAS schema with source"
for tbl in "${SYNC_TABLES[@]}"; do
ensure_columns "$tbl"
done
run_sqlite_heredoc "creating indexes" "
ATTACH '$NAS_DB' AS nas;
CREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);
CREATE INDEX IF NOT EXISTS nas.idx_frames_document_path ON frames(document_path) WHERE document_path IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_elements_onscreen_frame ON elements(frame_id) WHERE on_screen = 1 AND text IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);
CREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);
DETACH nas;
"
run_sqlite_heredoc "creating FTS tables" "
ATTACH '$NAS_DB' AS nas;
CREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(
text, role, frame_id UNINDEXED,
content='elements', content_rowid='id', tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(
full_text, app_name, window_name, browser_url, id UNINDEXED,
tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(
text_content,
app_name,
window_title,
element_name,
content='ui_events',
content_rowid='id',
tokenize='unicode61'
);
DETACH nas;
"
# ─── BUILD EXPLICIT COLUMN LISTS ──────────────────────────────────────────
# After ensure_columns, source ⊆ NAS for every synced table, so source's
# column list is a safe subset to use on both sides of the INSERT.
# For tables that JOIN frames (ocr_text, elements), the SELECT side needs
# alias-qualified columns because both tables share names (app_name, etc).
FRAMES_COLS=$(build_col_list frames)
ELEMENTS_COLS=$(build_col_list elements)
ELEMENTS_COLS_E=$(build_col_list elements e)
UI_EVENTS_COLS=$(build_col_list ui_events)
OCR_TEXT_COLS=$(build_col_list ocr_text)
OCR_TEXT_COLS_O=$(build_col_list ocr_text o)
VIDEO_CHUNKS_COLS=$(build_col_list video_chunks)
MEETINGS_COLS=$(build_col_list meetings)
# ─── SYNC DATA ────────────────────────────────────────────────────────────
step "Syncing data for $TARGET_DATE"
run_sqlite_heredoc "video_chunks" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.video_chunks ($VIDEO_CHUNKS_COLS)
SELECT $VIDEO_CHUNKS_COLS FROM main.video_chunks
WHERE id IN (
SELECT DISTINCT video_chunk_id FROM main.frames
WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL
);
DETACH nas;
"
run_sqlite_heredoc "frames ($SRC_FRAMES rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.frames ($FRAMES_COLS)
SELECT $FRAMES_COLS FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ocr_text ($SRC_OCR rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ocr_text ($OCR_TEXT_COLS)
SELECT $OCR_TEXT_COLS_O FROM main.ocr_text o
JOIN main.frames f ON o.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ui_events ($SRC_UI rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ui_events ($UI_EVENTS_COLS)
SELECT $UI_EVENTS_COLS FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "elements ($SRC_ELEMENTS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.elements ($ELEMENTS_COLS)
SELECT $ELEMENTS_COLS_E FROM main.elements e
JOIN main.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "meetings ($SRC_MEETINGS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.meetings ($MEETINGS_COLS)
SELECT $MEETINGS_COLS FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';
DETACH nas;
"
# ─── FTS UPDATE ───────────────────────────────────────────────────────────
step "Updating FTS indexes"
run_sqlite_heredoc "elements_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.elements_fts(rowid, text, role)
SELECT e.id, e.text, e.role
FROM nas.elements e
JOIN nas.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE'
AND e.text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "frames_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)
SELECT id, full_text, app_name, window_name, browser_url, id
FROM nas.frames
WHERE date(timestamp) = '$TARGET_DATE'
AND full_text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "ui_events_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)
SELECT id, text_content, app_name, window_title, element_name
FROM nas.ui_events
WHERE date(timestamp) = '$TARGET_DATE'
AND text_content IS NOT NULL;
DETACH nas;
"
# ─── VERIFY DB ────────────────────────────────────────────────────────────
step "Verifying DB"
V_FRAMES=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
V_ELEMENTS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_UI=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
V_OCR=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_MEETINGS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';")
check "frames" "$V_FRAMES" "$SRC_FRAMES"
check "elements" "$V_ELEMENTS" "$SRC_ELEMENTS"
check "ui_events" "$V_UI" "$SRC_UI"
check "ocr_text" "$V_OCR" "$SRC_OCR"
check "meetings" "$V_MEETINGS" "$SRC_MEETINGS"
fi
# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────
# Always runs regardless of DB sync status
step "Copying data folder for $TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
mkdir -p "$NAS_DATA/$TARGET_DATE"
RSYNC_START=$(date +%s)
printf " %-36s " "rsync $TARGET_DATE/ → NAS"
rsync -a --ignore-existing \
"$DATA_SRC/" \
"$NAS_DATA/$TARGET_DATE/" \
2>>"$LOG_FILE"
RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))
COPIED_FILES=$(ls "$NAS_DATA/$TARGET_DATE" | wc -l | tr -d ' ')
SRC_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
COPIED_SIZE=$(du -sh "$NAS_DATA/$TARGET_DATE" | cut -f1)
if [ "$COPIED_FILES" -eq "$SRC_FILES" ]; then
printf "\r %-36s ✓ %dm%02ds (%s files, %s)\n" \
"rsync $TARGET_DATE/ → NAS" \
"$(( RSYNC_DUR / 60 ))" "$(( RSYNC_DUR % 60 ))" \
"$COPIED_FILES" "$COPIED_SIZE" | tee -a "$LOG_FILE"
else
printf "\r %-36s ✗ %s / %s files\n" \
"rsync $TARGET_DATE/ → NAS" "$COPIED_FILES" "$SRC_FILES" | tee -a "$LOG_FILE"
fi
else
printf " %-36s %s\n" "rsync $TARGET_DATE/ → NAS" "skipped (no source dir)"
fi
# ─── COPY LOGS ────────────────────────────────────────────────────────────────
# Screenpipe writes daily logs to ~/.screenpipe/screenpipe.YYYY-MM-DD.N.log
# (N is a rotation counter, almost always 0). Mirror them to NAS so log
# analysis can happen on the consumer side without SSH'ing back to the Mac.
step "Copying screenpipe logs for $TARGET_DATE"
NAS_LOGS="$NAS_MOUNT/logs"
mkdir -p "$NAS_LOGS"
# Use a glob with nullglob so an empty match doesn't expand to a literal pattern.
shopt -s nullglob
LOG_FILES=( "$HOME/.screenpipe/screenpipe.$TARGET_DATE."*.log )
shopt -u nullglob
if [ ${#LOG_FILES[@]} -gt 0 ]; then
printf " %-36s " "rsync logs → NAS"
# No --ignore-existing here: logs grow during the day, so we want rsync's
# default size+mtime check to refresh files that have changed.
rsync -a "${LOG_FILES[@]}" "$NAS_LOGS/" 2>>"$LOG_FILE"
COPIED=${#LOG_FILES[@]}
TOTAL_SIZE=$(du -ch "${LOG_FILES[@]}" | tail -1 | cut -f1)
printf "✓ %d file(s), %s\n" "$COPIED" "$TOTAL_SIZE" | tee -a "$LOG_FILE"
else
printf " %-36s %s\n" "rsync logs → NAS" "skipped (no matching logs)"
fi
# ─── SUMMARY ──────────────────────────────────────────────────────────────────
TOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))
DB_SIZE=$(du -sh "$NAS_DB" | cut -f1)
echo ""
log "Archive DB size: $DB_SIZE"
log "Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s"
log "Sync complete for $TARGET_DATE"
log "========================================"
# Mirror this script's own logbook to NAS so sync health can be monitored
# from the consumer side. Done last so the summary lines above are included.
rsync -a "$HOME/.screenpipe/sync.log" "$NAS_LOGS/sync.log" 2>/dev/null || true
Implement and run pipe l…, Editor Group 2
Problems (⇧⌘M)
PROBLEMS
Output (⇧⌘U)
OUTPUT
Debug Console (⇧⌘Y)
DEBUG CONSOLE
Terminal (⌃`)
TERMINAL
Ports - 1 forwarded port
PORTS
1
remote SSH: nas
SSH: nas
screenpipe (Git) - master*, Checkout Branch/Tag...
master*
screenpipe (Git) - Synchronize Changes
No Problems
0
0
Forwarded Ports: 8766
1
Notifications
Sign In
Sign In
No results found
Implement and run pipe logic
Session history
New session
Message actions
main.py
main.py
lets implement logic with pipes. how can I run it?
Thinking
Thinking
Let me look at the current project structure to understand what's already in place.
Bash
List project files
IN
find /volume1/screenpipe -type f | head -50 && echo "---" && ls /volume1/screenpipe
Copy code to clipboard
OUT
/volume1/screenpipe/.DS_Store
/volume1/screenpipe/screenpipe.db
/volume1/screenpipe/screenpipe_sync.sh
/volume1/screenpipe/app_settings.json
/volume1/screenpipe/.gitignore
/volume1/screenpipe/archive.db
/volume1/screenpipe/db.sqlite
/volume1/screenpipe/db.sqlite-wal
/volume1/screenpipe/db.sqlite-shm
/volume1/screenpipe/#recycle/desktop.ini
/volume1/screenpipe/#recycle/db.sqlite
/volume1/screenpipe/#recycle/Copy #1 of db.sqlite
/volume1/screenpipe/#recycle/.DS_Store
/volume1/screenpipe/#recycle/Copy #2 of db.sqlite
/volume1/screenpipe/#recycle/archive.db
/volume1/screenpipe/#recycle/Copy #1 of archive.db
/volume1/screenpipe/#recycle/Copy #2 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of archive.db
/volume1/screenpipe/#recycle/Copy #4 of archive.db
/volume1/screenpipe/#recycle/Copy #5 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of db.sqlite
/volume1/screenpipe/#recycle/Copy #4 of db.sqlite
/volume1/screenpipe/#recycle/Copy #6 of archive.db
/volume1/screenpipe/#recycle/test.txt
/volume1/screenpipe/#recycle/Copy #7 of archive.db
/volume1/screenpipe/#recycle/Copy #8 of archive.db
/volume1/screenpipe/#recycle/archive.db-journal
/volume1/screenpipe/#recycle/Copy #1 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #2 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #3 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #4 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #6 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #7 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of db.sqlite
/volume1/screenpipe/pipes/.DS_Store
/volume1/screenpipe/app/.env
/volume1/screenpipe/app/cli.py
/volume1/screenpipe/app/.DS_Store
/volume1/screenpipe/app/db.py
/volume1/screenpipe/app/docker-compose.yml
/volume1/screenpipe/app/main.py
/volume1/screenpipe/app/requirements.txt
/volume1/screenpipe/app/Dockerfile
/volume1/screenpipe/data/.DS_Store
/volume1/screenpipe/.git/description
/volume1/screenpipe/.git/HEAD
/volume1/screenpipe/.git/index
/volume1/screenpipe/.git/COMMIT_EDITMSG
/volume1/screenpipe/#recycle/data/.DS_Store
---
app
app_settings.json
archive.db
data
db.sqlite
db.sqlite-shm
db.sqlite-wal
pipes
#recycle
screenpipe.db
screenpipe_sync.sh
Read
main.py
main.py
Bash
Check pipes directory and docker-compose
IN
ls /volume1/screenpipe/pipes/ && ls /volume1/screenpipe/app/ && cat /volume1/screenpipe/app/docker-compose.yml
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
cli.py
consumers
db.py
docker-compose.yml
Dockerfile
main.py
__pycache__
requirements.txt
static
services:
screenpipe-app:
build: .
container_name: screenpipe-app
restart: unless-stopped
ports:
- "8766:8000"
volumes:
- /volume1/screenpipe:/data
env_file:
- .env
environment:
TZ: Europe/Sofia
DB_PATH: /data/db.sqlite
sqlite-web-archive:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-archive
restart: unless-stopped
ports:
- "8767:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/archive.db"]
sqlite-web-live:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-live
restart: unless-stopped
ports:
- "8768:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/db.sqlite"]
Read
requirements.txt
requirements.txt
Bash
Inspect a pipe directory
IN
ls /volume1/screenpipe/pipes/day-recap/ && cat /volume1/screenpipe/pipes/day-recap/pipe.json 2>/dev/null || ls /volume1/screenpipe/pipes/day-recap/
Copy code to clipboard
OUT
pipe.md
pipe.md
Read
cli.py
cli.py
Bash
List all pipes and their contents
IN
ls /volume1/screenpipe/pipes/ && for d in /volume1/screenpipe/pipes/*/; do echo "=== $d ==="; ls "$d"; done
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
=== /volume1/screenpipe/pipes/ai-habits/ ===
pipe.md
=== /volume1/screenpipe/pipes/day-recap/ ===
pipe.md
=== /volume1/screenpipe/pipes/meeting-summary/ ===
pipe.md
=== /volume1/screenpipe/pipes/standup-update/ ===
pipe.md
=== /volume1/screenpipe/pipes/time-breakdown/ ===
pipe.md
=== /volume1/screenpipe/pipes/video-export/ ===
pipe.md
Bash
Read pipe markdown files
IN
cat /volume1/screenpipe/pipes/day-recap/pipe.md && echo "===" && cat /volume1/screenpipe/pipes/meeting-summary/pipe.md 2>/dev/null | head -50
Copy code to clipboard
OUT
---
schedule: manual
enabled: true
template: true
title: Day Recap
description: "Today's accomplishments, key moments, and unfinished work"
icon: "📋"
featured: true
---
Analyze my screen and audio recordings from today (last 16 hours only).
Read screenpipe skill first.
Use this exact format:
## Summary
One sentence: what I mainly did today.
## Accomplishments
- Top 3 things I finished, with timestamps (e.g. "2:30 PM")
- Name specific apps, files, or projects
## Key Moments
- Important things I saw, said, or heard — with timestamps
## Unfinished Work
- What I should continue tomorrow — name the app/file/task
## Patterns
- Apps I used most, topics that came up repeatedly
Only rep...
|
[{"role":"AXRadioButton","text [{"role":"AXRadioButton","text":"Explorer (⇧⌘E) - 1 unsaved file","depth":19,"bounds":{"left":0.0,"top":0.047885075,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":true},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.057462092,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":22,"bounds":{"left":0.009640957,"top":0.06863528,"width":0.0016622341,"height":0.008778931},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Search (⇧⌘F)","depth":19,"bounds":{"left":0.0,"top":0.08619314,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.09577015,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Source Control (⌃⇧G) - 10 pending changes","depth":19,"bounds":{"left":0.0,"top":0.1245012,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.13407822,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"10","depth":22,"bounds":{"left":0.00831117,"top":0.1452514,"width":0.003656915,"height":0.008778931},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.00831117,"top":0.14604948,"width":0.0016622341,"height":0.007980846}},{"char_start":1,"char_count":1,"bounds":{"left":0.009973404,"top":0.14604948,"width":0.0023271276,"height":0.007980846}}],"role_description":"text"},{"role":"AXRadioButton","text":"Run and Debug (⇧⌘D)","depth":19,"bounds":{"left":0.0,"top":0.16280925,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.17238627,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Remote Explorer","depth":19,"bounds":{"left":0.0,"top":0.20111732,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.21069433,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Extensions (⇧⌘X) - 2 require update","depth":19,"bounds":{"left":0.0,"top":0.23942538,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.2490024,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"2","depth":22,"bounds":{"left":0.009640957,"top":0.2601756,"width":0.0019946808,"height":0.008778931},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Claude Code","depth":19,"bounds":{"left":0.0,"top":0.27773345,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"Containers","depth":19,"bounds":{"left":0.0,"top":0.3160415,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXHeading","text":"EXPLORER","depth":17,"bounds":{"left":0.022606382,"top":0.047885075,"width":0.018949468,"height":0.02793296},"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"EXPLORER","depth":18,"bounds":{"left":0.022606382,"top":0.056664005,"width":0.018949468,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.022606382,"top":0.056664005,"width":0.0023271276,"height":0.0103751}},{"char_start":1,"char_count":7,"bounds":{"left":0.024933511,"top":0.056664005,"width":0.01662234,"height":0.0103751}}],"role_description":"text"},{"role":"AXButton","text":"Explorer Section: screenpipe [SSH: nas]","depth":21,"bounds":{"left":0.015957447,"top":0.07581804,"width":0.09940159,"height":0.017557861},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":true},{"role":"AXStaticText","text":"","depth":23,"bounds":{"left":0.01662234,"top":0.07821229,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"Explorer Section: screenpipe [SSH: nas]","depth":22,"bounds":{"left":0.022606382,"top":0.07581804,"width":0.045877658,"height":0.017557861},"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"SCREENPIPE [SSH: NAS]","depth":23,"bounds":{"left":0.022606382,"top":0.079010375,"width":0.045877658,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.022606382,"top":0.07980846,"width":0.0026595744,"height":0.0103751}},{"char_start":1,"char_count":20,"bounds":{"left":0.025265958,"top":0.07980846,"width":0.043218084,"height":0.0103751}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.09577015,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"#recycle","depth":27,"bounds":{"left":0.025930852,"top":0.09577015,"width":0.017287234,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.096568234,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":7,"bounds":{"left":0.028590426,"top":0.096568234,"width":0.01462766,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.11332801,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"app","depth":27,"bounds":{"left":0.025930852,"top":0.11332801,"width":0.0076462766,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.11412609,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":2,"bounds":{"left":0.02825798,"top":0.11412609,"width":0.005319149,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.11412609,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.022273935,"top":0.13088587,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"__pycache__","depth":27,"bounds":{"left":0.028590426,"top":0.13088587,"width":0.026595745,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.13168396,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":10,"bounds":{"left":0.030917553,"top":0.13168396,"width":0.024268618,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.022273935,"top":0.14844373,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"consumers","depth":27,"bounds":{"left":0.028590426,"top":0.14844373,"width":0.022273935,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.14924182,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":8,"bounds":{"left":0.030917553,"top":0.14924182,"width":0.019946808,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.14924182,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.022273935,"top":0.1660016,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"static","depth":27,"bounds":{"left":0.028590426,"top":0.1660016,"width":0.010970744,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.16679968,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":5,"bounds":{"left":0.030917553,"top":0.16679968,"width":0.008976064,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.16679968,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.1819633,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":".env","depth":27,"bounds":{"left":0.028590426,"top":0.18355946,"width":0.00831117,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.18435754,"width":0.0013297872,"height":0.011971269}},{"char_start":1,"char_count":3,"bounds":{"left":0.029920213,"top":0.18435754,"width":0.006981383,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.19952115,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"cli.py","depth":27,"bounds":{"left":0.028590426,"top":0.20111732,"width":0.010638298,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.2019154,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":5,"bounds":{"left":0.030917553,"top":0.2019154,"width":0.00831117,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.2019154,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.21707901,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.py","depth":27,"bounds":{"left":0.028590426,"top":0.21867518,"width":0.011303191,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.21947326,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":4,"bounds":{"left":0.03125,"top":0.21947326,"width":0.008643617,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.23463687,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"docker-compose.yml","depth":27,"bounds":{"left":0.028590426,"top":0.23623304,"width":0.042220745,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.23703113,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":17,"bounds":{"left":0.03125,"top":0.23703113,"width":0.03956117,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.25219473,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Dockerfile","depth":27,"bounds":{"left":0.028590426,"top":0.25379092,"width":0.020611702,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.254589,"width":0.0033244682,"height":0.011971269}},{"char_start":1,"char_count":9,"bounds":{"left":0.031914894,"top":0.254589,"width":0.017287234,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.254589,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.2697526,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"main.py","depth":27,"bounds":{"left":0.028590426,"top":0.27134877,"width":0.015625,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.27214685,"width":0.003656915,"height":0.011971269}},{"char_start":1,"char_count":6,"bounds":{"left":0.032247342,"top":0.27214685,"width":0.012300532,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.27214685,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.28731045,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"requirements.txt","depth":27,"bounds":{"left":0.028590426,"top":0.28890663,"width":0.032912236,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.2897047,"width":0.0016622341,"height":0.011971269}},{"char_start":1,"char_count":15,"bounds":{"left":0.03025266,"top":0.2897047,"width":0.03158245,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.2897047,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.3064645,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"data","depth":27,"bounds":{"left":0.025930852,"top":0.3064645,"width":0.008976064,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.30726257,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":3,"bounds":{"left":0.028590426,"top":0.30726257,"width":0.0063164895,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.32402235,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"logs","depth":27,"bounds":{"left":0.025930852,"top":0.32402235,"width":0.00831117,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.32482043,"width":0.0009973404,"height":0.011971269}},{"char_start":1,"char_count":3,"bounds":{"left":0.026928192,"top":0.32482043,"width":0.0076462766,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.32482043,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.3415802,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"pipes","depth":27,"bounds":{"left":0.025930852,"top":0.3415802,"width":0.010970744,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.3423783,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":4,"bounds":{"left":0.028590426,"top":0.3423783,"width":0.00831117,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.3575419,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":".gitignore","depth":27,"bounds":{"left":0.025930852,"top":0.35913807,"width":0.018949468,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.35993615,"width":0.0013297872,"height":0.011971269}},{"char_start":1,"char_count":9,"bounds":{"left":0.027260639,"top":0.35993615,"width":0.017952127,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.37509975,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"app_settings.json","depth":27,"bounds":{"left":0.025930852,"top":0.37669593,"width":0.03557181,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.377494,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":16,"bounds":{"left":0.02825798,"top":0.377494,"width":0.03324468,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.3926576,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"archive.db","depth":27,"bounds":{"left":0.025930852,"top":0.3942538,"width":0.020944148,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.39505187,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":9,"bounds":{"left":0.02825798,"top":0.39505187,"width":0.01861702,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.4102155,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"archive.db-bak","depth":27,"bounds":{"left":0.025930852,"top":0.41181165,"width":0.03025266,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.41260973,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":13,"bounds":{"left":0.02825798,"top":0.41260973,"width":0.027925532,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"U","depth":27,"bounds":{"left":0.10704787,"top":0.41260973,"width":0.0029920214,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.42777336,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite","depth":27,"bounds":{"left":0.025930852,"top":0.4293695,"width":0.017287234,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.4301676,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":8,"bounds":{"left":0.028590426,"top":0.4301676,"width":0.014960106,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.44533122,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite-shm","depth":27,"bounds":{"left":0.025930852,"top":0.44692737,"width":0.027925532,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.44772545,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":12,"bounds":{"left":0.028590426,"top":0.44772545,"width":0.025265958,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.46288908,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite-wal","depth":27,"bounds":{"left":0.025930852,"top":0.46448523,"width":0.025930852,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.46528333,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":12,"bounds":{"left":0.028590426,"top":0.46528333,"width":0.023603724,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.48044693,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe_sync_updated.sh","depth":27,"bounds":{"left":0.025930852,"top":0.4820431,"width":0.059175532,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.4828412,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":25,"bounds":{"left":0.02825798,"top":0.4828412,"width":0.056848403,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"U","depth":27,"bounds":{"left":0.10704787,"top":0.4828412,"width":0.0029920214,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.4980048,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe_sync.sh","depth":27,"bounds":{"left":0.025930852,"top":0.49960095,"width":0.039893616,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.50039905,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":17,"bounds":{"left":0.02825798,"top":0.50039905,"width":0.037898935,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.51556265,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe.db","depth":27,"bounds":{"left":0.025930852,"top":0.5171588,"width":0.028590426,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.5179569,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":12,"bounds":{"left":0.02825798,"top":0.5179569,"width":0.026595745,"height":0.011971269}}],"role_description":"text"},{"role":"AXButton","text":"Outline Section","depth":21,"bounds":{"left":0.015957447,"top":0.9473264,"width":0.09940159,"height":0.017557861},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":23,"bounds":{"left":0.01662234,"top":0.9497207,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"OUTLINE","depth":22,"bounds":{"left":0.022606382,"top":0.9473264,"width":0.01662234,"height":0.017557861},"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"OUTLINE","depth":23,"bounds":{"left":0.022606382,"top":0.95131683,"width":0.01662234,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.022606382,"top":0.95131683,"width":0.0029920214,"height":0.0103751}},{"char_start":1,"char_count":6,"bounds":{"left":0.025598405,"top":0.95131683,"width":0.013630319,"height":0.0103751}}],"role_description":"text"},{"role":"AXButton","text":"Timeline Section","depth":21,"bounds":{"left":0.015957447,"top":0.9648843,"width":0.09940159,"height":0.017557861},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":23,"bounds":{"left":0.01662234,"top":0.96727854,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"TIMELINE","depth":22,"bounds":{"left":0.022606382,"top":0.9648843,"width":0.01761968,"height":0.017557861},"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"TIMELINE","depth":23,"bounds":{"left":0.022606382,"top":0.9688747,"width":0.01761968,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.022606382,"top":0.9688747,"width":0.0026595744,"height":0.0103751}},{"char_start":1,"char_count":7,"bounds":{"left":0.025265958,"top":0.9688747,"width":0.015292553,"height":0.0103751}}],"role_description":"text"},{"role":"AXRadioButton","text":"app_settings.json, Editor Group 1","depth":28,"bounds":{"left":0.11569149,"top":0.047885075,"width":0.055851065,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"screenpipe_sync.sh, Editor Group 1","depth":28,"bounds":{"left":0.17154256,"top":0.047885075,"width":0.06050532,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":false},{"role":"AXRadioButton","text":"pipe.md, Editor Group 1","depth":28,"bounds":{"left":0.23171543,"top":0.047885075,"width":0.040226065,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":".env, Editor Group 1","depth":28,"bounds":{"left":0.27194148,"top":0.047885075,"width":0.039893616,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"#!/bin/bash\n# screenpipe_sync.sh\n# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).\n# Also copies the day's video/frame data folder to the NAS.\n#\n# Schema-drift tolerant: if Screenpipe migrations add new columns to the source DB,\n# the NAS archive gets ALTER TABLE'd to match. Inserts use explicit column lists,\n# so positional mismatches can't occur.\n#\n# Usage:\n# ./screenpipe_sync.sh # syncs yesterday (default)\n# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date\n# ./screenpipe_sync.sh today # syncs today so far\n#\n# Cron example (runs at 3am daily):\n# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1\n\nset -euo pipefail\n\n# ─── CONFIG ───────────────────────────────────────────────────────────────────\nDB_SRC=\"${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}\"\nNAS_MOUNT=\"${NAS_MOUNT:-/Volumes/screenpipe}\"\nNAS_DB=\"$NAS_MOUNT/archive.db\"\nNAS_DATA=\"$NAS_MOUNT/data\"\nLOG_FILE=\"$HOME/.screenpipe/sync.log\"\n# Tables that get schema drift handling. Order matters for FK-ish references\n# (parents before children: video_chunks → frames → elements/ocr_text/ui_events).\nSYNC_TABLES=(video_chunks frames elements ocr_text ui_events meetings)\n# ──────────────────────────────────────────────────────────────────────────────\n\n# ─── HELPERS ──────────────────────────────────────────────────────────────────\nSCRIPT_START=$(date +%s)\n\nlog() {\n local msg=\"[$(date '+%Y-%m-%d %H:%M:%S')] $*\"\n echo \"$msg\" | tee -a \"$LOG_FILE\"\n}\n\nstep() {\n local now=$(date +%s)\n local elapsed=$(( now - SCRIPT_START ))\n local min=$(( elapsed / 60 ))\n local sec=$(( elapsed % 60 ))\n printf \"\\n[+%02dm%02ds] ▶ %s\\n\" \"$min\" \"$sec\" \"$*\" | tee -a \"$LOG_FILE\"\n}\n\nrun_sqlite_heredoc() {\n local label=\"$1\"\n local sql=\"$2\"\n local start=$(date +%s)\n\n printf \" %-36s \" \"$label\"\n\n sqlite3 \"$DB_SRC\" <<< \"$sql\" &\n local pid=$!\n local spin=('⠋' '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')\n local i=0\n while kill -0 \"$pid\" 2>/dev/null; do\n printf \"\\r %-36s %s \" \"$label\" \"${spin[$i]}\"\n i=$(( (i + 1) % 10 ))\n sleep 0.2\n done\n wait \"$pid\"\n local rc=$?\n if [ $rc -ne 0 ]; then\n printf \"\\r %-36s ✗ FAILED\\n\" \"$label\" | tee -a \"$LOG_FILE\"\n exit $rc\n fi\n\n local dur=$(( $(date +%s) - start ))\n printf \"\\r %-36s ✓ %dm%02ds\\n\" \"$label\" \"$(( dur / 60 ))\" \"$(( dur % 60 ))\" | tee -a \"$LOG_FILE\"\n}\n\ncheck() {\n local label=\"$1\" got=\"$2\" expected=\"$3\"\n if [ \"$got\" -eq \"$expected\" ]; then\n printf \" %-20s %s / %s ✓\\n\" \"$label:\" \"$got\" \"$expected\"\n else\n printf \" %-20s %s / %s ✗ MISMATCH\\n\" \"$label:\" \"$got\" \"$expected\"\n fi\n}\n\n# ─── SCHEMA HELPERS ───────────────────────────────────────────────────────────\n# Echoes \"name|type\" lines for a table from a given DB.\ntable_columns_with_types() {\n local db=\"$1\" table=\"$2\"\n sqlite3 \"$db\" \"PRAGMA table_info($table);\" | awk -F'|' '{print $2 \"|\" $3}'\n}\n\n# Echoes just column names, one per line.\ntable_columns() {\n local db=\"$1\" table=\"$2\"\n sqlite3 \"$db\" \"PRAGMA table_info($table);\" | awk -F'|' '{print $2}'\n}\n\n# Returns true (0) if a table exists in the given DB.\ntable_exists() {\n local db=\"$1\" table=\"$2\"\n local count\n count=$(sqlite3 \"$db\" \"SELECT COUNT(*) FROM sqlite_master WHERE type='table' AND name='$table';\")\n [ \"$count\" -gt 0 ]\n}\n\n# Adds any columns present in source but missing in NAS for the given table.\n# Uses ALTER TABLE ADD COLUMN, which is a fast metadata-only operation in SQLite.\nensure_columns() {\n local table=\"$1\"\n local label=\"schema: $table\"\n printf \" %-36s \" \"$label\"\n\n if ! table_exists \"$DB_SRC\" \"$table\"; then\n printf \"✗ source missing — skipping\\n\"\n return 0\n fi\n\n if ! table_exists \"$NAS_DB\" \"$table\"; then\n printf \"✓ fresh (created above)\\n\"\n return 0\n fi\n\n local src_cols\n src_cols=$(table_columns_with_types \"$DB_SRC\" \"$table\")\n local nas_cols\n nas_cols=$(table_columns \"$NAS_DB\" \"$table\")\n\n local added=0\n local added_names=\"\"\n while IFS='|' read -r name type; do\n [ -z \"$name\" ] && continue\n # Use grep -F -x for fixed-string exact match (safe against regex chars).\n if ! echo \"$nas_cols\" | grep -Fxq \"$name\"; then\n # SQLite ALTER TABLE ADD COLUMN: type is optional, no NOT NULL allowed\n # without a constant default. Default-NULL is exactly what we want for archive.\n sqlite3 \"$NAS_DB\" \"ALTER TABLE $table ADD COLUMN \\\"$name\\\" $type;\"\n added=$((added + 1))\n added_names=\"$added_names $name\"\n fi\n done <<< \"$src_cols\"\n\n if [ \"$added\" -gt 0 ]; then\n printf \"✓ added %d:%s\\n\" \"$added\" \"$added_names\"\n else\n printf \"✓ in sync\\n\"\n fi\n}\n\n# Echoes a comma-separated list of source columns for a table, double-quoted\n# so reserved words and hyphens are safe. If an alias is provided, columns are\n# prefixed (e.g. `o.\"col\"`). Used for both INSERT and SELECT sides; aliased\n# form is required when SELECTing from a JOIN where column names collide\n# (e.g. ocr_text and frames both have app_name, window_name).\nbuild_col_list() {\n local table=\"$1\"\n local alias=\"${2:-}\"\n local prefix=\"\"\n [ -n \"$alias\" ] && prefix=\"${alias}.\"\n table_columns \"$DB_SRC\" \"$table\" | awk 'NF' | awk -v p=\"$prefix\" '{print p \"\\\"\" $0 \"\\\"\"}' | paste -sd, -\n}\n# ──────────────────────────────────────────────────────────────────────────────\n\n# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────\nif [ \"${1:-}\" = \"today\" ]; then\n TARGET_DATE=$(date +%Y-%m-%d)\nelif [ -n \"${1:-}\" ]; then\n TARGET_DATE=\"$1\"\n if ! [[ \"$TARGET_DATE\" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then\n echo \"ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday.\"\n exit 1\n fi\nelse\n TARGET_DATE=$(date -v-1d +%Y-%m-%d)\nfi\n\nlog \"========================================\"\nlog \"Screenpipe sync starting for: $TARGET_DATE\"\nlog \"========================================\"\n\n# ─── PREFLIGHT ────────────────────────────────────────────────────────────────\nstep \"Preflight checks\"\n\nif [ ! -f \"$DB_SRC\" ]; then\n log \"ERROR: Source DB not found at $DB_SRC\"; exit 1\nfi\nprintf \" %-20s %s (%s)\\n\" \"Source DB:\" \"OK\" \"$(du -sh \"$DB_SRC\" | cut -f1)\"\n\nif [ ! -d \"$NAS_MOUNT\" ]; then\n log \"ERROR: NAS not mounted at $NAS_MOUNT\"; exit 1\nfi\nprintf \" %-20s %s\\n\" \"NAS mount:\" \"OK $NAS_MOUNT\"\n\n# Check if DB already synced for this date\nDB_ALREADY_SYNCED=false\nif [ -f \"$NAS_DB\" ]; then\n if table_exists \"$NAS_DB\" \"frames\"; then\n EXISTING=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\" 2>/dev/null || echo \"0\")\n if [ \"$EXISTING\" -gt \"0\" ]; then\n log \"Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync\"\n DB_ALREADY_SYNCED=true\n else\n printf \" %-20s %s (%s)\\n\" \"Archive DB:\" \"exists\" \"$(du -sh \"$NAS_DB\" | cut -f1)\"\n fi\n else\n printf \" %-20s %s\\n\" \"Archive DB:\" \"exists, no frames table yet\"\n fi\nelse\n printf \" %-20s %s\\n\" \"Archive DB:\" \"will be created\"\nfi\n\n# Source data dir for this date\nDATA_SRC=\"$HOME/.screenpipe/data/data/$TARGET_DATE\"\nif [ -d \"$DATA_SRC\" ]; then\n DATA_SIZE=$(du -sh \"$DATA_SRC\" | cut -f1)\n DATA_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n printf \" %-20s %s (%s files, %s)\\n\" \"Data dir:\" \"OK\" \"$DATA_FILES\" \"$DATA_SIZE\"\nelse\n printf \" %-20s %s\\n\" \"Data dir:\" \"not found — skipping file copy\"\nfi\n\n# ─── DB SYNC ──────────────────────────────────────────────────────────────────\nif [ \"$DB_ALREADY_SYNCED\" = false ]; then\n\n # ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────\n step \"Counting source rows for $TARGET_DATE\"\n\n SRC_FRAMES=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\")\n SRC_ELEMENTS=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n SRC_UI=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';\")\n SRC_OCR=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n SRC_MEETINGS=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';\")\n\n printf \" %-20s %s\\n\" \"frames:\" \"$SRC_FRAMES\"\n printf \" %-20s %s\\n\" \"elements:\" \"$SRC_ELEMENTS\"\n printf \" %-20s %s\\n\" \"ui_events:\" \"$SRC_UI\"\n printf \" %-20s %s\\n\" \"ocr_text:\" \"$SRC_OCR\"\n printf \" %-20s %s\\n\" \"meetings:\" \"$SRC_MEETINGS\"\n\n if [ \"$SRC_FRAMES\" -eq \"0\" ]; then\n log \"No frames found for $TARGET_DATE — skipping DB sync\"\n DB_ALREADY_SYNCED=true\n fi\n\nfi\n\nif [ \"$DB_ALREADY_SYNCED\" = false ]; then\n\n # ─── INIT TABLES ──────────────────────────────────────────────────────────\n step \"Initialising tables (CREATE IF NOT EXISTS)\"\n\n run_sqlite_heredoc \"creating tables\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;\nDETACH nas;\n\"\n\n # ─── SCHEMA DRIFT FIX ─────────────────────────────────────────────────────\n # Runs AFTER CREATE IF NOT EXISTS so newly-created tables are no-ops here,\n # and pre-existing tables get any missing columns added.\n step \"Reconciling NAS schema with source\"\n for tbl in \"${SYNC_TABLES[@]}\"; do\n ensure_columns \"$tbl\"\n done\n\n run_sqlite_heredoc \"creating indexes\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_document_path ON frames(document_path) WHERE document_path IS NOT NULL;\nCREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;\nCREATE INDEX IF NOT EXISTS nas.idx_elements_onscreen_frame ON elements(frame_id) WHERE on_screen = 1 AND text IS NOT NULL;\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);\nCREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"creating FTS tables\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(\n text, role, frame_id UNINDEXED,\n content='elements', content_rowid='id', tokenize='unicode61'\n);\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(\n full_text, app_name, window_name, browser_url, id UNINDEXED,\n tokenize='unicode61'\n);\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(\n text_content,\n app_name,\n window_title,\n element_name,\n content='ui_events',\n content_rowid='id',\n tokenize='unicode61'\n);\nDETACH nas;\n\"\n\n # ─── BUILD EXPLICIT COLUMN LISTS ──────────────────────────────────────────\n # After ensure_columns, source ⊆ NAS for every synced table, so source's\n # column list is a safe subset to use on both sides of the INSERT.\n # For tables that JOIN frames (ocr_text, elements), the SELECT side needs\n # alias-qualified columns because both tables share names (app_name, etc).\n FRAMES_COLS=$(build_col_list frames)\n ELEMENTS_COLS=$(build_col_list elements)\n ELEMENTS_COLS_E=$(build_col_list elements e)\n UI_EVENTS_COLS=$(build_col_list ui_events)\n OCR_TEXT_COLS=$(build_col_list ocr_text)\n OCR_TEXT_COLS_O=$(build_col_list ocr_text o)\n VIDEO_CHUNKS_COLS=$(build_col_list video_chunks)\n MEETINGS_COLS=$(build_col_list meetings)\n\n # ─── SYNC DATA ────────────────────────────────────────────────────────────\n step \"Syncing data for $TARGET_DATE\"\n\n run_sqlite_heredoc \"video_chunks\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.video_chunks ($VIDEO_CHUNKS_COLS)\n SELECT $VIDEO_CHUNKS_COLS FROM main.video_chunks\n WHERE id IN (\n SELECT DISTINCT video_chunk_id FROM main.frames\n WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL\n );\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames ($SRC_FRAMES rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.frames ($FRAMES_COLS)\n SELECT $FRAMES_COLS FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ocr_text ($SRC_OCR rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ocr_text ($OCR_TEXT_COLS)\n SELECT $OCR_TEXT_COLS_O FROM main.ocr_text o\n JOIN main.frames f ON o.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events ($SRC_UI rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ui_events ($UI_EVENTS_COLS)\n SELECT $UI_EVENTS_COLS FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"elements ($SRC_ELEMENTS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.elements ($ELEMENTS_COLS)\n SELECT $ELEMENTS_COLS_E FROM main.elements e\n JOIN main.frames f ON e.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"meetings ($SRC_MEETINGS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.meetings ($MEETINGS_COLS)\n SELECT $MEETINGS_COLS FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n # ─── FTS UPDATE ───────────────────────────────────────────────────────────\n step \"Updating FTS indexes\"\n\n run_sqlite_heredoc \"elements_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.elements_fts(rowid, text, role)\n SELECT e.id, e.text, e.role\n FROM nas.elements e\n JOIN nas.frames f ON e.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE'\n AND e.text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)\n SELECT id, full_text, app_name, window_name, browser_url, id\n FROM nas.frames\n WHERE date(timestamp) = '$TARGET_DATE'\n AND full_text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)\n SELECT id, text_content, app_name, window_title, element_name\n FROM nas.ui_events\n WHERE date(timestamp) = '$TARGET_DATE'\n AND text_content IS NOT NULL;\nDETACH nas;\n\"\n\n # ─── VERIFY DB ────────────────────────────────────────────────────────────\n step \"Verifying DB\"\n\n V_FRAMES=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\")\n V_ELEMENTS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n V_UI=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';\")\n V_OCR=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n V_MEETINGS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';\")\n\n check \"frames\" \"$V_FRAMES\" \"$SRC_FRAMES\"\n check \"elements\" \"$V_ELEMENTS\" \"$SRC_ELEMENTS\"\n check \"ui_events\" \"$V_UI\" \"$SRC_UI\"\n check \"ocr_text\" \"$V_OCR\" \"$SRC_OCR\"\n check \"meetings\" \"$V_MEETINGS\" \"$SRC_MEETINGS\"\n\nfi\n\n# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────\n# Always runs regardless of DB sync status\nstep \"Copying data folder for $TARGET_DATE\"\n\nif [ -d \"$DATA_SRC\" ]; then\n mkdir -p \"$NAS_DATA/$TARGET_DATE\"\n RSYNC_START=$(date +%s)\n printf \" %-36s \" \"rsync $TARGET_DATE/ → NAS\"\n rsync -a --ignore-existing \\\n \"$DATA_SRC/\" \\\n \"$NAS_DATA/$TARGET_DATE/\" \\\n 2>>\"$LOG_FILE\"\n RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))\n COPIED_FILES=$(ls \"$NAS_DATA/$TARGET_DATE\" | wc -l | tr -d ' ')\n SRC_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n COPIED_SIZE=$(du -sh \"$NAS_DATA/$TARGET_DATE\" | cut -f1)\n if [ \"$COPIED_FILES\" -eq \"$SRC_FILES\" ]; then\n printf \"\\r %-36s ✓ %dm%02ds (%s files, %s)\\n\" \\\n \"rsync $TARGET_DATE/ → NAS\" \\\n \"$(( RSYNC_DUR / 60 ))\" \"$(( RSYNC_DUR % 60 ))\" \\\n \"$COPIED_FILES\" \"$COPIED_SIZE\" | tee -a \"$LOG_FILE\"\n else\n printf \"\\r %-36s ✗ %s / %s files\\n\" \\\n \"rsync $TARGET_DATE/ → NAS\" \"$COPIED_FILES\" \"$SRC_FILES\" | tee -a \"$LOG_FILE\"\n fi\nelse\n printf \" %-36s %s\\n\" \"rsync $TARGET_DATE/ → NAS\" \"skipped (no source dir)\"\nfi\n\n# ─── COPY LOGS ────────────────────────────────────────────────────────────────\n# Screenpipe writes daily logs to ~/.screenpipe/screenpipe.YYYY-MM-DD.N.log\n# (N is a rotation counter, almost always 0). Mirror them to NAS so log\n# analysis can happen on the consumer side without SSH'ing back to the Mac.\nstep \"Copying screenpipe logs for $TARGET_DATE\"\n\nNAS_LOGS=\"$NAS_MOUNT/logs\"\nmkdir -p \"$NAS_LOGS\"\n\n# Use a glob with nullglob so an empty match doesn't expand to a literal pattern.\nshopt -s nullglob\nLOG_FILES=( \"$HOME/.screenpipe/screenpipe.$TARGET_DATE.\"*.log )\nshopt -u nullglob\n\nif [ ${#LOG_FILES[@]} -gt 0 ]; then\n printf \" %-36s \" \"rsync logs → NAS\"\n # No --ignore-existing here: logs grow during the day, so we want rsync's\n # default size+mtime check to refresh files that have changed.\n rsync -a \"${LOG_FILES[@]}\" \"$NAS_LOGS/\" 2>>\"$LOG_FILE\"\n COPIED=${#LOG_FILES[@]}\n TOTAL_SIZE=$(du -ch \"${LOG_FILES[@]}\" | tail -1 | cut -f1)\n printf \"✓ %d file(s), %s\\n\" \"$COPIED\" \"$TOTAL_SIZE\" | tee -a \"$LOG_FILE\"\nelse\n printf \" %-36s %s\\n\" \"rsync logs → NAS\" \"skipped (no matching logs)\"\nfi\n\n# ─── SUMMARY ──────────────────────────────────────────────────────────────────\nTOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))\nDB_SIZE=$(du -sh \"$NAS_DB\" | cut -f1)\n\necho \"\"\nlog \"Archive DB size: $DB_SIZE\"\nlog \"Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s\"\nlog \"Sync complete for $TARGET_DATE\"\nlog \"========================================\"\n\n# Mirror this script's own logbook to NAS so sync health can be monitored\n# from the consumer side. Done last so the summary lines above are included.\nrsync -a \"$HOME/.screenpipe/sync.log\" \"$NAS_LOGS/sync.log\" 2>/dev/null || true","depth":28,"bounds":{"left":0.11569149,"top":0.0933759,"width":0.38031915,"height":0.0007980846},"on_screen":true,"value":"#!/bin/bash\n# screenpipe_sync.sh\n# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).\n# Also copies the day's video/frame data folder to the NAS.\n#\n# Schema-drift tolerant: if Screenpipe migrations add new columns to the source DB,\n# the NAS archive gets ALTER TABLE'd to match. Inserts use explicit column lists,\n# so positional mismatches can't occur.\n#\n# Usage:\n# ./screenpipe_sync.sh # syncs yesterday (default)\n# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date\n# ./screenpipe_sync.sh today # syncs today so far\n#\n# Cron example (runs at 3am daily):\n# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1\n\nset -euo pipefail\n\n# ─── CONFIG ───────────────────────────────────────────────────────────────────\nDB_SRC=\"${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}\"\nNAS_MOUNT=\"${NAS_MOUNT:-/Volumes/screenpipe}\"\nNAS_DB=\"$NAS_MOUNT/archive.db\"\nNAS_DATA=\"$NAS_MOUNT/data\"\nLOG_FILE=\"$HOME/.screenpipe/sync.log\"\n# Tables that get schema drift handling. Order matters for FK-ish references\n# (parents before children: video_chunks → frames → elements/ocr_text/ui_events).\nSYNC_TABLES=(video_chunks frames elements ocr_text ui_events meetings)\n# ──────────────────────────────────────────────────────────────────────────────\n\n# ─── HELPERS ──────────────────────────────────────────────────────────────────\nSCRIPT_START=$(date +%s)\n\nlog() {\n local msg=\"[$(date '+%Y-%m-%d %H:%M:%S')] $*\"\n echo \"$msg\" | tee -a \"$LOG_FILE\"\n}\n\nstep() {\n local now=$(date +%s)\n local elapsed=$(( now - SCRIPT_START ))\n local min=$(( elapsed / 60 ))\n local sec=$(( elapsed % 60 ))\n printf \"\\n[+%02dm%02ds] ▶ %s\\n\" \"$min\" \"$sec\" \"$*\" | tee -a \"$LOG_FILE\"\n}\n\nrun_sqlite_heredoc() {\n local label=\"$1\"\n local sql=\"$2\"\n local start=$(date +%s)\n\n printf \" %-36s \" \"$label\"\n\n sqlite3 \"$DB_SRC\" <<< \"$sql\" &\n local pid=$!\n local spin=('⠋' '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')\n local i=0\n while kill -0 \"$pid\" 2>/dev/null; do\n printf \"\\r %-36s %s \" \"$label\" \"${spin[$i]}\"\n i=$(( (i + 1) % 10 ))\n sleep 0.2\n done\n wait \"$pid\"\n local rc=$?\n if [ $rc -ne 0 ]; then\n printf \"\\r %-36s ✗ FAILED\\n\" \"$label\" | tee -a \"$LOG_FILE\"\n exit $rc\n fi\n\n local dur=$(( $(date +%s) - start ))\n printf \"\\r %-36s ✓ %dm%02ds\\n\" \"$label\" \"$(( dur / 60 ))\" \"$(( dur % 60 ))\" | tee -a \"$LOG_FILE\"\n}\n\ncheck() {\n local label=\"$1\" got=\"$2\" expected=\"$3\"\n if [ \"$got\" -eq \"$expected\" ]; then\n printf \" %-20s %s / %s ✓\\n\" \"$label:\" \"$got\" \"$expected\"\n else\n printf \" %-20s %s / %s ✗ MISMATCH\\n\" \"$label:\" \"$got\" \"$expected\"\n fi\n}\n\n# ─── SCHEMA HELPERS ───────────────────────────────────────────────────────────\n# Echoes \"name|type\" lines for a table from a given DB.\ntable_columns_with_types() {\n local db=\"$1\" table=\"$2\"\n sqlite3 \"$db\" \"PRAGMA table_info($table);\" | awk -F'|' '{print $2 \"|\" $3}'\n}\n\n# Echoes just column names, one per line.\ntable_columns() {\n local db=\"$1\" table=\"$2\"\n sqlite3 \"$db\" \"PRAGMA table_info($table);\" | awk -F'|' '{print $2}'\n}\n\n# Returns true (0) if a table exists in the given DB.\ntable_exists() {\n local db=\"$1\" table=\"$2\"\n local count\n count=$(sqlite3 \"$db\" \"SELECT COUNT(*) FROM sqlite_master WHERE type='table' AND name='$table';\")\n [ \"$count\" -gt 0 ]\n}\n\n# Adds any columns present in source but missing in NAS for the given table.\n# Uses ALTER TABLE ADD COLUMN, which is a fast metadata-only operation in SQLite.\nensure_columns() {\n local table=\"$1\"\n local label=\"schema: $table\"\n printf \" %-36s \" \"$label\"\n\n if ! table_exists \"$DB_SRC\" \"$table\"; then\n printf \"✗ source missing — skipping\\n\"\n return 0\n fi\n\n if ! table_exists \"$NAS_DB\" \"$table\"; then\n printf \"✓ fresh (created above)\\n\"\n return 0\n fi\n\n local src_cols\n src_cols=$(table_columns_with_types \"$DB_SRC\" \"$table\")\n local nas_cols\n nas_cols=$(table_columns \"$NAS_DB\" \"$table\")\n\n local added=0\n local added_names=\"\"\n while IFS='|' read -r name type; do\n [ -z \"$name\" ] && continue\n # Use grep -F -x for fixed-string exact match (safe against regex chars).\n if ! echo \"$nas_cols\" | grep -Fxq \"$name\"; then\n # SQLite ALTER TABLE ADD COLUMN: type is optional, no NOT NULL allowed\n # without a constant default. Default-NULL is exactly what we want for archive.\n sqlite3 \"$NAS_DB\" \"ALTER TABLE $table ADD COLUMN \\\"$name\\\" $type;\"\n added=$((added + 1))\n added_names=\"$added_names $name\"\n fi\n done <<< \"$src_cols\"\n\n if [ \"$added\" -gt 0 ]; then\n printf \"✓ added %d:%s\\n\" \"$added\" \"$added_names\"\n else\n printf \"✓ in sync\\n\"\n fi\n}\n\n# Echoes a comma-separated list of source columns for a table, double-quoted\n# so reserved words and hyphens are safe. If an alias is provided, columns are\n# prefixed (e.g. `o.\"col\"`). Used for both INSERT and SELECT sides; aliased\n# form is required when SELECTing from a JOIN where column names collide\n# (e.g. ocr_text and frames both have app_name, window_name).\nbuild_col_list() {\n local table=\"$1\"\n local alias=\"${2:-}\"\n local prefix=\"\"\n [ -n \"$alias\" ] && prefix=\"${alias}.\"\n table_columns \"$DB_SRC\" \"$table\" | awk 'NF' | awk -v p=\"$prefix\" '{print p \"\\\"\" $0 \"\\\"\"}' | paste -sd, -\n}\n# ──────────────────────────────────────────────────────────────────────────────\n\n# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────\nif [ \"${1:-}\" = \"today\" ]; then\n TARGET_DATE=$(date +%Y-%m-%d)\nelif [ -n \"${1:-}\" ]; then\n TARGET_DATE=\"$1\"\n if ! [[ \"$TARGET_DATE\" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then\n echo \"ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday.\"\n exit 1\n fi\nelse\n TARGET_DATE=$(date -v-1d +%Y-%m-%d)\nfi\n\nlog \"========================================\"\nlog \"Screenpipe sync starting for: $TARGET_DATE\"\nlog \"========================================\"\n\n# ─── PREFLIGHT ────────────────────────────────────────────────────────────────\nstep \"Preflight checks\"\n\nif [ ! -f \"$DB_SRC\" ]; then\n log \"ERROR: Source DB not found at $DB_SRC\"; exit 1\nfi\nprintf \" %-20s %s (%s)\\n\" \"Source DB:\" \"OK\" \"$(du -sh \"$DB_SRC\" | cut -f1)\"\n\nif [ ! -d \"$NAS_MOUNT\" ]; then\n log \"ERROR: NAS not mounted at $NAS_MOUNT\"; exit 1\nfi\nprintf \" %-20s %s\\n\" \"NAS mount:\" \"OK $NAS_MOUNT\"\n\n# Check if DB already synced for this date\nDB_ALREADY_SYNCED=false\nif [ -f \"$NAS_DB\" ]; then\n if table_exists \"$NAS_DB\" \"frames\"; then\n EXISTING=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\" 2>/dev/null || echo \"0\")\n if [ \"$EXISTING\" -gt \"0\" ]; then\n log \"Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync\"\n DB_ALREADY_SYNCED=true\n else\n printf \" %-20s %s (%s)\\n\" \"Archive DB:\" \"exists\" \"$(du -sh \"$NAS_DB\" | cut -f1)\"\n fi\n else\n printf \" %-20s %s\\n\" \"Archive DB:\" \"exists, no frames table yet\"\n fi\nelse\n printf \" %-20s %s\\n\" \"Archive DB:\" \"will be created\"\nfi\n\n# Source data dir for this date\nDATA_SRC=\"$HOME/.screenpipe/data/data/$TARGET_DATE\"\nif [ -d \"$DATA_SRC\" ]; then\n DATA_SIZE=$(du -sh \"$DATA_SRC\" | cut -f1)\n DATA_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n printf \" %-20s %s (%s files, %s)\\n\" \"Data dir:\" \"OK\" \"$DATA_FILES\" \"$DATA_SIZE\"\nelse\n printf \" %-20s %s\\n\" \"Data dir:\" \"not found — skipping file copy\"\nfi\n\n# ─── DB SYNC ──────────────────────────────────────────────────────────────────\nif [ \"$DB_ALREADY_SYNCED\" = false ]; then\n\n # ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────\n step \"Counting source rows for $TARGET_DATE\"\n\n SRC_FRAMES=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\")\n SRC_ELEMENTS=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n SRC_UI=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';\")\n SRC_OCR=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n SRC_MEETINGS=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';\")\n\n printf \" %-20s %s\\n\" \"frames:\" \"$SRC_FRAMES\"\n printf \" %-20s %s\\n\" \"elements:\" \"$SRC_ELEMENTS\"\n printf \" %-20s %s\\n\" \"ui_events:\" \"$SRC_UI\"\n printf \" %-20s %s\\n\" \"ocr_text:\" \"$SRC_OCR\"\n printf \" %-20s %s\\n\" \"meetings:\" \"$SRC_MEETINGS\"\n\n if [ \"$SRC_FRAMES\" -eq \"0\" ]; then\n log \"No frames found for $TARGET_DATE — skipping DB sync\"\n DB_ALREADY_SYNCED=true\n fi\n\nfi\n\nif [ \"$DB_ALREADY_SYNCED\" = false ]; then\n\n # ─── INIT TABLES ──────────────────────────────────────────────────────────\n step \"Initialising tables (CREATE IF NOT EXISTS)\"\n\n run_sqlite_heredoc \"creating tables\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;\nDETACH nas;\n\"\n\n # ─── SCHEMA DRIFT FIX ─────────────────────────────────────────────────────\n # Runs AFTER CREATE IF NOT EXISTS so newly-created tables are no-ops here,\n # and pre-existing tables get any missing columns added.\n step \"Reconciling NAS schema with source\"\n for tbl in \"${SYNC_TABLES[@]}\"; do\n ensure_columns \"$tbl\"\n done\n\n run_sqlite_heredoc \"creating indexes\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_document_path ON frames(document_path) WHERE document_path IS NOT NULL;\nCREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;\nCREATE INDEX IF NOT EXISTS nas.idx_elements_onscreen_frame ON elements(frame_id) WHERE on_screen = 1 AND text IS NOT NULL;\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);\nCREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"creating FTS tables\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(\n text, role, frame_id UNINDEXED,\n content='elements', content_rowid='id', tokenize='unicode61'\n);\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(\n full_text, app_name, window_name, browser_url, id UNINDEXED,\n tokenize='unicode61'\n);\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(\n text_content,\n app_name,\n window_title,\n element_name,\n content='ui_events',\n content_rowid='id',\n tokenize='unicode61'\n);\nDETACH nas;\n\"\n\n # ─── BUILD EXPLICIT COLUMN LISTS ──────────────────────────────────────────\n # After ensure_columns, source ⊆ NAS for every synced table, so source's\n # column list is a safe subset to use on both sides of the INSERT.\n # For tables that JOIN frames (ocr_text, elements), the SELECT side needs\n # alias-qualified columns because both tables share names (app_name, etc).\n FRAMES_COLS=$(build_col_list frames)\n ELEMENTS_COLS=$(build_col_list elements)\n ELEMENTS_COLS_E=$(build_col_list elements e)\n UI_EVENTS_COLS=$(build_col_list ui_events)\n OCR_TEXT_COLS=$(build_col_list ocr_text)\n OCR_TEXT_COLS_O=$(build_col_list ocr_text o)\n VIDEO_CHUNKS_COLS=$(build_col_list video_chunks)\n MEETINGS_COLS=$(build_col_list meetings)\n\n # ─── SYNC DATA ────────────────────────────────────────────────────────────\n step \"Syncing data for $TARGET_DATE\"\n\n run_sqlite_heredoc \"video_chunks\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.video_chunks ($VIDEO_CHUNKS_COLS)\n SELECT $VIDEO_CHUNKS_COLS FROM main.video_chunks\n WHERE id IN (\n SELECT DISTINCT video_chunk_id FROM main.frames\n WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL\n );\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames ($SRC_FRAMES rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.frames ($FRAMES_COLS)\n SELECT $FRAMES_COLS FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ocr_text ($SRC_OCR rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ocr_text ($OCR_TEXT_COLS)\n SELECT $OCR_TEXT_COLS_O FROM main.ocr_text o\n JOIN main.frames f ON o.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events ($SRC_UI rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ui_events ($UI_EVENTS_COLS)\n SELECT $UI_EVENTS_COLS FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"elements ($SRC_ELEMENTS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.elements ($ELEMENTS_COLS)\n SELECT $ELEMENTS_COLS_E FROM main.elements e\n JOIN main.frames f ON e.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"meetings ($SRC_MEETINGS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.meetings ($MEETINGS_COLS)\n SELECT $MEETINGS_COLS FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n # ─── FTS UPDATE ───────────────────────────────────────────────────────────\n step \"Updating FTS indexes\"\n\n run_sqlite_heredoc \"elements_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.elements_fts(rowid, text, role)\n SELECT e.id, e.text, e.role\n FROM nas.elements e\n JOIN nas.frames f ON e.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE'\n AND e.text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)\n SELECT id, full_text, app_name, window_name, browser_url, id\n FROM nas.frames\n WHERE date(timestamp) = '$TARGET_DATE'\n AND full_text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)\n SELECT id, text_content, app_name, window_title, element_name\n FROM nas.ui_events\n WHERE date(timestamp) = '$TARGET_DATE'\n AND text_content IS NOT NULL;\nDETACH nas;\n\"\n\n # ─── VERIFY DB ────────────────────────────────────────────────────────────\n step \"Verifying DB\"\n\n V_FRAMES=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\")\n V_ELEMENTS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n V_UI=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';\")\n V_OCR=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n V_MEETINGS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';\")\n\n check \"frames\" \"$V_FRAMES\" \"$SRC_FRAMES\"\n check \"elements\" \"$V_ELEMENTS\" \"$SRC_ELEMENTS\"\n check \"ui_events\" \"$V_UI\" \"$SRC_UI\"\n check \"ocr_text\" \"$V_OCR\" \"$SRC_OCR\"\n check \"meetings\" \"$V_MEETINGS\" \"$SRC_MEETINGS\"\n\nfi\n\n# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────\n# Always runs regardless of DB sync status\nstep \"Copying data folder for $TARGET_DATE\"\n\nif [ -d \"$DATA_SRC\" ]; then\n mkdir -p \"$NAS_DATA/$TARGET_DATE\"\n RSYNC_START=$(date +%s)\n printf \" %-36s \" \"rsync $TARGET_DATE/ → NAS\"\n rsync -a --ignore-existing \\\n \"$DATA_SRC/\" \\\n \"$NAS_DATA/$TARGET_DATE/\" \\\n 2>>\"$LOG_FILE\"\n RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))\n COPIED_FILES=$(ls \"$NAS_DATA/$TARGET_DATE\" | wc -l | tr -d ' ')\n SRC_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n COPIED_SIZE=$(du -sh \"$NAS_DATA/$TARGET_DATE\" | cut -f1)\n if [ \"$COPIED_FILES\" -eq \"$SRC_FILES\" ]; then\n printf \"\\r %-36s ✓ %dm%02ds (%s files, %s)\\n\" \\\n \"rsync $TARGET_DATE/ → NAS\" \\\n \"$(( RSYNC_DUR / 60 ))\" \"$(( RSYNC_DUR % 60 ))\" \\\n \"$COPIED_FILES\" \"$COPIED_SIZE\" | tee -a \"$LOG_FILE\"\n else\n printf \"\\r %-36s ✗ %s / %s files\\n\" \\\n \"rsync $TARGET_DATE/ → NAS\" \"$COPIED_FILES\" \"$SRC_FILES\" | tee -a \"$LOG_FILE\"\n fi\nelse\n printf \" %-36s %s\\n\" \"rsync $TARGET_DATE/ → NAS\" \"skipped (no source dir)\"\nfi\n\n# ─── COPY LOGS ────────────────────────────────────────────────────────────────\n# Screenpipe writes daily logs to ~/.screenpipe/screenpipe.YYYY-MM-DD.N.log\n# (N is a rotation counter, almost always 0). Mirror them to NAS so log\n# analysis can happen on the consumer side without SSH'ing back to the Mac.\nstep \"Copying screenpipe logs for $TARGET_DATE\"\n\nNAS_LOGS=\"$NAS_MOUNT/logs\"\nmkdir -p \"$NAS_LOGS\"\n\n# Use a glob with nullglob so an empty match doesn't expand to a literal pattern.\nshopt -s nullglob\nLOG_FILES=( \"$HOME/.screenpipe/screenpipe.$TARGET_DATE.\"*.log )\nshopt -u nullglob\n\nif [ ${#LOG_FILES[@]} -gt 0 ]; then\n printf \" %-36s \" \"rsync logs → NAS\"\n # No --ignore-existing here: logs grow during the day, so we want rsync's\n # default size+mtime check to refresh files that have changed.\n rsync -a \"${LOG_FILES[@]}\" \"$NAS_LOGS/\" 2>>\"$LOG_FILE\"\n COPIED=${#LOG_FILES[@]}\n TOTAL_SIZE=$(du -ch \"${LOG_FILES[@]}\" | tail -1 | cut -f1)\n printf \"✓ %d file(s), %s\\n\" \"$COPIED\" \"$TOTAL_SIZE\" | tee -a \"$LOG_FILE\"\nelse\n printf \" %-36s %s\\n\" \"rsync logs → NAS\" \"skipped (no matching logs)\"\nfi\n\n# ─── SUMMARY ──────────────────────────────────────────────────────────────────\nTOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))\nDB_SIZE=$(du -sh \"$NAS_DB\" | cut -f1)\n\necho \"\"\nlog \"Archive DB size: $DB_SIZE\"\nlog \"Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s\"\nlog \"Sync complete for $TARGET_DATE\"\nlog \"========================================\"\n\n# Mirror this script's own logbook to NAS so sync health can be monitored\n# from the consumer side. Done last so the summary lines above are included.\nrsync -a \"$HOME/.screenpipe/sync.log\" \"$NAS_LOGS/sync.log\" 2>/dev/null || true","role_description":"editor","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"#!/bin/bash\n# screenpipe_sync.sh\n# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).\n# Also copies the day's video/frame data folder to the NAS.\n#\n# Schema-drift tolerant: if Screenpipe migrations add new columns to the source DB,\n# the NAS archive gets ALTER TABLE'd to match. Inserts use explicit column lists,\n# so positional mismatches can't occur.\n#\n# Usage:\n# ./screenpipe_sync.sh # syncs yesterday (default)\n# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date\n# ./screenpipe_sync.sh today # syncs today so far\n#\n# Cron example (runs at 3am daily):\n# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1\n\nset -euo pipefail\n\n# ─── CONFIG ───────────────────────────────────────────────────────────────────\nDB_SRC=\"${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}\"\nNAS_MOUNT=\"${NAS_MOUNT:-/Volumes/screenpipe}\"\nNAS_DB=\"$NAS_MOUNT/archive.db\"\nNAS_DATA=\"$NAS_MOUNT/data\"\nLOG_FILE=\"$HOME/.screenpipe/sync.log\"\n# Tables that get schema drift handling. Order matters for FK-ish references\n# (parents before children: video_chunks → frames → elements/ocr_text/ui_events).\nSYNC_TABLES=(video_chunks frames elements ocr_text ui_events meetings)\n# ──────────────────────────────────────────────────────────────────────────────\n\n# ─── HELPERS ──────────────────────────────────────────────────────────────────\nSCRIPT_START=$(date +%s)\n\nlog() {\n local msg=\"[$(date '+%Y-%m-%d %H:%M:%S')] $*\"\n echo \"$msg\" | tee -a \"$LOG_FILE\"\n}\n\nstep() {\n local now=$(date +%s)\n local elapsed=$(( now - SCRIPT_START ))\n local min=$(( elapsed / 60 ))\n local sec=$(( elapsed % 60 ))\n printf \"\\n[+%02dm%02ds] ▶ %s\\n\" \"$min\" \"$sec\" \"$*\" | tee -a \"$LOG_FILE\"\n}\n\nrun_sqlite_heredoc() {\n local label=\"$1\"\n local sql=\"$2\"\n local start=$(date +%s)\n\n printf \" %-36s \" \"$label\"\n\n sqlite3 \"$DB_SRC\" <<< \"$sql\" &\n local pid=$!\n local spin=('⠋' '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')\n local i=0\n while kill -0 \"$pid\" 2>/dev/null; do\n printf \"\\r %-36s %s \" \"$label\" \"${spin[$i]}\"\n i=$(( (i + 1) % 10 ))\n sleep 0.2\n done\n wait \"$pid\"\n local rc=$?\n if [ $rc -ne 0 ]; then\n printf \"\\r %-36s ✗ FAILED\\n\" \"$label\" | tee -a \"$LOG_FILE\"\n exit $rc\n fi\n\n local dur=$(( $(date +%s) - start ))\n printf \"\\r %-36s ✓ %dm%02ds\\n\" \"$label\" \"$(( dur / 60 ))\" \"$(( dur % 60 ))\" | tee -a \"$LOG_FILE\"\n}\n\ncheck() {\n local label=\"$1\" got=\"$2\" expected=\"$3\"\n if [ \"$got\" -eq \"$expected\" ]; then\n printf \" %-20s %s / %s ✓\\n\" \"$label:\" \"$got\" \"$expected\"\n else\n printf \" %-20s %s / %s ✗ MISMATCH\\n\" \"$label:\" \"$got\" \"$expected\"\n fi\n}\n\n# ─── SCHEMA HELPERS ───────────────────────────────────────────────────────────\n# Echoes \"name|type\" lines for a table from a given DB.\ntable_columns_with_types() {\n local db=\"$1\" table=\"$2\"\n sqlite3 \"$db\" \"PRAGMA table_info($table);\" | awk -F'|' '{print $2 \"|\" $3}'\n}\n\n# Echoes just column names, one per line.\ntable_columns() {\n local db=\"$1\" table=\"$2\"\n sqlite3 \"$db\" \"PRAGMA table_info($table);\" | awk -F'|' '{print $2}'\n}\n\n# Returns true (0) if a table exists in the given DB.\ntable_exists() {\n local db=\"$1\" table=\"$2\"\n local count\n count=$(sqlite3 \"$db\" \"SELECT COUNT(*) FROM sqlite_master WHERE type='table' AND name='$table';\")\n [ \"$count\" -gt 0 ]\n}\n\n# Adds any columns present in source but missing in NAS for the given table.\n# Uses ALTER TABLE ADD COLUMN, which is a fast metadata-only operation in SQLite.\nensure_columns() {\n local table=\"$1\"\n local label=\"schema: $table\"\n printf \" %-36s \" \"$label\"\n\n if ! table_exists \"$DB_SRC\" \"$table\"; then\n printf \"✗ source missing — skipping\\n\"\n return 0\n fi\n\n if ! table_exists \"$NAS_DB\" \"$table\"; then\n printf \"✓ fresh (created above)\\n\"\n return 0\n fi\n\n local src_cols\n src_cols=$(table_columns_with_types \"$DB_SRC\" \"$table\")\n local nas_cols\n nas_cols=$(table_columns \"$NAS_DB\" \"$table\")\n\n local added=0\n local added_names=\"\"\n while IFS='|' read -r name type; do\n [ -z \"$name\" ] && continue\n # Use grep -F -x for fixed-string exact match (safe against regex chars).\n if ! echo \"$nas_cols\" | grep -Fxq \"$name\"; then\n # SQLite ALTER TABLE ADD COLUMN: type is optional, no NOT NULL allowed\n # without a constant default. Default-NULL is exactly what we want for archive.\n sqlite3 \"$NAS_DB\" \"ALTER TABLE $table ADD COLUMN \\\"$name\\\" $type;\"\n added=$((added + 1))\n added_names=\"$added_names $name\"\n fi\n done <<< \"$src_cols\"\n\n if [ \"$added\" -gt 0 ]; then\n printf \"✓ added %d:%s\\n\" \"$added\" \"$added_names\"\n else\n printf \"✓ in sync\\n\"\n fi\n}\n\n# Echoes a comma-separated list of source columns for a table, double-quoted\n# so reserved words and hyphens are safe. If an alias is provided, columns are\n# prefixed (e.g. `o.\"col\"`). Used for both INSERT and SELECT sides; aliased\n# form is required when SELECTing from a JOIN where column names collide\n# (e.g. ocr_text and frames both have app_name, window_name).\nbuild_col_list() {\n local table=\"$1\"\n local alias=\"${2:-}\"\n local prefix=\"\"\n [ -n \"$alias\" ] && prefix=\"${alias}.\"\n table_columns \"$DB_SRC\" \"$table\" | awk 'NF' | awk -v p=\"$prefix\" '{print p \"\\\"\" $0 \"\\\"\"}' | paste -sd, -\n}\n# ──────────────────────────────────────────────────────────────────────────────\n\n# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────\nif [ \"${1:-}\" = \"today\" ]; then\n TARGET_DATE=$(date +%Y-%m-%d)\nelif [ -n \"${1:-}\" ]; then\n TARGET_DATE=\"$1\"\n if ! [[ \"$TARGET_DATE\" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then\n echo \"ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday.\"\n exit 1\n fi\nelse\n TARGET_DATE=$(date -v-1d +%Y-%m-%d)\nfi\n\nlog \"========================================\"\nlog \"Screenpipe sync starting for: $TARGET_DATE\"\nlog \"========================================\"\n\n# ─── PREFLIGHT ────────────────────────────────────────────────────────────────\nstep \"Preflight checks\"\n\nif [ ! -f \"$DB_SRC\" ]; then\n log \"ERROR: Source DB not found at $DB_SRC\"; exit 1\nfi\nprintf \" %-20s %s (%s)\\n\" \"Source DB:\" \"OK\" \"$(du -sh \"$DB_SRC\" | cut -f1)\"\n\nif [ ! -d \"$NAS_MOUNT\" ]; then\n log \"ERROR: NAS not mounted at $NAS_MOUNT\"; exit 1\nfi\nprintf \" %-20s %s\\n\" \"NAS mount:\" \"OK $NAS_MOUNT\"\n\n# Check if DB already synced for this date\nDB_ALREADY_SYNCED=false\nif [ -f \"$NAS_DB\" ]; then\n if table_exists \"$NAS_DB\" \"frames\"; then\n EXISTING=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\" 2>/dev/null || echo \"0\")\n if [ \"$EXISTING\" -gt \"0\" ]; then\n log \"Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync\"\n DB_ALREADY_SYNCED=true\n else\n printf \" %-20s %s (%s)\\n\" \"Archive DB:\" \"exists\" \"$(du -sh \"$NAS_DB\" | cut -f1)\"\n fi\n else\n printf \" %-20s %s\\n\" \"Archive DB:\" \"exists, no frames table yet\"\n fi\nelse\n printf \" %-20s %s\\n\" \"Archive DB:\" \"will be created\"\nfi\n\n# Source data dir for this date\nDATA_SRC=\"$HOME/.screenpipe/data/data/$TARGET_DATE\"\nif [ -d \"$DATA_SRC\" ]; then\n DATA_SIZE=$(du -sh \"$DATA_SRC\" | cut -f1)\n DATA_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n printf \" %-20s %s (%s files, %s)\\n\" \"Data dir:\" \"OK\" \"$DATA_FILES\" \"$DATA_SIZE\"\nelse\n printf \" %-20s %s\\n\" \"Data dir:\" \"not found — skipping file copy\"\nfi\n\n# ─── DB SYNC ──────────────────────────────────────────────────────────────────\nif [ \"$DB_ALREADY_SYNCED\" = false ]; then\n\n # ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────\n step \"Counting source rows for $TARGET_DATE\"\n\n SRC_FRAMES=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\")\n SRC_ELEMENTS=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n SRC_UI=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';\")\n SRC_OCR=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n SRC_MEETINGS=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';\")\n\n printf \" %-20s %s\\n\" \"frames:\" \"$SRC_FRAMES\"\n printf \" %-20s %s\\n\" \"elements:\" \"$SRC_ELEMENTS\"\n printf \" %-20s %s\\n\" \"ui_events:\" \"$SRC_UI\"\n printf \" %-20s %s\\n\" \"ocr_text:\" \"$SRC_OCR\"\n printf \" %-20s %s\\n\" \"meetings:\" \"$SRC_MEETINGS\"\n\n if [ \"$SRC_FRAMES\" -eq \"0\" ]; then\n log \"No frames found for $TARGET_DATE — skipping DB sync\"\n DB_ALREADY_SYNCED=true\n fi\n\nfi\n\nif [ \"$DB_ALREADY_SYNCED\" = false ]; then\n\n # ─── INIT TABLES ──────────────────────────────────────────────────────────\n step \"Initialising tables (CREATE IF NOT EXISTS)\"\n\n run_sqlite_heredoc \"creating tables\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;\nDETACH nas;\n\"\n\n # ─── SCHEMA DRIFT FIX ─────────────────────────────────────────────────────\n # Runs AFTER CREATE IF NOT EXISTS so newly-created tables are no-ops here,\n # and pre-existing tables get any missing columns added.\n step \"Reconciling NAS schema with source\"\n for tbl in \"${SYNC_TABLES[@]}\"; do\n ensure_columns \"$tbl\"\n done\n\n run_sqlite_heredoc \"creating indexes\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_document_path ON frames(document_path) WHERE document_path IS NOT NULL;\nCREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;\nCREATE INDEX IF NOT EXISTS nas.idx_elements_onscreen_frame ON elements(frame_id) WHERE on_screen = 1 AND text IS NOT NULL;\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);\nCREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"creating FTS tables\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(\n text, role, frame_id UNINDEXED,\n content='elements', content_rowid='id', tokenize='unicode61'\n);\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(\n full_text, app_name, window_name, browser_url, id UNINDEXED,\n tokenize='unicode61'\n);\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(\n text_content,\n app_name,\n window_title,\n element_name,\n content='ui_events',\n content_rowid='id',\n tokenize='unicode61'\n);\nDETACH nas;\n\"\n\n # ─── BUILD EXPLICIT COLUMN LISTS ──────────────────────────────────────────\n # After ensure_columns, source ⊆ NAS for every synced table, so source's\n # column list is a safe subset to use on both sides of the INSERT.\n # For tables that JOIN frames (ocr_text, elements), the SELECT side needs\n # alias-qualified columns because both tables share names (app_name, etc).\n FRAMES_COLS=$(build_col_list frames)\n ELEMENTS_COLS=$(build_col_list elements)\n ELEMENTS_COLS_E=$(build_col_list elements e)\n UI_EVENTS_COLS=$(build_col_list ui_events)\n OCR_TEXT_COLS=$(build_col_list ocr_text)\n OCR_TEXT_COLS_O=$(build_col_list ocr_text o)\n VIDEO_CHUNKS_COLS=$(build_col_list video_chunks)\n MEETINGS_COLS=$(build_col_list meetings)\n\n # ─── SYNC DATA ────────────────────────────────────────────────────────────\n step \"Syncing data for $TARGET_DATE\"\n\n run_sqlite_heredoc \"video_chunks\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.video_chunks ($VIDEO_CHUNKS_COLS)\n SELECT $VIDEO_CHUNKS_COLS FROM main.video_chunks\n WHERE id IN (\n SELECT DISTINCT video_chunk_id FROM main.frames\n WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL\n );\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames ($SRC_FRAMES rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.frames ($FRAMES_COLS)\n SELECT $FRAMES_COLS FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ocr_text ($SRC_OCR rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ocr_text ($OCR_TEXT_COLS)\n SELECT $OCR_TEXT_COLS_O FROM main.ocr_text o\n JOIN main.frames f ON o.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events ($SRC_UI rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ui_events ($UI_EVENTS_COLS)\n SELECT $UI_EVENTS_COLS FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"elements ($SRC_ELEMENTS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.elements ($ELEMENTS_COLS)\n SELECT $ELEMENTS_COLS_E FROM main.elements e\n JOIN main.frames f ON e.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"meetings ($SRC_MEETINGS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.meetings ($MEETINGS_COLS)\n SELECT $MEETINGS_COLS FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n # ─── FTS UPDATE ───────────────────────────────────────────────────────────\n step \"Updating FTS indexes\"\n\n run_sqlite_heredoc \"elements_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.elements_fts(rowid, text, role)\n SELECT e.id, e.text, e.role\n FROM nas.elements e\n JOIN nas.frames f ON e.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE'\n AND e.text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)\n SELECT id, full_text, app_name, window_name, browser_url, id\n FROM nas.frames\n WHERE date(timestamp) = '$TARGET_DATE'\n AND full_text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)\n SELECT id, text_content, app_name, window_title, element_name\n FROM nas.ui_events\n WHERE date(timestamp) = '$TARGET_DATE'\n AND text_content IS NOT NULL;\nDETACH nas;\n\"\n\n # ─── VERIFY DB ────────────────────────────────────────────────────────────\n step \"Verifying DB\"\n\n V_FRAMES=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\")\n V_ELEMENTS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n V_UI=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';\")\n V_OCR=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n V_MEETINGS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';\")\n\n check \"frames\" \"$V_FRAMES\" \"$SRC_FRAMES\"\n check \"elements\" \"$V_ELEMENTS\" \"$SRC_ELEMENTS\"\n check \"ui_events\" \"$V_UI\" \"$SRC_UI\"\n check \"ocr_text\" \"$V_OCR\" \"$SRC_OCR\"\n check \"meetings\" \"$V_MEETINGS\" \"$SRC_MEETINGS\"\n\nfi\n\n# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────\n# Always runs regardless of DB sync status\nstep \"Copying data folder for $TARGET_DATE\"\n\nif [ -d \"$DATA_SRC\" ]; then\n mkdir -p \"$NAS_DATA/$TARGET_DATE\"\n RSYNC_START=$(date +%s)\n printf \" %-36s \" \"rsync $TARGET_DATE/ → NAS\"\n rsync -a --ignore-existing \\\n \"$DATA_SRC/\" \\\n \"$NAS_DATA/$TARGET_DATE/\" \\\n 2>>\"$LOG_FILE\"\n RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))\n COPIED_FILES=$(ls \"$NAS_DATA/$TARGET_DATE\" | wc -l | tr -d ' ')\n SRC_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n COPIED_SIZE=$(du -sh \"$NAS_DATA/$TARGET_DATE\" | cut -f1)\n if [ \"$COPIED_FILES\" -eq \"$SRC_FILES\" ]; then\n printf \"\\r %-36s ✓ %dm%02ds (%s files, %s)\\n\" \\\n \"rsync $TARGET_DATE/ → NAS\" \\\n \"$(( RSYNC_DUR / 60 ))\" \"$(( RSYNC_DUR % 60 ))\" \\\n \"$COPIED_FILES\" \"$COPIED_SIZE\" | tee -a \"$LOG_FILE\"\n else\n printf \"\\r %-36s ✗ %s / %s files\\n\" \\\n \"rsync $TARGET_DATE/ → NAS\" \"$COPIED_FILES\" \"$SRC_FILES\" | tee -a \"$LOG_FILE\"\n fi\nelse\n printf \" %-36s %s\\n\" \"rsync $TARGET_DATE/ → NAS\" \"skipped (no source dir)\"\nfi\n\n# ─── COPY LOGS ────────────────────────────────────────────────────────────────\n# Screenpipe writes daily logs to ~/.screenpipe/screenpipe.YYYY-MM-DD.N.log\n# (N is a rotation counter, almost always 0). Mirror them to NAS so log\n# analysis can happen on the consumer side without SSH'ing back to the Mac.\nstep \"Copying screenpipe logs for $TARGET_DATE\"\n\nNAS_LOGS=\"$NAS_MOUNT/logs\"\nmkdir -p \"$NAS_LOGS\"\n\n# Use a glob with nullglob so an empty match doesn't expand to a literal pattern.\nshopt -s nullglob\nLOG_FILES=( \"$HOME/.screenpipe/screenpipe.$TARGET_DATE.\"*.log )\nshopt -u nullglob\n\nif [ ${#LOG_FILES[@]} -gt 0 ]; then\n printf \" %-36s \" \"rsync logs → NAS\"\n # No --ignore-existing here: logs grow during the day, so we want rsync's\n # default size+mtime check to refresh files that have changed.\n rsync -a \"${LOG_FILES[@]}\" \"$NAS_LOGS/\" 2>>\"$LOG_FILE\"\n COPIED=${#LOG_FILES[@]}\n TOTAL_SIZE=$(du -ch \"${LOG_FILES[@]}\" | tail -1 | cut -f1)\n printf \"✓ %d file(s), %s\\n\" \"$COPIED\" \"$TOTAL_SIZE\" | tee -a \"$LOG_FILE\"\nelse\n printf \" %-36s %s\\n\" \"rsync logs → NAS\" \"skipped (no matching logs)\"\nfi\n\n# ─── SUMMARY ──────────────────────────────────────────────────────────────────\nTOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))\nDB_SIZE=$(du -sh \"$NAS_DB\" | cut -f1)\n\necho \"\"\nlog \"Archive DB size: $DB_SIZE\"\nlog \"Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s\"\nlog \"Sync complete for $TARGET_DATE\"\nlog \"========================================\"\n\n# Mirror this script's own logbook to NAS so sync health can be monitored\n# from the consumer side. Done last so the summary lines above are included.\nrsync -a \"$HOME/.screenpipe/sync.log\" \"$NAS_LOGS/sync.log\" 2>/dev/null || true","depth":29,"bounds":{"left":0.11569149,"top":0.0933759,"width":0.35804522,"height":0.0007980846},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Implement and run pipe l…, Editor Group 2","depth":28,"bounds":{"left":0.5578458,"top":0.047885075,"width":0.073803194,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":false},{"role":"AXRadioButton","text":"Problems (⇧⌘M)","depth":22,"bounds":{"left":0.118351065,"top":0.7278532,"width":0.027925532,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"PROBLEMS","depth":24,"bounds":{"left":0.122340426,"top":0.7366321,"width":0.019946808,"height":0.0103751},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Output (⇧⌘U)","depth":22,"bounds":{"left":0.14594415,"top":0.7278532,"width":0.023603724,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUTPUT","depth":24,"bounds":{"left":0.14993352,"top":0.7366321,"width":0.015625,"height":0.0103751},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Debug Console (⇧⌘Y)","depth":22,"bounds":{"left":0.16921543,"top":0.7278532,"width":0.039893616,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"DEBUG CONSOLE","depth":24,"bounds":{"left":0.1732048,"top":0.7366321,"width":0.031914894,"height":0.0103751},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Terminal (⌃`)","depth":22,"bounds":{"left":0.2087766,"top":0.7278532,"width":0.026595745,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":true},{"role":"AXStaticText","text":"TERMINAL","depth":24,"bounds":{"left":0.21276596,"top":0.7366321,"width":0.01861702,"height":0.0103751},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Ports - 1 forwarded port","depth":22,"bounds":{"left":0.23537233,"top":0.7278532,"width":0.026263298,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"PORTS","depth":24,"bounds":{"left":0.2393617,"top":0.7366321,"width":0.012300532,"height":0.0103751},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":25,"bounds":{"left":0.25465426,"top":0.73743016,"width":0.0019946808,"height":0.008778931},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"remote SSH: nas","depth":16,"bounds":{"left":0.0006648936,"top":0.98244214,"width":0.028590426,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.0033244682,"top":0.9848364,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"SSH: nas","depth":17,"bounds":{"left":0.008643617,"top":0.9856345,"width":0.017952127,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"screenpipe (Git) - master*, Checkout Branch/Tag...","depth":16,"bounds":{"left":0.030917553,"top":0.98244214,"width":0.023271276,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.031914894,"top":0.9848364,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"master*","depth":17,"bounds":{"left":0.03723404,"top":0.9856345,"width":0.015957447,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"screenpipe (Git) - Synchronize Changes","depth":16,"bounds":{"left":0.05418883,"top":0.98244214,"width":0.00731383,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"No Problems","depth":16,"bounds":{"left":0.06416223,"top":0.98244214,"width":0.022606382,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.06582447,"top":0.9848364,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"0","depth":17,"bounds":{"left":0.07114362,"top":0.9856345,"width":0.004986702,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.07579787,"top":0.9848364,"width":0.0056515955,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"0","depth":17,"bounds":{"left":0.08111702,"top":0.9856345,"width":0.0039893617,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Forwarded Ports: 8766","depth":16,"bounds":{"left":0.08843085,"top":0.98244214,"width":0.012632979,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.09009308,"top":0.9848364,"width":0.0056515955,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":17,"bounds":{"left":0.09541223,"top":0.9856345,"width":0.0039893617,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Notifications","depth":16,"bounds":{"left":0.9886968,"top":0.98244214,"width":0.010638298,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sign In","depth":16,"bounds":{"left":0.9650931,"top":0.98244214,"width":0.022606382,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.96675533,"top":0.9848364,"width":0.0056515955,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Sign In","depth":17,"bounds":{"left":0.97207445,"top":0.9856345,"width":0.013962766,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"No results found","depth":12,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Implement and run pipe logic","depth":19,"bounds":{"left":0.56017286,"top":0.08060654,"width":0.07114362,"height":0.022346368},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Session history","depth":19,"bounds":{"left":0.9780585,"top":0.08060654,"width":0.00930851,"height":0.022346368},"on_screen":true,"help_text":"Session history","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"New session","depth":19,"bounds":{"left":0.9886968,"top":0.08060654,"width":0.00930851,"height":0.022346368},"on_screen":true,"help_text":"New session","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Message actions","depth":24,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"main.py","depth":23,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"lets implement logic with pipes. how can I run it?","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Let me look at the current project structure to understand what's already in place.","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"List project files","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"find /volume1/screenpipe -type f | head -50 && echo \"---\" && ls /volume1/screenpipe","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"/volume1/screenpipe/.DS_Store\n/volume1/screenpipe/screenpipe.db\n/volume1/screenpipe/screenpipe_sync.sh\n/volume1/screenpipe/app_settings.json\n/volume1/screenpipe/.gitignore\n/volume1/screenpipe/archive.db\n/volume1/screenpipe/db.sqlite\n/volume1/screenpipe/db.sqlite-wal\n/volume1/screenpipe/db.sqlite-shm\n/volume1/screenpipe/#recycle/desktop.ini\n/volume1/screenpipe/#recycle/db.sqlite\n/volume1/screenpipe/#recycle/Copy #1 of db.sqlite\n/volume1/screenpipe/#recycle/.DS_Store\n/volume1/screenpipe/#recycle/Copy #2 of db.sqlite\n/volume1/screenpipe/#recycle/archive.db\n/volume1/screenpipe/#recycle/Copy #1 of archive.db\n/volume1/screenpipe/#recycle/Copy #2 of archive.db\n/volume1/screenpipe/#recycle/Copy #3 of archive.db\n/volume1/screenpipe/#recycle/Copy #4 of archive.db\n/volume1/screenpipe/#recycle/Copy #5 of archive.db\n/volume1/screenpipe/#recycle/Copy #3 of db.sqlite\n/volume1/screenpipe/#recycle/Copy #4 of db.sqlite\n/volume1/screenpipe/#recycle/Copy #6 of archive.db\n/volume1/screenpipe/#recycle/test.txt\n/volume1/screenpipe/#recycle/Copy #7 of archive.db\n/volume1/screenpipe/#recycle/Copy #8 of archive.db\n/volume1/screenpipe/#recycle/archive.db-journal\n/volume1/screenpipe/#recycle/Copy #1 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #2 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #3 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #4 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #5 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #6 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #7 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #5 of db.sqlite\n/volume1/screenpipe/pipes/.DS_Store\n/volume1/screenpipe/app/.env\n/volume1/screenpipe/app/cli.py\n/volume1/screenpipe/app/.DS_Store\n/volume1/screenpipe/app/db.py\n/volume1/screenpipe/app/docker-compose.yml\n/volume1/screenpipe/app/main.py\n/volume1/screenpipe/app/requirements.txt\n/volume1/screenpipe/app/Dockerfile\n/volume1/screenpipe/data/.DS_Store\n/volume1/screenpipe/.git/description\n/volume1/screenpipe/.git/HEAD\n/volume1/screenpipe/.git/index\n/volume1/screenpipe/.git/COMMIT_EDITMSG\n/volume1/screenpipe/#recycle/data/.DS_Store\n---\napp\napp_settings.json\narchive.db\ndata\ndb.sqlite\ndb.sqlite-shm\ndb.sqlite-wal\npipes\n#recycle\nscreenpipe.db\nscreenpipe_sync.sh","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"main.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Check pipes directory and docker-compose","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/pipes/ && ls /volume1/screenpipe/app/ && cat /volume1/screenpipe/app/docker-compose.yml","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ai-habits\nday-recap\nmeeting-summary\nstandup-update\ntime-breakdown\nvideo-export\ncli.py\nconsumers\ndb.py\ndocker-compose.yml\nDockerfile\nmain.py\n__pycache__\nrequirements.txt\nstatic\nservices:\n screenpipe-app:\n build: .\n container_name: screenpipe-app\n restart: unless-stopped\n ports:\n - \"8766:8000\"\n volumes:\n - /volume1/screenpipe:/data\n env_file:\n - .env\n environment:\n TZ: Europe/Sofia\n DB_PATH: /data/db.sqlite\n\n sqlite-web-archive:\n image: ghcr.io/coleifer/sqlite-web:latest\n container_name: screenpipe-sqlweb-archive\n restart: unless-stopped\n ports:\n - \"8767:8080\"\n volumes:\n - /volume1/screenpipe:/data\n command: [\"-H\", \"0.0.0.0\", \"-r\", \"/data/archive.db\"]\n\n sqlite-web-live:\n image: ghcr.io/coleifer/sqlite-web:latest\n container_name: screenpipe-sqlweb-live\n restart: unless-stopped\n ports:\n - \"8768:8080\"\n volumes:\n - /volume1/screenpipe:/data\n command: [\"-H\", \"0.0.0.0\", \"-r\", \"/data/db.sqlite\"]","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"requirements.txt","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"requirements.txt","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Inspect a pipe directory","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/pipes/day-recap/ && cat /volume1/screenpipe/pipes/day-recap/pipe.json 2>/dev/null || ls /volume1/screenpipe/pipes/day-recap/","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"pipe.md\npipe.md","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"cli.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"cli.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"List all pipes and their contents","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/pipes/ && for d in /volume1/screenpipe/pipes/*/; do echo \"=== $d ===\"; ls \"$d\"; done","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ai-habits\nday-recap\nmeeting-summary\nstandup-update\ntime-breakdown\nvideo-export\n=== /volume1/screenpipe/pipes/ai-habits/ ===\npipe.md\n=== /volume1/screenpipe/pipes/day-recap/ ===\npipe.md\n=== /volume1/screenpipe/pipes/meeting-summary/ ===\npipe.md\n=== /volume1/screenpipe/pipes/standup-update/ ===\npipe.md\n=== /volume1/screenpipe/pipes/time-breakdown/ ===\npipe.md\n=== /volume1/screenpipe/pipes/video-export/ ===\npipe.md","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read pipe markdown files","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"cat /volume1/screenpipe/pipes/day-recap/pipe.md && echo \"===\" && cat /volume1/screenpipe/pipes/meeting-summary/pipe.md 2>/dev/null | head -50","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Day Recap\ndescription: \"Today's accomplishments, key moments, and unfinished work\"\nicon: \"📋\"\nfeatured: true\n---\n\nAnalyze my screen and audio recordings from today (last 16 hours only). \n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Summary\nOne sentence: what I mainly did today.\n\n## Accomplishments\n- Top 3 things I finished, with timestamps (e.g. \"2:30 PM\")\n- Name specific apps, files, or projects\n\n## Key Moments\n- Important things I saw, said, or heard — with timestamps\n\n## Unfinished Work\n- What I should continue tomorrow — name the app/file/task\n\n## Patterns\n- Apps I used most, topics that came up repeatedly\n\nOnly report what you can verify from the data. End with: \"**Next step:** [most important thing to continue]\"\n===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Meeting Summary\ndescription: \"Summarize meeting transcript with key takeaways and action items\"\nicon: \"🤝\"\nfeatured: false\n---\n\nSummarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.\n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Meeting Summary\nOne sentence: what this meeting was about.\n\n## Key Takeaways\n- Top 3-5 important points discussed\n- Include who said what when relevant\n\n## Action Items\n- [ ] Task — assigned to whom, deadline if mentioned\n- [ ] Task — assigned to whom\n\n## Decisions Made\n- List any decisions or agreements reached\n\n## Open Questions\n- Anything unresolved or needing follow-up\n\nKeep it concise and actionable.","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read summary consumer","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/app/consumers/ && cat /volume1/screenpipe/app/consumers/summary.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"activity.py\naudio.py\nelements.py\n__init__.py\ninteractions.py\nocr.py\n__pycache__\nreport.py\nsummary.py\n\"\"\"AI summary generator using Claude.\"\"\"\nimport os\nfrom datetime import date\nfrom typing import Any\n\nfrom consumers.activity import app_time, summary_stats, browser_urls, ui_event_summary\nfrom consumers.ocr import deduplicated_text\nfrom consumers.audio import formatted_transcript\n\n\nSUMMARY_TYPES = {\n \"day_recap\": {\n \"title\": \"Day Recap\",\n \"prompt\": \"\"\"\\\nYou are analyzing a person's computer activity for the day.\n\n## App usage (minutes per app):\n{app_time}\n\n## Browser URLs visited:\n{browser_urls}\n\n## UI activity per app (clicks / keystrokes / app-switches):\n{ui_events}\n\n## Screen content (sampled every 5 minutes):\n{ocr_text}\n\n## Audio/speech:\n{audio}\n\nWrite a concise day recap using EXACTLY this format:\n\n## Summary\nOne sentence: what I mainly worked on today.\n\n## Accomplishments\n- Top 3 things I finished, with approximate times\n- Name specific apps, files, or projects\n\n## Key Moments\n- Important things seen or heard, with timestamps\n\n## Unfinished Work\n- What to continue tomorrow\n\n## Patterns\n- Apps used most, topics that came up repeatedly\n\nOnly report what you can verify from the data. End with:\n**Next step:** [most important thing to continue]\"\"\",\n },\n \"standup\": {\n \"title\": \"Standup Update\",\n \"prompt\": \"\"\"\\\nYou are analyzing a person's computer activity for the day.\n\n## App usage (minutes per app):\n{app_time}\n\n## Browser URLs visited:\n{browser_urls}\n\n## UI activity per app (clicks / keystrokes / app-switches):\n{ui_events}\n\n## Screen content (sampled every 5 minutes):\n{ocr_text}\n\n## Audio/speech:\n{audio}\n\nWrite a brief standup update:\n\n**Yesterday:** What I worked on (2-3 bullets)\n**Today:** What I plan to continue (1-2 bullets)\n**Blockers:** Any issues observed (or \"None\")\n\nKeep it under 150 words. Only report what's verifiable from the data.\"\"\",\n },\n \"focus_time\": {\n \"title\": \"Focus & Distraction Analysis\",\n \"prompt\": \"\"\"\\\nYou are analyzing a person's computer activity for the day.\n\n## App usage (minutes per app):\n{app_time}\n\n## Browser URLs visited:\n{browser_urls}\n\n## UI activity per app (clicks / keystrokes / app-switches):\n{ui_events}\n\n## Screen content (sampled every 5 minutes):\n{ocr_text}\n\nAnalyze focus vs distraction patterns:\n\n## Deep Work Periods\n- When and how long were sustained focus sessions?\n- What was being worked on?\n\n## Distractions\n- Which apps/sites were used recreationally?\n- How much time was lost to context switching?\n\n## Recommendations\n- 2-3 concrete suggestions to improve focus tomorrow\n\nBe specific with times and app names.\"\"\",\n },\n}\n\n\ndef _build_context(for_date: date) -> dict[str, str]:\n apps = app_time(for_date)\n app_lines = \"\\n\".join(f\"- {a['app_name']}: {a['minutes']} min\" for a in apps[:20])\n\n urls = browser_urls(for_date, limit=20)\n url_lines = \"\\n\".join(\n f\"- {u['browser_url'][:100]} ({u['minutes']} min)\" for u in urls\n )\n\n ui_rows = ui_event_summary(for_date)\n ui_lines = \"\\n\".join(\n f\"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches\"\n for r in ui_rows[:15]\n )\n\n ocr_rows = deduplicated_text(for_date, chunk_minutes=5)\n ocr_lines = \"\\n\".join(\n f\"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}\"\n for r in ocr_rows[:100]\n )\n\n audio = formatted_transcript(for_date)\n\n return {\n \"app_time\": app_lines or \"(no app data)\",\n \"browser_urls\": url_lines or \"(no browser data)\",\n \"ui_events\": ui_lines or \"(no UI event data)\",\n \"ocr_text\": ocr_lines or \"(no screen data)\",\n \"audio\": audio[:3000] if len(audio) > 3000 else audio,\n }\n\n\ndef generate(\n summary_type: str = \"day_recap\",\n for_date: date | None = None,\n api_key: str | None = None,\n) -> dict[str, Any]:\n \"\"\"Generate an AI summary. Returns dict with 'title', 'content', 'date'.\"\"\"\n import anthropic\n\n d = for_date or date.today()\n key = api_key or os.environ.get(\"ANTHROPIC_API_KEY\", \"\")\n if not key:\n return {\n \"title\": \"Error\",\n \"content\": \"ANTHROPIC_API_KEY not set. Add it to your .env file.\",\n \"date\": str(d),\n }\n\n spec = SUMMARY_TYPES.get(summary_type)\n if not spec:\n return {\"title\": \"Error\", \"content\": f\"Unknown summary type: {summary_type}\", \"date\": str(d)}\n\n stats = summary_stats(d)\n if stats[\"total_frames\"] == 0:\n return {\n \"title\": spec[\"title\"],\n \"content\": f\"No screen data found for {d}.\",\n \"date\": str(d),\n }\n\n ctx = _build_context(d)\n prompt = spec[\"prompt\"].format(**ctx)\n\n client = anthropic.Anthropic(api_key=key)\n message = client.messages.create(\n model=\"claude-haiku-4-5-20251001\",\n max_tokens=1024,\n messages=[{\"role\": \"user\", \"content\": prompt}],\n )\n\n return {\n \"title\": spec[\"title\"],\n \"content\": message.content[0].text,\n \"date\": str(d),\n \"stats\": stats,\n }","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read all pipe.md files","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"for f in /volume1/screenpipe/pipes/*/pipe.md; do echo \"=== $f ===\"; cat \"$f\"; echo; done","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"=== /volume1/screenpipe/pipes/ai-habits/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: AI Habits\ndescription: \"How you use AI tools — patterns and insights\"\nicon: \"🤖\"\nfeatured: true\n---\n\nSearch my recordings from the last 24 hours for AI tool usage. Use app_name filter for each tool separately: ChatGPT, Claude, Copilot, Cursor, Gemini, Perplexity. Use limit=5 per search, max 6 searches total.\n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## AI Tools Used\n- List each tool with approximate time spent (e.g. \"Claude: ~45min\")\n\n## What I Used Them For\n- For each tool: coding, writing, research, or brainstorming\n\n## Usage Patterns\n- Do I switch between tools? Use them in bursts or steadily?\n\n## Effectiveness\n- Which tool appeared alongside completed work vs. abandoned attempts\n\nIf no AI usage is found, say so clearly. End with: \"**Tip:** [one suggestion to use AI tools more effectively]\"\n\n=== /volume1/screenpipe/pipes/day-recap/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Day Recap\ndescription: \"Today's accomplishments, key moments, and unfinished work\"\nicon: \"📋\"\nfeatured: true\n---\n\nAnalyze my screen and audio recordings from today (last 16 hours only). \n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Summary\nOne sentence: what I mainly did today.\n\n## Accomplishments\n- Top 3 things I finished, with timestamps (e.g. \"2:30 PM\")\n- Name specific apps, files, or projects\n\n## Key Moments\n- Important things I saw, said, or heard — with timestamps\n\n## Unfinished Work\n- What I should continue tomorrow — name the app/file/task\n\n## Patterns\n- Apps I used most, topics that came up repeatedly\n\nOnly report what you can verify from the data. End with: \"**Next step:** [most important thing to continue]\"\n\n=== /volume1/screenpipe/pipes/meeting-summary/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Meeting Summary\ndescription: \"Summarize meeting transcript with key takeaways and action items\"\nicon: \"🤝\"\nfeatured: false\n---\n\nSummarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.\n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Meeting Summary\nOne sentence: what this meeting was about.\n\n## Key Takeaways\n- Top 3-5 important points discussed\n- Include who said what when relevant\n\n## Action Items\n- [ ] Task — assigned to whom, deadline if mentioned\n- [ ] Task — assigned to whom\n\n## Decisions Made\n- List any decisions or agreements reached\n\n## Open Questions\n- Anything unresolved or needing follow-up\n\nKeep it concise and actionable.\n\n=== /volume1/screenpipe/pipes/standup-update/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Standup Update\ndescription: \"What you did, what's next, and any blockers\"\nicon: \"🏢\"\nfeatured: true\n---\n\nBased on my recordings from the last 24 hours, generate a standup update. Use limit=10 per search, max 3 searches total.\n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Yesterday\n- What I worked on (name specific projects, files, tools, PRs)\n\n## Today\n- What I will work on next (based on unfinished tasks and recent activity)\n\n## Blockers\n- Issues I hit — errors, slow builds, waiting on someone\n- If no blockers, write \"None\"\n\nKeep it under 150 words. Copy-paste ready for a team standup.\n\n=== /volume1/screenpipe/pipes/time-breakdown/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Time Breakdown\ndescription: \"Where your time went — by app, project, and category\"\nicon: \"⏱\"\nfeatured: false\n---\n\nAnalyze my app usage from today (last 12 hours). Use limit=10 per search, max 4 searches. Prefer /raw_sql with COUNT/GROUP BY queries.\n\nRead screenpipe skill first.\n\nUse this exact format with durations and percentages:\n\n## By Application\n- List each app with duration and percentage, sorted by time (e.g. \"VS Code: 2h 15min (28%)\")\n\n## By Category\n- Group into: coding, meetings, browsing, writing, communication, other\n- Show hours and percentage per category\n\n## By Project\n- Group related activities by project/topic. Name specific repos or tasks.\n\n## Productivity Score\n- Calculate: focused_work_hours / total_hours as a percentage\n- Focused = coding + writing. Unfocused = browsing + switching.\n\nEnd with: \"**Suggestion:** [one specific change to improve tomorrow's productivity]\"\n\n=== /volume1/screenpipe/pipes/video-export/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Export Video Clip\ndescription: \"Create a video of your recent screen activity\"\nicon: \"🎬\"\nfeatured: false\n---\n\nExport a video of my screen activity from the last 5 minutes.\n\nRead screenpipe skill first.\n\nUse the POST /frames/export endpoint with the time range and fps=1.0. Then show me the exported video file path as an inline code block so I can watch it.\n\nIf the export is large, suggest a lower fps or shorter time range.","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Now I have a clear picture. The pipes are markdown prompt templates in","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"/volume1/screenpipe/pipes/","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":", but there's no code to actually load and run them —","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"consumers/summary.py","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"has its own hardcoded prompts instead.","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Here's what I'll implement:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"consumers/pipes.py","depth":26,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"— dynamically loads pipe.md files and runs them via Claude (data injected as system message, pipe body as user prompt)","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"main.py","depth":26,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"— two new endpoints:","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"GET /api/pipes","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"and","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"POST /api/pipes/{pipe_id}/run","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"cli.py","depth":26,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"— a","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"pipe","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"command to run pipes from the terminal","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Let me build it:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Check browser_urls signature","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"cat /volume1/screenpipe/app/consumers/activity.py | grep \"def browser_urls\" -A 5","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"def browser_urls(\n for_date: date | None = None,\n app_name: str | None = None,\n ts_from: str | None = None,\n ts_to: str | None = None,\n limit: int = 30,","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Write","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"pipes.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"pipes.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"143 lines","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"\"\"\"Dynamic pipe loader and runner.\"\"\"\nimport os\nimport re\nfrom datetime import date\nfrom pathlib import Path\nfrom typing import Any\n\n\ndef _parse_frontmatter(text: str) -> tuple[dict, str]:\n if not text.startswith(\"---\"):\n return {}, text\n try:\n end = text.index(\"---\", 3)\n except ValueError:\n return {}, text\n fm_text = text[3:end].strip()\n body = text[end + 3:].strip()\n meta: dict = {}\n for line in fm_text.splitlines():\n if \":\" in line:\n k, _, v = line.partition(\":\")\n meta[k.strip()] = v.strip().strip('\"')\n return meta, body\n\n\ndef load_pipes(pipes_dir: Path) -> list[dict]:\n if not pipes_dir.exists():\n return []\n pipes = []\n for pipe_dir in sorted(pipes_dir.iterdir()):\n if not pipe_dir.is_dir() or pipe_dir.name.startswith(\".\"):\n continue\n pipe_md = pipe_dir / \"pipe.md\"\n if not pipe_md.exists():\n continue\n text = pipe_md.read_text(encoding=\"utf-8\")\n meta, body = _parse_frontmatter(text)\n if meta.get(\"enabled\", \"true\").lower() == \"false\":\n continue\n body = re.sub(r\"Read screenpipe skill first\\.?\\n?\", \"\", body).strip()\n pipes.append({\n \"id\": pipe_dir.name,\n \"title\": meta.get(\"title\", pipe_dir.name),\n \"description\": meta.get(\"description\", \"\"),\n \"icon\": meta.get(\"icon\", \"\"),\n \"schedule\": meta.get(\"schedule\", \"manual\"),\n \"featured\": meta.get(\"featured\", \"false\").lower() == \"true\",\n \"prompt\": body,\n })\n return pipes\n\n\ndef _build_system(d: date, stats: dict) -> str:\n from consumers.activity import app_time, browser_urls, ui_event_summary\n from consumers.ocr import deduplicated_text\n from consumers.audio import formatted_transcript\n\n apps = app_time(d)\n app_lines = \"\\n\".join(f\"- {a['app_name']}: {a['minutes']} min\" for a in apps[:20])\n\n urls = browser_urls(d, limit=20)\n url_lines = \"\\n\".join(f\"- {u['browser_url'][:100]} ({u['minutes']} min)\" for u in urls)\n\n ui_rows = ui_event_summary(d)\n ui_lines = \"\\n\".join(\n f\"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches\"\n for r in ui_rows[:15]\n )\n\n ocr_rows = deduplicated_text(d, chunk_minutes=5)\n ocr_lines = \"\\n\".join(\n f\"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}\"\n for r in ocr_rows[:100]\n )\n\n audio = formatted_transcript(d)\n if len(audio) > 3000:\n audio = audio[:3000]\n\n return f\"\"\"You are analyzing screenpipe data — recordings of a person's computer activity.\n\n## App usage (minutes per app):\n{app_lines or '(no app data)'}\n\n## Browser URLs visited:\n{url_lines or '(no browser data)'}\n\n## UI activity per app (clicks / keystrokes / app-switches):\n{ui_lines or '(no UI event data)'}\n\n## Screen content (sampled every 5 minutes):\n{ocr_lines or '(no screen data)'}\n\n## Audio / speech:\n{audio or '(no audio data)'}\n\nDate: {d}\nTotal frames recorded: {stats['total_frames']}\"\"\"\n\n\ndef run_pipe(\n pipe_id: str,\n for_date: date | None = None,\n api_key: str | None = None,\n pipes_dir: Path | None = None,\n) -> dict[str, Any]:\n import anthropic\n from consumers.activity import summary_stats\n\n d = for_date or date.today()\n key = api_key or os.environ.get(\"ANTHROPIC_API_KEY\", \"\")\n if not key:\n return {\"title\": \"Error\", \"content\": \"ANTHROPIC_API_KEY not set.\", \"date\": str(d)}\n\n _pipes_dir = pipes_dir or Path(os.environ.get(\"PIPES_DIR\", \"/data/pipes\"))\n all_pipes = {p[\"id\"]: p for p in load_pipes(_pipes_dir)}\n\n if pipe_id not in all_pipes:\n return {\"title\": \"Error\", \"content\": f\"Pipe not found: {pipe_id}\", \"date\": str(d)}\n\n pipe = all_pipes[pipe_id]\n stats = summary_stats(d)\n\n if stats[\"total_frames\"] == 0:\n return {\"title\": pipe[\"title\"], \"content\": f\"No screen data found for {d}.\", \"date\": str(d)}\n\n system = _build_system(d, stats)\n\n client = anthropic.Anthropic(api_key=key)\n message = client.messages.create(\n model=\"claude-haiku-4-5-20251001\",\n max_tokens=1024,\n system=system,\n messages=[{\"role\": \"user\", \"content\": pipe[\"prompt\"]}],\n )\n\n return {\n \"title\": pipe[\"title\"],\n \"content\": message.content[0].text,\n \"date\": str(d),\n \"stats\": stats,\n }","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Now add the API endpoints to","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"main.py","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":":","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Edit","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"main.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Added 1 line","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Edit","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"main.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Added 1 line","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Now add the pipe endpoints at the end of main.py, before the closing summary section:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Edit","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"main.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Added 14 lines","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Now add the CLI command to","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"cli.py","depth":23,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"cli.py","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":":","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Edit","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"cli.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"cli.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Added 40 lines","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Done. Here's how to run pipes:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXHeading","text":"How to run pipes","depth":22,"on_screen":false,"role_description":"heading"},{"role":"AXStaticText","text":"How to run pipes","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Via Docker (inside the running container):","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":23,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"docker exec -it screenpipe-app python cli.py pipe --list\ndocker exec -it screenpipe-app python cli.py pipe day-recap\ndocker exec -it screenpipe-app python cli.py pipe standup-update --date yesterday","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Via the API","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"(once the container is running on port 8766):","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":23,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"# List pipes\ncurl http://localhost:8766/api/pipes\n\n# Run a pipe\ncurl -X POST \"http://localhost:8766/api/pipes/day-recap/run\"\ncurl -X POST \"http://localhost:8766/api/pipes/standup-update/run?d=2026-04-25\"","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Rebuild and restart","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"to pick up the changes:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":23,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"cd /volume1/screenpipe/app\ndocker compose up --build -d","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"How it works:","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Each","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"pipe.md","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"file is loaded dynamically — the frontmatter provides metadata and the body becomes the user prompt. Screenpipe data (app usage, browser URLs, OCR, audio) is injected as a Claude system message so the pipe prompt can reference it naturally. The \"Read screenpipe skill first\" line is stripped automatically.","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"The pipes directory inside Docker is","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"/data/pipes","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"(since","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"/volume1/screenpipe","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"→","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"/data","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"). You can override it with a","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"PIPES_DIR","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"env var if needed.","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Message actions","depth":24,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"pipe.md","depth":23,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"pipe.md","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"where to place api key and can I use different keys","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read .env file","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"cat /volume1/screenpipe/app/.env","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ANTHROPIC_API_KEY=your_key_here","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Where to place the key:","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"app/.env","depth":23,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"app/.env","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"— replace","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"your_key_here","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"with your actual key:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":23,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"ANTHROPIC_API_KEY=sk-ant-...","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"That file is loaded by","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"load_dotenv()","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"at startup and is excluded from git via","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":".gitignore","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":".","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Can you use different keys per pipe?","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Not currently — all pipes share the one key from","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":".env","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":". But you can add per-pipe key support by adding an","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"api_key","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"field to the pipe's frontmatter:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":23,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"---\ntitle: Meeting Summary\napi_key_env: ANTHROPIC_KEY_MEETINGS\n---","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Then in","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"consumers/pipes.py","depth":23,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"consumers/pipes.py","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":", read it in","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"_parse_frontmatter","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"and pass it through","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"run_pipe","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":". Want me to add that?","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Message actions","depth":24,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"pipe.md","depth":23,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"pipe.md","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"can I use mistral or other llm? or is is build for antrophic only","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"}]...
|
6632213391033132511
|
8363351146505899285
|
visual_change
|
accessibility
|
NULL
|
Explorer (⇧⌘E) - 1 unsaved file
1
Search (⇧⌘F)
Explorer (⇧⌘E) - 1 unsaved file
1
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py
M
db.py
docker-compose.yml
Dockerfile
M
main.py
M
requirements.txt
M
data
logs
pipes
.gitignore
app_settings.json
archive.db
archive.db-bak
U
db.sqlite
db.sqlite-shm
db.sqlite-wal
screenpipe_sync_updated.sh
U
screenpipe_sync.sh
screenpipe.db
Outline Section
OUTLINE
OUTLINE
Timeline Section
TIMELINE
TIMELINE
app_settings.json, Editor Group 1
screenpipe_sync.sh, Editor Group 1
pipe.md, Editor Group 1
.env, Editor Group 1
#!/bin/bash
# screenpipe_sync.sh
# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).
# Also copies the day's video/frame data folder to the NAS.
#
# Schema-drift tolerant: if Screenpipe migrations add new columns to the source DB,
# the NAS archive gets ALTER TABLE'd to match. Inserts use explicit column lists,
# so positional mismatches can't occur.
#
# Usage:
# ./screenpipe_sync.sh # syncs yesterday (default)
# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date
# ./screenpipe_sync.sh today # syncs today so far
#
# Cron example (runs at 3am daily):
# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1
set -euo pipefail
# ─── CONFIG ───────────────────────────────────────────────────────────────────
DB_SRC="${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}"
NAS_MOUNT="${NAS_MOUNT:-/Volumes/screenpipe}"
NAS_DB="$NAS_MOUNT/archive.db"
NAS_DATA="$NAS_MOUNT/data"
LOG_FILE="$HOME/.screenpipe/sync.log"
# Tables that get schema drift handling. Order matters for FK-ish references
# (parents before children: video_chunks → frames → elements/ocr_text/ui_events).
SYNC_TABLES=(video_chunks frames elements ocr_text ui_events meetings)
# ──────────────────────────────────────────────────────────────────────────────
# ─── HELPERS ──────────────────────────────────────────────────────────────────
SCRIPT_START=$(date +%s)
log() {
local msg="[$(date '+%Y-%m-%d %H:%M:%S')] $*"
echo "$msg" | tee -a "$LOG_FILE"
}
step() {
local now=$(date +%s)
local elapsed=$(( now - SCRIPT_START ))
local min=$(( elapsed / 60 ))
local sec=$(( elapsed % 60 ))
printf "\n[+%02dm%02ds] ▶ %s\n" "$min" "$sec" "$*" | tee -a "$LOG_FILE"
}
run_sqlite_heredoc() {
local label="$1"
local sql="$2"
local start=$(date +%s)
printf " %-36s " "$label"
sqlite3 "$DB_SRC" <<< "$sql" &
local pid=$!
local spin=[PASSWORD] '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')
local i=0
while kill -0 "$pid" 2>/dev/null; do
printf "\r %-36s %s " "$label" "${spin[$i]}"
i=$(( (i + 1) % 10 ))
sleep 0.2
done
wait "$pid"
local rc=$?
if [ $rc -ne 0 ]; then
printf "\r %-36s ✗ FAILED\n" "$label" | tee -a "$LOG_FILE"
exit $rc
fi
local dur=$(( $(date +%s) - start ))
printf "\r %-36s ✓ %dm%02ds\n" "$label" "$(( dur / 60 ))" "$(( dur % 60 ))" | tee -a "$LOG_FILE"
}
check() {
local label="$1" got="$2" expected="$3"
if [ "$got" -eq "$expected" ]; then
printf " %-20s %s / %s ✓\n" "$label:" "$got" "$expected"
else
printf " %-20s %s / %s ✗ MISMATCH\n" "$label:" "$got" "$expected"
fi
}
# ─── SCHEMA HELPERS ───────────────────────────────────────────────────────────
# Echoes "name|type" lines for a table from a given DB.
table_columns_with_types() {
local db="$1" table="$2"
sqlite3 "$db" "PRAGMA table_info($table);" | awk -F'|' '{print $2 "|" $3}'
}
# Echoes just column names, one per line.
table_columns() {
local db="$1" table="$2"
sqlite3 "$db" "PRAGMA table_info($table);" | awk -F'|' '{print $2}'
}
# Returns true (0) if a table exists in the given DB.
table_exists() {
local db="$1" table="$2"
local count
count=$(sqlite3 "$db" "SELECT COUNT(*) FROM sqlite_master WHERE type='table' AND name='$table';")
[ "$count" -gt 0 ]
}
# Adds any columns present in source but missing in NAS for the given table.
# Uses ALTER TABLE ADD COLUMN, which is a fast metadata-only operation in SQLite.
ensure_columns() {
local table="$1"
local label="schema: $table"
printf " %-36s " "$label"
if ! table_exists "$DB_SRC" "$table"; then
printf "✗ source missing — skipping\n"
return 0
fi
if ! table_exists "$NAS_DB" "$table"; then
printf "✓ fresh (created above)\n"
return 0
fi
local src_cols
src_cols=$(table_columns_with_types "$DB_SRC" "$table")
local nas_cols
nas_cols=$(table_columns "$NAS_DB" "$table")
local added=0
local added_names=""
while IFS='|' read -r name type; do
[ -z "$name" ] && continue
# Use grep -F -x for fixed-string exact match (safe against regex chars).
if ! echo "$nas_cols" | grep -Fxq "$name"; then
# SQLite ALTER TABLE ADD COLUMN: type is optional, no NOT NULL allowed
# without a constant default. Default-NULL is exactly what we want for archive.
sqlite3 "$NAS_DB" "ALTER TABLE $table ADD COLUMN \"$name\" $type;"
added=$((added + 1))
added_names="$added_names $name"
fi
done <<< "$src_cols"
if [ "$added" -gt 0 ]; then
printf "✓ added %d:%s\n" "$added" "$added_names"
else
printf "✓ in sync\n"
fi
}
# Echoes a comma-separated list of source columns for a table, double-quoted
# so reserved words and hyphens are safe. If an alias is provided, columns are
# prefixed (e.g. `o."col"`). Used for both INSERT and SELECT sides; aliased
# form is required when SELECTing from a JOIN where column names collide
# (e.g. ocr_text and frames both have app_name, window_name).
build_col_list() {
local table="$1"
local alias="${2:-}"
local prefix=""
[ -n "$alias" ] && prefix="${alias}."
table_columns "$DB_SRC" "$table" | awk 'NF' | awk -v p="$prefix" '{print p "\"" $0 "\""}' | paste -sd, -
}
# ──────────────────────────────────────────────────────────────────────────────
# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────
if [ "${1:-}" = "today" ]; then
TARGET_DATE=$(date +%Y-%m-%d)
elif [ -n "${1:-}" ]; then
TARGET_DATE="$1"
if ! [[ "$TARGET_DATE" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then
echo "ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday."
exit 1
fi
else
TARGET_DATE=$(date -v-1d +%Y-%m-%d)
fi
log "========================================"
log "Screenpipe sync starting for: $TARGET_DATE"
log "========================================"
# ─── PREFLIGHT ────────────────────────────────────────────────────────────────
step "Preflight checks"
if [ ! -f "$DB_SRC" ]; then
log "ERROR: Source DB not found at $DB_SRC"; exit 1
fi
printf " %-20s %s (%s)\n" "Source DB:" "OK" "$(du -sh "$DB_SRC" | cut -f1)"
if [ ! -d "$NAS_MOUNT" ]; then
log "ERROR: NAS not mounted at $NAS_MOUNT"; exit 1
fi
printf " %-20s %s\n" "NAS mount:" "OK $NAS_MOUNT"
# Check if DB already synced for this date
DB_ALREADY_SYNCED=false
if [ -f "$NAS_DB" ]; then
if table_exists "$NAS_DB" "frames"; then
EXISTING=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';" 2>/dev/null || echo "0")
if [ "$EXISTING" -gt "0" ]; then
log "Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync"
DB_ALREADY_SYNCED=true
else
printf " %-20s %s (%s)\n" "Archive DB:" "exists" "$(du -sh "$NAS_DB" | cut -f1)"
fi
else
printf " %-20s %s\n" "Archive DB:" "exists, no frames table yet"
fi
else
printf " %-20s %s\n" "Archive DB:" "will be created"
fi
# Source data dir for this date
DATA_SRC="$HOME/.screenpipe/data/data/$TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
DATA_SIZE=$(du -sh "$DATA_SRC" | cut -f1)
DATA_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
printf " %-20s %s (%s files, %s)\n" "Data dir:" "OK" "$DATA_FILES" "$DATA_SIZE"
else
printf " %-20s %s\n" "Data dir:" "not found — skipping file copy"
fi
# ─── DB SYNC ──────────────────────────────────────────────────────────────────
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────
step "Counting source rows for $TARGET_DATE"
SRC_FRAMES=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
SRC_ELEMENTS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_UI=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
SRC_OCR=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_MEETINGS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';")
printf " %-20s %s\n" "frames:" "$SRC_FRAMES"
printf " %-20s %s\n" "elements:" "$SRC_ELEMENTS"
printf " %-20s %s\n" "ui_events:" "$SRC_UI"
printf " %-20s %s\n" "ocr_text:" "$SRC_OCR"
printf " %-20s %s\n" "meetings:" "$SRC_MEETINGS"
if [ "$SRC_FRAMES" -eq "0" ]; then
log "No frames found for $TARGET_DATE — skipping DB sync"
DB_ALREADY_SYNCED=true
fi
fi
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── INIT TABLES ──────────────────────────────────────────────────────────
step "Initialising tables (CREATE IF NOT EXISTS)"
run_sqlite_heredoc "creating tables" "
ATTACH '$NAS_DB' AS nas;
CREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;
CREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;
CREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;
CREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;
DETACH nas;
"
# ─── SCHEMA DRIFT FIX ─────────────────────────────────────────────────────
# Runs AFTER CREATE IF NOT EXISTS so newly-created tables are no-ops here,
# and pre-existing tables get any missing columns added.
step "Reconciling NAS schema with source"
for tbl in "${SYNC_TABLES[@]}"; do
ensure_columns "$tbl"
done
run_sqlite_heredoc "creating indexes" "
ATTACH '$NAS_DB' AS nas;
CREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);
CREATE INDEX IF NOT EXISTS nas.idx_frames_document_path ON frames(document_path) WHERE document_path IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_elements_onscreen_frame ON elements(frame_id) WHERE on_screen = 1 AND text IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);
CREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);
DETACH nas;
"
run_sqlite_heredoc "creating FTS tables" "
ATTACH '$NAS_DB' AS nas;
CREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(
text, role, frame_id UNINDEXED,
content='elements', content_rowid='id', tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(
full_text, app_name, window_name, browser_url, id UNINDEXED,
tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(
text_content,
app_name,
window_title,
element_name,
content='ui_events',
content_rowid='id',
tokenize='unicode61'
);
DETACH nas;
"
# ─── BUILD EXPLICIT COLUMN LISTS ──────────────────────────────────────────
# After ensure_columns, source ⊆ NAS for every synced table, so source's
# column list is a safe subset to use on both sides of the INSERT.
# For tables that JOIN frames (ocr_text, elements), the SELECT side needs
# alias-qualified columns because both tables share names (app_name, etc).
FRAMES_COLS=$(build_col_list frames)
ELEMENTS_COLS=$(build_col_list elements)
ELEMENTS_COLS_E=$(build_col_list elements e)
UI_EVENTS_COLS=$(build_col_list ui_events)
OCR_TEXT_COLS=$(build_col_list ocr_text)
OCR_TEXT_COLS_O=$(build_col_list ocr_text o)
VIDEO_CHUNKS_COLS=$(build_col_list video_chunks)
MEETINGS_COLS=$(build_col_list meetings)
# ─── SYNC DATA ────────────────────────────────────────────────────────────
step "Syncing data for $TARGET_DATE"
run_sqlite_heredoc "video_chunks" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.video_chunks ($VIDEO_CHUNKS_COLS)
SELECT $VIDEO_CHUNKS_COLS FROM main.video_chunks
WHERE id IN (
SELECT DISTINCT video_chunk_id FROM main.frames
WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL
);
DETACH nas;
"
run_sqlite_heredoc "frames ($SRC_FRAMES rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.frames ($FRAMES_COLS)
SELECT $FRAMES_COLS FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ocr_text ($SRC_OCR rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ocr_text ($OCR_TEXT_COLS)
SELECT $OCR_TEXT_COLS_O FROM main.ocr_text o
JOIN main.frames f ON o.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ui_events ($SRC_UI rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ui_events ($UI_EVENTS_COLS)
SELECT $UI_EVENTS_COLS FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "elements ($SRC_ELEMENTS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.elements ($ELEMENTS_COLS)
SELECT $ELEMENTS_COLS_E FROM main.elements e
JOIN main.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "meetings ($SRC_MEETINGS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.meetings ($MEETINGS_COLS)
SELECT $MEETINGS_COLS FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';
DETACH nas;
"
# ─── FTS UPDATE ───────────────────────────────────────────────────────────
step "Updating FTS indexes"
run_sqlite_heredoc "elements_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.elements_fts(rowid, text, role)
SELECT e.id, e.text, e.role
FROM nas.elements e
JOIN nas.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE'
AND e.text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "frames_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)
SELECT id, full_text, app_name, window_name, browser_url, id
FROM nas.frames
WHERE date(timestamp) = '$TARGET_DATE'
AND full_text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "ui_events_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)
SELECT id, text_content, app_name, window_title, element_name
FROM nas.ui_events
WHERE date(timestamp) = '$TARGET_DATE'
AND text_content IS NOT NULL;
DETACH nas;
"
# ─── VERIFY DB ────────────────────────────────────────────────────────────
step "Verifying DB"
V_FRAMES=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
V_ELEMENTS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_UI=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
V_OCR=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_MEETINGS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';")
check "frames" "$V_FRAMES" "$SRC_FRAMES"
check "elements" "$V_ELEMENTS" "$SRC_ELEMENTS"
check "ui_events" "$V_UI" "$SRC_UI"
check "ocr_text" "$V_OCR" "$SRC_OCR"
check "meetings" "$V_MEETINGS" "$SRC_MEETINGS"
fi
# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────
# Always runs regardless of DB sync status
step "Copying data folder for $TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
mkdir -p "$NAS_DATA/$TARGET_DATE"
RSYNC_START=$(date +%s)
printf " %-36s " "rsync $TARGET_DATE/ → NAS"
rsync -a --ignore-existing \
"$DATA_SRC/" \
"$NAS_DATA/$TARGET_DATE/" \
2>>"$LOG_FILE"
RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))
COPIED_FILES=$(ls "$NAS_DATA/$TARGET_DATE" | wc -l | tr -d ' ')
SRC_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
COPIED_SIZE=$(du -sh "$NAS_DATA/$TARGET_DATE" | cut -f1)
if [ "$COPIED_FILES" -eq "$SRC_FILES" ]; then
printf "\r %-36s ✓ %dm%02ds (%s files, %s)\n" \
"rsync $TARGET_DATE/ → NAS" \
"$(( RSYNC_DUR / 60 ))" "$(( RSYNC_DUR % 60 ))" \
"$COPIED_FILES" "$COPIED_SIZE" | tee -a "$LOG_FILE"
else
printf "\r %-36s ✗ %s / %s files\n" \
"rsync $TARGET_DATE/ → NAS" "$COPIED_FILES" "$SRC_FILES" | tee -a "$LOG_FILE"
fi
else
printf " %-36s %s\n" "rsync $TARGET_DATE/ → NAS" "skipped (no source dir)"
fi
# ─── COPY LOGS ────────────────────────────────────────────────────────────────
# Screenpipe writes daily logs to ~/.screenpipe/screenpipe.YYYY-MM-DD.N.log
# (N is a rotation counter, almost always 0). Mirror them to NAS so log
# analysis can happen on the consumer side without SSH'ing back to the Mac.
step "Copying screenpipe logs for $TARGET_DATE"
NAS_LOGS="$NAS_MOUNT/logs"
mkdir -p "$NAS_LOGS"
# Use a glob with nullglob so an empty match doesn't expand to a literal pattern.
shopt -s nullglob
LOG_FILES=( "$HOME/.screenpipe/screenpipe.$TARGET_DATE."*.log )
shopt -u nullglob
if [ ${#LOG_FILES[@]} -gt 0 ]; then
printf " %-36s " "rsync logs → NAS"
# No --ignore-existing here: logs grow during the day, so we want rsync's
# default size+mtime check to refresh files that have changed.
rsync -a "${LOG_FILES[@]}" "$NAS_LOGS/" 2>>"$LOG_FILE"
COPIED=${#LOG_FILES[@]}
TOTAL_SIZE=$(du -ch "${LOG_FILES[@]}" | tail -1 | cut -f1)
printf "✓ %d file(s), %s\n" "$COPIED" "$TOTAL_SIZE" | tee -a "$LOG_FILE"
else
printf " %-36s %s\n" "rsync logs → NAS" "skipped (no matching logs)"
fi
# ─── SUMMARY ──────────────────────────────────────────────────────────────────
TOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))
DB_SIZE=$(du -sh "$NAS_DB" | cut -f1)
echo ""
log "Archive DB size: $DB_SIZE"
log "Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s"
log "Sync complete for $TARGET_DATE"
log "========================================"
# Mirror this script's own logbook to NAS so sync health can be monitored
# from the consumer side. Done last so the summary lines above are included.
rsync -a "$HOME/.screenpipe/sync.log" "$NAS_LOGS/sync.log" 2>/dev/null || true
#!/bin/bash
# screenpipe_sync.sh
# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).
# Also copies the day's video/frame data folder to the NAS.
#
# Schema-drift tolerant: if Screenpipe migrations add new columns to the source DB,
# the NAS archive gets ALTER TABLE'd to match. Inserts use explicit column lists,
# so positional mismatches can't occur.
#
# Usage:
# ./screenpipe_sync.sh # syncs yesterday (default)
# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date
# ./screenpipe_sync.sh today # syncs today so far
#
# Cron example (runs at 3am daily):
# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1
set -euo pipefail
# ─── CONFIG ───────────────────────────────────────────────────────────────────
DB_SRC="${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}"
NAS_MOUNT="${NAS_MOUNT:-/Volumes/screenpipe}"
NAS_DB="$NAS_MOUNT/archive.db"
NAS_DATA="$NAS_MOUNT/data"
LOG_FILE="$HOME/.screenpipe/sync.log"
# Tables that get schema drift handling. Order matters for FK-ish references
# (parents before children: video_chunks → frames → elements/ocr_text/ui_events).
SYNC_TABLES=(video_chunks frames elements ocr_text ui_events meetings)
# ──────────────────────────────────────────────────────────────────────────────
# ─── HELPERS ──────────────────────────────────────────────────────────────────
SCRIPT_START=$(date +%s)
log() {
local msg="[$(date '+%Y-%m-%d %H:%M:%S')] $*"
echo "$msg" | tee -a "$LOG_FILE"
}
step() {
local now=$(date +%s)
local elapsed=$(( now - SCRIPT_START ))
local min=$(( elapsed / 60 ))
local sec=$(( elapsed % 60 ))
printf "\n[+%02dm%02ds] ▶ %s\n" "$min" "$sec" "$*" | tee -a "$LOG_FILE"
}
run_sqlite_heredoc() {
local label="$1"
local sql="$2"
local start=$(date +%s)
printf " %-36s " "$label"
sqlite3 "$DB_SRC" <<< "$sql" &
local pid=$!
local spin=[PASSWORD] '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')
local i=0
while kill -0 "$pid" 2>/dev/null; do
printf "\r %-36s %s " "$label" "${spin[$i]}"
i=$(( (i + 1) % 10 ))
sleep 0.2
done
wait "$pid"
local rc=$?
if [ $rc -ne 0 ]; then
printf "\r %-36s ✗ FAILED\n" "$label" | tee -a "$LOG_FILE"
exit $rc
fi
local dur=$(( $(date +%s) - start ))
printf "\r %-36s ✓ %dm%02ds\n" "$label" "$(( dur / 60 ))" "$(( dur % 60 ))" | tee -a "$LOG_FILE"
}
check() {
local label="$1" got="$2" expected="$3"
if [ "$got" -eq "$expected" ]; then
printf " %-20s %s / %s ✓\n" "$label:" "$got" "$expected"
else
printf " %-20s %s / %s ✗ MISMATCH\n" "$label:" "$got" "$expected"
fi
}
# ─── SCHEMA HELPERS ───────────────────────────────────────────────────────────
# Echoes "name|type" lines for a table from a given DB.
table_columns_with_types() {
local db="$1" table="$2"
sqlite3 "$db" "PRAGMA table_info($table);" | awk -F'|' '{print $2 "|" $3}'
}
# Echoes just column names, one per line.
table_columns() {
local db="$1" table="$2"
sqlite3 "$db" "PRAGMA table_info($table);" | awk -F'|' '{print $2}'
}
# Returns true (0) if a table exists in the given DB.
table_exists() {
local db="$1" table="$2"
local count
count=$(sqlite3 "$db" "SELECT COUNT(*) FROM sqlite_master WHERE type='table' AND name='$table';")
[ "$count" -gt 0 ]
}
# Adds any columns present in source but missing in NAS for the given table.
# Uses ALTER TABLE ADD COLUMN, which is a fast metadata-only operation in SQLite.
ensure_columns() {
local table="$1"
local label="schema: $table"
printf " %-36s " "$label"
if ! table_exists "$DB_SRC" "$table"; then
printf "✗ source missing — skipping\n"
return 0
fi
if ! table_exists "$NAS_DB" "$table"; then
printf "✓ fresh (created above)\n"
return 0
fi
local src_cols
src_cols=$(table_columns_with_types "$DB_SRC" "$table")
local nas_cols
nas_cols=$(table_columns "$NAS_DB" "$table")
local added=0
local added_names=""
while IFS='|' read -r name type; do
[ -z "$name" ] && continue
# Use grep -F -x for fixed-string exact match (safe against regex chars).
if ! echo "$nas_cols" | grep -Fxq "$name"; then
# SQLite ALTER TABLE ADD COLUMN: type is optional, no NOT NULL allowed
# without a constant default. Default-NULL is exactly what we want for archive.
sqlite3 "$NAS_DB" "ALTER TABLE $table ADD COLUMN \"$name\" $type;"
added=$((added + 1))
added_names="$added_names $name"
fi
done <<< "$src_cols"
if [ "$added" -gt 0 ]; then
printf "✓ added %d:%s\n" "$added" "$added_names"
else
printf "✓ in sync\n"
fi
}
# Echoes a comma-separated list of source columns for a table, double-quoted
# so reserved words and hyphens are safe. If an alias is provided, columns are
# prefixed (e.g. `o."col"`). Used for both INSERT and SELECT sides; aliased
# form is required when SELECTing from a JOIN where column names collide
# (e.g. ocr_text and frames both have app_name, window_name).
build_col_list() {
local table="$1"
local alias="${2:-}"
local prefix=""
[ -n "$alias" ] && prefix="${alias}."
table_columns "$DB_SRC" "$table" | awk 'NF' | awk -v p="$prefix" '{print p "\"" $0 "\""}' | paste -sd, -
}
# ──────────────────────────────────────────────────────────────────────────────
# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────
if [ "${1:-}" = "today" ]; then
TARGET_DATE=$(date +%Y-%m-%d)
elif [ -n "${1:-}" ]; then
TARGET_DATE="$1"
if ! [[ "$TARGET_DATE" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then
echo "ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday."
exit 1
fi
else
TARGET_DATE=$(date -v-1d +%Y-%m-%d)
fi
log "========================================"
log "Screenpipe sync starting for: $TARGET_DATE"
log "========================================"
# ─── PREFLIGHT ────────────────────────────────────────────────────────────────
step "Preflight checks"
if [ ! -f "$DB_SRC" ]; then
log "ERROR: Source DB not found at $DB_SRC"; exit 1
fi
printf " %-20s %s (%s)\n" "Source DB:" "OK" "$(du -sh "$DB_SRC" | cut -f1)"
if [ ! -d "$NAS_MOUNT" ]; then
log "ERROR: NAS not mounted at $NAS_MOUNT"; exit 1
fi
printf " %-20s %s\n" "NAS mount:" "OK $NAS_MOUNT"
# Check if DB already synced for this date
DB_ALREADY_SYNCED=false
if [ -f "$NAS_DB" ]; then
if table_exists "$NAS_DB" "frames"; then
EXISTING=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';" 2>/dev/null || echo "0")
if [ "$EXISTING" -gt "0" ]; then
log "Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync"
DB_ALREADY_SYNCED=true
else
printf " %-20s %s (%s)\n" "Archive DB:" "exists" "$(du -sh "$NAS_DB" | cut -f1)"
fi
else
printf " %-20s %s\n" "Archive DB:" "exists, no frames table yet"
fi
else
printf " %-20s %s\n" "Archive DB:" "will be created"
fi
# Source data dir for this date
DATA_SRC="$HOME/.screenpipe/data/data/$TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
DATA_SIZE=$(du -sh "$DATA_SRC" | cut -f1)
DATA_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
printf " %-20s %s (%s files, %s)\n" "Data dir:" "OK" "$DATA_FILES" "$DATA_SIZE"
else
printf " %-20s %s\n" "Data dir:" "not found — skipping file copy"
fi
# ─── DB SYNC ──────────────────────────────────────────────────────────────────
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────
step "Counting source rows for $TARGET_DATE"
SRC_FRAMES=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
SRC_ELEMENTS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_UI=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
SRC_OCR=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_MEETINGS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';")
printf " %-20s %s\n" "frames:" "$SRC_FRAMES"
printf " %-20s %s\n" "elements:" "$SRC_ELEMENTS"
printf " %-20s %s\n" "ui_events:" "$SRC_UI"
printf " %-20s %s\n" "ocr_text:" "$SRC_OCR"
printf " %-20s %s\n" "meetings:" "$SRC_MEETINGS"
if [ "$SRC_FRAMES" -eq "0" ]; then
log "No frames found for $TARGET_DATE — skipping DB sync"
DB_ALREADY_SYNCED=true
fi
fi
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── INIT TABLES ──────────────────────────────────────────────────────────
step "Initialising tables (CREATE IF NOT EXISTS)"
run_sqlite_heredoc "creating tables" "
ATTACH '$NAS_DB' AS nas;
CREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;
CREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;
CREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;
CREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;
DETACH nas;
"
# ─── SCHEMA DRIFT FIX ─────────────────────────────────────────────────────
# Runs AFTER CREATE IF NOT EXISTS so newly-created tables are no-ops here,
# and pre-existing tables get any missing columns added.
step "Reconciling NAS schema with source"
for tbl in "${SYNC_TABLES[@]}"; do
ensure_columns "$tbl"
done
run_sqlite_heredoc "creating indexes" "
ATTACH '$NAS_DB' AS nas;
CREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);
CREATE INDEX IF NOT EXISTS nas.idx_frames_document_path ON frames(document_path) WHERE document_path IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_elements_onscreen_frame ON elements(frame_id) WHERE on_screen = 1 AND text IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);
CREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);
DETACH nas;
"
run_sqlite_heredoc "creating FTS tables" "
ATTACH '$NAS_DB' AS nas;
CREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(
text, role, frame_id UNINDEXED,
content='elements', content_rowid='id', tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(
full_text, app_name, window_name, browser_url, id UNINDEXED,
tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(
text_content,
app_name,
window_title,
element_name,
content='ui_events',
content_rowid='id',
tokenize='unicode61'
);
DETACH nas;
"
# ─── BUILD EXPLICIT COLUMN LISTS ──────────────────────────────────────────
# After ensure_columns, source ⊆ NAS for every synced table, so source's
# column list is a safe subset to use on both sides of the INSERT.
# For tables that JOIN frames (ocr_text, elements), the SELECT side needs
# alias-qualified columns because both tables share names (app_name, etc).
FRAMES_COLS=$(build_col_list frames)
ELEMENTS_COLS=$(build_col_list elements)
ELEMENTS_COLS_E=$(build_col_list elements e)
UI_EVENTS_COLS=$(build_col_list ui_events)
OCR_TEXT_COLS=$(build_col_list ocr_text)
OCR_TEXT_COLS_O=$(build_col_list ocr_text o)
VIDEO_CHUNKS_COLS=$(build_col_list video_chunks)
MEETINGS_COLS=$(build_col_list meetings)
# ─── SYNC DATA ────────────────────────────────────────────────────────────
step "Syncing data for $TARGET_DATE"
run_sqlite_heredoc "video_chunks" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.video_chunks ($VIDEO_CHUNKS_COLS)
SELECT $VIDEO_CHUNKS_COLS FROM main.video_chunks
WHERE id IN (
SELECT DISTINCT video_chunk_id FROM main.frames
WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL
);
DETACH nas;
"
run_sqlite_heredoc "frames ($SRC_FRAMES rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.frames ($FRAMES_COLS)
SELECT $FRAMES_COLS FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ocr_text ($SRC_OCR rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ocr_text ($OCR_TEXT_COLS)
SELECT $OCR_TEXT_COLS_O FROM main.ocr_text o
JOIN main.frames f ON o.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ui_events ($SRC_UI rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ui_events ($UI_EVENTS_COLS)
SELECT $UI_EVENTS_COLS FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "elements ($SRC_ELEMENTS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.elements ($ELEMENTS_COLS)
SELECT $ELEMENTS_COLS_E FROM main.elements e
JOIN main.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "meetings ($SRC_MEETINGS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.meetings ($MEETINGS_COLS)
SELECT $MEETINGS_COLS FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';
DETACH nas;
"
# ─── FTS UPDATE ───────────────────────────────────────────────────────────
step "Updating FTS indexes"
run_sqlite_heredoc "elements_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.elements_fts(rowid, text, role)
SELECT e.id, e.text, e.role
FROM nas.elements e
JOIN nas.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE'
AND e.text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "frames_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)
SELECT id, full_text, app_name, window_name, browser_url, id
FROM nas.frames
WHERE date(timestamp) = '$TARGET_DATE'
AND full_text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "ui_events_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)
SELECT id, text_content, app_name, window_title, element_name
FROM nas.ui_events
WHERE date(timestamp) = '$TARGET_DATE'
AND text_content IS NOT NULL;
DETACH nas;
"
# ─── VERIFY DB ────────────────────────────────────────────────────────────
step "Verifying DB"
V_FRAMES=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
V_ELEMENTS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_UI=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
V_OCR=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_MEETINGS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';")
check "frames" "$V_FRAMES" "$SRC_FRAMES"
check "elements" "$V_ELEMENTS" "$SRC_ELEMENTS"
check "ui_events" "$V_UI" "$SRC_UI"
check "ocr_text" "$V_OCR" "$SRC_OCR"
check "meetings" "$V_MEETINGS" "$SRC_MEETINGS"
fi
# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────
# Always runs regardless of DB sync status
step "Copying data folder for $TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
mkdir -p "$NAS_DATA/$TARGET_DATE"
RSYNC_START=$(date +%s)
printf " %-36s " "rsync $TARGET_DATE/ → NAS"
rsync -a --ignore-existing \
"$DATA_SRC/" \
"$NAS_DATA/$TARGET_DATE/" \
2>>"$LOG_FILE"
RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))
COPIED_FILES=$(ls "$NAS_DATA/$TARGET_DATE" | wc -l | tr -d ' ')
SRC_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
COPIED_SIZE=$(du -sh "$NAS_DATA/$TARGET_DATE" | cut -f1)
if [ "$COPIED_FILES" -eq "$SRC_FILES" ]; then
printf "\r %-36s ✓ %dm%02ds (%s files, %s)\n" \
"rsync $TARGET_DATE/ → NAS" \
"$(( RSYNC_DUR / 60 ))" "$(( RSYNC_DUR % 60 ))" \
"$COPIED_FILES" "$COPIED_SIZE" | tee -a "$LOG_FILE"
else
printf "\r %-36s ✗ %s / %s files\n" \
"rsync $TARGET_DATE/ → NAS" "$COPIED_FILES" "$SRC_FILES" | tee -a "$LOG_FILE"
fi
else
printf " %-36s %s\n" "rsync $TARGET_DATE/ → NAS" "skipped (no source dir)"
fi
# ─── COPY LOGS ────────────────────────────────────────────────────────────────
# Screenpipe writes daily logs to ~/.screenpipe/screenpipe.YYYY-MM-DD.N.log
# (N is a rotation counter, almost always 0). Mirror them to NAS so log
# analysis can happen on the consumer side without SSH'ing back to the Mac.
step "Copying screenpipe logs for $TARGET_DATE"
NAS_LOGS="$NAS_MOUNT/logs"
mkdir -p "$NAS_LOGS"
# Use a glob with nullglob so an empty match doesn't expand to a literal pattern.
shopt -s nullglob
LOG_FILES=( "$HOME/.screenpipe/screenpipe.$TARGET_DATE."*.log )
shopt -u nullglob
if [ ${#LOG_FILES[@]} -gt 0 ]; then
printf " %-36s " "rsync logs → NAS"
# No --ignore-existing here: logs grow during the day, so we want rsync's
# default size+mtime check to refresh files that have changed.
rsync -a "${LOG_FILES[@]}" "$NAS_LOGS/" 2>>"$LOG_FILE"
COPIED=${#LOG_FILES[@]}
TOTAL_SIZE=$(du -ch "${LOG_FILES[@]}" | tail -1 | cut -f1)
printf "✓ %d file(s), %s\n" "$COPIED" "$TOTAL_SIZE" | tee -a "$LOG_FILE"
else
printf " %-36s %s\n" "rsync logs → NAS" "skipped (no matching logs)"
fi
# ─── SUMMARY ──────────────────────────────────────────────────────────────────
TOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))
DB_SIZE=$(du -sh "$NAS_DB" | cut -f1)
echo ""
log "Archive DB size: $DB_SIZE"
log "Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s"
log "Sync complete for $TARGET_DATE"
log "========================================"
# Mirror this script's own logbook to NAS so sync health can be monitored
# from the consumer side. Done last so the summary lines above are included.
rsync -a "$HOME/.screenpipe/sync.log" "$NAS_LOGS/sync.log" 2>/dev/null || true
Implement and run pipe l…, Editor Group 2
Problems (⇧⌘M)
PROBLEMS
Output (⇧⌘U)
OUTPUT
Debug Console (⇧⌘Y)
DEBUG CONSOLE
Terminal (⌃`)
TERMINAL
Ports - 1 forwarded port
PORTS
1
remote SSH: nas
SSH: nas
screenpipe (Git) - master*, Checkout Branch/Tag...
master*
screenpipe (Git) - Synchronize Changes
No Problems
0
0
Forwarded Ports: 8766
1
Notifications
Sign In
Sign In
No results found
Implement and run pipe logic
Session history
New session
Message actions
main.py
main.py
lets implement logic with pipes. how can I run it?
Thinking
Thinking
Let me look at the current project structure to understand what's already in place.
Bash
List project files
IN
find /volume1/screenpipe -type f | head -50 && echo "---" && ls /volume1/screenpipe
Copy code to clipboard
OUT
/volume1/screenpipe/.DS_Store
/volume1/screenpipe/screenpipe.db
/volume1/screenpipe/screenpipe_sync.sh
/volume1/screenpipe/app_settings.json
/volume1/screenpipe/.gitignore
/volume1/screenpipe/archive.db
/volume1/screenpipe/db.sqlite
/volume1/screenpipe/db.sqlite-wal
/volume1/screenpipe/db.sqlite-shm
/volume1/screenpipe/#recycle/desktop.ini
/volume1/screenpipe/#recycle/db.sqlite
/volume1/screenpipe/#recycle/Copy #1 of db.sqlite
/volume1/screenpipe/#recycle/.DS_Store
/volume1/screenpipe/#recycle/Copy #2 of db.sqlite
/volume1/screenpipe/#recycle/archive.db
/volume1/screenpipe/#recycle/Copy #1 of archive.db
/volume1/screenpipe/#recycle/Copy #2 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of archive.db
/volume1/screenpipe/#recycle/Copy #4 of archive.db
/volume1/screenpipe/#recycle/Copy #5 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of db.sqlite
/volume1/screenpipe/#recycle/Copy #4 of db.sqlite
/volume1/screenpipe/#recycle/Copy #6 of archive.db
/volume1/screenpipe/#recycle/test.txt
/volume1/screenpipe/#recycle/Copy #7 of archive.db
/volume1/screenpipe/#recycle/Copy #8 of archive.db
/volume1/screenpipe/#recycle/archive.db-journal
/volume1/screenpipe/#recycle/Copy #1 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #2 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #3 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #4 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #6 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #7 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of db.sqlite
/volume1/screenpipe/pipes/.DS_Store
/volume1/screenpipe/app/.env
/volume1/screenpipe/app/cli.py
/volume1/screenpipe/app/.DS_Store
/volume1/screenpipe/app/db.py
/volume1/screenpipe/app/docker-compose.yml
/volume1/screenpipe/app/main.py
/volume1/screenpipe/app/requirements.txt
/volume1/screenpipe/app/Dockerfile
/volume1/screenpipe/data/.DS_Store
/volume1/screenpipe/.git/description
/volume1/screenpipe/.git/HEAD
/volume1/screenpipe/.git/index
/volume1/screenpipe/.git/COMMIT_EDITMSG
/volume1/screenpipe/#recycle/data/.DS_Store
---
app
app_settings.json
archive.db
data
db.sqlite
db.sqlite-shm
db.sqlite-wal
pipes
#recycle
screenpipe.db
screenpipe_sync.sh
Read
main.py
main.py
Bash
Check pipes directory and docker-compose
IN
ls /volume1/screenpipe/pipes/ && ls /volume1/screenpipe/app/ && cat /volume1/screenpipe/app/docker-compose.yml
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
cli.py
consumers
db.py
docker-compose.yml
Dockerfile
main.py
__pycache__
requirements.txt
static
services:
screenpipe-app:
build: .
container_name: screenpipe-app
restart: unless-stopped
ports:
- "8766:8000"
volumes:
- /volume1/screenpipe:/data
env_file:
- .env
environment:
TZ: Europe/Sofia
DB_PATH: /data/db.sqlite
sqlite-web-archive:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-archive
restart: unless-stopped
ports:
- "8767:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/archive.db"]
sqlite-web-live:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-live
restart: unless-stopped
ports:
- "8768:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/db.sqlite"]
Read
requirements.txt
requirements.txt
Bash
Inspect a pipe directory
IN
ls /volume1/screenpipe/pipes/day-recap/ && cat /volume1/screenpipe/pipes/day-recap/pipe.json 2>/dev/null || ls /volume1/screenpipe/pipes/day-recap/
Copy code to clipboard
OUT
pipe.md
pipe.md
Read
cli.py
cli.py
Bash
List all pipes and their contents
IN
ls /volume1/screenpipe/pipes/ && for d in /volume1/screenpipe/pipes/*/; do echo "=== $d ==="; ls "$d"; done
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
=== /volume1/screenpipe/pipes/ai-habits/ ===
pipe.md
=== /volume1/screenpipe/pipes/day-recap/ ===
pipe.md
=== /volume1/screenpipe/pipes/meeting-summary/ ===
pipe.md
=== /volume1/screenpipe/pipes/standup-update/ ===
pipe.md
=== /volume1/screenpipe/pipes/time-breakdown/ ===
pipe.md
=== /volume1/screenpipe/pipes/video-export/ ===
pipe.md
Bash
Read pipe markdown files
IN
cat /volume1/screenpipe/pipes/day-recap/pipe.md && echo "===" && cat /volume1/screenpipe/pipes/meeting-summary/pipe.md 2>/dev/null | head -50
Copy code to clipboard
OUT
---
schedule: manual
enabled: true
template: true
title: Day Recap
description: "Today's accomplishments, key moments, and unfinished work"
icon: "📋"
featured: true
---
Analyze my screen and audio recordings from today (last 16 hours only).
Read screenpipe skill first.
Use this exact format:
## Summary
One sentence: what I mainly did today.
## Accomplishments
- Top 3 things I finished, with timestamps (e.g. "2:30 PM")
- Name specific apps, files, or projects
## Key Moments
- Important things I saw, said, or heard — with timestamps
## Unfinished Work
- What I should continue tomorrow — name the app/file/task
## Patterns
- Apps I used most, topics that came up repeatedly
Only rep...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
21111
|
922
|
15
|
2026-05-11T17:12:48.123172+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-11/1778 /Users/lukas/.screenpipe/data/data/2026-05-11/1778519568123_m1.jpg...
|
Code
|
Implement and run pipe l… — screenpipe [SSH: nas]
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Explorer (⇧⌘E) - 1 unsaved file
1
Search (⇧⌘F)
Explorer (⇧⌘E) - 1 unsaved file
1
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py...
|
[{"role":"AXRadioButton","text [{"role":"AXRadioButton","text":"Explorer (⇧⌘E) - 1 unsaved file","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":true},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Search (⇧⌘F)","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Source Control (⌃⇧G) - 10 pending changes","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"10","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Run and Debug (⇧⌘D)","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Remote Explorer","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Extensions (⇧⌘X) - 2 require update","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"2","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Claude Code","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"Containers","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXHeading","text":"EXPLORER","depth":17,"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"EXPLORER","depth":18,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Explorer Section: screenpipe [SSH: nas]","depth":21,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":true},{"role":"AXStaticText","text":"","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"Explorer Section: screenpipe [SSH: nas]","depth":22,"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"SCREENPIPE [SSH: NAS]","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"#recycle","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"app","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"__pycache__","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"consumers","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"static","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":".env","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"cli.py","depth":27,"on_screen":true,"role_description":"text"}]...
|
4733124253859840262
|
-7911848293267979896
|
click
|
accessibility
|
NULL
|
Explorer (⇧⌘E) - 1 unsaved file
1
Search (⇧⌘F)
Explorer (⇧⌘E) - 1 unsaved file
1
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
21112
|
923
|
17
|
2026-05-11T17:12:48.148169+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-11/1778 /Users/lukas/.screenpipe/data/data/2026-05-11/1778519568148_m2.jpg...
|
Code
|
Implement and run pipe l… — screenpipe [SSH: nas]
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Explorer (⇧⌘E) - 1 unsaved file
1
Search (⇧⌘F)
Explorer (⇧⌘E) - 1 unsaved file
1
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
...
|
[{"role":"AXRadioButton","text [{"role":"AXRadioButton","text":"Explorer (⇧⌘E) - 1 unsaved file","depth":19,"bounds":{"left":0.0,"top":0.047885075,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":true},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.057462092,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":22,"bounds":{"left":0.009640957,"top":0.06863528,"width":0.0016622341,"height":0.008778931},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Search (⇧⌘F)","depth":19,"bounds":{"left":0.0,"top":0.08619314,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.09577015,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Source Control (⌃⇧G) - 10 pending changes","depth":19,"bounds":{"left":0.0,"top":0.1245012,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.13407822,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"10","depth":22,"bounds":{"left":0.00831117,"top":0.1452514,"width":0.003656915,"height":0.008778931},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.00831117,"top":0.14604948,"width":0.0016622341,"height":0.007980846}},{"char_start":1,"char_count":1,"bounds":{"left":0.009973404,"top":0.14604948,"width":0.0023271276,"height":0.007980846}}],"role_description":"text"},{"role":"AXRadioButton","text":"Run and Debug (⇧⌘D)","depth":19,"bounds":{"left":0.0,"top":0.16280925,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.17238627,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Remote Explorer","depth":19,"bounds":{"left":0.0,"top":0.20111732,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.21069433,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Extensions (⇧⌘X) - 2 require update","depth":19,"bounds":{"left":0.0,"top":0.23942538,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.2490024,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"2","depth":22,"bounds":{"left":0.009640957,"top":0.2601756,"width":0.0019946808,"height":0.008778931},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Claude Code","depth":19,"bounds":{"left":0.0,"top":0.27773345,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"Containers","depth":19,"bounds":{"left":0.0,"top":0.3160415,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXHeading","text":"EXPLORER","depth":17,"bounds":{"left":0.022606382,"top":0.047885075,"width":0.018949468,"height":0.02793296},"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"EXPLORER","depth":18,"bounds":{"left":0.022606382,"top":0.056664005,"width":0.018949468,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.022606382,"top":0.056664005,"width":0.0023271276,"height":0.0103751}},{"char_start":1,"char_count":7,"bounds":{"left":0.024933511,"top":0.056664005,"width":0.01662234,"height":0.0103751}}],"role_description":"text"},{"role":"AXButton","text":"Explorer Section: screenpipe [SSH: nas]","depth":21,"bounds":{"left":0.015957447,"top":0.07581804,"width":0.09940159,"height":0.017557861},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":true},{"role":"AXStaticText","text":"","depth":23,"bounds":{"left":0.01662234,"top":0.07821229,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"Explorer Section: screenpipe [SSH: nas]","depth":22,"bounds":{"left":0.022606382,"top":0.07581804,"width":0.045877658,"height":0.017557861},"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"SCREENPIPE [SSH: NAS]","depth":23,"bounds":{"left":0.022606382,"top":0.079010375,"width":0.045877658,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.022606382,"top":0.07980846,"width":0.0026595744,"height":0.0103751}},{"char_start":1,"char_count":20,"bounds":{"left":0.025265958,"top":0.07980846,"width":0.043218084,"height":0.0103751}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.09577015,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"#recycle","depth":27,"bounds":{"left":0.025930852,"top":0.09577015,"width":0.017287234,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.096568234,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":7,"bounds":{"left":0.028590426,"top":0.096568234,"width":0.01462766,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.11332801,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"app","depth":27,"bounds":{"left":0.025930852,"top":0.11332801,"width":0.0076462766,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.11412609,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":2,"bounds":{"left":0.02825798,"top":0.11412609,"width":0.005319149,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.11412609,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.022273935,"top":0.13088587,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"__pycache__","depth":27,"bounds":{"left":0.028590426,"top":0.13088587,"width":0.026595745,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.13168396,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":10,"bounds":{"left":0.030917553,"top":0.13168396,"width":0.024268618,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.022273935,"top":0.14844373,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"consumers","depth":27,"bounds":{"left":0.028590426,"top":0.14844373,"width":0.022273935,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.14924182,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":8,"bounds":{"left":0.030917553,"top":0.14924182,"width":0.019946808,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.14924182,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.022273935,"top":0.1660016,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"static","depth":27,"bounds":{"left":0.028590426,"top":0.1660016,"width":0.010970744,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.16679968,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":5,"bounds":{"left":0.030917553,"top":0.16679968,"width":0.008976064,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.16679968,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"}]...
|
3492036130800030036
|
-7911883477623815796
|
click
|
accessibility
|
NULL
|
Explorer (⇧⌘E) - 1 unsaved file
1
Search (⇧⌘F)
Explorer (⇧⌘E) - 1 unsaved file
1
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
...
|
21110
|
NULL
|
NULL
|
NULL
|
|
21113
|
922
|
16
|
2026-05-11T17:12:49.416430+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-11/1778 /Users/lukas/.screenpipe/data/data/2026-05-11/1778519569416_m1.jpg...
|
Code
|
screenpipe_sync_updated.sh — screenpipe [SSH: nas] screenpipe_sync_updated.sh — screenpipe [SSH: nas] — Untracked...
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Explorer (⇧⌘E) - 1 unsaved file
1
Search (⇧⌘F)
Explorer (⇧⌘E) - 1 unsaved file
1
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py
M
db.py
docker-compose.yml
Dockerfile
M
main.py
M
requirements.txt
M
data
logs
pipes
.gitignore
app_settings.json
archive.db
archive.db-bak
U
db.sqlite
db.sqlite-shm
db.sqlite-wal
screenpipe_sync_updated.sh
U
screenpipe_sync.sh
screenpipe.db
Outline Section
OUTLINE
OUTLINE
Timeline Section
TIMELINE
TIMELINE
app_settings.json, Editor Group 1...
|
[{"role":"AXRadioButton","text [{"role":"AXRadioButton","text":"Explorer (⇧⌘E) - 1 unsaved file","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":true},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Search (⇧⌘F)","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Source Control (⌃⇧G) - 10 pending changes","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"10","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Run and Debug (⇧⌘D)","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Remote Explorer","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Extensions (⇧⌘X) - 2 require update","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"2","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Claude Code","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"Containers","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXHeading","text":"EXPLORER","depth":17,"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"EXPLORER","depth":18,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Explorer Section: screenpipe [SSH: nas]","depth":21,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":true},{"role":"AXStaticText","text":"","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"Explorer Section: screenpipe [SSH: nas]","depth":22,"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"SCREENPIPE [SSH: NAS]","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"#recycle","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"app","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"__pycache__","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"consumers","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"static","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":".env","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"cli.py","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.py","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"docker-compose.yml","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Dockerfile","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"main.py","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"requirements.txt","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"data","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"logs","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"pipes","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":".gitignore","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"app_settings.json","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"archive.db","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"archive.db-bak","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"U","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite-shm","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite-wal","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe_sync_updated.sh","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"U","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe_sync.sh","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe.db","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Outline Section","depth":21,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"OUTLINE","depth":22,"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"OUTLINE","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Timeline Section","depth":21,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"TIMELINE","depth":22,"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"TIMELINE","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"app_settings.json, Editor Group 1","depth":28,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
-707291648904908469
|
-5516287334125235328
|
click
|
accessibility
|
NULL
|
Explorer (⇧⌘E) - 1 unsaved file
1
Search (⇧⌘F)
Explorer (⇧⌘E) - 1 unsaved file
1
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py
M
db.py
docker-compose.yml
Dockerfile
M
main.py
M
requirements.txt
M
data
logs
pipes
.gitignore
app_settings.json
archive.db
archive.db-bak
U
db.sqlite
db.sqlite-shm
db.sqlite-wal
screenpipe_sync_updated.sh
U
screenpipe_sync.sh
screenpipe.db
Outline Section
OUTLINE
OUTLINE
Timeline Section
TIMELINE
TIMELINE
app_settings.json, Editor Group 1...
|
21111
|
NULL
|
NULL
|
NULL
|
|
21114
|
923
|
18
|
2026-05-11T17:12:49.393476+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-11/1778 /Users/lukas/.screenpipe/data/data/2026-05-11/1778519569393_m2.jpg...
|
Code
|
screenpipe_sync_updated.sh — screenpipe [SSH: nas] screenpipe_sync_updated.sh — screenpipe [SSH: nas] — Untracked...
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Explorer (⇧⌘E) - 1 unsaved file
1
Search (⇧⌘F)
Explorer (⇧⌘E) - 1 unsaved file
1
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py
M
db.py
docker-compose.yml
Dockerfile
M
main.py
M
requirements.txt
M
data
logs
pipes
.gitignore
app_settings.json
archive.db
archive.db-bak
U
db.sqlite
db.sqlite-shm
db.sqlite-wal
screenpipe_sync_updated.sh
U
screenpipe_sync.sh
...
|
[{"role":"AXRadioButton","text [{"role":"AXRadioButton","text":"Explorer (⇧⌘E) - 1 unsaved file","depth":19,"bounds":{"left":0.0,"top":0.047885075,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":true},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.057462092,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":22,"bounds":{"left":0.009640957,"top":0.06863528,"width":0.0016622341,"height":0.008778931},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Search (⇧⌘F)","depth":19,"bounds":{"left":0.0,"top":0.08619314,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.09577015,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Source Control (⌃⇧G) - 10 pending changes","depth":19,"bounds":{"left":0.0,"top":0.1245012,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.13407822,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"10","depth":22,"bounds":{"left":0.00831117,"top":0.1452514,"width":0.003656915,"height":0.008778931},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.00831117,"top":0.14604948,"width":0.0016622341,"height":0.007980846}},{"char_start":1,"char_count":1,"bounds":{"left":0.009973404,"top":0.14604948,"width":0.0023271276,"height":0.007980846}}],"role_description":"text"},{"role":"AXRadioButton","text":"Run and Debug (⇧⌘D)","depth":19,"bounds":{"left":0.0,"top":0.16280925,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.17238627,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Remote Explorer","depth":19,"bounds":{"left":0.0,"top":0.20111732,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.21069433,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Extensions (⇧⌘X) - 2 require update","depth":19,"bounds":{"left":0.0,"top":0.23942538,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.2490024,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"2","depth":22,"bounds":{"left":0.009640957,"top":0.2601756,"width":0.0019946808,"height":0.008778931},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Claude Code","depth":19,"bounds":{"left":0.0,"top":0.27773345,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"Containers","depth":19,"bounds":{"left":0.0,"top":0.3160415,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXHeading","text":"EXPLORER","depth":17,"bounds":{"left":0.022606382,"top":0.047885075,"width":0.018949468,"height":0.02793296},"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"EXPLORER","depth":18,"bounds":{"left":0.022606382,"top":0.056664005,"width":0.018949468,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.022606382,"top":0.056664005,"width":0.0023271276,"height":0.0103751}},{"char_start":1,"char_count":7,"bounds":{"left":0.024933511,"top":0.056664005,"width":0.01662234,"height":0.0103751}}],"role_description":"text"},{"role":"AXButton","text":"Explorer Section: screenpipe [SSH: nas]","depth":21,"bounds":{"left":0.015957447,"top":0.07581804,"width":0.09940159,"height":0.017557861},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":true},{"role":"AXStaticText","text":"","depth":23,"bounds":{"left":0.01662234,"top":0.07821229,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"Explorer Section: screenpipe [SSH: nas]","depth":22,"bounds":{"left":0.022606382,"top":0.07581804,"width":0.045877658,"height":0.017557861},"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"SCREENPIPE [SSH: NAS]","depth":23,"bounds":{"left":0.022606382,"top":0.079010375,"width":0.045877658,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.022606382,"top":0.07980846,"width":0.0026595744,"height":0.0103751}},{"char_start":1,"char_count":20,"bounds":{"left":0.025265958,"top":0.07980846,"width":0.043218084,"height":0.0103751}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.09577015,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"#recycle","depth":27,"bounds":{"left":0.025930852,"top":0.09577015,"width":0.017287234,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.096568234,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":7,"bounds":{"left":0.028590426,"top":0.096568234,"width":0.01462766,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.11332801,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"app","depth":27,"bounds":{"left":0.025930852,"top":0.11332801,"width":0.0076462766,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.11412609,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":2,"bounds":{"left":0.02825798,"top":0.11412609,"width":0.005319149,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.11412609,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.022273935,"top":0.13088587,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"__pycache__","depth":27,"bounds":{"left":0.028590426,"top":0.13088587,"width":0.026595745,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.13168396,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":10,"bounds":{"left":0.030917553,"top":0.13168396,"width":0.024268618,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.022273935,"top":0.14844373,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"consumers","depth":27,"bounds":{"left":0.028590426,"top":0.14844373,"width":0.022273935,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.14924182,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":8,"bounds":{"left":0.030917553,"top":0.14924182,"width":0.019946808,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.14924182,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.022273935,"top":0.1660016,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"static","depth":27,"bounds":{"left":0.028590426,"top":0.1660016,"width":0.010970744,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.16679968,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":5,"bounds":{"left":0.030917553,"top":0.16679968,"width":0.008976064,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.16679968,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.1819633,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":".env","depth":27,"bounds":{"left":0.028590426,"top":0.18355946,"width":0.00831117,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.18435754,"width":0.0013297872,"height":0.011971269}},{"char_start":1,"char_count":3,"bounds":{"left":0.029920213,"top":0.18435754,"width":0.006981383,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.19952115,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"cli.py","depth":27,"bounds":{"left":0.028590426,"top":0.20111732,"width":0.010638298,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.2019154,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":5,"bounds":{"left":0.030917553,"top":0.2019154,"width":0.00831117,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.2019154,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.21707901,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.py","depth":27,"bounds":{"left":0.028590426,"top":0.21867518,"width":0.011303191,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.21947326,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":4,"bounds":{"left":0.03125,"top":0.21947326,"width":0.008643617,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.23463687,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"docker-compose.yml","depth":27,"bounds":{"left":0.028590426,"top":0.23623304,"width":0.042220745,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.23703113,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":17,"bounds":{"left":0.03125,"top":0.23703113,"width":0.03956117,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.25219473,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Dockerfile","depth":27,"bounds":{"left":0.028590426,"top":0.25379092,"width":0.020611702,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.254589,"width":0.0033244682,"height":0.011971269}},{"char_start":1,"char_count":9,"bounds":{"left":0.031914894,"top":0.254589,"width":0.017287234,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.254589,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.2697526,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"main.py","depth":27,"bounds":{"left":0.028590426,"top":0.27134877,"width":0.015625,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.27214685,"width":0.003656915,"height":0.011971269}},{"char_start":1,"char_count":6,"bounds":{"left":0.032247342,"top":0.27214685,"width":0.012300532,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.27214685,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.28731045,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"requirements.txt","depth":27,"bounds":{"left":0.028590426,"top":0.28890663,"width":0.032912236,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.2897047,"width":0.0016622341,"height":0.011971269}},{"char_start":1,"char_count":15,"bounds":{"left":0.03025266,"top":0.2897047,"width":0.03158245,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.2897047,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.3064645,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"data","depth":27,"bounds":{"left":0.025930852,"top":0.3064645,"width":0.008976064,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.30726257,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":3,"bounds":{"left":0.028590426,"top":0.30726257,"width":0.0063164895,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.32402235,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"logs","depth":27,"bounds":{"left":0.025930852,"top":0.32402235,"width":0.00831117,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.32482043,"width":0.0009973404,"height":0.011971269}},{"char_start":1,"char_count":3,"bounds":{"left":0.026928192,"top":0.32482043,"width":0.0076462766,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.32482043,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.3415802,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"pipes","depth":27,"bounds":{"left":0.025930852,"top":0.3415802,"width":0.010970744,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.3423783,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":4,"bounds":{"left":0.028590426,"top":0.3423783,"width":0.00831117,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.3575419,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":".gitignore","depth":27,"bounds":{"left":0.025930852,"top":0.35913807,"width":0.018949468,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.35993615,"width":0.0013297872,"height":0.011971269}},{"char_start":1,"char_count":9,"bounds":{"left":0.027260639,"top":0.35993615,"width":0.017952127,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.37509975,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"app_settings.json","depth":27,"bounds":{"left":0.025930852,"top":0.37669593,"width":0.03557181,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.377494,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":16,"bounds":{"left":0.02825798,"top":0.377494,"width":0.03324468,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.3926576,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"archive.db","depth":27,"bounds":{"left":0.025930852,"top":0.3942538,"width":0.020944148,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.39505187,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":9,"bounds":{"left":0.02825798,"top":0.39505187,"width":0.01861702,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.4102155,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"archive.db-bak","depth":27,"bounds":{"left":0.025930852,"top":0.41181165,"width":0.03025266,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.41260973,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":13,"bounds":{"left":0.02825798,"top":0.41260973,"width":0.027925532,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"U","depth":27,"bounds":{"left":0.10704787,"top":0.41260973,"width":0.0029920214,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.42777336,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite","depth":27,"bounds":{"left":0.025930852,"top":0.4293695,"width":0.017287234,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.4301676,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":8,"bounds":{"left":0.028590426,"top":0.4301676,"width":0.014960106,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.44533122,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite-shm","depth":27,"bounds":{"left":0.025930852,"top":0.44692737,"width":0.027925532,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.44772545,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":12,"bounds":{"left":0.028590426,"top":0.44772545,"width":0.025265958,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.46288908,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite-wal","depth":27,"bounds":{"left":0.025930852,"top":0.46448523,"width":0.025930852,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.46528333,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":12,"bounds":{"left":0.028590426,"top":0.46528333,"width":0.023603724,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.48044693,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe_sync_updated.sh","depth":27,"bounds":{"left":0.025930852,"top":0.4820431,"width":0.059175532,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.4828412,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":25,"bounds":{"left":0.02825798,"top":0.4828412,"width":0.056848403,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"U","depth":27,"bounds":{"left":0.10704787,"top":0.4828412,"width":0.0029920214,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.4980048,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe_sync.sh","depth":27,"bounds":{"left":0.025930852,"top":0.49960095,"width":0.039893616,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.50039905,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":17,"bounds":{"left":0.02825798,"top":0.50039905,"width":0.037898935,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.51556265,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"}]...
|
-7952977788939551774
|
-5570334928362892928
|
click
|
accessibility
|
NULL
|
Explorer (⇧⌘E) - 1 unsaved file
1
Search (⇧⌘F)
Explorer (⇧⌘E) - 1 unsaved file
1
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py
M
db.py
docker-compose.yml
Dockerfile
M
main.py
M
requirements.txt
M
data
logs
pipes
.gitignore
app_settings.json
archive.db
archive.db-bak
U
db.sqlite
db.sqlite-shm
db.sqlite-wal
screenpipe_sync_updated.sh
U
screenpipe_sync.sh
...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
21115
|
922
|
17
|
2026-05-11T17:12:57.596842+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-11/1778 /Users/lukas/.screenpipe/data/data/2026-05-11/1778519577596_m1.jpg...
|
Code
|
screenpipe_sync_updated.sh — screenpipe [SSH: nas] screenpipe_sync_updated.sh — screenpipe [SSH: nas] — Untracked...
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Explorer (⇧⌘E) - 1 unsaved file
1
Search (⇧⌘F)
Explorer (⇧⌘E) - 1 unsaved file
1
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py
M
db.py
docker-compose.yml
Dockerfile
M
main.py
M
requirements.txt
M
data
logs
pipes
.gitignore
app_settings.json
archive.db
archive.db-bak
U
db.sqlite
db.sqlite-shm
db.sqlite-wal
screenpipe_sync_updated.sh
U
screenpipe_sync.sh
screenpipe.db
Outline Section
OUTLINE
OUTLINE
Timeline Section
TIMELINE
TIMELINE
app_settings.json, Editor Group 1
screenpipe_sync.sh, Editor Group 1
screenpipe_sync_updated.sh, preview, Editor Group 1
pipe.md, Editor Group 1
.env, Editor Group 1
#!/bin/bash
# screenpipe_sync.sh
# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).
# Also copies the day's video/frame data folder to the NAS.
#
# Schema-drift tolerant: if Screenpipe migrations add new columns to the source DB,
# the NAS archive gets ALTER TABLE'd to match. Inserts use explicit column lists,
# so positional mismatches can't occur.
#
# Usage:
# ./screenpipe_sync.sh # syncs yesterday (default)
# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date
# ./screenpipe_sync.sh today # syncs today so far
#
# Cron example (runs at 3am daily):
# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1
set -euo pipefail
# ─── CONFIG ───────────────────────────────────────────────────────────────────
DB_SRC="${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}"
NAS_MOUNT="${NAS_MOUNT:-/Volumes/screenpipe}"
NAS_DB="$NAS_MOUNT/archive.db"
NAS_DATA="$NAS_MOUNT/data"
LOG_FILE="$HOME/.screenpipe/sync.log"
# Tables that get schema drift handling. Order matters for FK-ish references
# (parents before children: video_chunks → frames → elements/ocr_text/ui_events).
SYNC_TABLES=(video_chunks frames elements ocr_text ui_events meetings)
# ──────────────────────────────────────────────────────────────────────────────
# ─── HELPERS ──────────────────────────────────────────────────────────────────
SCRIPT_START=$(date +%s)
log() {
local msg="[$(date '+%Y-%m-%d %H:%M:%S')] $*"
echo "$msg" | tee -a "$LOG_FILE"
}
step() {
local now=$(date +%s)
local elapsed=$(( now - SCRIPT_START ))
local min=$(( elapsed / 60 ))
local sec=$(( elapsed % 60 ))
printf "\n[+%02dm%02ds] ▶ %s\n" "$min" "$sec" "$*" | tee -a "$LOG_FILE"
}
run_sqlite_heredoc() {
local label="$1"
local sql="$2"
local start=$(date +%s)
printf " %-36s " "$label"
sqlite3 "$DB_SRC" <<< "$sql" &
local pid=$!
local spin=[PASSWORD] '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')
local i=0
while kill -0 "$pid" 2>/dev/null; do
printf "\r %-36s %s " "$label" "${spin[$i]}"
i=$(( (i + 1) % 10 ))
sleep 0.2
done
wait "$pid"
local rc=$?
if [ $rc -ne 0 ]; then
printf "\r %-36s ✗ FAILED\n" "$label" | tee -a "$LOG_FILE"
exit $rc
fi
local dur=$(( $(date +%s) - start ))
printf "\r %-36s ✓ %dm%02ds\n" "$label" "$(( dur / 60 ))" "$(( dur % 60 ))" | tee -a "$LOG_FILE"
}
check() {
local label="$1" got="$2" expected="$3"
if [ "$got" -eq "$expected" ]; then
printf " %-20s %s / %s ✓\n" "$label:" "$got" "$expected"
else
printf " %-20s %s / %s ✗ MISMATCH\n" "$label:" "$got" "$expected"
fi
}
# ─── SCHEMA HELPERS ───────────────────────────────────────────────────────────
# Echoes "name|type" lines for a table from a given DB.
table_columns_with_types() {
local db="$1" table="$2"
sqlite3 "$db" "PRAGMA table_info($table);" | awk -F'|' '{print $2 "|" $3}'
}
# Echoes just column names, one per line.
table_columns() {
local db="$1" table="$2"
sqlite3 "$db" "PRAGMA table_info($table);" | awk -F'|' '{print $2}'
}
# Returns true (0) if a table exists in the given DB.
table_exists() {
local db="$1" table="$2"
local count
count=$(sqlite3 "$db" "SELECT COUNT(*) FROM sqlite_master WHERE type='table' AND name='$table';")
[ "$count" -gt 0 ]
}
# Adds any columns present in source but missing in NAS for the given table.
# Uses ALTER TABLE ADD COLUMN, which is a fast metadata-only operation in SQLite.
ensure_columns() {
local table="$1"
local label="schema: $table"
printf " %-36s " "$label"
if ! table_exists "$DB_SRC" "$table"; then
printf "✗ source missing — skipping\n"
return 0
fi
if ! table_exists "$NAS_DB" "$table"; then
printf "✓ fresh (created above)\n"
return 0
fi
local src_cols
src_cols=$(table_columns_with_types "$DB_SRC" "$table")
local nas_cols
nas_cols=$(table_columns "$NAS_DB" "$table")
local added=0
local added_names=""
while IFS='|' read -r name type; do
[ -z "$name" ] && continue
# Use grep -F -x for fixed-string exact match (safe against regex chars).
if ! echo "$nas_cols" | grep -Fxq "$name"; then
# SQLite ALTER TABLE ADD COLUMN: type is optional, no NOT NULL allowed
# without a constant default. Default-NULL is exactly what we want for archive.
sqlite3 "$NAS_DB" "ALTER TABLE $table ADD COLUMN \"$name\" $type;"
added=$((added + 1))
added_names="$added_names $name"
fi
done <<< "$src_cols"
if [ "$added" -gt 0 ]; then
printf "✓ added %d:%s\n" "$added" "$added_names"
else
printf "✓ in sync\n"
fi
}
# Echoes a comma-separated list of source columns for a table, double-quoted
# so reserved words and hyphens are safe. Used for both INSERT and SELECT sides.
build_col_list() {
local table="$1"
table_columns "$DB_SRC" "$table" | awk 'NF' | sed 's/.*/"&"/' | paste -sd, -
}
# ──────────────────────────────────────────────────────────────────────────────
# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────
if [ "${1:-}" = "today" ]; then
TARGET_DATE=$(date +%Y-%m-%d)
elif [ -n "${1:-}" ]; then
TARGET_DATE="$1"
if ! [[ "$TARGET_DATE" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then
echo "ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday."
exit 1
fi
else
TARGET_DATE=$(date -v-1d +%Y-%m-%d)
fi
log "========================================"
log "Screenpipe sync starting for: $TARGET_DATE"
log "========================================"
# ─── PREFLIGHT ────────────────────────────────────────────────────────────────
step "Preflight checks"
if [ ! -f "$DB_SRC" ]; then
log "ERROR: Source DB not found at $DB_SRC"; exit 1
fi
printf " %-20s %s (%s)\n" "Source DB:" "OK" "$(du -sh "$DB_SRC" | cut -f1)"
if [ ! -d "$NAS_MOUNT" ]; then
log "ERROR: NAS not mounted at $NAS_MOUNT"; exit 1
fi
printf " %-20s %s\n" "NAS mount:" "OK $NAS_MOUNT"
# Check if DB already synced for this date
DB_ALREADY_SYNCED=false
if [ -f "$NAS_DB" ]; then
if table_exists "$NAS_DB" "frames"; then
EXISTING=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';" 2>/dev/null || echo "0")
if [ "$EXISTING" -gt "0" ]; then
log "Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync"
DB_ALREADY_SYNCED=true
else
printf " %-20s %s (%s)\n" "Archive DB:" "exists" "$(du -sh "$NAS_DB" | cut -f1)"
fi
else
printf " %-20s %s\n" "Archive DB:" "exists, no frames table yet"
fi
else
printf " %-20s %s\n" "Archive DB:" "will be created"
fi
# Source data dir for this date
DATA_SRC="$HOME/.screenpipe/data/data/$TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
DATA_SIZE=$(du -sh "$DATA_SRC" | cut -f1)
DATA_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
printf " %-20s %s (%s files, %s)\n" "Data dir:" "OK" "$DATA_FILES" "$DATA_SIZE"
else
printf " %-20s %s\n" "Data dir:" "not found — skipping file copy"
fi
# ─── DB SYNC ──────────────────────────────────────────────────────────────────
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────
step "Counting source rows for $TARGET_DATE"
SRC_FRAMES=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
SRC_ELEMENTS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_UI=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
SRC_OCR=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_MEETINGS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';")
printf " %-20s %s\n" "frames:" "$SRC_FRAMES"
printf " %-20s %s\n" "elements:" "$SRC_ELEMENTS"
printf " %-20s %s\n" "ui_events:" "$SRC_UI"
printf " %-20s %s\n" "ocr_text:" "$SRC_OCR"
printf " %-20s %s\n" "meetings:" "$SRC_MEETINGS"
if [ "$SRC_FRAMES" -eq "0" ]; then
log "No frames found for $TARGET_DATE — skipping DB sync"
DB_ALREADY_SYNCED=true
fi
fi
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── INIT TABLES ──────────────────────────────────────────────────────────
step "Initialising tables (CREATE IF NOT EXISTS)"
run_sqlite_heredoc "creating tables" "
ATTACH '$NAS_DB' AS nas;
CREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;
CREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;
CREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;
CREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;
DETACH nas;
"
# ─── SCHEMA DRIFT FIX ─────────────────────────────────────────────────────
# Runs AFTER CREATE IF NOT EXISTS so newly-created tables are no-ops here,
# and pre-existing tables get any missing columns added.
step "Reconciling NAS schema with source"
for tbl in "${SYNC_TABLES[@]}"; do
ensure_columns "$tbl"
done
run_sqlite_heredoc "creating indexes" "
ATTACH '$NAS_DB' AS nas;
CREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);
CREATE INDEX IF NOT EXISTS nas.idx_frames_document_path ON frames(document_path) WHERE document_path IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_elements_onscreen_frame ON elements(frame_id) WHERE on_screen = 1 AND text IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);
CREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);
DETACH nas;
"
run_sqlite_heredoc "creating FTS tables" "
ATTACH '$NAS_DB' AS nas;
CREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(
text, role, frame_id UNINDEXED,
content='elements', content_rowid='id', tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(
full_text, app_name, window_name, browser_url, id UNINDEXED,
tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(
text_content,
app_name,
window_title,
element_name,
content='ui_events',
content_rowid='id',
tokenize='unicode61'
);
DETACH nas;
"
# ─── BUILD EXPLICIT COLUMN LISTS ──────────────────────────────────────────
# After ensure_columns, source ⊆ NAS for every synced table, so source's
# column list is a safe subset to use on both sides of the INSERT.
FRAMES_COLS=$(build_col_list frames)
ELEMENTS_COLS=$(build_col_list elements)
UI_EVENTS_COLS=$(build_col_list ui_events)
OCR_TEXT_COLS=$(build_col_list ocr_text)
VIDEO_CHUNKS_COLS=$(build_col_list video_chunks)
MEETINGS_COLS=$(build_col_list meetings)
# ─── SYNC DATA ────────────────────────────────────────────────────────────
step "Syncing data for $TARGET_DATE"
run_sqlite_heredoc "video_chunks" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.video_chunks ($VIDEO_CHUNKS_COLS)
SELECT $VIDEO_CHUNKS_COLS FROM main.video_chunks
WHERE id IN (
SELECT DISTINCT video_chunk_id FROM main.frames
WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL
);
DETACH nas;
"
run_sqlite_heredoc "frames ($SRC_FRAMES rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.frames ($FRAMES_COLS)
SELECT $FRAMES_COLS FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ocr_text ($SRC_OCR rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ocr_text ($OCR_TEXT_COLS)
SELECT $OCR_TEXT_COLS FROM main.ocr_text o
JOIN main.frames f ON o.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ui_events ($SRC_UI rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ui_events ($UI_EVENTS_COLS)
SELECT $UI_EVENTS_COLS FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "elements ($SRC_ELEMENTS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.elements ($ELEMENTS_COLS)
SELECT $ELEMENTS_COLS FROM main.elements e
JOIN main.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "meetings ($SRC_MEETINGS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.meetings ($MEETINGS_COLS)
SELECT $MEETINGS_COLS FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';
DETACH nas;
"
# NOTE: the elements/ocr_text inserts use unqualified column names while
# selecting from a JOIN. SQLite resolves them against the leftmost table
# that has the column, which is what we want here (e.* / o.* implicitly),
# because none of the column names collide with frames'.
# ─── FTS UPDATE ───────────────────────────────────────────────────────────
step "Updating FTS indexes"
run_sqlite_heredoc "elements_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.elements_fts(rowid, text, role)
SELECT e.id, e.text, e.role
FROM nas.elements e
JOIN nas.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE'
AND e.text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "frames_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)
SELECT id, full_text, app_name, window_name, browser_url, id
FROM nas.frames
WHERE date(timestamp) = '$TARGET_DATE'
AND full_text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "ui_events_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)
SELECT id, text_content, app_name, window_title, element_name
FROM nas.ui_events
WHERE date(timestamp) = '$TARGET_DATE'
AND text_content IS NOT NULL;
DETACH nas;
"
# ─── VERIFY DB ────────────────────────────────────────────────────────────
step "Verifying DB"
V_FRAMES=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
V_ELEMENTS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_UI=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
V_OCR=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_MEETINGS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';")
check "frames" "$V_FRAMES" "$SRC_FRAMES"
check "elements" "$V_ELEMENTS" "$SRC_ELEMENTS"
check "ui_events" "$V_UI" "$SRC_UI"
check "ocr_text" "$V_OCR" "$SRC_OCR"
check "meetings" "$V_MEETINGS" "$SRC_MEETINGS"
fi
# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────
# Always runs regardless of DB sync status
step "Copying data folder for $TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
mkdir -p "$NAS_DATA/$TARGET_DATE"
RSYNC_START=$(date +%s)
printf " %-36s " "rsync $TARGET_DATE/ → NAS"
rsync -a --ignore-existing \
"$DATA_SRC/" \
"$NAS_DATA/$TARGET_DATE/" \
2>>"$LOG_FILE"
RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))
COPIED_FILES=$(ls "$NAS_DATA/$TARGET_DATE" | wc -l | tr -d ' ')
SRC_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
COPIED_SIZE=$(du -sh "$NAS_DATA/$TARGET_DATE" | cut -f1)
if [ "$COPIED_FILES" -eq "$SRC_FILES" ]; then
printf "\r %-36s ✓ %dm%02ds (%s files, %s)\n" \
"rsync $TARGET_DATE/ → NAS" \
"$(( RSYNC_DUR / 60 ))" "$(( RSYNC_DUR % 60 ))" \
"$COPIED_FILES" "$COPIED_SIZE" | tee -a "$LOG_FILE"
else
printf "\r %-36s ✗ %s / %s files\n" \
"rsync $TARGET_DATE/ → NAS" "$COPIED_FILES" "$SRC_FILES" | tee -a "$LOG_FILE"
fi
else
printf " %-36s %s\n" "rsync $TARGET_DATE/ → NAS" "skipped (no source dir)"
fi
# ─── SUMMARY ──────────────────────────────────────────────────────────────────
TOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))
DB_SIZE=$(du -sh "$NAS_DB" | cut -f1)
echo ""
log "Archive DB size: $DB_SIZE"
log "Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s"
log "Sync complete for $TARGET_DATE"
log "========================================"
#!/bin/bash
# screenpipe_sync.sh
# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).
# Also copies the day's video/frame data folder to the NAS.
#
# Schema-drift tolerant: if Screenpipe migrations add new columns to the source DB,
# the NAS archive gets ALTER TABLE'd to match. Inserts use explicit column lists,
# so positional mismatches can't occur.
#
# Usage:
# ./screenpipe_sync.sh # syncs yesterday (default)
# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date
# ./screenpipe_sync.sh today # syncs today so far
#
# Cron example (runs at 3am daily):
# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1
set -euo pipefail
# ─── CONFIG ───────────────────────────────────────────────────────────────────
DB_SRC="${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}"
NAS_MOUNT="${NAS_MOUNT:-/Volumes/screenpipe}"
NAS_DB="$NAS_MOUNT/archive.db"
NAS_DATA="$NAS_MOUNT/data"
LOG_FILE="$HOME/.screenpipe/sync.log"
# Tables that get schema drift handling. Order matters for FK-ish references
# (parents before children: video_chunks → frames → elements/ocr_text/ui_events).
SYNC_TABLES=(video_chunks frames elements ocr_text ui_events meetings)
# ──────────────────────────────────────────────────────────────────────────────
# ─── HELPERS ──────────────────────────────────────────────────────────────────
SCRIPT_START=$(date +%s)
log() {
local msg="[$(date '+%Y-%m-%d %H:%M:%S')] $*"
echo "$msg" | tee -a "$LOG_FILE"
}
step() {
local now=$(date +%s)
local elapsed=$(( now - SCRIPT_START ))
local min=$(( elapsed / 60 ))
local sec=$(( elapsed % 60 ))
printf "\n[+%02dm%02ds] ▶ %s\n" "$min" "$sec" "$*" | tee -a "$LOG_FILE"
}
run_sqlite_heredoc() {
local label="$1"
local sql="$2"
local start=$(date +%s)
printf " %-36s " "$label"
sqlite3 "$DB_SRC" <<< "$sql" &
local pid=$!
local spin=[PASSWORD] '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')
local i=0
while kill -0 "$pid" 2>/dev/null; do
printf "\r %-36s %s " "$label" "${spin[$i]}"
i=$(( (i + 1) % 10 ))
sleep 0.2
done
wait "$pid"
local rc=$?
if [ $rc -ne 0 ]; then
printf "\r %-36s ✗ FAILED\n" "$label" | tee -a "$LOG_FILE"
exit $rc
fi
local dur=$(( $(date +%s) - start ))
printf "\r %-36s ✓ %dm%02ds\n" "$label" "$(( dur / 60 ))" "$(( dur % 60 ))" | tee -a "$LOG_FILE"
}
check() {
local label="$1" got="$2" expected="$3"
if [ "$got" -eq "$expected" ]; then
printf " %-20s %s / %s ✓\n" "$label:" "$got" "$expected"
else
printf " %-20s %s / %s ✗ MISMATCH\n" "$label:" "$got" "$expected"
fi
}
# ─── SCHEMA HELPERS ───────────────────────────────────────────────────────────
# Echoes "name|type" lines for a table from a given DB.
table_columns_with_types() {
local db="$1" table="$2"
sqlite3 "$db" "PRAGMA table_info($table);" | awk -F'|' '{print $2 "|" $3}'
}
# Echoes just column names, one per line.
table_columns() {
local db="$1" table="$2"
sqlite3 "$db" "PRAGMA table_info($table);" | awk -F'|' '{print $2}'
}
# Returns true (0) if a table exists in the given DB.
table_exists() {
local db="$1" table="$2"
local count
count=$(sqlite3 "$db" "SELECT COUNT(*) FROM sqlite_master WHERE type='table' AND name='$table';")
[ "$count" -gt 0 ]
}
# Adds any columns present in source but missing in NAS for the given table.
# Uses ALTER TABLE ADD COLUMN, which is a fast metadata-only operation in SQLite.
ensure_columns() {
local table="$1"
local label="schema: $table"
printf " %-36s " "$label"
if ! table_exists "$DB_SRC" "$table"; then
printf "✗ source missing — skipping\n"
return 0
fi
if ! table_exists "$NAS_DB" "$table"; then
printf "✓ fresh (created above)\n"
return 0
fi
local src_cols
src_cols=$(table_columns_with_types "$DB_SRC" "$table")
local nas_cols
nas_cols=$(table_columns "$NAS_DB" "$table")
local added=0
local added_names=""
while IFS='|' read -r name type; do
[ -z "$name" ] && continue
# Use grep -F -x for fixed-string exact match (safe against regex chars).
if ! echo "$nas_cols" | grep -Fxq "$name"; then
# SQLite ALTER TABLE ADD COLUMN: type is optional, no NOT NULL allowed
# without a constant default. Default-NULL is exactly what we want for archive.
sqlite3 "$NAS_DB" "ALTER TABLE $table ADD COLUMN \"$name\" $type;"
added=$((added + 1))
added_names="$added_names $name"
fi
done <<< "$src_cols"
if [ "$added" -gt 0 ]; then
printf "✓ added %d:%s\n" "$added" "$added_names"
else
printf "✓ in sync\n"
fi
}
# Echoes a comma-separated list of source columns for a table, double-quoted
# so reserved words and hyphens are safe. Used for both INSERT and SELECT sides.
build_col_list() {
local table="$1"
table_columns "$DB_SRC" "$table" | awk 'NF' | sed 's/.*/"&"/' | paste -sd, -
}
# ──────────────────────────────────────────────────────────────────────────────
# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────
if [ "${1:-}" = "today" ]; then
TARGET_DATE=$(date +%Y-%m-%d)
elif [ -n "${1:-}" ]; then
TARGET_DATE="$1"
if ! [[ "$TARGET_DATE" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then
echo "ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday."
exit 1
fi
else
TARGET_DATE=$(date -v-1d +%Y-%m-%d)
fi
log "========================================"
log "Screenpipe sync starting for: $TARGET_DATE"
log "========================================"
# ─── PREFLIGHT ────────────────────────────────────────────────────────────────
step "Preflight checks"
if [ ! -f "$DB_SRC" ]; then
log "ERROR: Source DB not found at $DB_SRC"; exit 1
fi
printf " %-20s %s (%s)\n" "Source DB:" "OK" "$(du -sh "$DB_SRC" | cut -f1)"
if [ ! -d "$NAS_MOUNT" ]; then
log "ERROR: NAS not mounted at $NAS_MOUNT"; exit 1
fi
printf " %-20s %s\n" "NAS mount:" "OK $NAS_MOUNT"
# Check if DB already synced for this date
DB_ALREADY_SYNCED=false
if [ -f "$NAS_DB" ]; then
if table_exists "$NAS_DB" "frames"; then
EXISTING=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';" 2>/dev/null || echo "0")
if [ "$EXISTING" -gt "0" ]; then
log "Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync"
DB_ALREADY_SYNCED=true
else
printf " %-20s %s (%s)\n" "Archive DB:" "exists" "$(du -sh "$NAS_DB" | cut -f1)"
fi
else
printf " %-20s %s\n" "Archive DB:" "exists, no frames table yet"
fi
else
printf " %-20s %s\n" "Archive DB:" "will be created"
fi
# Source data dir for this date
DATA_SRC="$HOME/.screenpipe/data/data/$TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
DATA_SIZE=$(du -sh "$DATA_SRC" | cut -f1)
DATA_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
printf " %-20s %s (%s files, %s)\n" "Data dir:" "OK" "$DATA_FILES" "$DATA_SIZE"
else
printf " %-20s %s\n" "Data dir:" "not found — skipping file copy"
fi
# ─── DB SYNC ──────────────────────────────────────────────────────────────────
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────
step "Counting source rows for $TARGET_DATE"
SRC_FRAMES=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
SRC_ELEMENTS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_UI=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
SRC_OCR=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_MEETINGS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';")
printf " %-20s %s\n" "frames:" "$SRC_FRAMES"
printf " %-20s %s\n" "elements:" "$SRC_ELEMENTS"
printf " %-20s %s\n" "ui_events:" "$SRC_UI"
printf " %-20s %s\n" "ocr_text:" "$SRC_OCR"
printf " %-20s %s\n" "meetings:" "$SRC_MEETINGS"
if [ "$SRC_FRAMES" -eq "0" ]; then
log "No frames found for $TARGET_DATE — skipping DB sync"
DB_ALREADY_SYNCED=true
fi
fi
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── INIT TABLES ──────────────────────────────────────────────────────────
step "Initialising tables (CREATE IF NOT EXISTS)"
run_sqlite_heredoc "creating tables" "
ATTACH '$NAS_DB' AS nas;
CREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;
CREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;
CREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;
CREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;
DETACH nas;
"
# ─── SCHEMA DRIFT FIX ─────────────────────────────────────────────────────
# Runs AFTER CREATE IF NOT EXISTS so newly-created tables are no-ops here,
# and pre-existing tables get any missing columns added.
step "Reconciling NAS schema with source"
for tbl in "${SYNC_TABLES[@]}"; do
ensure_columns "$tbl"
done
run_sqlite_heredoc "creating indexes" "
ATTACH '$NAS_DB' AS nas;
CREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);
CREATE INDEX IF NOT EXISTS nas.idx_frames_document_path ON frames(document_path) WHERE document_path IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_elements_onscreen_frame ON elements(frame_id) WHERE on_screen = 1 AND text IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);
CREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);
DETACH nas;
"
run_sqlite_heredoc "creating FTS tables" "
ATTACH '$NAS_DB' AS nas;
CREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(
text, role, frame_id UNINDEXED,
content='elements', content_rowid='id', tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(
full_text, app_name, window_name, browser_url, id UNINDEXED,
tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(
text_content,
app_name,
window_title,
element_name,
content='ui_events',
content_rowid='id',
tokenize='unicode61'
);
DETACH nas;
"
# ─── BUILD EXPLICIT COLUMN LISTS ──────────────────────────────────────────
# After ensure_columns, source ⊆ NAS for every synced table, so source's
# column list is a safe subset to use on both sides of the INSERT.
FRAMES_COLS=$(build_col_list frames)
ELEMENTS_COLS=$(build_col_list elements)
UI_EVENTS_COLS=$(build_col_list ui_events)
OCR_TEXT_COLS=$(build_col_list ocr_text)
VIDEO_CHUNKS_COLS=$(build_col_list video_chunks)
MEETINGS_COLS=$(build_col_list meetings)
# ─── SYNC DATA ────────────────────────────────────────────────────────────
step "Syncing data for $TARGET_DATE"
run_sqlite_heredoc "video_chunks" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.video_chunks ($VIDEO_CHUNKS_COLS)
SELECT $VIDEO_CHUNKS_COLS FROM main.video_chunks
WHERE id IN (
SELECT DISTINCT video_chunk_id FROM main.frames
WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL
);
DETACH nas;
"
run_sqlite_heredoc "frames ($SRC_FRAMES rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.frames ($FRAMES_COLS)
SELECT $FRAMES_COLS FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ocr_text ($SRC_OCR rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ocr_text ($OCR_TEXT_COLS)
SELECT $OCR_TEXT_COLS FROM main.ocr_text o
JOIN main.frames f ON o.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ui_events ($SRC_UI rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ui_events ($UI_EVENTS_COLS)
SELECT $UI_EVENTS_COLS FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "elements ($SRC_ELEMENTS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.elements ($ELEMENTS_COLS)
SELECT $ELEMENTS_COLS FROM main.elements e
JOIN main.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "meetings ($SRC_MEETINGS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.meetings ($MEETINGS_COLS)
SELECT $MEETINGS_COLS FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';
DETACH nas;
"
# NOTE: the elements/ocr_text inserts use unqualified column names while
# selecting from a JOIN. SQLite resolves them against the leftmost table
# that has the column, which is what we want here (e.* / o.* implicitly),
# because none of the column names collide with frames'.
# ─── FTS UPDATE ───────────────────────────────────────────────────────────
step "Updating FTS indexes"
run_sqlite_heredoc "elements_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.elements_fts(rowid, text, role)
SELECT e.id, e.text, e.role
FROM nas.elements e
JOIN nas.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE'
AND e.text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "frames_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)
SELECT id, full_text, app_name, window_name, browser_url, id
FROM nas.frames
WHERE date(timestamp) = '$TARGET_DATE'
AND full_text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "ui_events_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)
SELECT id, text_content, app_name, window_title, element_name
FROM nas.ui_events
WHERE date(timestamp) = '$TARGET_DATE'
AND text_content IS NOT NULL;
DETACH nas;
"
# ─── VERIFY DB ────────────────────────────────────────────────────────────
step "Verifying DB"
V_FRAMES=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
V_ELEMENTS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_UI=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
V_OCR=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_MEETINGS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';")
check "frames" "$V_FRAMES" "$SRC_FRAMES"
check "elements" "$V_ELEMENTS" "$SRC_ELEMENTS"
check "ui_events" "$V_UI" "$SRC_UI"
check "ocr_text" "$V_OCR" "$SRC_OCR"
check "meetings" "$V_MEETINGS" "$SRC_MEETINGS"
fi
# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────
# Always runs regardless of DB sync status
step "Copying data folder for $TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
mkdir -p "$NAS_DATA/$TARGET_DATE"
RSYNC_START=$(date +%s)
printf " %-36s " "rsync $TARGET_DATE/ → NAS"
rsync -a --ignore-existing \
"$DATA_SRC/" \
"$NAS_DATA/$TARGET_DATE/" \
2>>"$LOG_FILE"
RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))
COPIED_FILES=$(ls "$NAS_DATA/$TARGET_DATE" | wc -l | tr -d ' ')
SRC_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
COPIED_SIZE=$(du -sh "$NAS_DATA/$TARGET_DATE" | cut -f1)
if [ "$COPIED_FILES" -eq "$SRC_FILES" ]; then
printf "\r %-36s ✓ %dm%02ds (%s files, %s)\n" \
"rsync $TARGET_DATE/ → NAS" \
"$(( RSYNC_DUR / 60 ))" "$(( RSYNC_DUR % 60 ))" \
"$COPIED_FILES" "$COPIED_SIZE" | tee -a "$LOG_FILE"
else
printf "\r %-36s ✗ %s / %s files\n" \
"rsync $TARGET_DATE/ → NAS" "$COPIED_FILES" "$SRC_FILES" | tee -a "$LOG_FILE"
fi
else
printf " %-36s %s\n" "rsync $TARGET_DATE/ → NAS" "skipped (no source dir)"
fi
# ─── SUMMARY ──────────────────────────────────────────────────────────────────
TOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))
DB_SIZE=$(du -sh "$NAS_DB" | cut -f1)
echo ""
log "Archive DB size: $DB_SIZE"
log "Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s"
log "Sync complete for $TARGET_DATE"
log "========================================"
Implement and run pipe l…, Editor Group 2
Problems (⇧⌘M)
PROBLEMS
Output (⇧⌘U)
OUTPUT
Debug Console (⇧⌘Y)
DEBUG CONSOLE
Terminal (⌃`)
TERMINAL
Ports - 1 forwarded port
PORTS
1
remote SSH: nas
SSH: nas
screenpipe (Git) - master*, Checkout Branch/Tag...
master*
screenpipe (Git) - Synchronize Changes
No Problems
0
0
Forwarded Ports: 8766
1
Notifications
Sign In
Sign In
No results found
Implement and run pipe logic
Session history
New session
Message actions
main.py
main.py
lets implement logic with pipes. how can I run it?
Thinking
Thinking
Let me look at the current project structure to understand what's already in place.
Bash
List project files
IN
find /volume1/screenpipe -type f | head -50 && echo "---" && ls /volume1/screenpipe
Copy code to clipboard
OUT
/volume1/screenpipe/.DS_Store
/volume1/screenpipe/screenpipe.db
/volume1/screenpipe/screenpipe_sync.sh
/volume1/screenpipe/app_settings.json
/volume1/screenpipe/.gitignore
/volume1/screenpipe/archive.db
/volume1/screenpipe/db.sqlite
/volume1/screenpipe/db.sqlite-wal
/volume1/screenpipe/db.sqlite-shm
/volume1/screenpipe/#recycle/desktop.ini
/volume1/screenpipe/#recycle/db.sqlite
/volume1/screenpipe/#recycle/Copy #1 of db.sqlite
/volume1/screenpipe/#recycle/.DS_Store
/volume1/screenpipe/#recycle/Copy #2 of db.sqlite
/volume1/screenpipe/#recycle/archive.db
/volume1/screenpipe/#recycle/Copy #1 of archive.db
/volume1/screenpipe/#recycle/Copy #2 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of archive.db
/volume1/screenpipe/#recycle/Copy #4 of archive.db
/volume1/screenpipe/#recycle/Copy #5 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of db.sqlite
/volume1/screenpipe/#recycle/Copy #4 of db.sqlite
/volume1/screenpipe/#recycle/Copy #6 of archive.db
/volume1/screenpipe/#recycle/test.txt
/volume1/screenpipe/#recycle/Copy #7 of archive.db
/volume1/screenpipe/#recycle/Copy #8 of archive.db
/volume1/screenpipe/#recycle/archive.db-journal
/volume1/screenpipe/#recycle/Copy #1 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #2 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #3 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #4 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #6 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #7 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of db.sqlite
/volume1/screenpipe/pipes/.DS_Store
/volume1/screenpipe/app/.env
/volume1/screenpipe/app/cli.py
/volume1/screenpipe/app/.DS_Store
/volume1/screenpipe/app/db.py
/volume1/screenpipe/app/docker-compose.yml
/volume1/screenpipe/app/main.py
/volume1/screenpipe/app/requirements.txt
/volume1/screenpipe/app/Dockerfile
/volume1/screenpipe/data/.DS_Store
/volume1/screenpipe/.git/description
/volume1/screenpipe/.git/HEAD
/volume1/screenpipe/.git/index
/volume1/screenpipe/.git/COMMIT_EDITMSG
/volume1/screenpipe/#recycle/data/.DS_Store
---
app
app_settings.json
archive.db
data
db.sqlite
db.sqlite-shm
db.sqlite-wal
pipes
#recycle
screenpipe.db
screenpipe_sync.sh
Read
main.py
main.py
Bash
Check pipes directory and docker-compose
IN
ls /volume1/screenpipe/pipes/ && ls /volume1/screenpipe/app/ && cat /volume1/screenpipe/app/docker-compose.yml
Copy code to clipboard...
|
[{"role":"AXRadioButton","text [{"role":"AXRadioButton","text":"Explorer (⇧⌘E) - 1 unsaved file","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":true},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Search (⇧⌘F)","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Source Control (⌃⇧G) - 10 pending changes","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"10","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Run and Debug (⇧⌘D)","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Remote Explorer","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Extensions (⇧⌘X) - 2 require update","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"2","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Claude Code","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"Containers","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXHeading","text":"EXPLORER","depth":17,"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"EXPLORER","depth":18,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Explorer Section: screenpipe [SSH: nas]","depth":21,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":true},{"role":"AXStaticText","text":"","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"Explorer Section: screenpipe [SSH: nas]","depth":22,"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"SCREENPIPE [SSH: NAS]","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"#recycle","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"app","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"__pycache__","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"consumers","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"static","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":".env","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"cli.py","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.py","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"docker-compose.yml","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Dockerfile","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"main.py","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"requirements.txt","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"data","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"logs","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"pipes","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":".gitignore","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"app_settings.json","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"archive.db","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"archive.db-bak","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"U","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite-shm","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite-wal","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe_sync_updated.sh","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"U","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe_sync.sh","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe.db","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Outline Section","depth":21,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"OUTLINE","depth":22,"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"OUTLINE","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Timeline Section","depth":21,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"TIMELINE","depth":22,"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"TIMELINE","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"app_settings.json, Editor Group 1","depth":28,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"screenpipe_sync.sh, Editor Group 1","depth":28,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"screenpipe_sync_updated.sh, preview, Editor Group 1","depth":28,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":false},{"role":"AXRadioButton","text":"pipe.md, Editor Group 1","depth":28,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":".env, Editor Group 1","depth":28,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"#!/bin/bash\n# screenpipe_sync.sh\n# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).\n# Also copies the day's video/frame data folder to the NAS.\n#\n# Schema-drift tolerant: if Screenpipe migrations add new columns to the source DB,\n# the NAS archive gets ALTER TABLE'd to match. Inserts use explicit column lists,\n# so positional mismatches can't occur.\n#\n# Usage:\n# ./screenpipe_sync.sh # syncs yesterday (default)\n# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date\n# ./screenpipe_sync.sh today # syncs today so far\n#\n# Cron example (runs at 3am daily):\n# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1\n\nset -euo pipefail\n\n# ─── CONFIG ───────────────────────────────────────────────────────────────────\nDB_SRC=\"${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}\"\nNAS_MOUNT=\"${NAS_MOUNT:-/Volumes/screenpipe}\"\nNAS_DB=\"$NAS_MOUNT/archive.db\"\nNAS_DATA=\"$NAS_MOUNT/data\"\nLOG_FILE=\"$HOME/.screenpipe/sync.log\"\n# Tables that get schema drift handling. Order matters for FK-ish references\n# (parents before children: video_chunks → frames → elements/ocr_text/ui_events).\nSYNC_TABLES=(video_chunks frames elements ocr_text ui_events meetings)\n# ──────────────────────────────────────────────────────────────────────────────\n\n# ─── HELPERS ──────────────────────────────────────────────────────────────────\nSCRIPT_START=$(date +%s)\n\nlog() {\n local msg=\"[$(date '+%Y-%m-%d %H:%M:%S')] $*\"\n echo \"$msg\" | tee -a \"$LOG_FILE\"\n}\n\nstep() {\n local now=$(date +%s)\n local elapsed=$(( now - SCRIPT_START ))\n local min=$(( elapsed / 60 ))\n local sec=$(( elapsed % 60 ))\n printf \"\\n[+%02dm%02ds] ▶ %s\\n\" \"$min\" \"$sec\" \"$*\" | tee -a \"$LOG_FILE\"\n}\n\nrun_sqlite_heredoc() {\n local label=\"$1\"\n local sql=\"$2\"\n local start=$(date +%s)\n\n printf \" %-36s \" \"$label\"\n\n sqlite3 \"$DB_SRC\" <<< \"$sql\" &\n local pid=$!\n local spin=('⠋' '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')\n local i=0\n while kill -0 \"$pid\" 2>/dev/null; do\n printf \"\\r %-36s %s \" \"$label\" \"${spin[$i]}\"\n i=$(( (i + 1) % 10 ))\n sleep 0.2\n done\n wait \"$pid\"\n local rc=$?\n if [ $rc -ne 0 ]; then\n printf \"\\r %-36s ✗ FAILED\\n\" \"$label\" | tee -a \"$LOG_FILE\"\n exit $rc\n fi\n\n local dur=$(( $(date +%s) - start ))\n printf \"\\r %-36s ✓ %dm%02ds\\n\" \"$label\" \"$(( dur / 60 ))\" \"$(( dur % 60 ))\" | tee -a \"$LOG_FILE\"\n}\n\ncheck() {\n local label=\"$1\" got=\"$2\" expected=\"$3\"\n if [ \"$got\" -eq \"$expected\" ]; then\n printf \" %-20s %s / %s ✓\\n\" \"$label:\" \"$got\" \"$expected\"\n else\n printf \" %-20s %s / %s ✗ MISMATCH\\n\" \"$label:\" \"$got\" \"$expected\"\n fi\n}\n\n# ─── SCHEMA HELPERS ───────────────────────────────────────────────────────────\n# Echoes \"name|type\" lines for a table from a given DB.\ntable_columns_with_types() {\n local db=\"$1\" table=\"$2\"\n sqlite3 \"$db\" \"PRAGMA table_info($table);\" | awk -F'|' '{print $2 \"|\" $3}'\n}\n\n# Echoes just column names, one per line.\ntable_columns() {\n local db=\"$1\" table=\"$2\"\n sqlite3 \"$db\" \"PRAGMA table_info($table);\" | awk -F'|' '{print $2}'\n}\n\n# Returns true (0) if a table exists in the given DB.\ntable_exists() {\n local db=\"$1\" table=\"$2\"\n local count\n count=$(sqlite3 \"$db\" \"SELECT COUNT(*) FROM sqlite_master WHERE type='table' AND name='$table';\")\n [ \"$count\" -gt 0 ]\n}\n\n# Adds any columns present in source but missing in NAS for the given table.\n# Uses ALTER TABLE ADD COLUMN, which is a fast metadata-only operation in SQLite.\nensure_columns() {\n local table=\"$1\"\n local label=\"schema: $table\"\n printf \" %-36s \" \"$label\"\n\n if ! table_exists \"$DB_SRC\" \"$table\"; then\n printf \"✗ source missing — skipping\\n\"\n return 0\n fi\n\n if ! table_exists \"$NAS_DB\" \"$table\"; then\n printf \"✓ fresh (created above)\\n\"\n return 0\n fi\n\n local src_cols\n src_cols=$(table_columns_with_types \"$DB_SRC\" \"$table\")\n local nas_cols\n nas_cols=$(table_columns \"$NAS_DB\" \"$table\")\n\n local added=0\n local added_names=\"\"\n while IFS='|' read -r name type; do\n [ -z \"$name\" ] && continue\n # Use grep -F -x for fixed-string exact match (safe against regex chars).\n if ! echo \"$nas_cols\" | grep -Fxq \"$name\"; then\n # SQLite ALTER TABLE ADD COLUMN: type is optional, no NOT NULL allowed\n # without a constant default. Default-NULL is exactly what we want for archive.\n sqlite3 \"$NAS_DB\" \"ALTER TABLE $table ADD COLUMN \\\"$name\\\" $type;\"\n added=$((added + 1))\n added_names=\"$added_names $name\"\n fi\n done <<< \"$src_cols\"\n\n if [ \"$added\" -gt 0 ]; then\n printf \"✓ added %d:%s\\n\" \"$added\" \"$added_names\"\n else\n printf \"✓ in sync\\n\"\n fi\n}\n\n# Echoes a comma-separated list of source columns for a table, double-quoted\n# so reserved words and hyphens are safe. Used for both INSERT and SELECT sides.\nbuild_col_list() {\n local table=\"$1\"\n table_columns \"$DB_SRC\" \"$table\" | awk 'NF' | sed 's/.*/\"&\"/' | paste -sd, -\n}\n# ──────────────────────────────────────────────────────────────────────────────\n\n# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────\nif [ \"${1:-}\" = \"today\" ]; then\n TARGET_DATE=$(date +%Y-%m-%d)\nelif [ -n \"${1:-}\" ]; then\n TARGET_DATE=\"$1\"\n if ! [[ \"$TARGET_DATE\" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then\n echo \"ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday.\"\n exit 1\n fi\nelse\n TARGET_DATE=$(date -v-1d +%Y-%m-%d)\nfi\n\nlog \"========================================\"\nlog \"Screenpipe sync starting for: $TARGET_DATE\"\nlog \"========================================\"\n\n# ─── PREFLIGHT ────────────────────────────────────────────────────────────────\nstep \"Preflight checks\"\n\nif [ ! -f \"$DB_SRC\" ]; then\n log \"ERROR: Source DB not found at $DB_SRC\"; exit 1\nfi\nprintf \" %-20s %s (%s)\\n\" \"Source DB:\" \"OK\" \"$(du -sh \"$DB_SRC\" | cut -f1)\"\n\nif [ ! -d \"$NAS_MOUNT\" ]; then\n log \"ERROR: NAS not mounted at $NAS_MOUNT\"; exit 1\nfi\nprintf \" %-20s %s\\n\" \"NAS mount:\" \"OK $NAS_MOUNT\"\n\n# Check if DB already synced for this date\nDB_ALREADY_SYNCED=false\nif [ -f \"$NAS_DB\" ]; then\n if table_exists \"$NAS_DB\" \"frames\"; then\n EXISTING=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\" 2>/dev/null || echo \"0\")\n if [ \"$EXISTING\" -gt \"0\" ]; then\n log \"Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync\"\n DB_ALREADY_SYNCED=true\n else\n printf \" %-20s %s (%s)\\n\" \"Archive DB:\" \"exists\" \"$(du -sh \"$NAS_DB\" | cut -f1)\"\n fi\n else\n printf \" %-20s %s\\n\" \"Archive DB:\" \"exists, no frames table yet\"\n fi\nelse\n printf \" %-20s %s\\n\" \"Archive DB:\" \"will be created\"\nfi\n\n# Source data dir for this date\nDATA_SRC=\"$HOME/.screenpipe/data/data/$TARGET_DATE\"\nif [ -d \"$DATA_SRC\" ]; then\n DATA_SIZE=$(du -sh \"$DATA_SRC\" | cut -f1)\n DATA_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n printf \" %-20s %s (%s files, %s)\\n\" \"Data dir:\" \"OK\" \"$DATA_FILES\" \"$DATA_SIZE\"\nelse\n printf \" %-20s %s\\n\" \"Data dir:\" \"not found — skipping file copy\"\nfi\n\n# ─── DB SYNC ──────────────────────────────────────────────────────────────────\nif [ \"$DB_ALREADY_SYNCED\" = false ]; then\n\n # ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────\n step \"Counting source rows for $TARGET_DATE\"\n\n SRC_FRAMES=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\")\n SRC_ELEMENTS=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n SRC_UI=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';\")\n SRC_OCR=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n SRC_MEETINGS=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';\")\n\n printf \" %-20s %s\\n\" \"frames:\" \"$SRC_FRAMES\"\n printf \" %-20s %s\\n\" \"elements:\" \"$SRC_ELEMENTS\"\n printf \" %-20s %s\\n\" \"ui_events:\" \"$SRC_UI\"\n printf \" %-20s %s\\n\" \"ocr_text:\" \"$SRC_OCR\"\n printf \" %-20s %s\\n\" \"meetings:\" \"$SRC_MEETINGS\"\n\n if [ \"$SRC_FRAMES\" -eq \"0\" ]; then\n log \"No frames found for $TARGET_DATE — skipping DB sync\"\n DB_ALREADY_SYNCED=true\n fi\n\nfi\n\nif [ \"$DB_ALREADY_SYNCED\" = false ]; then\n\n # ─── INIT TABLES ──────────────────────────────────────────────────────────\n step \"Initialising tables (CREATE IF NOT EXISTS)\"\n\n run_sqlite_heredoc \"creating tables\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;\nDETACH nas;\n\"\n\n # ─── SCHEMA DRIFT FIX ─────────────────────────────────────────────────────\n # Runs AFTER CREATE IF NOT EXISTS so newly-created tables are no-ops here,\n # and pre-existing tables get any missing columns added.\n step \"Reconciling NAS schema with source\"\n for tbl in \"${SYNC_TABLES[@]}\"; do\n ensure_columns \"$tbl\"\n done\n\n run_sqlite_heredoc \"creating indexes\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_document_path ON frames(document_path) WHERE document_path IS NOT NULL;\nCREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;\nCREATE INDEX IF NOT EXISTS nas.idx_elements_onscreen_frame ON elements(frame_id) WHERE on_screen = 1 AND text IS NOT NULL;\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);\nCREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"creating FTS tables\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(\n text, role, frame_id UNINDEXED,\n content='elements', content_rowid='id', tokenize='unicode61'\n);\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(\n full_text, app_name, window_name, browser_url, id UNINDEXED,\n tokenize='unicode61'\n);\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(\n text_content,\n app_name,\n window_title,\n element_name,\n content='ui_events',\n content_rowid='id',\n tokenize='unicode61'\n);\nDETACH nas;\n\"\n\n # ─── BUILD EXPLICIT COLUMN LISTS ──────────────────────────────────────────\n # After ensure_columns, source ⊆ NAS for every synced table, so source's\n # column list is a safe subset to use on both sides of the INSERT.\n FRAMES_COLS=$(build_col_list frames)\n ELEMENTS_COLS=$(build_col_list elements)\n UI_EVENTS_COLS=$(build_col_list ui_events)\n OCR_TEXT_COLS=$(build_col_list ocr_text)\n VIDEO_CHUNKS_COLS=$(build_col_list video_chunks)\n MEETINGS_COLS=$(build_col_list meetings)\n\n # ─── SYNC DATA ────────────────────────────────────────────────────────────\n step \"Syncing data for $TARGET_DATE\"\n\n run_sqlite_heredoc \"video_chunks\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.video_chunks ($VIDEO_CHUNKS_COLS)\n SELECT $VIDEO_CHUNKS_COLS FROM main.video_chunks\n WHERE id IN (\n SELECT DISTINCT video_chunk_id FROM main.frames\n WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL\n );\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames ($SRC_FRAMES rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.frames ($FRAMES_COLS)\n SELECT $FRAMES_COLS FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ocr_text ($SRC_OCR rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ocr_text ($OCR_TEXT_COLS)\n SELECT $OCR_TEXT_COLS FROM main.ocr_text o\n JOIN main.frames f ON o.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events ($SRC_UI rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ui_events ($UI_EVENTS_COLS)\n SELECT $UI_EVENTS_COLS FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"elements ($SRC_ELEMENTS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.elements ($ELEMENTS_COLS)\n SELECT $ELEMENTS_COLS FROM main.elements e\n JOIN main.frames f ON e.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"meetings ($SRC_MEETINGS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.meetings ($MEETINGS_COLS)\n SELECT $MEETINGS_COLS FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n # NOTE: the elements/ocr_text inserts use unqualified column names while\n # selecting from a JOIN. SQLite resolves them against the leftmost table\n # that has the column, which is what we want here (e.* / o.* implicitly),\n # because none of the column names collide with frames'.\n\n # ─── FTS UPDATE ───────────────────────────────────────────────────────────\n step \"Updating FTS indexes\"\n\n run_sqlite_heredoc \"elements_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.elements_fts(rowid, text, role)\n SELECT e.id, e.text, e.role\n FROM nas.elements e\n JOIN nas.frames f ON e.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE'\n AND e.text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)\n SELECT id, full_text, app_name, window_name, browser_url, id\n FROM nas.frames\n WHERE date(timestamp) = '$TARGET_DATE'\n AND full_text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)\n SELECT id, text_content, app_name, window_title, element_name\n FROM nas.ui_events\n WHERE date(timestamp) = '$TARGET_DATE'\n AND text_content IS NOT NULL;\nDETACH nas;\n\"\n\n # ─── VERIFY DB ────────────────────────────────────────────────────────────\n step \"Verifying DB\"\n\n V_FRAMES=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\")\n V_ELEMENTS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n V_UI=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';\")\n V_OCR=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n V_MEETINGS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';\")\n\n check \"frames\" \"$V_FRAMES\" \"$SRC_FRAMES\"\n check \"elements\" \"$V_ELEMENTS\" \"$SRC_ELEMENTS\"\n check \"ui_events\" \"$V_UI\" \"$SRC_UI\"\n check \"ocr_text\" \"$V_OCR\" \"$SRC_OCR\"\n check \"meetings\" \"$V_MEETINGS\" \"$SRC_MEETINGS\"\n\nfi\n\n# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────\n# Always runs regardless of DB sync status\nstep \"Copying data folder for $TARGET_DATE\"\n\nif [ -d \"$DATA_SRC\" ]; then\n mkdir -p \"$NAS_DATA/$TARGET_DATE\"\n RSYNC_START=$(date +%s)\n printf \" %-36s \" \"rsync $TARGET_DATE/ → NAS\"\n rsync -a --ignore-existing \\\n \"$DATA_SRC/\" \\\n \"$NAS_DATA/$TARGET_DATE/\" \\\n 2>>\"$LOG_FILE\"\n RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))\n COPIED_FILES=$(ls \"$NAS_DATA/$TARGET_DATE\" | wc -l | tr -d ' ')\n SRC_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n COPIED_SIZE=$(du -sh \"$NAS_DATA/$TARGET_DATE\" | cut -f1)\n if [ \"$COPIED_FILES\" -eq \"$SRC_FILES\" ]; then\n printf \"\\r %-36s ✓ %dm%02ds (%s files, %s)\\n\" \\\n \"rsync $TARGET_DATE/ → NAS\" \\\n \"$(( RSYNC_DUR / 60 ))\" \"$(( RSYNC_DUR % 60 ))\" \\\n \"$COPIED_FILES\" \"$COPIED_SIZE\" | tee -a \"$LOG_FILE\"\n else\n printf \"\\r %-36s ✗ %s / %s files\\n\" \\\n \"rsync $TARGET_DATE/ → NAS\" \"$COPIED_FILES\" \"$SRC_FILES\" | tee -a \"$LOG_FILE\"\n fi\nelse\n printf \" %-36s %s\\n\" \"rsync $TARGET_DATE/ → NAS\" \"skipped (no source dir)\"\nfi\n\n# ─── SUMMARY ──────────────────────────────────────────────────────────────────\nTOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))\nDB_SIZE=$(du -sh \"$NAS_DB\" | cut -f1)\n\necho \"\"\nlog \"Archive DB size: $DB_SIZE\"\nlog \"Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s\"\nlog \"Sync complete for $TARGET_DATE\"\nlog \"========================================\"","depth":28,"on_screen":true,"value":"#!/bin/bash\n# screenpipe_sync.sh\n# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).\n# Also copies the day's video/frame data folder to the NAS.\n#\n# Schema-drift tolerant: if Screenpipe migrations add new columns to the source DB,\n# the NAS archive gets ALTER TABLE'd to match. Inserts use explicit column lists,\n# so positional mismatches can't occur.\n#\n# Usage:\n# ./screenpipe_sync.sh # syncs yesterday (default)\n# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date\n# ./screenpipe_sync.sh today # syncs today so far\n#\n# Cron example (runs at 3am daily):\n# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1\n\nset -euo pipefail\n\n# ─── CONFIG ───────────────────────────────────────────────────────────────────\nDB_SRC=\"${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}\"\nNAS_MOUNT=\"${NAS_MOUNT:-/Volumes/screenpipe}\"\nNAS_DB=\"$NAS_MOUNT/archive.db\"\nNAS_DATA=\"$NAS_MOUNT/data\"\nLOG_FILE=\"$HOME/.screenpipe/sync.log\"\n# Tables that get schema drift handling. Order matters for FK-ish references\n# (parents before children: video_chunks → frames → elements/ocr_text/ui_events).\nSYNC_TABLES=(video_chunks frames elements ocr_text ui_events meetings)\n# ──────────────────────────────────────────────────────────────────────────────\n\n# ─── HELPERS ──────────────────────────────────────────────────────────────────\nSCRIPT_START=$(date +%s)\n\nlog() {\n local msg=\"[$(date '+%Y-%m-%d %H:%M:%S')] $*\"\n echo \"$msg\" | tee -a \"$LOG_FILE\"\n}\n\nstep() {\n local now=$(date +%s)\n local elapsed=$(( now - SCRIPT_START ))\n local min=$(( elapsed / 60 ))\n local sec=$(( elapsed % 60 ))\n printf \"\\n[+%02dm%02ds] ▶ %s\\n\" \"$min\" \"$sec\" \"$*\" | tee -a \"$LOG_FILE\"\n}\n\nrun_sqlite_heredoc() {\n local label=\"$1\"\n local sql=\"$2\"\n local start=$(date +%s)\n\n printf \" %-36s \" \"$label\"\n\n sqlite3 \"$DB_SRC\" <<< \"$sql\" &\n local pid=$!\n local spin=('⠋' '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')\n local i=0\n while kill -0 \"$pid\" 2>/dev/null; do\n printf \"\\r %-36s %s \" \"$label\" \"${spin[$i]}\"\n i=$(( (i + 1) % 10 ))\n sleep 0.2\n done\n wait \"$pid\"\n local rc=$?\n if [ $rc -ne 0 ]; then\n printf \"\\r %-36s ✗ FAILED\\n\" \"$label\" | tee -a \"$LOG_FILE\"\n exit $rc\n fi\n\n local dur=$(( $(date +%s) - start ))\n printf \"\\r %-36s ✓ %dm%02ds\\n\" \"$label\" \"$(( dur / 60 ))\" \"$(( dur % 60 ))\" | tee -a \"$LOG_FILE\"\n}\n\ncheck() {\n local label=\"$1\" got=\"$2\" expected=\"$3\"\n if [ \"$got\" -eq \"$expected\" ]; then\n printf \" %-20s %s / %s ✓\\n\" \"$label:\" \"$got\" \"$expected\"\n else\n printf \" %-20s %s / %s ✗ MISMATCH\\n\" \"$label:\" \"$got\" \"$expected\"\n fi\n}\n\n# ─── SCHEMA HELPERS ───────────────────────────────────────────────────────────\n# Echoes \"name|type\" lines for a table from a given DB.\ntable_columns_with_types() {\n local db=\"$1\" table=\"$2\"\n sqlite3 \"$db\" \"PRAGMA table_info($table);\" | awk -F'|' '{print $2 \"|\" $3}'\n}\n\n# Echoes just column names, one per line.\ntable_columns() {\n local db=\"$1\" table=\"$2\"\n sqlite3 \"$db\" \"PRAGMA table_info($table);\" | awk -F'|' '{print $2}'\n}\n\n# Returns true (0) if a table exists in the given DB.\ntable_exists() {\n local db=\"$1\" table=\"$2\"\n local count\n count=$(sqlite3 \"$db\" \"SELECT COUNT(*) FROM sqlite_master WHERE type='table' AND name='$table';\")\n [ \"$count\" -gt 0 ]\n}\n\n# Adds any columns present in source but missing in NAS for the given table.\n# Uses ALTER TABLE ADD COLUMN, which is a fast metadata-only operation in SQLite.\nensure_columns() {\n local table=\"$1\"\n local label=\"schema: $table\"\n printf \" %-36s \" \"$label\"\n\n if ! table_exists \"$DB_SRC\" \"$table\"; then\n printf \"✗ source missing — skipping\\n\"\n return 0\n fi\n\n if ! table_exists \"$NAS_DB\" \"$table\"; then\n printf \"✓ fresh (created above)\\n\"\n return 0\n fi\n\n local src_cols\n src_cols=$(table_columns_with_types \"$DB_SRC\" \"$table\")\n local nas_cols\n nas_cols=$(table_columns \"$NAS_DB\" \"$table\")\n\n local added=0\n local added_names=\"\"\n while IFS='|' read -r name type; do\n [ -z \"$name\" ] && continue\n # Use grep -F -x for fixed-string exact match (safe against regex chars).\n if ! echo \"$nas_cols\" | grep -Fxq \"$name\"; then\n # SQLite ALTER TABLE ADD COLUMN: type is optional, no NOT NULL allowed\n # without a constant default. Default-NULL is exactly what we want for archive.\n sqlite3 \"$NAS_DB\" \"ALTER TABLE $table ADD COLUMN \\\"$name\\\" $type;\"\n added=$((added + 1))\n added_names=\"$added_names $name\"\n fi\n done <<< \"$src_cols\"\n\n if [ \"$added\" -gt 0 ]; then\n printf \"✓ added %d:%s\\n\" \"$added\" \"$added_names\"\n else\n printf \"✓ in sync\\n\"\n fi\n}\n\n# Echoes a comma-separated list of source columns for a table, double-quoted\n# so reserved words and hyphens are safe. Used for both INSERT and SELECT sides.\nbuild_col_list() {\n local table=\"$1\"\n table_columns \"$DB_SRC\" \"$table\" | awk 'NF' | sed 's/.*/\"&\"/' | paste -sd, -\n}\n# ──────────────────────────────────────────────────────────────────────────────\n\n# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────\nif [ \"${1:-}\" = \"today\" ]; then\n TARGET_DATE=$(date +%Y-%m-%d)\nelif [ -n \"${1:-}\" ]; then\n TARGET_DATE=\"$1\"\n if ! [[ \"$TARGET_DATE\" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then\n echo \"ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday.\"\n exit 1\n fi\nelse\n TARGET_DATE=$(date -v-1d +%Y-%m-%d)\nfi\n\nlog \"========================================\"\nlog \"Screenpipe sync starting for: $TARGET_DATE\"\nlog \"========================================\"\n\n# ─── PREFLIGHT ────────────────────────────────────────────────────────────────\nstep \"Preflight checks\"\n\nif [ ! -f \"$DB_SRC\" ]; then\n log \"ERROR: Source DB not found at $DB_SRC\"; exit 1\nfi\nprintf \" %-20s %s (%s)\\n\" \"Source DB:\" \"OK\" \"$(du -sh \"$DB_SRC\" | cut -f1)\"\n\nif [ ! -d \"$NAS_MOUNT\" ]; then\n log \"ERROR: NAS not mounted at $NAS_MOUNT\"; exit 1\nfi\nprintf \" %-20s %s\\n\" \"NAS mount:\" \"OK $NAS_MOUNT\"\n\n# Check if DB already synced for this date\nDB_ALREADY_SYNCED=false\nif [ -f \"$NAS_DB\" ]; then\n if table_exists \"$NAS_DB\" \"frames\"; then\n EXISTING=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\" 2>/dev/null || echo \"0\")\n if [ \"$EXISTING\" -gt \"0\" ]; then\n log \"Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync\"\n DB_ALREADY_SYNCED=true\n else\n printf \" %-20s %s (%s)\\n\" \"Archive DB:\" \"exists\" \"$(du -sh \"$NAS_DB\" | cut -f1)\"\n fi\n else\n printf \" %-20s %s\\n\" \"Archive DB:\" \"exists, no frames table yet\"\n fi\nelse\n printf \" %-20s %s\\n\" \"Archive DB:\" \"will be created\"\nfi\n\n# Source data dir for this date\nDATA_SRC=\"$HOME/.screenpipe/data/data/$TARGET_DATE\"\nif [ -d \"$DATA_SRC\" ]; then\n DATA_SIZE=$(du -sh \"$DATA_SRC\" | cut -f1)\n DATA_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n printf \" %-20s %s (%s files, %s)\\n\" \"Data dir:\" \"OK\" \"$DATA_FILES\" \"$DATA_SIZE\"\nelse\n printf \" %-20s %s\\n\" \"Data dir:\" \"not found — skipping file copy\"\nfi\n\n# ─── DB SYNC ──────────────────────────────────────────────────────────────────\nif [ \"$DB_ALREADY_SYNCED\" = false ]; then\n\n # ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────\n step \"Counting source rows for $TARGET_DATE\"\n\n SRC_FRAMES=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\")\n SRC_ELEMENTS=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n SRC_UI=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';\")\n SRC_OCR=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n SRC_MEETINGS=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';\")\n\n printf \" %-20s %s\\n\" \"frames:\" \"$SRC_FRAMES\"\n printf \" %-20s %s\\n\" \"elements:\" \"$SRC_ELEMENTS\"\n printf \" %-20s %s\\n\" \"ui_events:\" \"$SRC_UI\"\n printf \" %-20s %s\\n\" \"ocr_text:\" \"$SRC_OCR\"\n printf \" %-20s %s\\n\" \"meetings:\" \"$SRC_MEETINGS\"\n\n if [ \"$SRC_FRAMES\" -eq \"0\" ]; then\n log \"No frames found for $TARGET_DATE — skipping DB sync\"\n DB_ALREADY_SYNCED=true\n fi\n\nfi\n\nif [ \"$DB_ALREADY_SYNCED\" = false ]; then\n\n # ─── INIT TABLES ──────────────────────────────────────────────────────────\n step \"Initialising tables (CREATE IF NOT EXISTS)\"\n\n run_sqlite_heredoc \"creating tables\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;\nDETACH nas;\n\"\n\n # ─── SCHEMA DRIFT FIX ─────────────────────────────────────────────────────\n # Runs AFTER CREATE IF NOT EXISTS so newly-created tables are no-ops here,\n # and pre-existing tables get any missing columns added.\n step \"Reconciling NAS schema with source\"\n for tbl in \"${SYNC_TABLES[@]}\"; do\n ensure_columns \"$tbl\"\n done\n\n run_sqlite_heredoc \"creating indexes\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_document_path ON frames(document_path) WHERE document_path IS NOT NULL;\nCREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;\nCREATE INDEX IF NOT EXISTS nas.idx_elements_onscreen_frame ON elements(frame_id) WHERE on_screen = 1 AND text IS NOT NULL;\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);\nCREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"creating FTS tables\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(\n text, role, frame_id UNINDEXED,\n content='elements', content_rowid='id', tokenize='unicode61'\n);\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(\n full_text, app_name, window_name, browser_url, id UNINDEXED,\n tokenize='unicode61'\n);\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(\n text_content,\n app_name,\n window_title,\n element_name,\n content='ui_events',\n content_rowid='id',\n tokenize='unicode61'\n);\nDETACH nas;\n\"\n\n # ─── BUILD EXPLICIT COLUMN LISTS ──────────────────────────────────────────\n # After ensure_columns, source ⊆ NAS for every synced table, so source's\n # column list is a safe subset to use on both sides of the INSERT.\n FRAMES_COLS=$(build_col_list frames)\n ELEMENTS_COLS=$(build_col_list elements)\n UI_EVENTS_COLS=$(build_col_list ui_events)\n OCR_TEXT_COLS=$(build_col_list ocr_text)\n VIDEO_CHUNKS_COLS=$(build_col_list video_chunks)\n MEETINGS_COLS=$(build_col_list meetings)\n\n # ─── SYNC DATA ────────────────────────────────────────────────────────────\n step \"Syncing data for $TARGET_DATE\"\n\n run_sqlite_heredoc \"video_chunks\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.video_chunks ($VIDEO_CHUNKS_COLS)\n SELECT $VIDEO_CHUNKS_COLS FROM main.video_chunks\n WHERE id IN (\n SELECT DISTINCT video_chunk_id FROM main.frames\n WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL\n );\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames ($SRC_FRAMES rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.frames ($FRAMES_COLS)\n SELECT $FRAMES_COLS FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ocr_text ($SRC_OCR rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ocr_text ($OCR_TEXT_COLS)\n SELECT $OCR_TEXT_COLS FROM main.ocr_text o\n JOIN main.frames f ON o.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events ($SRC_UI rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ui_events ($UI_EVENTS_COLS)\n SELECT $UI_EVENTS_COLS FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"elements ($SRC_ELEMENTS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.elements ($ELEMENTS_COLS)\n SELECT $ELEMENTS_COLS FROM main.elements e\n JOIN main.frames f ON e.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"meetings ($SRC_MEETINGS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.meetings ($MEETINGS_COLS)\n SELECT $MEETINGS_COLS FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n # NOTE: the elements/ocr_text inserts use unqualified column names while\n # selecting from a JOIN. SQLite resolves them against the leftmost table\n # that has the column, which is what we want here (e.* / o.* implicitly),\n # because none of the column names collide with frames'.\n\n # ─── FTS UPDATE ───────────────────────────────────────────────────────────\n step \"Updating FTS indexes\"\n\n run_sqlite_heredoc \"elements_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.elements_fts(rowid, text, role)\n SELECT e.id, e.text, e.role\n FROM nas.elements e\n JOIN nas.frames f ON e.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE'\n AND e.text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)\n SELECT id, full_text, app_name, window_name, browser_url, id\n FROM nas.frames\n WHERE date(timestamp) = '$TARGET_DATE'\n AND full_text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)\n SELECT id, text_content, app_name, window_title, element_name\n FROM nas.ui_events\n WHERE date(timestamp) = '$TARGET_DATE'\n AND text_content IS NOT NULL;\nDETACH nas;\n\"\n\n # ─── VERIFY DB ────────────────────────────────────────────────────────────\n step \"Verifying DB\"\n\n V_FRAMES=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\")\n V_ELEMENTS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n V_UI=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';\")\n V_OCR=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n V_MEETINGS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';\")\n\n check \"frames\" \"$V_FRAMES\" \"$SRC_FRAMES\"\n check \"elements\" \"$V_ELEMENTS\" \"$SRC_ELEMENTS\"\n check \"ui_events\" \"$V_UI\" \"$SRC_UI\"\n check \"ocr_text\" \"$V_OCR\" \"$SRC_OCR\"\n check \"meetings\" \"$V_MEETINGS\" \"$SRC_MEETINGS\"\n\nfi\n\n# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────\n# Always runs regardless of DB sync status\nstep \"Copying data folder for $TARGET_DATE\"\n\nif [ -d \"$DATA_SRC\" ]; then\n mkdir -p \"$NAS_DATA/$TARGET_DATE\"\n RSYNC_START=$(date +%s)\n printf \" %-36s \" \"rsync $TARGET_DATE/ → NAS\"\n rsync -a --ignore-existing \\\n \"$DATA_SRC/\" \\\n \"$NAS_DATA/$TARGET_DATE/\" \\\n 2>>\"$LOG_FILE\"\n RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))\n COPIED_FILES=$(ls \"$NAS_DATA/$TARGET_DATE\" | wc -l | tr -d ' ')\n SRC_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n COPIED_SIZE=$(du -sh \"$NAS_DATA/$TARGET_DATE\" | cut -f1)\n if [ \"$COPIED_FILES\" -eq \"$SRC_FILES\" ]; then\n printf \"\\r %-36s ✓ %dm%02ds (%s files, %s)\\n\" \\\n \"rsync $TARGET_DATE/ → NAS\" \\\n \"$(( RSYNC_DUR / 60 ))\" \"$(( RSYNC_DUR % 60 ))\" \\\n \"$COPIED_FILES\" \"$COPIED_SIZE\" | tee -a \"$LOG_FILE\"\n else\n printf \"\\r %-36s ✗ %s / %s files\\n\" \\\n \"rsync $TARGET_DATE/ → NAS\" \"$COPIED_FILES\" \"$SRC_FILES\" | tee -a \"$LOG_FILE\"\n fi\nelse\n printf \" %-36s %s\\n\" \"rsync $TARGET_DATE/ → NAS\" \"skipped (no source dir)\"\nfi\n\n# ─── SUMMARY ──────────────────────────────────────────────────────────────────\nTOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))\nDB_SIZE=$(du -sh \"$NAS_DB\" | cut -f1)\n\necho \"\"\nlog \"Archive DB size: $DB_SIZE\"\nlog \"Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s\"\nlog \"Sync complete for $TARGET_DATE\"\nlog \"========================================\"","role_description":"editor","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"#!/bin/bash\n# screenpipe_sync.sh\n# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).\n# Also copies the day's video/frame data folder to the NAS.\n#\n# Schema-drift tolerant: if Screenpipe migrations add new columns to the source DB,\n# the NAS archive gets ALTER TABLE'd to match. Inserts use explicit column lists,\n# so positional mismatches can't occur.\n#\n# Usage:\n# ./screenpipe_sync.sh # syncs yesterday (default)\n# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date\n# ./screenpipe_sync.sh today # syncs today so far\n#\n# Cron example (runs at 3am daily):\n# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1\n\nset -euo pipefail\n\n# ─── CONFIG ───────────────────────────────────────────────────────────────────\nDB_SRC=\"${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}\"\nNAS_MOUNT=\"${NAS_MOUNT:-/Volumes/screenpipe}\"\nNAS_DB=\"$NAS_MOUNT/archive.db\"\nNAS_DATA=\"$NAS_MOUNT/data\"\nLOG_FILE=\"$HOME/.screenpipe/sync.log\"\n# Tables that get schema drift handling. Order matters for FK-ish references\n# (parents before children: video_chunks → frames → elements/ocr_text/ui_events).\nSYNC_TABLES=(video_chunks frames elements ocr_text ui_events meetings)\n# ──────────────────────────────────────────────────────────────────────────────\n\n# ─── HELPERS ──────────────────────────────────────────────────────────────────\nSCRIPT_START=$(date +%s)\n\nlog() {\n local msg=\"[$(date '+%Y-%m-%d %H:%M:%S')] $*\"\n echo \"$msg\" | tee -a \"$LOG_FILE\"\n}\n\nstep() {\n local now=$(date +%s)\n local elapsed=$(( now - SCRIPT_START ))\n local min=$(( elapsed / 60 ))\n local sec=$(( elapsed % 60 ))\n printf \"\\n[+%02dm%02ds] ▶ %s\\n\" \"$min\" \"$sec\" \"$*\" | tee -a \"$LOG_FILE\"\n}\n\nrun_sqlite_heredoc() {\n local label=\"$1\"\n local sql=\"$2\"\n local start=$(date +%s)\n\n printf \" %-36s \" \"$label\"\n\n sqlite3 \"$DB_SRC\" <<< \"$sql\" &\n local pid=$!\n local spin=('⠋' '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')\n local i=0\n while kill -0 \"$pid\" 2>/dev/null; do\n printf \"\\r %-36s %s \" \"$label\" \"${spin[$i]}\"\n i=$(( (i + 1) % 10 ))\n sleep 0.2\n done\n wait \"$pid\"\n local rc=$?\n if [ $rc -ne 0 ]; then\n printf \"\\r %-36s ✗ FAILED\\n\" \"$label\" | tee -a \"$LOG_FILE\"\n exit $rc\n fi\n\n local dur=$(( $(date +%s) - start ))\n printf \"\\r %-36s ✓ %dm%02ds\\n\" \"$label\" \"$(( dur / 60 ))\" \"$(( dur % 60 ))\" | tee -a \"$LOG_FILE\"\n}\n\ncheck() {\n local label=\"$1\" got=\"$2\" expected=\"$3\"\n if [ \"$got\" -eq \"$expected\" ]; then\n printf \" %-20s %s / %s ✓\\n\" \"$label:\" \"$got\" \"$expected\"\n else\n printf \" %-20s %s / %s ✗ MISMATCH\\n\" \"$label:\" \"$got\" \"$expected\"\n fi\n}\n\n# ─── SCHEMA HELPERS ───────────────────────────────────────────────────────────\n# Echoes \"name|type\" lines for a table from a given DB.\ntable_columns_with_types() {\n local db=\"$1\" table=\"$2\"\n sqlite3 \"$db\" \"PRAGMA table_info($table);\" | awk -F'|' '{print $2 \"|\" $3}'\n}\n\n# Echoes just column names, one per line.\ntable_columns() {\n local db=\"$1\" table=\"$2\"\n sqlite3 \"$db\" \"PRAGMA table_info($table);\" | awk -F'|' '{print $2}'\n}\n\n# Returns true (0) if a table exists in the given DB.\ntable_exists() {\n local db=\"$1\" table=\"$2\"\n local count\n count=$(sqlite3 \"$db\" \"SELECT COUNT(*) FROM sqlite_master WHERE type='table' AND name='$table';\")\n [ \"$count\" -gt 0 ]\n}\n\n# Adds any columns present in source but missing in NAS for the given table.\n# Uses ALTER TABLE ADD COLUMN, which is a fast metadata-only operation in SQLite.\nensure_columns() {\n local table=\"$1\"\n local label=\"schema: $table\"\n printf \" %-36s \" \"$label\"\n\n if ! table_exists \"$DB_SRC\" \"$table\"; then\n printf \"✗ source missing — skipping\\n\"\n return 0\n fi\n\n if ! table_exists \"$NAS_DB\" \"$table\"; then\n printf \"✓ fresh (created above)\\n\"\n return 0\n fi\n\n local src_cols\n src_cols=$(table_columns_with_types \"$DB_SRC\" \"$table\")\n local nas_cols\n nas_cols=$(table_columns \"$NAS_DB\" \"$table\")\n\n local added=0\n local added_names=\"\"\n while IFS='|' read -r name type; do\n [ -z \"$name\" ] && continue\n # Use grep -F -x for fixed-string exact match (safe against regex chars).\n if ! echo \"$nas_cols\" | grep -Fxq \"$name\"; then\n # SQLite ALTER TABLE ADD COLUMN: type is optional, no NOT NULL allowed\n # without a constant default. Default-NULL is exactly what we want for archive.\n sqlite3 \"$NAS_DB\" \"ALTER TABLE $table ADD COLUMN \\\"$name\\\" $type;\"\n added=$((added + 1))\n added_names=\"$added_names $name\"\n fi\n done <<< \"$src_cols\"\n\n if [ \"$added\" -gt 0 ]; then\n printf \"✓ added %d:%s\\n\" \"$added\" \"$added_names\"\n else\n printf \"✓ in sync\\n\"\n fi\n}\n\n# Echoes a comma-separated list of source columns for a table, double-quoted\n# so reserved words and hyphens are safe. Used for both INSERT and SELECT sides.\nbuild_col_list() {\n local table=\"$1\"\n table_columns \"$DB_SRC\" \"$table\" | awk 'NF' | sed 's/.*/\"&\"/' | paste -sd, -\n}\n# ──────────────────────────────────────────────────────────────────────────────\n\n# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────\nif [ \"${1:-}\" = \"today\" ]; then\n TARGET_DATE=$(date +%Y-%m-%d)\nelif [ -n \"${1:-}\" ]; then\n TARGET_DATE=\"$1\"\n if ! [[ \"$TARGET_DATE\" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then\n echo \"ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday.\"\n exit 1\n fi\nelse\n TARGET_DATE=$(date -v-1d +%Y-%m-%d)\nfi\n\nlog \"========================================\"\nlog \"Screenpipe sync starting for: $TARGET_DATE\"\nlog \"========================================\"\n\n# ─── PREFLIGHT ────────────────────────────────────────────────────────────────\nstep \"Preflight checks\"\n\nif [ ! -f \"$DB_SRC\" ]; then\n log \"ERROR: Source DB not found at $DB_SRC\"; exit 1\nfi\nprintf \" %-20s %s (%s)\\n\" \"Source DB:\" \"OK\" \"$(du -sh \"$DB_SRC\" | cut -f1)\"\n\nif [ ! -d \"$NAS_MOUNT\" ]; then\n log \"ERROR: NAS not mounted at $NAS_MOUNT\"; exit 1\nfi\nprintf \" %-20s %s\\n\" \"NAS mount:\" \"OK $NAS_MOUNT\"\n\n# Check if DB already synced for this date\nDB_ALREADY_SYNCED=false\nif [ -f \"$NAS_DB\" ]; then\n if table_exists \"$NAS_DB\" \"frames\"; then\n EXISTING=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\" 2>/dev/null || echo \"0\")\n if [ \"$EXISTING\" -gt \"0\" ]; then\n log \"Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync\"\n DB_ALREADY_SYNCED=true\n else\n printf \" %-20s %s (%s)\\n\" \"Archive DB:\" \"exists\" \"$(du -sh \"$NAS_DB\" | cut -f1)\"\n fi\n else\n printf \" %-20s %s\\n\" \"Archive DB:\" \"exists, no frames table yet\"\n fi\nelse\n printf \" %-20s %s\\n\" \"Archive DB:\" \"will be created\"\nfi\n\n# Source data dir for this date\nDATA_SRC=\"$HOME/.screenpipe/data/data/$TARGET_DATE\"\nif [ -d \"$DATA_SRC\" ]; then\n DATA_SIZE=$(du -sh \"$DATA_SRC\" | cut -f1)\n DATA_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n printf \" %-20s %s (%s files, %s)\\n\" \"Data dir:\" \"OK\" \"$DATA_FILES\" \"$DATA_SIZE\"\nelse\n printf \" %-20s %s\\n\" \"Data dir:\" \"not found — skipping file copy\"\nfi\n\n# ─── DB SYNC ──────────────────────────────────────────────────────────────────\nif [ \"$DB_ALREADY_SYNCED\" = false ]; then\n\n # ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────\n step \"Counting source rows for $TARGET_DATE\"\n\n SRC_FRAMES=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\")\n SRC_ELEMENTS=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n SRC_UI=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';\")\n SRC_OCR=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n SRC_MEETINGS=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';\")\n\n printf \" %-20s %s\\n\" \"frames:\" \"$SRC_FRAMES\"\n printf \" %-20s %s\\n\" \"elements:\" \"$SRC_ELEMENTS\"\n printf \" %-20s %s\\n\" \"ui_events:\" \"$SRC_UI\"\n printf \" %-20s %s\\n\" \"ocr_text:\" \"$SRC_OCR\"\n printf \" %-20s %s\\n\" \"meetings:\" \"$SRC_MEETINGS\"\n\n if [ \"$SRC_FRAMES\" -eq \"0\" ]; then\n log \"No frames found for $TARGET_DATE — skipping DB sync\"\n DB_ALREADY_SYNCED=true\n fi\n\nfi\n\nif [ \"$DB_ALREADY_SYNCED\" = false ]; then\n\n # ─── INIT TABLES ──────────────────────────────────────────────────────────\n step \"Initialising tables (CREATE IF NOT EXISTS)\"\n\n run_sqlite_heredoc \"creating tables\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;\nDETACH nas;\n\"\n\n # ─── SCHEMA DRIFT FIX ─────────────────────────────────────────────────────\n # Runs AFTER CREATE IF NOT EXISTS so newly-created tables are no-ops here,\n # and pre-existing tables get any missing columns added.\n step \"Reconciling NAS schema with source\"\n for tbl in \"${SYNC_TABLES[@]}\"; do\n ensure_columns \"$tbl\"\n done\n\n run_sqlite_heredoc \"creating indexes\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_document_path ON frames(document_path) WHERE document_path IS NOT NULL;\nCREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;\nCREATE INDEX IF NOT EXISTS nas.idx_elements_onscreen_frame ON elements(frame_id) WHERE on_screen = 1 AND text IS NOT NULL;\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);\nCREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"creating FTS tables\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(\n text, role, frame_id UNINDEXED,\n content='elements', content_rowid='id', tokenize='unicode61'\n);\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(\n full_text, app_name, window_name, browser_url, id UNINDEXED,\n tokenize='unicode61'\n);\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(\n text_content,\n app_name,\n window_title,\n element_name,\n content='ui_events',\n content_rowid='id',\n tokenize='unicode61'\n);\nDETACH nas;\n\"\n\n # ─── BUILD EXPLICIT COLUMN LISTS ──────────────────────────────────────────\n # After ensure_columns, source ⊆ NAS for every synced table, so source's\n # column list is a safe subset to use on both sides of the INSERT.\n FRAMES_COLS=$(build_col_list frames)\n ELEMENTS_COLS=$(build_col_list elements)\n UI_EVENTS_COLS=$(build_col_list ui_events)\n OCR_TEXT_COLS=$(build_col_list ocr_text)\n VIDEO_CHUNKS_COLS=$(build_col_list video_chunks)\n MEETINGS_COLS=$(build_col_list meetings)\n\n # ─── SYNC DATA ────────────────────────────────────────────────────────────\n step \"Syncing data for $TARGET_DATE\"\n\n run_sqlite_heredoc \"video_chunks\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.video_chunks ($VIDEO_CHUNKS_COLS)\n SELECT $VIDEO_CHUNKS_COLS FROM main.video_chunks\n WHERE id IN (\n SELECT DISTINCT video_chunk_id FROM main.frames\n WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL\n );\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames ($SRC_FRAMES rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.frames ($FRAMES_COLS)\n SELECT $FRAMES_COLS FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ocr_text ($SRC_OCR rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ocr_text ($OCR_TEXT_COLS)\n SELECT $OCR_TEXT_COLS FROM main.ocr_text o\n JOIN main.frames f ON o.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events ($SRC_UI rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ui_events ($UI_EVENTS_COLS)\n SELECT $UI_EVENTS_COLS FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"elements ($SRC_ELEMENTS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.elements ($ELEMENTS_COLS)\n SELECT $ELEMENTS_COLS FROM main.elements e\n JOIN main.frames f ON e.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"meetings ($SRC_MEETINGS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.meetings ($MEETINGS_COLS)\n SELECT $MEETINGS_COLS FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n # NOTE: the elements/ocr_text inserts use unqualified column names while\n # selecting from a JOIN. SQLite resolves them against the leftmost table\n # that has the column, which is what we want here (e.* / o.* implicitly),\n # because none of the column names collide with frames'.\n\n # ─── FTS UPDATE ───────────────────────────────────────────────────────────\n step \"Updating FTS indexes\"\n\n run_sqlite_heredoc \"elements_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.elements_fts(rowid, text, role)\n SELECT e.id, e.text, e.role\n FROM nas.elements e\n JOIN nas.frames f ON e.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE'\n AND e.text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)\n SELECT id, full_text, app_name, window_name, browser_url, id\n FROM nas.frames\n WHERE date(timestamp) = '$TARGET_DATE'\n AND full_text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)\n SELECT id, text_content, app_name, window_title, element_name\n FROM nas.ui_events\n WHERE date(timestamp) = '$TARGET_DATE'\n AND text_content IS NOT NULL;\nDETACH nas;\n\"\n\n # ─── VERIFY DB ────────────────────────────────────────────────────────────\n step \"Verifying DB\"\n\n V_FRAMES=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\")\n V_ELEMENTS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n V_UI=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';\")\n V_OCR=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n V_MEETINGS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';\")\n\n check \"frames\" \"$V_FRAMES\" \"$SRC_FRAMES\"\n check \"elements\" \"$V_ELEMENTS\" \"$SRC_ELEMENTS\"\n check \"ui_events\" \"$V_UI\" \"$SRC_UI\"\n check \"ocr_text\" \"$V_OCR\" \"$SRC_OCR\"\n check \"meetings\" \"$V_MEETINGS\" \"$SRC_MEETINGS\"\n\nfi\n\n# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────\n# Always runs regardless of DB sync status\nstep \"Copying data folder for $TARGET_DATE\"\n\nif [ -d \"$DATA_SRC\" ]; then\n mkdir -p \"$NAS_DATA/$TARGET_DATE\"\n RSYNC_START=$(date +%s)\n printf \" %-36s \" \"rsync $TARGET_DATE/ → NAS\"\n rsync -a --ignore-existing \\\n \"$DATA_SRC/\" \\\n \"$NAS_DATA/$TARGET_DATE/\" \\\n 2>>\"$LOG_FILE\"\n RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))\n COPIED_FILES=$(ls \"$NAS_DATA/$TARGET_DATE\" | wc -l | tr -d ' ')\n SRC_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n COPIED_SIZE=$(du -sh \"$NAS_DATA/$TARGET_DATE\" | cut -f1)\n if [ \"$COPIED_FILES\" -eq \"$SRC_FILES\" ]; then\n printf \"\\r %-36s ✓ %dm%02ds (%s files, %s)\\n\" \\\n \"rsync $TARGET_DATE/ → NAS\" \\\n \"$(( RSYNC_DUR / 60 ))\" \"$(( RSYNC_DUR % 60 ))\" \\\n \"$COPIED_FILES\" \"$COPIED_SIZE\" | tee -a \"$LOG_FILE\"\n else\n printf \"\\r %-36s ✗ %s / %s files\\n\" \\\n \"rsync $TARGET_DATE/ → NAS\" \"$COPIED_FILES\" \"$SRC_FILES\" | tee -a \"$LOG_FILE\"\n fi\nelse\n printf \" %-36s %s\\n\" \"rsync $TARGET_DATE/ → NAS\" \"skipped (no source dir)\"\nfi\n\n# ─── SUMMARY ──────────────────────────────────────────────────────────────────\nTOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))\nDB_SIZE=$(du -sh \"$NAS_DB\" | cut -f1)\n\necho \"\"\nlog \"Archive DB size: $DB_SIZE\"\nlog \"Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s\"\nlog \"Sync complete for $TARGET_DATE\"\nlog \"========================================\"","depth":29,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Implement and run pipe l…, Editor Group 2","depth":28,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":false},{"role":"AXRadioButton","text":"Problems (⇧⌘M)","depth":22,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"PROBLEMS","depth":24,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Output (⇧⌘U)","depth":22,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUTPUT","depth":24,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Debug Console (⇧⌘Y)","depth":22,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"DEBUG CONSOLE","depth":24,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Terminal (⌃`)","depth":22,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":true},{"role":"AXStaticText","text":"TERMINAL","depth":24,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Ports - 1 forwarded port","depth":22,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"PORTS","depth":24,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":25,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"remote SSH: nas","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"SSH: nas","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"screenpipe (Git) - master*, Checkout Branch/Tag...","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"master*","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"screenpipe (Git) - Synchronize Changes","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"No Problems","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"0","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"0","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Forwarded Ports: 8766","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Notifications","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sign In","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Sign In","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"No results found","depth":12,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Implement and run pipe logic","depth":19,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Session history","depth":19,"on_screen":true,"help_text":"Session history","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"New session","depth":19,"on_screen":true,"help_text":"New session","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Message actions","depth":24,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"main.py","depth":23,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"lets implement logic with pipes. how can I run it?","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Let me look at the current project structure to understand what's already in place.","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"List project files","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"find /volume1/screenpipe -type f | head -50 && echo \"---\" && ls /volume1/screenpipe","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"/volume1/screenpipe/.DS_Store\n/volume1/screenpipe/screenpipe.db\n/volume1/screenpipe/screenpipe_sync.sh\n/volume1/screenpipe/app_settings.json\n/volume1/screenpipe/.gitignore\n/volume1/screenpipe/archive.db\n/volume1/screenpipe/db.sqlite\n/volume1/screenpipe/db.sqlite-wal\n/volume1/screenpipe/db.sqlite-shm\n/volume1/screenpipe/#recycle/desktop.ini\n/volume1/screenpipe/#recycle/db.sqlite\n/volume1/screenpipe/#recycle/Copy #1 of db.sqlite\n/volume1/screenpipe/#recycle/.DS_Store\n/volume1/screenpipe/#recycle/Copy #2 of db.sqlite\n/volume1/screenpipe/#recycle/archive.db\n/volume1/screenpipe/#recycle/Copy #1 of archive.db\n/volume1/screenpipe/#recycle/Copy #2 of archive.db\n/volume1/screenpipe/#recycle/Copy #3 of archive.db\n/volume1/screenpipe/#recycle/Copy #4 of archive.db\n/volume1/screenpipe/#recycle/Copy #5 of archive.db\n/volume1/screenpipe/#recycle/Copy #3 of db.sqlite\n/volume1/screenpipe/#recycle/Copy #4 of db.sqlite\n/volume1/screenpipe/#recycle/Copy #6 of archive.db\n/volume1/screenpipe/#recycle/test.txt\n/volume1/screenpipe/#recycle/Copy #7 of archive.db\n/volume1/screenpipe/#recycle/Copy #8 of archive.db\n/volume1/screenpipe/#recycle/archive.db-journal\n/volume1/screenpipe/#recycle/Copy #1 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #2 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #3 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #4 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #5 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #6 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #7 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #5 of db.sqlite\n/volume1/screenpipe/pipes/.DS_Store\n/volume1/screenpipe/app/.env\n/volume1/screenpipe/app/cli.py\n/volume1/screenpipe/app/.DS_Store\n/volume1/screenpipe/app/db.py\n/volume1/screenpipe/app/docker-compose.yml\n/volume1/screenpipe/app/main.py\n/volume1/screenpipe/app/requirements.txt\n/volume1/screenpipe/app/Dockerfile\n/volume1/screenpipe/data/.DS_Store\n/volume1/screenpipe/.git/description\n/volume1/screenpipe/.git/HEAD\n/volume1/screenpipe/.git/index\n/volume1/screenpipe/.git/COMMIT_EDITMSG\n/volume1/screenpipe/#recycle/data/.DS_Store\n---\napp\napp_settings.json\narchive.db\ndata\ndb.sqlite\ndb.sqlite-shm\ndb.sqlite-wal\npipes\n#recycle\nscreenpipe.db\nscreenpipe_sync.sh","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"main.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Check pipes directory and docker-compose","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/pipes/ && ls /volume1/screenpipe/app/ && cat /volume1/screenpipe/app/docker-compose.yml","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
6920325012745602585
|
3751665402955369749
|
click
|
accessibility
|
NULL
|
Explorer (⇧⌘E) - 1 unsaved file
1
Search (⇧⌘F)
Explorer (⇧⌘E) - 1 unsaved file
1
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py
M
db.py
docker-compose.yml
Dockerfile
M
main.py
M
requirements.txt
M
data
logs
pipes
.gitignore
app_settings.json
archive.db
archive.db-bak
U
db.sqlite
db.sqlite-shm
db.sqlite-wal
screenpipe_sync_updated.sh
U
screenpipe_sync.sh
screenpipe.db
Outline Section
OUTLINE
OUTLINE
Timeline Section
TIMELINE
TIMELINE
app_settings.json, Editor Group 1
screenpipe_sync.sh, Editor Group 1
screenpipe_sync_updated.sh, preview, Editor Group 1
pipe.md, Editor Group 1
.env, Editor Group 1
#!/bin/bash
# screenpipe_sync.sh
# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).
# Also copies the day's video/frame data folder to the NAS.
#
# Schema-drift tolerant: if Screenpipe migrations add new columns to the source DB,
# the NAS archive gets ALTER TABLE'd to match. Inserts use explicit column lists,
# so positional mismatches can't occur.
#
# Usage:
# ./screenpipe_sync.sh # syncs yesterday (default)
# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date
# ./screenpipe_sync.sh today # syncs today so far
#
# Cron example (runs at 3am daily):
# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1
set -euo pipefail
# ─── CONFIG ───────────────────────────────────────────────────────────────────
DB_SRC="${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}"
NAS_MOUNT="${NAS_MOUNT:-/Volumes/screenpipe}"
NAS_DB="$NAS_MOUNT/archive.db"
NAS_DATA="$NAS_MOUNT/data"
LOG_FILE="$HOME/.screenpipe/sync.log"
# Tables that get schema drift handling. Order matters for FK-ish references
# (parents before children: video_chunks → frames → elements/ocr_text/ui_events).
SYNC_TABLES=(video_chunks frames elements ocr_text ui_events meetings)
# ──────────────────────────────────────────────────────────────────────────────
# ─── HELPERS ──────────────────────────────────────────────────────────────────
SCRIPT_START=$(date +%s)
log() {
local msg="[$(date '+%Y-%m-%d %H:%M:%S')] $*"
echo "$msg" | tee -a "$LOG_FILE"
}
step() {
local now=$(date +%s)
local elapsed=$(( now - SCRIPT_START ))
local min=$(( elapsed / 60 ))
local sec=$(( elapsed % 60 ))
printf "\n[+%02dm%02ds] ▶ %s\n" "$min" "$sec" "$*" | tee -a "$LOG_FILE"
}
run_sqlite_heredoc() {
local label="$1"
local sql="$2"
local start=$(date +%s)
printf " %-36s " "$label"
sqlite3 "$DB_SRC" <<< "$sql" &
local pid=$!
local spin=[PASSWORD] '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')
local i=0
while kill -0 "$pid" 2>/dev/null; do
printf "\r %-36s %s " "$label" "${spin[$i]}"
i=$(( (i + 1) % 10 ))
sleep 0.2
done
wait "$pid"
local rc=$?
if [ $rc -ne 0 ]; then
printf "\r %-36s ✗ FAILED\n" "$label" | tee -a "$LOG_FILE"
exit $rc
fi
local dur=$(( $(date +%s) - start ))
printf "\r %-36s ✓ %dm%02ds\n" "$label" "$(( dur / 60 ))" "$(( dur % 60 ))" | tee -a "$LOG_FILE"
}
check() {
local label="$1" got="$2" expected="$3"
if [ "$got" -eq "$expected" ]; then
printf " %-20s %s / %s ✓\n" "$label:" "$got" "$expected"
else
printf " %-20s %s / %s ✗ MISMATCH\n" "$label:" "$got" "$expected"
fi
}
# ─── SCHEMA HELPERS ───────────────────────────────────────────────────────────
# Echoes "name|type" lines for a table from a given DB.
table_columns_with_types() {
local db="$1" table="$2"
sqlite3 "$db" "PRAGMA table_info($table);" | awk -F'|' '{print $2 "|" $3}'
}
# Echoes just column names, one per line.
table_columns() {
local db="$1" table="$2"
sqlite3 "$db" "PRAGMA table_info($table);" | awk -F'|' '{print $2}'
}
# Returns true (0) if a table exists in the given DB.
table_exists() {
local db="$1" table="$2"
local count
count=$(sqlite3 "$db" "SELECT COUNT(*) FROM sqlite_master WHERE type='table' AND name='$table';")
[ "$count" -gt 0 ]
}
# Adds any columns present in source but missing in NAS for the given table.
# Uses ALTER TABLE ADD COLUMN, which is a fast metadata-only operation in SQLite.
ensure_columns() {
local table="$1"
local label="schema: $table"
printf " %-36s " "$label"
if ! table_exists "$DB_SRC" "$table"; then
printf "✗ source missing — skipping\n"
return 0
fi
if ! table_exists "$NAS_DB" "$table"; then
printf "✓ fresh (created above)\n"
return 0
fi
local src_cols
src_cols=$(table_columns_with_types "$DB_SRC" "$table")
local nas_cols
nas_cols=$(table_columns "$NAS_DB" "$table")
local added=0
local added_names=""
while IFS='|' read -r name type; do
[ -z "$name" ] && continue
# Use grep -F -x for fixed-string exact match (safe against regex chars).
if ! echo "$nas_cols" | grep -Fxq "$name"; then
# SQLite ALTER TABLE ADD COLUMN: type is optional, no NOT NULL allowed
# without a constant default. Default-NULL is exactly what we want for archive.
sqlite3 "$NAS_DB" "ALTER TABLE $table ADD COLUMN \"$name\" $type;"
added=$((added + 1))
added_names="$added_names $name"
fi
done <<< "$src_cols"
if [ "$added" -gt 0 ]; then
printf "✓ added %d:%s\n" "$added" "$added_names"
else
printf "✓ in sync\n"
fi
}
# Echoes a comma-separated list of source columns for a table, double-quoted
# so reserved words and hyphens are safe. Used for both INSERT and SELECT sides.
build_col_list() {
local table="$1"
table_columns "$DB_SRC" "$table" | awk 'NF' | sed 's/.*/"&"/' | paste -sd, -
}
# ──────────────────────────────────────────────────────────────────────────────
# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────
if [ "${1:-}" = "today" ]; then
TARGET_DATE=$(date +%Y-%m-%d)
elif [ -n "${1:-}" ]; then
TARGET_DATE="$1"
if ! [[ "$TARGET_DATE" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then
echo "ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday."
exit 1
fi
else
TARGET_DATE=$(date -v-1d +%Y-%m-%d)
fi
log "========================================"
log "Screenpipe sync starting for: $TARGET_DATE"
log "========================================"
# ─── PREFLIGHT ────────────────────────────────────────────────────────────────
step "Preflight checks"
if [ ! -f "$DB_SRC" ]; then
log "ERROR: Source DB not found at $DB_SRC"; exit 1
fi
printf " %-20s %s (%s)\n" "Source DB:" "OK" "$(du -sh "$DB_SRC" | cut -f1)"
if [ ! -d "$NAS_MOUNT" ]; then
log "ERROR: NAS not mounted at $NAS_MOUNT"; exit 1
fi
printf " %-20s %s\n" "NAS mount:" "OK $NAS_MOUNT"
# Check if DB already synced for this date
DB_ALREADY_SYNCED=false
if [ -f "$NAS_DB" ]; then
if table_exists "$NAS_DB" "frames"; then
EXISTING=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';" 2>/dev/null || echo "0")
if [ "$EXISTING" -gt "0" ]; then
log "Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync"
DB_ALREADY_SYNCED=true
else
printf " %-20s %s (%s)\n" "Archive DB:" "exists" "$(du -sh "$NAS_DB" | cut -f1)"
fi
else
printf " %-20s %s\n" "Archive DB:" "exists, no frames table yet"
fi
else
printf " %-20s %s\n" "Archive DB:" "will be created"
fi
# Source data dir for this date
DATA_SRC="$HOME/.screenpipe/data/data/$TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
DATA_SIZE=$(du -sh "$DATA_SRC" | cut -f1)
DATA_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
printf " %-20s %s (%s files, %s)\n" "Data dir:" "OK" "$DATA_FILES" "$DATA_SIZE"
else
printf " %-20s %s\n" "Data dir:" "not found — skipping file copy"
fi
# ─── DB SYNC ──────────────────────────────────────────────────────────────────
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────
step "Counting source rows for $TARGET_DATE"
SRC_FRAMES=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
SRC_ELEMENTS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_UI=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
SRC_OCR=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_MEETINGS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';")
printf " %-20s %s\n" "frames:" "$SRC_FRAMES"
printf " %-20s %s\n" "elements:" "$SRC_ELEMENTS"
printf " %-20s %s\n" "ui_events:" "$SRC_UI"
printf " %-20s %s\n" "ocr_text:" "$SRC_OCR"
printf " %-20s %s\n" "meetings:" "$SRC_MEETINGS"
if [ "$SRC_FRAMES" -eq "0" ]; then
log "No frames found for $TARGET_DATE — skipping DB sync"
DB_ALREADY_SYNCED=true
fi
fi
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── INIT TABLES ──────────────────────────────────────────────────────────
step "Initialising tables (CREATE IF NOT EXISTS)"
run_sqlite_heredoc "creating tables" "
ATTACH '$NAS_DB' AS nas;
CREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;
CREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;
CREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;
CREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;
DETACH nas;
"
# ─── SCHEMA DRIFT FIX ─────────────────────────────────────────────────────
# Runs AFTER CREATE IF NOT EXISTS so newly-created tables are no-ops here,
# and pre-existing tables get any missing columns added.
step "Reconciling NAS schema with source"
for tbl in "${SYNC_TABLES[@]}"; do
ensure_columns "$tbl"
done
run_sqlite_heredoc "creating indexes" "
ATTACH '$NAS_DB' AS nas;
CREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);
CREATE INDEX IF NOT EXISTS nas.idx_frames_document_path ON frames(document_path) WHERE document_path IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_elements_onscreen_frame ON elements(frame_id) WHERE on_screen = 1 AND text IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);
CREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);
DETACH nas;
"
run_sqlite_heredoc "creating FTS tables" "
ATTACH '$NAS_DB' AS nas;
CREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(
text, role, frame_id UNINDEXED,
content='elements', content_rowid='id', tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(
full_text, app_name, window_name, browser_url, id UNINDEXED,
tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(
text_content,
app_name,
window_title,
element_name,
content='ui_events',
content_rowid='id',
tokenize='unicode61'
);
DETACH nas;
"
# ─── BUILD EXPLICIT COLUMN LISTS ──────────────────────────────────────────
# After ensure_columns, source ⊆ NAS for every synced table, so source's
# column list is a safe subset to use on both sides of the INSERT.
FRAMES_COLS=$(build_col_list frames)
ELEMENTS_COLS=$(build_col_list elements)
UI_EVENTS_COLS=$(build_col_list ui_events)
OCR_TEXT_COLS=$(build_col_list ocr_text)
VIDEO_CHUNKS_COLS=$(build_col_list video_chunks)
MEETINGS_COLS=$(build_col_list meetings)
# ─── SYNC DATA ────────────────────────────────────────────────────────────
step "Syncing data for $TARGET_DATE"
run_sqlite_heredoc "video_chunks" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.video_chunks ($VIDEO_CHUNKS_COLS)
SELECT $VIDEO_CHUNKS_COLS FROM main.video_chunks
WHERE id IN (
SELECT DISTINCT video_chunk_id FROM main.frames
WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL
);
DETACH nas;
"
run_sqlite_heredoc "frames ($SRC_FRAMES rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.frames ($FRAMES_COLS)
SELECT $FRAMES_COLS FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ocr_text ($SRC_OCR rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ocr_text ($OCR_TEXT_COLS)
SELECT $OCR_TEXT_COLS FROM main.ocr_text o
JOIN main.frames f ON o.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ui_events ($SRC_UI rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ui_events ($UI_EVENTS_COLS)
SELECT $UI_EVENTS_COLS FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "elements ($SRC_ELEMENTS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.elements ($ELEMENTS_COLS)
SELECT $ELEMENTS_COLS FROM main.elements e
JOIN main.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "meetings ($SRC_MEETINGS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.meetings ($MEETINGS_COLS)
SELECT $MEETINGS_COLS FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';
DETACH nas;
"
# NOTE: the elements/ocr_text inserts use unqualified column names while
# selecting from a JOIN. SQLite resolves them against the leftmost table
# that has the column, which is what we want here (e.* / o.* implicitly),
# because none of the column names collide with frames'.
# ─── FTS UPDATE ───────────────────────────────────────────────────────────
step "Updating FTS indexes"
run_sqlite_heredoc "elements_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.elements_fts(rowid, text, role)
SELECT e.id, e.text, e.role
FROM nas.elements e
JOIN nas.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE'
AND e.text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "frames_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)
SELECT id, full_text, app_name, window_name, browser_url, id
FROM nas.frames
WHERE date(timestamp) = '$TARGET_DATE'
AND full_text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "ui_events_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)
SELECT id, text_content, app_name, window_title, element_name
FROM nas.ui_events
WHERE date(timestamp) = '$TARGET_DATE'
AND text_content IS NOT NULL;
DETACH nas;
"
# ─── VERIFY DB ────────────────────────────────────────────────────────────
step "Verifying DB"
V_FRAMES=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
V_ELEMENTS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_UI=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
V_OCR=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_MEETINGS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';")
check "frames" "$V_FRAMES" "$SRC_FRAMES"
check "elements" "$V_ELEMENTS" "$SRC_ELEMENTS"
check "ui_events" "$V_UI" "$SRC_UI"
check "ocr_text" "$V_OCR" "$SRC_OCR"
check "meetings" "$V_MEETINGS" "$SRC_MEETINGS"
fi
# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────
# Always runs regardless of DB sync status
step "Copying data folder for $TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
mkdir -p "$NAS_DATA/$TARGET_DATE"
RSYNC_START=$(date +%s)
printf " %-36s " "rsync $TARGET_DATE/ → NAS"
rsync -a --ignore-existing \
"$DATA_SRC/" \
"$NAS_DATA/$TARGET_DATE/" \
2>>"$LOG_FILE"
RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))
COPIED_FILES=$(ls "$NAS_DATA/$TARGET_DATE" | wc -l | tr -d ' ')
SRC_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
COPIED_SIZE=$(du -sh "$NAS_DATA/$TARGET_DATE" | cut -f1)
if [ "$COPIED_FILES" -eq "$SRC_FILES" ]; then
printf "\r %-36s ✓ %dm%02ds (%s files, %s)\n" \
"rsync $TARGET_DATE/ → NAS" \
"$(( RSYNC_DUR / 60 ))" "$(( RSYNC_DUR % 60 ))" \
"$COPIED_FILES" "$COPIED_SIZE" | tee -a "$LOG_FILE"
else
printf "\r %-36s ✗ %s / %s files\n" \
"rsync $TARGET_DATE/ → NAS" "$COPIED_FILES" "$SRC_FILES" | tee -a "$LOG_FILE"
fi
else
printf " %-36s %s\n" "rsync $TARGET_DATE/ → NAS" "skipped (no source dir)"
fi
# ─── SUMMARY ──────────────────────────────────────────────────────────────────
TOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))
DB_SIZE=$(du -sh "$NAS_DB" | cut -f1)
echo ""
log "Archive DB size: $DB_SIZE"
log "Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s"
log "Sync complete for $TARGET_DATE"
log "========================================"
#!/bin/bash
# screenpipe_sync.sh
# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).
# Also copies the day's video/frame data folder to the NAS.
#
# Schema-drift tolerant: if Screenpipe migrations add new columns to the source DB,
# the NAS archive gets ALTER TABLE'd to match. Inserts use explicit column lists,
# so positional mismatches can't occur.
#
# Usage:
# ./screenpipe_sync.sh # syncs yesterday (default)
# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date
# ./screenpipe_sync.sh today # syncs today so far
#
# Cron example (runs at 3am daily):
# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1
set -euo pipefail
# ─── CONFIG ───────────────────────────────────────────────────────────────────
DB_SRC="${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}"
NAS_MOUNT="${NAS_MOUNT:-/Volumes/screenpipe}"
NAS_DB="$NAS_MOUNT/archive.db"
NAS_DATA="$NAS_MOUNT/data"
LOG_FILE="$HOME/.screenpipe/sync.log"
# Tables that get schema drift handling. Order matters for FK-ish references
# (parents before children: video_chunks → frames → elements/ocr_text/ui_events).
SYNC_TABLES=(video_chunks frames elements ocr_text ui_events meetings)
# ──────────────────────────────────────────────────────────────────────────────
# ─── HELPERS ──────────────────────────────────────────────────────────────────
SCRIPT_START=$(date +%s)
log() {
local msg="[$(date '+%Y-%m-%d %H:%M:%S')] $*"
echo "$msg" | tee -a "$LOG_FILE"
}
step() {
local now=$(date +%s)
local elapsed=$(( now - SCRIPT_START ))
local min=$(( elapsed / 60 ))
local sec=$(( elapsed % 60 ))
printf "\n[+%02dm%02ds] ▶ %s\n" "$min" "$sec" "$*" | tee -a "$LOG_FILE"
}
run_sqlite_heredoc() {
local label="$1"
local sql="$2"
local start=$(date +%s)
printf " %-36s " "$label"
sqlite3 "$DB_SRC" <<< "$sql" &
local pid=$!
local spin=[PASSWORD] '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')
local i=0
while kill -0 "$pid" 2>/dev/null; do
printf "\r %-36s %s " "$label" "${spin[$i]}"
i=$(( (i + 1) % 10 ))
sleep 0.2
done
wait "$pid"
local rc=$?
if [ $rc -ne 0 ]; then
printf "\r %-36s ✗ FAILED\n" "$label" | tee -a "$LOG_FILE"
exit $rc
fi
local dur=$(( $(date +%s) - start ))
printf "\r %-36s ✓ %dm%02ds\n" "$label" "$(( dur / 60 ))" "$(( dur % 60 ))" | tee -a "$LOG_FILE"
}
check() {
local label="$1" got="$2" expected="$3"
if [ "$got" -eq "$expected" ]; then
printf " %-20s %s / %s ✓\n" "$label:" "$got" "$expected"
else
printf " %-20s %s / %s ✗ MISMATCH\n" "$label:" "$got" "$expected"
fi
}
# ─── SCHEMA HELPERS ───────────────────────────────────────────────────────────
# Echoes "name|type" lines for a table from a given DB.
table_columns_with_types() {
local db="$1" table="$2"
sqlite3 "$db" "PRAGMA table_info($table);" | awk -F'|' '{print $2 "|" $3}'
}
# Echoes just column names, one per line.
table_columns() {
local db="$1" table="$2"
sqlite3 "$db" "PRAGMA table_info($table);" | awk -F'|' '{print $2}'
}
# Returns true (0) if a table exists in the given DB.
table_exists() {
local db="$1" table="$2"
local count
count=$(sqlite3 "$db" "SELECT COUNT(*) FROM sqlite_master WHERE type='table' AND name='$table';")
[ "$count" -gt 0 ]
}
# Adds any columns present in source but missing in NAS for the given table.
# Uses ALTER TABLE ADD COLUMN, which is a fast metadata-only operation in SQLite.
ensure_columns() {
local table="$1"
local label="schema: $table"
printf " %-36s " "$label"
if ! table_exists "$DB_SRC" "$table"; then
printf "✗ source missing — skipping\n"
return 0
fi
if ! table_exists "$NAS_DB" "$table"; then
printf "✓ fresh (created above)\n"
return 0
fi
local src_cols
src_cols=$(table_columns_with_types "$DB_SRC" "$table")
local nas_cols
nas_cols=$(table_columns "$NAS_DB" "$table")
local added=0
local added_names=""
while IFS='|' read -r name type; do
[ -z "$name" ] && continue
# Use grep -F -x for fixed-string exact match (safe against regex chars).
if ! echo "$nas_cols" | grep -Fxq "$name"; then
# SQLite ALTER TABLE ADD COLUMN: type is optional, no NOT NULL allowed
# without a constant default. Default-NULL is exactly what we want for archive.
sqlite3 "$NAS_DB" "ALTER TABLE $table ADD COLUMN \"$name\" $type;"
added=$((added + 1))
added_names="$added_names $name"
fi
done <<< "$src_cols"
if [ "$added" -gt 0 ]; then
printf "✓ added %d:%s\n" "$added" "$added_names"
else
printf "✓ in sync\n"
fi
}
# Echoes a comma-separated list of source columns for a table, double-quoted
# so reserved words and hyphens are safe. Used for both INSERT and SELECT sides.
build_col_list() {
local table="$1"
table_columns "$DB_SRC" "$table" | awk 'NF' | sed 's/.*/"&"/' | paste -sd, -
}
# ──────────────────────────────────────────────────────────────────────────────
# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────
if [ "${1:-}" = "today" ]; then
TARGET_DATE=$(date +%Y-%m-%d)
elif [ -n "${1:-}" ]; then
TARGET_DATE="$1"
if ! [[ "$TARGET_DATE" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then
echo "ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday."
exit 1
fi
else
TARGET_DATE=$(date -v-1d +%Y-%m-%d)
fi
log "========================================"
log "Screenpipe sync starting for: $TARGET_DATE"
log "========================================"
# ─── PREFLIGHT ────────────────────────────────────────────────────────────────
step "Preflight checks"
if [ ! -f "$DB_SRC" ]; then
log "ERROR: Source DB not found at $DB_SRC"; exit 1
fi
printf " %-20s %s (%s)\n" "Source DB:" "OK" "$(du -sh "$DB_SRC" | cut -f1)"
if [ ! -d "$NAS_MOUNT" ]; then
log "ERROR: NAS not mounted at $NAS_MOUNT"; exit 1
fi
printf " %-20s %s\n" "NAS mount:" "OK $NAS_MOUNT"
# Check if DB already synced for this date
DB_ALREADY_SYNCED=false
if [ -f "$NAS_DB" ]; then
if table_exists "$NAS_DB" "frames"; then
EXISTING=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';" 2>/dev/null || echo "0")
if [ "$EXISTING" -gt "0" ]; then
log "Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync"
DB_ALREADY_SYNCED=true
else
printf " %-20s %s (%s)\n" "Archive DB:" "exists" "$(du -sh "$NAS_DB" | cut -f1)"
fi
else
printf " %-20s %s\n" "Archive DB:" "exists, no frames table yet"
fi
else
printf " %-20s %s\n" "Archive DB:" "will be created"
fi
# Source data dir for this date
DATA_SRC="$HOME/.screenpipe/data/data/$TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
DATA_SIZE=$(du -sh "$DATA_SRC" | cut -f1)
DATA_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
printf " %-20s %s (%s files, %s)\n" "Data dir:" "OK" "$DATA_FILES" "$DATA_SIZE"
else
printf " %-20s %s\n" "Data dir:" "not found — skipping file copy"
fi
# ─── DB SYNC ──────────────────────────────────────────────────────────────────
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────
step "Counting source rows for $TARGET_DATE"
SRC_FRAMES=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
SRC_ELEMENTS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_UI=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
SRC_OCR=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_MEETINGS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';")
printf " %-20s %s\n" "frames:" "$SRC_FRAMES"
printf " %-20s %s\n" "elements:" "$SRC_ELEMENTS"
printf " %-20s %s\n" "ui_events:" "$SRC_UI"
printf " %-20s %s\n" "ocr_text:" "$SRC_OCR"
printf " %-20s %s\n" "meetings:" "$SRC_MEETINGS"
if [ "$SRC_FRAMES" -eq "0" ]; then
log "No frames found for $TARGET_DATE — skipping DB sync"
DB_ALREADY_SYNCED=true
fi
fi
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── INIT TABLES ──────────────────────────────────────────────────────────
step "Initialising tables (CREATE IF NOT EXISTS)"
run_sqlite_heredoc "creating tables" "
ATTACH '$NAS_DB' AS nas;
CREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;
CREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;
CREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;
CREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;
DETACH nas;
"
# ─── SCHEMA DRIFT FIX ─────────────────────────────────────────────────────
# Runs AFTER CREATE IF NOT EXISTS so newly-created tables are no-ops here,
# and pre-existing tables get any missing columns added.
step "Reconciling NAS schema with source"
for tbl in "${SYNC_TABLES[@]}"; do
ensure_columns "$tbl"
done
run_sqlite_heredoc "creating indexes" "
ATTACH '$NAS_DB' AS nas;
CREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);
CREATE INDEX IF NOT EXISTS nas.idx_frames_document_path ON frames(document_path) WHERE document_path IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_elements_onscreen_frame ON elements(frame_id) WHERE on_screen = 1 AND text IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);
CREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);
DETACH nas;
"
run_sqlite_heredoc "creating FTS tables" "
ATTACH '$NAS_DB' AS nas;
CREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(
text, role, frame_id UNINDEXED,
content='elements', content_rowid='id', tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(
full_text, app_name, window_name, browser_url, id UNINDEXED,
tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(
text_content,
app_name,
window_title,
element_name,
content='ui_events',
content_rowid='id',
tokenize='unicode61'
);
DETACH nas;
"
# ─── BUILD EXPLICIT COLUMN LISTS ──────────────────────────────────────────
# After ensure_columns, source ⊆ NAS for every synced table, so source's
# column list is a safe subset to use on both sides of the INSERT.
FRAMES_COLS=$(build_col_list frames)
ELEMENTS_COLS=$(build_col_list elements)
UI_EVENTS_COLS=$(build_col_list ui_events)
OCR_TEXT_COLS=$(build_col_list ocr_text)
VIDEO_CHUNKS_COLS=$(build_col_list video_chunks)
MEETINGS_COLS=$(build_col_list meetings)
# ─── SYNC DATA ────────────────────────────────────────────────────────────
step "Syncing data for $TARGET_DATE"
run_sqlite_heredoc "video_chunks" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.video_chunks ($VIDEO_CHUNKS_COLS)
SELECT $VIDEO_CHUNKS_COLS FROM main.video_chunks
WHERE id IN (
SELECT DISTINCT video_chunk_id FROM main.frames
WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL
);
DETACH nas;
"
run_sqlite_heredoc "frames ($SRC_FRAMES rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.frames ($FRAMES_COLS)
SELECT $FRAMES_COLS FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ocr_text ($SRC_OCR rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ocr_text ($OCR_TEXT_COLS)
SELECT $OCR_TEXT_COLS FROM main.ocr_text o
JOIN main.frames f ON o.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ui_events ($SRC_UI rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ui_events ($UI_EVENTS_COLS)
SELECT $UI_EVENTS_COLS FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "elements ($SRC_ELEMENTS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.elements ($ELEMENTS_COLS)
SELECT $ELEMENTS_COLS FROM main.elements e
JOIN main.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "meetings ($SRC_MEETINGS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.meetings ($MEETINGS_COLS)
SELECT $MEETINGS_COLS FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';
DETACH nas;
"
# NOTE: the elements/ocr_text inserts use unqualified column names while
# selecting from a JOIN. SQLite resolves them against the leftmost table
# that has the column, which is what we want here (e.* / o.* implicitly),
# because none of the column names collide with frames'.
# ─── FTS UPDATE ───────────────────────────────────────────────────────────
step "Updating FTS indexes"
run_sqlite_heredoc "elements_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.elements_fts(rowid, text, role)
SELECT e.id, e.text, e.role
FROM nas.elements e
JOIN nas.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE'
AND e.text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "frames_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)
SELECT id, full_text, app_name, window_name, browser_url, id
FROM nas.frames
WHERE date(timestamp) = '$TARGET_DATE'
AND full_text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "ui_events_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)
SELECT id, text_content, app_name, window_title, element_name
FROM nas.ui_events
WHERE date(timestamp) = '$TARGET_DATE'
AND text_content IS NOT NULL;
DETACH nas;
"
# ─── VERIFY DB ────────────────────────────────────────────────────────────
step "Verifying DB"
V_FRAMES=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
V_ELEMENTS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_UI=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
V_OCR=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_MEETINGS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';")
check "frames" "$V_FRAMES" "$SRC_FRAMES"
check "elements" "$V_ELEMENTS" "$SRC_ELEMENTS"
check "ui_events" "$V_UI" "$SRC_UI"
check "ocr_text" "$V_OCR" "$SRC_OCR"
check "meetings" "$V_MEETINGS" "$SRC_MEETINGS"
fi
# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────
# Always runs regardless of DB sync status
step "Copying data folder for $TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
mkdir -p "$NAS_DATA/$TARGET_DATE"
RSYNC_START=$(date +%s)
printf " %-36s " "rsync $TARGET_DATE/ → NAS"
rsync -a --ignore-existing \
"$DATA_SRC/" \
"$NAS_DATA/$TARGET_DATE/" \
2>>"$LOG_FILE"
RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))
COPIED_FILES=$(ls "$NAS_DATA/$TARGET_DATE" | wc -l | tr -d ' ')
SRC_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
COPIED_SIZE=$(du -sh "$NAS_DATA/$TARGET_DATE" | cut -f1)
if [ "$COPIED_FILES" -eq "$SRC_FILES" ]; then
printf "\r %-36s ✓ %dm%02ds (%s files, %s)\n" \
"rsync $TARGET_DATE/ → NAS" \
"$(( RSYNC_DUR / 60 ))" "$(( RSYNC_DUR % 60 ))" \
"$COPIED_FILES" "$COPIED_SIZE" | tee -a "$LOG_FILE"
else
printf "\r %-36s ✗ %s / %s files\n" \
"rsync $TARGET_DATE/ → NAS" "$COPIED_FILES" "$SRC_FILES" | tee -a "$LOG_FILE"
fi
else
printf " %-36s %s\n" "rsync $TARGET_DATE/ → NAS" "skipped (no source dir)"
fi
# ─── SUMMARY ──────────────────────────────────────────────────────────────────
TOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))
DB_SIZE=$(du -sh "$NAS_DB" | cut -f1)
echo ""
log "Archive DB size: $DB_SIZE"
log "Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s"
log "Sync complete for $TARGET_DATE"
log "========================================"
Implement and run pipe l…, Editor Group 2
Problems (⇧⌘M)
PROBLEMS
Output (⇧⌘U)
OUTPUT
Debug Console (⇧⌘Y)
DEBUG CONSOLE
Terminal (⌃`)
TERMINAL
Ports - 1 forwarded port
PORTS
1
remote SSH: nas
SSH: nas
screenpipe (Git) - master*, Checkout Branch/Tag...
master*
screenpipe (Git) - Synchronize Changes
No Problems
0
0
Forwarded Ports: 8766
1
Notifications
Sign In
Sign In
No results found
Implement and run pipe logic
Session history
New session
Message actions
main.py
main.py
lets implement logic with pipes. how can I run it?
Thinking
Thinking
Let me look at the current project structure to understand what's already in place.
Bash
List project files
IN
find /volume1/screenpipe -type f | head -50 && echo "---" && ls /volume1/screenpipe
Copy code to clipboard
OUT
/volume1/screenpipe/.DS_Store
/volume1/screenpipe/screenpipe.db
/volume1/screenpipe/screenpipe_sync.sh
/volume1/screenpipe/app_settings.json
/volume1/screenpipe/.gitignore
/volume1/screenpipe/archive.db
/volume1/screenpipe/db.sqlite
/volume1/screenpipe/db.sqlite-wal
/volume1/screenpipe/db.sqlite-shm
/volume1/screenpipe/#recycle/desktop.ini
/volume1/screenpipe/#recycle/db.sqlite
/volume1/screenpipe/#recycle/Copy #1 of db.sqlite
/volume1/screenpipe/#recycle/.DS_Store
/volume1/screenpipe/#recycle/Copy #2 of db.sqlite
/volume1/screenpipe/#recycle/archive.db
/volume1/screenpipe/#recycle/Copy #1 of archive.db
/volume1/screenpipe/#recycle/Copy #2 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of archive.db
/volume1/screenpipe/#recycle/Copy #4 of archive.db
/volume1/screenpipe/#recycle/Copy #5 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of db.sqlite
/volume1/screenpipe/#recycle/Copy #4 of db.sqlite
/volume1/screenpipe/#recycle/Copy #6 of archive.db
/volume1/screenpipe/#recycle/test.txt
/volume1/screenpipe/#recycle/Copy #7 of archive.db
/volume1/screenpipe/#recycle/Copy #8 of archive.db
/volume1/screenpipe/#recycle/archive.db-journal
/volume1/screenpipe/#recycle/Copy #1 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #2 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #3 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #4 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #6 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #7 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of db.sqlite
/volume1/screenpipe/pipes/.DS_Store
/volume1/screenpipe/app/.env
/volume1/screenpipe/app/cli.py
/volume1/screenpipe/app/.DS_Store
/volume1/screenpipe/app/db.py
/volume1/screenpipe/app/docker-compose.yml
/volume1/screenpipe/app/main.py
/volume1/screenpipe/app/requirements.txt
/volume1/screenpipe/app/Dockerfile
/volume1/screenpipe/data/.DS_Store
/volume1/screenpipe/.git/description
/volume1/screenpipe/.git/HEAD
/volume1/screenpipe/.git/index
/volume1/screenpipe/.git/COMMIT_EDITMSG
/volume1/screenpipe/#recycle/data/.DS_Store
---
app
app_settings.json
archive.db
data
db.sqlite
db.sqlite-shm
db.sqlite-wal
pipes
#recycle
screenpipe.db
screenpipe_sync.sh
Read
main.py
main.py
Bash
Check pipes directory and docker-compose
IN
ls /volume1/screenpipe/pipes/ && ls /volume1/screenpipe/app/ && cat /volume1/screenpipe/app/docker-compose.yml
Copy code to clipboard...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
21116
|
923
|
19
|
2026-05-11T17:12:57.554174+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-11/1778 /Users/lukas/.screenpipe/data/data/2026-05-11/1778519577554_m2.jpg...
|
Code
|
screenpipe_sync_updated.sh — screenpipe [SSH: nas] screenpipe_sync_updated.sh — screenpipe [SSH: nas] — Untracked...
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Explorer (⇧⌘E) - 1 unsaved file
1
Search (⇧⌘F)
Explorer (⇧⌘E) - 1 unsaved file
1
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py
M
db.py
docker-compose.yml
Dockerfile
M
main.py
M
requirements.txt
M
data
logs
pipes
.gitignore
app_settings.json
archive.db
archive.db-bak
U
db.sqlite
db.sqlite-shm
db.sqlite-wal
screenpipe_sync_updated.sh
U
screenpipe_sync.sh
screenpipe.db
Outline Section
OUTLINE
OUTLINE
Timeline Section
TIMELINE
TIMELINE
app_settings.json, Editor Group 1
screenpipe_sync.sh, Editor Group 1
screenpipe_sync_updated.sh, preview, Editor Group 1
pipe.md, Editor Group 1
.env, Editor Group 1
#!/bin/bash
# screenpipe_sync.sh
# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).
# Also copies the day's video/frame data folder to the NAS.
#
# Schema-drift tolerant: if Screenpipe migrations add new columns to the source DB,
# the NAS archive gets ALTER TABLE'd to match. Inserts use explicit column lists,
# so positional mismatches can't occur.
#
# Usage:
# ./screenpipe_sync.sh # syncs yesterday (default)
# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date
# ./screenpipe_sync.sh today # syncs today so far
#
# Cron example (runs at 3am daily):
# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1
set -euo pipefail
# ─── CONFIG ───────────────────────────────────────────────────────────────────
DB_SRC="${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}"
NAS_MOUNT="${NAS_MOUNT:-/Volumes/screenpipe}"
NAS_DB="$NAS_MOUNT/archive.db"
NAS_DATA="$NAS_MOUNT/data"
LOG_FILE="$HOME/.screenpipe/sync.log"
# Tables that get schema drift handling. Order matters for FK-ish references
# (parents before children: video_chunks → frames → elements/ocr_text/ui_events).
SYNC_TABLES=(video_chunks frames elements ocr_text ui_events meetings)
# ──────────────────────────────────────────────────────────────────────────────
# ─── HELPERS ──────────────────────────────────────────────────────────────────
SCRIPT_START=$(date +%s)
log() {
local msg="[$(date '+%Y-%m-%d %H:%M:%S')] $*"
echo "$msg" | tee -a "$LOG_FILE"
}
step() {
local now=$(date +%s)
local elapsed=$(( now - SCRIPT_START ))
local min=$(( elapsed / 60 ))
local sec=$(( elapsed % 60 ))
printf "\n[+%02dm%02ds] ▶ %s\n" "$min" "$sec" "$*" | tee -a "$LOG_FILE"
}
run_sqlite_heredoc() {
local label="$1"
local sql="$2"
local start=$(date +%s)
printf " %-36s " "$label"
sqlite3 "$DB_SRC" <<< "$sql" &
local pid=$!
local spin=[PASSWORD] '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')
local i=0
while kill -0 "$pid" 2>/dev/null; do
printf "\r %-36s %s " "$label" "${spin[$i]}"
i=$(( (i + 1) % 10 ))
sleep 0.2
done
wait "$pid"
local rc=$?
if [ $rc -ne 0 ]; then
printf "\r %-36s ✗ FAILED\n" "$label" | tee -a "$LOG_FILE"
exit $rc
fi
local dur=$(( $(date +%s) - start ))
printf "\r %-36s ✓ %dm%02ds\n" "$label" "$(( dur / 60 ))" "$(( dur % 60 ))" | tee -a "$LOG_FILE"
}
check() {
local label="$1" got="$2" expected="$3"
if [ "$got" -eq "$expected" ]; then
printf " %-20s %s / %s ✓\n" "$label:" "$got" "$expected"
else
printf " %-20s %s / %s ✗ MISMATCH\n" "$label:" "$got" "$expected"
fi
}
# ─── SCHEMA HELPERS ───────────────────────────────────────────────────────────
# Echoes "name|type" lines for a table from a given DB.
table_columns_with_types() {
local db="$1" table="$2"
sqlite3 "$db" "PRAGMA table_info($table);" | awk -F'|' '{print $2 "|" $3}'
}
# Echoes just column names, one per line.
table_columns() {
local db="$1" table="$2"
sqlite3 "$db" "PRAGMA table_info($table);" | awk -F'|' '{print $2}'
}
# Returns true (0) if a table exists in the given DB.
table_exists() {
local db="$1" table="$2"
local count
count=$(sqlite3 "$db" "SELECT COUNT(*) FROM sqlite_master WHERE type='table' AND name='$table';")
[ "$count" -gt 0 ]
}
# Adds any columns present in source but missing in NAS for the given table.
# Uses ALTER TABLE ADD COLUMN, which is a fast metadata-only operation in SQLite.
ensure_columns() {
local table="$1"
local label="schema: $table"
printf " %-36s " "$label"
if ! table_exists "$DB_SRC" "$table"; then
printf "✗ source missing — skipping\n"
return 0
fi
if ! table_exists "$NAS_DB" "$table"; then
printf "✓ fresh (created above)\n"
return 0
fi
local src_cols
src_cols=$(table_columns_with_types "$DB_SRC" "$table")
local nas_cols
nas_cols=$(table_columns "$NAS_DB" "$table")
local added=0
local added_names=""
while IFS='|' read -r name type; do
[ -z "$name" ] && continue
# Use grep -F -x for fixed-string exact match (safe against regex chars).
if ! echo "$nas_cols" | grep -Fxq "$name"; then
# SQLite ALTER TABLE ADD COLUMN: type is optional, no NOT NULL allowed
# without a constant default. Default-NULL is exactly what we want for archive.
sqlite3 "$NAS_DB" "ALTER TABLE $table ADD COLUMN \"$name\" $type;"
added=$((added + 1))
added_names="$added_names $name"
fi
done <<< "$src_cols"
if [ "$added" -gt 0 ]; then
printf "✓ added %d:%s\n" "$added" "$added_names"
else
printf "✓ in sync\n"
fi
}
# Echoes a comma-separated list of source columns for a table, double-quoted
# so reserved words and hyphens are safe. Used for both INSERT and SELECT sides.
build_col_list() {
local table="$1"
table_columns "$DB_SRC" "$table" | awk 'NF' | sed 's/.*/"&"/' | paste -sd, -
}
# ──────────────────────────────────────────────────────────────────────────────
# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────
if [ "${1:-}" = "today" ]; then
TARGET_DATE=$(date +%Y-%m-%d)
elif [ -n "${1:-}" ]; then
TARGET_DATE="$1"
if ! [[ "$TARGET_DATE" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then
echo "ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday."
exit 1
fi
else
TARGET_DATE=$(date -v-1d +%Y-%m-%d)
fi
log "========================================"
log "Screenpipe sync starting for: $TARGET_DATE"
log "========================================"
# ─── PREFLIGHT ────────────────────────────────────────────────────────────────
step "Preflight checks"
if [ ! -f "$DB_SRC" ]; then
log "ERROR: Source DB not found at $DB_SRC"; exit 1
fi
printf " %-20s %s (%s)\n" "Source DB:" "OK" "$(du -sh "$DB_SRC" | cut -f1)"
if [ ! -d "$NAS_MOUNT" ]; then
log "ERROR: NAS not mounted at $NAS_MOUNT"; exit 1
fi
printf " %-20s %s\n" "NAS mount:" "OK $NAS_MOUNT"
# Check if DB already synced for this date
DB_ALREADY_SYNCED=false
if [ -f "$NAS_DB" ]; then
if table_exists "$NAS_DB" "frames"; then
EXISTING=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';" 2>/dev/null || echo "0")
if [ "$EXISTING" -gt "0" ]; then
log "Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync"
DB_ALREADY_SYNCED=true
else
printf " %-20s %s (%s)\n" "Archive DB:" "exists" "$(du -sh "$NAS_DB" | cut -f1)"
fi
else
printf " %-20s %s\n" "Archive DB:" "exists, no frames table yet"
fi
else
printf " %-20s %s\n" "Archive DB:" "will be created"
fi
# Source data dir for this date
DATA_SRC="$HOME/.screenpipe/data/data/$TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
DATA_SIZE=$(du -sh "$DATA_SRC" | cut -f1)
DATA_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
printf " %-20s %s (%s files, %s)\n" "Data dir:" "OK" "$DATA_FILES" "$DATA_SIZE"
else
printf " %-20s %s\n" "Data dir:" "not found — skipping file copy"
fi
# ─── DB SYNC ──────────────────────────────────────────────────────────────────
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────
step "Counting source rows for $TARGET_DATE"
SRC_FRAMES=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
SRC_ELEMENTS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_UI=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
SRC_OCR=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_MEETINGS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';")
printf " %-20s %s\n" "frames:" "$SRC_FRAMES"
printf " %-20s %s\n" "elements:" "$SRC_ELEMENTS"
printf " %-20s %s\n" "ui_events:" "$SRC_UI"
printf " %-20s %s\n" "ocr_text:" "$SRC_OCR"
printf " %-20s %s\n" "meetings:" "$SRC_MEETINGS"
if [ "$SRC_FRAMES" -eq "0" ]; then
log "No frames found for $TARGET_DATE — skipping DB sync"
DB_ALREADY_SYNCED=true
fi
fi
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── INIT TABLES ──────────────────────────────────────────────────────────
step "Initialising tables (CREATE IF NOT EXISTS)"
run_sqlite_heredoc "creating tables" "
ATTACH '$NAS_DB' AS nas;
CREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;
CREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;
CREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;
CREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;
DETACH nas;
"
# ─── SCHEMA DRIFT FIX ─────────────────────────────────────────────────────
# Runs AFTER CREATE IF NOT EXISTS so newly-created tables are no-ops here,
# and pre-existing tables get any missing columns added.
step "Reconciling NAS schema with source"
for tbl in "${SYNC_TABLES[@]}"; do
ensure_columns "$tbl"
done
run_sqlite_heredoc "creating indexes" "
ATTACH '$NAS_DB' AS nas;
CREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);
CREATE INDEX IF NOT EXISTS nas.idx_frames_document_path ON frames(document_path) WHERE document_path IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_elements_onscreen_frame ON elements(frame_id) WHERE on_screen = 1 AND text IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);
CREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);
DETACH nas;
"
run_sqlite_heredoc "creating FTS tables" "
ATTACH '$NAS_DB' AS nas;
CREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(
text, role, frame_id UNINDEXED,
content='elements', content_rowid='id', tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(
full_text, app_name, window_name, browser_url, id UNINDEXED,
tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(
text_content,
app_name,
window_title,
element_name,
content='ui_events',
content_rowid='id',
tokenize='unicode61'
);
DETACH nas;
"
# ─── BUILD EXPLICIT COLUMN LISTS ──────────────────────────────────────────
# After ensure_columns, source ⊆ NAS for every synced table, so source's
# column list is a safe subset to use on both sides of the INSERT.
FRAMES_COLS=$(build_col_list frames)
ELEMENTS_COLS=$(build_col_list elements)
UI_EVENTS_COLS=$(build_col_list ui_events)
OCR_TEXT_COLS=$(build_col_list ocr_text)
VIDEO_CHUNKS_COLS=$(build_col_list video_chunks)
MEETINGS_COLS=$(build_col_list meetings)
# ─── SYNC DATA ────────────────────────────────────────────────────────────
step "Syncing data for $TARGET_DATE"
run_sqlite_heredoc "video_chunks" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.video_chunks ($VIDEO_CHUNKS_COLS)
SELECT $VIDEO_CHUNKS_COLS FROM main.video_chunks
WHERE id IN (
SELECT DISTINCT video_chunk_id FROM main.frames
WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL
);
DETACH nas;
"
run_sqlite_heredoc "frames ($SRC_FRAMES rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.frames ($FRAMES_COLS)
SELECT $FRAMES_COLS FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ocr_text ($SRC_OCR rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ocr_text ($OCR_TEXT_COLS)
SELECT $OCR_TEXT_COLS FROM main.ocr_text o
JOIN main.frames f ON o.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ui_events ($SRC_UI rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ui_events ($UI_EVENTS_COLS)
SELECT $UI_EVENTS_COLS FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "elements ($SRC_ELEMENTS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.elements ($ELEMENTS_COLS)
SELECT $ELEMENTS_COLS FROM main.elements e
JOIN main.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "meetings ($SRC_MEETINGS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.meetings ($MEETINGS_COLS)
SELECT $MEETINGS_COLS FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';
DETACH nas;
"
# NOTE: the elements/ocr_text inserts use unqualified column names while
# selecting from a JOIN. SQLite resolves them against the leftmost table
# that has the column, which is what we want here (e.* / o.* implicitly),
# because none of the column names collide with frames'.
# ─── FTS UPDATE ───────────────────────────────────────────────────────────
step "Updating FTS indexes"
run_sqlite_heredoc "elements_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.elements_fts(rowid, text, role)
SELECT e.id, e.text, e.role
FROM nas.elements e
JOIN nas.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE'
AND e.text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "frames_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)
SELECT id, full_text, app_name, window_name, browser_url, id
FROM nas.frames
WHERE date(timestamp) = '$TARGET_DATE'
AND full_text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "ui_events_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)
SELECT id, text_content, app_name, window_title, element_name
FROM nas.ui_events
WHERE date(timestamp) = '$TARGET_DATE'
AND text_content IS NOT NULL;
DETACH nas;
"
# ─── VERIFY DB ────────────────────────────────────────────────────────────
step "Verifying DB"
V_FRAMES=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
V_ELEMENTS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_UI=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
V_OCR=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_MEETINGS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';")
check "frames" "$V_FRAMES" "$SRC_FRAMES"
check "elements" "$V_ELEMENTS" "$SRC_ELEMENTS"
check "ui_events" "$V_UI" "$SRC_UI"
check "ocr_text" "$V_OCR" "$SRC_OCR"
check "meetings" "$V_MEETINGS" "$SRC_MEETINGS"
fi
# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────
# Always runs regardless of DB sync status
step "Copying data folder for $TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
mkdir -p "$NAS_DATA/$TARGET_DATE"
RSYNC_START=$(date +%s)
printf " %-36s " "rsync $TARGET_DATE/ → NAS"
rsync -a --ignore-existing \
"$DATA_SRC/" \
"$NAS_DATA/$TARGET_DATE/" \
2>>"$LOG_FILE"
RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))
COPIED_FILES=$(ls "$NAS_DATA/$TARGET_DATE" | wc -l | tr -d ' ')
SRC_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
COPIED_SIZE=$(du -sh "$NAS_DATA/$TARGET_DATE" | cut -f1)
if [ "$COPIED_FILES" -eq "$SRC_FILES" ]; then
printf "\r %-36s ✓ %dm%02ds (%s files, %s)\n" \
"rsync $TARGET_DATE/ → NAS" \
"$(( RSYNC_DUR / 60 ))" "$(( RSYNC_DUR % 60 ))" \
"$COPIED_FILES" "$COPIED_SIZE" | tee -a "$LOG_FILE"
else
printf "\r %-36s ✗ %s / %s files\n" \
"rsync $TARGET_DATE/ → NAS" "$COPIED_FILES" "$SRC_FILES" | tee -a "$LOG_FILE"
fi
else
printf " %-36s %s\n" "rsync $TARGET_DATE/ → NAS" "skipped (no source dir)"
fi
# ─── SUMMARY ──────────────────────────────────────────────────────────────────
TOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))
DB_SIZE=$(du -sh "$NAS_DB" | cut -f1)
echo ""
log "Archive DB size: $DB_SIZE"
log "Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s"
log "Sync complete for $TARGET_DATE"
log "========================================"
#!/bin/bash
# screenpipe_sync.sh
# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).
# Also copies the day's video/frame data folder to the NAS.
#
# Schema-drift tolerant: if Screenpipe migrations add new columns to the source DB,
# the NAS archive gets ALTER TABLE'd to match. Inserts use explicit column lists,
# so positional mismatches can't occur.
#
# Usage:
# ./screenpipe_sync.sh # syncs yesterday (default)
# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date
# ./screenpipe_sync.sh today # syncs today so far
#
# Cron example (runs at 3am daily):
# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1
set -euo pipefail
# ─── CONFIG ───────────────────────────────────────────────────────────────────
DB_SRC="${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}"
NAS_MOUNT="${NAS_MOUNT:-/Volumes/screenpipe}"
NAS_DB="$NAS_MOUNT/archive.db"
NAS_DATA="$NAS_MOUNT/data"
LOG_FILE="$HOME/.screenpipe/sync.log"
# Tables that get schema drift handling. Order matters for FK-ish references
# (parents before children: video_chunks → frames → elements/ocr_text/ui_events).
SYNC_TABLES=(video_chunks frames elements ocr_text ui_events meetings)
# ──────────────────────────────────────────────────────────────────────────────
# ─── HELPERS ──────────────────────────────────────────────────────────────────
SCRIPT_START=$(date +%s)
log() {
local msg="[$(date '+%Y-%m-%d %H:%M:%S')] $*"
echo "$msg" | tee -a "$LOG_FILE"
}
step() {
local now=$(date +%s)
local elapsed=$(( now - SCRIPT_START ))
local min=$(( elapsed / 60 ))
local sec=$(( elapsed % 60 ))
printf "\n[+%02dm%02ds] ▶ %s\n" "$min" "$sec" "$*" | tee -a "$LOG_FILE"
}
run_sqlite_heredoc() {
local label="$1"
local sql="$2"
local start=$(date +%s)
printf " %-36s " "$label"
sqlite3 "$DB_SRC" <<< "$sql" &
local pid=$!
local spin=[PASSWORD] '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')
local i=0
while kill -0 "$pid" 2>/dev/null; do
printf "\r %-36s %s " "$label" "${spin[$i]}"
i=$(( (i + 1) % 10 ))
sleep 0.2
done
wait "$pid"
local rc=$?
if [ $rc -ne 0 ]; then
printf "\r %-36s ✗ FAILED\n" "$label" | tee -a "$LOG_FILE"
exit $rc
fi
local dur=$(( $(date +%s) - start ))
printf "\r %-36s ✓ %dm%02ds\n" "$label" "$(( dur / 60 ))" "$(( dur % 60 ))" | tee -a "$LOG_FILE"
}
check() {
local label="$1" got="$2" expected="$3"
if [ "$got" -eq "$expected" ]; then
printf " %-20s %s / %s ✓\n" "$label:" "$got" "$expected"
else
printf " %-20s %s / %s ✗ MISMATCH\n" "$label:" "$got" "$expected"
fi
}
# ─── SCHEMA HELPERS ───────────────────────────────────────────────────────────
# Echoes "name|type" lines for a table from a given DB.
table_columns_with_types() {
local db="$1" table="$2"
sqlite3 "$db" "PRAGMA table_info($table);" | awk -F'|' '{print $2 "|" $3}'
}
# Echoes just column names, one per line.
table_columns() {
local db="$1" table="$2"
sqlite3 "$db" "PRAGMA table_info($table);" | awk -F'|' '{print $2}'
}
# Returns true (0) if a table exists in the given DB.
table_exists() {
local db="$1" table="$2"
local count
count=$(sqlite3 "$db" "SELECT COUNT(*) FROM sqlite_master WHERE type='table' AND name='$table';")
[ "$count" -gt 0 ]
}
# Adds any columns present in source but missing in NAS for the given table.
# Uses ALTER TABLE ADD COLUMN, which is a fast metadata-only operation in SQLite.
ensure_columns() {
local table="$1"
local label="schema: $table"
printf " %-36s " "$label"
if ! table_exists "$DB_SRC" "$table"; then
printf "✗ source missing — skipping\n"
return 0
fi
if ! table_exists "$NAS_DB" "$table"; then
printf "✓ fresh (created above)\n"
return 0
fi
local src_cols
src_cols=$(table_columns_with_types "$DB_SRC" "$table")
local nas_cols
nas_cols=$(table_columns "$NAS_DB" "$table")
local added=0
local added_names=""
while IFS='|' read -r name type; do
[ -z "$name" ] && continue
# Use grep -F -x for fixed-string exact match (safe against regex chars).
if ! echo "$nas_cols" | grep -Fxq "$name"; then
# SQLite ALTER TABLE ADD COLUMN: type is optional, no NOT NULL allowed
# without a constant default. Default-NULL is exactly what we want for archive.
sqlite3 "$NAS_DB" "ALTER TABLE $table ADD COLUMN \"$name\" $type;"
added=$((added + 1))
added_names="$added_names $name"
fi
done <<< "$src_cols"
if [ "$added" -gt 0 ]; then
printf "✓ added %d:%s\n" "$added" "$added_names"
else
printf "✓ in sync\n"
fi
}
# Echoes a comma-separated list of source columns for a table, double-quoted
# so reserved words and hyphens are safe. Used for both INSERT and SELECT sides.
build_col_list() {
local table="$1"
table_columns "$DB_SRC" "$table" | awk 'NF' | sed 's/.*/"&"/' | paste -sd, -
}
# ──────────────────────────────────────────────────────────────────────────────
# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────
if [ "${1:-}" = "today" ]; then
TARGET_DATE=$(date +%Y-%m-%d)
elif [ -n "${1:-}" ]; then
TARGET_DATE="$1"
if ! [[ "$TARGET_DATE" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then
echo "ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday."
exit 1
fi
else
TARGET_DATE=$(date -v-1d +%Y-%m-%d)
fi
log "========================================"
log "Screenpipe sync starting for: $TARGET_DATE"
log "========================================"
# ─── PREFLIGHT ────────────────────────────────────────────────────────────────
step "Preflight checks"
if [ ! -f "$DB_SRC" ]; then
log "ERROR: Source DB not found at $DB_SRC"; exit 1
fi
printf " %-20s %s (%s)\n" "Source DB:" "OK" "$(du -sh "$DB_SRC" | cut -f1)"
if [ ! -d "$NAS_MOUNT" ]; then
log "ERROR: NAS not mounted at $NAS_MOUNT"; exit 1
fi
printf " %-20s %s\n" "NAS mount:" "OK $NAS_MOUNT"
# Check if DB already synced for this date
DB_ALREADY_SYNCED=false
if [ -f "$NAS_DB" ]; then
if table_exists "$NAS_DB" "frames"; then
EXISTING=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';" 2>/dev/null || echo "0")
if [ "$EXISTING" -gt "0" ]; then
log "Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync"
DB_ALREADY_SYNCED=true
else
printf " %-20s %s (%s)\n" "Archive DB:" "exists" "$(du -sh "$NAS_DB" | cut -f1)"
fi
else
printf " %-20s %s\n" "Archive DB:" "exists, no frames table yet"
fi
else
printf " %-20s %s\n" "Archive DB:" "will be created"
fi
# Source data dir for this date
DATA_SRC="$HOME/.screenpipe/data/data/$TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
DATA_SIZE=$(du -sh "$DATA_SRC" | cut -f1)
DATA_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
printf " %-20s %s (%s files, %s)\n" "Data dir:" "OK" "$DATA_FILES" "$DATA_SIZE"
else
printf " %-20s %s\n" "Data dir:" "not found — skipping file copy"
fi
# ─── DB SYNC ──────────────────────────────────────────────────────────────────
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────
step "Counting source rows for $TARGET_DATE"
SRC_FRAMES=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
SRC_ELEMENTS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_UI=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
SRC_OCR=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_MEETINGS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';")
printf " %-20s %s\n" "frames:" "$SRC_FRAMES"
printf " %-20s %s\n" "elements:" "$SRC_ELEMENTS"
printf " %-20s %s\n" "ui_events:" "$SRC_UI"
printf " %-20s %s\n" "ocr_text:" "$SRC_OCR"
printf " %-20s %s\n" "meetings:" "$SRC_MEETINGS"
if [ "$SRC_FRAMES" -eq "0" ]; then
log "No frames found for $TARGET_DATE — skipping DB sync"
DB_ALREADY_SYNCED=true
fi
fi
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── INIT TABLES ──────────────────────────────────────────────────────────
step "Initialising tables (CREATE IF NOT EXISTS)"
run_sqlite_heredoc "creating tables" "
ATTACH '$NAS_DB' AS nas;
CREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;
CREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;
CREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;
CREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;
DETACH nas;
"
# ─── SCHEMA DRIFT FIX ─────────────────────────────────────────────────────
# Runs AFTER CREATE IF NOT EXISTS so newly-created tables are no-ops here,
# and pre-existing tables get any missing columns added.
step "Reconciling NAS schema with source"
for tbl in "${SYNC_TABLES[@]}"; do
ensure_columns "$tbl"
done
run_sqlite_heredoc "creating indexes" "
ATTACH '$NAS_DB' AS nas;
CREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);
CREATE INDEX IF NOT EXISTS nas.idx_frames_document_path ON frames(document_path) WHERE document_path IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_elements_onscreen_frame ON elements(frame_id) WHERE on_screen = 1 AND text IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);
CREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);
DETACH nas;
"
run_sqlite_heredoc "creating FTS tables" "
ATTACH '$NAS_DB' AS nas;
CREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(
text, role, frame_id UNINDEXED,
content='elements', content_rowid='id', tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(
full_text, app_name, window_name, browser_url, id UNINDEXED,
tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(
text_content,
app_name,
window_title,
element_name,
content='ui_events',
content_rowid='id',
tokenize='unicode61'
);
DETACH nas;
"
# ─── BUILD EXPLICIT COLUMN LISTS ──────────────────────────────────────────
# After ensure_columns, source ⊆ NAS for every synced table, so source's
# column list is a safe subset to use on both sides of the INSERT.
FRAMES_COLS=$(build_col_list frames)
ELEMENTS_COLS=$(build_col_list elements)
UI_EVENTS_COLS=$(build_col_list ui_events)
OCR_TEXT_COLS=$(build_col_list ocr_text)
VIDEO_CHUNKS_COLS=$(build_col_list video_chunks)
MEETINGS_COLS=$(build_col_list meetings)
# ─── SYNC DATA ────────────────────────────────────────────────────────────
step "Syncing data for $TARGET_DATE"
run_sqlite_heredoc "video_chunks" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.video_chunks ($VIDEO_CHUNKS_COLS)
SELECT $VIDEO_CHUNKS_COLS FROM main.video_chunks
WHERE id IN (
SELECT DISTINCT video_chunk_id FROM main.frames
WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL
);
DETACH nas;
"
run_sqlite_heredoc "frames ($SRC_FRAMES rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.frames ($FRAMES_COLS)
SELECT $FRAMES_COLS FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ocr_text ($SRC_OCR rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ocr_text ($OCR_TEXT_COLS)
SELECT $OCR_TEXT_COLS FROM main.ocr_text o
JOIN main.frames f ON o.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ui_events ($SRC_UI rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ui_events ($UI_EVENTS_COLS)
SELECT $UI_EVENTS_COLS FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "elements ($SRC_ELEMENTS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.elements ($ELEMENTS_COLS)
SELECT $ELEMENTS_COLS FROM main.elements e
JOIN main.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "meetings ($SRC_MEETINGS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.meetings ($MEETINGS_COLS)
SELECT $MEETINGS_COLS FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';
DETACH nas;
"
# NOTE: the elements/ocr_text inserts use unqualified column names while
# selecting from a JOIN. SQLite resolves them against the leftmost table
# that has the column, which is what we want here (e.* / o.* implicitly),
# because none of the column names collide with frames'.
# ─── FTS UPDATE ───────────────────────────────────────────────────────────
step "Updating FTS indexes"
run_sqlite_heredoc "elements_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.elements_fts(rowid, text, role)
SELECT e.id, e.text, e.role
FROM nas.elements e
JOIN nas.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE'
AND e.text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "frames_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)
SELECT id, full_text, app_name, window_name, browser_url, id
FROM nas.frames
WHERE date(timestamp) = '$TARGET_DATE'
AND full_text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "ui_events_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)
SELECT id, text_content, app_name, window_title, element_name
FROM nas.ui_events
WHERE date(timestamp) = '$TARGET_DATE'
AND text_content IS NOT NULL;
DETACH nas;
"
# ─── VERIFY DB ────────────────────────────────────────────────────────────
step "Verifying DB"
V_FRAMES=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
V_ELEMENTS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_UI=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
V_OCR=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_MEETINGS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';")
check "frames" "$V_FRAMES" "$SRC_FRAMES"
check "elements" "$V_ELEMENTS" "$SRC_ELEMENTS"
check "ui_events" "$V_UI" "$SRC_UI"
check "ocr_text" "$V_OCR" "$SRC_OCR"
check "meetings" "$V_MEETINGS" "$SRC_MEETINGS"
fi
# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────
# Always runs regardless of DB sync status
step "Copying data folder for $TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
mkdir -p "$NAS_DATA/$TARGET_DATE"
RSYNC_START=$(date +%s)
printf " %-36s " "rsync $TARGET_DATE/ → NAS"
rsync -a --ignore-existing \
"$DATA_SRC/" \
"$NAS_DATA/$TARGET_DATE/" \
2>>"$LOG_FILE"
RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))
COPIED_FILES=$(ls "$NAS_DATA/$TARGET_DATE" | wc -l | tr -d ' ')
SRC_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
COPIED_SIZE=$(du -sh "$NAS_DATA/$TARGET_DATE" | cut -f1)
if [ "$COPIED_FILES" -eq "$SRC_FILES" ]; then
printf "\r %-36s ✓ %dm%02ds (%s files, %s)\n" \
"rsync $TARGET_DATE/ → NAS" \
"$(( RSYNC_DUR / 60 ))" "$(( RSYNC_DUR % 60 ))" \
"$COPIED_FILES" "$COPIED_SIZE" | tee -a "$LOG_FILE"
else
printf "\r %-36s ✗ %s / %s files\n" \
"rsync $TARGET_DATE/ → NAS" "$COPIED_FILES" "$SRC_FILES" | tee -a "$LOG_FILE"
fi
else
printf " %-36s %s\n" "rsync $TARGET_DATE/ → NAS" "skipped (no source dir)"
fi
# ─── SUMMARY ──────────────────────────────────────────────────────────────────
TOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))
DB_SIZE=$(du -sh "$NAS_DB" | cut -f1)
echo ""
log "Archive DB size: $DB_SIZE"
log "Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s"
log "Sync complete for $TARGET_DATE"
log "========================================"
Implement and run pipe l…, Editor Group 2
Problems (⇧⌘M)
PROBLEMS
Output (⇧⌘U)
OUTPUT
Debug Console (⇧⌘Y)
DEBUG CONSOLE
Terminal (⌃`)
TERMINAL
Ports - 1 forwarded port
PORTS
1
remote SSH: nas
SSH: nas
screenpipe (Git) - master*, Checkout Branch/Tag...
master*
screenpipe (Git) - Synchronize Changes
No Problems
0
0
Forwarded Ports: 8766
1
Notifications
Sign In
Sign In
No results found
Implement and run pipe logic...
|
[{"role":"AXRadioButton","text [{"role":"AXRadioButton","text":"Explorer (⇧⌘E) - 1 unsaved file","depth":19,"bounds":{"left":0.0,"top":0.047885075,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":true},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.057462092,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":22,"bounds":{"left":0.009640957,"top":0.06863528,"width":0.0016622341,"height":0.008778931},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Search (⇧⌘F)","depth":19,"bounds":{"left":0.0,"top":0.08619314,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.09577015,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Source Control (⌃⇧G) - 10 pending changes","depth":19,"bounds":{"left":0.0,"top":0.1245012,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.13407822,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"10","depth":22,"bounds":{"left":0.00831117,"top":0.1452514,"width":0.003656915,"height":0.008778931},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.00831117,"top":0.14604948,"width":0.0016622341,"height":0.007980846}},{"char_start":1,"char_count":1,"bounds":{"left":0.009973404,"top":0.14604948,"width":0.0023271276,"height":0.007980846}}],"role_description":"text"},{"role":"AXRadioButton","text":"Run and Debug (⇧⌘D)","depth":19,"bounds":{"left":0.0,"top":0.16280925,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.17238627,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Remote Explorer","depth":19,"bounds":{"left":0.0,"top":0.20111732,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.21069433,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Extensions (⇧⌘X) - 2 require update","depth":19,"bounds":{"left":0.0,"top":0.23942538,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.2490024,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"2","depth":22,"bounds":{"left":0.009640957,"top":0.2601756,"width":0.0019946808,"height":0.008778931},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Claude Code","depth":19,"bounds":{"left":0.0,"top":0.27773345,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"Containers","depth":19,"bounds":{"left":0.0,"top":0.3160415,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXHeading","text":"EXPLORER","depth":17,"bounds":{"left":0.022606382,"top":0.047885075,"width":0.018949468,"height":0.02793296},"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"EXPLORER","depth":18,"bounds":{"left":0.022606382,"top":0.056664005,"width":0.018949468,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.022606382,"top":0.056664005,"width":0.0023271276,"height":0.0103751}},{"char_start":1,"char_count":7,"bounds":{"left":0.024933511,"top":0.056664005,"width":0.01662234,"height":0.0103751}}],"role_description":"text"},{"role":"AXButton","text":"Explorer Section: screenpipe [SSH: nas]","depth":21,"bounds":{"left":0.015957447,"top":0.07581804,"width":0.09940159,"height":0.017557861},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":true},{"role":"AXStaticText","text":"","depth":23,"bounds":{"left":0.01662234,"top":0.07821229,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"Explorer Section: screenpipe [SSH: nas]","depth":22,"bounds":{"left":0.022606382,"top":0.07581804,"width":0.045877658,"height":0.017557861},"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"SCREENPIPE [SSH: NAS]","depth":23,"bounds":{"left":0.022606382,"top":0.079010375,"width":0.045877658,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.022606382,"top":0.07980846,"width":0.0026595744,"height":0.0103751}},{"char_start":1,"char_count":20,"bounds":{"left":0.025265958,"top":0.07980846,"width":0.043218084,"height":0.0103751}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.09577015,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"#recycle","depth":27,"bounds":{"left":0.025930852,"top":0.09577015,"width":0.017287234,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.096568234,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":7,"bounds":{"left":0.028590426,"top":0.096568234,"width":0.01462766,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.11332801,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"app","depth":27,"bounds":{"left":0.025930852,"top":0.11332801,"width":0.0076462766,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.11412609,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":2,"bounds":{"left":0.02825798,"top":0.11412609,"width":0.005319149,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.11412609,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.022273935,"top":0.13088587,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"__pycache__","depth":27,"bounds":{"left":0.028590426,"top":0.13088587,"width":0.026595745,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.13168396,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":10,"bounds":{"left":0.030917553,"top":0.13168396,"width":0.024268618,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.022273935,"top":0.14844373,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"consumers","depth":27,"bounds":{"left":0.028590426,"top":0.14844373,"width":0.022273935,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.14924182,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":8,"bounds":{"left":0.030917553,"top":0.14924182,"width":0.019946808,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.14924182,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.022273935,"top":0.1660016,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"static","depth":27,"bounds":{"left":0.028590426,"top":0.1660016,"width":0.010970744,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.16679968,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":5,"bounds":{"left":0.030917553,"top":0.16679968,"width":0.008976064,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.16679968,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.1819633,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":".env","depth":27,"bounds":{"left":0.028590426,"top":0.18355946,"width":0.00831117,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.18435754,"width":0.0013297872,"height":0.011971269}},{"char_start":1,"char_count":3,"bounds":{"left":0.029920213,"top":0.18435754,"width":0.006981383,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.19952115,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"cli.py","depth":27,"bounds":{"left":0.028590426,"top":0.20111732,"width":0.010638298,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.2019154,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":5,"bounds":{"left":0.030917553,"top":0.2019154,"width":0.00831117,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.2019154,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.21707901,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.py","depth":27,"bounds":{"left":0.028590426,"top":0.21867518,"width":0.011303191,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.21947326,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":4,"bounds":{"left":0.03125,"top":0.21947326,"width":0.008643617,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.23463687,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"docker-compose.yml","depth":27,"bounds":{"left":0.028590426,"top":0.23623304,"width":0.042220745,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.23703113,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":17,"bounds":{"left":0.03125,"top":0.23703113,"width":0.03956117,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.25219473,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Dockerfile","depth":27,"bounds":{"left":0.028590426,"top":0.25379092,"width":0.020611702,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.254589,"width":0.0033244682,"height":0.011971269}},{"char_start":1,"char_count":9,"bounds":{"left":0.031914894,"top":0.254589,"width":0.017287234,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.254589,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.2697526,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"main.py","depth":27,"bounds":{"left":0.028590426,"top":0.27134877,"width":0.015625,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.27214685,"width":0.003656915,"height":0.011971269}},{"char_start":1,"char_count":6,"bounds":{"left":0.032247342,"top":0.27214685,"width":0.012300532,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.27214685,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.28731045,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"requirements.txt","depth":27,"bounds":{"left":0.028590426,"top":0.28890663,"width":0.032912236,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.2897047,"width":0.0016622341,"height":0.011971269}},{"char_start":1,"char_count":15,"bounds":{"left":0.03025266,"top":0.2897047,"width":0.03158245,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.2897047,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.3064645,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"data","depth":27,"bounds":{"left":0.025930852,"top":0.3064645,"width":0.008976064,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.30726257,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":3,"bounds":{"left":0.028590426,"top":0.30726257,"width":0.0063164895,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.32402235,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"logs","depth":27,"bounds":{"left":0.025930852,"top":0.32402235,"width":0.00831117,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.32482043,"width":0.0009973404,"height":0.011971269}},{"char_start":1,"char_count":3,"bounds":{"left":0.026928192,"top":0.32482043,"width":0.0076462766,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.32482043,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.3415802,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"pipes","depth":27,"bounds":{"left":0.025930852,"top":0.3415802,"width":0.010970744,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.3423783,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":4,"bounds":{"left":0.028590426,"top":0.3423783,"width":0.00831117,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.3575419,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":".gitignore","depth":27,"bounds":{"left":0.025930852,"top":0.35913807,"width":0.018949468,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.35993615,"width":0.0013297872,"height":0.011971269}},{"char_start":1,"char_count":9,"bounds":{"left":0.027260639,"top":0.35993615,"width":0.017952127,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.37509975,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"app_settings.json","depth":27,"bounds":{"left":0.025930852,"top":0.37669593,"width":0.03557181,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.377494,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":16,"bounds":{"left":0.02825798,"top":0.377494,"width":0.03324468,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.3926576,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"archive.db","depth":27,"bounds":{"left":0.025930852,"top":0.3942538,"width":0.020944148,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.39505187,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":9,"bounds":{"left":0.02825798,"top":0.39505187,"width":0.01861702,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.4102155,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"archive.db-bak","depth":27,"bounds":{"left":0.025930852,"top":0.41181165,"width":0.03025266,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.41260973,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":13,"bounds":{"left":0.02825798,"top":0.41260973,"width":0.027925532,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"U","depth":27,"bounds":{"left":0.10704787,"top":0.41260973,"width":0.0029920214,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.42777336,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite","depth":27,"bounds":{"left":0.025930852,"top":0.4293695,"width":0.017287234,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.4301676,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":8,"bounds":{"left":0.028590426,"top":0.4301676,"width":0.014960106,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.44533122,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite-shm","depth":27,"bounds":{"left":0.025930852,"top":0.44692737,"width":0.027925532,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.44772545,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":12,"bounds":{"left":0.028590426,"top":0.44772545,"width":0.025265958,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.46288908,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite-wal","depth":27,"bounds":{"left":0.025930852,"top":0.46448523,"width":0.025930852,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.46528333,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":12,"bounds":{"left":0.028590426,"top":0.46528333,"width":0.023603724,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.48044693,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe_sync_updated.sh","depth":27,"bounds":{"left":0.025930852,"top":0.4820431,"width":0.059175532,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.4828412,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":25,"bounds":{"left":0.02825798,"top":0.4828412,"width":0.056848403,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"U","depth":27,"bounds":{"left":0.10704787,"top":0.4828412,"width":0.0029920214,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.4980048,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe_sync.sh","depth":27,"bounds":{"left":0.025930852,"top":0.49960095,"width":0.039893616,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.50039905,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":17,"bounds":{"left":0.02825798,"top":0.50039905,"width":0.037898935,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.51556265,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe.db","depth":27,"bounds":{"left":0.025930852,"top":0.5171588,"width":0.028590426,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.5179569,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":12,"bounds":{"left":0.02825798,"top":0.5179569,"width":0.026595745,"height":0.011971269}}],"role_description":"text"},{"role":"AXButton","text":"Outline Section","depth":21,"bounds":{"left":0.015957447,"top":0.9473264,"width":0.09940159,"height":0.017557861},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":23,"bounds":{"left":0.01662234,"top":0.9497207,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"OUTLINE","depth":22,"bounds":{"left":0.022606382,"top":0.9473264,"width":0.01662234,"height":0.017557861},"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"OUTLINE","depth":23,"bounds":{"left":0.022606382,"top":0.95131683,"width":0.01662234,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.022606382,"top":0.95131683,"width":0.0029920214,"height":0.0103751}},{"char_start":1,"char_count":6,"bounds":{"left":0.025598405,"top":0.95131683,"width":0.013630319,"height":0.0103751}}],"role_description":"text"},{"role":"AXButton","text":"Timeline Section","depth":21,"bounds":{"left":0.015957447,"top":0.9648843,"width":0.09940159,"height":0.017557861},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":23,"bounds":{"left":0.01662234,"top":0.96727854,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"TIMELINE","depth":22,"bounds":{"left":0.022606382,"top":0.9648843,"width":0.01761968,"height":0.017557861},"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"TIMELINE","depth":23,"bounds":{"left":0.022606382,"top":0.9688747,"width":0.01761968,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.022606382,"top":0.9688747,"width":0.0026595744,"height":0.0103751}},{"char_start":1,"char_count":7,"bounds":{"left":0.025265958,"top":0.9688747,"width":0.015292553,"height":0.0103751}}],"role_description":"text"},{"role":"AXRadioButton","text":"app_settings.json, Editor Group 1","depth":28,"bounds":{"left":0.11569149,"top":0.047885075,"width":0.055851065,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"screenpipe_sync.sh, Editor Group 1","depth":28,"bounds":{"left":0.17154256,"top":0.047885075,"width":0.06050532,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"screenpipe_sync_updated.sh, preview, Editor Group 1","depth":28,"bounds":{"left":0.23171543,"top":0.047885075,"width":0.08344415,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":false},{"role":"AXRadioButton","text":"pipe.md, Editor Group 1","depth":28,"bounds":{"left":0.3148271,"top":0.047885075,"width":0.040226065,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":".env, Editor Group 1","depth":28,"bounds":{"left":0.35472074,"top":0.047885075,"width":0.040226065,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"#!/bin/bash\n# screenpipe_sync.sh\n# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).\n# Also copies the day's video/frame data folder to the NAS.\n#\n# Schema-drift tolerant: if Screenpipe migrations add new columns to the source DB,\n# the NAS archive gets ALTER TABLE'd to match. Inserts use explicit column lists,\n# so positional mismatches can't occur.\n#\n# Usage:\n# ./screenpipe_sync.sh # syncs yesterday (default)\n# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date\n# ./screenpipe_sync.sh today # syncs today so far\n#\n# Cron example (runs at 3am daily):\n# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1\n\nset -euo pipefail\n\n# ─── CONFIG ───────────────────────────────────────────────────────────────────\nDB_SRC=\"${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}\"\nNAS_MOUNT=\"${NAS_MOUNT:-/Volumes/screenpipe}\"\nNAS_DB=\"$NAS_MOUNT/archive.db\"\nNAS_DATA=\"$NAS_MOUNT/data\"\nLOG_FILE=\"$HOME/.screenpipe/sync.log\"\n# Tables that get schema drift handling. Order matters for FK-ish references\n# (parents before children: video_chunks → frames → elements/ocr_text/ui_events).\nSYNC_TABLES=(video_chunks frames elements ocr_text ui_events meetings)\n# ──────────────────────────────────────────────────────────────────────────────\n\n# ─── HELPERS ──────────────────────────────────────────────────────────────────\nSCRIPT_START=$(date +%s)\n\nlog() {\n local msg=\"[$(date '+%Y-%m-%d %H:%M:%S')] $*\"\n echo \"$msg\" | tee -a \"$LOG_FILE\"\n}\n\nstep() {\n local now=$(date +%s)\n local elapsed=$(( now - SCRIPT_START ))\n local min=$(( elapsed / 60 ))\n local sec=$(( elapsed % 60 ))\n printf \"\\n[+%02dm%02ds] ▶ %s\\n\" \"$min\" \"$sec\" \"$*\" | tee -a \"$LOG_FILE\"\n}\n\nrun_sqlite_heredoc() {\n local label=\"$1\"\n local sql=\"$2\"\n local start=$(date +%s)\n\n printf \" %-36s \" \"$label\"\n\n sqlite3 \"$DB_SRC\" <<< \"$sql\" &\n local pid=$!\n local spin=('⠋' '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')\n local i=0\n while kill -0 \"$pid\" 2>/dev/null; do\n printf \"\\r %-36s %s \" \"$label\" \"${spin[$i]}\"\n i=$(( (i + 1) % 10 ))\n sleep 0.2\n done\n wait \"$pid\"\n local rc=$?\n if [ $rc -ne 0 ]; then\n printf \"\\r %-36s ✗ FAILED\\n\" \"$label\" | tee -a \"$LOG_FILE\"\n exit $rc\n fi\n\n local dur=$(( $(date +%s) - start ))\n printf \"\\r %-36s ✓ %dm%02ds\\n\" \"$label\" \"$(( dur / 60 ))\" \"$(( dur % 60 ))\" | tee -a \"$LOG_FILE\"\n}\n\ncheck() {\n local label=\"$1\" got=\"$2\" expected=\"$3\"\n if [ \"$got\" -eq \"$expected\" ]; then\n printf \" %-20s %s / %s ✓\\n\" \"$label:\" \"$got\" \"$expected\"\n else\n printf \" %-20s %s / %s ✗ MISMATCH\\n\" \"$label:\" \"$got\" \"$expected\"\n fi\n}\n\n# ─── SCHEMA HELPERS ───────────────────────────────────────────────────────────\n# Echoes \"name|type\" lines for a table from a given DB.\ntable_columns_with_types() {\n local db=\"$1\" table=\"$2\"\n sqlite3 \"$db\" \"PRAGMA table_info($table);\" | awk -F'|' '{print $2 \"|\" $3}'\n}\n\n# Echoes just column names, one per line.\ntable_columns() {\n local db=\"$1\" table=\"$2\"\n sqlite3 \"$db\" \"PRAGMA table_info($table);\" | awk -F'|' '{print $2}'\n}\n\n# Returns true (0) if a table exists in the given DB.\ntable_exists() {\n local db=\"$1\" table=\"$2\"\n local count\n count=$(sqlite3 \"$db\" \"SELECT COUNT(*) FROM sqlite_master WHERE type='table' AND name='$table';\")\n [ \"$count\" -gt 0 ]\n}\n\n# Adds any columns present in source but missing in NAS for the given table.\n# Uses ALTER TABLE ADD COLUMN, which is a fast metadata-only operation in SQLite.\nensure_columns() {\n local table=\"$1\"\n local label=\"schema: $table\"\n printf \" %-36s \" \"$label\"\n\n if ! table_exists \"$DB_SRC\" \"$table\"; then\n printf \"✗ source missing — skipping\\n\"\n return 0\n fi\n\n if ! table_exists \"$NAS_DB\" \"$table\"; then\n printf \"✓ fresh (created above)\\n\"\n return 0\n fi\n\n local src_cols\n src_cols=$(table_columns_with_types \"$DB_SRC\" \"$table\")\n local nas_cols\n nas_cols=$(table_columns \"$NAS_DB\" \"$table\")\n\n local added=0\n local added_names=\"\"\n while IFS='|' read -r name type; do\n [ -z \"$name\" ] && continue\n # Use grep -F -x for fixed-string exact match (safe against regex chars).\n if ! echo \"$nas_cols\" | grep -Fxq \"$name\"; then\n # SQLite ALTER TABLE ADD COLUMN: type is optional, no NOT NULL allowed\n # without a constant default. Default-NULL is exactly what we want for archive.\n sqlite3 \"$NAS_DB\" \"ALTER TABLE $table ADD COLUMN \\\"$name\\\" $type;\"\n added=$((added + 1))\n added_names=\"$added_names $name\"\n fi\n done <<< \"$src_cols\"\n\n if [ \"$added\" -gt 0 ]; then\n printf \"✓ added %d:%s\\n\" \"$added\" \"$added_names\"\n else\n printf \"✓ in sync\\n\"\n fi\n}\n\n# Echoes a comma-separated list of source columns for a table, double-quoted\n# so reserved words and hyphens are safe. Used for both INSERT and SELECT sides.\nbuild_col_list() {\n local table=\"$1\"\n table_columns \"$DB_SRC\" \"$table\" | awk 'NF' | sed 's/.*/\"&\"/' | paste -sd, -\n}\n# ──────────────────────────────────────────────────────────────────────────────\n\n# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────\nif [ \"${1:-}\" = \"today\" ]; then\n TARGET_DATE=$(date +%Y-%m-%d)\nelif [ -n \"${1:-}\" ]; then\n TARGET_DATE=\"$1\"\n if ! [[ \"$TARGET_DATE\" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then\n echo \"ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday.\"\n exit 1\n fi\nelse\n TARGET_DATE=$(date -v-1d +%Y-%m-%d)\nfi\n\nlog \"========================================\"\nlog \"Screenpipe sync starting for: $TARGET_DATE\"\nlog \"========================================\"\n\n# ─── PREFLIGHT ────────────────────────────────────────────────────────────────\nstep \"Preflight checks\"\n\nif [ ! -f \"$DB_SRC\" ]; then\n log \"ERROR: Source DB not found at $DB_SRC\"; exit 1\nfi\nprintf \" %-20s %s (%s)\\n\" \"Source DB:\" \"OK\" \"$(du -sh \"$DB_SRC\" | cut -f1)\"\n\nif [ ! -d \"$NAS_MOUNT\" ]; then\n log \"ERROR: NAS not mounted at $NAS_MOUNT\"; exit 1\nfi\nprintf \" %-20s %s\\n\" \"NAS mount:\" \"OK $NAS_MOUNT\"\n\n# Check if DB already synced for this date\nDB_ALREADY_SYNCED=false\nif [ -f \"$NAS_DB\" ]; then\n if table_exists \"$NAS_DB\" \"frames\"; then\n EXISTING=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\" 2>/dev/null || echo \"0\")\n if [ \"$EXISTING\" -gt \"0\" ]; then\n log \"Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync\"\n DB_ALREADY_SYNCED=true\n else\n printf \" %-20s %s (%s)\\n\" \"Archive DB:\" \"exists\" \"$(du -sh \"$NAS_DB\" | cut -f1)\"\n fi\n else\n printf \" %-20s %s\\n\" \"Archive DB:\" \"exists, no frames table yet\"\n fi\nelse\n printf \" %-20s %s\\n\" \"Archive DB:\" \"will be created\"\nfi\n\n# Source data dir for this date\nDATA_SRC=\"$HOME/.screenpipe/data/data/$TARGET_DATE\"\nif [ -d \"$DATA_SRC\" ]; then\n DATA_SIZE=$(du -sh \"$DATA_SRC\" | cut -f1)\n DATA_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n printf \" %-20s %s (%s files, %s)\\n\" \"Data dir:\" \"OK\" \"$DATA_FILES\" \"$DATA_SIZE\"\nelse\n printf \" %-20s %s\\n\" \"Data dir:\" \"not found — skipping file copy\"\nfi\n\n# ─── DB SYNC ──────────────────────────────────────────────────────────────────\nif [ \"$DB_ALREADY_SYNCED\" = false ]; then\n\n # ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────\n step \"Counting source rows for $TARGET_DATE\"\n\n SRC_FRAMES=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\")\n SRC_ELEMENTS=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n SRC_UI=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';\")\n SRC_OCR=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n SRC_MEETINGS=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';\")\n\n printf \" %-20s %s\\n\" \"frames:\" \"$SRC_FRAMES\"\n printf \" %-20s %s\\n\" \"elements:\" \"$SRC_ELEMENTS\"\n printf \" %-20s %s\\n\" \"ui_events:\" \"$SRC_UI\"\n printf \" %-20s %s\\n\" \"ocr_text:\" \"$SRC_OCR\"\n printf \" %-20s %s\\n\" \"meetings:\" \"$SRC_MEETINGS\"\n\n if [ \"$SRC_FRAMES\" -eq \"0\" ]; then\n log \"No frames found for $TARGET_DATE — skipping DB sync\"\n DB_ALREADY_SYNCED=true\n fi\n\nfi\n\nif [ \"$DB_ALREADY_SYNCED\" = false ]; then\n\n # ─── INIT TABLES ──────────────────────────────────────────────────────────\n step \"Initialising tables (CREATE IF NOT EXISTS)\"\n\n run_sqlite_heredoc \"creating tables\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;\nDETACH nas;\n\"\n\n # ─── SCHEMA DRIFT FIX ─────────────────────────────────────────────────────\n # Runs AFTER CREATE IF NOT EXISTS so newly-created tables are no-ops here,\n # and pre-existing tables get any missing columns added.\n step \"Reconciling NAS schema with source\"\n for tbl in \"${SYNC_TABLES[@]}\"; do\n ensure_columns \"$tbl\"\n done\n\n run_sqlite_heredoc \"creating indexes\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_document_path ON frames(document_path) WHERE document_path IS NOT NULL;\nCREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;\nCREATE INDEX IF NOT EXISTS nas.idx_elements_onscreen_frame ON elements(frame_id) WHERE on_screen = 1 AND text IS NOT NULL;\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);\nCREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"creating FTS tables\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(\n text, role, frame_id UNINDEXED,\n content='elements', content_rowid='id', tokenize='unicode61'\n);\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(\n full_text, app_name, window_name, browser_url, id UNINDEXED,\n tokenize='unicode61'\n);\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(\n text_content,\n app_name,\n window_title,\n element_name,\n content='ui_events',\n content_rowid='id',\n tokenize='unicode61'\n);\nDETACH nas;\n\"\n\n # ─── BUILD EXPLICIT COLUMN LISTS ──────────────────────────────────────────\n # After ensure_columns, source ⊆ NAS for every synced table, so source's\n # column list is a safe subset to use on both sides of the INSERT.\n FRAMES_COLS=$(build_col_list frames)\n ELEMENTS_COLS=$(build_col_list elements)\n UI_EVENTS_COLS=$(build_col_list ui_events)\n OCR_TEXT_COLS=$(build_col_list ocr_text)\n VIDEO_CHUNKS_COLS=$(build_col_list video_chunks)\n MEETINGS_COLS=$(build_col_list meetings)\n\n # ─── SYNC DATA ────────────────────────────────────────────────────────────\n step \"Syncing data for $TARGET_DATE\"\n\n run_sqlite_heredoc \"video_chunks\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.video_chunks ($VIDEO_CHUNKS_COLS)\n SELECT $VIDEO_CHUNKS_COLS FROM main.video_chunks\n WHERE id IN (\n SELECT DISTINCT video_chunk_id FROM main.frames\n WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL\n );\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames ($SRC_FRAMES rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.frames ($FRAMES_COLS)\n SELECT $FRAMES_COLS FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ocr_text ($SRC_OCR rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ocr_text ($OCR_TEXT_COLS)\n SELECT $OCR_TEXT_COLS FROM main.ocr_text o\n JOIN main.frames f ON o.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events ($SRC_UI rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ui_events ($UI_EVENTS_COLS)\n SELECT $UI_EVENTS_COLS FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"elements ($SRC_ELEMENTS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.elements ($ELEMENTS_COLS)\n SELECT $ELEMENTS_COLS FROM main.elements e\n JOIN main.frames f ON e.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"meetings ($SRC_MEETINGS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.meetings ($MEETINGS_COLS)\n SELECT $MEETINGS_COLS FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n # NOTE: the elements/ocr_text inserts use unqualified column names while\n # selecting from a JOIN. SQLite resolves them against the leftmost table\n # that has the column, which is what we want here (e.* / o.* implicitly),\n # because none of the column names collide with frames'.\n\n # ─── FTS UPDATE ───────────────────────────────────────────────────────────\n step \"Updating FTS indexes\"\n\n run_sqlite_heredoc \"elements_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.elements_fts(rowid, text, role)\n SELECT e.id, e.text, e.role\n FROM nas.elements e\n JOIN nas.frames f ON e.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE'\n AND e.text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)\n SELECT id, full_text, app_name, window_name, browser_url, id\n FROM nas.frames\n WHERE date(timestamp) = '$TARGET_DATE'\n AND full_text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)\n SELECT id, text_content, app_name, window_title, element_name\n FROM nas.ui_events\n WHERE date(timestamp) = '$TARGET_DATE'\n AND text_content IS NOT NULL;\nDETACH nas;\n\"\n\n # ─── VERIFY DB ────────────────────────────────────────────────────────────\n step \"Verifying DB\"\n\n V_FRAMES=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\")\n V_ELEMENTS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n V_UI=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';\")\n V_OCR=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n V_MEETINGS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';\")\n\n check \"frames\" \"$V_FRAMES\" \"$SRC_FRAMES\"\n check \"elements\" \"$V_ELEMENTS\" \"$SRC_ELEMENTS\"\n check \"ui_events\" \"$V_UI\" \"$SRC_UI\"\n check \"ocr_text\" \"$V_OCR\" \"$SRC_OCR\"\n check \"meetings\" \"$V_MEETINGS\" \"$SRC_MEETINGS\"\n\nfi\n\n# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────\n# Always runs regardless of DB sync status\nstep \"Copying data folder for $TARGET_DATE\"\n\nif [ -d \"$DATA_SRC\" ]; then\n mkdir -p \"$NAS_DATA/$TARGET_DATE\"\n RSYNC_START=$(date +%s)\n printf \" %-36s \" \"rsync $TARGET_DATE/ → NAS\"\n rsync -a --ignore-existing \\\n \"$DATA_SRC/\" \\\n \"$NAS_DATA/$TARGET_DATE/\" \\\n 2>>\"$LOG_FILE\"\n RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))\n COPIED_FILES=$(ls \"$NAS_DATA/$TARGET_DATE\" | wc -l | tr -d ' ')\n SRC_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n COPIED_SIZE=$(du -sh \"$NAS_DATA/$TARGET_DATE\" | cut -f1)\n if [ \"$COPIED_FILES\" -eq \"$SRC_FILES\" ]; then\n printf \"\\r %-36s ✓ %dm%02ds (%s files, %s)\\n\" \\\n \"rsync $TARGET_DATE/ → NAS\" \\\n \"$(( RSYNC_DUR / 60 ))\" \"$(( RSYNC_DUR % 60 ))\" \\\n \"$COPIED_FILES\" \"$COPIED_SIZE\" | tee -a \"$LOG_FILE\"\n else\n printf \"\\r %-36s ✗ %s / %s files\\n\" \\\n \"rsync $TARGET_DATE/ → NAS\" \"$COPIED_FILES\" \"$SRC_FILES\" | tee -a \"$LOG_FILE\"\n fi\nelse\n printf \" %-36s %s\\n\" \"rsync $TARGET_DATE/ → NAS\" \"skipped (no source dir)\"\nfi\n\n# ─── SUMMARY ──────────────────────────────────────────────────────────────────\nTOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))\nDB_SIZE=$(du -sh \"$NAS_DB\" | cut -f1)\n\necho \"\"\nlog \"Archive DB size: $DB_SIZE\"\nlog \"Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s\"\nlog \"Sync complete for $TARGET_DATE\"\nlog \"========================================\"","depth":28,"bounds":{"left":0.11569149,"top":0.0933759,"width":0.38031915,"height":0.0007980846},"on_screen":true,"value":"#!/bin/bash\n# screenpipe_sync.sh\n# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).\n# Also copies the day's video/frame data folder to the NAS.\n#\n# Schema-drift tolerant: if Screenpipe migrations add new columns to the source DB,\n# the NAS archive gets ALTER TABLE'd to match. Inserts use explicit column lists,\n# so positional mismatches can't occur.\n#\n# Usage:\n# ./screenpipe_sync.sh # syncs yesterday (default)\n# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date\n# ./screenpipe_sync.sh today # syncs today so far\n#\n# Cron example (runs at 3am daily):\n# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1\n\nset -euo pipefail\n\n# ─── CONFIG ───────────────────────────────────────────────────────────────────\nDB_SRC=\"${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}\"\nNAS_MOUNT=\"${NAS_MOUNT:-/Volumes/screenpipe}\"\nNAS_DB=\"$NAS_MOUNT/archive.db\"\nNAS_DATA=\"$NAS_MOUNT/data\"\nLOG_FILE=\"$HOME/.screenpipe/sync.log\"\n# Tables that get schema drift handling. Order matters for FK-ish references\n# (parents before children: video_chunks → frames → elements/ocr_text/ui_events).\nSYNC_TABLES=(video_chunks frames elements ocr_text ui_events meetings)\n# ──────────────────────────────────────────────────────────────────────────────\n\n# ─── HELPERS ──────────────────────────────────────────────────────────────────\nSCRIPT_START=$(date +%s)\n\nlog() {\n local msg=\"[$(date '+%Y-%m-%d %H:%M:%S')] $*\"\n echo \"$msg\" | tee -a \"$LOG_FILE\"\n}\n\nstep() {\n local now=$(date +%s)\n local elapsed=$(( now - SCRIPT_START ))\n local min=$(( elapsed / 60 ))\n local sec=$(( elapsed % 60 ))\n printf \"\\n[+%02dm%02ds] ▶ %s\\n\" \"$min\" \"$sec\" \"$*\" | tee -a \"$LOG_FILE\"\n}\n\nrun_sqlite_heredoc() {\n local label=\"$1\"\n local sql=\"$2\"\n local start=$(date +%s)\n\n printf \" %-36s \" \"$label\"\n\n sqlite3 \"$DB_SRC\" <<< \"$sql\" &\n local pid=$!\n local spin=('⠋' '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')\n local i=0\n while kill -0 \"$pid\" 2>/dev/null; do\n printf \"\\r %-36s %s \" \"$label\" \"${spin[$i]}\"\n i=$(( (i + 1) % 10 ))\n sleep 0.2\n done\n wait \"$pid\"\n local rc=$?\n if [ $rc -ne 0 ]; then\n printf \"\\r %-36s ✗ FAILED\\n\" \"$label\" | tee -a \"$LOG_FILE\"\n exit $rc\n fi\n\n local dur=$(( $(date +%s) - start ))\n printf \"\\r %-36s ✓ %dm%02ds\\n\" \"$label\" \"$(( dur / 60 ))\" \"$(( dur % 60 ))\" | tee -a \"$LOG_FILE\"\n}\n\ncheck() {\n local label=\"$1\" got=\"$2\" expected=\"$3\"\n if [ \"$got\" -eq \"$expected\" ]; then\n printf \" %-20s %s / %s ✓\\n\" \"$label:\" \"$got\" \"$expected\"\n else\n printf \" %-20s %s / %s ✗ MISMATCH\\n\" \"$label:\" \"$got\" \"$expected\"\n fi\n}\n\n# ─── SCHEMA HELPERS ───────────────────────────────────────────────────────────\n# Echoes \"name|type\" lines for a table from a given DB.\ntable_columns_with_types() {\n local db=\"$1\" table=\"$2\"\n sqlite3 \"$db\" \"PRAGMA table_info($table);\" | awk -F'|' '{print $2 \"|\" $3}'\n}\n\n# Echoes just column names, one per line.\ntable_columns() {\n local db=\"$1\" table=\"$2\"\n sqlite3 \"$db\" \"PRAGMA table_info($table);\" | awk -F'|' '{print $2}'\n}\n\n# Returns true (0) if a table exists in the given DB.\ntable_exists() {\n local db=\"$1\" table=\"$2\"\n local count\n count=$(sqlite3 \"$db\" \"SELECT COUNT(*) FROM sqlite_master WHERE type='table' AND name='$table';\")\n [ \"$count\" -gt 0 ]\n}\n\n# Adds any columns present in source but missing in NAS for the given table.\n# Uses ALTER TABLE ADD COLUMN, which is a fast metadata-only operation in SQLite.\nensure_columns() {\n local table=\"$1\"\n local label=\"schema: $table\"\n printf \" %-36s \" \"$label\"\n\n if ! table_exists \"$DB_SRC\" \"$table\"; then\n printf \"✗ source missing — skipping\\n\"\n return 0\n fi\n\n if ! table_exists \"$NAS_DB\" \"$table\"; then\n printf \"✓ fresh (created above)\\n\"\n return 0\n fi\n\n local src_cols\n src_cols=$(table_columns_with_types \"$DB_SRC\" \"$table\")\n local nas_cols\n nas_cols=$(table_columns \"$NAS_DB\" \"$table\")\n\n local added=0\n local added_names=\"\"\n while IFS='|' read -r name type; do\n [ -z \"$name\" ] && continue\n # Use grep -F -x for fixed-string exact match (safe against regex chars).\n if ! echo \"$nas_cols\" | grep -Fxq \"$name\"; then\n # SQLite ALTER TABLE ADD COLUMN: type is optional, no NOT NULL allowed\n # without a constant default. Default-NULL is exactly what we want for archive.\n sqlite3 \"$NAS_DB\" \"ALTER TABLE $table ADD COLUMN \\\"$name\\\" $type;\"\n added=$((added + 1))\n added_names=\"$added_names $name\"\n fi\n done <<< \"$src_cols\"\n\n if [ \"$added\" -gt 0 ]; then\n printf \"✓ added %d:%s\\n\" \"$added\" \"$added_names\"\n else\n printf \"✓ in sync\\n\"\n fi\n}\n\n# Echoes a comma-separated list of source columns for a table, double-quoted\n# so reserved words and hyphens are safe. Used for both INSERT and SELECT sides.\nbuild_col_list() {\n local table=\"$1\"\n table_columns \"$DB_SRC\" \"$table\" | awk 'NF' | sed 's/.*/\"&\"/' | paste -sd, -\n}\n# ──────────────────────────────────────────────────────────────────────────────\n\n# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────\nif [ \"${1:-}\" = \"today\" ]; then\n TARGET_DATE=$(date +%Y-%m-%d)\nelif [ -n \"${1:-}\" ]; then\n TARGET_DATE=\"$1\"\n if ! [[ \"$TARGET_DATE\" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then\n echo \"ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday.\"\n exit 1\n fi\nelse\n TARGET_DATE=$(date -v-1d +%Y-%m-%d)\nfi\n\nlog \"========================================\"\nlog \"Screenpipe sync starting for: $TARGET_DATE\"\nlog \"========================================\"\n\n# ─── PREFLIGHT ────────────────────────────────────────────────────────────────\nstep \"Preflight checks\"\n\nif [ ! -f \"$DB_SRC\" ]; then\n log \"ERROR: Source DB not found at $DB_SRC\"; exit 1\nfi\nprintf \" %-20s %s (%s)\\n\" \"Source DB:\" \"OK\" \"$(du -sh \"$DB_SRC\" | cut -f1)\"\n\nif [ ! -d \"$NAS_MOUNT\" ]; then\n log \"ERROR: NAS not mounted at $NAS_MOUNT\"; exit 1\nfi\nprintf \" %-20s %s\\n\" \"NAS mount:\" \"OK $NAS_MOUNT\"\n\n# Check if DB already synced for this date\nDB_ALREADY_SYNCED=false\nif [ -f \"$NAS_DB\" ]; then\n if table_exists \"$NAS_DB\" \"frames\"; then\n EXISTING=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\" 2>/dev/null || echo \"0\")\n if [ \"$EXISTING\" -gt \"0\" ]; then\n log \"Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync\"\n DB_ALREADY_SYNCED=true\n else\n printf \" %-20s %s (%s)\\n\" \"Archive DB:\" \"exists\" \"$(du -sh \"$NAS_DB\" | cut -f1)\"\n fi\n else\n printf \" %-20s %s\\n\" \"Archive DB:\" \"exists, no frames table yet\"\n fi\nelse\n printf \" %-20s %s\\n\" \"Archive DB:\" \"will be created\"\nfi\n\n# Source data dir for this date\nDATA_SRC=\"$HOME/.screenpipe/data/data/$TARGET_DATE\"\nif [ -d \"$DATA_SRC\" ]; then\n DATA_SIZE=$(du -sh \"$DATA_SRC\" | cut -f1)\n DATA_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n printf \" %-20s %s (%s files, %s)\\n\" \"Data dir:\" \"OK\" \"$DATA_FILES\" \"$DATA_SIZE\"\nelse\n printf \" %-20s %s\\n\" \"Data dir:\" \"not found — skipping file copy\"\nfi\n\n# ─── DB SYNC ──────────────────────────────────────────────────────────────────\nif [ \"$DB_ALREADY_SYNCED\" = false ]; then\n\n # ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────\n step \"Counting source rows for $TARGET_DATE\"\n\n SRC_FRAMES=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\")\n SRC_ELEMENTS=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n SRC_UI=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';\")\n SRC_OCR=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n SRC_MEETINGS=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';\")\n\n printf \" %-20s %s\\n\" \"frames:\" \"$SRC_FRAMES\"\n printf \" %-20s %s\\n\" \"elements:\" \"$SRC_ELEMENTS\"\n printf \" %-20s %s\\n\" \"ui_events:\" \"$SRC_UI\"\n printf \" %-20s %s\\n\" \"ocr_text:\" \"$SRC_OCR\"\n printf \" %-20s %s\\n\" \"meetings:\" \"$SRC_MEETINGS\"\n\n if [ \"$SRC_FRAMES\" -eq \"0\" ]; then\n log \"No frames found for $TARGET_DATE — skipping DB sync\"\n DB_ALREADY_SYNCED=true\n fi\n\nfi\n\nif [ \"$DB_ALREADY_SYNCED\" = false ]; then\n\n # ─── INIT TABLES ──────────────────────────────────────────────────────────\n step \"Initialising tables (CREATE IF NOT EXISTS)\"\n\n run_sqlite_heredoc \"creating tables\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;\nDETACH nas;\n\"\n\n # ─── SCHEMA DRIFT FIX ─────────────────────────────────────────────────────\n # Runs AFTER CREATE IF NOT EXISTS so newly-created tables are no-ops here,\n # and pre-existing tables get any missing columns added.\n step \"Reconciling NAS schema with source\"\n for tbl in \"${SYNC_TABLES[@]}\"; do\n ensure_columns \"$tbl\"\n done\n\n run_sqlite_heredoc \"creating indexes\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_document_path ON frames(document_path) WHERE document_path IS NOT NULL;\nCREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;\nCREATE INDEX IF NOT EXISTS nas.idx_elements_onscreen_frame ON elements(frame_id) WHERE on_screen = 1 AND text IS NOT NULL;\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);\nCREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"creating FTS tables\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(\n text, role, frame_id UNINDEXED,\n content='elements', content_rowid='id', tokenize='unicode61'\n);\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(\n full_text, app_name, window_name, browser_url, id UNINDEXED,\n tokenize='unicode61'\n);\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(\n text_content,\n app_name,\n window_title,\n element_name,\n content='ui_events',\n content_rowid='id',\n tokenize='unicode61'\n);\nDETACH nas;\n\"\n\n # ─── BUILD EXPLICIT COLUMN LISTS ──────────────────────────────────────────\n # After ensure_columns, source ⊆ NAS for every synced table, so source's\n # column list is a safe subset to use on both sides of the INSERT.\n FRAMES_COLS=$(build_col_list frames)\n ELEMENTS_COLS=$(build_col_list elements)\n UI_EVENTS_COLS=$(build_col_list ui_events)\n OCR_TEXT_COLS=$(build_col_list ocr_text)\n VIDEO_CHUNKS_COLS=$(build_col_list video_chunks)\n MEETINGS_COLS=$(build_col_list meetings)\n\n # ─── SYNC DATA ────────────────────────────────────────────────────────────\n step \"Syncing data for $TARGET_DATE\"\n\n run_sqlite_heredoc \"video_chunks\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.video_chunks ($VIDEO_CHUNKS_COLS)\n SELECT $VIDEO_CHUNKS_COLS FROM main.video_chunks\n WHERE id IN (\n SELECT DISTINCT video_chunk_id FROM main.frames\n WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL\n );\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames ($SRC_FRAMES rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.frames ($FRAMES_COLS)\n SELECT $FRAMES_COLS FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ocr_text ($SRC_OCR rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ocr_text ($OCR_TEXT_COLS)\n SELECT $OCR_TEXT_COLS FROM main.ocr_text o\n JOIN main.frames f ON o.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events ($SRC_UI rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ui_events ($UI_EVENTS_COLS)\n SELECT $UI_EVENTS_COLS FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"elements ($SRC_ELEMENTS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.elements ($ELEMENTS_COLS)\n SELECT $ELEMENTS_COLS FROM main.elements e\n JOIN main.frames f ON e.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"meetings ($SRC_MEETINGS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.meetings ($MEETINGS_COLS)\n SELECT $MEETINGS_COLS FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n # NOTE: the elements/ocr_text inserts use unqualified column names while\n # selecting from a JOIN. SQLite resolves them against the leftmost table\n # that has the column, which is what we want here (e.* / o.* implicitly),\n # because none of the column names collide with frames'.\n\n # ─── FTS UPDATE ───────────────────────────────────────────────────────────\n step \"Updating FTS indexes\"\n\n run_sqlite_heredoc \"elements_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.elements_fts(rowid, text, role)\n SELECT e.id, e.text, e.role\n FROM nas.elements e\n JOIN nas.frames f ON e.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE'\n AND e.text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)\n SELECT id, full_text, app_name, window_name, browser_url, id\n FROM nas.frames\n WHERE date(timestamp) = '$TARGET_DATE'\n AND full_text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)\n SELECT id, text_content, app_name, window_title, element_name\n FROM nas.ui_events\n WHERE date(timestamp) = '$TARGET_DATE'\n AND text_content IS NOT NULL;\nDETACH nas;\n\"\n\n # ─── VERIFY DB ────────────────────────────────────────────────────────────\n step \"Verifying DB\"\n\n V_FRAMES=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\")\n V_ELEMENTS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n V_UI=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';\")\n V_OCR=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n V_MEETINGS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';\")\n\n check \"frames\" \"$V_FRAMES\" \"$SRC_FRAMES\"\n check \"elements\" \"$V_ELEMENTS\" \"$SRC_ELEMENTS\"\n check \"ui_events\" \"$V_UI\" \"$SRC_UI\"\n check \"ocr_text\" \"$V_OCR\" \"$SRC_OCR\"\n check \"meetings\" \"$V_MEETINGS\" \"$SRC_MEETINGS\"\n\nfi\n\n# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────\n# Always runs regardless of DB sync status\nstep \"Copying data folder for $TARGET_DATE\"\n\nif [ -d \"$DATA_SRC\" ]; then\n mkdir -p \"$NAS_DATA/$TARGET_DATE\"\n RSYNC_START=$(date +%s)\n printf \" %-36s \" \"rsync $TARGET_DATE/ → NAS\"\n rsync -a --ignore-existing \\\n \"$DATA_SRC/\" \\\n \"$NAS_DATA/$TARGET_DATE/\" \\\n 2>>\"$LOG_FILE\"\n RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))\n COPIED_FILES=$(ls \"$NAS_DATA/$TARGET_DATE\" | wc -l | tr -d ' ')\n SRC_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n COPIED_SIZE=$(du -sh \"$NAS_DATA/$TARGET_DATE\" | cut -f1)\n if [ \"$COPIED_FILES\" -eq \"$SRC_FILES\" ]; then\n printf \"\\r %-36s ✓ %dm%02ds (%s files, %s)\\n\" \\\n \"rsync $TARGET_DATE/ → NAS\" \\\n \"$(( RSYNC_DUR / 60 ))\" \"$(( RSYNC_DUR % 60 ))\" \\\n \"$COPIED_FILES\" \"$COPIED_SIZE\" | tee -a \"$LOG_FILE\"\n else\n printf \"\\r %-36s ✗ %s / %s files\\n\" \\\n \"rsync $TARGET_DATE/ → NAS\" \"$COPIED_FILES\" \"$SRC_FILES\" | tee -a \"$LOG_FILE\"\n fi\nelse\n printf \" %-36s %s\\n\" \"rsync $TARGET_DATE/ → NAS\" \"skipped (no source dir)\"\nfi\n\n# ─── SUMMARY ──────────────────────────────────────────────────────────────────\nTOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))\nDB_SIZE=$(du -sh \"$NAS_DB\" | cut -f1)\n\necho \"\"\nlog \"Archive DB size: $DB_SIZE\"\nlog \"Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s\"\nlog \"Sync complete for $TARGET_DATE\"\nlog \"========================================\"","role_description":"editor","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"#!/bin/bash\n# screenpipe_sync.sh\n# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).\n# Also copies the day's video/frame data folder to the NAS.\n#\n# Schema-drift tolerant: if Screenpipe migrations add new columns to the source DB,\n# the NAS archive gets ALTER TABLE'd to match. Inserts use explicit column lists,\n# so positional mismatches can't occur.\n#\n# Usage:\n# ./screenpipe_sync.sh # syncs yesterday (default)\n# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date\n# ./screenpipe_sync.sh today # syncs today so far\n#\n# Cron example (runs at 3am daily):\n# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1\n\nset -euo pipefail\n\n# ─── CONFIG ───────────────────────────────────────────────────────────────────\nDB_SRC=\"${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}\"\nNAS_MOUNT=\"${NAS_MOUNT:-/Volumes/screenpipe}\"\nNAS_DB=\"$NAS_MOUNT/archive.db\"\nNAS_DATA=\"$NAS_MOUNT/data\"\nLOG_FILE=\"$HOME/.screenpipe/sync.log\"\n# Tables that get schema drift handling. Order matters for FK-ish references\n# (parents before children: video_chunks → frames → elements/ocr_text/ui_events).\nSYNC_TABLES=(video_chunks frames elements ocr_text ui_events meetings)\n# ──────────────────────────────────────────────────────────────────────────────\n\n# ─── HELPERS ──────────────────────────────────────────────────────────────────\nSCRIPT_START=$(date +%s)\n\nlog() {\n local msg=\"[$(date '+%Y-%m-%d %H:%M:%S')] $*\"\n echo \"$msg\" | tee -a \"$LOG_FILE\"\n}\n\nstep() {\n local now=$(date +%s)\n local elapsed=$(( now - SCRIPT_START ))\n local min=$(( elapsed / 60 ))\n local sec=$(( elapsed % 60 ))\n printf \"\\n[+%02dm%02ds] ▶ %s\\n\" \"$min\" \"$sec\" \"$*\" | tee -a \"$LOG_FILE\"\n}\n\nrun_sqlite_heredoc() {\n local label=\"$1\"\n local sql=\"$2\"\n local start=$(date +%s)\n\n printf \" %-36s \" \"$label\"\n\n sqlite3 \"$DB_SRC\" <<< \"$sql\" &\n local pid=$!\n local spin=('⠋' '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')\n local i=0\n while kill -0 \"$pid\" 2>/dev/null; do\n printf \"\\r %-36s %s \" \"$label\" \"${spin[$i]}\"\n i=$(( (i + 1) % 10 ))\n sleep 0.2\n done\n wait \"$pid\"\n local rc=$?\n if [ $rc -ne 0 ]; then\n printf \"\\r %-36s ✗ FAILED\\n\" \"$label\" | tee -a \"$LOG_FILE\"\n exit $rc\n fi\n\n local dur=$(( $(date +%s) - start ))\n printf \"\\r %-36s ✓ %dm%02ds\\n\" \"$label\" \"$(( dur / 60 ))\" \"$(( dur % 60 ))\" | tee -a \"$LOG_FILE\"\n}\n\ncheck() {\n local label=\"$1\" got=\"$2\" expected=\"$3\"\n if [ \"$got\" -eq \"$expected\" ]; then\n printf \" %-20s %s / %s ✓\\n\" \"$label:\" \"$got\" \"$expected\"\n else\n printf \" %-20s %s / %s ✗ MISMATCH\\n\" \"$label:\" \"$got\" \"$expected\"\n fi\n}\n\n# ─── SCHEMA HELPERS ───────────────────────────────────────────────────────────\n# Echoes \"name|type\" lines for a table from a given DB.\ntable_columns_with_types() {\n local db=\"$1\" table=\"$2\"\n sqlite3 \"$db\" \"PRAGMA table_info($table);\" | awk -F'|' '{print $2 \"|\" $3}'\n}\n\n# Echoes just column names, one per line.\ntable_columns() {\n local db=\"$1\" table=\"$2\"\n sqlite3 \"$db\" \"PRAGMA table_info($table);\" | awk -F'|' '{print $2}'\n}\n\n# Returns true (0) if a table exists in the given DB.\ntable_exists() {\n local db=\"$1\" table=\"$2\"\n local count\n count=$(sqlite3 \"$db\" \"SELECT COUNT(*) FROM sqlite_master WHERE type='table' AND name='$table';\")\n [ \"$count\" -gt 0 ]\n}\n\n# Adds any columns present in source but missing in NAS for the given table.\n# Uses ALTER TABLE ADD COLUMN, which is a fast metadata-only operation in SQLite.\nensure_columns() {\n local table=\"$1\"\n local label=\"schema: $table\"\n printf \" %-36s \" \"$label\"\n\n if ! table_exists \"$DB_SRC\" \"$table\"; then\n printf \"✗ source missing — skipping\\n\"\n return 0\n fi\n\n if ! table_exists \"$NAS_DB\" \"$table\"; then\n printf \"✓ fresh (created above)\\n\"\n return 0\n fi\n\n local src_cols\n src_cols=$(table_columns_with_types \"$DB_SRC\" \"$table\")\n local nas_cols\n nas_cols=$(table_columns \"$NAS_DB\" \"$table\")\n\n local added=0\n local added_names=\"\"\n while IFS='|' read -r name type; do\n [ -z \"$name\" ] && continue\n # Use grep -F -x for fixed-string exact match (safe against regex chars).\n if ! echo \"$nas_cols\" | grep -Fxq \"$name\"; then\n # SQLite ALTER TABLE ADD COLUMN: type is optional, no NOT NULL allowed\n # without a constant default. Default-NULL is exactly what we want for archive.\n sqlite3 \"$NAS_DB\" \"ALTER TABLE $table ADD COLUMN \\\"$name\\\" $type;\"\n added=$((added + 1))\n added_names=\"$added_names $name\"\n fi\n done <<< \"$src_cols\"\n\n if [ \"$added\" -gt 0 ]; then\n printf \"✓ added %d:%s\\n\" \"$added\" \"$added_names\"\n else\n printf \"✓ in sync\\n\"\n fi\n}\n\n# Echoes a comma-separated list of source columns for a table, double-quoted\n# so reserved words and hyphens are safe. Used for both INSERT and SELECT sides.\nbuild_col_list() {\n local table=\"$1\"\n table_columns \"$DB_SRC\" \"$table\" | awk 'NF' | sed 's/.*/\"&\"/' | paste -sd, -\n}\n# ──────────────────────────────────────────────────────────────────────────────\n\n# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────\nif [ \"${1:-}\" = \"today\" ]; then\n TARGET_DATE=$(date +%Y-%m-%d)\nelif [ -n \"${1:-}\" ]; then\n TARGET_DATE=\"$1\"\n if ! [[ \"$TARGET_DATE\" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then\n echo \"ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday.\"\n exit 1\n fi\nelse\n TARGET_DATE=$(date -v-1d +%Y-%m-%d)\nfi\n\nlog \"========================================\"\nlog \"Screenpipe sync starting for: $TARGET_DATE\"\nlog \"========================================\"\n\n# ─── PREFLIGHT ────────────────────────────────────────────────────────────────\nstep \"Preflight checks\"\n\nif [ ! -f \"$DB_SRC\" ]; then\n log \"ERROR: Source DB not found at $DB_SRC\"; exit 1\nfi\nprintf \" %-20s %s (%s)\\n\" \"Source DB:\" \"OK\" \"$(du -sh \"$DB_SRC\" | cut -f1)\"\n\nif [ ! -d \"$NAS_MOUNT\" ]; then\n log \"ERROR: NAS not mounted at $NAS_MOUNT\"; exit 1\nfi\nprintf \" %-20s %s\\n\" \"NAS mount:\" \"OK $NAS_MOUNT\"\n\n# Check if DB already synced for this date\nDB_ALREADY_SYNCED=false\nif [ -f \"$NAS_DB\" ]; then\n if table_exists \"$NAS_DB\" \"frames\"; then\n EXISTING=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\" 2>/dev/null || echo \"0\")\n if [ \"$EXISTING\" -gt \"0\" ]; then\n log \"Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync\"\n DB_ALREADY_SYNCED=true\n else\n printf \" %-20s %s (%s)\\n\" \"Archive DB:\" \"exists\" \"$(du -sh \"$NAS_DB\" | cut -f1)\"\n fi\n else\n printf \" %-20s %s\\n\" \"Archive DB:\" \"exists, no frames table yet\"\n fi\nelse\n printf \" %-20s %s\\n\" \"Archive DB:\" \"will be created\"\nfi\n\n# Source data dir for this date\nDATA_SRC=\"$HOME/.screenpipe/data/data/$TARGET_DATE\"\nif [ -d \"$DATA_SRC\" ]; then\n DATA_SIZE=$(du -sh \"$DATA_SRC\" | cut -f1)\n DATA_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n printf \" %-20s %s (%s files, %s)\\n\" \"Data dir:\" \"OK\" \"$DATA_FILES\" \"$DATA_SIZE\"\nelse\n printf \" %-20s %s\\n\" \"Data dir:\" \"not found — skipping file copy\"\nfi\n\n# ─── DB SYNC ──────────────────────────────────────────────────────────────────\nif [ \"$DB_ALREADY_SYNCED\" = false ]; then\n\n # ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────\n step \"Counting source rows for $TARGET_DATE\"\n\n SRC_FRAMES=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\")\n SRC_ELEMENTS=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n SRC_UI=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';\")\n SRC_OCR=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n SRC_MEETINGS=$(sqlite3 \"$DB_SRC\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';\")\n\n printf \" %-20s %s\\n\" \"frames:\" \"$SRC_FRAMES\"\n printf \" %-20s %s\\n\" \"elements:\" \"$SRC_ELEMENTS\"\n printf \" %-20s %s\\n\" \"ui_events:\" \"$SRC_UI\"\n printf \" %-20s %s\\n\" \"ocr_text:\" \"$SRC_OCR\"\n printf \" %-20s %s\\n\" \"meetings:\" \"$SRC_MEETINGS\"\n\n if [ \"$SRC_FRAMES\" -eq \"0\" ]; then\n log \"No frames found for $TARGET_DATE — skipping DB sync\"\n DB_ALREADY_SYNCED=true\n fi\n\nfi\n\nif [ \"$DB_ALREADY_SYNCED\" = false ]; then\n\n # ─── INIT TABLES ──────────────────────────────────────────────────────────\n step \"Initialising tables (CREATE IF NOT EXISTS)\"\n\n run_sqlite_heredoc \"creating tables\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;\nCREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;\nDETACH nas;\n\"\n\n # ─── SCHEMA DRIFT FIX ─────────────────────────────────────────────────────\n # Runs AFTER CREATE IF NOT EXISTS so newly-created tables are no-ops here,\n # and pre-existing tables get any missing columns added.\n step \"Reconciling NAS schema with source\"\n for tbl in \"${SYNC_TABLES[@]}\"; do\n ensure_columns \"$tbl\"\n done\n\n run_sqlite_heredoc \"creating indexes\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);\nCREATE INDEX IF NOT EXISTS nas.idx_frames_document_path ON frames(document_path) WHERE document_path IS NOT NULL;\nCREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;\nCREATE INDEX IF NOT EXISTS nas.idx_elements_onscreen_frame ON elements(frame_id) WHERE on_screen = 1 AND text IS NOT NULL;\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);\nCREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);\nCREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);\nCREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"creating FTS tables\" \"\nATTACH '$NAS_DB' AS nas;\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(\n text, role, frame_id UNINDEXED,\n content='elements', content_rowid='id', tokenize='unicode61'\n);\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(\n full_text, app_name, window_name, browser_url, id UNINDEXED,\n tokenize='unicode61'\n);\nCREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(\n text_content,\n app_name,\n window_title,\n element_name,\n content='ui_events',\n content_rowid='id',\n tokenize='unicode61'\n);\nDETACH nas;\n\"\n\n # ─── BUILD EXPLICIT COLUMN LISTS ──────────────────────────────────────────\n # After ensure_columns, source ⊆ NAS for every synced table, so source's\n # column list is a safe subset to use on both sides of the INSERT.\n FRAMES_COLS=$(build_col_list frames)\n ELEMENTS_COLS=$(build_col_list elements)\n UI_EVENTS_COLS=$(build_col_list ui_events)\n OCR_TEXT_COLS=$(build_col_list ocr_text)\n VIDEO_CHUNKS_COLS=$(build_col_list video_chunks)\n MEETINGS_COLS=$(build_col_list meetings)\n\n # ─── SYNC DATA ────────────────────────────────────────────────────────────\n step \"Syncing data for $TARGET_DATE\"\n\n run_sqlite_heredoc \"video_chunks\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.video_chunks ($VIDEO_CHUNKS_COLS)\n SELECT $VIDEO_CHUNKS_COLS FROM main.video_chunks\n WHERE id IN (\n SELECT DISTINCT video_chunk_id FROM main.frames\n WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL\n );\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames ($SRC_FRAMES rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.frames ($FRAMES_COLS)\n SELECT $FRAMES_COLS FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ocr_text ($SRC_OCR rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ocr_text ($OCR_TEXT_COLS)\n SELECT $OCR_TEXT_COLS FROM main.ocr_text o\n JOIN main.frames f ON o.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events ($SRC_UI rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ui_events ($UI_EVENTS_COLS)\n SELECT $UI_EVENTS_COLS FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"elements ($SRC_ELEMENTS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.elements ($ELEMENTS_COLS)\n SELECT $ELEMENTS_COLS FROM main.elements e\n JOIN main.frames f ON e.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"meetings ($SRC_MEETINGS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.meetings ($MEETINGS_COLS)\n SELECT $MEETINGS_COLS FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n # NOTE: the elements/ocr_text inserts use unqualified column names while\n # selecting from a JOIN. SQLite resolves them against the leftmost table\n # that has the column, which is what we want here (e.* / o.* implicitly),\n # because none of the column names collide with frames'.\n\n # ─── FTS UPDATE ───────────────────────────────────────────────────────────\n step \"Updating FTS indexes\"\n\n run_sqlite_heredoc \"elements_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.elements_fts(rowid, text, role)\n SELECT e.id, e.text, e.role\n FROM nas.elements e\n JOIN nas.frames f ON e.frame_id = f.id\n WHERE date(f.timestamp) = '$TARGET_DATE'\n AND e.text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)\n SELECT id, full_text, app_name, window_name, browser_url, id\n FROM nas.frames\n WHERE date(timestamp) = '$TARGET_DATE'\n AND full_text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)\n SELECT id, text_content, app_name, window_title, element_name\n FROM nas.ui_events\n WHERE date(timestamp) = '$TARGET_DATE'\n AND text_content IS NOT NULL;\nDETACH nas;\n\"\n\n # ─── VERIFY DB ────────────────────────────────────────────────────────────\n step \"Verifying DB\"\n\n V_FRAMES=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';\")\n V_ELEMENTS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n V_UI=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';\")\n V_OCR=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');\")\n V_MEETINGS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';\")\n\n check \"frames\" \"$V_FRAMES\" \"$SRC_FRAMES\"\n check \"elements\" \"$V_ELEMENTS\" \"$SRC_ELEMENTS\"\n check \"ui_events\" \"$V_UI\" \"$SRC_UI\"\n check \"ocr_text\" \"$V_OCR\" \"$SRC_OCR\"\n check \"meetings\" \"$V_MEETINGS\" \"$SRC_MEETINGS\"\n\nfi\n\n# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────\n# Always runs regardless of DB sync status\nstep \"Copying data folder for $TARGET_DATE\"\n\nif [ -d \"$DATA_SRC\" ]; then\n mkdir -p \"$NAS_DATA/$TARGET_DATE\"\n RSYNC_START=$(date +%s)\n printf \" %-36s \" \"rsync $TARGET_DATE/ → NAS\"\n rsync -a --ignore-existing \\\n \"$DATA_SRC/\" \\\n \"$NAS_DATA/$TARGET_DATE/\" \\\n 2>>\"$LOG_FILE\"\n RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))\n COPIED_FILES=$(ls \"$NAS_DATA/$TARGET_DATE\" | wc -l | tr -d ' ')\n SRC_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n COPIED_SIZE=$(du -sh \"$NAS_DATA/$TARGET_DATE\" | cut -f1)\n if [ \"$COPIED_FILES\" -eq \"$SRC_FILES\" ]; then\n printf \"\\r %-36s ✓ %dm%02ds (%s files, %s)\\n\" \\\n \"rsync $TARGET_DATE/ → NAS\" \\\n \"$(( RSYNC_DUR / 60 ))\" \"$(( RSYNC_DUR % 60 ))\" \\\n \"$COPIED_FILES\" \"$COPIED_SIZE\" | tee -a \"$LOG_FILE\"\n else\n printf \"\\r %-36s ✗ %s / %s files\\n\" \\\n \"rsync $TARGET_DATE/ → NAS\" \"$COPIED_FILES\" \"$SRC_FILES\" | tee -a \"$LOG_FILE\"\n fi\nelse\n printf \" %-36s %s\\n\" \"rsync $TARGET_DATE/ → NAS\" \"skipped (no source dir)\"\nfi\n\n# ─── SUMMARY ──────────────────────────────────────────────────────────────────\nTOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))\nDB_SIZE=$(du -sh \"$NAS_DB\" | cut -f1)\n\necho \"\"\nlog \"Archive DB size: $DB_SIZE\"\nlog \"Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s\"\nlog \"Sync complete for $TARGET_DATE\"\nlog \"========================================\"","depth":29,"bounds":{"left":0.11569149,"top":0.0933759,"width":0.35804522,"height":0.0007980846},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Implement and run pipe l…, Editor Group 2","depth":28,"bounds":{"left":0.5578458,"top":0.047885075,"width":0.073803194,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":false},{"role":"AXRadioButton","text":"Problems (⇧⌘M)","depth":22,"bounds":{"left":0.118351065,"top":0.7278532,"width":0.027925532,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"PROBLEMS","depth":24,"bounds":{"left":0.122340426,"top":0.7366321,"width":0.019946808,"height":0.0103751},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Output (⇧⌘U)","depth":22,"bounds":{"left":0.14594415,"top":0.7278532,"width":0.023603724,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUTPUT","depth":24,"bounds":{"left":0.14993352,"top":0.7366321,"width":0.015625,"height":0.0103751},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Debug Console (⇧⌘Y)","depth":22,"bounds":{"left":0.16921543,"top":0.7278532,"width":0.039893616,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"DEBUG CONSOLE","depth":24,"bounds":{"left":0.1732048,"top":0.7366321,"width":0.031914894,"height":0.0103751},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Terminal (⌃`)","depth":22,"bounds":{"left":0.2087766,"top":0.7278532,"width":0.026595745,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":true},{"role":"AXStaticText","text":"TERMINAL","depth":24,"bounds":{"left":0.21276596,"top":0.7366321,"width":0.01861702,"height":0.0103751},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Ports - 1 forwarded port","depth":22,"bounds":{"left":0.23537233,"top":0.7278532,"width":0.026263298,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"PORTS","depth":24,"bounds":{"left":0.2393617,"top":0.7366321,"width":0.012300532,"height":0.0103751},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":25,"bounds":{"left":0.25465426,"top":0.73743016,"width":0.0019946808,"height":0.008778931},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"remote SSH: nas","depth":16,"bounds":{"left":0.0006648936,"top":0.98244214,"width":0.028590426,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.0033244682,"top":0.9848364,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"SSH: nas","depth":17,"bounds":{"left":0.008643617,"top":0.9856345,"width":0.017952127,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"screenpipe (Git) - master*, Checkout Branch/Tag...","depth":16,"bounds":{"left":0.030917553,"top":0.98244214,"width":0.023271276,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.031914894,"top":0.9848364,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"master*","depth":17,"bounds":{"left":0.03723404,"top":0.9856345,"width":0.015957447,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"screenpipe (Git) - Synchronize Changes","depth":16,"bounds":{"left":0.05418883,"top":0.98244214,"width":0.00731383,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"No Problems","depth":16,"bounds":{"left":0.06416223,"top":0.98244214,"width":0.022606382,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.06582447,"top":0.9848364,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"0","depth":17,"bounds":{"left":0.07114362,"top":0.9856345,"width":0.004986702,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.07579787,"top":0.9848364,"width":0.0056515955,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"0","depth":17,"bounds":{"left":0.08111702,"top":0.9856345,"width":0.0039893617,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Forwarded Ports: 8766","depth":16,"bounds":{"left":0.08843085,"top":0.98244214,"width":0.012632979,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.09009308,"top":0.9848364,"width":0.0056515955,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":17,"bounds":{"left":0.09541223,"top":0.9856345,"width":0.0039893617,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Notifications","depth":16,"bounds":{"left":0.9886968,"top":0.98244214,"width":0.010638298,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sign In","depth":16,"bounds":{"left":0.9650931,"top":0.98244214,"width":0.022606382,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.96675533,"top":0.9848364,"width":0.0056515955,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Sign In","depth":17,"bounds":{"left":0.97207445,"top":0.9856345,"width":0.013962766,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"No results found","depth":12,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Implement and run pipe logic","depth":19,"bounds":{"left":0.56017286,"top":0.08060654,"width":0.07114362,"height":0.022346368},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false}]...
|
8587183063490674106
|
4328126292698795287
|
click
|
accessibility
|
NULL
|
Explorer (⇧⌘E) - 1 unsaved file
1
Search (⇧⌘F)
Explorer (⇧⌘E) - 1 unsaved file
1
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py
M
db.py
docker-compose.yml
Dockerfile
M
main.py
M
requirements.txt
M
data
logs
pipes
.gitignore
app_settings.json
archive.db
archive.db-bak
U
db.sqlite
db.sqlite-shm
db.sqlite-wal
screenpipe_sync_updated.sh
U
screenpipe_sync.sh
screenpipe.db
Outline Section
OUTLINE
OUTLINE
Timeline Section
TIMELINE
TIMELINE
app_settings.json, Editor Group 1
screenpipe_sync.sh, Editor Group 1
screenpipe_sync_updated.sh, preview, Editor Group 1
pipe.md, Editor Group 1
.env, Editor Group 1
#!/bin/bash
# screenpipe_sync.sh
# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).
# Also copies the day's video/frame data folder to the NAS.
#
# Schema-drift tolerant: if Screenpipe migrations add new columns to the source DB,
# the NAS archive gets ALTER TABLE'd to match. Inserts use explicit column lists,
# so positional mismatches can't occur.
#
# Usage:
# ./screenpipe_sync.sh # syncs yesterday (default)
# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date
# ./screenpipe_sync.sh today # syncs today so far
#
# Cron example (runs at 3am daily):
# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1
set -euo pipefail
# ─── CONFIG ───────────────────────────────────────────────────────────────────
DB_SRC="${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}"
NAS_MOUNT="${NAS_MOUNT:-/Volumes/screenpipe}"
NAS_DB="$NAS_MOUNT/archive.db"
NAS_DATA="$NAS_MOUNT/data"
LOG_FILE="$HOME/.screenpipe/sync.log"
# Tables that get schema drift handling. Order matters for FK-ish references
# (parents before children: video_chunks → frames → elements/ocr_text/ui_events).
SYNC_TABLES=(video_chunks frames elements ocr_text ui_events meetings)
# ──────────────────────────────────────────────────────────────────────────────
# ─── HELPERS ──────────────────────────────────────────────────────────────────
SCRIPT_START=$(date +%s)
log() {
local msg="[$(date '+%Y-%m-%d %H:%M:%S')] $*"
echo "$msg" | tee -a "$LOG_FILE"
}
step() {
local now=$(date +%s)
local elapsed=$(( now - SCRIPT_START ))
local min=$(( elapsed / 60 ))
local sec=$(( elapsed % 60 ))
printf "\n[+%02dm%02ds] ▶ %s\n" "$min" "$sec" "$*" | tee -a "$LOG_FILE"
}
run_sqlite_heredoc() {
local label="$1"
local sql="$2"
local start=$(date +%s)
printf " %-36s " "$label"
sqlite3 "$DB_SRC" <<< "$sql" &
local pid=$!
local spin=[PASSWORD] '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')
local i=0
while kill -0 "$pid" 2>/dev/null; do
printf "\r %-36s %s " "$label" "${spin[$i]}"
i=$(( (i + 1) % 10 ))
sleep 0.2
done
wait "$pid"
local rc=$?
if [ $rc -ne 0 ]; then
printf "\r %-36s ✗ FAILED\n" "$label" | tee -a "$LOG_FILE"
exit $rc
fi
local dur=$(( $(date +%s) - start ))
printf "\r %-36s ✓ %dm%02ds\n" "$label" "$(( dur / 60 ))" "$(( dur % 60 ))" | tee -a "$LOG_FILE"
}
check() {
local label="$1" got="$2" expected="$3"
if [ "$got" -eq "$expected" ]; then
printf " %-20s %s / %s ✓\n" "$label:" "$got" "$expected"
else
printf " %-20s %s / %s ✗ MISMATCH\n" "$label:" "$got" "$expected"
fi
}
# ─── SCHEMA HELPERS ───────────────────────────────────────────────────────────
# Echoes "name|type" lines for a table from a given DB.
table_columns_with_types() {
local db="$1" table="$2"
sqlite3 "$db" "PRAGMA table_info($table);" | awk -F'|' '{print $2 "|" $3}'
}
# Echoes just column names, one per line.
table_columns() {
local db="$1" table="$2"
sqlite3 "$db" "PRAGMA table_info($table);" | awk -F'|' '{print $2}'
}
# Returns true (0) if a table exists in the given DB.
table_exists() {
local db="$1" table="$2"
local count
count=$(sqlite3 "$db" "SELECT COUNT(*) FROM sqlite_master WHERE type='table' AND name='$table';")
[ "$count" -gt 0 ]
}
# Adds any columns present in source but missing in NAS for the given table.
# Uses ALTER TABLE ADD COLUMN, which is a fast metadata-only operation in SQLite.
ensure_columns() {
local table="$1"
local label="schema: $table"
printf " %-36s " "$label"
if ! table_exists "$DB_SRC" "$table"; then
printf "✗ source missing — skipping\n"
return 0
fi
if ! table_exists "$NAS_DB" "$table"; then
printf "✓ fresh (created above)\n"
return 0
fi
local src_cols
src_cols=$(table_columns_with_types "$DB_SRC" "$table")
local nas_cols
nas_cols=$(table_columns "$NAS_DB" "$table")
local added=0
local added_names=""
while IFS='|' read -r name type; do
[ -z "$name" ] && continue
# Use grep -F -x for fixed-string exact match (safe against regex chars).
if ! echo "$nas_cols" | grep -Fxq "$name"; then
# SQLite ALTER TABLE ADD COLUMN: type is optional, no NOT NULL allowed
# without a constant default. Default-NULL is exactly what we want for archive.
sqlite3 "$NAS_DB" "ALTER TABLE $table ADD COLUMN \"$name\" $type;"
added=$((added + 1))
added_names="$added_names $name"
fi
done <<< "$src_cols"
if [ "$added" -gt 0 ]; then
printf "✓ added %d:%s\n" "$added" "$added_names"
else
printf "✓ in sync\n"
fi
}
# Echoes a comma-separated list of source columns for a table, double-quoted
# so reserved words and hyphens are safe. Used for both INSERT and SELECT sides.
build_col_list() {
local table="$1"
table_columns "$DB_SRC" "$table" | awk 'NF' | sed 's/.*/"&"/' | paste -sd, -
}
# ──────────────────────────────────────────────────────────────────────────────
# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────
if [ "${1:-}" = "today" ]; then
TARGET_DATE=$(date +%Y-%m-%d)
elif [ -n "${1:-}" ]; then
TARGET_DATE="$1"
if ! [[ "$TARGET_DATE" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then
echo "ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday."
exit 1
fi
else
TARGET_DATE=$(date -v-1d +%Y-%m-%d)
fi
log "========================================"
log "Screenpipe sync starting for: $TARGET_DATE"
log "========================================"
# ─── PREFLIGHT ────────────────────────────────────────────────────────────────
step "Preflight checks"
if [ ! -f "$DB_SRC" ]; then
log "ERROR: Source DB not found at $DB_SRC"; exit 1
fi
printf " %-20s %s (%s)\n" "Source DB:" "OK" "$(du -sh "$DB_SRC" | cut -f1)"
if [ ! -d "$NAS_MOUNT" ]; then
log "ERROR: NAS not mounted at $NAS_MOUNT"; exit 1
fi
printf " %-20s %s\n" "NAS mount:" "OK $NAS_MOUNT"
# Check if DB already synced for this date
DB_ALREADY_SYNCED=false
if [ -f "$NAS_DB" ]; then
if table_exists "$NAS_DB" "frames"; then
EXISTING=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';" 2>/dev/null || echo "0")
if [ "$EXISTING" -gt "0" ]; then
log "Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync"
DB_ALREADY_SYNCED=true
else
printf " %-20s %s (%s)\n" "Archive DB:" "exists" "$(du -sh "$NAS_DB" | cut -f1)"
fi
else
printf " %-20s %s\n" "Archive DB:" "exists, no frames table yet"
fi
else
printf " %-20s %s\n" "Archive DB:" "will be created"
fi
# Source data dir for this date
DATA_SRC="$HOME/.screenpipe/data/data/$TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
DATA_SIZE=$(du -sh "$DATA_SRC" | cut -f1)
DATA_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
printf " %-20s %s (%s files, %s)\n" "Data dir:" "OK" "$DATA_FILES" "$DATA_SIZE"
else
printf " %-20s %s\n" "Data dir:" "not found — skipping file copy"
fi
# ─── DB SYNC ──────────────────────────────────────────────────────────────────
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────
step "Counting source rows for $TARGET_DATE"
SRC_FRAMES=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
SRC_ELEMENTS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_UI=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
SRC_OCR=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_MEETINGS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';")
printf " %-20s %s\n" "frames:" "$SRC_FRAMES"
printf " %-20s %s\n" "elements:" "$SRC_ELEMENTS"
printf " %-20s %s\n" "ui_events:" "$SRC_UI"
printf " %-20s %s\n" "ocr_text:" "$SRC_OCR"
printf " %-20s %s\n" "meetings:" "$SRC_MEETINGS"
if [ "$SRC_FRAMES" -eq "0" ]; then
log "No frames found for $TARGET_DATE — skipping DB sync"
DB_ALREADY_SYNCED=true
fi
fi
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── INIT TABLES ──────────────────────────────────────────────────────────
step "Initialising tables (CREATE IF NOT EXISTS)"
run_sqlite_heredoc "creating tables" "
ATTACH '$NAS_DB' AS nas;
CREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;
CREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;
CREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;
CREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;
DETACH nas;
"
# ─── SCHEMA DRIFT FIX ─────────────────────────────────────────────────────
# Runs AFTER CREATE IF NOT EXISTS so newly-created tables are no-ops here,
# and pre-existing tables get any missing columns added.
step "Reconciling NAS schema with source"
for tbl in "${SYNC_TABLES[@]}"; do
ensure_columns "$tbl"
done
run_sqlite_heredoc "creating indexes" "
ATTACH '$NAS_DB' AS nas;
CREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);
CREATE INDEX IF NOT EXISTS nas.idx_frames_document_path ON frames(document_path) WHERE document_path IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_elements_onscreen_frame ON elements(frame_id) WHERE on_screen = 1 AND text IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);
CREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);
DETACH nas;
"
run_sqlite_heredoc "creating FTS tables" "
ATTACH '$NAS_DB' AS nas;
CREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(
text, role, frame_id UNINDEXED,
content='elements', content_rowid='id', tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(
full_text, app_name, window_name, browser_url, id UNINDEXED,
tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(
text_content,
app_name,
window_title,
element_name,
content='ui_events',
content_rowid='id',
tokenize='unicode61'
);
DETACH nas;
"
# ─── BUILD EXPLICIT COLUMN LISTS ──────────────────────────────────────────
# After ensure_columns, source ⊆ NAS for every synced table, so source's
# column list is a safe subset to use on both sides of the INSERT.
FRAMES_COLS=$(build_col_list frames)
ELEMENTS_COLS=$(build_col_list elements)
UI_EVENTS_COLS=$(build_col_list ui_events)
OCR_TEXT_COLS=$(build_col_list ocr_text)
VIDEO_CHUNKS_COLS=$(build_col_list video_chunks)
MEETINGS_COLS=$(build_col_list meetings)
# ─── SYNC DATA ────────────────────────────────────────────────────────────
step "Syncing data for $TARGET_DATE"
run_sqlite_heredoc "video_chunks" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.video_chunks ($VIDEO_CHUNKS_COLS)
SELECT $VIDEO_CHUNKS_COLS FROM main.video_chunks
WHERE id IN (
SELECT DISTINCT video_chunk_id FROM main.frames
WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL
);
DETACH nas;
"
run_sqlite_heredoc "frames ($SRC_FRAMES rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.frames ($FRAMES_COLS)
SELECT $FRAMES_COLS FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ocr_text ($SRC_OCR rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ocr_text ($OCR_TEXT_COLS)
SELECT $OCR_TEXT_COLS FROM main.ocr_text o
JOIN main.frames f ON o.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ui_events ($SRC_UI rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ui_events ($UI_EVENTS_COLS)
SELECT $UI_EVENTS_COLS FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "elements ($SRC_ELEMENTS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.elements ($ELEMENTS_COLS)
SELECT $ELEMENTS_COLS FROM main.elements e
JOIN main.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "meetings ($SRC_MEETINGS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.meetings ($MEETINGS_COLS)
SELECT $MEETINGS_COLS FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';
DETACH nas;
"
# NOTE: the elements/ocr_text inserts use unqualified column names while
# selecting from a JOIN. SQLite resolves them against the leftmost table
# that has the column, which is what we want here (e.* / o.* implicitly),
# because none of the column names collide with frames'.
# ─── FTS UPDATE ───────────────────────────────────────────────────────────
step "Updating FTS indexes"
run_sqlite_heredoc "elements_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.elements_fts(rowid, text, role)
SELECT e.id, e.text, e.role
FROM nas.elements e
JOIN nas.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE'
AND e.text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "frames_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)
SELECT id, full_text, app_name, window_name, browser_url, id
FROM nas.frames
WHERE date(timestamp) = '$TARGET_DATE'
AND full_text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "ui_events_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)
SELECT id, text_content, app_name, window_title, element_name
FROM nas.ui_events
WHERE date(timestamp) = '$TARGET_DATE'
AND text_content IS NOT NULL;
DETACH nas;
"
# ─── VERIFY DB ────────────────────────────────────────────────────────────
step "Verifying DB"
V_FRAMES=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
V_ELEMENTS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_UI=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
V_OCR=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_MEETINGS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';")
check "frames" "$V_FRAMES" "$SRC_FRAMES"
check "elements" "$V_ELEMENTS" "$SRC_ELEMENTS"
check "ui_events" "$V_UI" "$SRC_UI"
check "ocr_text" "$V_OCR" "$SRC_OCR"
check "meetings" "$V_MEETINGS" "$SRC_MEETINGS"
fi
# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────
# Always runs regardless of DB sync status
step "Copying data folder for $TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
mkdir -p "$NAS_DATA/$TARGET_DATE"
RSYNC_START=$(date +%s)
printf " %-36s " "rsync $TARGET_DATE/ → NAS"
rsync -a --ignore-existing \
"$DATA_SRC/" \
"$NAS_DATA/$TARGET_DATE/" \
2>>"$LOG_FILE"
RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))
COPIED_FILES=$(ls "$NAS_DATA/$TARGET_DATE" | wc -l | tr -d ' ')
SRC_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
COPIED_SIZE=$(du -sh "$NAS_DATA/$TARGET_DATE" | cut -f1)
if [ "$COPIED_FILES" -eq "$SRC_FILES" ]; then
printf "\r %-36s ✓ %dm%02ds (%s files, %s)\n" \
"rsync $TARGET_DATE/ → NAS" \
"$(( RSYNC_DUR / 60 ))" "$(( RSYNC_DUR % 60 ))" \
"$COPIED_FILES" "$COPIED_SIZE" | tee -a "$LOG_FILE"
else
printf "\r %-36s ✗ %s / %s files\n" \
"rsync $TARGET_DATE/ → NAS" "$COPIED_FILES" "$SRC_FILES" | tee -a "$LOG_FILE"
fi
else
printf " %-36s %s\n" "rsync $TARGET_DATE/ → NAS" "skipped (no source dir)"
fi
# ─── SUMMARY ──────────────────────────────────────────────────────────────────
TOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))
DB_SIZE=$(du -sh "$NAS_DB" | cut -f1)
echo ""
log "Archive DB size: $DB_SIZE"
log "Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s"
log "Sync complete for $TARGET_DATE"
log "========================================"
#!/bin/bash
# screenpipe_sync.sh
# Syncs Screenpipe SQLite data to a NAS archive database (append-only, no deletions).
# Also copies the day's video/frame data folder to the NAS.
#
# Schema-drift tolerant: if Screenpipe migrations add new columns to the source DB,
# the NAS archive gets ALTER TABLE'd to match. Inserts use explicit column lists,
# so positional mismatches can't occur.
#
# Usage:
# ./screenpipe_sync.sh # syncs yesterday (default)
# ./screenpipe_sync.sh 2026-04-15 # syncs a specific date
# ./screenpipe_sync.sh today # syncs today so far
#
# Cron example (runs at 3am daily):
# 0 3 * * * /Users/lukas/.screenpipe/screenpipe_sync.sh >> /Users/lukas/.screenpipe/sync.log 2>&1
set -euo pipefail
# ─── CONFIG ───────────────────────────────────────────────────────────────────
DB_SRC="${SCREENPIPE_DB:-$HOME/.screenpipe/db.sqlite}"
NAS_MOUNT="${NAS_MOUNT:-/Volumes/screenpipe}"
NAS_DB="$NAS_MOUNT/archive.db"
NAS_DATA="$NAS_MOUNT/data"
LOG_FILE="$HOME/.screenpipe/sync.log"
# Tables that get schema drift handling. Order matters for FK-ish references
# (parents before children: video_chunks → frames → elements/ocr_text/ui_events).
SYNC_TABLES=(video_chunks frames elements ocr_text ui_events meetings)
# ──────────────────────────────────────────────────────────────────────────────
# ─── HELPERS ──────────────────────────────────────────────────────────────────
SCRIPT_START=$(date +%s)
log() {
local msg="[$(date '+%Y-%m-%d %H:%M:%S')] $*"
echo "$msg" | tee -a "$LOG_FILE"
}
step() {
local now=$(date +%s)
local elapsed=$(( now - SCRIPT_START ))
local min=$(( elapsed / 60 ))
local sec=$(( elapsed % 60 ))
printf "\n[+%02dm%02ds] ▶ %s\n" "$min" "$sec" "$*" | tee -a "$LOG_FILE"
}
run_sqlite_heredoc() {
local label="$1"
local sql="$2"
local start=$(date +%s)
printf " %-36s " "$label"
sqlite3 "$DB_SRC" <<< "$sql" &
local pid=$!
local spin=[PASSWORD] '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')
local i=0
while kill -0 "$pid" 2>/dev/null; do
printf "\r %-36s %s " "$label" "${spin[$i]}"
i=$(( (i + 1) % 10 ))
sleep 0.2
done
wait "$pid"
local rc=$?
if [ $rc -ne 0 ]; then
printf "\r %-36s ✗ FAILED\n" "$label" | tee -a "$LOG_FILE"
exit $rc
fi
local dur=$(( $(date +%s) - start ))
printf "\r %-36s ✓ %dm%02ds\n" "$label" "$(( dur / 60 ))" "$(( dur % 60 ))" | tee -a "$LOG_FILE"
}
check() {
local label="$1" got="$2" expected="$3"
if [ "$got" -eq "$expected" ]; then
printf " %-20s %s / %s ✓\n" "$label:" "$got" "$expected"
else
printf " %-20s %s / %s ✗ MISMATCH\n" "$label:" "$got" "$expected"
fi
}
# ─── SCHEMA HELPERS ───────────────────────────────────────────────────────────
# Echoes "name|type" lines for a table from a given DB.
table_columns_with_types() {
local db="$1" table="$2"
sqlite3 "$db" "PRAGMA table_info($table);" | awk -F'|' '{print $2 "|" $3}'
}
# Echoes just column names, one per line.
table_columns() {
local db="$1" table="$2"
sqlite3 "$db" "PRAGMA table_info($table);" | awk -F'|' '{print $2}'
}
# Returns true (0) if a table exists in the given DB.
table_exists() {
local db="$1" table="$2"
local count
count=$(sqlite3 "$db" "SELECT COUNT(*) FROM sqlite_master WHERE type='table' AND name='$table';")
[ "$count" -gt 0 ]
}
# Adds any columns present in source but missing in NAS for the given table.
# Uses ALTER TABLE ADD COLUMN, which is a fast metadata-only operation in SQLite.
ensure_columns() {
local table="$1"
local label="schema: $table"
printf " %-36s " "$label"
if ! table_exists "$DB_SRC" "$table"; then
printf "✗ source missing — skipping\n"
return 0
fi
if ! table_exists "$NAS_DB" "$table"; then
printf "✓ fresh (created above)\n"
return 0
fi
local src_cols
src_cols=$(table_columns_with_types "$DB_SRC" "$table")
local nas_cols
nas_cols=$(table_columns "$NAS_DB" "$table")
local added=0
local added_names=""
while IFS='|' read -r name type; do
[ -z "$name" ] && continue
# Use grep -F -x for fixed-string exact match (safe against regex chars).
if ! echo "$nas_cols" | grep -Fxq "$name"; then
# SQLite ALTER TABLE ADD COLUMN: type is optional, no NOT NULL allowed
# without a constant default. Default-NULL is exactly what we want for archive.
sqlite3 "$NAS_DB" "ALTER TABLE $table ADD COLUMN \"$name\" $type;"
added=$((added + 1))
added_names="$added_names $name"
fi
done <<< "$src_cols"
if [ "$added" -gt 0 ]; then
printf "✓ added %d:%s\n" "$added" "$added_names"
else
printf "✓ in sync\n"
fi
}
# Echoes a comma-separated list of source columns for a table, double-quoted
# so reserved words and hyphens are safe. Used for both INSERT and SELECT sides.
build_col_list() {
local table="$1"
table_columns "$DB_SRC" "$table" | awk 'NF' | sed 's/.*/"&"/' | paste -sd, -
}
# ──────────────────────────────────────────────────────────────────────────────
# ─── DATE ARGUMENT ────────────────────────────────────────────────────────────
if [ "${1:-}" = "today" ]; then
TARGET_DATE=$(date +%Y-%m-%d)
elif [ -n "${1:-}" ]; then
TARGET_DATE="$1"
if ! [[ "$TARGET_DATE" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then
echo "ERROR: Invalid date format. Use YYYY-MM-DD, 'today', or no argument for yesterday."
exit 1
fi
else
TARGET_DATE=$(date -v-1d +%Y-%m-%d)
fi
log "========================================"
log "Screenpipe sync starting for: $TARGET_DATE"
log "========================================"
# ─── PREFLIGHT ────────────────────────────────────────────────────────────────
step "Preflight checks"
if [ ! -f "$DB_SRC" ]; then
log "ERROR: Source DB not found at $DB_SRC"; exit 1
fi
printf " %-20s %s (%s)\n" "Source DB:" "OK" "$(du -sh "$DB_SRC" | cut -f1)"
if [ ! -d "$NAS_MOUNT" ]; then
log "ERROR: NAS not mounted at $NAS_MOUNT"; exit 1
fi
printf " %-20s %s\n" "NAS mount:" "OK $NAS_MOUNT"
# Check if DB already synced for this date
DB_ALREADY_SYNCED=false
if [ -f "$NAS_DB" ]; then
if table_exists "$NAS_DB" "frames"; then
EXISTING=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';" 2>/dev/null || echo "0")
if [ "$EXISTING" -gt "0" ]; then
log "Date $TARGET_DATE already has $EXISTING frames in archive — skipping DB sync"
DB_ALREADY_SYNCED=true
else
printf " %-20s %s (%s)\n" "Archive DB:" "exists" "$(du -sh "$NAS_DB" | cut -f1)"
fi
else
printf " %-20s %s\n" "Archive DB:" "exists, no frames table yet"
fi
else
printf " %-20s %s\n" "Archive DB:" "will be created"
fi
# Source data dir for this date
DATA_SRC="$HOME/.screenpipe/data/data/$TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
DATA_SIZE=$(du -sh "$DATA_SRC" | cut -f1)
DATA_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
printf " %-20s %s (%s files, %s)\n" "Data dir:" "OK" "$DATA_FILES" "$DATA_SIZE"
else
printf " %-20s %s\n" "Data dir:" "not found — skipping file copy"
fi
# ─── DB SYNC ──────────────────────────────────────────────────────────────────
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── COUNT SOURCE ROWS ────────────────────────────────────────────────────
step "Counting source rows for $TARGET_DATE"
SRC_FRAMES=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
SRC_ELEMENTS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_UI=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
SRC_OCR=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
SRC_MEETINGS=$(sqlite3 "$DB_SRC" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE';")
printf " %-20s %s\n" "frames:" "$SRC_FRAMES"
printf " %-20s %s\n" "elements:" "$SRC_ELEMENTS"
printf " %-20s %s\n" "ui_events:" "$SRC_UI"
printf " %-20s %s\n" "ocr_text:" "$SRC_OCR"
printf " %-20s %s\n" "meetings:" "$SRC_MEETINGS"
if [ "$SRC_FRAMES" -eq "0" ]; then
log "No frames found for $TARGET_DATE — skipping DB sync"
DB_ALREADY_SYNCED=true
fi
fi
if [ "$DB_ALREADY_SYNCED" = false ]; then
# ─── INIT TABLES ──────────────────────────────────────────────────────────
step "Initialising tables (CREATE IF NOT EXISTS)"
run_sqlite_heredoc "creating tables" "
ATTACH '$NAS_DB' AS nas;
CREATE TABLE IF NOT EXISTS nas.frames AS SELECT * FROM main.frames WHERE 0;
CREATE TABLE IF NOT EXISTS nas.elements AS SELECT * FROM main.elements WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ui_events AS SELECT * FROM main.ui_events WHERE 0;
CREATE TABLE IF NOT EXISTS nas.ocr_text AS SELECT * FROM main.ocr_text WHERE 0;
CREATE TABLE IF NOT EXISTS nas.video_chunks AS SELECT * FROM main.video_chunks WHERE 0;
CREATE TABLE IF NOT EXISTS nas.meetings AS SELECT * FROM main.meetings WHERE 0;
DETACH nas;
"
# ─── SCHEMA DRIFT FIX ─────────────────────────────────────────────────────
# Runs AFTER CREATE IF NOT EXISTS so newly-created tables are no-ops here,
# and pre-existing tables get any missing columns added.
step "Reconciling NAS schema with source"
for tbl in "${SYNC_TABLES[@]}"; do
ensure_columns "$tbl"
done
run_sqlite_heredoc "creating indexes" "
ATTACH '$NAS_DB' AS nas;
CREATE INDEX IF NOT EXISTS nas.idx_frames_timestamp ON frames(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_frames_app_name ON frames(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_window_name ON frames(window_name);
CREATE INDEX IF NOT EXISTS nas.idx_frames_video_chunk_id ON frames(video_chunk_id);
CREATE INDEX IF NOT EXISTS nas.idx_frames_document_path ON frames(document_path) WHERE document_path IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_id ON elements(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_elements_frame_src_role ON elements(frame_id, source, role) WHERE text IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_elements_onscreen_frame ON elements(frame_id) WHERE on_screen = 1 AND text IS NOT NULL;
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_timestamp ON ui_events(timestamp);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_app_name ON ui_events(app_name);
CREATE INDEX IF NOT EXISTS nas.idx_ui_events_frame_id ON ui_events(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_ocr_text_frame_id ON ocr_text(frame_id);
CREATE INDEX IF NOT EXISTS nas.idx_meetings_start ON meetings(meeting_start);
CREATE INDEX IF NOT EXISTS nas.idx_video_chunks_device ON video_chunks(device_name);
DETACH nas;
"
run_sqlite_heredoc "creating FTS tables" "
ATTACH '$NAS_DB' AS nas;
CREATE VIRTUAL TABLE IF NOT EXISTS nas.elements_fts USING fts5(
text, role, frame_id UNINDEXED,
content='elements', content_rowid='id', tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.frames_fts USING fts5(
full_text, app_name, window_name, browser_url, id UNINDEXED,
tokenize='unicode61'
);
CREATE VIRTUAL TABLE IF NOT EXISTS nas.ui_events_fts USING fts5(
text_content,
app_name,
window_title,
element_name,
content='ui_events',
content_rowid='id',
tokenize='unicode61'
);
DETACH nas;
"
# ─── BUILD EXPLICIT COLUMN LISTS ──────────────────────────────────────────
# After ensure_columns, source ⊆ NAS for every synced table, so source's
# column list is a safe subset to use on both sides of the INSERT.
FRAMES_COLS=$(build_col_list frames)
ELEMENTS_COLS=$(build_col_list elements)
UI_EVENTS_COLS=$(build_col_list ui_events)
OCR_TEXT_COLS=$(build_col_list ocr_text)
VIDEO_CHUNKS_COLS=$(build_col_list video_chunks)
MEETINGS_COLS=$(build_col_list meetings)
# ─── SYNC DATA ────────────────────────────────────────────────────────────
step "Syncing data for $TARGET_DATE"
run_sqlite_heredoc "video_chunks" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.video_chunks ($VIDEO_CHUNKS_COLS)
SELECT $VIDEO_CHUNKS_COLS FROM main.video_chunks
WHERE id IN (
SELECT DISTINCT video_chunk_id FROM main.frames
WHERE date(timestamp) = '$TARGET_DATE' AND video_chunk_id IS NOT NULL
);
DETACH nas;
"
run_sqlite_heredoc "frames ($SRC_FRAMES rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.frames ($FRAMES_COLS)
SELECT $FRAMES_COLS FROM main.frames WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ocr_text ($SRC_OCR rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ocr_text ($OCR_TEXT_COLS)
SELECT $OCR_TEXT_COLS FROM main.ocr_text o
JOIN main.frames f ON o.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "ui_events ($SRC_UI rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ui_events ($UI_EVENTS_COLS)
SELECT $UI_EVENTS_COLS FROM main.ui_events WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "elements ($SRC_ELEMENTS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.elements ($ELEMENTS_COLS)
SELECT $ELEMENTS_COLS FROM main.elements e
JOIN main.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "meetings ($SRC_MEETINGS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.meetings ($MEETINGS_COLS)
SELECT $MEETINGS_COLS FROM main.meetings WHERE date(meeting_start) = '$TARGET_DATE';
DETACH nas;
"
# NOTE: the elements/ocr_text inserts use unqualified column names while
# selecting from a JOIN. SQLite resolves them against the leftmost table
# that has the column, which is what we want here (e.* / o.* implicitly),
# because none of the column names collide with frames'.
# ─── FTS UPDATE ───────────────────────────────────────────────────────────
step "Updating FTS indexes"
run_sqlite_heredoc "elements_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.elements_fts(rowid, text, role)
SELECT e.id, e.text, e.role
FROM nas.elements e
JOIN nas.frames f ON e.frame_id = f.id
WHERE date(f.timestamp) = '$TARGET_DATE'
AND e.text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "frames_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)
SELECT id, full_text, app_name, window_name, browser_url, id
FROM nas.frames
WHERE date(timestamp) = '$TARGET_DATE'
AND full_text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "ui_events_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)
SELECT id, text_content, app_name, window_title, element_name
FROM nas.ui_events
WHERE date(timestamp) = '$TARGET_DATE'
AND text_content IS NOT NULL;
DETACH nas;
"
# ─── VERIFY DB ────────────────────────────────────────────────────────────
step "Verifying DB"
V_FRAMES=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE';")
V_ELEMENTS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM elements WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_UI=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE';")
V_OCR=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ocr_text WHERE frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE');")
V_MEETINGS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start)= '$TARGET_DATE';")
check "frames" "$V_FRAMES" "$SRC_FRAMES"
check "elements" "$V_ELEMENTS" "$SRC_ELEMENTS"
check "ui_events" "$V_UI" "$SRC_UI"
check "ocr_text" "$V_OCR" "$SRC_OCR"
check "meetings" "$V_MEETINGS" "$SRC_MEETINGS"
fi
# ─── COPY DATA FOLDER ─────────────────────────────────────────────────────────
# Always runs regardless of DB sync status
step "Copying data folder for $TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
mkdir -p "$NAS_DATA/$TARGET_DATE"
RSYNC_START=$(date +%s)
printf " %-36s " "rsync $TARGET_DATE/ → NAS"
rsync -a --ignore-existing \
"$DATA_SRC/" \
"$NAS_DATA/$TARGET_DATE/" \
2>>"$LOG_FILE"
RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))
COPIED_FILES=$(ls "$NAS_DATA/$TARGET_DATE" | wc -l | tr -d ' ')
SRC_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
COPIED_SIZE=$(du -sh "$NAS_DATA/$TARGET_DATE" | cut -f1)
if [ "$COPIED_FILES" -eq "$SRC_FILES" ]; then
printf "\r %-36s ✓ %dm%02ds (%s files, %s)\n" \
"rsync $TARGET_DATE/ → NAS" \
"$(( RSYNC_DUR / 60 ))" "$(( RSYNC_DUR % 60 ))" \
"$COPIED_FILES" "$COPIED_SIZE" | tee -a "$LOG_FILE"
else
printf "\r %-36s ✗ %s / %s files\n" \
"rsync $TARGET_DATE/ → NAS" "$COPIED_FILES" "$SRC_FILES" | tee -a "$LOG_FILE"
fi
else
printf " %-36s %s\n" "rsync $TARGET_DATE/ → NAS" "skipped (no source dir)"
fi
# ─── SUMMARY ──────────────────────────────────────────────────────────────────
TOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))
DB_SIZE=$(du -sh "$NAS_DB" | cut -f1)
echo ""
log "Archive DB size: $DB_SIZE"
log "Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s"
log "Sync complete for $TARGET_DATE"
log "========================================"
Implement and run pipe l…, Editor Group 2
Problems (⇧⌘M)
PROBLEMS
Output (⇧⌘U)
OUTPUT
Debug Console (⇧⌘Y)
DEBUG CONSOLE
Terminal (⌃`)
TERMINAL
Ports - 1 forwarded port
PORTS
1
remote SSH: nas
SSH: nas
screenpipe (Git) - master*, Checkout Branch/Tag...
master*
screenpipe (Git) - Synchronize Changes
No Problems
0
0
Forwarded Ports: 8766
1
Notifications
Sign In
Sign In
No results found
Implement and run pipe logic...
|
21114
|
NULL
|
NULL
|
NULL
|
|
21402
|
936
|
13
|
2026-05-11T17:48:12.939488+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-11/1778 /Users/lukas/.screenpipe/data/data/2026-05-11/1778521692939_m1.jpg...
|
Code
|
Implement and run pipe l… — screenpipe [SSH: nas]
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
iTerm2ShellEditViewSessionScriptsProfilesWindowHel iTerm2ShellEditViewSessionScriptsProfilesWindowHelp-zshDOCKER-rw-r--r---rw-r--r---rw-r--r---W-r--r---rw-r--r---rw-r--r---rw-r--r---rw-r--r---W-r--r-=-rw-r--r---rw-r--r--DEV (docker)$2APP (-zsh)*3-zsh841 lukasstaff562611May09:28soundcore AeroClip(input)_2026-05-11_06-28-15.mp4lukasstaff462011May09:29soundcore AeroClip(input)_2026-05-11_06-28-50.mp4lukasstaff881711May09:29soundcore AeroClip(input)_2026-05-11_06-29-22.mp41lukasstaff581211May09:30soundcore AeroClip(input)_2026-05-11_06-29-52.mp4lukasstaff567111May09:30soundcore AeroClip(input)_2026-05-11_06-30-22.mp41lukasstaff796311May09:31soundcore AeroClip(input)_2026-05-11_06-31-11.mp4lukasstaff6614111lukasstaff560611May09:32soundcore AeroClip(input)_2026-05-11_06-31-43.mp4May09:32soundcore AeroClip(input)_2026-05-11_06-32-20.mp4lukasstaff639011May09:33soundcore AeroCliplukasstaff6031311(input)_2026-05-11_06-32-52.mp41lukasstaff8843311May09:33soundcore AeroClip(input)_2026-05-11_06-33-22.mp4May09:34soundcoreAeroClipinput_2026-05-11_06-33-52.mp4lukasstaff12524911May09:34soundcore AeroClip(input)_2026-05-11_06-34-22.mp4-rw-r--r---=---e-rw-r--r---rw-r--r---rw-r--r---rw-r--r---=---s-rw-r--r---rw-r--r--1lukasstaff10297511May09:35soundcore AeroClip(input)_2026-05-11-06-34-•52.mp4lukasstaff2139911May09:35soundcore AeroClip(input)_2026-05-11_06-35-22.mp4lukasstaff3937911May09:36soundcore AeroClip(input)_2026-05-11_06-35-52.mp41lukasstaff995711May09:37soundcore AeroClip(input)_2026-05-11_.06-36-46.mp4lukasstaff8814811May09:37soundcore AeroClip(input)_2026-05-11_06-37-18.mp41lukasstaff13584011May09:38soundcore AeroClip(input)_2026-05-11_06-37-48.mp41lukasstaff3477011 May09:38soundcore AeroClip (input)_2026-05-11_06-38-18.mp4lukasstaff52737111lukasstaffMay09:39soundcore AeroClip(input)_2026-05-11_06-38-48.mp47007011 May09:39soundcore AeroClip(input)_2026-05-11_06-39-18.mp4lukasstaff5062811May09:40soundcore AeroClip(input)_2026-05-11_06-39-48.mp4-rw-r--r---W-r--T---rw-r--r---rw-r--r---rw-r--r---rw-r--r---V=---s-rw-r--r---rw-r--r--lukasstaff76838111lukasMay09:40soundcore AeroClip (input)_2026-05-11_06-40-18.mp4staff66733 11 May09:41soundcore AeroClip(input)_2026-05-11_06-40-48.mp41lukasstaff7788711May09:41soundcore AeroClip(input)_2026-05-11_06-41-18.mp41lukasstaff6392211May09:42soundcore AeroClip(input)_2026-05-11_06-41-48.mp4lukasstaff1888411May09:42soundcore AeroClip(input)_2026-05-11_06-42-18.mp411lukasstaff1394211May09:43soundcore AeroClip(input)_2026-05-11_06-42-56.mp4lukasstaff565011May09:44soundcore AeroCliplukasstaff462011May09:45(input)_2026-05-11_06-43-53.mp4soundcore AeroClip(input)_2026-05-11_06-44-38.mp41lukasstaff685111May09:45soundcore AeroClipinput_2026-05-11_06-45-10.mp4lukasstaff110711 May09:45soundcore AeroClip-rw-r--r---V=---e-rw-r--r---Ver-=---rw-r--r---rw-r--r---V=--es-rw-r--r---rw-r--r--lukasstaff1780011May19:18(input)_2026-05-11_06-45-22.mp4soundcore AeroClip(input)_2026-05-11_16-18-23.mp4lukasstaff1273211May19:19soundcore AeroClip(input)_2026-05-11_16-18-54.mp411lukasstaff736111May19:19soundcore AeroClip(input)_2026-05-11_16-19-24.mp4lukasstaff1662211May19:20soundcore AeroClip(input)_2026-05-11_16-19-54.mp4lukasstaff15093611May19:21soundcore AeroClip (input)_2026-05-11_16-20-29.mp41lukasstaff13473211May19:21soundcore AeroClip(input)_2026-05-11_16-21-01.mp4lukasstaff2369011May19:22soundcore AeroCliplukasstaff(input)_2026-05-11_16-21-31.mp41665111May19:22soundcore AeroClip(input)_2026-05-11__16-22-01.mp41lukasstaff692211May19:23soundcore AeroClip(input)_2026-05-11_16-22-31.mp4lukasstaff560311May19:23soundcore AeroClip(input)_2026-05-11_16-23-01.mp4-rw-r--r---rw-rlukasstaff4950911May19:24soundcore AeroClip(input)_2026-05-11_.16-23-31.mp41 lukasstaff34462 11May19:24soundcore AeroClip (input)_2026-05-11_16-24-01.mp4.ukas@Lukas-Kovaliks-MacBook-Pro-Jiminny'.screenpipe/data $ 11||-zsh*5screenpipe™100% <78• Mon 11 May 20:48:12181O 886-zshX7...
|
NULL
|
2693911880497730559
|
NULL
|
app_switch
|
ocr
|
NULL
|
iTerm2ShellEditViewSessionScriptsProfilesWindowHel iTerm2ShellEditViewSessionScriptsProfilesWindowHelp-zshDOCKER-rw-r--r---rw-r--r---rw-r--r---W-r--r---rw-r--r---rw-r--r---rw-r--r---rw-r--r---W-r--r-=-rw-r--r---rw-r--r--DEV (docker)$2APP (-zsh)*3-zsh841 lukasstaff562611May09:28soundcore AeroClip(input)_2026-05-11_06-28-15.mp4lukasstaff462011May09:29soundcore AeroClip(input)_2026-05-11_06-28-50.mp4lukasstaff881711May09:29soundcore AeroClip(input)_2026-05-11_06-29-22.mp41lukasstaff581211May09:30soundcore AeroClip(input)_2026-05-11_06-29-52.mp4lukasstaff567111May09:30soundcore AeroClip(input)_2026-05-11_06-30-22.mp41lukasstaff796311May09:31soundcore AeroClip(input)_2026-05-11_06-31-11.mp4lukasstaff6614111lukasstaff560611May09:32soundcore AeroClip(input)_2026-05-11_06-31-43.mp4May09:32soundcore AeroClip(input)_2026-05-11_06-32-20.mp4lukasstaff639011May09:33soundcore AeroCliplukasstaff6031311(input)_2026-05-11_06-32-52.mp41lukasstaff8843311May09:33soundcore AeroClip(input)_2026-05-11_06-33-22.mp4May09:34soundcoreAeroClipinput_2026-05-11_06-33-52.mp4lukasstaff12524911May09:34soundcore AeroClip(input)_2026-05-11_06-34-22.mp4-rw-r--r---=---e-rw-r--r---rw-r--r---rw-r--r---rw-r--r---=---s-rw-r--r---rw-r--r--1lukasstaff10297511May09:35soundcore AeroClip(input)_2026-05-11-06-34-•52.mp4lukasstaff2139911May09:35soundcore AeroClip(input)_2026-05-11_06-35-22.mp4lukasstaff3937911May09:36soundcore AeroClip(input)_2026-05-11_06-35-52.mp41lukasstaff995711May09:37soundcore AeroClip(input)_2026-05-11_.06-36-46.mp4lukasstaff8814811May09:37soundcore AeroClip(input)_2026-05-11_06-37-18.mp41lukasstaff13584011May09:38soundcore AeroClip(input)_2026-05-11_06-37-48.mp41lukasstaff3477011 May09:38soundcore AeroClip (input)_2026-05-11_06-38-18.mp4lukasstaff52737111lukasstaffMay09:39soundcore AeroClip(input)_2026-05-11_06-38-48.mp47007011 May09:39soundcore AeroClip(input)_2026-05-11_06-39-18.mp4lukasstaff5062811May09:40soundcore AeroClip(input)_2026-05-11_06-39-48.mp4-rw-r--r---W-r--T---rw-r--r---rw-r--r---rw-r--r---rw-r--r---V=---s-rw-r--r---rw-r--r--lukasstaff76838111lukasMay09:40soundcore AeroClip (input)_2026-05-11_06-40-18.mp4staff66733 11 May09:41soundcore AeroClip(input)_2026-05-11_06-40-48.mp41lukasstaff7788711May09:41soundcore AeroClip(input)_2026-05-11_06-41-18.mp41lukasstaff6392211May09:42soundcore AeroClip(input)_2026-05-11_06-41-48.mp4lukasstaff1888411May09:42soundcore AeroClip(input)_2026-05-11_06-42-18.mp411lukasstaff1394211May09:43soundcore AeroClip(input)_2026-05-11_06-42-56.mp4lukasstaff565011May09:44soundcore AeroCliplukasstaff462011May09:45(input)_2026-05-11_06-43-53.mp4soundcore AeroClip(input)_2026-05-11_06-44-38.mp41lukasstaff685111May09:45soundcore AeroClipinput_2026-05-11_06-45-10.mp4lukasstaff110711 May09:45soundcore AeroClip-rw-r--r---V=---e-rw-r--r---Ver-=---rw-r--r---rw-r--r---V=--es-rw-r--r---rw-r--r--lukasstaff1780011May19:18(input)_2026-05-11_06-45-22.mp4soundcore AeroClip(input)_2026-05-11_16-18-23.mp4lukasstaff1273211May19:19soundcore AeroClip(input)_2026-05-11_16-18-54.mp411lukasstaff736111May19:19soundcore AeroClip(input)_2026-05-11_16-19-24.mp4lukasstaff1662211May19:20soundcore AeroClip(input)_2026-05-11_16-19-54.mp4lukasstaff15093611May19:21soundcore AeroClip (input)_2026-05-11_16-20-29.mp41lukasstaff13473211May19:21soundcore AeroClip(input)_2026-05-11_16-21-01.mp4lukasstaff2369011May19:22soundcore AeroCliplukasstaff(input)_2026-05-11_16-21-31.mp41665111May19:22soundcore AeroClip(input)_2026-05-11__16-22-01.mp41lukasstaff692211May19:23soundcore AeroClip(input)_2026-05-11_16-22-31.mp4lukasstaff560311May19:23soundcore AeroClip(input)_2026-05-11_16-23-01.mp4-rw-r--r---rw-rlukasstaff4950911May19:24soundcore AeroClip(input)_2026-05-11_.16-23-31.mp41 lukasstaff34462 11May19:24soundcore AeroClip (input)_2026-05-11_16-24-01.mp4.ukas@Lukas-Kovaliks-MacBook-Pro-Jiminny'.screenpipe/data $ 11||-zsh*5screenpipe™100% <78• Mon 11 May 20:48:12181O 886-zshX7...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
21403
|
936
|
14
|
2026-05-11T17:48:15.887014+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-11/1778 /Users/lukas/.screenpipe/data/data/2026-05-11/1778521695887_m1.jpg...
|
Code
|
screenpipe_sync.sh — screenpipe [SSH: nas]
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Explorer (⇧⌘E) - 1 unsaved file
1
Search (⇧⌘F)
Explorer (⇧⌘E) - 1 unsaved file
1
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py
M
db.py
docker-compose.yml
Dockerfile
M
main.py
M...
|
[{"role":"AXRadioButton","text [{"role":"AXRadioButton","text":"Explorer (⇧⌘E) - 1 unsaved file","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":true},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Search (⇧⌘F)","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Source Control (⌃⇧G) - 10 pending changes","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"10","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Run and Debug (⇧⌘D)","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Remote Explorer","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Extensions (⇧⌘X) - 2 require update","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"2","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Claude Code","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"Containers","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXHeading","text":"EXPLORER","depth":17,"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"EXPLORER","depth":18,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Explorer Section: screenpipe [SSH: nas]","depth":21,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":true},{"role":"AXStaticText","text":"","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"Explorer Section: screenpipe [SSH: nas]","depth":22,"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"SCREENPIPE [SSH: NAS]","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"#recycle","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"app","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"__pycache__","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"consumers","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"static","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":".env","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"cli.py","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.py","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"docker-compose.yml","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Dockerfile","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"main.py","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"on_screen":true,"role_description":"text"}]...
|
-6495722819554312565
|
-7857805097739495028
|
click
|
accessibility
|
NULL
|
Explorer (⇧⌘E) - 1 unsaved file
1
Search (⇧⌘F)
Explorer (⇧⌘E) - 1 unsaved file
1
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py
M
db.py
docker-compose.yml
Dockerfile
M
main.py
M...
|
21402
|
NULL
|
NULL
|
NULL
|
|
21404
|
937
|
20
|
2026-05-11T17:48:12.939765+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-11/1778 /Users/lukas/.screenpipe/data/data/2026-05-11/1778521692939_m2.jpg...
|
Code
|
Implement and run pipe l… — screenpipe [SSH: nas]
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
SioCodeselectionvIewWindowy apo settinas.isonV SCR SioCodeselectionvIewWindowy apo settinas.isonV SCREENPIPE [SSH: NAS]/ #recycleconsumers> static• .env& cli.py# db.pvdocker-compose.vmli# Dockertilemain.py=requirements.txt• data>logs→oinec• aitianore* aoo settinas.ison=archive.db=archive.db-bal= db salite=dh salite.chmE dh calite-wall$ screennine svnc undated sh$ screenpipe_sync.shE screennine dhsscreenpipe sync updated.sh U Xpipe.mc•.env(append-only, no deletions).*Hiso coptes tne days viueofirale dald totuet to the Nho.# Schema-drift tolerant: if Screenpipe migrations add new columns to the source DB,# che NAs archive gets ALTER VABLE'd to match. Inserts use expuicic column Lists,# suncs vesterdav (default)/screennine svnc.sh 2026-04-151# syncs a specific date• cron example (runs at sam dally):* /Users/lukas/.screenpipe/screenpipe_sync.sh > /Users/lukas/.screenpipe/sync.log 2>&1set -euo pipefailSRC="${SCREENPIPE DB:-$HOME/. screenpipe/db.sqlite}"NAS MUUNI= SINAS MOUNI:-/Vo Lumes/screenpiperNAS UB="SNAS MUUNIarchive.db"NAS DATA="SNAS MOUNT data"LOG ?ILE"SHOME.screenoipe/sync.lo0"* Tables that aet schema drift handling. Order matters for Fk-ish referencesSYNC TABLES=video chunks frames elements ocr text ui events meetinas)HEI DEpdSCRIPT START=S(date +%s)msa=" Sdate"+%Y-%m-%d %H:%M:9S") S*echo "Smsa" | tee -a "sLoG FtLE'local now=s date +%s)local elapsed=s now - SCRIPT START ))local mines elapsed / 60 ))local seceselapsed % 60))nrintf "n1+902dme02dsl | %cin" "smin" "ssec" "s*" | tee ca "SLOG FTLE"PROBLEMSOUTPUTAdm1nanypAg00pi lIC_R55g: /volume1/ccreennineescreenpipe SSH: nasl100% L2Mon 11 May 20:48:1208 000*mA .•›* Implement and run pipe I...Implement and run oipe logleAamin@DXP4800PLUS-B5F8:/volumel//screenpipe/apps sudo docker exec -it screenpipe-app python cli.py pipe day-recap -=date 2026-04-20Running pipe 'day-recap' for 2026-04-20...• The container started before you updated the.env , so it's using the old placeholder key. Restart it to pick up the new one:cd /volumel/screenpipe/appsudo docker comoose restart screenoine-aooThen try adain:sudo docker exec -it screenpipe-app python cli.py pipe day-recap --date 2026-04-20Admin@DXP4800PLUS-B5r8:/volumel/screenpipe/apps sudo docker exec -it screenpipe-app python cli.py pipe day-recap --date 2026-04-20Runnina nine 'dav-recan' for 2026-04.20..key is there now but Adm1n@DXP4800PLUS-B5F8:/volume1/screenpipe/app$ sudo docker exec -it screenpipe-app python cli.py pipe day-recap --date 2026-04-20Runnina oioe 'dav-recao' for 2026-04-20.1• The kev works — it authenticated successfullv. The error is iust that vour Anthropic account has no credits. Go to console.anthropic.com → Plans & Billina and add some credits (a few dollars is enouah fotesting).Once topped up, rerun the same command and it should work.tevoм ho asctoenpo. syлo an 1 wan to maxo sur ro aso audeM screenpipe_sync_updated.sh€Ask before edits?bash +vM @ •| xOUTIINE> TIMELINE* SSH: nas 8 master* @@0A0 (@18 Sign In...
|
NULL
|
-1603871698031012591
|
NULL
|
app_switch
|
ocr
|
NULL
|
SioCodeselectionvIewWindowy apo settinas.isonV SCR SioCodeselectionvIewWindowy apo settinas.isonV SCREENPIPE [SSH: NAS]/ #recycleconsumers> static• .env& cli.py# db.pvdocker-compose.vmli# Dockertilemain.py=requirements.txt• data>logs→oinec• aitianore* aoo settinas.ison=archive.db=archive.db-bal= db salite=dh salite.chmE dh calite-wall$ screennine svnc undated sh$ screenpipe_sync.shE screennine dhsscreenpipe sync updated.sh U Xpipe.mc•.env(append-only, no deletions).*Hiso coptes tne days viueofirale dald totuet to the Nho.# Schema-drift tolerant: if Screenpipe migrations add new columns to the source DB,# che NAs archive gets ALTER VABLE'd to match. Inserts use expuicic column Lists,# suncs vesterdav (default)/screennine svnc.sh 2026-04-151# syncs a specific date• cron example (runs at sam dally):* /Users/lukas/.screenpipe/screenpipe_sync.sh > /Users/lukas/.screenpipe/sync.log 2>&1set -euo pipefailSRC="${SCREENPIPE DB:-$HOME/. screenpipe/db.sqlite}"NAS MUUNI= SINAS MOUNI:-/Vo Lumes/screenpiperNAS UB="SNAS MUUNIarchive.db"NAS DATA="SNAS MOUNT data"LOG ?ILE"SHOME.screenoipe/sync.lo0"* Tables that aet schema drift handling. Order matters for Fk-ish referencesSYNC TABLES=video chunks frames elements ocr text ui events meetinas)HEI DEpdSCRIPT START=S(date +%s)msa=" Sdate"+%Y-%m-%d %H:%M:9S") S*echo "Smsa" | tee -a "sLoG FtLE'local now=s date +%s)local elapsed=s now - SCRIPT START ))local mines elapsed / 60 ))local seceselapsed % 60))nrintf "n1+902dme02dsl | %cin" "smin" "ssec" "s*" | tee ca "SLOG FTLE"PROBLEMSOUTPUTAdm1nanypAg00pi lIC_R55g: /volume1/ccreennineescreenpipe SSH: nasl100% L2Mon 11 May 20:48:1208 000*mA .•›* Implement and run pipe I...Implement and run oipe logleAamin@DXP4800PLUS-B5F8:/volumel//screenpipe/apps sudo docker exec -it screenpipe-app python cli.py pipe day-recap -=date 2026-04-20Running pipe 'day-recap' for 2026-04-20...• The container started before you updated the.env , so it's using the old placeholder key. Restart it to pick up the new one:cd /volumel/screenpipe/appsudo docker comoose restart screenoine-aooThen try adain:sudo docker exec -it screenpipe-app python cli.py pipe day-recap --date 2026-04-20Admin@DXP4800PLUS-B5r8:/volumel/screenpipe/apps sudo docker exec -it screenpipe-app python cli.py pipe day-recap --date 2026-04-20Runnina nine 'dav-recan' for 2026-04.20..key is there now but Adm1n@DXP4800PLUS-B5F8:/volume1/screenpipe/app$ sudo docker exec -it screenpipe-app python cli.py pipe day-recap --date 2026-04-20Runnina oioe 'dav-recao' for 2026-04-20.1• The kev works — it authenticated successfullv. The error is iust that vour Anthropic account has no credits. Go to console.anthropic.com → Plans & Billina and add some credits (a few dollars is enouah fotesting).Once topped up, rerun the same command and it should work.tevoм ho asctoenpo. syлo an 1 wan to maxo sur ro aso audeM screenpipe_sync_updated.sh€Ask before edits?bash +vM @ •| xOUTIINE> TIMELINE* SSH: nas 8 master* @@0A0 (@18 Sign In...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
21405
|
936
|
15
|
2026-05-11T17:48:18.283951+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-11/1778 /Users/lukas/.screenpipe/data/data/2026-05-11/1778521698283_m1.jpg...
|
Code
|
screenpipe_sync.sh — screenpipe [SSH: nas]
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Explorer (⇧⌘E) - 1 unsaved file
1
Search (⇧⌘F)
Explorer (⇧⌘E) - 1 unsaved file
1
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py
M
db.py
docker-compose.yml
Dockerfile
M
main.py
M
requirements.txt
M
data
logs
pipes
.gitignore
app_settings.json
archive.db
archive.db-bak
U
db.sqlite
db.sqlite-shm
db.sqlite-wal
screenpipe_sync_updated.sh
U
screenpipe_sync.sh
screenpipe.db
Outline Section
OUTLINE
OUTLINE
Timeline Section
TIMELINE
TIMELINE
app_settings.json, Editor Group 1
screenpipe_sync.sh, Editor Group 1
screenpipe_sync_updated.sh, preview, Editor Group 1
pipe.md, Editor Group 1
.env, Editor Group 1
# the source currently has; INSERT OR IGNORE handles the duplicate case.
run_sqlite_heredoc "speakers ($SRC_SPEAKERS rows, all-time)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.speakers ($SPEAKERS_COLS, install_id)
SELECT $SPEAKERS_COLS, '$INSTALL_ID' FROM main.speakers;
DETACH nas;
"
run_sqlite_heredoc "speaker_embeddings ($SRC_SEMB rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.speaker_embeddings ($SEMB_COLS, install_id)
SELECT $SEMB_COLS, '$INSTALL_ID' FROM main.speaker_embeddings;
DETACH nas;
"
run_sqlite_heredoc "audio_chunks ($SRC_ACHUNKS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.audio_chunks ($ACHUNKS_COLS, install_id)
SELECT $ACHUNKS_COLS, '$INSTALL_ID' FROM main.audio_chunks WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "audio_transcriptions ($SRC_ATRANS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.audio_transcriptions ($ATRANS_COLS, install_id)
SELECT $ATRANS_COLS_T, '$INSTALL_ID' FROM main.audio_transcriptions t
JOIN main.audio_chunks c ON t.audio_chunk_id = c.id
WHERE date(c.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "audio_tags ($SRC_ATAGS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.audio_tags ($ATAGS_COLS, install_id)
SELECT $ATAGS_COLS_AT, '$INSTALL_ID' FROM main.audio_tags at
JOIN main.audio_chunks c ON at.audio_chunk_id = c.id
WHERE date(c.timestamp) = '$TARGET_DATE';
DETACH nas;
"
# ─── FTS UPDATE ───────────────────────────────────────────────────────────
step "Updating FTS indexes"
run_sqlite_heredoc "elements_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.elements_fts(rowid, text, role)
SELECT e.id, e.text, e.role
FROM nas.elements e
JOIN nas.frames f ON e.frame_id = f.id AND e.install_id = f.install_id
WHERE date(f.timestamp) = '$TARGET_DATE'
AND e.install_id = '$INSTALL_ID'
AND e.text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "frames_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)
SELECT id, full_text, app_name, window_name, browser_url, id
FROM nas.frames
WHERE date(timestamp) = '$TARGET_DATE'
AND install_id = '$INSTALL_ID'
AND full_text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "ui_events_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)
SELECT id, text_content, app_name, window_title, element_name
FROM nas.ui_events
WHERE date(timestamp) = '$TARGET_DATE'
AND install_id = '$INSTALL_ID'
AND text_content IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "audio_transcriptions_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.audio_transcriptions_fts(rowid, transcription, device, speaker_id, id)
SELECT t.id, t.transcription, COALESCE(t.device,''), t.speaker_id, t.id
FROM nas.audio_transcriptions t
JOIN nas.audio_chunks c ON t.audio_chunk_id = c.id AND t.install_id = c.install_id
WHERE date(c.timestamp) = '$TARGET_DATE'
AND t.install_id = '$INSTALL_ID'
AND t.transcription IS NOT NULL AND t.transcription != '';
DETACH nas;
"
# ─── VERIFY ───────────────────────────────────────────────────────────────
step "Verifying DB"
V_FRAMES=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID';")
V_ELEMENTS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM elements WHERE install_id='$INSTALL_ID' AND frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID');")
V_UI=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID';")
V_OCR=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ocr_text WHERE install_id='$INSTALL_ID' AND frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID');")
V_MEETINGS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE' AND install_id='$INSTALL_ID';")
V_ACHUNKS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM audio_chunks WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID';")
V_ATRANS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM audio_transcriptions WHERE install_id='$INSTALL_ID' AND audio_chunk_id IN (SELECT id FROM audio_chunks WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID');")
V_ATAGS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM audio_tags WHERE install_id='$INSTALL_ID' AND audio_chunk_id IN (SELECT id FROM audio_chunks WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID');")
check "frames" "$V_FRAMES" "$SRC_FRAMES"
check "elements" "$V_ELEMENTS" "$SRC_ELEMENTS"
check "ui_events" "$V_UI" "$SRC_UI"
check "ocr_text" "$V_OCR" "$SRC_OCR"
check "meetings" "$V_MEETINGS" "$SRC_MEETINGS"
check "audio_chunks" "$V_ACHUNKS" "$SRC_ACHUNKS"
check "audio_transcriptions" "$V_ATRANS" "$SRC_ATRANS"
check "audio_tags" "$V_ATAGS" "$SRC_ATAGS"
fi
# ─── COPY FRAME DATA FOLDER ──────────────────────────────────────────────────
# Always runs regardless of DB sync status.
step "Copying frame data folder for $TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
mkdir -p "$NAS_DATA/$TARGET_DATE"
RSYNC_START=$(date +%s)
printf " %-36s " "rsync frames → NAS"
rsync -a --ignore-existing "$DATA_SRC/" "$NAS_DATA/$TARGET_DATE/" 2>>"$LOG_FILE"
RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))
COPIED_FILES=$(ls "$NAS_DATA/$TARGET_DATE" 2>/dev/null | grep -v '^audio$' | wc -l | tr -d ' ')
SRC_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
COPIED_SIZE=$(du -sh "$NAS_DATA/$TARGET_DATE" | cut -f1)
if [ "$COPIED_FILES" -ge "$SRC_FILES" ]; then
printf "\r %-36s ✓ %dm%02ds (%s files, %s)\n" \
"rsync frames → NAS" \
"$(( RSYNC_DUR / 60 ))" "$(( RSYNC_DUR % 60 ))" \
"$COPIED_FILES" "$COPIED_SIZE" | tee -a "$LOG_FILE"
else
printf "\r %-36s ✗ %s / %s files\n" \
"rsync frames → NAS" "$COPIED_FILES" "$SRC_FILES" | tee -a "$LOG_FILE"
fi
else
printf " %-36s %s\n" "rsync frames → NAS" "skipped (no source dir)"
fi
# ─── COPY AUDIO FILES ────────────────────────────────────────────────────────
# Audio is flat in ~/.screenpipe/data/ with the date in the filename, e.g.
# System Audio (output)_2026-05-11_13-48-12.mp4
# soundcore AeroClip (input)_2026-05-10_11-10-32.mp4
# Mirrored to $NAS_DATA/<date>/audio/ so each day's archive is self-contained.
step "Copying audio files for $TARGET_DATE"
shopt -s nullglob
AUDIO_FILES=( "$HOME/.screenpipe/data/"*_"${TARGET_DATE}"_*.mp4 )
shopt -u nullglob
if [ ${#AUDIO_FILES[@]} -gt 0 ]; then
mkdir -p "$NAS_DATA/$TARGET_DATE/audio"
RSYNC_START=$(date +%s)
printf " %-36s " "rsync audio → NAS"
rsync -a --ignore-existing "${AUDIO_FILES[@]}" "$NAS_DATA/$TARGET_DATE/audio/" 2>>"$LOG_FILE"
RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))
COPIED_AUDIO=$(ls "$NAS_DATA/$TARGET_DATE/audio" | wc -l | tr -d ' ')
AUDIO_SIZE=$(du -sh "$NAS_DATA/$TARGET_DATE/audio" | cut -f1)
printf "\r %-36s ✓ %dm%02ds (%s files, %s)\n" \
"rsync audio → NAS" \
"$(( RSYNC_DUR / 60 ))" "$(( RSYNC_DUR % 60 ))" \
"$COPIED_AUDIO" "$AUDIO_SIZE" | tee -a "$LOG_FILE"
else
printf " %-36s %s\n" "rsync audio → NAS" "skipped (no audio for date)"
fi
# ─── COPY LOGS ────────────────────────────────────────────────────────────────
step "Copying screenpipe logs for $TARGET_DATE"
NAS_LOGS="$NAS_MOUNT/logs"
mkdir -p "$NAS_LOGS"
shopt -s nullglob
LOG_FILES=( "$HOME/.screenpipe/screenpipe.$TARGET_DATE."*.log )
shopt -u nullglob
if [ ${#LOG_FILES[@]} -gt 0 ]; then
printf " %-36s " "rsync logs → NAS"
rsync -a "${LOG_FILES[@]}" "$NAS_LOGS/" 2>>"$LOG_FILE"
TOTAL_SIZE=$(du -ch "${LOG_FILES[@]}" | tail -1 | cut -f1)
printf "✓ %d file(s), %s\n" "${#LOG_FILES[@]}" "$TOTAL_SIZE" | tee -a "$LOG_FILE"
else
printf " %-36s %s\n" "rsync logs → NAS" "skipped (no matching logs)"
fi
# ─── SUMMARY ──────────────────────────────────────────────────────────────────
TOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))
DB_SIZE=$(du -sh "$NAS_DB" | cut -f1)
echo ""
log "Archive DB size: $DB_SIZE"
log "Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s"
log "Sync complete for $TARGET_DATE (install $INSTALL_ID)"
log "========================================"
rsync -a "$HOME/.screenpipe/sync.log" "$NAS_LOGS/sync.log" 2>/dev/null || true
# the source currently has; INSERT OR IGNORE handles the duplicate case.
run_sqlite_heredoc "speakers ($SRC_SPEAKERS rows, all-time)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.speakers ($SPEAKERS_COLS, install_id)
SELECT $SPEAKERS_COLS, '$INSTALL_ID' FROM main.speakers;
DETACH nas;
"
run_sqlite_heredoc "speaker_embeddings ($SRC_SEMB rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.speaker_embeddings ($SEMB_COLS, install_id)
SELECT $SEMB_COLS, '$INSTALL_ID' FROM main.speaker_embeddings;
DETACH nas;
"
run_sqlite_heredoc "audio_chunks ($SRC_ACHUNKS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.audio_chunks ($ACHUNKS_COLS, install_id)
SELECT $ACHUNKS_COLS, '$INSTALL_ID' FROM main.audio_chunks WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "audio_transcriptions ($SRC_ATRANS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.audio_transcriptions ($ATRANS_COLS, install_id)
SELECT $ATRANS_COLS_T, '$INSTALL_ID' FROM main.audio_transcriptions t
JOIN main.audio_chunks c ON t.audio_chunk_id = c.id
WHERE date(c.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "audio_tags ($SRC_ATAGS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.audio_tags ($ATAGS_COLS, install_id)
SELECT $ATAGS_COLS_AT, '$INSTALL_ID' FROM main.audio_tags at
JOIN main.audio_chunks c ON at.audio_chunk_id = c.id
WHERE date(c.timestamp) = '$TARGET_DATE';
DETACH nas;
"
# ─── FTS UPDATE ───────────────────────────────────────────────────────────
step "Updating FTS indexes"
run_sqlite_heredoc "elements_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.elements_fts(rowid, text, role)
SELECT e.id, e.text, e.role
FROM nas.elements e
JOIN nas.frames f ON e.frame_id = f.id AND e.install_id = f.install_id
WHERE date(f.timestamp) = '$TARGET_DATE'
AND e.install_id = '$INSTALL_ID'
AND e.text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "frames_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)
SELECT id, full_text, app_name, window_name, browser_url, id
FROM nas.frames
WHERE date(timestamp) = '$TARGET_DATE'
AND install_id = '$INSTALL_ID'
AND full_text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "ui_events_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)
SELECT id, text_content, app_name, window_title, element_name
FROM nas.ui_events
WHERE date(timestamp) = '$TARGET_DATE'
AND install_id = '$INSTALL_ID'
AND text_content IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "audio_transcriptions_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.audio_transcriptions_fts(rowid, transcription, device, speaker_id, id)
SELECT t.id, t.transcription, COALESCE(t.device,''), t.speaker_id, t.id
FROM nas.audio_transcriptions t
JOIN nas.audio_chunks c ON t.audio_chunk_id = c.id AND t.install_id = c.install_id
WHERE date(c.timestamp) = '$TARGET_DATE'
AND t.install_id = '$INSTALL_ID'
AND t.transcription IS NOT NULL AND t.transcription != '';
DETACH nas;
"
# ─── VERIFY ───────────────────────────────────────────────────────────────
step "Verifying DB"
V_FRAMES=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID';")
V_ELEMENTS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM elements WHERE install_id='$INSTALL_ID' AND frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID');")
V_UI=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID';")
V_OCR=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ocr_text WHERE install_id='$INSTALL_ID' AND frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID');")
V_MEETINGS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE' AND install_id='$INSTALL_ID';")
V_ACHUNKS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM audio_chunks WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID';")
V_ATRANS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM audio_transcriptions WHERE install_id='$INSTALL_ID' AND audio_chunk_id IN (SELECT id FROM audio_chunks WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID');")
V_ATAGS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM audio_tags WHERE install_id='$INSTALL_ID' AND audio_chunk_id IN (SELECT id FROM audio_chunks WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID');")
check "frames" "$V_FRAMES" "$SRC_FRAMES"
check "elements" "$V_ELEMENTS" "$SRC_ELEMENTS"
check "ui_events" "$V_UI" "$SRC_UI"
check "ocr_text" "$V_OCR" "$SRC_OCR"
check "meetings" "$V_MEETINGS" "$SRC_MEETINGS"
check "audio_chunks" "$V_ACHUNKS" "$SRC_ACHUNKS"
check "audio_transcriptions" "$V_ATRANS" "$SRC_ATRANS"
check "audio_tags" "$V_ATAGS" "$SRC_ATAGS"
fi
# ─── COPY FRAME DATA FOLDER ──────────────────────────────────────────────────
# Always runs regardless of DB sync status.
step "Copying frame data folder for $TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
mkdir -p "$NAS_DATA/$TARGET_DATE"
RSYNC_START=$(date +%s)
printf " %-36s " "rsync frames → NAS"
rsync -a --ignore-existing "$DATA_SRC/" "$NAS_DATA/$TARGET_DATE/" 2>>"$LOG_FILE"
RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))
COPIED_FILES=$(ls "$NAS_DATA/$TARGET_DATE" 2>/dev/null | grep -v '^audio$' | wc -l | tr -d ' ')
SRC_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
COPIED_SIZE=$(du -sh "$NAS_DATA/$TARGET_DATE" | cut -f1)
if [ "$COPIED_FILES" -ge "$SRC_FILES" ]; then
printf "\r %-36s ✓ %dm%02ds (%s files, %s)\n" \
"rsync frames → NAS" \
"$(( RSYNC_DUR / 60 ))" "$(( RSYNC_DUR % 60 ))" \
"$COPIED_FILES" "$COPIED_SIZE" | tee -a "$LOG_FILE"
else
printf "\r %-36s ✗ %s / %s files\n" \
"rsync frames → NAS" "$COPIED_FILES" "$SRC_FILES" | tee -a "$LOG_FILE"
fi
else
printf " %-36s %s\n" "rsync frames → NAS" "skipped (no source dir)"
fi
# ─── COPY AUDIO FILES ────────────────────────────────────────────────────────
# Audio is flat in ~/.screenpipe/data/ with the date in the filename, e.g.
# System Audio (output)_2026-05-11_13-48-12.mp4
# soundcore AeroClip (input)_2026-05-10_11-10-32.mp4
# Mirrored to $NAS_DATA/<date>/audio/ so each day's archive is self-contained.
step "Copying audio files for $TARGET_DATE"
shopt -s nullglob
AUDIO_FILES=( "$HOME/.screenpipe/data/"*_"${TARGET_DATE}"_*.mp4 )
shopt -u nullglob
if [ ${#AUDIO_FILES[@]} -gt 0 ]; then
mkdir -p "$NAS_DATA/$TARGET_DATE/audio"
RSYNC_START=$(date +%s)
printf " %-36s " "rsync audio → NAS"
rsync -a --ignore-existing "${AUDIO_FILES[@]}" "$NAS_DATA/$TARGET_DATE/audio/" 2>>"$LOG_FILE"
RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))
COPIED_AUDIO=$(ls "$NAS_DATA/$TARGET_DATE/audio" | wc -l | tr -d ' ')
AUDIO_SIZE=$(du -sh "$NAS_DATA/$TARGET_DATE/audio" | cut -f1)
printf "\r %-36s ✓ %dm%02ds (%s files, %s)\n" \
"rsync audio → NAS" \
"$(( RSYNC_DUR / 60 ))" "$(( RSYNC_DUR % 60 ))" \
"$COPIED_AUDIO" "$AUDIO_SIZE" | tee -a "$LOG_FILE"
else
printf " %-36s %s\n" "rsync audio → NAS" "skipped (no audio for date)"
fi
# ─── COPY LOGS ────────────────────────────────────────────────────────────────
step "Copying screenpipe logs for $TARGET_DATE"
NAS_LOGS="$NAS_MOUNT/logs"
mkdir -p "$NAS_LOGS"
shopt -s nullglob
LOG_FILES=( "$HOME/.screenpipe/screenpipe.$TARGET_DATE."*.log )
shopt -u nullglob
if [ ${#LOG_FILES[@]} -gt 0 ]; then
printf " %-36s " "rsync logs → NAS"
rsync -a "${LOG_FILES[@]}" "$NAS_LOGS/" 2>>"$LOG_FILE"
TOTAL_SIZE=$(du -ch "${LOG_FILES[@]}" | tail -1 | cut -f1)
printf "✓ %d file(s), %s\n" "${#LOG_FILES[@]}" "$TOTAL_SIZE" | tee -a "$LOG_FILE"
else
printf " %-36s %s\n" "rsync logs → NAS" "skipped (no matching logs)"
fi
# ─── SUMMARY ──────────────────────────────────────────────────────────────────
TOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))
DB_SIZE=$(du -sh "$NAS_DB" | cut -f1)
echo ""
log "Archive DB size: $DB_SIZE"
log "Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s"
log "Sync complete for $TARGET_DATE (install $INSTALL_ID)"
log "========================================"
rsync -a "$HOME/.screenpipe/sync.log" "$NAS_LOGS/sync.log" 2>/dev/null || true
Implement and run pipe l…, Editor Group 2
Problems (⇧⌘M)
PROBLEMS
Output (⇧⌘U)
OUTPUT
Debug Console (⇧⌘Y)
DEBUG CONSOLE
Terminal (⌃`)
TERMINAL
Ports - 1 forwarded port
PORTS
1
remote SSH: nas
SSH: nas
screenpipe (Git) - master*, Checkout Branch/Tag...
master*
screenpipe (Git) - Synchronize Changes
No Problems
0
0
Forwarded Ports: 8766
1
Notifications
Sign In
Sign In
Shell Script
Editor Language Status: Inline Suggestions, next: $(copilot) No inline suggestion available, Inline suggestions
LF
UTF-8
Spaces: 2
Ln 675, Col 1
git-commit Not Committed Yet
Not Committed Yet
No results found
Implement and run pipe logic
Session history
New session
Message actions
main.py
main.py
lets implement logic with pipes. how can I run it?
Thinking
Thinking
Let me look at the current project structure to understand what's already in place.
Bash
List project files
IN
find /volume1/screenpipe -type f | head -50 && echo "---" && ls /volume1/screenpipe
Copy code to clipboard
OUT
/volume1/screenpipe/.DS_Store
/volume1/screenpipe/screenpipe.db
/volume1/screenpipe/screenpipe_sync.sh
/volume1/screenpipe/app_settings.json
/volume1/screenpipe/.gitignore
/volume1/screenpipe/archive.db
/volume1/screenpipe/db.sqlite
/volume1/screenpipe/db.sqlite-wal
/volume1/screenpipe/db.sqlite-shm
/volume1/screenpipe/#recycle/desktop.ini
/volume1/screenpipe/#recycle/db.sqlite
/volume1/screenpipe/#recycle/Copy #1 of db.sqlite
/volume1/screenpipe/#recycle/.DS_Store
/volume1/screenpipe/#recycle/Copy #2 of db.sqlite
/volume1/screenpipe/#recycle/archive.db
/volume1/screenpipe/#recycle/Copy #1 of archive.db
/volume1/screenpipe/#recycle/Copy #2 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of archive.db
/volume1/screenpipe/#recycle/Copy #4 of archive.db
/volume1/screenpipe/#recycle/Copy #5 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of db.sqlite
/volume1/screenpipe/#recycle/Copy #4 of db.sqlite
/volume1/screenpipe/#recycle/Copy #6 of archive.db
/volume1/screenpipe/#recycle/test.txt
/volume1/screenpipe/#recycle/Copy #7 of archive.db
/volume1/screenpipe/#recycle/Copy #8 of archive.db
/volume1/screenpipe/#recycle/archive.db-journal
/volume1/screenpipe/#recycle/Copy #1 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #2 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #3 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #4 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #6 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #7 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of db.sqlite
/volume1/screenpipe/pipes/.DS_Store
/volume1/screenpipe/app/.env
/volume1/screenpipe/app/cli.py
/volume1/screenpipe/app/.DS_Store
/volume1/screenpipe/app/db.py
/volume1/screenpipe/app/docker-compose.yml
/volume1/screenpipe/app/main.py
/volume1/screenpipe/app/requirements.txt
/volume1/screenpipe/app/Dockerfile
/volume1/screenpipe/data/.DS_Store
/volume1/screenpipe/.git/description
/volume1/screenpipe/.git/HEAD
/volume1/screenpipe/.git/index
/volume1/screenpipe/.git/COMMIT_EDITMSG
/volume1/screenpipe/#recycle/data/.DS_Store
---
app
app_settings.json
archive.db
data
db.sqlite
db.sqlite-shm
db.sqlite-wal
pipes
#recycle
screenpipe.db
screenpipe_sync.sh
Read
main.py
main.py
Bash
Check pipes directory and docker-compose
IN
ls /volume1/screenpipe/pipes/ && ls /volume1/screenpipe/app/ && cat /volume1/screenpipe/app/docker-compose.yml
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
cli.py
consumers
db.py
docker-compose.yml
Dockerfile
main.py
__pycache__
requirements.txt
static
services:
screenpipe-app:
build: .
container_name: screenpipe-app
restart: unless-stopped
ports:
- "8766:8000"
volumes:
- /volume1/screenpipe:/data
env_file:
- .env
environment:
TZ: Europe/Sofia
DB_PATH: /data/db.sqlite
sqlite-web-archive:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-archive
restart: unless-stopped
ports:
- "8767:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/archive.db"]
sqlite-web-live:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-live
restart: unless-stopped
ports:
- "8768:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/db.sqlite"]
Read
requirements.txt
requirements.txt
Bash
Inspect a pipe directory
IN
ls /volume1/screenpipe/pipes/day-recap/ && cat /volume1/screenpipe/pipes/day-recap/pipe.json 2>/dev/null || ls /volume1/screenpipe/pipes/day-recap/
Copy code to clipboard
OUT
pipe.md
pipe.md
Read
cli.py
cli.py
Bash
List all pipes and their contents
IN
ls /volume1/screenpipe/pipes/ && for d in /volume1/screenpipe/pipes/*/; do echo "=== $d ==="; ls "$d"; done
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
=== /volume1/screenpipe/pipes/ai-habits/ ===
pipe.md
=== /volume1/screenpipe/pipes/day-recap/ ===
pipe.md
=== /volume1/screenpipe/pipes/meeting-summary/ ===
pipe.md
=== /volume1/screenpipe/pipes/standup-update/ ===
pipe.md
=== /volume1/screenpipe/pipes/time-breakdown/ ===
pipe.md
=== /volume1/screenpipe/pipes/video-export/ ===
pipe.md
Bash
Read pipe markdown files
IN
cat /volume1/screenpipe/pipes/day-recap/pipe.md && echo "===" && cat /volume1/screenpipe/pipes/meeting-summary/pipe.md 2>/dev/null | head -50
Copy code to clipboard
OUT
---
schedule: manual
enabled: true
template: true
title: Day Recap
description: "Today's accomplishments, key moments, and unfinished work"
icon: "📋"
featured: true
---
Analyze my screen and audio recordings from today (last 16 hours only).
Read screenpipe skill first.
Use this exact format:
## Summary
One sentence: what I mainly did today.
## Accomplishments
- Top 3 things I finished, with timestamps (e.g. "2:30 PM")
- Name specific apps, files, or projects
## Key Moments
- Important things I saw, said, or heard — with timestamps
## Unfinished Work
- What I should continue tomorrow — name the app/file/task
## Patterns
- Apps I used most, topics that came up repeatedly
Only report what you can verify from the data. End with: "**Next step:** [most important thing to continue]"
===
---
schedule: manual
enabled: true
template: true
title: Meeting Summary
description: "Summarize meeting transcript with key takeaways and action items"
icon: "🤝"
featured: false
---
Summarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.
Read screenpipe skill first.
Use this exact format:
## Meeting Summary
One sentence: what this meeting was about.
## Key Takeaways
- Top 3-5 important points discussed
- Include who said what when relevant
## Action Items
- [ ] Task — assigned to whom, deadline if mentioned
- [ ] Task — assigned to whom
## Decisions Made
- List any decisions or agreements reached
## Open Questions
- Anything unresolved or needing follow-up
Keep it concise and actionable.
Thinking
Thinking
Bash
Read summary consumer
IN
ls /volume1/screenpipe/app/consumers/ && cat /volume1/screenpipe/app/consumers/summary.py
Copy code to clipboard
OUT
activity.py
audio.py
elements.py
__init__.py
interactions.py
ocr.py
__pycache__
report.py
summary.py
"""AI summary generator using Claude."""
import os
from datetime import date
from typing import Any
from consumers.activity import app_time, summary_stats, browser_urls, ui_event_summary
from consumers.ocr import deduplicated_text
from consumers.audio import formatted_transcript
SUMMARY_TYPES = {
"day_recap": {
"title": "Day Recap",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
## Audio/speech:
{audio}
Write a concise day recap using EXACTLY this format:
## Summary
One sentence: what I mainly worked on today.
## Accomplishments
- Top 3 things I finished, with approximate times
- Name specific apps, files, or projects
## Key Moments
- Important things seen or heard, with timestamps
## Unfinished Work
- What to continue tomorrow
## Patterns
- Apps used most, topics that came up repeatedly
Only report what you can verify from the data. End with:
**Next step:** [most important thing to continue]""",
},
"standup": {
"title": "Standup Update",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
## Audio/speech:
{audio}
Write a brief standup update:
**Yesterday:** What I worked on (2-3 bullets)
**Today:** What I plan to continue (1-2 bullets)
**Blockers:** Any issues observed (or "None")
Keep it under 150 words. Only report what's verifiable from the data.""",
},
"focus_time": {
"title": "Focus & Distraction Analysis",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
Analyze focus vs distraction patterns:
## Deep Work Periods
- When and how long were sustained focus sessions?
- What was being worked on?
## Distractions
- Which apps/sites were used recreationally?
- How much time was lost to context switching?
## Recommendations
- 2-3 concrete suggestions to improve focus tomorrow
Be specific with times and app names.""",
},
}
def _build_context(for_date: date) -> dict[str, str]:
apps = app_time(for_date)
app_lines = "\n".join(f"- {a['app_name']}: {a['minutes']} min" for a in apps[:20])
urls = browser_urls(for_date, limit=20)
url_lines = "\n".join(
f"- {u['browser_url'][:100]} ({u['minutes']} min)" for u in urls
)
ui_rows = ui_event_summary(for_date)
ui_lines = "\n".join(
f"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches"
for r in ui_rows[:15]
)
ocr_rows = deduplicated_text(for_date, chunk_minutes=5)
ocr_lines = "\n".join(
f"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}"
for r in ocr_rows[:100]
)
audio = formatted_transcript(for_date)
return {
"app_time": app_lines or "(no app data)",
"browser_urls": url_lines or "(no browser data)",
"ui_events": ui_lines or "(no UI event data)",
"ocr_text": ocr_lines or "(no screen data)",
"audio": audio[:3000] if len(audio) > 3000 else audio,
}
def generate(
summary_type: str = "day_recap",
for_date: date | None = None,
api_key: str | None = None,
) -> dict[str, Any]:
"""Generate an AI summary. Returns dict with 'title', 'content', 'date'."""
import anthropic
d = for_date or date.today()
key = api_key or os.environ.get("ANTHROPIC_API_KEY", "")
if not key:
return {
"title": "Error",
"content": "ANTHROPIC_API_KEY not set. Add it to your .env file.",
"date": str(d),
}
spec = SUMMARY_TYPES.get(summary_type)
if not spec:
return {"title": "Error", "content": f"Unknown summary type: {summary_type}", "date": str(d)}
stats = summary_stats(d)
if stats["total_frames"] == 0:
return {
"title": spec["title"],
"content": f"No screen data found for {d}.",
"date": str(d),
}
ctx = _build_context(d)
prompt = spec["prompt"].format(**ctx)
client = anthropic.Anthropic(api_key=key)
message = client.messages.create(
model="claude-haiku-4-5-20251001",
max_tokens=1024,
messages=[{"role": "user", "content": prompt}],
)
return {
"title": spec["title"],
"content": message.content[0].text,
"date": str(d),
"stats": stats,
}
Thinking
Thinking
Bash
Read all pipe.md files
IN
for f in /volume1/screenpipe/pipes/*/pipe.md; do echo "=== $f ==="; cat "$f"; echo; done
Copy code to clipboard
OUT
=== /volume1/screenpipe/pipes/ai-habits/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: AI Habits
description: "How you use AI tools — patterns and insights"
icon: "🤖"
featured: true
---
Search my recordings from the last 24 hours for AI tool usage. Use app_name filter for each tool separately: ChatGPT, Claude, Copilot, Cursor, Gemini, Perplexity. Use limit=5 per search, max 6 searches total.
Read screenpipe skill first.
Use this exact format:
## AI Tools Used
- List each tool with approximate time spent (e.g. "Claude: ~45min")
## What I Used Them For
- For each tool: coding, writing, research, or brainstorming
## Usage Patterns
- Do I switch between tools? Use them in bursts or steadily?
## Effectiveness
- Which tool appeared alongside completed work vs. abandoned attempts
If no AI usage is found, say so clearly. End with: "**Tip:** [one suggestion to use AI tools more effectively]"
=== /volume1/screenpipe/pipes/day-recap/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Day Recap
description: "Today's accomplishments, key moments, and unfinished work"
icon: "📋"
featured: true
---
Analyze my screen and audio recordings from today (last 16 hours only).
Read screenpipe skill first.
Use this exact format:
## Summary
One sentence: what I mainly did today.
## Accomplishments
- Top 3 things I finished, with timestamps (e.g. "2:30 PM")
- Name specific apps, files, or projects
## Key Moments
- Important things I saw, said, or heard — with timestamps
## Unfinished Work
- What I should continue tomorrow — name the app/file/task
## Patterns
- Apps I used most, topics that came up repeatedly
Only report what you can verify from the data. End with: "**Next step:** [most important thing to continue]"
=== /volume1/screenpipe/pipes/meeting-summary/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Meeting Summary
description: "Summarize meeting transcript with key takeaways and action items"
icon: "🤝"
featured: false
---
Summarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.
Read screenpipe skill first.
Use this exact format:
## Meeting Summary
One sentence: what this meeting was about.
## Key Takeaways
- Top 3-5 important points discussed
- Include who said what when relevant
## Action Items
- [ ] Task — assigned to whom, deadline if mentioned
- [ ] Task — assigned to whom
## Decisions Made
- List any decisions or agreements reached
## Open Questions
- Anything unresolved or needing follow-up
Keep it concise and actionable.
=== /volume1/screenpipe/pipes/standup-update/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Standup Update
description: "What you did, what's next, and any blockers"
icon: "🏢"
featured: true
---
Based on my recordings from the last 24 hours, generate a standup update. Use limit=10 per search, max 3 searches total.
Read screenpipe skill first.
Use this exact format:
## Yesterday
- What I worked on (name specific projects, files, tools, PRs)
## Today
- What I will work on next (based on unfinished tasks and recent activity)
## Blockers
- Issues I hit — errors, slow builds, waiting on someone
- If no blockers, write "None"
Keep it under 150 words. Copy-paste ready for a team standup.
=== /volume1/screenpipe/pipes/time-breakdown/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Time Breakdown
description: "Where your time went — by app, project, and category"
icon: "⏱"
featured: false
---
Analyze my app usage from today (last 12 hours). Use limit=10 per search, max 4 searches. Prefer /raw_sql with COUNT/GROUP BY queries.
Read screenpipe skill first.
Use this exact format with durations and percentages:
## By Application
- List each app with duration and percentage, sorted by time (e.g. "VS Code: 2h 15min (28%)")
## By Category
- Group into: coding, meetings, browsing, writing, communication, other
- Show hours and percentage per category
## By Project
- Group related activities by project/topic. Name specific repos or tasks.
## Productivity Score
- Calculate: focused_work_hours / total_hours as a percentage
- Focused = coding + writing. Unfocused = browsing + switching.
End with: "**Suggestion:** [one specific change to improve tomorrow's productivity]"
=== /volume1/screenpipe/pipes/video-export/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Export Video Clip
description: "Create a video of your recent screen activity"
icon: "🎬"
featured: false
---
Export a video of my screen activity from the last 5 minutes.
Read screenpipe skill first.
Use the POST /frames/export endpoint with the time range and fps=1.0. Then show me the exported video file path as an inline code block so I can watch it.
If the export is large, suggest a lower fps or shorter time range.
Thinking
Thinking
Now I have a clear picture. The pipes are markdown prompt templates in
/volume1/screenpipe/pipes/
, but there's no code to actually load and run them —
consumers/summary.py
has its own hardcoded prompts instead.
Here's what I'll implement:
consumers/pipes.py
— dynamically loads pipe.md files and runs them via Claude (data injected as system message, pipe body as user prompt)
main.py
— two new endpoints:
GET /api/pipes
and
POST /api/pipes/{pipe_id}/run
cli.py
— a
pipe
command to run pipes from the terminal
Let me build it:
Bash
Check browser_urls signature
IN
cat /volume1/screenpipe/app/consumers/activity.py | grep "def browser_urls" -A 5
Copy code to clipboard
OUT
def browser_urls(
for_date: date | None = None,
app_name: str | None = None,
ts_from: str | None = None,
ts_to: str | None = None,
limit: int = 30,
Write
pipes.py
pipes.py
143 lines
"""Dynamic pipe loader and runner."""
import os
import re
from datetime import date
from pathlib import Path
from typing import Any
def _parse_frontmatter(text: str) -> tuple[dict, str]:
if not text.startswith("---"):
return {}, text
try:
end = text.index("---", 3)
except ValueError:
return {}, text
fm_text = text[3:end].strip()
body = text[end + 3:].strip()
meta: dict = {}
for line in fm_text.splitlines():
if ":" in line:
k, _, v = line.partition(":")
meta[k.strip()] = v.strip().strip('"')
return meta, body
def load_pipes(pipes_dir: Path) -> list[dict]:
if not pipes_dir.exists():
return []
pipes = []
for pipe_dir in sorted(pipes_dir.iterdir()):
if not pipe_dir.is_dir() or pipe_dir.name.startswith("."):
continue
pipe_md = pipe_dir / "pipe.md"
if not pipe_md.exists():
continue
text = pipe_md.read_text(encoding="utf-8")
meta, body = _parse_frontmatter(text)
if meta.get("enabled", "true").lower() == "false":
continue
body = re.sub(r"Read screenpipe skill first\.?\n?", "", body).strip()
pipes.append({
"id": pipe_dir.name,
"title": meta.get("title", pipe_dir.name),
"description": meta.get("description", ""),
"icon": meta.get("icon", ""),
"schedule": meta.get("schedule", "manual"),
"featured": meta.get("featured", "false").lower() == "true",
"prompt": body,
})
return pipes
def _build_system(d: date, stats: dict) -> str:
from consumers.activity import app_time, browser_urls, ui_event_summary
from consumers.ocr import deduplicated_text
from consumers.audio import formatted_transcript
apps = app_time(d)
app_lines = "\n".join(f"- {a['app_name']}: {a['minutes']} min" for a in apps[:20])
urls = browser_urls(d, limit=20)
url_lines = "\n".join(f"- {u['browser_url'][:100]} ({u['minutes']} min)" for u in urls)
ui_rows = ui_event_summary(d)
ui_lines = "\n".join(
f"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches"
for r in ui_rows[:15]
)
ocr_rows = deduplicated_text(d, chunk_minutes=5)
ocr_lines = "\n".join(
f"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}"
for r in ocr_rows[:100]
)
audio = formatted_transcript(d)
if len(audio) > 3000:
audio = audio[:3000]
return f"""You are analyzing screenpipe data — recordings of a person's computer activity.
## App usage (minutes per app):
{app_lines or '(no app data)'}
## Browser URLs visited:
{url_lines or '(no browser data)'}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_lines or '(no UI event data)'}
## Screen content (sampled every 5 minutes):
{ocr_lines or '(no screen data)'}
## Audio / speech:
{audio or '(no audio data)'}
Date: {d}
Total frames recorded: {stats['total_frames']}"""
def run_pipe(
pipe_id: str,
for_date: date | None = None,
api_key: str | None = None,
pipes_dir: Path | None = None,
) -> dict[str, Any]:
import anthropic
from consumers.activity import summary_stats
d = for_date or date.today()
key = api_key or os.environ.get("ANTHROPIC_API_KEY", "")
if not key:
return {"title": "Error", "content": "ANTHROPIC_API_KEY not set.", "date": str(d)}
_pipes_dir = pipes_dir or Path(os.environ.get("PIPES_DIR", "/data/pipes"))
all_pipes = {p["id"]: p for p in load_pipes(_pipes_dir)}
if pipe_id not in all_pipes:
return {"title": "Error", "content": f"Pipe not found: {pipe_id}", "date": str(d)}
pipe = all_pipes[pipe_id]
stats = summary_stats(d)
if stats["total_frames"] == 0:
return {"title": pipe["title"], "content": f"No screen data found for {d}.", "date": str(d)}
system = _build_system(d, stats)
client = anthropic.Anthropic(api_key=key)
message = client.messages.create(
model="claude-haiku-4-5-20251001",
max_tokens=1024,
system=system,
messages=[{"role": "user", "content": pipe["prompt"]}],
)
return {
"title": pipe["title"],
"content": message.content[0].text,
"date": str(d),
"stats": stats,
}
Now add the API endpoints to
main.py
:
Edit
main.py
main.py
Added 1 line
Edit
main.py
main.py
Added 1 line...
|
[{"role":"AXRadioButton","text [{"role":"AXRadioButton","text":"Explorer (⇧⌘E) - 1 unsaved file","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":true},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Search (⇧⌘F)","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Source Control (⌃⇧G) - 10 pending changes","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"10","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Run and Debug (⇧⌘D)","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Remote Explorer","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Extensions (⇧⌘X) - 2 require update","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"2","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Claude Code","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"Containers","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXHeading","text":"EXPLORER","depth":17,"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"EXPLORER","depth":18,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Explorer Section: screenpipe [SSH: nas]","depth":21,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":true},{"role":"AXStaticText","text":"","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"Explorer Section: screenpipe [SSH: nas]","depth":22,"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"SCREENPIPE [SSH: NAS]","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"#recycle","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"app","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"__pycache__","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"consumers","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"static","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":".env","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"cli.py","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.py","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"docker-compose.yml","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Dockerfile","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"main.py","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"requirements.txt","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"data","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"logs","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"pipes","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":".gitignore","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"app_settings.json","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"archive.db","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"archive.db-bak","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"U","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite-shm","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite-wal","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe_sync_updated.sh","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"U","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe_sync.sh","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe.db","depth":27,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Outline Section","depth":21,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"OUTLINE","depth":22,"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"OUTLINE","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Timeline Section","depth":21,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"TIMELINE","depth":22,"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"TIMELINE","depth":23,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"app_settings.json, Editor Group 1","depth":28,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"screenpipe_sync.sh, Editor Group 1","depth":28,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":false},{"role":"AXRadioButton","text":"screenpipe_sync_updated.sh, preview, Editor Group 1","depth":28,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"pipe.md, Editor Group 1","depth":28,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":".env, Editor Group 1","depth":28,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"# the source currently has; INSERT OR IGNORE handles the duplicate case.\n run_sqlite_heredoc \"speakers ($SRC_SPEAKERS rows, all-time)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.speakers ($SPEAKERS_COLS, install_id)\n SELECT $SPEAKERS_COLS, '$INSTALL_ID' FROM main.speakers;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"speaker_embeddings ($SRC_SEMB rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.speaker_embeddings ($SEMB_COLS, install_id)\n SELECT $SEMB_COLS, '$INSTALL_ID' FROM main.speaker_embeddings;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"audio_chunks ($SRC_ACHUNKS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.audio_chunks ($ACHUNKS_COLS, install_id)\n SELECT $ACHUNKS_COLS, '$INSTALL_ID' FROM main.audio_chunks WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"audio_transcriptions ($SRC_ATRANS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.audio_transcriptions ($ATRANS_COLS, install_id)\n SELECT $ATRANS_COLS_T, '$INSTALL_ID' FROM main.audio_transcriptions t\n JOIN main.audio_chunks c ON t.audio_chunk_id = c.id\n WHERE date(c.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"audio_tags ($SRC_ATAGS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.audio_tags ($ATAGS_COLS, install_id)\n SELECT $ATAGS_COLS_AT, '$INSTALL_ID' FROM main.audio_tags at\n JOIN main.audio_chunks c ON at.audio_chunk_id = c.id\n WHERE date(c.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n # ─── FTS UPDATE ───────────────────────────────────────────────────────────\n step \"Updating FTS indexes\"\n\n run_sqlite_heredoc \"elements_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.elements_fts(rowid, text, role)\n SELECT e.id, e.text, e.role\n FROM nas.elements e\n JOIN nas.frames f ON e.frame_id = f.id AND e.install_id = f.install_id\n WHERE date(f.timestamp) = '$TARGET_DATE'\n AND e.install_id = '$INSTALL_ID'\n AND e.text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)\n SELECT id, full_text, app_name, window_name, browser_url, id\n FROM nas.frames\n WHERE date(timestamp) = '$TARGET_DATE'\n AND install_id = '$INSTALL_ID'\n AND full_text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)\n SELECT id, text_content, app_name, window_title, element_name\n FROM nas.ui_events\n WHERE date(timestamp) = '$TARGET_DATE'\n AND install_id = '$INSTALL_ID'\n AND text_content IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"audio_transcriptions_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.audio_transcriptions_fts(rowid, transcription, device, speaker_id, id)\n SELECT t.id, t.transcription, COALESCE(t.device,''), t.speaker_id, t.id\n FROM nas.audio_transcriptions t\n JOIN nas.audio_chunks c ON t.audio_chunk_id = c.id AND t.install_id = c.install_id\n WHERE date(c.timestamp) = '$TARGET_DATE'\n AND t.install_id = '$INSTALL_ID'\n AND t.transcription IS NOT NULL AND t.transcription != '';\nDETACH nas;\n\"\n\n # ─── VERIFY ───────────────────────────────────────────────────────────────\n step \"Verifying DB\"\n\n V_FRAMES=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID';\")\n V_ELEMENTS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM elements WHERE install_id='$INSTALL_ID' AND frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID');\")\n V_UI=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID';\")\n V_OCR=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ocr_text WHERE install_id='$INSTALL_ID' AND frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID');\")\n V_MEETINGS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE' AND install_id='$INSTALL_ID';\")\n V_ACHUNKS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM audio_chunks WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID';\")\n V_ATRANS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM audio_transcriptions WHERE install_id='$INSTALL_ID' AND audio_chunk_id IN (SELECT id FROM audio_chunks WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID');\")\n V_ATAGS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM audio_tags WHERE install_id='$INSTALL_ID' AND audio_chunk_id IN (SELECT id FROM audio_chunks WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID');\")\n\n check \"frames\" \"$V_FRAMES\" \"$SRC_FRAMES\"\n check \"elements\" \"$V_ELEMENTS\" \"$SRC_ELEMENTS\"\n check \"ui_events\" \"$V_UI\" \"$SRC_UI\"\n check \"ocr_text\" \"$V_OCR\" \"$SRC_OCR\"\n check \"meetings\" \"$V_MEETINGS\" \"$SRC_MEETINGS\"\n check \"audio_chunks\" \"$V_ACHUNKS\" \"$SRC_ACHUNKS\"\n check \"audio_transcriptions\" \"$V_ATRANS\" \"$SRC_ATRANS\"\n check \"audio_tags\" \"$V_ATAGS\" \"$SRC_ATAGS\"\n\nfi\n\n# ─── COPY FRAME DATA FOLDER ──────────────────────────────────────────────────\n# Always runs regardless of DB sync status.\nstep \"Copying frame data folder for $TARGET_DATE\"\n\nif [ -d \"$DATA_SRC\" ]; then\n mkdir -p \"$NAS_DATA/$TARGET_DATE\"\n RSYNC_START=$(date +%s)\n printf \" %-36s \" \"rsync frames → NAS\"\n rsync -a --ignore-existing \"$DATA_SRC/\" \"$NAS_DATA/$TARGET_DATE/\" 2>>\"$LOG_FILE\"\n RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))\n COPIED_FILES=$(ls \"$NAS_DATA/$TARGET_DATE\" 2>/dev/null | grep -v '^audio$' | wc -l | tr -d ' ')\n SRC_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n COPIED_SIZE=$(du -sh \"$NAS_DATA/$TARGET_DATE\" | cut -f1)\n if [ \"$COPIED_FILES\" -ge \"$SRC_FILES\" ]; then\n printf \"\\r %-36s ✓ %dm%02ds (%s files, %s)\\n\" \\\n \"rsync frames → NAS\" \\\n \"$(( RSYNC_DUR / 60 ))\" \"$(( RSYNC_DUR % 60 ))\" \\\n \"$COPIED_FILES\" \"$COPIED_SIZE\" | tee -a \"$LOG_FILE\"\n else\n printf \"\\r %-36s ✗ %s / %s files\\n\" \\\n \"rsync frames → NAS\" \"$COPIED_FILES\" \"$SRC_FILES\" | tee -a \"$LOG_FILE\"\n fi\nelse\n printf \" %-36s %s\\n\" \"rsync frames → NAS\" \"skipped (no source dir)\"\nfi\n\n# ─── COPY AUDIO FILES ────────────────────────────────────────────────────────\n# Audio is flat in ~/.screenpipe/data/ with the date in the filename, e.g.\n# System Audio (output)_2026-05-11_13-48-12.mp4\n# soundcore AeroClip (input)_2026-05-10_11-10-32.mp4\n# Mirrored to $NAS_DATA/<date>/audio/ so each day's archive is self-contained.\nstep \"Copying audio files for $TARGET_DATE\"\n\nshopt -s nullglob\nAUDIO_FILES=( \"$HOME/.screenpipe/data/\"*_\"${TARGET_DATE}\"_*.mp4 )\nshopt -u nullglob\n\nif [ ${#AUDIO_FILES[@]} -gt 0 ]; then\n mkdir -p \"$NAS_DATA/$TARGET_DATE/audio\"\n RSYNC_START=$(date +%s)\n printf \" %-36s \" \"rsync audio → NAS\"\n rsync -a --ignore-existing \"${AUDIO_FILES[@]}\" \"$NAS_DATA/$TARGET_DATE/audio/\" 2>>\"$LOG_FILE\"\n RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))\n COPIED_AUDIO=$(ls \"$NAS_DATA/$TARGET_DATE/audio\" | wc -l | tr -d ' ')\n AUDIO_SIZE=$(du -sh \"$NAS_DATA/$TARGET_DATE/audio\" | cut -f1)\n printf \"\\r %-36s ✓ %dm%02ds (%s files, %s)\\n\" \\\n \"rsync audio → NAS\" \\\n \"$(( RSYNC_DUR / 60 ))\" \"$(( RSYNC_DUR % 60 ))\" \\\n \"$COPIED_AUDIO\" \"$AUDIO_SIZE\" | tee -a \"$LOG_FILE\"\nelse\n printf \" %-36s %s\\n\" \"rsync audio → NAS\" \"skipped (no audio for date)\"\nfi\n\n# ─── COPY LOGS ────────────────────────────────────────────────────────────────\nstep \"Copying screenpipe logs for $TARGET_DATE\"\n\nNAS_LOGS=\"$NAS_MOUNT/logs\"\nmkdir -p \"$NAS_LOGS\"\n\nshopt -s nullglob\nLOG_FILES=( \"$HOME/.screenpipe/screenpipe.$TARGET_DATE.\"*.log )\nshopt -u nullglob\n\nif [ ${#LOG_FILES[@]} -gt 0 ]; then\n printf \" %-36s \" \"rsync logs → NAS\"\n rsync -a \"${LOG_FILES[@]}\" \"$NAS_LOGS/\" 2>>\"$LOG_FILE\"\n TOTAL_SIZE=$(du -ch \"${LOG_FILES[@]}\" | tail -1 | cut -f1)\n printf \"✓ %d file(s), %s\\n\" \"${#LOG_FILES[@]}\" \"$TOTAL_SIZE\" | tee -a \"$LOG_FILE\"\nelse\n printf \" %-36s %s\\n\" \"rsync logs → NAS\" \"skipped (no matching logs)\"\nfi\n\n# ─── SUMMARY ──────────────────────────────────────────────────────────────────\nTOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))\nDB_SIZE=$(du -sh \"$NAS_DB\" | cut -f1)\n\necho \"\"\nlog \"Archive DB size: $DB_SIZE\"\nlog \"Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s\"\nlog \"Sync complete for $TARGET_DATE (install $INSTALL_ID)\"\nlog \"========================================\"\n\nrsync -a \"$HOME/.screenpipe/sync.log\" \"$NAS_LOGS/sync.log\" 2>/dev/null || true","depth":28,"on_screen":true,"value":"# the source currently has; INSERT OR IGNORE handles the duplicate case.\n run_sqlite_heredoc \"speakers ($SRC_SPEAKERS rows, all-time)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.speakers ($SPEAKERS_COLS, install_id)\n SELECT $SPEAKERS_COLS, '$INSTALL_ID' FROM main.speakers;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"speaker_embeddings ($SRC_SEMB rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.speaker_embeddings ($SEMB_COLS, install_id)\n SELECT $SEMB_COLS, '$INSTALL_ID' FROM main.speaker_embeddings;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"audio_chunks ($SRC_ACHUNKS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.audio_chunks ($ACHUNKS_COLS, install_id)\n SELECT $ACHUNKS_COLS, '$INSTALL_ID' FROM main.audio_chunks WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"audio_transcriptions ($SRC_ATRANS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.audio_transcriptions ($ATRANS_COLS, install_id)\n SELECT $ATRANS_COLS_T, '$INSTALL_ID' FROM main.audio_transcriptions t\n JOIN main.audio_chunks c ON t.audio_chunk_id = c.id\n WHERE date(c.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"audio_tags ($SRC_ATAGS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.audio_tags ($ATAGS_COLS, install_id)\n SELECT $ATAGS_COLS_AT, '$INSTALL_ID' FROM main.audio_tags at\n JOIN main.audio_chunks c ON at.audio_chunk_id = c.id\n WHERE date(c.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n # ─── FTS UPDATE ───────────────────────────────────────────────────────────\n step \"Updating FTS indexes\"\n\n run_sqlite_heredoc \"elements_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.elements_fts(rowid, text, role)\n SELECT e.id, e.text, e.role\n FROM nas.elements e\n JOIN nas.frames f ON e.frame_id = f.id AND e.install_id = f.install_id\n WHERE date(f.timestamp) = '$TARGET_DATE'\n AND e.install_id = '$INSTALL_ID'\n AND e.text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)\n SELECT id, full_text, app_name, window_name, browser_url, id\n FROM nas.frames\n WHERE date(timestamp) = '$TARGET_DATE'\n AND install_id = '$INSTALL_ID'\n AND full_text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)\n SELECT id, text_content, app_name, window_title, element_name\n FROM nas.ui_events\n WHERE date(timestamp) = '$TARGET_DATE'\n AND install_id = '$INSTALL_ID'\n AND text_content IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"audio_transcriptions_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.audio_transcriptions_fts(rowid, transcription, device, speaker_id, id)\n SELECT t.id, t.transcription, COALESCE(t.device,''), t.speaker_id, t.id\n FROM nas.audio_transcriptions t\n JOIN nas.audio_chunks c ON t.audio_chunk_id = c.id AND t.install_id = c.install_id\n WHERE date(c.timestamp) = '$TARGET_DATE'\n AND t.install_id = '$INSTALL_ID'\n AND t.transcription IS NOT NULL AND t.transcription != '';\nDETACH nas;\n\"\n\n # ─── VERIFY ───────────────────────────────────────────────────────────────\n step \"Verifying DB\"\n\n V_FRAMES=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID';\")\n V_ELEMENTS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM elements WHERE install_id='$INSTALL_ID' AND frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID');\")\n V_UI=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID';\")\n V_OCR=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ocr_text WHERE install_id='$INSTALL_ID' AND frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID');\")\n V_MEETINGS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE' AND install_id='$INSTALL_ID';\")\n V_ACHUNKS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM audio_chunks WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID';\")\n V_ATRANS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM audio_transcriptions WHERE install_id='$INSTALL_ID' AND audio_chunk_id IN (SELECT id FROM audio_chunks WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID');\")\n V_ATAGS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM audio_tags WHERE install_id='$INSTALL_ID' AND audio_chunk_id IN (SELECT id FROM audio_chunks WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID');\")\n\n check \"frames\" \"$V_FRAMES\" \"$SRC_FRAMES\"\n check \"elements\" \"$V_ELEMENTS\" \"$SRC_ELEMENTS\"\n check \"ui_events\" \"$V_UI\" \"$SRC_UI\"\n check \"ocr_text\" \"$V_OCR\" \"$SRC_OCR\"\n check \"meetings\" \"$V_MEETINGS\" \"$SRC_MEETINGS\"\n check \"audio_chunks\" \"$V_ACHUNKS\" \"$SRC_ACHUNKS\"\n check \"audio_transcriptions\" \"$V_ATRANS\" \"$SRC_ATRANS\"\n check \"audio_tags\" \"$V_ATAGS\" \"$SRC_ATAGS\"\n\nfi\n\n# ─── COPY FRAME DATA FOLDER ──────────────────────────────────────────────────\n# Always runs regardless of DB sync status.\nstep \"Copying frame data folder for $TARGET_DATE\"\n\nif [ -d \"$DATA_SRC\" ]; then\n mkdir -p \"$NAS_DATA/$TARGET_DATE\"\n RSYNC_START=$(date +%s)\n printf \" %-36s \" \"rsync frames → NAS\"\n rsync -a --ignore-existing \"$DATA_SRC/\" \"$NAS_DATA/$TARGET_DATE/\" 2>>\"$LOG_FILE\"\n RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))\n COPIED_FILES=$(ls \"$NAS_DATA/$TARGET_DATE\" 2>/dev/null | grep -v '^audio$' | wc -l | tr -d ' ')\n SRC_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n COPIED_SIZE=$(du -sh \"$NAS_DATA/$TARGET_DATE\" | cut -f1)\n if [ \"$COPIED_FILES\" -ge \"$SRC_FILES\" ]; then\n printf \"\\r %-36s ✓ %dm%02ds (%s files, %s)\\n\" \\\n \"rsync frames → NAS\" \\\n \"$(( RSYNC_DUR / 60 ))\" \"$(( RSYNC_DUR % 60 ))\" \\\n \"$COPIED_FILES\" \"$COPIED_SIZE\" | tee -a \"$LOG_FILE\"\n else\n printf \"\\r %-36s ✗ %s / %s files\\n\" \\\n \"rsync frames → NAS\" \"$COPIED_FILES\" \"$SRC_FILES\" | tee -a \"$LOG_FILE\"\n fi\nelse\n printf \" %-36s %s\\n\" \"rsync frames → NAS\" \"skipped (no source dir)\"\nfi\n\n# ─── COPY AUDIO FILES ────────────────────────────────────────────────────────\n# Audio is flat in ~/.screenpipe/data/ with the date in the filename, e.g.\n# System Audio (output)_2026-05-11_13-48-12.mp4\n# soundcore AeroClip (input)_2026-05-10_11-10-32.mp4\n# Mirrored to $NAS_DATA/<date>/audio/ so each day's archive is self-contained.\nstep \"Copying audio files for $TARGET_DATE\"\n\nshopt -s nullglob\nAUDIO_FILES=( \"$HOME/.screenpipe/data/\"*_\"${TARGET_DATE}\"_*.mp4 )\nshopt -u nullglob\n\nif [ ${#AUDIO_FILES[@]} -gt 0 ]; then\n mkdir -p \"$NAS_DATA/$TARGET_DATE/audio\"\n RSYNC_START=$(date +%s)\n printf \" %-36s \" \"rsync audio → NAS\"\n rsync -a --ignore-existing \"${AUDIO_FILES[@]}\" \"$NAS_DATA/$TARGET_DATE/audio/\" 2>>\"$LOG_FILE\"\n RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))\n COPIED_AUDIO=$(ls \"$NAS_DATA/$TARGET_DATE/audio\" | wc -l | tr -d ' ')\n AUDIO_SIZE=$(du -sh \"$NAS_DATA/$TARGET_DATE/audio\" | cut -f1)\n printf \"\\r %-36s ✓ %dm%02ds (%s files, %s)\\n\" \\\n \"rsync audio → NAS\" \\\n \"$(( RSYNC_DUR / 60 ))\" \"$(( RSYNC_DUR % 60 ))\" \\\n \"$COPIED_AUDIO\" \"$AUDIO_SIZE\" | tee -a \"$LOG_FILE\"\nelse\n printf \" %-36s %s\\n\" \"rsync audio → NAS\" \"skipped (no audio for date)\"\nfi\n\n# ─── COPY LOGS ────────────────────────────────────────────────────────────────\nstep \"Copying screenpipe logs for $TARGET_DATE\"\n\nNAS_LOGS=\"$NAS_MOUNT/logs\"\nmkdir -p \"$NAS_LOGS\"\n\nshopt -s nullglob\nLOG_FILES=( \"$HOME/.screenpipe/screenpipe.$TARGET_DATE.\"*.log )\nshopt -u nullglob\n\nif [ ${#LOG_FILES[@]} -gt 0 ]; then\n printf \" %-36s \" \"rsync logs → NAS\"\n rsync -a \"${LOG_FILES[@]}\" \"$NAS_LOGS/\" 2>>\"$LOG_FILE\"\n TOTAL_SIZE=$(du -ch \"${LOG_FILES[@]}\" | tail -1 | cut -f1)\n printf \"✓ %d file(s), %s\\n\" \"${#LOG_FILES[@]}\" \"$TOTAL_SIZE\" | tee -a \"$LOG_FILE\"\nelse\n printf \" %-36s %s\\n\" \"rsync logs → NAS\" \"skipped (no matching logs)\"\nfi\n\n# ─── SUMMARY ──────────────────────────────────────────────────────────────────\nTOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))\nDB_SIZE=$(du -sh \"$NAS_DB\" | cut -f1)\n\necho \"\"\nlog \"Archive DB size: $DB_SIZE\"\nlog \"Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s\"\nlog \"Sync complete for $TARGET_DATE (install $INSTALL_ID)\"\nlog \"========================================\"\n\nrsync -a \"$HOME/.screenpipe/sync.log\" \"$NAS_LOGS/sync.log\" 2>/dev/null || true","role_description":"editor","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"# the source currently has; INSERT OR IGNORE handles the duplicate case.\n run_sqlite_heredoc \"speakers ($SRC_SPEAKERS rows, all-time)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.speakers ($SPEAKERS_COLS, install_id)\n SELECT $SPEAKERS_COLS, '$INSTALL_ID' FROM main.speakers;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"speaker_embeddings ($SRC_SEMB rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.speaker_embeddings ($SEMB_COLS, install_id)\n SELECT $SEMB_COLS, '$INSTALL_ID' FROM main.speaker_embeddings;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"audio_chunks ($SRC_ACHUNKS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.audio_chunks ($ACHUNKS_COLS, install_id)\n SELECT $ACHUNKS_COLS, '$INSTALL_ID' FROM main.audio_chunks WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"audio_transcriptions ($SRC_ATRANS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.audio_transcriptions ($ATRANS_COLS, install_id)\n SELECT $ATRANS_COLS_T, '$INSTALL_ID' FROM main.audio_transcriptions t\n JOIN main.audio_chunks c ON t.audio_chunk_id = c.id\n WHERE date(c.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"audio_tags ($SRC_ATAGS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.audio_tags ($ATAGS_COLS, install_id)\n SELECT $ATAGS_COLS_AT, '$INSTALL_ID' FROM main.audio_tags at\n JOIN main.audio_chunks c ON at.audio_chunk_id = c.id\n WHERE date(c.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n # ─── FTS UPDATE ───────────────────────────────────────────────────────────\n step \"Updating FTS indexes\"\n\n run_sqlite_heredoc \"elements_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.elements_fts(rowid, text, role)\n SELECT e.id, e.text, e.role\n FROM nas.elements e\n JOIN nas.frames f ON e.frame_id = f.id AND e.install_id = f.install_id\n WHERE date(f.timestamp) = '$TARGET_DATE'\n AND e.install_id = '$INSTALL_ID'\n AND e.text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)\n SELECT id, full_text, app_name, window_name, browser_url, id\n FROM nas.frames\n WHERE date(timestamp) = '$TARGET_DATE'\n AND install_id = '$INSTALL_ID'\n AND full_text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)\n SELECT id, text_content, app_name, window_title, element_name\n FROM nas.ui_events\n WHERE date(timestamp) = '$TARGET_DATE'\n AND install_id = '$INSTALL_ID'\n AND text_content IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"audio_transcriptions_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.audio_transcriptions_fts(rowid, transcription, device, speaker_id, id)\n SELECT t.id, t.transcription, COALESCE(t.device,''), t.speaker_id, t.id\n FROM nas.audio_transcriptions t\n JOIN nas.audio_chunks c ON t.audio_chunk_id = c.id AND t.install_id = c.install_id\n WHERE date(c.timestamp) = '$TARGET_DATE'\n AND t.install_id = '$INSTALL_ID'\n AND t.transcription IS NOT NULL AND t.transcription != '';\nDETACH nas;\n\"\n\n # ─── VERIFY ───────────────────────────────────────────────────────────────\n step \"Verifying DB\"\n\n V_FRAMES=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID';\")\n V_ELEMENTS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM elements WHERE install_id='$INSTALL_ID' AND frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID');\")\n V_UI=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID';\")\n V_OCR=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ocr_text WHERE install_id='$INSTALL_ID' AND frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID');\")\n V_MEETINGS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE' AND install_id='$INSTALL_ID';\")\n V_ACHUNKS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM audio_chunks WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID';\")\n V_ATRANS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM audio_transcriptions WHERE install_id='$INSTALL_ID' AND audio_chunk_id IN (SELECT id FROM audio_chunks WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID');\")\n V_ATAGS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM audio_tags WHERE install_id='$INSTALL_ID' AND audio_chunk_id IN (SELECT id FROM audio_chunks WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID');\")\n\n check \"frames\" \"$V_FRAMES\" \"$SRC_FRAMES\"\n check \"elements\" \"$V_ELEMENTS\" \"$SRC_ELEMENTS\"\n check \"ui_events\" \"$V_UI\" \"$SRC_UI\"\n check \"ocr_text\" \"$V_OCR\" \"$SRC_OCR\"\n check \"meetings\" \"$V_MEETINGS\" \"$SRC_MEETINGS\"\n check \"audio_chunks\" \"$V_ACHUNKS\" \"$SRC_ACHUNKS\"\n check \"audio_transcriptions\" \"$V_ATRANS\" \"$SRC_ATRANS\"\n check \"audio_tags\" \"$V_ATAGS\" \"$SRC_ATAGS\"\n\nfi\n\n# ─── COPY FRAME DATA FOLDER ──────────────────────────────────────────────────\n# Always runs regardless of DB sync status.\nstep \"Copying frame data folder for $TARGET_DATE\"\n\nif [ -d \"$DATA_SRC\" ]; then\n mkdir -p \"$NAS_DATA/$TARGET_DATE\"\n RSYNC_START=$(date +%s)\n printf \" %-36s \" \"rsync frames → NAS\"\n rsync -a --ignore-existing \"$DATA_SRC/\" \"$NAS_DATA/$TARGET_DATE/\" 2>>\"$LOG_FILE\"\n RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))\n COPIED_FILES=$(ls \"$NAS_DATA/$TARGET_DATE\" 2>/dev/null | grep -v '^audio$' | wc -l | tr -d ' ')\n SRC_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n COPIED_SIZE=$(du -sh \"$NAS_DATA/$TARGET_DATE\" | cut -f1)\n if [ \"$COPIED_FILES\" -ge \"$SRC_FILES\" ]; then\n printf \"\\r %-36s ✓ %dm%02ds (%s files, %s)\\n\" \\\n \"rsync frames → NAS\" \\\n \"$(( RSYNC_DUR / 60 ))\" \"$(( RSYNC_DUR % 60 ))\" \\\n \"$COPIED_FILES\" \"$COPIED_SIZE\" | tee -a \"$LOG_FILE\"\n else\n printf \"\\r %-36s ✗ %s / %s files\\n\" \\\n \"rsync frames → NAS\" \"$COPIED_FILES\" \"$SRC_FILES\" | tee -a \"$LOG_FILE\"\n fi\nelse\n printf \" %-36s %s\\n\" \"rsync frames → NAS\" \"skipped (no source dir)\"\nfi\n\n# ─── COPY AUDIO FILES ────────────────────────────────────────────────────────\n# Audio is flat in ~/.screenpipe/data/ with the date in the filename, e.g.\n# System Audio (output)_2026-05-11_13-48-12.mp4\n# soundcore AeroClip (input)_2026-05-10_11-10-32.mp4\n# Mirrored to $NAS_DATA/<date>/audio/ so each day's archive is self-contained.\nstep \"Copying audio files for $TARGET_DATE\"\n\nshopt -s nullglob\nAUDIO_FILES=( \"$HOME/.screenpipe/data/\"*_\"${TARGET_DATE}\"_*.mp4 )\nshopt -u nullglob\n\nif [ ${#AUDIO_FILES[@]} -gt 0 ]; then\n mkdir -p \"$NAS_DATA/$TARGET_DATE/audio\"\n RSYNC_START=$(date +%s)\n printf \" %-36s \" \"rsync audio → NAS\"\n rsync -a --ignore-existing \"${AUDIO_FILES[@]}\" \"$NAS_DATA/$TARGET_DATE/audio/\" 2>>\"$LOG_FILE\"\n RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))\n COPIED_AUDIO=$(ls \"$NAS_DATA/$TARGET_DATE/audio\" | wc -l | tr -d ' ')\n AUDIO_SIZE=$(du -sh \"$NAS_DATA/$TARGET_DATE/audio\" | cut -f1)\n printf \"\\r %-36s ✓ %dm%02ds (%s files, %s)\\n\" \\\n \"rsync audio → NAS\" \\\n \"$(( RSYNC_DUR / 60 ))\" \"$(( RSYNC_DUR % 60 ))\" \\\n \"$COPIED_AUDIO\" \"$AUDIO_SIZE\" | tee -a \"$LOG_FILE\"\nelse\n printf \" %-36s %s\\n\" \"rsync audio → NAS\" \"skipped (no audio for date)\"\nfi\n\n# ─── COPY LOGS ────────────────────────────────────────────────────────────────\nstep \"Copying screenpipe logs for $TARGET_DATE\"\n\nNAS_LOGS=\"$NAS_MOUNT/logs\"\nmkdir -p \"$NAS_LOGS\"\n\nshopt -s nullglob\nLOG_FILES=( \"$HOME/.screenpipe/screenpipe.$TARGET_DATE.\"*.log )\nshopt -u nullglob\n\nif [ ${#LOG_FILES[@]} -gt 0 ]; then\n printf \" %-36s \" \"rsync logs → NAS\"\n rsync -a \"${LOG_FILES[@]}\" \"$NAS_LOGS/\" 2>>\"$LOG_FILE\"\n TOTAL_SIZE=$(du -ch \"${LOG_FILES[@]}\" | tail -1 | cut -f1)\n printf \"✓ %d file(s), %s\\n\" \"${#LOG_FILES[@]}\" \"$TOTAL_SIZE\" | tee -a \"$LOG_FILE\"\nelse\n printf \" %-36s %s\\n\" \"rsync logs → NAS\" \"skipped (no matching logs)\"\nfi\n\n# ─── SUMMARY ──────────────────────────────────────────────────────────────────\nTOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))\nDB_SIZE=$(du -sh \"$NAS_DB\" | cut -f1)\n\necho \"\"\nlog \"Archive DB size: $DB_SIZE\"\nlog \"Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s\"\nlog \"Sync complete for $TARGET_DATE (install $INSTALL_ID)\"\nlog \"========================================\"\n\nrsync -a \"$HOME/.screenpipe/sync.log\" \"$NAS_LOGS/sync.log\" 2>/dev/null || true","depth":29,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Implement and run pipe l…, Editor Group 2","depth":28,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":false},{"role":"AXRadioButton","text":"Problems (⇧⌘M)","depth":22,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"PROBLEMS","depth":24,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Output (⇧⌘U)","depth":22,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUTPUT","depth":24,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Debug Console (⇧⌘Y)","depth":22,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"DEBUG CONSOLE","depth":24,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Terminal (⌃`)","depth":22,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":true},{"role":"AXStaticText","text":"TERMINAL","depth":24,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Ports - 1 forwarded port","depth":22,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"PORTS","depth":24,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":25,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"remote SSH: nas","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"SSH: nas","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"screenpipe (Git) - master*, Checkout Branch/Tag...","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"master*","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"screenpipe (Git) - Synchronize Changes","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"No Problems","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"0","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"0","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Forwarded Ports: 8766","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Notifications","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sign In","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Sign In","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Shell Script","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Editor Language Status: Inline Suggestions, next: $(copilot) No inline suggestion available, Inline suggestions","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"LF","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"UTF-8","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Spaces: 2","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Ln 675, Col 1","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"git-commit Not Committed Yet","depth":16,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Not Committed Yet","depth":17,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"No results found","depth":12,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Implement and run pipe logic","depth":19,"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Session history","depth":19,"on_screen":true,"help_text":"Session history","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"New session","depth":19,"on_screen":true,"help_text":"New session","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Message actions","depth":24,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"main.py","depth":23,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"lets implement logic with pipes. how can I run it?","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Let me look at the current project structure to understand what's already in place.","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"List project files","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"find /volume1/screenpipe -type f | head -50 && echo \"---\" && ls /volume1/screenpipe","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"/volume1/screenpipe/.DS_Store\n/volume1/screenpipe/screenpipe.db\n/volume1/screenpipe/screenpipe_sync.sh\n/volume1/screenpipe/app_settings.json\n/volume1/screenpipe/.gitignore\n/volume1/screenpipe/archive.db\n/volume1/screenpipe/db.sqlite\n/volume1/screenpipe/db.sqlite-wal\n/volume1/screenpipe/db.sqlite-shm\n/volume1/screenpipe/#recycle/desktop.ini\n/volume1/screenpipe/#recycle/db.sqlite\n/volume1/screenpipe/#recycle/Copy #1 of db.sqlite\n/volume1/screenpipe/#recycle/.DS_Store\n/volume1/screenpipe/#recycle/Copy #2 of db.sqlite\n/volume1/screenpipe/#recycle/archive.db\n/volume1/screenpipe/#recycle/Copy #1 of archive.db\n/volume1/screenpipe/#recycle/Copy #2 of archive.db\n/volume1/screenpipe/#recycle/Copy #3 of archive.db\n/volume1/screenpipe/#recycle/Copy #4 of archive.db\n/volume1/screenpipe/#recycle/Copy #5 of archive.db\n/volume1/screenpipe/#recycle/Copy #3 of db.sqlite\n/volume1/screenpipe/#recycle/Copy #4 of db.sqlite\n/volume1/screenpipe/#recycle/Copy #6 of archive.db\n/volume1/screenpipe/#recycle/test.txt\n/volume1/screenpipe/#recycle/Copy #7 of archive.db\n/volume1/screenpipe/#recycle/Copy #8 of archive.db\n/volume1/screenpipe/#recycle/archive.db-journal\n/volume1/screenpipe/#recycle/Copy #1 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #2 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #3 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #4 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #5 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #6 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #7 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #5 of db.sqlite\n/volume1/screenpipe/pipes/.DS_Store\n/volume1/screenpipe/app/.env\n/volume1/screenpipe/app/cli.py\n/volume1/screenpipe/app/.DS_Store\n/volume1/screenpipe/app/db.py\n/volume1/screenpipe/app/docker-compose.yml\n/volume1/screenpipe/app/main.py\n/volume1/screenpipe/app/requirements.txt\n/volume1/screenpipe/app/Dockerfile\n/volume1/screenpipe/data/.DS_Store\n/volume1/screenpipe/.git/description\n/volume1/screenpipe/.git/HEAD\n/volume1/screenpipe/.git/index\n/volume1/screenpipe/.git/COMMIT_EDITMSG\n/volume1/screenpipe/#recycle/data/.DS_Store\n---\napp\napp_settings.json\narchive.db\ndata\ndb.sqlite\ndb.sqlite-shm\ndb.sqlite-wal\npipes\n#recycle\nscreenpipe.db\nscreenpipe_sync.sh","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"main.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Check pipes directory and docker-compose","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/pipes/ && ls /volume1/screenpipe/app/ && cat /volume1/screenpipe/app/docker-compose.yml","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ai-habits\nday-recap\nmeeting-summary\nstandup-update\ntime-breakdown\nvideo-export\ncli.py\nconsumers\ndb.py\ndocker-compose.yml\nDockerfile\nmain.py\n__pycache__\nrequirements.txt\nstatic\nservices:\n screenpipe-app:\n build: .\n container_name: screenpipe-app\n restart: unless-stopped\n ports:\n - \"8766:8000\"\n volumes:\n - /volume1/screenpipe:/data\n env_file:\n - .env\n environment:\n TZ: Europe/Sofia\n DB_PATH: /data/db.sqlite\n\n sqlite-web-archive:\n image: ghcr.io/coleifer/sqlite-web:latest\n container_name: screenpipe-sqlweb-archive\n restart: unless-stopped\n ports:\n - \"8767:8080\"\n volumes:\n - /volume1/screenpipe:/data\n command: [\"-H\", \"0.0.0.0\", \"-r\", \"/data/archive.db\"]\n\n sqlite-web-live:\n image: ghcr.io/coleifer/sqlite-web:latest\n container_name: screenpipe-sqlweb-live\n restart: unless-stopped\n ports:\n - \"8768:8080\"\n volumes:\n - /volume1/screenpipe:/data\n command: [\"-H\", \"0.0.0.0\", \"-r\", \"/data/db.sqlite\"]","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"requirements.txt","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"requirements.txt","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Inspect a pipe directory","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/pipes/day-recap/ && cat /volume1/screenpipe/pipes/day-recap/pipe.json 2>/dev/null || ls /volume1/screenpipe/pipes/day-recap/","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"pipe.md\npipe.md","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"cli.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"cli.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"List all pipes and their contents","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/pipes/ && for d in /volume1/screenpipe/pipes/*/; do echo \"=== $d ===\"; ls \"$d\"; done","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ai-habits\nday-recap\nmeeting-summary\nstandup-update\ntime-breakdown\nvideo-export\n=== /volume1/screenpipe/pipes/ai-habits/ ===\npipe.md\n=== /volume1/screenpipe/pipes/day-recap/ ===\npipe.md\n=== /volume1/screenpipe/pipes/meeting-summary/ ===\npipe.md\n=== /volume1/screenpipe/pipes/standup-update/ ===\npipe.md\n=== /volume1/screenpipe/pipes/time-breakdown/ ===\npipe.md\n=== /volume1/screenpipe/pipes/video-export/ ===\npipe.md","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read pipe markdown files","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"cat /volume1/screenpipe/pipes/day-recap/pipe.md && echo \"===\" && cat /volume1/screenpipe/pipes/meeting-summary/pipe.md 2>/dev/null | head -50","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Day Recap\ndescription: \"Today's accomplishments, key moments, and unfinished work\"\nicon: \"📋\"\nfeatured: true\n---\n\nAnalyze my screen and audio recordings from today (last 16 hours only). \n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Summary\nOne sentence: what I mainly did today.\n\n## Accomplishments\n- Top 3 things I finished, with timestamps (e.g. \"2:30 PM\")\n- Name specific apps, files, or projects\n\n## Key Moments\n- Important things I saw, said, or heard — with timestamps\n\n## Unfinished Work\n- What I should continue tomorrow — name the app/file/task\n\n## Patterns\n- Apps I used most, topics that came up repeatedly\n\nOnly report what you can verify from the data. End with: \"**Next step:** [most important thing to continue]\"\n===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Meeting Summary\ndescription: \"Summarize meeting transcript with key takeaways and action items\"\nicon: \"🤝\"\nfeatured: false\n---\n\nSummarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.\n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Meeting Summary\nOne sentence: what this meeting was about.\n\n## Key Takeaways\n- Top 3-5 important points discussed\n- Include who said what when relevant\n\n## Action Items\n- [ ] Task — assigned to whom, deadline if mentioned\n- [ ] Task — assigned to whom\n\n## Decisions Made\n- List any decisions or agreements reached\n\n## Open Questions\n- Anything unresolved or needing follow-up\n\nKeep it concise and actionable.","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read summary consumer","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/app/consumers/ && cat /volume1/screenpipe/app/consumers/summary.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"activity.py\naudio.py\nelements.py\n__init__.py\ninteractions.py\nocr.py\n__pycache__\nreport.py\nsummary.py\n\"\"\"AI summary generator using Claude.\"\"\"\nimport os\nfrom datetime import date\nfrom typing import Any\n\nfrom consumers.activity import app_time, summary_stats, browser_urls, ui_event_summary\nfrom consumers.ocr import deduplicated_text\nfrom consumers.audio import formatted_transcript\n\n\nSUMMARY_TYPES = {\n \"day_recap\": {\n \"title\": \"Day Recap\",\n \"prompt\": \"\"\"\\\nYou are analyzing a person's computer activity for the day.\n\n## App usage (minutes per app):\n{app_time}\n\n## Browser URLs visited:\n{browser_urls}\n\n## UI activity per app (clicks / keystrokes / app-switches):\n{ui_events}\n\n## Screen content (sampled every 5 minutes):\n{ocr_text}\n\n## Audio/speech:\n{audio}\n\nWrite a concise day recap using EXACTLY this format:\n\n## Summary\nOne sentence: what I mainly worked on today.\n\n## Accomplishments\n- Top 3 things I finished, with approximate times\n- Name specific apps, files, or projects\n\n## Key Moments\n- Important things seen or heard, with timestamps\n\n## Unfinished Work\n- What to continue tomorrow\n\n## Patterns\n- Apps used most, topics that came up repeatedly\n\nOnly report what you can verify from the data. End with:\n**Next step:** [most important thing to continue]\"\"\",\n },\n \"standup\": {\n \"title\": \"Standup Update\",\n \"prompt\": \"\"\"\\\nYou are analyzing a person's computer activity for the day.\n\n## App usage (minutes per app):\n{app_time}\n\n## Browser URLs visited:\n{browser_urls}\n\n## UI activity per app (clicks / keystrokes / app-switches):\n{ui_events}\n\n## Screen content (sampled every 5 minutes):\n{ocr_text}\n\n## Audio/speech:\n{audio}\n\nWrite a brief standup update:\n\n**Yesterday:** What I worked on (2-3 bullets)\n**Today:** What I plan to continue (1-2 bullets)\n**Blockers:** Any issues observed (or \"None\")\n\nKeep it under 150 words. Only report what's verifiable from the data.\"\"\",\n },\n \"focus_time\": {\n \"title\": \"Focus & Distraction Analysis\",\n \"prompt\": \"\"\"\\\nYou are analyzing a person's computer activity for the day.\n\n## App usage (minutes per app):\n{app_time}\n\n## Browser URLs visited:\n{browser_urls}\n\n## UI activity per app (clicks / keystrokes / app-switches):\n{ui_events}\n\n## Screen content (sampled every 5 minutes):\n{ocr_text}\n\nAnalyze focus vs distraction patterns:\n\n## Deep Work Periods\n- When and how long were sustained focus sessions?\n- What was being worked on?\n\n## Distractions\n- Which apps/sites were used recreationally?\n- How much time was lost to context switching?\n\n## Recommendations\n- 2-3 concrete suggestions to improve focus tomorrow\n\nBe specific with times and app names.\"\"\",\n },\n}\n\n\ndef _build_context(for_date: date) -> dict[str, str]:\n apps = app_time(for_date)\n app_lines = \"\\n\".join(f\"- {a['app_name']}: {a['minutes']} min\" for a in apps[:20])\n\n urls = browser_urls(for_date, limit=20)\n url_lines = \"\\n\".join(\n f\"- {u['browser_url'][:100]} ({u['minutes']} min)\" for u in urls\n )\n\n ui_rows = ui_event_summary(for_date)\n ui_lines = \"\\n\".join(\n f\"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches\"\n for r in ui_rows[:15]\n )\n\n ocr_rows = deduplicated_text(for_date, chunk_minutes=5)\n ocr_lines = \"\\n\".join(\n f\"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}\"\n for r in ocr_rows[:100]\n )\n\n audio = formatted_transcript(for_date)\n\n return {\n \"app_time\": app_lines or \"(no app data)\",\n \"browser_urls\": url_lines or \"(no browser data)\",\n \"ui_events\": ui_lines or \"(no UI event data)\",\n \"ocr_text\": ocr_lines or \"(no screen data)\",\n \"audio\": audio[:3000] if len(audio) > 3000 else audio,\n }\n\n\ndef generate(\n summary_type: str = \"day_recap\",\n for_date: date | None = None,\n api_key: str | None = None,\n) -> dict[str, Any]:\n \"\"\"Generate an AI summary. Returns dict with 'title', 'content', 'date'.\"\"\"\n import anthropic\n\n d = for_date or date.today()\n key = api_key or os.environ.get(\"ANTHROPIC_API_KEY\", \"\")\n if not key:\n return {\n \"title\": \"Error\",\n \"content\": \"ANTHROPIC_API_KEY not set. Add it to your .env file.\",\n \"date\": str(d),\n }\n\n spec = SUMMARY_TYPES.get(summary_type)\n if not spec:\n return {\"title\": \"Error\", \"content\": f\"Unknown summary type: {summary_type}\", \"date\": str(d)}\n\n stats = summary_stats(d)\n if stats[\"total_frames\"] == 0:\n return {\n \"title\": spec[\"title\"],\n \"content\": f\"No screen data found for {d}.\",\n \"date\": str(d),\n }\n\n ctx = _build_context(d)\n prompt = spec[\"prompt\"].format(**ctx)\n\n client = anthropic.Anthropic(api_key=key)\n message = client.messages.create(\n model=\"claude-haiku-4-5-20251001\",\n max_tokens=1024,\n messages=[{\"role\": \"user\", \"content\": prompt}],\n )\n\n return {\n \"title\": spec[\"title\"],\n \"content\": message.content[0].text,\n \"date\": str(d),\n \"stats\": stats,\n }","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read all pipe.md files","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"for f in /volume1/screenpipe/pipes/*/pipe.md; do echo \"=== $f ===\"; cat \"$f\"; echo; done","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"=== /volume1/screenpipe/pipes/ai-habits/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: AI Habits\ndescription: \"How you use AI tools — patterns and insights\"\nicon: \"🤖\"\nfeatured: true\n---\n\nSearch my recordings from the last 24 hours for AI tool usage. Use app_name filter for each tool separately: ChatGPT, Claude, Copilot, Cursor, Gemini, Perplexity. Use limit=5 per search, max 6 searches total.\n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## AI Tools Used\n- List each tool with approximate time spent (e.g. \"Claude: ~45min\")\n\n## What I Used Them For\n- For each tool: coding, writing, research, or brainstorming\n\n## Usage Patterns\n- Do I switch between tools? Use them in bursts or steadily?\n\n## Effectiveness\n- Which tool appeared alongside completed work vs. abandoned attempts\n\nIf no AI usage is found, say so clearly. End with: \"**Tip:** [one suggestion to use AI tools more effectively]\"\n\n=== /volume1/screenpipe/pipes/day-recap/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Day Recap\ndescription: \"Today's accomplishments, key moments, and unfinished work\"\nicon: \"📋\"\nfeatured: true\n---\n\nAnalyze my screen and audio recordings from today (last 16 hours only). \n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Summary\nOne sentence: what I mainly did today.\n\n## Accomplishments\n- Top 3 things I finished, with timestamps (e.g. \"2:30 PM\")\n- Name specific apps, files, or projects\n\n## Key Moments\n- Important things I saw, said, or heard — with timestamps\n\n## Unfinished Work\n- What I should continue tomorrow — name the app/file/task\n\n## Patterns\n- Apps I used most, topics that came up repeatedly\n\nOnly report what you can verify from the data. End with: \"**Next step:** [most important thing to continue]\"\n\n=== /volume1/screenpipe/pipes/meeting-summary/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Meeting Summary\ndescription: \"Summarize meeting transcript with key takeaways and action items\"\nicon: \"🤝\"\nfeatured: false\n---\n\nSummarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.\n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Meeting Summary\nOne sentence: what this meeting was about.\n\n## Key Takeaways\n- Top 3-5 important points discussed\n- Include who said what when relevant\n\n## Action Items\n- [ ] Task — assigned to whom, deadline if mentioned\n- [ ] Task — assigned to whom\n\n## Decisions Made\n- List any decisions or agreements reached\n\n## Open Questions\n- Anything unresolved or needing follow-up\n\nKeep it concise and actionable.\n\n=== /volume1/screenpipe/pipes/standup-update/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Standup Update\ndescription: \"What you did, what's next, and any blockers\"\nicon: \"🏢\"\nfeatured: true\n---\n\nBased on my recordings from the last 24 hours, generate a standup update. Use limit=10 per search, max 3 searches total.\n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Yesterday\n- What I worked on (name specific projects, files, tools, PRs)\n\n## Today\n- What I will work on next (based on unfinished tasks and recent activity)\n\n## Blockers\n- Issues I hit — errors, slow builds, waiting on someone\n- If no blockers, write \"None\"\n\nKeep it under 150 words. Copy-paste ready for a team standup.\n\n=== /volume1/screenpipe/pipes/time-breakdown/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Time Breakdown\ndescription: \"Where your time went — by app, project, and category\"\nicon: \"⏱\"\nfeatured: false\n---\n\nAnalyze my app usage from today (last 12 hours). Use limit=10 per search, max 4 searches. Prefer /raw_sql with COUNT/GROUP BY queries.\n\nRead screenpipe skill first.\n\nUse this exact format with durations and percentages:\n\n## By Application\n- List each app with duration and percentage, sorted by time (e.g. \"VS Code: 2h 15min (28%)\")\n\n## By Category\n- Group into: coding, meetings, browsing, writing, communication, other\n- Show hours and percentage per category\n\n## By Project\n- Group related activities by project/topic. Name specific repos or tasks.\n\n## Productivity Score\n- Calculate: focused_work_hours / total_hours as a percentage\n- Focused = coding + writing. Unfocused = browsing + switching.\n\nEnd with: \"**Suggestion:** [one specific change to improve tomorrow's productivity]\"\n\n=== /volume1/screenpipe/pipes/video-export/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Export Video Clip\ndescription: \"Create a video of your recent screen activity\"\nicon: \"🎬\"\nfeatured: false\n---\n\nExport a video of my screen activity from the last 5 minutes.\n\nRead screenpipe skill first.\n\nUse the POST /frames/export endpoint with the time range and fps=1.0. Then show me the exported video file path as an inline code block so I can watch it.\n\nIf the export is large, suggest a lower fps or shorter time range.","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Now I have a clear picture. The pipes are markdown prompt templates in","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"/volume1/screenpipe/pipes/","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":", but there's no code to actually load and run them —","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"consumers/summary.py","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"has its own hardcoded prompts instead.","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Here's what I'll implement:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"consumers/pipes.py","depth":26,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"— dynamically loads pipe.md files and runs them via Claude (data injected as system message, pipe body as user prompt)","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"main.py","depth":26,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"— two new endpoints:","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"GET /api/pipes","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"and","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"POST /api/pipes/{pipe_id}/run","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"cli.py","depth":26,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"— a","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"pipe","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"command to run pipes from the terminal","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Let me build it:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Check browser_urls signature","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"cat /volume1/screenpipe/app/consumers/activity.py | grep \"def browser_urls\" -A 5","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"def browser_urls(\n for_date: date | None = None,\n app_name: str | None = None,\n ts_from: str | None = None,\n ts_to: str | None = None,\n limit: int = 30,","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Write","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"pipes.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"pipes.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"143 lines","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"\"\"\"Dynamic pipe loader and runner.\"\"\"\nimport os\nimport re\nfrom datetime import date\nfrom pathlib import Path\nfrom typing import Any\n\n\ndef _parse_frontmatter(text: str) -> tuple[dict, str]:\n if not text.startswith(\"---\"):\n return {}, text\n try:\n end = text.index(\"---\", 3)\n except ValueError:\n return {}, text\n fm_text = text[3:end].strip()\n body = text[end + 3:].strip()\n meta: dict = {}\n for line in fm_text.splitlines():\n if \":\" in line:\n k, _, v = line.partition(\":\")\n meta[k.strip()] = v.strip().strip('\"')\n return meta, body\n\n\ndef load_pipes(pipes_dir: Path) -> list[dict]:\n if not pipes_dir.exists():\n return []\n pipes = []\n for pipe_dir in sorted(pipes_dir.iterdir()):\n if not pipe_dir.is_dir() or pipe_dir.name.startswith(\".\"):\n continue\n pipe_md = pipe_dir / \"pipe.md\"\n if not pipe_md.exists():\n continue\n text = pipe_md.read_text(encoding=\"utf-8\")\n meta, body = _parse_frontmatter(text)\n if meta.get(\"enabled\", \"true\").lower() == \"false\":\n continue\n body = re.sub(r\"Read screenpipe skill first\\.?\\n?\", \"\", body).strip()\n pipes.append({\n \"id\": pipe_dir.name,\n \"title\": meta.get(\"title\", pipe_dir.name),\n \"description\": meta.get(\"description\", \"\"),\n \"icon\": meta.get(\"icon\", \"\"),\n \"schedule\": meta.get(\"schedule\", \"manual\"),\n \"featured\": meta.get(\"featured\", \"false\").lower() == \"true\",\n \"prompt\": body,\n })\n return pipes\n\n\ndef _build_system(d: date, stats: dict) -> str:\n from consumers.activity import app_time, browser_urls, ui_event_summary\n from consumers.ocr import deduplicated_text\n from consumers.audio import formatted_transcript\n\n apps = app_time(d)\n app_lines = \"\\n\".join(f\"- {a['app_name']}: {a['minutes']} min\" for a in apps[:20])\n\n urls = browser_urls(d, limit=20)\n url_lines = \"\\n\".join(f\"- {u['browser_url'][:100]} ({u['minutes']} min)\" for u in urls)\n\n ui_rows = ui_event_summary(d)\n ui_lines = \"\\n\".join(\n f\"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches\"\n for r in ui_rows[:15]\n )\n\n ocr_rows = deduplicated_text(d, chunk_minutes=5)\n ocr_lines = \"\\n\".join(\n f\"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}\"\n for r in ocr_rows[:100]\n )\n\n audio = formatted_transcript(d)\n if len(audio) > 3000:\n audio = audio[:3000]\n\n return f\"\"\"You are analyzing screenpipe data — recordings of a person's computer activity.\n\n## App usage (minutes per app):\n{app_lines or '(no app data)'}\n\n## Browser URLs visited:\n{url_lines or '(no browser data)'}\n\n## UI activity per app (clicks / keystrokes / app-switches):\n{ui_lines or '(no UI event data)'}\n\n## Screen content (sampled every 5 minutes):\n{ocr_lines or '(no screen data)'}\n\n## Audio / speech:\n{audio or '(no audio data)'}\n\nDate: {d}\nTotal frames recorded: {stats['total_frames']}\"\"\"\n\n\ndef run_pipe(\n pipe_id: str,\n for_date: date | None = None,\n api_key: str | None = None,\n pipes_dir: Path | None = None,\n) -> dict[str, Any]:\n import anthropic\n from consumers.activity import summary_stats\n\n d = for_date or date.today()\n key = api_key or os.environ.get(\"ANTHROPIC_API_KEY\", \"\")\n if not key:\n return {\"title\": \"Error\", \"content\": \"ANTHROPIC_API_KEY not set.\", \"date\": str(d)}\n\n _pipes_dir = pipes_dir or Path(os.environ.get(\"PIPES_DIR\", \"/data/pipes\"))\n all_pipes = {p[\"id\"]: p for p in load_pipes(_pipes_dir)}\n\n if pipe_id not in all_pipes:\n return {\"title\": \"Error\", \"content\": f\"Pipe not found: {pipe_id}\", \"date\": str(d)}\n\n pipe = all_pipes[pipe_id]\n stats = summary_stats(d)\n\n if stats[\"total_frames\"] == 0:\n return {\"title\": pipe[\"title\"], \"content\": f\"No screen data found for {d}.\", \"date\": str(d)}\n\n system = _build_system(d, stats)\n\n client = anthropic.Anthropic(api_key=key)\n message = client.messages.create(\n model=\"claude-haiku-4-5-20251001\",\n max_tokens=1024,\n system=system,\n messages=[{\"role\": \"user\", \"content\": pipe[\"prompt\"]}],\n )\n\n return {\n \"title\": pipe[\"title\"],\n \"content\": message.content[0].text,\n \"date\": str(d),\n \"stats\": stats,\n }","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Now add the API endpoints to","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"main.py","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":":","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Edit","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"main.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Added 1 line","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Edit","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"main.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Added 1 line","depth":24,"on_screen":false,"role_description":"text"}]...
|
219043695316756802
|
-8905351981048886812
|
click
|
accessibility
|
NULL
|
Explorer (⇧⌘E) - 1 unsaved file
1
Search (⇧⌘F)
Explorer (⇧⌘E) - 1 unsaved file
1
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py
M
db.py
docker-compose.yml
Dockerfile
M
main.py
M
requirements.txt
M
data
logs
pipes
.gitignore
app_settings.json
archive.db
archive.db-bak
U
db.sqlite
db.sqlite-shm
db.sqlite-wal
screenpipe_sync_updated.sh
U
screenpipe_sync.sh
screenpipe.db
Outline Section
OUTLINE
OUTLINE
Timeline Section
TIMELINE
TIMELINE
app_settings.json, Editor Group 1
screenpipe_sync.sh, Editor Group 1
screenpipe_sync_updated.sh, preview, Editor Group 1
pipe.md, Editor Group 1
.env, Editor Group 1
# the source currently has; INSERT OR IGNORE handles the duplicate case.
run_sqlite_heredoc "speakers ($SRC_SPEAKERS rows, all-time)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.speakers ($SPEAKERS_COLS, install_id)
SELECT $SPEAKERS_COLS, '$INSTALL_ID' FROM main.speakers;
DETACH nas;
"
run_sqlite_heredoc "speaker_embeddings ($SRC_SEMB rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.speaker_embeddings ($SEMB_COLS, install_id)
SELECT $SEMB_COLS, '$INSTALL_ID' FROM main.speaker_embeddings;
DETACH nas;
"
run_sqlite_heredoc "audio_chunks ($SRC_ACHUNKS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.audio_chunks ($ACHUNKS_COLS, install_id)
SELECT $ACHUNKS_COLS, '$INSTALL_ID' FROM main.audio_chunks WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "audio_transcriptions ($SRC_ATRANS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.audio_transcriptions ($ATRANS_COLS, install_id)
SELECT $ATRANS_COLS_T, '$INSTALL_ID' FROM main.audio_transcriptions t
JOIN main.audio_chunks c ON t.audio_chunk_id = c.id
WHERE date(c.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "audio_tags ($SRC_ATAGS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.audio_tags ($ATAGS_COLS, install_id)
SELECT $ATAGS_COLS_AT, '$INSTALL_ID' FROM main.audio_tags at
JOIN main.audio_chunks c ON at.audio_chunk_id = c.id
WHERE date(c.timestamp) = '$TARGET_DATE';
DETACH nas;
"
# ─── FTS UPDATE ───────────────────────────────────────────────────────────
step "Updating FTS indexes"
run_sqlite_heredoc "elements_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.elements_fts(rowid, text, role)
SELECT e.id, e.text, e.role
FROM nas.elements e
JOIN nas.frames f ON e.frame_id = f.id AND e.install_id = f.install_id
WHERE date(f.timestamp) = '$TARGET_DATE'
AND e.install_id = '$INSTALL_ID'
AND e.text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "frames_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)
SELECT id, full_text, app_name, window_name, browser_url, id
FROM nas.frames
WHERE date(timestamp) = '$TARGET_DATE'
AND install_id = '$INSTALL_ID'
AND full_text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "ui_events_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)
SELECT id, text_content, app_name, window_title, element_name
FROM nas.ui_events
WHERE date(timestamp) = '$TARGET_DATE'
AND install_id = '$INSTALL_ID'
AND text_content IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "audio_transcriptions_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.audio_transcriptions_fts(rowid, transcription, device, speaker_id, id)
SELECT t.id, t.transcription, COALESCE(t.device,''), t.speaker_id, t.id
FROM nas.audio_transcriptions t
JOIN nas.audio_chunks c ON t.audio_chunk_id = c.id AND t.install_id = c.install_id
WHERE date(c.timestamp) = '$TARGET_DATE'
AND t.install_id = '$INSTALL_ID'
AND t.transcription IS NOT NULL AND t.transcription != '';
DETACH nas;
"
# ─── VERIFY ───────────────────────────────────────────────────────────────
step "Verifying DB"
V_FRAMES=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID';")
V_ELEMENTS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM elements WHERE install_id='$INSTALL_ID' AND frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID');")
V_UI=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID';")
V_OCR=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ocr_text WHERE install_id='$INSTALL_ID' AND frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID');")
V_MEETINGS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE' AND install_id='$INSTALL_ID';")
V_ACHUNKS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM audio_chunks WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID';")
V_ATRANS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM audio_transcriptions WHERE install_id='$INSTALL_ID' AND audio_chunk_id IN (SELECT id FROM audio_chunks WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID');")
V_ATAGS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM audio_tags WHERE install_id='$INSTALL_ID' AND audio_chunk_id IN (SELECT id FROM audio_chunks WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID');")
check "frames" "$V_FRAMES" "$SRC_FRAMES"
check "elements" "$V_ELEMENTS" "$SRC_ELEMENTS"
check "ui_events" "$V_UI" "$SRC_UI"
check "ocr_text" "$V_OCR" "$SRC_OCR"
check "meetings" "$V_MEETINGS" "$SRC_MEETINGS"
check "audio_chunks" "$V_ACHUNKS" "$SRC_ACHUNKS"
check "audio_transcriptions" "$V_ATRANS" "$SRC_ATRANS"
check "audio_tags" "$V_ATAGS" "$SRC_ATAGS"
fi
# ─── COPY FRAME DATA FOLDER ──────────────────────────────────────────────────
# Always runs regardless of DB sync status.
step "Copying frame data folder for $TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
mkdir -p "$NAS_DATA/$TARGET_DATE"
RSYNC_START=$(date +%s)
printf " %-36s " "rsync frames → NAS"
rsync -a --ignore-existing "$DATA_SRC/" "$NAS_DATA/$TARGET_DATE/" 2>>"$LOG_FILE"
RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))
COPIED_FILES=$(ls "$NAS_DATA/$TARGET_DATE" 2>/dev/null | grep -v '^audio$' | wc -l | tr -d ' ')
SRC_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
COPIED_SIZE=$(du -sh "$NAS_DATA/$TARGET_DATE" | cut -f1)
if [ "$COPIED_FILES" -ge "$SRC_FILES" ]; then
printf "\r %-36s ✓ %dm%02ds (%s files, %s)\n" \
"rsync frames → NAS" \
"$(( RSYNC_DUR / 60 ))" "$(( RSYNC_DUR % 60 ))" \
"$COPIED_FILES" "$COPIED_SIZE" | tee -a "$LOG_FILE"
else
printf "\r %-36s ✗ %s / %s files\n" \
"rsync frames → NAS" "$COPIED_FILES" "$SRC_FILES" | tee -a "$LOG_FILE"
fi
else
printf " %-36s %s\n" "rsync frames → NAS" "skipped (no source dir)"
fi
# ─── COPY AUDIO FILES ────────────────────────────────────────────────────────
# Audio is flat in ~/.screenpipe/data/ with the date in the filename, e.g.
# System Audio (output)_2026-05-11_13-48-12.mp4
# soundcore AeroClip (input)_2026-05-10_11-10-32.mp4
# Mirrored to $NAS_DATA/<date>/audio/ so each day's archive is self-contained.
step "Copying audio files for $TARGET_DATE"
shopt -s nullglob
AUDIO_FILES=( "$HOME/.screenpipe/data/"*_"${TARGET_DATE}"_*.mp4 )
shopt -u nullglob
if [ ${#AUDIO_FILES[@]} -gt 0 ]; then
mkdir -p "$NAS_DATA/$TARGET_DATE/audio"
RSYNC_START=$(date +%s)
printf " %-36s " "rsync audio → NAS"
rsync -a --ignore-existing "${AUDIO_FILES[@]}" "$NAS_DATA/$TARGET_DATE/audio/" 2>>"$LOG_FILE"
RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))
COPIED_AUDIO=$(ls "$NAS_DATA/$TARGET_DATE/audio" | wc -l | tr -d ' ')
AUDIO_SIZE=$(du -sh "$NAS_DATA/$TARGET_DATE/audio" | cut -f1)
printf "\r %-36s ✓ %dm%02ds (%s files, %s)\n" \
"rsync audio → NAS" \
"$(( RSYNC_DUR / 60 ))" "$(( RSYNC_DUR % 60 ))" \
"$COPIED_AUDIO" "$AUDIO_SIZE" | tee -a "$LOG_FILE"
else
printf " %-36s %s\n" "rsync audio → NAS" "skipped (no audio for date)"
fi
# ─── COPY LOGS ────────────────────────────────────────────────────────────────
step "Copying screenpipe logs for $TARGET_DATE"
NAS_LOGS="$NAS_MOUNT/logs"
mkdir -p "$NAS_LOGS"
shopt -s nullglob
LOG_FILES=( "$HOME/.screenpipe/screenpipe.$TARGET_DATE."*.log )
shopt -u nullglob
if [ ${#LOG_FILES[@]} -gt 0 ]; then
printf " %-36s " "rsync logs → NAS"
rsync -a "${LOG_FILES[@]}" "$NAS_LOGS/" 2>>"$LOG_FILE"
TOTAL_SIZE=$(du -ch "${LOG_FILES[@]}" | tail -1 | cut -f1)
printf "✓ %d file(s), %s\n" "${#LOG_FILES[@]}" "$TOTAL_SIZE" | tee -a "$LOG_FILE"
else
printf " %-36s %s\n" "rsync logs → NAS" "skipped (no matching logs)"
fi
# ─── SUMMARY ──────────────────────────────────────────────────────────────────
TOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))
DB_SIZE=$(du -sh "$NAS_DB" | cut -f1)
echo ""
log "Archive DB size: $DB_SIZE"
log "Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s"
log "Sync complete for $TARGET_DATE (install $INSTALL_ID)"
log "========================================"
rsync -a "$HOME/.screenpipe/sync.log" "$NAS_LOGS/sync.log" 2>/dev/null || true
# the source currently has; INSERT OR IGNORE handles the duplicate case.
run_sqlite_heredoc "speakers ($SRC_SPEAKERS rows, all-time)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.speakers ($SPEAKERS_COLS, install_id)
SELECT $SPEAKERS_COLS, '$INSTALL_ID' FROM main.speakers;
DETACH nas;
"
run_sqlite_heredoc "speaker_embeddings ($SRC_SEMB rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.speaker_embeddings ($SEMB_COLS, install_id)
SELECT $SEMB_COLS, '$INSTALL_ID' FROM main.speaker_embeddings;
DETACH nas;
"
run_sqlite_heredoc "audio_chunks ($SRC_ACHUNKS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.audio_chunks ($ACHUNKS_COLS, install_id)
SELECT $ACHUNKS_COLS, '$INSTALL_ID' FROM main.audio_chunks WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "audio_transcriptions ($SRC_ATRANS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.audio_transcriptions ($ATRANS_COLS, install_id)
SELECT $ATRANS_COLS_T, '$INSTALL_ID' FROM main.audio_transcriptions t
JOIN main.audio_chunks c ON t.audio_chunk_id = c.id
WHERE date(c.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "audio_tags ($SRC_ATAGS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.audio_tags ($ATAGS_COLS, install_id)
SELECT $ATAGS_COLS_AT, '$INSTALL_ID' FROM main.audio_tags at
JOIN main.audio_chunks c ON at.audio_chunk_id = c.id
WHERE date(c.timestamp) = '$TARGET_DATE';
DETACH nas;
"
# ─── FTS UPDATE ───────────────────────────────────────────────────────────
step "Updating FTS indexes"
run_sqlite_heredoc "elements_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.elements_fts(rowid, text, role)
SELECT e.id, e.text, e.role
FROM nas.elements e
JOIN nas.frames f ON e.frame_id = f.id AND e.install_id = f.install_id
WHERE date(f.timestamp) = '$TARGET_DATE'
AND e.install_id = '$INSTALL_ID'
AND e.text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "frames_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)
SELECT id, full_text, app_name, window_name, browser_url, id
FROM nas.frames
WHERE date(timestamp) = '$TARGET_DATE'
AND install_id = '$INSTALL_ID'
AND full_text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "ui_events_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)
SELECT id, text_content, app_name, window_title, element_name
FROM nas.ui_events
WHERE date(timestamp) = '$TARGET_DATE'
AND install_id = '$INSTALL_ID'
AND text_content IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "audio_transcriptions_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.audio_transcriptions_fts(rowid, transcription, device, speaker_id, id)
SELECT t.id, t.transcription, COALESCE(t.device,''), t.speaker_id, t.id
FROM nas.audio_transcriptions t
JOIN nas.audio_chunks c ON t.audio_chunk_id = c.id AND t.install_id = c.install_id
WHERE date(c.timestamp) = '$TARGET_DATE'
AND t.install_id = '$INSTALL_ID'
AND t.transcription IS NOT NULL AND t.transcription != '';
DETACH nas;
"
# ─── VERIFY ───────────────────────────────────────────────────────────────
step "Verifying DB"
V_FRAMES=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID';")
V_ELEMENTS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM elements WHERE install_id='$INSTALL_ID' AND frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID');")
V_UI=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID';")
V_OCR=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ocr_text WHERE install_id='$INSTALL_ID' AND frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID');")
V_MEETINGS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE' AND install_id='$INSTALL_ID';")
V_ACHUNKS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM audio_chunks WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID';")
V_ATRANS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM audio_transcriptions WHERE install_id='$INSTALL_ID' AND audio_chunk_id IN (SELECT id FROM audio_chunks WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID');")
V_ATAGS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM audio_tags WHERE install_id='$INSTALL_ID' AND audio_chunk_id IN (SELECT id FROM audio_chunks WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID');")
check "frames" "$V_FRAMES" "$SRC_FRAMES"
check "elements" "$V_ELEMENTS" "$SRC_ELEMENTS"
check "ui_events" "$V_UI" "$SRC_UI"
check "ocr_text" "$V_OCR" "$SRC_OCR"
check "meetings" "$V_MEETINGS" "$SRC_MEETINGS"
check "audio_chunks" "$V_ACHUNKS" "$SRC_ACHUNKS"
check "audio_transcriptions" "$V_ATRANS" "$SRC_ATRANS"
check "audio_tags" "$V_ATAGS" "$SRC_ATAGS"
fi
# ─── COPY FRAME DATA FOLDER ──────────────────────────────────────────────────
# Always runs regardless of DB sync status.
step "Copying frame data folder for $TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
mkdir -p "$NAS_DATA/$TARGET_DATE"
RSYNC_START=$(date +%s)
printf " %-36s " "rsync frames → NAS"
rsync -a --ignore-existing "$DATA_SRC/" "$NAS_DATA/$TARGET_DATE/" 2>>"$LOG_FILE"
RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))
COPIED_FILES=$(ls "$NAS_DATA/$TARGET_DATE" 2>/dev/null | grep -v '^audio$' | wc -l | tr -d ' ')
SRC_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
COPIED_SIZE=$(du -sh "$NAS_DATA/$TARGET_DATE" | cut -f1)
if [ "$COPIED_FILES" -ge "$SRC_FILES" ]; then
printf "\r %-36s ✓ %dm%02ds (%s files, %s)\n" \
"rsync frames → NAS" \
"$(( RSYNC_DUR / 60 ))" "$(( RSYNC_DUR % 60 ))" \
"$COPIED_FILES" "$COPIED_SIZE" | tee -a "$LOG_FILE"
else
printf "\r %-36s ✗ %s / %s files\n" \
"rsync frames → NAS" "$COPIED_FILES" "$SRC_FILES" | tee -a "$LOG_FILE"
fi
else
printf " %-36s %s\n" "rsync frames → NAS" "skipped (no source dir)"
fi
# ─── COPY AUDIO FILES ────────────────────────────────────────────────────────
# Audio is flat in ~/.screenpipe/data/ with the date in the filename, e.g.
# System Audio (output)_2026-05-11_13-48-12.mp4
# soundcore AeroClip (input)_2026-05-10_11-10-32.mp4
# Mirrored to $NAS_DATA/<date>/audio/ so each day's archive is self-contained.
step "Copying audio files for $TARGET_DATE"
shopt -s nullglob
AUDIO_FILES=( "$HOME/.screenpipe/data/"*_"${TARGET_DATE}"_*.mp4 )
shopt -u nullglob
if [ ${#AUDIO_FILES[@]} -gt 0 ]; then
mkdir -p "$NAS_DATA/$TARGET_DATE/audio"
RSYNC_START=$(date +%s)
printf " %-36s " "rsync audio → NAS"
rsync -a --ignore-existing "${AUDIO_FILES[@]}" "$NAS_DATA/$TARGET_DATE/audio/" 2>>"$LOG_FILE"
RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))
COPIED_AUDIO=$(ls "$NAS_DATA/$TARGET_DATE/audio" | wc -l | tr -d ' ')
AUDIO_SIZE=$(du -sh "$NAS_DATA/$TARGET_DATE/audio" | cut -f1)
printf "\r %-36s ✓ %dm%02ds (%s files, %s)\n" \
"rsync audio → NAS" \
"$(( RSYNC_DUR / 60 ))" "$(( RSYNC_DUR % 60 ))" \
"$COPIED_AUDIO" "$AUDIO_SIZE" | tee -a "$LOG_FILE"
else
printf " %-36s %s\n" "rsync audio → NAS" "skipped (no audio for date)"
fi
# ─── COPY LOGS ────────────────────────────────────────────────────────────────
step "Copying screenpipe logs for $TARGET_DATE"
NAS_LOGS="$NAS_MOUNT/logs"
mkdir -p "$NAS_LOGS"
shopt -s nullglob
LOG_FILES=( "$HOME/.screenpipe/screenpipe.$TARGET_DATE."*.log )
shopt -u nullglob
if [ ${#LOG_FILES[@]} -gt 0 ]; then
printf " %-36s " "rsync logs → NAS"
rsync -a "${LOG_FILES[@]}" "$NAS_LOGS/" 2>>"$LOG_FILE"
TOTAL_SIZE=$(du -ch "${LOG_FILES[@]}" | tail -1 | cut -f1)
printf "✓ %d file(s), %s\n" "${#LOG_FILES[@]}" "$TOTAL_SIZE" | tee -a "$LOG_FILE"
else
printf " %-36s %s\n" "rsync logs → NAS" "skipped (no matching logs)"
fi
# ─── SUMMARY ──────────────────────────────────────────────────────────────────
TOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))
DB_SIZE=$(du -sh "$NAS_DB" | cut -f1)
echo ""
log "Archive DB size: $DB_SIZE"
log "Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s"
log "Sync complete for $TARGET_DATE (install $INSTALL_ID)"
log "========================================"
rsync -a "$HOME/.screenpipe/sync.log" "$NAS_LOGS/sync.log" 2>/dev/null || true
Implement and run pipe l…, Editor Group 2
Problems (⇧⌘M)
PROBLEMS
Output (⇧⌘U)
OUTPUT
Debug Console (⇧⌘Y)
DEBUG CONSOLE
Terminal (⌃`)
TERMINAL
Ports - 1 forwarded port
PORTS
1
remote SSH: nas
SSH: nas
screenpipe (Git) - master*, Checkout Branch/Tag...
master*
screenpipe (Git) - Synchronize Changes
No Problems
0
0
Forwarded Ports: 8766
1
Notifications
Sign In
Sign In
Shell Script
Editor Language Status: Inline Suggestions, next: $(copilot) No inline suggestion available, Inline suggestions
LF
UTF-8
Spaces: 2
Ln 675, Col 1
git-commit Not Committed Yet
Not Committed Yet
No results found
Implement and run pipe logic
Session history
New session
Message actions
main.py
main.py
lets implement logic with pipes. how can I run it?
Thinking
Thinking
Let me look at the current project structure to understand what's already in place.
Bash
List project files
IN
find /volume1/screenpipe -type f | head -50 && echo "---" && ls /volume1/screenpipe
Copy code to clipboard
OUT
/volume1/screenpipe/.DS_Store
/volume1/screenpipe/screenpipe.db
/volume1/screenpipe/screenpipe_sync.sh
/volume1/screenpipe/app_settings.json
/volume1/screenpipe/.gitignore
/volume1/screenpipe/archive.db
/volume1/screenpipe/db.sqlite
/volume1/screenpipe/db.sqlite-wal
/volume1/screenpipe/db.sqlite-shm
/volume1/screenpipe/#recycle/desktop.ini
/volume1/screenpipe/#recycle/db.sqlite
/volume1/screenpipe/#recycle/Copy #1 of db.sqlite
/volume1/screenpipe/#recycle/.DS_Store
/volume1/screenpipe/#recycle/Copy #2 of db.sqlite
/volume1/screenpipe/#recycle/archive.db
/volume1/screenpipe/#recycle/Copy #1 of archive.db
/volume1/screenpipe/#recycle/Copy #2 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of archive.db
/volume1/screenpipe/#recycle/Copy #4 of archive.db
/volume1/screenpipe/#recycle/Copy #5 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of db.sqlite
/volume1/screenpipe/#recycle/Copy #4 of db.sqlite
/volume1/screenpipe/#recycle/Copy #6 of archive.db
/volume1/screenpipe/#recycle/test.txt
/volume1/screenpipe/#recycle/Copy #7 of archive.db
/volume1/screenpipe/#recycle/Copy #8 of archive.db
/volume1/screenpipe/#recycle/archive.db-journal
/volume1/screenpipe/#recycle/Copy #1 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #2 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #3 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #4 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #6 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #7 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of db.sqlite
/volume1/screenpipe/pipes/.DS_Store
/volume1/screenpipe/app/.env
/volume1/screenpipe/app/cli.py
/volume1/screenpipe/app/.DS_Store
/volume1/screenpipe/app/db.py
/volume1/screenpipe/app/docker-compose.yml
/volume1/screenpipe/app/main.py
/volume1/screenpipe/app/requirements.txt
/volume1/screenpipe/app/Dockerfile
/volume1/screenpipe/data/.DS_Store
/volume1/screenpipe/.git/description
/volume1/screenpipe/.git/HEAD
/volume1/screenpipe/.git/index
/volume1/screenpipe/.git/COMMIT_EDITMSG
/volume1/screenpipe/#recycle/data/.DS_Store
---
app
app_settings.json
archive.db
data
db.sqlite
db.sqlite-shm
db.sqlite-wal
pipes
#recycle
screenpipe.db
screenpipe_sync.sh
Read
main.py
main.py
Bash
Check pipes directory and docker-compose
IN
ls /volume1/screenpipe/pipes/ && ls /volume1/screenpipe/app/ && cat /volume1/screenpipe/app/docker-compose.yml
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
cli.py
consumers
db.py
docker-compose.yml
Dockerfile
main.py
__pycache__
requirements.txt
static
services:
screenpipe-app:
build: .
container_name: screenpipe-app
restart: unless-stopped
ports:
- "8766:8000"
volumes:
- /volume1/screenpipe:/data
env_file:
- .env
environment:
TZ: Europe/Sofia
DB_PATH: /data/db.sqlite
sqlite-web-archive:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-archive
restart: unless-stopped
ports:
- "8767:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/archive.db"]
sqlite-web-live:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-live
restart: unless-stopped
ports:
- "8768:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/db.sqlite"]
Read
requirements.txt
requirements.txt
Bash
Inspect a pipe directory
IN
ls /volume1/screenpipe/pipes/day-recap/ && cat /volume1/screenpipe/pipes/day-recap/pipe.json 2>/dev/null || ls /volume1/screenpipe/pipes/day-recap/
Copy code to clipboard
OUT
pipe.md
pipe.md
Read
cli.py
cli.py
Bash
List all pipes and their contents
IN
ls /volume1/screenpipe/pipes/ && for d in /volume1/screenpipe/pipes/*/; do echo "=== $d ==="; ls "$d"; done
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
=== /volume1/screenpipe/pipes/ai-habits/ ===
pipe.md
=== /volume1/screenpipe/pipes/day-recap/ ===
pipe.md
=== /volume1/screenpipe/pipes/meeting-summary/ ===
pipe.md
=== /volume1/screenpipe/pipes/standup-update/ ===
pipe.md
=== /volume1/screenpipe/pipes/time-breakdown/ ===
pipe.md
=== /volume1/screenpipe/pipes/video-export/ ===
pipe.md
Bash
Read pipe markdown files
IN
cat /volume1/screenpipe/pipes/day-recap/pipe.md && echo "===" && cat /volume1/screenpipe/pipes/meeting-summary/pipe.md 2>/dev/null | head -50
Copy code to clipboard
OUT
---
schedule: manual
enabled: true
template: true
title: Day Recap
description: "Today's accomplishments, key moments, and unfinished work"
icon: "📋"
featured: true
---
Analyze my screen and audio recordings from today (last 16 hours only).
Read screenpipe skill first.
Use this exact format:
## Summary
One sentence: what I mainly did today.
## Accomplishments
- Top 3 things I finished, with timestamps (e.g. "2:30 PM")
- Name specific apps, files, or projects
## Key Moments
- Important things I saw, said, or heard — with timestamps
## Unfinished Work
- What I should continue tomorrow — name the app/file/task
## Patterns
- Apps I used most, topics that came up repeatedly
Only report what you can verify from the data. End with: "**Next step:** [most important thing to continue]"
===
---
schedule: manual
enabled: true
template: true
title: Meeting Summary
description: "Summarize meeting transcript with key takeaways and action items"
icon: "🤝"
featured: false
---
Summarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.
Read screenpipe skill first.
Use this exact format:
## Meeting Summary
One sentence: what this meeting was about.
## Key Takeaways
- Top 3-5 important points discussed
- Include who said what when relevant
## Action Items
- [ ] Task — assigned to whom, deadline if mentioned
- [ ] Task — assigned to whom
## Decisions Made
- List any decisions or agreements reached
## Open Questions
- Anything unresolved or needing follow-up
Keep it concise and actionable.
Thinking
Thinking
Bash
Read summary consumer
IN
ls /volume1/screenpipe/app/consumers/ && cat /volume1/screenpipe/app/consumers/summary.py
Copy code to clipboard
OUT
activity.py
audio.py
elements.py
__init__.py
interactions.py
ocr.py
__pycache__
report.py
summary.py
"""AI summary generator using Claude."""
import os
from datetime import date
from typing import Any
from consumers.activity import app_time, summary_stats, browser_urls, ui_event_summary
from consumers.ocr import deduplicated_text
from consumers.audio import formatted_transcript
SUMMARY_TYPES = {
"day_recap": {
"title": "Day Recap",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
## Audio/speech:
{audio}
Write a concise day recap using EXACTLY this format:
## Summary
One sentence: what I mainly worked on today.
## Accomplishments
- Top 3 things I finished, with approximate times
- Name specific apps, files, or projects
## Key Moments
- Important things seen or heard, with timestamps
## Unfinished Work
- What to continue tomorrow
## Patterns
- Apps used most, topics that came up repeatedly
Only report what you can verify from the data. End with:
**Next step:** [most important thing to continue]""",
},
"standup": {
"title": "Standup Update",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
## Audio/speech:
{audio}
Write a brief standup update:
**Yesterday:** What I worked on (2-3 bullets)
**Today:** What I plan to continue (1-2 bullets)
**Blockers:** Any issues observed (or "None")
Keep it under 150 words. Only report what's verifiable from the data.""",
},
"focus_time": {
"title": "Focus & Distraction Analysis",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
Analyze focus vs distraction patterns:
## Deep Work Periods
- When and how long were sustained focus sessions?
- What was being worked on?
## Distractions
- Which apps/sites were used recreationally?
- How much time was lost to context switching?
## Recommendations
- 2-3 concrete suggestions to improve focus tomorrow
Be specific with times and app names.""",
},
}
def _build_context(for_date: date) -> dict[str, str]:
apps = app_time(for_date)
app_lines = "\n".join(f"- {a['app_name']}: {a['minutes']} min" for a in apps[:20])
urls = browser_urls(for_date, limit=20)
url_lines = "\n".join(
f"- {u['browser_url'][:100]} ({u['minutes']} min)" for u in urls
)
ui_rows = ui_event_summary(for_date)
ui_lines = "\n".join(
f"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches"
for r in ui_rows[:15]
)
ocr_rows = deduplicated_text(for_date, chunk_minutes=5)
ocr_lines = "\n".join(
f"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}"
for r in ocr_rows[:100]
)
audio = formatted_transcript(for_date)
return {
"app_time": app_lines or "(no app data)",
"browser_urls": url_lines or "(no browser data)",
"ui_events": ui_lines or "(no UI event data)",
"ocr_text": ocr_lines or "(no screen data)",
"audio": audio[:3000] if len(audio) > 3000 else audio,
}
def generate(
summary_type: str = "day_recap",
for_date: date | None = None,
api_key: str | None = None,
) -> dict[str, Any]:
"""Generate an AI summary. Returns dict with 'title', 'content', 'date'."""
import anthropic
d = for_date or date.today()
key = api_key or os.environ.get("ANTHROPIC_API_KEY", "")
if not key:
return {
"title": "Error",
"content": "ANTHROPIC_API_KEY not set. Add it to your .env file.",
"date": str(d),
}
spec = SUMMARY_TYPES.get(summary_type)
if not spec:
return {"title": "Error", "content": f"Unknown summary type: {summary_type}", "date": str(d)}
stats = summary_stats(d)
if stats["total_frames"] == 0:
return {
"title": spec["title"],
"content": f"No screen data found for {d}.",
"date": str(d),
}
ctx = _build_context(d)
prompt = spec["prompt"].format(**ctx)
client = anthropic.Anthropic(api_key=key)
message = client.messages.create(
model="claude-haiku-4-5-20251001",
max_tokens=1024,
messages=[{"role": "user", "content": prompt}],
)
return {
"title": spec["title"],
"content": message.content[0].text,
"date": str(d),
"stats": stats,
}
Thinking
Thinking
Bash
Read all pipe.md files
IN
for f in /volume1/screenpipe/pipes/*/pipe.md; do echo "=== $f ==="; cat "$f"; echo; done
Copy code to clipboard
OUT
=== /volume1/screenpipe/pipes/ai-habits/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: AI Habits
description: "How you use AI tools — patterns and insights"
icon: "🤖"
featured: true
---
Search my recordings from the last 24 hours for AI tool usage. Use app_name filter for each tool separately: ChatGPT, Claude, Copilot, Cursor, Gemini, Perplexity. Use limit=5 per search, max 6 searches total.
Read screenpipe skill first.
Use this exact format:
## AI Tools Used
- List each tool with approximate time spent (e.g. "Claude: ~45min")
## What I Used Them For
- For each tool: coding, writing, research, or brainstorming
## Usage Patterns
- Do I switch between tools? Use them in bursts or steadily?
## Effectiveness
- Which tool appeared alongside completed work vs. abandoned attempts
If no AI usage is found, say so clearly. End with: "**Tip:** [one suggestion to use AI tools more effectively]"
=== /volume1/screenpipe/pipes/day-recap/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Day Recap
description: "Today's accomplishments, key moments, and unfinished work"
icon: "📋"
featured: true
---
Analyze my screen and audio recordings from today (last 16 hours only).
Read screenpipe skill first.
Use this exact format:
## Summary
One sentence: what I mainly did today.
## Accomplishments
- Top 3 things I finished, with timestamps (e.g. "2:30 PM")
- Name specific apps, files, or projects
## Key Moments
- Important things I saw, said, or heard — with timestamps
## Unfinished Work
- What I should continue tomorrow — name the app/file/task
## Patterns
- Apps I used most, topics that came up repeatedly
Only report what you can verify from the data. End with: "**Next step:** [most important thing to continue]"
=== /volume1/screenpipe/pipes/meeting-summary/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Meeting Summary
description: "Summarize meeting transcript with key takeaways and action items"
icon: "🤝"
featured: false
---
Summarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.
Read screenpipe skill first.
Use this exact format:
## Meeting Summary
One sentence: what this meeting was about.
## Key Takeaways
- Top 3-5 important points discussed
- Include who said what when relevant
## Action Items
- [ ] Task — assigned to whom, deadline if mentioned
- [ ] Task — assigned to whom
## Decisions Made
- List any decisions or agreements reached
## Open Questions
- Anything unresolved or needing follow-up
Keep it concise and actionable.
=== /volume1/screenpipe/pipes/standup-update/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Standup Update
description: "What you did, what's next, and any blockers"
icon: "🏢"
featured: true
---
Based on my recordings from the last 24 hours, generate a standup update. Use limit=10 per search, max 3 searches total.
Read screenpipe skill first.
Use this exact format:
## Yesterday
- What I worked on (name specific projects, files, tools, PRs)
## Today
- What I will work on next (based on unfinished tasks and recent activity)
## Blockers
- Issues I hit — errors, slow builds, waiting on someone
- If no blockers, write "None"
Keep it under 150 words. Copy-paste ready for a team standup.
=== /volume1/screenpipe/pipes/time-breakdown/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Time Breakdown
description: "Where your time went — by app, project, and category"
icon: "⏱"
featured: false
---
Analyze my app usage from today (last 12 hours). Use limit=10 per search, max 4 searches. Prefer /raw_sql with COUNT/GROUP BY queries.
Read screenpipe skill first.
Use this exact format with durations and percentages:
## By Application
- List each app with duration and percentage, sorted by time (e.g. "VS Code: 2h 15min (28%)")
## By Category
- Group into: coding, meetings, browsing, writing, communication, other
- Show hours and percentage per category
## By Project
- Group related activities by project/topic. Name specific repos or tasks.
## Productivity Score
- Calculate: focused_work_hours / total_hours as a percentage
- Focused = coding + writing. Unfocused = browsing + switching.
End with: "**Suggestion:** [one specific change to improve tomorrow's productivity]"
=== /volume1/screenpipe/pipes/video-export/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Export Video Clip
description: "Create a video of your recent screen activity"
icon: "🎬"
featured: false
---
Export a video of my screen activity from the last 5 minutes.
Read screenpipe skill first.
Use the POST /frames/export endpoint with the time range and fps=1.0. Then show me the exported video file path as an inline code block so I can watch it.
If the export is large, suggest a lower fps or shorter time range.
Thinking
Thinking
Now I have a clear picture. The pipes are markdown prompt templates in
/volume1/screenpipe/pipes/
, but there's no code to actually load and run them —
consumers/summary.py
has its own hardcoded prompts instead.
Here's what I'll implement:
consumers/pipes.py
— dynamically loads pipe.md files and runs them via Claude (data injected as system message, pipe body as user prompt)
main.py
— two new endpoints:
GET /api/pipes
and
POST /api/pipes/{pipe_id}/run
cli.py
— a
pipe
command to run pipes from the terminal
Let me build it:
Bash
Check browser_urls signature
IN
cat /volume1/screenpipe/app/consumers/activity.py | grep "def browser_urls" -A 5
Copy code to clipboard
OUT
def browser_urls(
for_date: date | None = None,
app_name: str | None = None,
ts_from: str | None = None,
ts_to: str | None = None,
limit: int = 30,
Write
pipes.py
pipes.py
143 lines
"""Dynamic pipe loader and runner."""
import os
import re
from datetime import date
from pathlib import Path
from typing import Any
def _parse_frontmatter(text: str) -> tuple[dict, str]:
if not text.startswith("---"):
return {}, text
try:
end = text.index("---", 3)
except ValueError:
return {}, text
fm_text = text[3:end].strip()
body = text[end + 3:].strip()
meta: dict = {}
for line in fm_text.splitlines():
if ":" in line:
k, _, v = line.partition(":")
meta[k.strip()] = v.strip().strip('"')
return meta, body
def load_pipes(pipes_dir: Path) -> list[dict]:
if not pipes_dir.exists():
return []
pipes = []
for pipe_dir in sorted(pipes_dir.iterdir()):
if not pipe_dir.is_dir() or pipe_dir.name.startswith("."):
continue
pipe_md = pipe_dir / "pipe.md"
if not pipe_md.exists():
continue
text = pipe_md.read_text(encoding="utf-8")
meta, body = _parse_frontmatter(text)
if meta.get("enabled", "true").lower() == "false":
continue
body = re.sub(r"Read screenpipe skill first\.?\n?", "", body).strip()
pipes.append({
"id": pipe_dir.name,
"title": meta.get("title", pipe_dir.name),
"description": meta.get("description", ""),
"icon": meta.get("icon", ""),
"schedule": meta.get("schedule", "manual"),
"featured": meta.get("featured", "false").lower() == "true",
"prompt": body,
})
return pipes
def _build_system(d: date, stats: dict) -> str:
from consumers.activity import app_time, browser_urls, ui_event_summary
from consumers.ocr import deduplicated_text
from consumers.audio import formatted_transcript
apps = app_time(d)
app_lines = "\n".join(f"- {a['app_name']}: {a['minutes']} min" for a in apps[:20])
urls = browser_urls(d, limit=20)
url_lines = "\n".join(f"- {u['browser_url'][:100]} ({u['minutes']} min)" for u in urls)
ui_rows = ui_event_summary(d)
ui_lines = "\n".join(
f"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches"
for r in ui_rows[:15]
)
ocr_rows = deduplicated_text(d, chunk_minutes=5)
ocr_lines = "\n".join(
f"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}"
for r in ocr_rows[:100]
)
audio = formatted_transcript(d)
if len(audio) > 3000:
audio = audio[:3000]
return f"""You are analyzing screenpipe data — recordings of a person's computer activity.
## App usage (minutes per app):
{app_lines or '(no app data)'}
## Browser URLs visited:
{url_lines or '(no browser data)'}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_lines or '(no UI event data)'}
## Screen content (sampled every 5 minutes):
{ocr_lines or '(no screen data)'}
## Audio / speech:
{audio or '(no audio data)'}
Date: {d}
Total frames recorded: {stats['total_frames']}"""
def run_pipe(
pipe_id: str,
for_date: date | None = None,
api_key: str | None = None,
pipes_dir: Path | None = None,
) -> dict[str, Any]:
import anthropic
from consumers.activity import summary_stats
d = for_date or date.today()
key = api_key or os.environ.get("ANTHROPIC_API_KEY", "")
if not key:
return {"title": "Error", "content": "ANTHROPIC_API_KEY not set.", "date": str(d)}
_pipes_dir = pipes_dir or Path(os.environ.get("PIPES_DIR", "/data/pipes"))
all_pipes = {p["id"]: p for p in load_pipes(_pipes_dir)}
if pipe_id not in all_pipes:
return {"title": "Error", "content": f"Pipe not found: {pipe_id}", "date": str(d)}
pipe = all_pipes[pipe_id]
stats = summary_stats(d)
if stats["total_frames"] == 0:
return {"title": pipe["title"], "content": f"No screen data found for {d}.", "date": str(d)}
system = _build_system(d, stats)
client = anthropic.Anthropic(api_key=key)
message = client.messages.create(
model="claude-haiku-4-5-20251001",
max_tokens=1024,
system=system,
messages=[{"role": "user", "content": pipe["prompt"]}],
)
return {
"title": pipe["title"],
"content": message.content[0].text,
"date": str(d),
"stats": stats,
}
Now add the API endpoints to
main.py
:
Edit
main.py
main.py
Added 1 line
Edit
main.py
main.py
Added 1 line...
|
NULL
|
NULL
|
NULL
|
NULL
|
|
21406
|
937
|
21
|
2026-05-11T17:48:18.283101+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-11/1778 /Users/lukas/.screenpipe/data/data/2026-05-11/1778521698283_m2.jpg...
|
Code
|
screenpipe_sync.sh — screenpipe [SSH: nas]
|
1
|
NULL
|
monitor_2
|
NULL
|
NULL
|
NULL
|
NULL
|
Explorer (⇧⌘E) - 1 unsaved file
1
Search (⇧⌘F)
Explorer (⇧⌘E) - 1 unsaved file
1
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py
M
db.py
docker-compose.yml
Dockerfile
M
main.py
M
requirements.txt
M
data
logs
pipes
.gitignore
app_settings.json
archive.db
archive.db-bak
U
db.sqlite
db.sqlite-shm
db.sqlite-wal
screenpipe_sync_updated.sh
U
screenpipe_sync.sh
screenpipe.db
Outline Section
OUTLINE
OUTLINE
Timeline Section
TIMELINE
TIMELINE
app_settings.json, Editor Group 1
screenpipe_sync.sh, Editor Group 1
screenpipe_sync_updated.sh, preview, Editor Group 1
pipe.md, Editor Group 1
.env, Editor Group 1
# the source currently has; INSERT OR IGNORE handles the duplicate case.
run_sqlite_heredoc "speakers ($SRC_SPEAKERS rows, all-time)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.speakers ($SPEAKERS_COLS, install_id)
SELECT $SPEAKERS_COLS, '$INSTALL_ID' FROM main.speakers;
DETACH nas;
"
run_sqlite_heredoc "speaker_embeddings ($SRC_SEMB rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.speaker_embeddings ($SEMB_COLS, install_id)
SELECT $SEMB_COLS, '$INSTALL_ID' FROM main.speaker_embeddings;
DETACH nas;
"
run_sqlite_heredoc "audio_chunks ($SRC_ACHUNKS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.audio_chunks ($ACHUNKS_COLS, install_id)
SELECT $ACHUNKS_COLS, '$INSTALL_ID' FROM main.audio_chunks WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "audio_transcriptions ($SRC_ATRANS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.audio_transcriptions ($ATRANS_COLS, install_id)
SELECT $ATRANS_COLS_T, '$INSTALL_ID' FROM main.audio_transcriptions t
JOIN main.audio_chunks c ON t.audio_chunk_id = c.id
WHERE date(c.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "audio_tags ($SRC_ATAGS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.audio_tags ($ATAGS_COLS, install_id)
SELECT $ATAGS_COLS_AT, '$INSTALL_ID' FROM main.audio_tags at
JOIN main.audio_chunks c ON at.audio_chunk_id = c.id
WHERE date(c.timestamp) = '$TARGET_DATE';
DETACH nas;
"
# ─── FTS UPDATE ───────────────────────────────────────────────────────────
step "Updating FTS indexes"
run_sqlite_heredoc "elements_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.elements_fts(rowid, text, role)
SELECT e.id, e.text, e.role
FROM nas.elements e
JOIN nas.frames f ON e.frame_id = f.id AND e.install_id = f.install_id
WHERE date(f.timestamp) = '$TARGET_DATE'
AND e.install_id = '$INSTALL_ID'
AND e.text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "frames_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)
SELECT id, full_text, app_name, window_name, browser_url, id
FROM nas.frames
WHERE date(timestamp) = '$TARGET_DATE'
AND install_id = '$INSTALL_ID'
AND full_text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "ui_events_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)
SELECT id, text_content, app_name, window_title, element_name
FROM nas.ui_events
WHERE date(timestamp) = '$TARGET_DATE'
AND install_id = '$INSTALL_ID'
AND text_content IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "audio_transcriptions_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.audio_transcriptions_fts(rowid, transcription, device, speaker_id, id)
SELECT t.id, t.transcription, COALESCE(t.device,''), t.speaker_id, t.id
FROM nas.audio_transcriptions t
JOIN nas.audio_chunks c ON t.audio_chunk_id = c.id AND t.install_id = c.install_id
WHERE date(c.timestamp) = '$TARGET_DATE'
AND t.install_id = '$INSTALL_ID'
AND t.transcription IS NOT NULL AND t.transcription != '';
DETACH nas;
"
# ─── VERIFY ───────────────────────────────────────────────────────────────
step "Verifying DB"
V_FRAMES=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID';")
V_ELEMENTS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM elements WHERE install_id='$INSTALL_ID' AND frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID');")
V_UI=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID';")
V_OCR=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ocr_text WHERE install_id='$INSTALL_ID' AND frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID');")
V_MEETINGS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE' AND install_id='$INSTALL_ID';")
V_ACHUNKS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM audio_chunks WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID';")
V_ATRANS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM audio_transcriptions WHERE install_id='$INSTALL_ID' AND audio_chunk_id IN (SELECT id FROM audio_chunks WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID');")
V_ATAGS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM audio_tags WHERE install_id='$INSTALL_ID' AND audio_chunk_id IN (SELECT id FROM audio_chunks WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID');")
check "frames" "$V_FRAMES" "$SRC_FRAMES"
check "elements" "$V_ELEMENTS" "$SRC_ELEMENTS"
check "ui_events" "$V_UI" "$SRC_UI"
check "ocr_text" "$V_OCR" "$SRC_OCR"
check "meetings" "$V_MEETINGS" "$SRC_MEETINGS"
check "audio_chunks" "$V_ACHUNKS" "$SRC_ACHUNKS"
check "audio_transcriptions" "$V_ATRANS" "$SRC_ATRANS"
check "audio_tags" "$V_ATAGS" "$SRC_ATAGS"
fi
# ─── COPY FRAME DATA FOLDER ──────────────────────────────────────────────────
# Always runs regardless of DB sync status.
step "Copying frame data folder for $TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
mkdir -p "$NAS_DATA/$TARGET_DATE"
RSYNC_START=$(date +%s)
printf " %-36s " "rsync frames → NAS"
rsync -a --ignore-existing "$DATA_SRC/" "$NAS_DATA/$TARGET_DATE/" 2>>"$LOG_FILE"
RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))
COPIED_FILES=$(ls "$NAS_DATA/$TARGET_DATE" 2>/dev/null | grep -v '^audio$' | wc -l | tr -d ' ')
SRC_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
COPIED_SIZE=$(du -sh "$NAS_DATA/$TARGET_DATE" | cut -f1)
if [ "$COPIED_FILES" -ge "$SRC_FILES" ]; then
printf "\r %-36s ✓ %dm%02ds (%s files, %s)\n" \
"rsync frames → NAS" \
"$(( RSYNC_DUR / 60 ))" "$(( RSYNC_DUR % 60 ))" \
"$COPIED_FILES" "$COPIED_SIZE" | tee -a "$LOG_FILE"
else
printf "\r %-36s ✗ %s / %s files\n" \
"rsync frames → NAS" "$COPIED_FILES" "$SRC_FILES" | tee -a "$LOG_FILE"
fi
else
printf " %-36s %s\n" "rsync frames → NAS" "skipped (no source dir)"
fi
# ─── COPY AUDIO FILES ────────────────────────────────────────────────────────
# Audio is flat in ~/.screenpipe/data/ with the date in the filename, e.g.
# System Audio (output)_2026-05-11_13-48-12.mp4
# soundcore AeroClip (input)_2026-05-10_11-10-32.mp4
# Mirrored to $NAS_DATA/<date>/audio/ so each day's archive is self-contained.
step "Copying audio files for $TARGET_DATE"
shopt -s nullglob
AUDIO_FILES=( "$HOME/.screenpipe/data/"*_"${TARGET_DATE}"_*.mp4 )
shopt -u nullglob
if [ ${#AUDIO_FILES[@]} -gt 0 ]; then
mkdir -p "$NAS_DATA/$TARGET_DATE/audio"
RSYNC_START=$(date +%s)
printf " %-36s " "rsync audio → NAS"
rsync -a --ignore-existing "${AUDIO_FILES[@]}" "$NAS_DATA/$TARGET_DATE/audio/" 2>>"$LOG_FILE"
RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))
COPIED_AUDIO=$(ls "$NAS_DATA/$TARGET_DATE/audio" | wc -l | tr -d ' ')
AUDIO_SIZE=$(du -sh "$NAS_DATA/$TARGET_DATE/audio" | cut -f1)
printf "\r %-36s ✓ %dm%02ds (%s files, %s)\n" \
"rsync audio → NAS" \
"$(( RSYNC_DUR / 60 ))" "$(( RSYNC_DUR % 60 ))" \
"$COPIED_AUDIO" "$AUDIO_SIZE" | tee -a "$LOG_FILE"
else
printf " %-36s %s\n" "rsync audio → NAS" "skipped (no audio for date)"
fi
# ─── COPY LOGS ────────────────────────────────────────────────────────────────
step "Copying screenpipe logs for $TARGET_DATE"
NAS_LOGS="$NAS_MOUNT/logs"
mkdir -p "$NAS_LOGS"
shopt -s nullglob
LOG_FILES=( "$HOME/.screenpipe/screenpipe.$TARGET_DATE."*.log )
shopt -u nullglob
if [ ${#LOG_FILES[@]} -gt 0 ]; then
printf " %-36s " "rsync logs → NAS"
rsync -a "${LOG_FILES[@]}" "$NAS_LOGS/" 2>>"$LOG_FILE"
TOTAL_SIZE=$(du -ch "${LOG_FILES[@]}" | tail -1 | cut -f1)
printf "✓ %d file(s), %s\n" "${#LOG_FILES[@]}" "$TOTAL_SIZE" | tee -a "$LOG_FILE"
else
printf " %-36s %s\n" "rsync logs → NAS" "skipped (no matching logs)"
fi
# ─── SUMMARY ──────────────────────────────────────────────────────────────────
TOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))
DB_SIZE=$(du -sh "$NAS_DB" | cut -f1)
echo ""
log "Archive DB size: $DB_SIZE"
log "Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s"
log "Sync complete for $TARGET_DATE (install $INSTALL_ID)"
log "========================================"
rsync -a "$HOME/.screenpipe/sync.log" "$NAS_LOGS/sync.log" 2>/dev/null || true
# the source currently has; INSERT OR IGNORE handles the duplicate case.
run_sqlite_heredoc "speakers ($SRC_SPEAKERS rows, all-time)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.speakers ($SPEAKERS_COLS, install_id)
SELECT $SPEAKERS_COLS, '$INSTALL_ID' FROM main.speakers;
DETACH nas;
"
run_sqlite_heredoc "speaker_embeddings ($SRC_SEMB rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.speaker_embeddings ($SEMB_COLS, install_id)
SELECT $SEMB_COLS, '$INSTALL_ID' FROM main.speaker_embeddings;
DETACH nas;
"
run_sqlite_heredoc "audio_chunks ($SRC_ACHUNKS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.audio_chunks ($ACHUNKS_COLS, install_id)
SELECT $ACHUNKS_COLS, '$INSTALL_ID' FROM main.audio_chunks WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "audio_transcriptions ($SRC_ATRANS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.audio_transcriptions ($ATRANS_COLS, install_id)
SELECT $ATRANS_COLS_T, '$INSTALL_ID' FROM main.audio_transcriptions t
JOIN main.audio_chunks c ON t.audio_chunk_id = c.id
WHERE date(c.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "audio_tags ($SRC_ATAGS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.audio_tags ($ATAGS_COLS, install_id)
SELECT $ATAGS_COLS_AT, '$INSTALL_ID' FROM main.audio_tags at
JOIN main.audio_chunks c ON at.audio_chunk_id = c.id
WHERE date(c.timestamp) = '$TARGET_DATE';
DETACH nas;
"
# ─── FTS UPDATE ───────────────────────────────────────────────────────────
step "Updating FTS indexes"
run_sqlite_heredoc "elements_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.elements_fts(rowid, text, role)
SELECT e.id, e.text, e.role
FROM nas.elements e
JOIN nas.frames f ON e.frame_id = f.id AND e.install_id = f.install_id
WHERE date(f.timestamp) = '$TARGET_DATE'
AND e.install_id = '$INSTALL_ID'
AND e.text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "frames_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)
SELECT id, full_text, app_name, window_name, browser_url, id
FROM nas.frames
WHERE date(timestamp) = '$TARGET_DATE'
AND install_id = '$INSTALL_ID'
AND full_text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "ui_events_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)
SELECT id, text_content, app_name, window_title, element_name
FROM nas.ui_events
WHERE date(timestamp) = '$TARGET_DATE'
AND install_id = '$INSTALL_ID'
AND text_content IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "audio_transcriptions_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.audio_transcriptions_fts(rowid, transcription, device, speaker_id, id)
SELECT t.id, t.transcription, COALESCE(t.device,''), t.speaker_id, t.id
FROM nas.audio_transcriptions t
JOIN nas.audio_chunks c ON t.audio_chunk_id = c.id AND t.install_id = c.install_id
WHERE date(c.timestamp) = '$TARGET_DATE'
AND t.install_id = '$INSTALL_ID'
AND t.transcription IS NOT NULL AND t.transcription != '';
DETACH nas;
"
# ─── VERIFY ───────────────────────────────────────────────────────────────
step "Verifying DB"
V_FRAMES=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID';")
V_ELEMENTS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM elements WHERE install_id='$INSTALL_ID' AND frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID');")
V_UI=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID';")
V_OCR=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ocr_text WHERE install_id='$INSTALL_ID' AND frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID');")
V_MEETINGS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE' AND install_id='$INSTALL_ID';")
V_ACHUNKS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM audio_chunks WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID';")
V_ATRANS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM audio_transcriptions WHERE install_id='$INSTALL_ID' AND audio_chunk_id IN (SELECT id FROM audio_chunks WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID');")
V_ATAGS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM audio_tags WHERE install_id='$INSTALL_ID' AND audio_chunk_id IN (SELECT id FROM audio_chunks WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID');")
check "frames" "$V_FRAMES" "$SRC_FRAMES"
check "elements" "$V_ELEMENTS" "$SRC_ELEMENTS"
check "ui_events" "$V_UI" "$SRC_UI"
check "ocr_text" "$V_OCR" "$SRC_OCR"
check "meetings" "$V_MEETINGS" "$SRC_MEETINGS"
check "audio_chunks" "$V_ACHUNKS" "$SRC_ACHUNKS"
check "audio_transcriptions" "$V_ATRANS" "$SRC_ATRANS"
check "audio_tags" "$V_ATAGS" "$SRC_ATAGS"
fi
# ─── COPY FRAME DATA FOLDER ──────────────────────────────────────────────────
# Always runs regardless of DB sync status.
step "Copying frame data folder for $TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
mkdir -p "$NAS_DATA/$TARGET_DATE"
RSYNC_START=$(date +%s)
printf " %-36s " "rsync frames → NAS"
rsync -a --ignore-existing "$DATA_SRC/" "$NAS_DATA/$TARGET_DATE/" 2>>"$LOG_FILE"
RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))
COPIED_FILES=$(ls "$NAS_DATA/$TARGET_DATE" 2>/dev/null | grep -v '^audio$' | wc -l | tr -d ' ')
SRC_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
COPIED_SIZE=$(du -sh "$NAS_DATA/$TARGET_DATE" | cut -f1)
if [ "$COPIED_FILES" -ge "$SRC_FILES" ]; then
printf "\r %-36s ✓ %dm%02ds (%s files, %s)\n" \
"rsync frames → NAS" \
"$(( RSYNC_DUR / 60 ))" "$(( RSYNC_DUR % 60 ))" \
"$COPIED_FILES" "$COPIED_SIZE" | tee -a "$LOG_FILE"
else
printf "\r %-36s ✗ %s / %s files\n" \
"rsync frames → NAS" "$COPIED_FILES" "$SRC_FILES" | tee -a "$LOG_FILE"
fi
else
printf " %-36s %s\n" "rsync frames → NAS" "skipped (no source dir)"
fi
# ─── COPY AUDIO FILES ────────────────────────────────────────────────────────
# Audio is flat in ~/.screenpipe/data/ with the date in the filename, e.g.
# System Audio (output)_2026-05-11_13-48-12.mp4
# soundcore AeroClip (input)_2026-05-10_11-10-32.mp4
# Mirrored to $NAS_DATA/<date>/audio/ so each day's archive is self-contained.
step "Copying audio files for $TARGET_DATE"
shopt -s nullglob
AUDIO_FILES=( "$HOME/.screenpipe/data/"*_"${TARGET_DATE}"_*.mp4 )
shopt -u nullglob
if [ ${#AUDIO_FILES[@]} -gt 0 ]; then
mkdir -p "$NAS_DATA/$TARGET_DATE/audio"
RSYNC_START=$(date +%s)
printf " %-36s " "rsync audio → NAS"
rsync -a --ignore-existing "${AUDIO_FILES[@]}" "$NAS_DATA/$TARGET_DATE/audio/" 2>>"$LOG_FILE"
RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))
COPIED_AUDIO=$(ls "$NAS_DATA/$TARGET_DATE/audio" | wc -l | tr -d ' ')
AUDIO_SIZE=$(du -sh "$NAS_DATA/$TARGET_DATE/audio" | cut -f1)
printf "\r %-36s ✓ %dm%02ds (%s files, %s)\n" \
"rsync audio → NAS" \
"$(( RSYNC_DUR / 60 ))" "$(( RSYNC_DUR % 60 ))" \
"$COPIED_AUDIO" "$AUDIO_SIZE" | tee -a "$LOG_FILE"
else
printf " %-36s %s\n" "rsync audio → NAS" "skipped (no audio for date)"
fi
# ─── COPY LOGS ────────────────────────────────────────────────────────────────
step "Copying screenpipe logs for $TARGET_DATE"
NAS_LOGS="$NAS_MOUNT/logs"
mkdir -p "$NAS_LOGS"
shopt -s nullglob
LOG_FILES=( "$HOME/.screenpipe/screenpipe.$TARGET_DATE."*.log )
shopt -u nullglob
if [ ${#LOG_FILES[@]} -gt 0 ]; then
printf " %-36s " "rsync logs → NAS"
rsync -a "${LOG_FILES[@]}" "$NAS_LOGS/" 2>>"$LOG_FILE"
TOTAL_SIZE=$(du -ch "${LOG_FILES[@]}" | tail -1 | cut -f1)
printf "✓ %d file(s), %s\n" "${#LOG_FILES[@]}" "$TOTAL_SIZE" | tee -a "$LOG_FILE"
else
printf " %-36s %s\n" "rsync logs → NAS" "skipped (no matching logs)"
fi
# ─── SUMMARY ──────────────────────────────────────────────────────────────────
TOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))
DB_SIZE=$(du -sh "$NAS_DB" | cut -f1)
echo ""
log "Archive DB size: $DB_SIZE"
log "Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s"
log "Sync complete for $TARGET_DATE (install $INSTALL_ID)"
log "========================================"
rsync -a "$HOME/.screenpipe/sync.log" "$NAS_LOGS/sync.log" 2>/dev/null || true
Implement and run pipe l…, Editor Group 2
Problems (⇧⌘M)
PROBLEMS
Output (⇧⌘U)
OUTPUT
Debug Console (⇧⌘Y)
DEBUG CONSOLE
Terminal (⌃`)
TERMINAL
Ports - 1 forwarded port
PORTS
1
remote SSH: nas
SSH: nas
screenpipe (Git) - master*, Checkout Branch/Tag...
master*
screenpipe (Git) - Synchronize Changes
No Problems
0
0
Forwarded Ports: 8766
1
Notifications
Sign In
Sign In
Shell Script
Editor Language Status: Inline Suggestions, next: $(copilot) No inline suggestion available, Inline suggestions
LF
UTF-8
Spaces: 2
Ln 675, Col 1
git-commit Not Committed Yet
Not Committed Yet
No results found
Implement and run pipe logic
Session history
New session
Message actions
main.py
main.py
lets implement logic with pipes. how can I run it?
Thinking
Thinking
Let me look at the current project structure to understand what's already in place.
Bash
List project files
IN
find /volume1/screenpipe -type f | head -50 && echo "---" && ls /volume1/screenpipe
Copy code to clipboard
OUT
/volume1/screenpipe/.DS_Store
/volume1/screenpipe/screenpipe.db
/volume1/screenpipe/screenpipe_sync.sh
/volume1/screenpipe/app_settings.json
/volume1/screenpipe/.gitignore
/volume1/screenpipe/archive.db
/volume1/screenpipe/db.sqlite
/volume1/screenpipe/db.sqlite-wal
/volume1/screenpipe/db.sqlite-shm
/volume1/screenpipe/#recycle/desktop.ini
/volume1/screenpipe/#recycle/db.sqlite
/volume1/screenpipe/#recycle/Copy #1 of db.sqlite
/volume1/screenpipe/#recycle/.DS_Store
/volume1/screenpipe/#recycle/Copy #2 of db.sqlite
/volume1/screenpipe/#recycle/archive.db
/volume1/screenpipe/#recycle/Copy #1 of archive.db
/volume1/screenpipe/#recycle/Copy #2 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of archive.db
/volume1/screenpipe/#recycle/Copy #4 of archive.db
/volume1/screenpipe/#recycle/Copy #5 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of db.sqlite
/volume1/screenpipe/#recycle/Copy #4 of db.sqlite
/volume1/screenpipe/#recycle/Copy #6 of archive.db
/volume1/screenpipe/#recycle/test.txt
/volume1/screenpipe/#recycle/Copy #7 of archive.db
/volume1/screenpipe/#recycle/Copy #8 of archive.db
/volume1/screenpipe/#recycle/archive.db-journal
/volume1/screenpipe/#recycle/Copy #1 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #2 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #3 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #4 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #6 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #7 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of db.sqlite
/volume1/screenpipe/pipes/.DS_Store
/volume1/screenpipe/app/.env
/volume1/screenpipe/app/cli.py
/volume1/screenpipe/app/.DS_Store
/volume1/screenpipe/app/db.py
/volume1/screenpipe/app/docker-compose.yml
/volume1/screenpipe/app/main.py
/volume1/screenpipe/app/requirements.txt
/volume1/screenpipe/app/Dockerfile
/volume1/screenpipe/data/.DS_Store
/volume1/screenpipe/.git/description
/volume1/screenpipe/.git/HEAD
/volume1/screenpipe/.git/index
/volume1/screenpipe/.git/COMMIT_EDITMSG
/volume1/screenpipe/#recycle/data/.DS_Store
---
app
app_settings.json
archive.db
data
db.sqlite
db.sqlite-shm
db.sqlite-wal
pipes
#recycle
screenpipe.db
screenpipe_sync.sh
Read
main.py
main.py
Bash
Check pipes directory and docker-compose
IN
ls /volume1/screenpipe/pipes/ && ls /volume1/screenpipe/app/ && cat /volume1/screenpipe/app/docker-compose.yml
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
cli.py
consumers
db.py
docker-compose.yml
Dockerfile
main.py
__pycache__
requirements.txt
static
services:
screenpipe-app:
build: .
container_name: screenpipe-app
restart: unless-stopped
ports:
- "8766:8000"
volumes:
- /volume1/screenpipe:/data
env_file:
- .env
environment:
TZ: Europe/Sofia
DB_PATH: /data/db.sqlite
sqlite-web-archive:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-archive
restart: unless-stopped
ports:
- "8767:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/archive.db"]
sqlite-web-live:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-live
restart: unless-stopped
ports:
- "8768:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/db.sqlite"]
Read
requirements.txt
requirements.txt
Bash
Inspect a pipe directory
IN
ls /volume1/screenpipe/pipes/day-recap/ && cat /volume1/screenpipe/pipes/day-recap/pipe.json 2>/dev/null || ls /volume1/screenpipe/pipes/day-recap/
Copy code to clipboard
OUT
pipe.md
pipe.md
Read
cli.py
cli.py
Bash
List all pipes and their contents
IN
ls /volume1/screenpipe/pipes/ && for d in /volume1/screenpipe/pipes/*/; do echo "=== $d ==="; ls "$d"; done
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
=== /volume1/screenpipe/pipes/ai-habits/ ===
pipe.md
=== /volume1/screenpipe/pipes/day-recap/ ===
pipe.md
=== /volume1/screenpipe/pipes/meeting-summary/ ===
pipe.md
=== /volume1/screenpipe/pipes/standup-update/ ===
pipe.md
=== /volume1/screenpipe/pipes/time-breakdown/ ===
pipe.md
=== /volume1/screenpipe/pipes/video-export/ ===
pipe.md
Bash
Read pipe markdown files
IN
cat /volume1/screenpipe/pipes/day-recap/pipe.md && echo "===" && cat /volume1/screenpipe/pipes/meeting-summary/pipe.md 2>/dev/null | head -50
Copy code to clipboard
OUT
---
schedule: manual
enabled: true
template: true
title: Day Recap
description: "Today's accomplishments, key moments, and unfinished work"
icon: "📋"
featured: true
---
Analyze my screen and audio recordings from today (last 16 hours only).
Read screenpipe skill first.
Use this exact format:
## Summary
One sentence: what I mainly did today.
## Accomplishments
- Top 3 things I finished, with timestamps (e.g. "2:30 PM")
- Name specific apps, files, or projects
## Key Moments
- Important things I saw, said, or heard — with timestamps
## Unfinished Work
- What I should continue tomorrow — name the app/file/task
## Patterns
- Apps I used most, topics that came up repeatedly
Only report what you can verify from the data. End with: "**Next step:** [most important thing to continue]"
===
---
schedule: manual
enabled: true
template: true
title: Meeting Summary
description: "Summarize meeting transcript with key takeaways and action items"
icon: "🤝"
featured: false
---
Summarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.
Read screenpipe skill first.
Use this exact format:
## Meeting Summary
One sentence: what this meeting was about.
## Key Takeaways
- Top 3-5 important points discussed
- Include who said what when relevant
## Action Items
- [ ] Task — assigned to whom, deadline if mentioned
- [ ] Task — assigned to whom
## Decisions Made
- List any decisions or agreements reached
## Open Questions
- Anything unresolved or needing follow-up
Keep it concise and actionable.
Thinking
Thinking
Bash
Read summary consumer
IN
ls /volume1/screenpipe/app/consumers/ && cat /volume1/screenpipe/app/consumers/summary.py
Copy code to clipboard
OUT
activity.py
audio.py
elements.py
__init__.py
interactions.py
ocr.py
__pycache__
report.py
summary.py
"""AI summary generator using Claude."""
import os
from datetime import date
from typing import Any
from consumers.activity import app_time, summary_stats, browser_urls, ui_event_summary
from consumers.ocr import deduplicated_text
from consumers.audio import formatted_transcript
SUMMARY_TYPES = {
"day_recap": {
"title": "Day Recap",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
## Audio/speech:
{audio}
Write a concise day recap using EXACTLY this format:
## Summary
One sentence: what I mainly worked on today.
## Accomplishments
- Top 3 things I finished, with approximate times
- Name specific apps, files, or projects
## Key Moments
- Important things seen or heard, with timestamps
## Unfinished Work
- What to continue tomorrow
## Patterns
- Apps used most, topics that came up repeatedly
Only report what you can verify from the data. End with:
**Next step:** [most important thing to continue]""",
},
"standup": {
"title": "Standup Update",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
## Audio/speech:
{audio}
Write a brief standup update:
**Yesterday:** What I worked on (2-3 bullets)
**Today:** What I plan to continue (1-2 bullets)
**Blockers:** Any issues observed (or "None")
Keep it under 150 words. Only report what's verifiable from the data.""",
},
"focus_time": {
"title": "Focus & Distraction Analysis",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
Analyze focus vs distraction patterns:
## Deep Work Periods
- When and how long were sustained focus sessions?
- What was being worked on?
## Distractions
- Which apps/sites were used recreationally?
- How much time was lost to context switching?
## Recommendations
- 2-3 concrete suggestions to improve focus tomorrow
Be specific with times and app names.""",
},
}
def _build_context(for_date: date) -> dict[str, str]:
apps = app_time(for_date)
app_lines = "\n".join(f"- {a['app_name']}: {a['minutes']} min" for a in apps[:20])
urls = browser_urls(for_date, limit=20)
url_lines = "\n".join(
f"- {u['browser_url'][:100]} ({u['minutes']} min)" for u in urls
)
ui_rows = ui_event_summary(for_date)
ui_lines = "\n".join(
f"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches"
for r in ui_rows[:15]
)
ocr_rows = deduplicated_text(for_date, chunk_minutes=5)
ocr_lines = "\n".join(
f"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}"
for r in ocr_rows[:100]
)
audio = formatted_transcript(for_date)
return {
"app_time": app_lines or "(no app data)",
"browser_urls": url_lines or "(no browser data)",
"ui_events": ui_lines or "(no UI event data)",
"ocr_text": ocr_lines or "(no screen data)",
"audio": audio[:3000] if len(audio) > 3000 else audio,
}
def generate(
summary_type: str = "day_recap",
for_date: date | None = None,
api_key: str | None = None,
) -> dict[str, Any]:
"""Generate an AI summary. Returns dict with 'title', 'content', 'date'."""
import anthropic
d = for_date or date.today()
key = api_key or os.environ.get("ANTHROPIC_API_KEY", "")
if not key:
return {
"title": "Error",
"content": "ANTHROPIC_API_KEY not set. Add it to your .env file.",
"date": str(d),
}
spec = SUMMARY_TYPES.get(summary_type)
if not spec:
return {"title": "Error", "content": f"Unknown summary type: {summary_type}", "date": str(d)}
stats = summary_stats(d)
if stats["total_frames"] == 0:
return {
"title": spec["title"],
"content": f"No screen data found for {d}.",
"date": str(d),
}
ctx = _build_context(d)
prompt = spec["prompt"].format(**ctx)
client = anthropic.Anthropic(api_key=key)
message = client.messages.create(
model="claude-haiku-4-5-20251001",
max_tokens=1024,
messages=[{"role": "user", "content": prompt}],
)
return {
"title": spec["title"],
"content": message.content[0].text,
"date": str(d),
"stats": stats,
}
Thinking
Thinking
Bash
Read all pipe.md files
IN
for f in /volume1/screenpipe/pipes/*/pipe.md; do echo "=== $f ==="; cat "$f"; echo; done
Copy code to clipboard
OUT
=== /volume1/screenpipe/pipes/ai-habits/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: AI Habits
description: "How you use AI tools — patterns and insights"
icon: "🤖"
featured: true
---
Search my recordings from the last 24 hours for AI tool usage. Use app_name filter for each tool separately: ChatGPT, Claude, Copilot, Cursor, Gemini, Perplexity. Use limit=5 per search, max 6 searches total.
Read screenpipe skill first.
Use this exact format:
## AI Tools Used
- List each tool with approximate time spent (e.g. "Claude: ~45min")
## What I Used Them For
- For each tool: coding, writing, research, or brainstorming
## Usage Patterns
- Do I switch between tools? Use them in bursts or steadily?
## Effectiveness
- Which tool appeared alongside completed work vs. abandoned attempts
If no AI usage is found, say so clearly. End with: "**Tip:** [one suggestion to use AI tools more effectively]"
=== /volume1/screenpipe/pipes/day-recap/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Day Recap
description: "Today's accomplishments, key moments, and unfinished work"
icon: "📋"
featured: true
---
Analyze my screen and audio recordings from today (last 16 hours only).
Read screenpipe skill first.
Use this exact format:
## Summary
One sentence: what I mainly did today.
## Accomplishments
- Top 3 things I finished, with timestamps (e.g. "2:30 PM")
- Name specific apps, files, or projects
## Key Moments
- Important things I saw, said, or heard — with timestamps
## Unfinished Work
- What I should continue tomorrow — name the app/file/task
## Patterns
- Apps I used most, topics that came up repeatedly
Only report what you can verify from the data. End with: "**Next step:** [most important thing to continue]"
=== /volume1/screenpipe/pipes/meeting-summary/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Meeting Summary
description: "Summarize meeting transcript with key takeaways and action items"
icon: "🤝"
featured: false
---
Summarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.
Read screenpipe skill first.
Use this exact format:
## Meeting Summary
One sentence: what this meeting was about.
## Key Takeaways
- Top 3-5 important points discussed
- Include who said what when relevant
## Action Items
- [ ] Task — assigned to whom, deadline if mentioned
- [ ] Task — assigned to whom
## Decisions Made
- List any decisions or agreements reached
## Open Questions
- Anything unresolved or needing follow-up
Keep it concise and actionable.
=== /volume1/screenpipe/pipes/standup-update/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Standup Update
description: "What you did, what's next, and any blockers"
icon: "🏢"
featured: true
---
Based on my recordings from the last 24 hours, generate a standup update. Use limit=10 per search, max 3 searches total.
Read screenpipe skill first.
Use this exact format:
## Yesterday
- What I worked on (name specific projects, files, tools, PRs)
## Today
- What I will work on next (based on unfinished tasks and recent activity)
## Blockers
- Issues I hit — errors, slow builds, waiting on someone
- If no blockers, write "None"
Keep it under 150 words. Copy-paste ready for a team standup.
=== /volume1/screenpipe/pipes/time-breakdown/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Time Breakdown
description: "Where your time went — by app, project, and category"
icon: "⏱"
featured: false
---
Analyze my app usage from today (last 12 hours). Use limit=10 per search, max 4 searches. Prefer /raw_sql with COUNT/GROUP BY queries.
Read screenpipe skill first.
Use this exact format with durations and percentages:
## By Application
- List each app with duration and percentage, sorted by time (e.g. "VS Code: 2h 15min (28%)")
## By Category
- Group into: coding, meetings, browsing, writing, communication, other
- Show hours and percentage per category
## By Project
- Group related activities by project/topic. Name specific repos or tasks.
## Productivity Score
- Calculate: focused_work_hours / total_hours as a percentage
- Focused = coding + writing. Unfocused = browsing + switching.
End with: "**Suggestion:** [one specific change to improve tomorrow's productivity]"
=== /volume1/screenpipe/pipes/video-export/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Export Video Clip
description: "Create a video of your recent screen activity"
icon: "🎬"
featured: false
---
Export a video of my screen activity from the last 5 minutes.
Read screenpipe skill first.
Use the POST /frames/export endpoint with the time range and fps=1.0. Then show me the exported video file path as an inline code block so I can watch it.
If the export is large, suggest a lower fps or shorter time range.
Thinking
Thinking
Now I have a clear picture. The pipes are markdown prompt templates in
/volume1/screenpipe/pipes/
, but there's no code to actually load and run them —
consumers/summary.py
has its own hardcoded prompts instead.
Here's what I'll implement:
consumers/pipes.py
— dynamically loads pipe.md files and runs them via Claude (data injected as system message, pipe body as user prompt)
main.py
— two new endpoints:
GET /api/pipes
and
POST /api/pipes/{pipe_id}/run
cli.py
— a
pipe
command to run pipes from the terminal
Let me build it:
Bash
Check browser_urls signature
IN
cat /volume1/screenpipe/app/consumers/activity.py | grep "def browser_urls" -A 5
Copy code to clipboard
OUT
def browser_urls(
for_date: date | None = None,
app_name: str | None = None,
ts_from: str | None = None,
ts_to: str | None = None,
limit: int = 30,
Write
pipes.py
pipes.py
143 lines
"""Dynamic pipe loader and runner."""
import os
import re
from datetime import date
from pathlib import Path
from typing import Any
def _parse_frontmatter(text: str) -> tuple[dict, str]:
if not text.startswith("---"):
return {}, text
try:
end = text.index("---", 3)
except ValueError:
return {}, text
fm_text = text[3:end].strip()
body = text[end + 3:].strip()
meta: dict = {}
for line in fm_text.splitlines():
if ":" in line:
k, _, v = line.partition(":")
meta[k.strip()] = v.strip().strip('"')
return meta, body
def load_pipes(pipes_dir: Path) -> list[dict]:
if not pipes_dir.exists():
return []
pipes = []
for pipe_dir in sorted(pipes_dir.iterdir()):
if not pipe_dir.is_dir() or pipe_dir.name.startswith("."):
continue
pipe_md = pipe_dir / "pipe.md"
if not pipe_md.exists():
continue
text = pipe_md.read_text(encoding="utf-8")
meta, body = _parse_frontmatter(text)
if meta.get("enabled", "true").lower() == "false":
continue
body = re.sub(r"Read screenpipe skill first\.?\n?", "", body).strip()
pipes.append({
"id": pipe_dir.name,
"title": meta.get("title", pipe_dir.name),
"description": meta.get("description", ""),
"icon": meta.get("icon", ""),
"schedule": meta.get("schedule", "manual"),
"featured": meta.get("featured", "false").lower() == "true",
"prompt": body,
})
return pipes
def _build_system(d: date, stats: dict) -> str:
from consumers.activity import app_time, browser_urls, ui_event_summary
from consumers.ocr import deduplicated_text
from consumers.audio import formatted_transcript
apps = app_time(d)
app_lines = "\n".join(f"- {a['app_name']}: {a['minutes']} min" for a in apps[:20])
urls = browser_urls(d, limit=20)
url_lines = "\n".join(f"- {u['browser_url'][:100]} ({u['minutes']} min)" for u in urls)
ui_rows = ui_event_summary(d)
ui_lines = "\n".join(
f"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches"
for r in ui_rows[:15]
)
ocr_rows = deduplicated_text(d, chunk_minutes=5)
ocr_lines = "\n".join(
f"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}"
for r in ocr_rows[:100]
)
audio = formatted_transcript(d)
if len(audio) > 3000:
audio = audio[:3000]
return f"""You are analyzing screenpipe data — recordings of a person's computer activity.
## App usage (minutes per app):
{app_lines or '(no app data)'}
## Browser URLs visited:
{url_lines or '(no browser data)'}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_lines or '(no UI event data)'}
## Screen content (sampled every 5 minutes):
{ocr_lines or '(no screen data)'}
## Audio / speech:
{audio or '(no audio data)'}
Date: {d}
Total frames recorded: {stats['total_frames']}"""
def run_pipe(
pipe_id: str,
for_date: date | None = None,
api_key: str | None = None,
pipes_dir: Path | None = None,
) -> dict[str, Any]:
import anthropic
from consumers.activity import summary_stats
d = for_date or date.today()
key = api_key or os.environ.get("ANTHROPIC_API_KEY", "")
if not key:
return {"title": "Error", "content": "ANTHROPIC_API_KEY not set.", "date": str(d)}
_pipes_dir = pipes_dir or Path(os.environ.get("PIPES_DIR", "/data/pipes"))
all_pipes = {p["id"]: p for p in load_pipes(_pipes_dir)}
if pipe_id not in all_pipes:
return {"title": "Error", "content": f"Pipe not found: {pipe_id}", "date": str(d)}
pipe = all_pipes[pipe_id]
stats = summary_stats(d)
if stats["total_frames"] == 0:
return {"title": pipe["title"], "content": f"No screen data found for {d}.", "date": str(d)}
system = _build_system(d, stats)
client = anthropic.Anthropic(api_key=key)
message = client.messages.create(
model="claude-haiku-4-5-20251001",
max_tokens=1024,
system=system,
messages=[{"role": "user", "content": pipe["prompt"]}],
)
return {
"title": pipe["title"],
"content": message.content[0].text,
"date": str(d),
"stats": stats,
}
Now add the API endpoints to
main.py
:...
|
[{"role":"AXRadioButton","text [{"role":"AXRadioButton","text":"Explorer (⇧⌘E) - 1 unsaved file","depth":19,"bounds":{"left":0.0,"top":0.047885075,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":true},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.057462092,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":22,"bounds":{"left":0.009640957,"top":0.06863528,"width":0.0016622341,"height":0.008778931},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Search (⇧⌘F)","depth":19,"bounds":{"left":0.0,"top":0.08619314,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.09577015,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Source Control (⌃⇧G) - 10 pending changes","depth":19,"bounds":{"left":0.0,"top":0.1245012,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.13407822,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"10","depth":22,"bounds":{"left":0.00831117,"top":0.1452514,"width":0.003656915,"height":0.008778931},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.00831117,"top":0.14604948,"width":0.0016622341,"height":0.007980846}},{"char_start":1,"char_count":1,"bounds":{"left":0.009973404,"top":0.14604948,"width":0.0023271276,"height":0.007980846}}],"role_description":"text"},{"role":"AXRadioButton","text":"Run and Debug (⇧⌘D)","depth":19,"bounds":{"left":0.0,"top":0.16280925,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.17238627,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Remote Explorer","depth":19,"bounds":{"left":0.0,"top":0.20111732,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.21069433,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Extensions (⇧⌘X) - 2 require update","depth":19,"bounds":{"left":0.0,"top":0.23942538,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"bounds":{"left":0.0039893617,"top":0.2490024,"width":0.007978723,"height":0.01915403},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"2","depth":22,"bounds":{"left":0.009640957,"top":0.2601756,"width":0.0019946808,"height":0.008778931},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Claude Code","depth":19,"bounds":{"left":0.0,"top":0.27773345,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"Containers","depth":19,"bounds":{"left":0.0,"top":0.3160415,"width":0.015957447,"height":0.03830806},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXHeading","text":"EXPLORER","depth":17,"bounds":{"left":0.022606382,"top":0.047885075,"width":0.018949468,"height":0.02793296},"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"EXPLORER","depth":18,"bounds":{"left":0.022606382,"top":0.056664005,"width":0.018949468,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.022606382,"top":0.056664005,"width":0.0023271276,"height":0.0103751}},{"char_start":1,"char_count":7,"bounds":{"left":0.024933511,"top":0.056664005,"width":0.01662234,"height":0.0103751}}],"role_description":"text"},{"role":"AXButton","text":"Explorer Section: screenpipe [SSH: nas]","depth":21,"bounds":{"left":0.015957447,"top":0.07581804,"width":0.09940159,"height":0.017557861},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":true},{"role":"AXStaticText","text":"","depth":23,"bounds":{"left":0.01662234,"top":0.07821229,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"Explorer Section: screenpipe [SSH: nas]","depth":22,"bounds":{"left":0.022606382,"top":0.07581804,"width":0.045877658,"height":0.017557861},"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"SCREENPIPE [SSH: NAS]","depth":23,"bounds":{"left":0.022606382,"top":0.079010375,"width":0.045877658,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.022606382,"top":0.07980846,"width":0.0026595744,"height":0.0103751}},{"char_start":1,"char_count":20,"bounds":{"left":0.025265958,"top":0.07980846,"width":0.043218084,"height":0.0103751}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.09577015,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"#recycle","depth":27,"bounds":{"left":0.025930852,"top":0.09577015,"width":0.017287234,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.096568234,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":7,"bounds":{"left":0.028590426,"top":0.096568234,"width":0.01462766,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.11332801,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"app","depth":27,"bounds":{"left":0.025930852,"top":0.11332801,"width":0.0076462766,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.11412609,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":2,"bounds":{"left":0.02825798,"top":0.11412609,"width":0.005319149,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.11412609,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.022273935,"top":0.13088587,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"__pycache__","depth":27,"bounds":{"left":0.028590426,"top":0.13088587,"width":0.026595745,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.13168396,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":10,"bounds":{"left":0.030917553,"top":0.13168396,"width":0.024268618,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.022273935,"top":0.14844373,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"consumers","depth":27,"bounds":{"left":0.028590426,"top":0.14844373,"width":0.022273935,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.14924182,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":8,"bounds":{"left":0.030917553,"top":0.14924182,"width":0.019946808,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.14924182,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.022273935,"top":0.1660016,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"static","depth":27,"bounds":{"left":0.028590426,"top":0.1660016,"width":0.010970744,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.16679968,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":5,"bounds":{"left":0.030917553,"top":0.16679968,"width":0.008976064,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.16679968,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.1819633,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":".env","depth":27,"bounds":{"left":0.028590426,"top":0.18355946,"width":0.00831117,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.18435754,"width":0.0013297872,"height":0.011971269}},{"char_start":1,"char_count":3,"bounds":{"left":0.029920213,"top":0.18435754,"width":0.006981383,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.19952115,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"cli.py","depth":27,"bounds":{"left":0.028590426,"top":0.20111732,"width":0.010638298,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.2019154,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":5,"bounds":{"left":0.030917553,"top":0.2019154,"width":0.00831117,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.2019154,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.21707901,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.py","depth":27,"bounds":{"left":0.028590426,"top":0.21867518,"width":0.011303191,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.21947326,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":4,"bounds":{"left":0.03125,"top":0.21947326,"width":0.008643617,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.23463687,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"docker-compose.yml","depth":27,"bounds":{"left":0.028590426,"top":0.23623304,"width":0.042220745,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.23703113,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":17,"bounds":{"left":0.03125,"top":0.23703113,"width":0.03956117,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.25219473,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Dockerfile","depth":27,"bounds":{"left":0.028590426,"top":0.25379092,"width":0.020611702,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.254589,"width":0.0033244682,"height":0.011971269}},{"char_start":1,"char_count":9,"bounds":{"left":0.031914894,"top":0.254589,"width":0.017287234,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.254589,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.2697526,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"main.py","depth":27,"bounds":{"left":0.028590426,"top":0.27134877,"width":0.015625,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.27214685,"width":0.003656915,"height":0.011971269}},{"char_start":1,"char_count":6,"bounds":{"left":0.032247342,"top":0.27214685,"width":0.012300532,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.27214685,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.021276595,"top":0.28731045,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"requirements.txt","depth":27,"bounds":{"left":0.028590426,"top":0.28890663,"width":0.032912236,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.028590426,"top":0.2897047,"width":0.0016622341,"height":0.011971269}},{"char_start":1,"char_count":15,"bounds":{"left":0.03025266,"top":0.2897047,"width":0.03158245,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"M","depth":27,"bounds":{"left":0.10638298,"top":0.2897047,"width":0.003656915,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.3064645,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"data","depth":27,"bounds":{"left":0.025930852,"top":0.3064645,"width":0.008976064,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.30726257,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":3,"bounds":{"left":0.028590426,"top":0.30726257,"width":0.0063164895,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.32402235,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"logs","depth":27,"bounds":{"left":0.025930852,"top":0.32402235,"width":0.00831117,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.32482043,"width":0.0009973404,"height":0.011971269}},{"char_start":1,"char_count":3,"bounds":{"left":0.026928192,"top":0.32482043,"width":0.0076462766,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.10605053,"top":0.32482043,"width":0.004654255,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":26,"bounds":{"left":0.019614361,"top":0.3415802,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"pipes","depth":27,"bounds":{"left":0.025930852,"top":0.3415802,"width":0.010970744,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.3423783,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":4,"bounds":{"left":0.028590426,"top":0.3423783,"width":0.00831117,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.3575419,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":".gitignore","depth":27,"bounds":{"left":0.025930852,"top":0.35913807,"width":0.018949468,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.35993615,"width":0.0013297872,"height":0.011971269}},{"char_start":1,"char_count":9,"bounds":{"left":0.027260639,"top":0.35993615,"width":0.017952127,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.37509975,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"app_settings.json","depth":27,"bounds":{"left":0.025930852,"top":0.37669593,"width":0.03557181,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.377494,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":16,"bounds":{"left":0.02825798,"top":0.377494,"width":0.03324468,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.3926576,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"archive.db","depth":27,"bounds":{"left":0.025930852,"top":0.3942538,"width":0.020944148,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.39505187,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":9,"bounds":{"left":0.02825798,"top":0.39505187,"width":0.01861702,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.4102155,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"archive.db-bak","depth":27,"bounds":{"left":0.025930852,"top":0.41181165,"width":0.03025266,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.41260973,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":13,"bounds":{"left":0.02825798,"top":0.41260973,"width":0.027925532,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"U","depth":27,"bounds":{"left":0.10704787,"top":0.41260973,"width":0.0029920214,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.42777336,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite","depth":27,"bounds":{"left":0.025930852,"top":0.4293695,"width":0.017287234,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.4301676,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":8,"bounds":{"left":0.028590426,"top":0.4301676,"width":0.014960106,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.44533122,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite-shm","depth":27,"bounds":{"left":0.025930852,"top":0.44692737,"width":0.027925532,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.44772545,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":12,"bounds":{"left":0.028590426,"top":0.44772545,"width":0.025265958,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.46288908,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"db.sqlite-wal","depth":27,"bounds":{"left":0.025930852,"top":0.46448523,"width":0.025930852,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.46528333,"width":0.0026595744,"height":0.011971269}},{"char_start":1,"char_count":12,"bounds":{"left":0.028590426,"top":0.46528333,"width":0.023603724,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.48044693,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe_sync_updated.sh","depth":27,"bounds":{"left":0.025930852,"top":0.4820431,"width":0.059175532,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.4828412,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":25,"bounds":{"left":0.02825798,"top":0.4828412,"width":0.056848403,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"U","depth":27,"bounds":{"left":0.10704787,"top":0.4828412,"width":0.0029920214,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.4980048,"width":0.0063164895,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe_sync.sh","depth":27,"bounds":{"left":0.025930852,"top":0.49960095,"width":0.039893616,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.50039905,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":17,"bounds":{"left":0.02825798,"top":0.50039905,"width":0.037898935,"height":0.011971269}}],"role_description":"text"},{"role":"AXStaticText","text":"","depth":27,"bounds":{"left":0.01861702,"top":0.51556265,"width":0.0076462766,"height":0.015163607},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"screenpipe.db","depth":27,"bounds":{"left":0.025930852,"top":0.5171588,"width":0.028590426,"height":0.011971269},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.025930852,"top":0.5179569,"width":0.0023271276,"height":0.011971269}},{"char_start":1,"char_count":12,"bounds":{"left":0.02825798,"top":0.5179569,"width":0.026595745,"height":0.011971269}}],"role_description":"text"},{"role":"AXButton","text":"Outline Section","depth":21,"bounds":{"left":0.015957447,"top":0.9473264,"width":0.09940159,"height":0.017557861},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":23,"bounds":{"left":0.01662234,"top":0.9497207,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"OUTLINE","depth":22,"bounds":{"left":0.022606382,"top":0.9473264,"width":0.01662234,"height":0.017557861},"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"OUTLINE","depth":23,"bounds":{"left":0.022606382,"top":0.95131683,"width":0.01662234,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.022606382,"top":0.95131683,"width":0.0029920214,"height":0.0103751}},{"char_start":1,"char_count":6,"bounds":{"left":0.025598405,"top":0.95131683,"width":0.013630319,"height":0.0103751}}],"role_description":"text"},{"role":"AXButton","text":"Timeline Section","depth":21,"bounds":{"left":0.015957447,"top":0.9648843,"width":0.09940159,"height":0.017557861},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":23,"bounds":{"left":0.01662234,"top":0.96727854,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXHeading","text":"TIMELINE","depth":22,"bounds":{"left":0.022606382,"top":0.9648843,"width":0.01761968,"height":0.017557861},"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"TIMELINE","depth":23,"bounds":{"left":0.022606382,"top":0.9688747,"width":0.01761968,"height":0.0103751},"on_screen":true,"lines":[{"char_start":0,"char_count":1,"bounds":{"left":0.022606382,"top":0.9688747,"width":0.0026595744,"height":0.0103751}},{"char_start":1,"char_count":7,"bounds":{"left":0.025265958,"top":0.9688747,"width":0.015292553,"height":0.0103751}}],"role_description":"text"},{"role":"AXRadioButton","text":"app_settings.json, Editor Group 1","depth":28,"bounds":{"left":0.11569149,"top":0.047885075,"width":0.055851065,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"screenpipe_sync.sh, Editor Group 1","depth":28,"bounds":{"left":0.17154256,"top":0.047885075,"width":0.06050532,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":false},{"role":"AXRadioButton","text":"screenpipe_sync_updated.sh, preview, Editor Group 1","depth":28,"bounds":{"left":0.23171543,"top":0.047885075,"width":0.08344415,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"pipe.md, Editor Group 1","depth":28,"bounds":{"left":0.3148271,"top":0.047885075,"width":0.040226065,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":".env, Editor Group 1","depth":28,"bounds":{"left":0.35472074,"top":0.047885075,"width":0.040226065,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXTextArea","text":"# the source currently has; INSERT OR IGNORE handles the duplicate case.\n run_sqlite_heredoc \"speakers ($SRC_SPEAKERS rows, all-time)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.speakers ($SPEAKERS_COLS, install_id)\n SELECT $SPEAKERS_COLS, '$INSTALL_ID' FROM main.speakers;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"speaker_embeddings ($SRC_SEMB rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.speaker_embeddings ($SEMB_COLS, install_id)\n SELECT $SEMB_COLS, '$INSTALL_ID' FROM main.speaker_embeddings;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"audio_chunks ($SRC_ACHUNKS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.audio_chunks ($ACHUNKS_COLS, install_id)\n SELECT $ACHUNKS_COLS, '$INSTALL_ID' FROM main.audio_chunks WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"audio_transcriptions ($SRC_ATRANS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.audio_transcriptions ($ATRANS_COLS, install_id)\n SELECT $ATRANS_COLS_T, '$INSTALL_ID' FROM main.audio_transcriptions t\n JOIN main.audio_chunks c ON t.audio_chunk_id = c.id\n WHERE date(c.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"audio_tags ($SRC_ATAGS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.audio_tags ($ATAGS_COLS, install_id)\n SELECT $ATAGS_COLS_AT, '$INSTALL_ID' FROM main.audio_tags at\n JOIN main.audio_chunks c ON at.audio_chunk_id = c.id\n WHERE date(c.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n # ─── FTS UPDATE ───────────────────────────────────────────────────────────\n step \"Updating FTS indexes\"\n\n run_sqlite_heredoc \"elements_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.elements_fts(rowid, text, role)\n SELECT e.id, e.text, e.role\n FROM nas.elements e\n JOIN nas.frames f ON e.frame_id = f.id AND e.install_id = f.install_id\n WHERE date(f.timestamp) = '$TARGET_DATE'\n AND e.install_id = '$INSTALL_ID'\n AND e.text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)\n SELECT id, full_text, app_name, window_name, browser_url, id\n FROM nas.frames\n WHERE date(timestamp) = '$TARGET_DATE'\n AND install_id = '$INSTALL_ID'\n AND full_text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)\n SELECT id, text_content, app_name, window_title, element_name\n FROM nas.ui_events\n WHERE date(timestamp) = '$TARGET_DATE'\n AND install_id = '$INSTALL_ID'\n AND text_content IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"audio_transcriptions_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.audio_transcriptions_fts(rowid, transcription, device, speaker_id, id)\n SELECT t.id, t.transcription, COALESCE(t.device,''), t.speaker_id, t.id\n FROM nas.audio_transcriptions t\n JOIN nas.audio_chunks c ON t.audio_chunk_id = c.id AND t.install_id = c.install_id\n WHERE date(c.timestamp) = '$TARGET_DATE'\n AND t.install_id = '$INSTALL_ID'\n AND t.transcription IS NOT NULL AND t.transcription != '';\nDETACH nas;\n\"\n\n # ─── VERIFY ───────────────────────────────────────────────────────────────\n step \"Verifying DB\"\n\n V_FRAMES=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID';\")\n V_ELEMENTS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM elements WHERE install_id='$INSTALL_ID' AND frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID');\")\n V_UI=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID';\")\n V_OCR=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ocr_text WHERE install_id='$INSTALL_ID' AND frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID');\")\n V_MEETINGS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE' AND install_id='$INSTALL_ID';\")\n V_ACHUNKS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM audio_chunks WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID';\")\n V_ATRANS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM audio_transcriptions WHERE install_id='$INSTALL_ID' AND audio_chunk_id IN (SELECT id FROM audio_chunks WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID');\")\n V_ATAGS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM audio_tags WHERE install_id='$INSTALL_ID' AND audio_chunk_id IN (SELECT id FROM audio_chunks WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID');\")\n\n check \"frames\" \"$V_FRAMES\" \"$SRC_FRAMES\"\n check \"elements\" \"$V_ELEMENTS\" \"$SRC_ELEMENTS\"\n check \"ui_events\" \"$V_UI\" \"$SRC_UI\"\n check \"ocr_text\" \"$V_OCR\" \"$SRC_OCR\"\n check \"meetings\" \"$V_MEETINGS\" \"$SRC_MEETINGS\"\n check \"audio_chunks\" \"$V_ACHUNKS\" \"$SRC_ACHUNKS\"\n check \"audio_transcriptions\" \"$V_ATRANS\" \"$SRC_ATRANS\"\n check \"audio_tags\" \"$V_ATAGS\" \"$SRC_ATAGS\"\n\nfi\n\n# ─── COPY FRAME DATA FOLDER ──────────────────────────────────────────────────\n# Always runs regardless of DB sync status.\nstep \"Copying frame data folder for $TARGET_DATE\"\n\nif [ -d \"$DATA_SRC\" ]; then\n mkdir -p \"$NAS_DATA/$TARGET_DATE\"\n RSYNC_START=$(date +%s)\n printf \" %-36s \" \"rsync frames → NAS\"\n rsync -a --ignore-existing \"$DATA_SRC/\" \"$NAS_DATA/$TARGET_DATE/\" 2>>\"$LOG_FILE\"\n RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))\n COPIED_FILES=$(ls \"$NAS_DATA/$TARGET_DATE\" 2>/dev/null | grep -v '^audio$' | wc -l | tr -d ' ')\n SRC_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n COPIED_SIZE=$(du -sh \"$NAS_DATA/$TARGET_DATE\" | cut -f1)\n if [ \"$COPIED_FILES\" -ge \"$SRC_FILES\" ]; then\n printf \"\\r %-36s ✓ %dm%02ds (%s files, %s)\\n\" \\\n \"rsync frames → NAS\" \\\n \"$(( RSYNC_DUR / 60 ))\" \"$(( RSYNC_DUR % 60 ))\" \\\n \"$COPIED_FILES\" \"$COPIED_SIZE\" | tee -a \"$LOG_FILE\"\n else\n printf \"\\r %-36s ✗ %s / %s files\\n\" \\\n \"rsync frames → NAS\" \"$COPIED_FILES\" \"$SRC_FILES\" | tee -a \"$LOG_FILE\"\n fi\nelse\n printf \" %-36s %s\\n\" \"rsync frames → NAS\" \"skipped (no source dir)\"\nfi\n\n# ─── COPY AUDIO FILES ────────────────────────────────────────────────────────\n# Audio is flat in ~/.screenpipe/data/ with the date in the filename, e.g.\n# System Audio (output)_2026-05-11_13-48-12.mp4\n# soundcore AeroClip (input)_2026-05-10_11-10-32.mp4\n# Mirrored to $NAS_DATA/<date>/audio/ so each day's archive is self-contained.\nstep \"Copying audio files for $TARGET_DATE\"\n\nshopt -s nullglob\nAUDIO_FILES=( \"$HOME/.screenpipe/data/\"*_\"${TARGET_DATE}\"_*.mp4 )\nshopt -u nullglob\n\nif [ ${#AUDIO_FILES[@]} -gt 0 ]; then\n mkdir -p \"$NAS_DATA/$TARGET_DATE/audio\"\n RSYNC_START=$(date +%s)\n printf \" %-36s \" \"rsync audio → NAS\"\n rsync -a --ignore-existing \"${AUDIO_FILES[@]}\" \"$NAS_DATA/$TARGET_DATE/audio/\" 2>>\"$LOG_FILE\"\n RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))\n COPIED_AUDIO=$(ls \"$NAS_DATA/$TARGET_DATE/audio\" | wc -l | tr -d ' ')\n AUDIO_SIZE=$(du -sh \"$NAS_DATA/$TARGET_DATE/audio\" | cut -f1)\n printf \"\\r %-36s ✓ %dm%02ds (%s files, %s)\\n\" \\\n \"rsync audio → NAS\" \\\n \"$(( RSYNC_DUR / 60 ))\" \"$(( RSYNC_DUR % 60 ))\" \\\n \"$COPIED_AUDIO\" \"$AUDIO_SIZE\" | tee -a \"$LOG_FILE\"\nelse\n printf \" %-36s %s\\n\" \"rsync audio → NAS\" \"skipped (no audio for date)\"\nfi\n\n# ─── COPY LOGS ────────────────────────────────────────────────────────────────\nstep \"Copying screenpipe logs for $TARGET_DATE\"\n\nNAS_LOGS=\"$NAS_MOUNT/logs\"\nmkdir -p \"$NAS_LOGS\"\n\nshopt -s nullglob\nLOG_FILES=( \"$HOME/.screenpipe/screenpipe.$TARGET_DATE.\"*.log )\nshopt -u nullglob\n\nif [ ${#LOG_FILES[@]} -gt 0 ]; then\n printf \" %-36s \" \"rsync logs → NAS\"\n rsync -a \"${LOG_FILES[@]}\" \"$NAS_LOGS/\" 2>>\"$LOG_FILE\"\n TOTAL_SIZE=$(du -ch \"${LOG_FILES[@]}\" | tail -1 | cut -f1)\n printf \"✓ %d file(s), %s\\n\" \"${#LOG_FILES[@]}\" \"$TOTAL_SIZE\" | tee -a \"$LOG_FILE\"\nelse\n printf \" %-36s %s\\n\" \"rsync logs → NAS\" \"skipped (no matching logs)\"\nfi\n\n# ─── SUMMARY ──────────────────────────────────────────────────────────────────\nTOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))\nDB_SIZE=$(du -sh \"$NAS_DB\" | cut -f1)\n\necho \"\"\nlog \"Archive DB size: $DB_SIZE\"\nlog \"Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s\"\nlog \"Sync complete for $TARGET_DATE (install $INSTALL_ID)\"\nlog \"========================================\"\n\nrsync -a \"$HOME/.screenpipe/sync.log\" \"$NAS_LOGS/sync.log\" 2>/dev/null || true","depth":28,"bounds":{"left":0.13763298,"top":0.35434955,"width":0.38031915,"height":0.014365523},"on_screen":true,"value":"# the source currently has; INSERT OR IGNORE handles the duplicate case.\n run_sqlite_heredoc \"speakers ($SRC_SPEAKERS rows, all-time)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.speakers ($SPEAKERS_COLS, install_id)\n SELECT $SPEAKERS_COLS, '$INSTALL_ID' FROM main.speakers;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"speaker_embeddings ($SRC_SEMB rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.speaker_embeddings ($SEMB_COLS, install_id)\n SELECT $SEMB_COLS, '$INSTALL_ID' FROM main.speaker_embeddings;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"audio_chunks ($SRC_ACHUNKS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.audio_chunks ($ACHUNKS_COLS, install_id)\n SELECT $ACHUNKS_COLS, '$INSTALL_ID' FROM main.audio_chunks WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"audio_transcriptions ($SRC_ATRANS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.audio_transcriptions ($ATRANS_COLS, install_id)\n SELECT $ATRANS_COLS_T, '$INSTALL_ID' FROM main.audio_transcriptions t\n JOIN main.audio_chunks c ON t.audio_chunk_id = c.id\n WHERE date(c.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"audio_tags ($SRC_ATAGS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.audio_tags ($ATAGS_COLS, install_id)\n SELECT $ATAGS_COLS_AT, '$INSTALL_ID' FROM main.audio_tags at\n JOIN main.audio_chunks c ON at.audio_chunk_id = c.id\n WHERE date(c.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n # ─── FTS UPDATE ───────────────────────────────────────────────────────────\n step \"Updating FTS indexes\"\n\n run_sqlite_heredoc \"elements_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.elements_fts(rowid, text, role)\n SELECT e.id, e.text, e.role\n FROM nas.elements e\n JOIN nas.frames f ON e.frame_id = f.id AND e.install_id = f.install_id\n WHERE date(f.timestamp) = '$TARGET_DATE'\n AND e.install_id = '$INSTALL_ID'\n AND e.text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)\n SELECT id, full_text, app_name, window_name, browser_url, id\n FROM nas.frames\n WHERE date(timestamp) = '$TARGET_DATE'\n AND install_id = '$INSTALL_ID'\n AND full_text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)\n SELECT id, text_content, app_name, window_title, element_name\n FROM nas.ui_events\n WHERE date(timestamp) = '$TARGET_DATE'\n AND install_id = '$INSTALL_ID'\n AND text_content IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"audio_transcriptions_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.audio_transcriptions_fts(rowid, transcription, device, speaker_id, id)\n SELECT t.id, t.transcription, COALESCE(t.device,''), t.speaker_id, t.id\n FROM nas.audio_transcriptions t\n JOIN nas.audio_chunks c ON t.audio_chunk_id = c.id AND t.install_id = c.install_id\n WHERE date(c.timestamp) = '$TARGET_DATE'\n AND t.install_id = '$INSTALL_ID'\n AND t.transcription IS NOT NULL AND t.transcription != '';\nDETACH nas;\n\"\n\n # ─── VERIFY ───────────────────────────────────────────────────────────────\n step \"Verifying DB\"\n\n V_FRAMES=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID';\")\n V_ELEMENTS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM elements WHERE install_id='$INSTALL_ID' AND frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID');\")\n V_UI=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID';\")\n V_OCR=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ocr_text WHERE install_id='$INSTALL_ID' AND frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID');\")\n V_MEETINGS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE' AND install_id='$INSTALL_ID';\")\n V_ACHUNKS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM audio_chunks WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID';\")\n V_ATRANS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM audio_transcriptions WHERE install_id='$INSTALL_ID' AND audio_chunk_id IN (SELECT id FROM audio_chunks WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID');\")\n V_ATAGS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM audio_tags WHERE install_id='$INSTALL_ID' AND audio_chunk_id IN (SELECT id FROM audio_chunks WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID');\")\n\n check \"frames\" \"$V_FRAMES\" \"$SRC_FRAMES\"\n check \"elements\" \"$V_ELEMENTS\" \"$SRC_ELEMENTS\"\n check \"ui_events\" \"$V_UI\" \"$SRC_UI\"\n check \"ocr_text\" \"$V_OCR\" \"$SRC_OCR\"\n check \"meetings\" \"$V_MEETINGS\" \"$SRC_MEETINGS\"\n check \"audio_chunks\" \"$V_ACHUNKS\" \"$SRC_ACHUNKS\"\n check \"audio_transcriptions\" \"$V_ATRANS\" \"$SRC_ATRANS\"\n check \"audio_tags\" \"$V_ATAGS\" \"$SRC_ATAGS\"\n\nfi\n\n# ─── COPY FRAME DATA FOLDER ──────────────────────────────────────────────────\n# Always runs regardless of DB sync status.\nstep \"Copying frame data folder for $TARGET_DATE\"\n\nif [ -d \"$DATA_SRC\" ]; then\n mkdir -p \"$NAS_DATA/$TARGET_DATE\"\n RSYNC_START=$(date +%s)\n printf \" %-36s \" \"rsync frames → NAS\"\n rsync -a --ignore-existing \"$DATA_SRC/\" \"$NAS_DATA/$TARGET_DATE/\" 2>>\"$LOG_FILE\"\n RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))\n COPIED_FILES=$(ls \"$NAS_DATA/$TARGET_DATE\" 2>/dev/null | grep -v '^audio$' | wc -l | tr -d ' ')\n SRC_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n COPIED_SIZE=$(du -sh \"$NAS_DATA/$TARGET_DATE\" | cut -f1)\n if [ \"$COPIED_FILES\" -ge \"$SRC_FILES\" ]; then\n printf \"\\r %-36s ✓ %dm%02ds (%s files, %s)\\n\" \\\n \"rsync frames → NAS\" \\\n \"$(( RSYNC_DUR / 60 ))\" \"$(( RSYNC_DUR % 60 ))\" \\\n \"$COPIED_FILES\" \"$COPIED_SIZE\" | tee -a \"$LOG_FILE\"\n else\n printf \"\\r %-36s ✗ %s / %s files\\n\" \\\n \"rsync frames → NAS\" \"$COPIED_FILES\" \"$SRC_FILES\" | tee -a \"$LOG_FILE\"\n fi\nelse\n printf \" %-36s %s\\n\" \"rsync frames → NAS\" \"skipped (no source dir)\"\nfi\n\n# ─── COPY AUDIO FILES ────────────────────────────────────────────────────────\n# Audio is flat in ~/.screenpipe/data/ with the date in the filename, e.g.\n# System Audio (output)_2026-05-11_13-48-12.mp4\n# soundcore AeroClip (input)_2026-05-10_11-10-32.mp4\n# Mirrored to $NAS_DATA/<date>/audio/ so each day's archive is self-contained.\nstep \"Copying audio files for $TARGET_DATE\"\n\nshopt -s nullglob\nAUDIO_FILES=( \"$HOME/.screenpipe/data/\"*_\"${TARGET_DATE}\"_*.mp4 )\nshopt -u nullglob\n\nif [ ${#AUDIO_FILES[@]} -gt 0 ]; then\n mkdir -p \"$NAS_DATA/$TARGET_DATE/audio\"\n RSYNC_START=$(date +%s)\n printf \" %-36s \" \"rsync audio → NAS\"\n rsync -a --ignore-existing \"${AUDIO_FILES[@]}\" \"$NAS_DATA/$TARGET_DATE/audio/\" 2>>\"$LOG_FILE\"\n RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))\n COPIED_AUDIO=$(ls \"$NAS_DATA/$TARGET_DATE/audio\" | wc -l | tr -d ' ')\n AUDIO_SIZE=$(du -sh \"$NAS_DATA/$TARGET_DATE/audio\" | cut -f1)\n printf \"\\r %-36s ✓ %dm%02ds (%s files, %s)\\n\" \\\n \"rsync audio → NAS\" \\\n \"$(( RSYNC_DUR / 60 ))\" \"$(( RSYNC_DUR % 60 ))\" \\\n \"$COPIED_AUDIO\" \"$AUDIO_SIZE\" | tee -a \"$LOG_FILE\"\nelse\n printf \" %-36s %s\\n\" \"rsync audio → NAS\" \"skipped (no audio for date)\"\nfi\n\n# ─── COPY LOGS ────────────────────────────────────────────────────────────────\nstep \"Copying screenpipe logs for $TARGET_DATE\"\n\nNAS_LOGS=\"$NAS_MOUNT/logs\"\nmkdir -p \"$NAS_LOGS\"\n\nshopt -s nullglob\nLOG_FILES=( \"$HOME/.screenpipe/screenpipe.$TARGET_DATE.\"*.log )\nshopt -u nullglob\n\nif [ ${#LOG_FILES[@]} -gt 0 ]; then\n printf \" %-36s \" \"rsync logs → NAS\"\n rsync -a \"${LOG_FILES[@]}\" \"$NAS_LOGS/\" 2>>\"$LOG_FILE\"\n TOTAL_SIZE=$(du -ch \"${LOG_FILES[@]}\" | tail -1 | cut -f1)\n printf \"✓ %d file(s), %s\\n\" \"${#LOG_FILES[@]}\" \"$TOTAL_SIZE\" | tee -a \"$LOG_FILE\"\nelse\n printf \" %-36s %s\\n\" \"rsync logs → NAS\" \"skipped (no matching logs)\"\nfi\n\n# ─── SUMMARY ──────────────────────────────────────────────────────────────────\nTOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))\nDB_SIZE=$(du -sh \"$NAS_DB\" | cut -f1)\n\necho \"\"\nlog \"Archive DB size: $DB_SIZE\"\nlog \"Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s\"\nlog \"Sync complete for $TARGET_DATE (install $INSTALL_ID)\"\nlog \"========================================\"\n\nrsync -a \"$HOME/.screenpipe/sync.log\" \"$NAS_LOGS/sync.log\" 2>/dev/null || true","role_description":"editor","is_enabled":true,"is_focused":true,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"# the source currently has; INSERT OR IGNORE handles the duplicate case.\n run_sqlite_heredoc \"speakers ($SRC_SPEAKERS rows, all-time)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.speakers ($SPEAKERS_COLS, install_id)\n SELECT $SPEAKERS_COLS, '$INSTALL_ID' FROM main.speakers;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"speaker_embeddings ($SRC_SEMB rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.speaker_embeddings ($SEMB_COLS, install_id)\n SELECT $SEMB_COLS, '$INSTALL_ID' FROM main.speaker_embeddings;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"audio_chunks ($SRC_ACHUNKS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.audio_chunks ($ACHUNKS_COLS, install_id)\n SELECT $ACHUNKS_COLS, '$INSTALL_ID' FROM main.audio_chunks WHERE date(timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"audio_transcriptions ($SRC_ATRANS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.audio_transcriptions ($ATRANS_COLS, install_id)\n SELECT $ATRANS_COLS_T, '$INSTALL_ID' FROM main.audio_transcriptions t\n JOIN main.audio_chunks c ON t.audio_chunk_id = c.id\n WHERE date(c.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"audio_tags ($SRC_ATAGS rows)\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.audio_tags ($ATAGS_COLS, install_id)\n SELECT $ATAGS_COLS_AT, '$INSTALL_ID' FROM main.audio_tags at\n JOIN main.audio_chunks c ON at.audio_chunk_id = c.id\n WHERE date(c.timestamp) = '$TARGET_DATE';\nDETACH nas;\n\"\n\n # ─── FTS UPDATE ───────────────────────────────────────────────────────────\n step \"Updating FTS indexes\"\n\n run_sqlite_heredoc \"elements_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.elements_fts(rowid, text, role)\n SELECT e.id, e.text, e.role\n FROM nas.elements e\n JOIN nas.frames f ON e.frame_id = f.id AND e.install_id = f.install_id\n WHERE date(f.timestamp) = '$TARGET_DATE'\n AND e.install_id = '$INSTALL_ID'\n AND e.text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"frames_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)\n SELECT id, full_text, app_name, window_name, browser_url, id\n FROM nas.frames\n WHERE date(timestamp) = '$TARGET_DATE'\n AND install_id = '$INSTALL_ID'\n AND full_text IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"ui_events_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)\n SELECT id, text_content, app_name, window_title, element_name\n FROM nas.ui_events\n WHERE date(timestamp) = '$TARGET_DATE'\n AND install_id = '$INSTALL_ID'\n AND text_content IS NOT NULL;\nDETACH nas;\n\"\n\n run_sqlite_heredoc \"audio_transcriptions_fts\" \"\nATTACH '$NAS_DB' AS nas;\nINSERT OR IGNORE INTO nas.audio_transcriptions_fts(rowid, transcription, device, speaker_id, id)\n SELECT t.id, t.transcription, COALESCE(t.device,''), t.speaker_id, t.id\n FROM nas.audio_transcriptions t\n JOIN nas.audio_chunks c ON t.audio_chunk_id = c.id AND t.install_id = c.install_id\n WHERE date(c.timestamp) = '$TARGET_DATE'\n AND t.install_id = '$INSTALL_ID'\n AND t.transcription IS NOT NULL AND t.transcription != '';\nDETACH nas;\n\"\n\n # ─── VERIFY ───────────────────────────────────────────────────────────────\n step \"Verifying DB\"\n\n V_FRAMES=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID';\")\n V_ELEMENTS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM elements WHERE install_id='$INSTALL_ID' AND frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID');\")\n V_UI=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID';\")\n V_OCR=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM ocr_text WHERE install_id='$INSTALL_ID' AND frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID');\")\n V_MEETINGS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE' AND install_id='$INSTALL_ID';\")\n V_ACHUNKS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM audio_chunks WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID';\")\n V_ATRANS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM audio_transcriptions WHERE install_id='$INSTALL_ID' AND audio_chunk_id IN (SELECT id FROM audio_chunks WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID');\")\n V_ATAGS=$(sqlite3 \"$NAS_DB\" \"SELECT COUNT(*) FROM audio_tags WHERE install_id='$INSTALL_ID' AND audio_chunk_id IN (SELECT id FROM audio_chunks WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID');\")\n\n check \"frames\" \"$V_FRAMES\" \"$SRC_FRAMES\"\n check \"elements\" \"$V_ELEMENTS\" \"$SRC_ELEMENTS\"\n check \"ui_events\" \"$V_UI\" \"$SRC_UI\"\n check \"ocr_text\" \"$V_OCR\" \"$SRC_OCR\"\n check \"meetings\" \"$V_MEETINGS\" \"$SRC_MEETINGS\"\n check \"audio_chunks\" \"$V_ACHUNKS\" \"$SRC_ACHUNKS\"\n check \"audio_transcriptions\" \"$V_ATRANS\" \"$SRC_ATRANS\"\n check \"audio_tags\" \"$V_ATAGS\" \"$SRC_ATAGS\"\n\nfi\n\n# ─── COPY FRAME DATA FOLDER ──────────────────────────────────────────────────\n# Always runs regardless of DB sync status.\nstep \"Copying frame data folder for $TARGET_DATE\"\n\nif [ -d \"$DATA_SRC\" ]; then\n mkdir -p \"$NAS_DATA/$TARGET_DATE\"\n RSYNC_START=$(date +%s)\n printf \" %-36s \" \"rsync frames → NAS\"\n rsync -a --ignore-existing \"$DATA_SRC/\" \"$NAS_DATA/$TARGET_DATE/\" 2>>\"$LOG_FILE\"\n RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))\n COPIED_FILES=$(ls \"$NAS_DATA/$TARGET_DATE\" 2>/dev/null | grep -v '^audio$' | wc -l | tr -d ' ')\n SRC_FILES=$(ls \"$DATA_SRC\" | wc -l | tr -d ' ')\n COPIED_SIZE=$(du -sh \"$NAS_DATA/$TARGET_DATE\" | cut -f1)\n if [ \"$COPIED_FILES\" -ge \"$SRC_FILES\" ]; then\n printf \"\\r %-36s ✓ %dm%02ds (%s files, %s)\\n\" \\\n \"rsync frames → NAS\" \\\n \"$(( RSYNC_DUR / 60 ))\" \"$(( RSYNC_DUR % 60 ))\" \\\n \"$COPIED_FILES\" \"$COPIED_SIZE\" | tee -a \"$LOG_FILE\"\n else\n printf \"\\r %-36s ✗ %s / %s files\\n\" \\\n \"rsync frames → NAS\" \"$COPIED_FILES\" \"$SRC_FILES\" | tee -a \"$LOG_FILE\"\n fi\nelse\n printf \" %-36s %s\\n\" \"rsync frames → NAS\" \"skipped (no source dir)\"\nfi\n\n# ─── COPY AUDIO FILES ────────────────────────────────────────────────────────\n# Audio is flat in ~/.screenpipe/data/ with the date in the filename, e.g.\n# System Audio (output)_2026-05-11_13-48-12.mp4\n# soundcore AeroClip (input)_2026-05-10_11-10-32.mp4\n# Mirrored to $NAS_DATA/<date>/audio/ so each day's archive is self-contained.\nstep \"Copying audio files for $TARGET_DATE\"\n\nshopt -s nullglob\nAUDIO_FILES=( \"$HOME/.screenpipe/data/\"*_\"${TARGET_DATE}\"_*.mp4 )\nshopt -u nullglob\n\nif [ ${#AUDIO_FILES[@]} -gt 0 ]; then\n mkdir -p \"$NAS_DATA/$TARGET_DATE/audio\"\n RSYNC_START=$(date +%s)\n printf \" %-36s \" \"rsync audio → NAS\"\n rsync -a --ignore-existing \"${AUDIO_FILES[@]}\" \"$NAS_DATA/$TARGET_DATE/audio/\" 2>>\"$LOG_FILE\"\n RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))\n COPIED_AUDIO=$(ls \"$NAS_DATA/$TARGET_DATE/audio\" | wc -l | tr -d ' ')\n AUDIO_SIZE=$(du -sh \"$NAS_DATA/$TARGET_DATE/audio\" | cut -f1)\n printf \"\\r %-36s ✓ %dm%02ds (%s files, %s)\\n\" \\\n \"rsync audio → NAS\" \\\n \"$(( RSYNC_DUR / 60 ))\" \"$(( RSYNC_DUR % 60 ))\" \\\n \"$COPIED_AUDIO\" \"$AUDIO_SIZE\" | tee -a \"$LOG_FILE\"\nelse\n printf \" %-36s %s\\n\" \"rsync audio → NAS\" \"skipped (no audio for date)\"\nfi\n\n# ─── COPY LOGS ────────────────────────────────────────────────────────────────\nstep \"Copying screenpipe logs for $TARGET_DATE\"\n\nNAS_LOGS=\"$NAS_MOUNT/logs\"\nmkdir -p \"$NAS_LOGS\"\n\nshopt -s nullglob\nLOG_FILES=( \"$HOME/.screenpipe/screenpipe.$TARGET_DATE.\"*.log )\nshopt -u nullglob\n\nif [ ${#LOG_FILES[@]} -gt 0 ]; then\n printf \" %-36s \" \"rsync logs → NAS\"\n rsync -a \"${LOG_FILES[@]}\" \"$NAS_LOGS/\" 2>>\"$LOG_FILE\"\n TOTAL_SIZE=$(du -ch \"${LOG_FILES[@]}\" | tail -1 | cut -f1)\n printf \"✓ %d file(s), %s\\n\" \"${#LOG_FILES[@]}\" \"$TOTAL_SIZE\" | tee -a \"$LOG_FILE\"\nelse\n printf \" %-36s %s\\n\" \"rsync logs → NAS\" \"skipped (no matching logs)\"\nfi\n\n# ─── SUMMARY ──────────────────────────────────────────────────────────────────\nTOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))\nDB_SIZE=$(du -sh \"$NAS_DB\" | cut -f1)\n\necho \"\"\nlog \"Archive DB size: $DB_SIZE\"\nlog \"Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s\"\nlog \"Sync complete for $TARGET_DATE (install $INSTALL_ID)\"\nlog \"========================================\"\n\nrsync -a \"$HOME/.screenpipe/sync.log\" \"$NAS_LOGS/sync.log\" 2>/dev/null || true","depth":29,"bounds":{"left":0.13763298,"top":0.35434955,"width":0.38031915,"height":0.014365523},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Implement and run pipe l…, Editor Group 2","depth":28,"bounds":{"left":0.5578458,"top":0.047885075,"width":0.073803194,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":false},{"role":"AXRadioButton","text":"Problems (⇧⌘M)","depth":22,"bounds":{"left":0.118351065,"top":0.7278532,"width":0.027925532,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"PROBLEMS","depth":24,"bounds":{"left":0.122340426,"top":0.7366321,"width":0.019946808,"height":0.0103751},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Output (⇧⌘U)","depth":22,"bounds":{"left":0.14594415,"top":0.7278532,"width":0.023603724,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUTPUT","depth":24,"bounds":{"left":0.14993352,"top":0.7366321,"width":0.015625,"height":0.0103751},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Debug Console (⇧⌘Y)","depth":22,"bounds":{"left":0.16921543,"top":0.7278532,"width":0.039893616,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"DEBUG CONSOLE","depth":24,"bounds":{"left":0.1732048,"top":0.7366321,"width":0.031914894,"height":0.0103751},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Terminal (⌃`)","depth":22,"bounds":{"left":0.2087766,"top":0.7278532,"width":0.026595745,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":true},{"role":"AXStaticText","text":"TERMINAL","depth":24,"bounds":{"left":0.21276596,"top":0.7366321,"width":0.01861702,"height":0.0103751},"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Ports - 1 forwarded port","depth":22,"bounds":{"left":0.23537233,"top":0.7278532,"width":0.026263298,"height":0.02793296},"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"PORTS","depth":24,"bounds":{"left":0.2393617,"top":0.7366321,"width":0.012300532,"height":0.0103751},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":25,"bounds":{"left":0.25465426,"top":0.73743016,"width":0.0019946808,"height":0.008778931},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"remote SSH: nas","depth":16,"bounds":{"left":0.0006648936,"top":0.98244214,"width":0.028590426,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.0033244682,"top":0.9848364,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"SSH: nas","depth":17,"bounds":{"left":0.008643617,"top":0.9856345,"width":0.017952127,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"screenpipe (Git) - master*, Checkout Branch/Tag...","depth":16,"bounds":{"left":0.030917553,"top":0.98244214,"width":0.023271276,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.031914894,"top":0.9848364,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"master*","depth":17,"bounds":{"left":0.03723404,"top":0.9856345,"width":0.015957447,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"screenpipe (Git) - Synchronize Changes","depth":16,"bounds":{"left":0.05418883,"top":0.98244214,"width":0.00731383,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"No Problems","depth":16,"bounds":{"left":0.06416223,"top":0.98244214,"width":0.022606382,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.06582447,"top":0.9848364,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"0","depth":17,"bounds":{"left":0.07114362,"top":0.9856345,"width":0.004986702,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.07579787,"top":0.9848364,"width":0.0056515955,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"0","depth":17,"bounds":{"left":0.08111702,"top":0.9856345,"width":0.0039893617,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Forwarded Ports: 8766","depth":16,"bounds":{"left":0.08843085,"top":0.98244214,"width":0.012632979,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.09009308,"top":0.9848364,"width":0.0056515955,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"1","depth":17,"bounds":{"left":0.09541223,"top":0.9856345,"width":0.0039893617,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Notifications","depth":16,"bounds":{"left":0.9886968,"top":0.98244214,"width":0.010638298,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Sign In","depth":16,"bounds":{"left":0.9650931,"top":0.98244214,"width":0.022606382,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.96675533,"top":0.9848364,"width":0.0056515955,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Sign In","depth":17,"bounds":{"left":0.97207445,"top":0.9856345,"width":0.013962766,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXButton","text":"Shell Script","depth":16,"bounds":{"left":0.93916225,"top":0.98244214,"width":0.023603724,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Editor Language Status: Inline Suggestions, next: $(copilot) No inline suggestion available, Inline suggestions","depth":16,"bounds":{"left":0.9318484,"top":0.98244214,"width":0.00731383,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"LF","depth":16,"bounds":{"left":0.9212101,"top":0.98244214,"width":0.007978723,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"UTF-8","depth":16,"bounds":{"left":0.90359044,"top":0.98244214,"width":0.015625,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Spaces: 2","depth":16,"bounds":{"left":0.8796542,"top":0.98244214,"width":0.022273935,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Ln 675, Col 1","depth":16,"bounds":{"left":0.8490692,"top":0.98244214,"width":0.028922873,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"git-commit Not Committed Yet","depth":16,"bounds":{"left":0.8015292,"top":0.98244214,"width":0.045545213,"height":0.01755786},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":17,"bounds":{"left":0.8031915,"top":0.9848364,"width":0.005319149,"height":0.012769354},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"Not Committed Yet","depth":17,"bounds":{"left":0.80851066,"top":0.9856345,"width":0.036901597,"height":0.011173184},"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"No results found","depth":12,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Implement and run pipe logic","depth":19,"bounds":{"left":0.56017286,"top":0.08060654,"width":0.07114362,"height":0.022346368},"on_screen":true,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Session history","depth":19,"bounds":{"left":0.9780585,"top":0.08060654,"width":0.00930851,"height":0.022346368},"on_screen":true,"help_text":"Session history","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"New session","depth":19,"bounds":{"left":0.9886968,"top":0.08060654,"width":0.00930851,"height":0.022346368},"on_screen":true,"help_text":"New session","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"Message actions","depth":24,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXButton","text":"main.py","depth":23,"on_screen":false,"role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"lets implement logic with pipes. how can I run it?","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Let me look at the current project structure to understand what's already in place.","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"List project files","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"find /volume1/screenpipe -type f | head -50 && echo \"---\" && ls /volume1/screenpipe","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"/volume1/screenpipe/.DS_Store\n/volume1/screenpipe/screenpipe.db\n/volume1/screenpipe/screenpipe_sync.sh\n/volume1/screenpipe/app_settings.json\n/volume1/screenpipe/.gitignore\n/volume1/screenpipe/archive.db\n/volume1/screenpipe/db.sqlite\n/volume1/screenpipe/db.sqlite-wal\n/volume1/screenpipe/db.sqlite-shm\n/volume1/screenpipe/#recycle/desktop.ini\n/volume1/screenpipe/#recycle/db.sqlite\n/volume1/screenpipe/#recycle/Copy #1 of db.sqlite\n/volume1/screenpipe/#recycle/.DS_Store\n/volume1/screenpipe/#recycle/Copy #2 of db.sqlite\n/volume1/screenpipe/#recycle/archive.db\n/volume1/screenpipe/#recycle/Copy #1 of archive.db\n/volume1/screenpipe/#recycle/Copy #2 of archive.db\n/volume1/screenpipe/#recycle/Copy #3 of archive.db\n/volume1/screenpipe/#recycle/Copy #4 of archive.db\n/volume1/screenpipe/#recycle/Copy #5 of archive.db\n/volume1/screenpipe/#recycle/Copy #3 of db.sqlite\n/volume1/screenpipe/#recycle/Copy #4 of db.sqlite\n/volume1/screenpipe/#recycle/Copy #6 of archive.db\n/volume1/screenpipe/#recycle/test.txt\n/volume1/screenpipe/#recycle/Copy #7 of archive.db\n/volume1/screenpipe/#recycle/Copy #8 of archive.db\n/volume1/screenpipe/#recycle/archive.db-journal\n/volume1/screenpipe/#recycle/Copy #1 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #2 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #3 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #4 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #5 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #6 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #7 of archive.db-journal\n/volume1/screenpipe/#recycle/Copy #5 of db.sqlite\n/volume1/screenpipe/pipes/.DS_Store\n/volume1/screenpipe/app/.env\n/volume1/screenpipe/app/cli.py\n/volume1/screenpipe/app/.DS_Store\n/volume1/screenpipe/app/db.py\n/volume1/screenpipe/app/docker-compose.yml\n/volume1/screenpipe/app/main.py\n/volume1/screenpipe/app/requirements.txt\n/volume1/screenpipe/app/Dockerfile\n/volume1/screenpipe/data/.DS_Store\n/volume1/screenpipe/.git/description\n/volume1/screenpipe/.git/HEAD\n/volume1/screenpipe/.git/index\n/volume1/screenpipe/.git/COMMIT_EDITMSG\n/volume1/screenpipe/#recycle/data/.DS_Store\n---\napp\napp_settings.json\narchive.db\ndata\ndb.sqlite\ndb.sqlite-shm\ndb.sqlite-wal\npipes\n#recycle\nscreenpipe.db\nscreenpipe_sync.sh","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"main.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"main.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Check pipes directory and docker-compose","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/pipes/ && ls /volume1/screenpipe/app/ && cat /volume1/screenpipe/app/docker-compose.yml","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ai-habits\nday-recap\nmeeting-summary\nstandup-update\ntime-breakdown\nvideo-export\ncli.py\nconsumers\ndb.py\ndocker-compose.yml\nDockerfile\nmain.py\n__pycache__\nrequirements.txt\nstatic\nservices:\n screenpipe-app:\n build: .\n container_name: screenpipe-app\n restart: unless-stopped\n ports:\n - \"8766:8000\"\n volumes:\n - /volume1/screenpipe:/data\n env_file:\n - .env\n environment:\n TZ: Europe/Sofia\n DB_PATH: /data/db.sqlite\n\n sqlite-web-archive:\n image: ghcr.io/coleifer/sqlite-web:latest\n container_name: screenpipe-sqlweb-archive\n restart: unless-stopped\n ports:\n - \"8767:8080\"\n volumes:\n - /volume1/screenpipe:/data\n command: [\"-H\", \"0.0.0.0\", \"-r\", \"/data/archive.db\"]\n\n sqlite-web-live:\n image: ghcr.io/coleifer/sqlite-web:latest\n container_name: screenpipe-sqlweb-live\n restart: unless-stopped\n ports:\n - \"8768:8080\"\n volumes:\n - /volume1/screenpipe:/data\n command: [\"-H\", \"0.0.0.0\", \"-r\", \"/data/db.sqlite\"]","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"requirements.txt","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"requirements.txt","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Inspect a pipe directory","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/pipes/day-recap/ && cat /volume1/screenpipe/pipes/day-recap/pipe.json 2>/dev/null || ls /volume1/screenpipe/pipes/day-recap/","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"pipe.md\npipe.md","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"cli.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"cli.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"List all pipes and their contents","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/pipes/ && for d in /volume1/screenpipe/pipes/*/; do echo \"=== $d ===\"; ls \"$d\"; done","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ai-habits\nday-recap\nmeeting-summary\nstandup-update\ntime-breakdown\nvideo-export\n=== /volume1/screenpipe/pipes/ai-habits/ ===\npipe.md\n=== /volume1/screenpipe/pipes/day-recap/ ===\npipe.md\n=== /volume1/screenpipe/pipes/meeting-summary/ ===\npipe.md\n=== /volume1/screenpipe/pipes/standup-update/ ===\npipe.md\n=== /volume1/screenpipe/pipes/time-breakdown/ ===\npipe.md\n=== /volume1/screenpipe/pipes/video-export/ ===\npipe.md","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read pipe markdown files","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"cat /volume1/screenpipe/pipes/day-recap/pipe.md && echo \"===\" && cat /volume1/screenpipe/pipes/meeting-summary/pipe.md 2>/dev/null | head -50","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Day Recap\ndescription: \"Today's accomplishments, key moments, and unfinished work\"\nicon: \"📋\"\nfeatured: true\n---\n\nAnalyze my screen and audio recordings from today (last 16 hours only). \n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Summary\nOne sentence: what I mainly did today.\n\n## Accomplishments\n- Top 3 things I finished, with timestamps (e.g. \"2:30 PM\")\n- Name specific apps, files, or projects\n\n## Key Moments\n- Important things I saw, said, or heard — with timestamps\n\n## Unfinished Work\n- What I should continue tomorrow — name the app/file/task\n\n## Patterns\n- Apps I used most, topics that came up repeatedly\n\nOnly report what you can verify from the data. End with: \"**Next step:** [most important thing to continue]\"\n===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Meeting Summary\ndescription: \"Summarize meeting transcript with key takeaways and action items\"\nicon: \"🤝\"\nfeatured: false\n---\n\nSummarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.\n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Meeting Summary\nOne sentence: what this meeting was about.\n\n## Key Takeaways\n- Top 3-5 important points discussed\n- Include who said what when relevant\n\n## Action Items\n- [ ] Task — assigned to whom, deadline if mentioned\n- [ ] Task — assigned to whom\n\n## Decisions Made\n- List any decisions or agreements reached\n\n## Open Questions\n- Anything unresolved or needing follow-up\n\nKeep it concise and actionable.","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read summary consumer","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"ls /volume1/screenpipe/app/consumers/ && cat /volume1/screenpipe/app/consumers/summary.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"activity.py\naudio.py\nelements.py\n__init__.py\ninteractions.py\nocr.py\n__pycache__\nreport.py\nsummary.py\n\"\"\"AI summary generator using Claude.\"\"\"\nimport os\nfrom datetime import date\nfrom typing import Any\n\nfrom consumers.activity import app_time, summary_stats, browser_urls, ui_event_summary\nfrom consumers.ocr import deduplicated_text\nfrom consumers.audio import formatted_transcript\n\n\nSUMMARY_TYPES = {\n \"day_recap\": {\n \"title\": \"Day Recap\",\n \"prompt\": \"\"\"\\\nYou are analyzing a person's computer activity for the day.\n\n## App usage (minutes per app):\n{app_time}\n\n## Browser URLs visited:\n{browser_urls}\n\n## UI activity per app (clicks / keystrokes / app-switches):\n{ui_events}\n\n## Screen content (sampled every 5 minutes):\n{ocr_text}\n\n## Audio/speech:\n{audio}\n\nWrite a concise day recap using EXACTLY this format:\n\n## Summary\nOne sentence: what I mainly worked on today.\n\n## Accomplishments\n- Top 3 things I finished, with approximate times\n- Name specific apps, files, or projects\n\n## Key Moments\n- Important things seen or heard, with timestamps\n\n## Unfinished Work\n- What to continue tomorrow\n\n## Patterns\n- Apps used most, topics that came up repeatedly\n\nOnly report what you can verify from the data. End with:\n**Next step:** [most important thing to continue]\"\"\",\n },\n \"standup\": {\n \"title\": \"Standup Update\",\n \"prompt\": \"\"\"\\\nYou are analyzing a person's computer activity for the day.\n\n## App usage (minutes per app):\n{app_time}\n\n## Browser URLs visited:\n{browser_urls}\n\n## UI activity per app (clicks / keystrokes / app-switches):\n{ui_events}\n\n## Screen content (sampled every 5 minutes):\n{ocr_text}\n\n## Audio/speech:\n{audio}\n\nWrite a brief standup update:\n\n**Yesterday:** What I worked on (2-3 bullets)\n**Today:** What I plan to continue (1-2 bullets)\n**Blockers:** Any issues observed (or \"None\")\n\nKeep it under 150 words. Only report what's verifiable from the data.\"\"\",\n },\n \"focus_time\": {\n \"title\": \"Focus & Distraction Analysis\",\n \"prompt\": \"\"\"\\\nYou are analyzing a person's computer activity for the day.\n\n## App usage (minutes per app):\n{app_time}\n\n## Browser URLs visited:\n{browser_urls}\n\n## UI activity per app (clicks / keystrokes / app-switches):\n{ui_events}\n\n## Screen content (sampled every 5 minutes):\n{ocr_text}\n\nAnalyze focus vs distraction patterns:\n\n## Deep Work Periods\n- When and how long were sustained focus sessions?\n- What was being worked on?\n\n## Distractions\n- Which apps/sites were used recreationally?\n- How much time was lost to context switching?\n\n## Recommendations\n- 2-3 concrete suggestions to improve focus tomorrow\n\nBe specific with times and app names.\"\"\",\n },\n}\n\n\ndef _build_context(for_date: date) -> dict[str, str]:\n apps = app_time(for_date)\n app_lines = \"\\n\".join(f\"- {a['app_name']}: {a['minutes']} min\" for a in apps[:20])\n\n urls = browser_urls(for_date, limit=20)\n url_lines = \"\\n\".join(\n f\"- {u['browser_url'][:100]} ({u['minutes']} min)\" for u in urls\n )\n\n ui_rows = ui_event_summary(for_date)\n ui_lines = \"\\n\".join(\n f\"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches\"\n for r in ui_rows[:15]\n )\n\n ocr_rows = deduplicated_text(for_date, chunk_minutes=5)\n ocr_lines = \"\\n\".join(\n f\"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}\"\n for r in ocr_rows[:100]\n )\n\n audio = formatted_transcript(for_date)\n\n return {\n \"app_time\": app_lines or \"(no app data)\",\n \"browser_urls\": url_lines or \"(no browser data)\",\n \"ui_events\": ui_lines or \"(no UI event data)\",\n \"ocr_text\": ocr_lines or \"(no screen data)\",\n \"audio\": audio[:3000] if len(audio) > 3000 else audio,\n }\n\n\ndef generate(\n summary_type: str = \"day_recap\",\n for_date: date | None = None,\n api_key: str | None = None,\n) -> dict[str, Any]:\n \"\"\"Generate an AI summary. Returns dict with 'title', 'content', 'date'.\"\"\"\n import anthropic\n\n d = for_date or date.today()\n key = api_key or os.environ.get(\"ANTHROPIC_API_KEY\", \"\")\n if not key:\n return {\n \"title\": \"Error\",\n \"content\": \"ANTHROPIC_API_KEY not set. Add it to your .env file.\",\n \"date\": str(d),\n }\n\n spec = SUMMARY_TYPES.get(summary_type)\n if not spec:\n return {\"title\": \"Error\", \"content\": f\"Unknown summary type: {summary_type}\", \"date\": str(d)}\n\n stats = summary_stats(d)\n if stats[\"total_frames\"] == 0:\n return {\n \"title\": spec[\"title\"],\n \"content\": f\"No screen data found for {d}.\",\n \"date\": str(d),\n }\n\n ctx = _build_context(d)\n prompt = spec[\"prompt\"].format(**ctx)\n\n client = anthropic.Anthropic(api_key=key)\n message = client.messages.create(\n model=\"claude-haiku-4-5-20251001\",\n max_tokens=1024,\n messages=[{\"role\": \"user\", \"content\": prompt}],\n )\n\n return {\n \"title\": spec[\"title\"],\n \"content\": message.content[0].text,\n \"date\": str(d),\n \"stats\": stats,\n }","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Read all pipe.md files","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"for f in /volume1/screenpipe/pipes/*/pipe.md; do echo \"=== $f ===\"; cat \"$f\"; echo; done","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"=== /volume1/screenpipe/pipes/ai-habits/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: AI Habits\ndescription: \"How you use AI tools — patterns and insights\"\nicon: \"🤖\"\nfeatured: true\n---\n\nSearch my recordings from the last 24 hours for AI tool usage. Use app_name filter for each tool separately: ChatGPT, Claude, Copilot, Cursor, Gemini, Perplexity. Use limit=5 per search, max 6 searches total.\n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## AI Tools Used\n- List each tool with approximate time spent (e.g. \"Claude: ~45min\")\n\n## What I Used Them For\n- For each tool: coding, writing, research, or brainstorming\n\n## Usage Patterns\n- Do I switch between tools? Use them in bursts or steadily?\n\n## Effectiveness\n- Which tool appeared alongside completed work vs. abandoned attempts\n\nIf no AI usage is found, say so clearly. End with: \"**Tip:** [one suggestion to use AI tools more effectively]\"\n\n=== /volume1/screenpipe/pipes/day-recap/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Day Recap\ndescription: \"Today's accomplishments, key moments, and unfinished work\"\nicon: \"📋\"\nfeatured: true\n---\n\nAnalyze my screen and audio recordings from today (last 16 hours only). \n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Summary\nOne sentence: what I mainly did today.\n\n## Accomplishments\n- Top 3 things I finished, with timestamps (e.g. \"2:30 PM\")\n- Name specific apps, files, or projects\n\n## Key Moments\n- Important things I saw, said, or heard — with timestamps\n\n## Unfinished Work\n- What I should continue tomorrow — name the app/file/task\n\n## Patterns\n- Apps I used most, topics that came up repeatedly\n\nOnly report what you can verify from the data. End with: \"**Next step:** [most important thing to continue]\"\n\n=== /volume1/screenpipe/pipes/meeting-summary/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Meeting Summary\ndescription: \"Summarize meeting transcript with key takeaways and action items\"\nicon: \"🤝\"\nfeatured: false\n---\n\nSummarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.\n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Meeting Summary\nOne sentence: what this meeting was about.\n\n## Key Takeaways\n- Top 3-5 important points discussed\n- Include who said what when relevant\n\n## Action Items\n- [ ] Task — assigned to whom, deadline if mentioned\n- [ ] Task — assigned to whom\n\n## Decisions Made\n- List any decisions or agreements reached\n\n## Open Questions\n- Anything unresolved or needing follow-up\n\nKeep it concise and actionable.\n\n=== /volume1/screenpipe/pipes/standup-update/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Standup Update\ndescription: \"What you did, what's next, and any blockers\"\nicon: \"🏢\"\nfeatured: true\n---\n\nBased on my recordings from the last 24 hours, generate a standup update. Use limit=10 per search, max 3 searches total.\n\nRead screenpipe skill first.\n\nUse this exact format:\n\n## Yesterday\n- What I worked on (name specific projects, files, tools, PRs)\n\n## Today\n- What I will work on next (based on unfinished tasks and recent activity)\n\n## Blockers\n- Issues I hit — errors, slow builds, waiting on someone\n- If no blockers, write \"None\"\n\nKeep it under 150 words. Copy-paste ready for a team standup.\n\n=== /volume1/screenpipe/pipes/time-breakdown/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Time Breakdown\ndescription: \"Where your time went — by app, project, and category\"\nicon: \"⏱\"\nfeatured: false\n---\n\nAnalyze my app usage from today (last 12 hours). Use limit=10 per search, max 4 searches. Prefer /raw_sql with COUNT/GROUP BY queries.\n\nRead screenpipe skill first.\n\nUse this exact format with durations and percentages:\n\n## By Application\n- List each app with duration and percentage, sorted by time (e.g. \"VS Code: 2h 15min (28%)\")\n\n## By Category\n- Group into: coding, meetings, browsing, writing, communication, other\n- Show hours and percentage per category\n\n## By Project\n- Group related activities by project/topic. Name specific repos or tasks.\n\n## Productivity Score\n- Calculate: focused_work_hours / total_hours as a percentage\n- Focused = coding + writing. Unfocused = browsing + switching.\n\nEnd with: \"**Suggestion:** [one specific change to improve tomorrow's productivity]\"\n\n=== /volume1/screenpipe/pipes/video-export/pipe.md ===\n---\nschedule: manual\nenabled: true\ntemplate: true\ntitle: Export Video Clip\ndescription: \"Create a video of your recent screen activity\"\nicon: \"🎬\"\nfeatured: false\n---\n\nExport a video of my screen activity from the last 5 minutes.\n\nRead screenpipe skill first.\n\nUse the POST /frames/export endpoint with the time range and fps=1.0. Then show me the exported video file path as an inline code block so I can watch it.\n\nIf the export is large, suggest a lower fps or shorter time range.","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Thinking","depth":23,"on_screen":false,"role_description":"disclosure triangle","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"Thinking","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Now I have a clear picture. The pipes are markdown prompt templates in","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"/volume1/screenpipe/pipes/","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":", but there's no code to actually load and run them —","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"consumers/summary.py","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"has its own hardcoded prompts instead.","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Here's what I'll implement:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"consumers/pipes.py","depth":26,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"— dynamically loads pipe.md files and runs them via Claude (data injected as system message, pipe body as user prompt)","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"main.py","depth":26,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"— two new endpoints:","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"GET /api/pipes","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"and","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"POST /api/pipes/{pipe_id}/run","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"cli.py","depth":26,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"— a","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"pipe","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"command to run pipes from the terminal","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Let me build it:","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Bash","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Check browser_urls signature","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"IN","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"cat /volume1/screenpipe/app/consumers/activity.py | grep \"def browser_urls\" -A 5","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXButton","text":"Copy code to clipboard","depth":24,"on_screen":false,"help_text":"Copy code","role_description":"button","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"OUT","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"def browser_urls(\n for_date: date | None = None,\n app_name: str | None = None,\n ts_from: str | None = None,\n ts_to: str | None = None,\n limit: int = 30,","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Write","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXLink","text":"pipes.py","depth":24,"on_screen":false,"role_description":"link","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"pipes.py","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"143 lines","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"\"\"\"Dynamic pipe loader and runner.\"\"\"\nimport os\nimport re\nfrom datetime import date\nfrom pathlib import Path\nfrom typing import Any\n\n\ndef _parse_frontmatter(text: str) -> tuple[dict, str]:\n if not text.startswith(\"---\"):\n return {}, text\n try:\n end = text.index(\"---\", 3)\n except ValueError:\n return {}, text\n fm_text = text[3:end].strip()\n body = text[end + 3:].strip()\n meta: dict = {}\n for line in fm_text.splitlines():\n if \":\" in line:\n k, _, v = line.partition(\":\")\n meta[k.strip()] = v.strip().strip('\"')\n return meta, body\n\n\ndef load_pipes(pipes_dir: Path) -> list[dict]:\n if not pipes_dir.exists():\n return []\n pipes = []\n for pipe_dir in sorted(pipes_dir.iterdir()):\n if not pipe_dir.is_dir() or pipe_dir.name.startswith(\".\"):\n continue\n pipe_md = pipe_dir / \"pipe.md\"\n if not pipe_md.exists():\n continue\n text = pipe_md.read_text(encoding=\"utf-8\")\n meta, body = _parse_frontmatter(text)\n if meta.get(\"enabled\", \"true\").lower() == \"false\":\n continue\n body = re.sub(r\"Read screenpipe skill first\\.?\\n?\", \"\", body).strip()\n pipes.append({\n \"id\": pipe_dir.name,\n \"title\": meta.get(\"title\", pipe_dir.name),\n \"description\": meta.get(\"description\", \"\"),\n \"icon\": meta.get(\"icon\", \"\"),\n \"schedule\": meta.get(\"schedule\", \"manual\"),\n \"featured\": meta.get(\"featured\", \"false\").lower() == \"true\",\n \"prompt\": body,\n })\n return pipes\n\n\ndef _build_system(d: date, stats: dict) -> str:\n from consumers.activity import app_time, browser_urls, ui_event_summary\n from consumers.ocr import deduplicated_text\n from consumers.audio import formatted_transcript\n\n apps = app_time(d)\n app_lines = \"\\n\".join(f\"- {a['app_name']}: {a['minutes']} min\" for a in apps[:20])\n\n urls = browser_urls(d, limit=20)\n url_lines = \"\\n\".join(f\"- {u['browser_url'][:100]} ({u['minutes']} min)\" for u in urls)\n\n ui_rows = ui_event_summary(d)\n ui_lines = \"\\n\".join(\n f\"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches\"\n for r in ui_rows[:15]\n )\n\n ocr_rows = deduplicated_text(d, chunk_minutes=5)\n ocr_lines = \"\\n\".join(\n f\"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}\"\n for r in ocr_rows[:100]\n )\n\n audio = formatted_transcript(d)\n if len(audio) > 3000:\n audio = audio[:3000]\n\n return f\"\"\"You are analyzing screenpipe data — recordings of a person's computer activity.\n\n## App usage (minutes per app):\n{app_lines or '(no app data)'}\n\n## Browser URLs visited:\n{url_lines or '(no browser data)'}\n\n## UI activity per app (clicks / keystrokes / app-switches):\n{ui_lines or '(no UI event data)'}\n\n## Screen content (sampled every 5 minutes):\n{ocr_lines or '(no screen data)'}\n\n## Audio / speech:\n{audio or '(no audio data)'}\n\nDate: {d}\nTotal frames recorded: {stats['total_frames']}\"\"\"\n\n\ndef run_pipe(\n pipe_id: str,\n for_date: date | None = None,\n api_key: str | None = None,\n pipes_dir: Path | None = None,\n) -> dict[str, Any]:\n import anthropic\n from consumers.activity import summary_stats\n\n d = for_date or date.today()\n key = api_key or os.environ.get(\"ANTHROPIC_API_KEY\", \"\")\n if not key:\n return {\"title\": \"Error\", \"content\": \"ANTHROPIC_API_KEY not set.\", \"date\": str(d)}\n\n _pipes_dir = pipes_dir or Path(os.environ.get(\"PIPES_DIR\", \"/data/pipes\"))\n all_pipes = {p[\"id\"]: p for p in load_pipes(_pipes_dir)}\n\n if pipe_id not in all_pipes:\n return {\"title\": \"Error\", \"content\": f\"Pipe not found: {pipe_id}\", \"date\": str(d)}\n\n pipe = all_pipes[pipe_id]\n stats = summary_stats(d)\n\n if stats[\"total_frames\"] == 0:\n return {\"title\": pipe[\"title\"], \"content\": f\"No screen data found for {d}.\", \"date\": str(d)}\n\n system = _build_system(d, stats)\n\n client = anthropic.Anthropic(api_key=key)\n message = client.messages.create(\n model=\"claude-haiku-4-5-20251001\",\n max_tokens=1024,\n system=system,\n messages=[{\"role\": \"user\", \"content\": pipe[\"prompt\"]}],\n )\n\n return {\n \"title\": pipe[\"title\"],\n \"content\": message.content[0].text,\n \"date\": str(d),\n \"stats\": stats,\n }","depth":25,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"Now add the API endpoints to","depth":23,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":"main.py","depth":24,"on_screen":false,"role_description":"text"},{"role":"AXStaticText","text":":","depth":23,"on_screen":false,"role_description":"text"}]...
|
6924779615564935865
|
-8905351981048886812
|
click
|
accessibility
|
NULL
|
Explorer (⇧⌘E) - 1 unsaved file
1
Search (⇧⌘F)
Explorer (⇧⌘E) - 1 unsaved file
1
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
Explorer Section: screenpipe [SSH: nas]
Explorer Section: screenpipe [SSH: nas]
SCREENPIPE [SSH: NAS]
#recycle
app
__pycache__
consumers
static
.env
cli.py
M
db.py
docker-compose.yml
Dockerfile
M
main.py
M
requirements.txt
M
data
logs
pipes
.gitignore
app_settings.json
archive.db
archive.db-bak
U
db.sqlite
db.sqlite-shm
db.sqlite-wal
screenpipe_sync_updated.sh
U
screenpipe_sync.sh
screenpipe.db
Outline Section
OUTLINE
OUTLINE
Timeline Section
TIMELINE
TIMELINE
app_settings.json, Editor Group 1
screenpipe_sync.sh, Editor Group 1
screenpipe_sync_updated.sh, preview, Editor Group 1
pipe.md, Editor Group 1
.env, Editor Group 1
# the source currently has; INSERT OR IGNORE handles the duplicate case.
run_sqlite_heredoc "speakers ($SRC_SPEAKERS rows, all-time)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.speakers ($SPEAKERS_COLS, install_id)
SELECT $SPEAKERS_COLS, '$INSTALL_ID' FROM main.speakers;
DETACH nas;
"
run_sqlite_heredoc "speaker_embeddings ($SRC_SEMB rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.speaker_embeddings ($SEMB_COLS, install_id)
SELECT $SEMB_COLS, '$INSTALL_ID' FROM main.speaker_embeddings;
DETACH nas;
"
run_sqlite_heredoc "audio_chunks ($SRC_ACHUNKS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.audio_chunks ($ACHUNKS_COLS, install_id)
SELECT $ACHUNKS_COLS, '$INSTALL_ID' FROM main.audio_chunks WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "audio_transcriptions ($SRC_ATRANS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.audio_transcriptions ($ATRANS_COLS, install_id)
SELECT $ATRANS_COLS_T, '$INSTALL_ID' FROM main.audio_transcriptions t
JOIN main.audio_chunks c ON t.audio_chunk_id = c.id
WHERE date(c.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "audio_tags ($SRC_ATAGS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.audio_tags ($ATAGS_COLS, install_id)
SELECT $ATAGS_COLS_AT, '$INSTALL_ID' FROM main.audio_tags at
JOIN main.audio_chunks c ON at.audio_chunk_id = c.id
WHERE date(c.timestamp) = '$TARGET_DATE';
DETACH nas;
"
# ─── FTS UPDATE ───────────────────────────────────────────────────────────
step "Updating FTS indexes"
run_sqlite_heredoc "elements_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.elements_fts(rowid, text, role)
SELECT e.id, e.text, e.role
FROM nas.elements e
JOIN nas.frames f ON e.frame_id = f.id AND e.install_id = f.install_id
WHERE date(f.timestamp) = '$TARGET_DATE'
AND e.install_id = '$INSTALL_ID'
AND e.text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "frames_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)
SELECT id, full_text, app_name, window_name, browser_url, id
FROM nas.frames
WHERE date(timestamp) = '$TARGET_DATE'
AND install_id = '$INSTALL_ID'
AND full_text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "ui_events_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)
SELECT id, text_content, app_name, window_title, element_name
FROM nas.ui_events
WHERE date(timestamp) = '$TARGET_DATE'
AND install_id = '$INSTALL_ID'
AND text_content IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "audio_transcriptions_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.audio_transcriptions_fts(rowid, transcription, device, speaker_id, id)
SELECT t.id, t.transcription, COALESCE(t.device,''), t.speaker_id, t.id
FROM nas.audio_transcriptions t
JOIN nas.audio_chunks c ON t.audio_chunk_id = c.id AND t.install_id = c.install_id
WHERE date(c.timestamp) = '$TARGET_DATE'
AND t.install_id = '$INSTALL_ID'
AND t.transcription IS NOT NULL AND t.transcription != '';
DETACH nas;
"
# ─── VERIFY ───────────────────────────────────────────────────────────────
step "Verifying DB"
V_FRAMES=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID';")
V_ELEMENTS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM elements WHERE install_id='$INSTALL_ID' AND frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID');")
V_UI=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID';")
V_OCR=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ocr_text WHERE install_id='$INSTALL_ID' AND frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID');")
V_MEETINGS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE' AND install_id='$INSTALL_ID';")
V_ACHUNKS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM audio_chunks WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID';")
V_ATRANS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM audio_transcriptions WHERE install_id='$INSTALL_ID' AND audio_chunk_id IN (SELECT id FROM audio_chunks WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID');")
V_ATAGS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM audio_tags WHERE install_id='$INSTALL_ID' AND audio_chunk_id IN (SELECT id FROM audio_chunks WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID');")
check "frames" "$V_FRAMES" "$SRC_FRAMES"
check "elements" "$V_ELEMENTS" "$SRC_ELEMENTS"
check "ui_events" "$V_UI" "$SRC_UI"
check "ocr_text" "$V_OCR" "$SRC_OCR"
check "meetings" "$V_MEETINGS" "$SRC_MEETINGS"
check "audio_chunks" "$V_ACHUNKS" "$SRC_ACHUNKS"
check "audio_transcriptions" "$V_ATRANS" "$SRC_ATRANS"
check "audio_tags" "$V_ATAGS" "$SRC_ATAGS"
fi
# ─── COPY FRAME DATA FOLDER ──────────────────────────────────────────────────
# Always runs regardless of DB sync status.
step "Copying frame data folder for $TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
mkdir -p "$NAS_DATA/$TARGET_DATE"
RSYNC_START=$(date +%s)
printf " %-36s " "rsync frames → NAS"
rsync -a --ignore-existing "$DATA_SRC/" "$NAS_DATA/$TARGET_DATE/" 2>>"$LOG_FILE"
RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))
COPIED_FILES=$(ls "$NAS_DATA/$TARGET_DATE" 2>/dev/null | grep -v '^audio$' | wc -l | tr -d ' ')
SRC_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
COPIED_SIZE=$(du -sh "$NAS_DATA/$TARGET_DATE" | cut -f1)
if [ "$COPIED_FILES" -ge "$SRC_FILES" ]; then
printf "\r %-36s ✓ %dm%02ds (%s files, %s)\n" \
"rsync frames → NAS" \
"$(( RSYNC_DUR / 60 ))" "$(( RSYNC_DUR % 60 ))" \
"$COPIED_FILES" "$COPIED_SIZE" | tee -a "$LOG_FILE"
else
printf "\r %-36s ✗ %s / %s files\n" \
"rsync frames → NAS" "$COPIED_FILES" "$SRC_FILES" | tee -a "$LOG_FILE"
fi
else
printf " %-36s %s\n" "rsync frames → NAS" "skipped (no source dir)"
fi
# ─── COPY AUDIO FILES ────────────────────────────────────────────────────────
# Audio is flat in ~/.screenpipe/data/ with the date in the filename, e.g.
# System Audio (output)_2026-05-11_13-48-12.mp4
# soundcore AeroClip (input)_2026-05-10_11-10-32.mp4
# Mirrored to $NAS_DATA/<date>/audio/ so each day's archive is self-contained.
step "Copying audio files for $TARGET_DATE"
shopt -s nullglob
AUDIO_FILES=( "$HOME/.screenpipe/data/"*_"${TARGET_DATE}"_*.mp4 )
shopt -u nullglob
if [ ${#AUDIO_FILES[@]} -gt 0 ]; then
mkdir -p "$NAS_DATA/$TARGET_DATE/audio"
RSYNC_START=$(date +%s)
printf " %-36s " "rsync audio → NAS"
rsync -a --ignore-existing "${AUDIO_FILES[@]}" "$NAS_DATA/$TARGET_DATE/audio/" 2>>"$LOG_FILE"
RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))
COPIED_AUDIO=$(ls "$NAS_DATA/$TARGET_DATE/audio" | wc -l | tr -d ' ')
AUDIO_SIZE=$(du -sh "$NAS_DATA/$TARGET_DATE/audio" | cut -f1)
printf "\r %-36s ✓ %dm%02ds (%s files, %s)\n" \
"rsync audio → NAS" \
"$(( RSYNC_DUR / 60 ))" "$(( RSYNC_DUR % 60 ))" \
"$COPIED_AUDIO" "$AUDIO_SIZE" | tee -a "$LOG_FILE"
else
printf " %-36s %s\n" "rsync audio → NAS" "skipped (no audio for date)"
fi
# ─── COPY LOGS ────────────────────────────────────────────────────────────────
step "Copying screenpipe logs for $TARGET_DATE"
NAS_LOGS="$NAS_MOUNT/logs"
mkdir -p "$NAS_LOGS"
shopt -s nullglob
LOG_FILES=( "$HOME/.screenpipe/screenpipe.$TARGET_DATE."*.log )
shopt -u nullglob
if [ ${#LOG_FILES[@]} -gt 0 ]; then
printf " %-36s " "rsync logs → NAS"
rsync -a "${LOG_FILES[@]}" "$NAS_LOGS/" 2>>"$LOG_FILE"
TOTAL_SIZE=$(du -ch "${LOG_FILES[@]}" | tail -1 | cut -f1)
printf "✓ %d file(s), %s\n" "${#LOG_FILES[@]}" "$TOTAL_SIZE" | tee -a "$LOG_FILE"
else
printf " %-36s %s\n" "rsync logs → NAS" "skipped (no matching logs)"
fi
# ─── SUMMARY ──────────────────────────────────────────────────────────────────
TOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))
DB_SIZE=$(du -sh "$NAS_DB" | cut -f1)
echo ""
log "Archive DB size: $DB_SIZE"
log "Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s"
log "Sync complete for $TARGET_DATE (install $INSTALL_ID)"
log "========================================"
rsync -a "$HOME/.screenpipe/sync.log" "$NAS_LOGS/sync.log" 2>/dev/null || true
# the source currently has; INSERT OR IGNORE handles the duplicate case.
run_sqlite_heredoc "speakers ($SRC_SPEAKERS rows, all-time)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.speakers ($SPEAKERS_COLS, install_id)
SELECT $SPEAKERS_COLS, '$INSTALL_ID' FROM main.speakers;
DETACH nas;
"
run_sqlite_heredoc "speaker_embeddings ($SRC_SEMB rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.speaker_embeddings ($SEMB_COLS, install_id)
SELECT $SEMB_COLS, '$INSTALL_ID' FROM main.speaker_embeddings;
DETACH nas;
"
run_sqlite_heredoc "audio_chunks ($SRC_ACHUNKS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.audio_chunks ($ACHUNKS_COLS, install_id)
SELECT $ACHUNKS_COLS, '$INSTALL_ID' FROM main.audio_chunks WHERE date(timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "audio_transcriptions ($SRC_ATRANS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.audio_transcriptions ($ATRANS_COLS, install_id)
SELECT $ATRANS_COLS_T, '$INSTALL_ID' FROM main.audio_transcriptions t
JOIN main.audio_chunks c ON t.audio_chunk_id = c.id
WHERE date(c.timestamp) = '$TARGET_DATE';
DETACH nas;
"
run_sqlite_heredoc "audio_tags ($SRC_ATAGS rows)" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.audio_tags ($ATAGS_COLS, install_id)
SELECT $ATAGS_COLS_AT, '$INSTALL_ID' FROM main.audio_tags at
JOIN main.audio_chunks c ON at.audio_chunk_id = c.id
WHERE date(c.timestamp) = '$TARGET_DATE';
DETACH nas;
"
# ─── FTS UPDATE ───────────────────────────────────────────────────────────
step "Updating FTS indexes"
run_sqlite_heredoc "elements_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.elements_fts(rowid, text, role)
SELECT e.id, e.text, e.role
FROM nas.elements e
JOIN nas.frames f ON e.frame_id = f.id AND e.install_id = f.install_id
WHERE date(f.timestamp) = '$TARGET_DATE'
AND e.install_id = '$INSTALL_ID'
AND e.text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "frames_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.frames_fts(rowid, full_text, app_name, window_name, browser_url, id)
SELECT id, full_text, app_name, window_name, browser_url, id
FROM nas.frames
WHERE date(timestamp) = '$TARGET_DATE'
AND install_id = '$INSTALL_ID'
AND full_text IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "ui_events_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.ui_events_fts(rowid, text_content, app_name, window_title, element_name)
SELECT id, text_content, app_name, window_title, element_name
FROM nas.ui_events
WHERE date(timestamp) = '$TARGET_DATE'
AND install_id = '$INSTALL_ID'
AND text_content IS NOT NULL;
DETACH nas;
"
run_sqlite_heredoc "audio_transcriptions_fts" "
ATTACH '$NAS_DB' AS nas;
INSERT OR IGNORE INTO nas.audio_transcriptions_fts(rowid, transcription, device, speaker_id, id)
SELECT t.id, t.transcription, COALESCE(t.device,''), t.speaker_id, t.id
FROM nas.audio_transcriptions t
JOIN nas.audio_chunks c ON t.audio_chunk_id = c.id AND t.install_id = c.install_id
WHERE date(c.timestamp) = '$TARGET_DATE'
AND t.install_id = '$INSTALL_ID'
AND t.transcription IS NOT NULL AND t.transcription != '';
DETACH nas;
"
# ─── VERIFY ───────────────────────────────────────────────────────────────
step "Verifying DB"
V_FRAMES=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM frames WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID';")
V_ELEMENTS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM elements WHERE install_id='$INSTALL_ID' AND frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID');")
V_UI=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ui_events WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID';")
V_OCR=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM ocr_text WHERE install_id='$INSTALL_ID' AND frame_id IN (SELECT id FROM frames WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID');")
V_MEETINGS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM meetings WHERE date(meeting_start) = '$TARGET_DATE' AND install_id='$INSTALL_ID';")
V_ACHUNKS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM audio_chunks WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID';")
V_ATRANS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM audio_transcriptions WHERE install_id='$INSTALL_ID' AND audio_chunk_id IN (SELECT id FROM audio_chunks WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID');")
V_ATAGS=$(sqlite3 "$NAS_DB" "SELECT COUNT(*) FROM audio_tags WHERE install_id='$INSTALL_ID' AND audio_chunk_id IN (SELECT id FROM audio_chunks WHERE date(timestamp) = '$TARGET_DATE' AND install_id='$INSTALL_ID');")
check "frames" "$V_FRAMES" "$SRC_FRAMES"
check "elements" "$V_ELEMENTS" "$SRC_ELEMENTS"
check "ui_events" "$V_UI" "$SRC_UI"
check "ocr_text" "$V_OCR" "$SRC_OCR"
check "meetings" "$V_MEETINGS" "$SRC_MEETINGS"
check "audio_chunks" "$V_ACHUNKS" "$SRC_ACHUNKS"
check "audio_transcriptions" "$V_ATRANS" "$SRC_ATRANS"
check "audio_tags" "$V_ATAGS" "$SRC_ATAGS"
fi
# ─── COPY FRAME DATA FOLDER ──────────────────────────────────────────────────
# Always runs regardless of DB sync status.
step "Copying frame data folder for $TARGET_DATE"
if [ -d "$DATA_SRC" ]; then
mkdir -p "$NAS_DATA/$TARGET_DATE"
RSYNC_START=$(date +%s)
printf " %-36s " "rsync frames → NAS"
rsync -a --ignore-existing "$DATA_SRC/" "$NAS_DATA/$TARGET_DATE/" 2>>"$LOG_FILE"
RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))
COPIED_FILES=$(ls "$NAS_DATA/$TARGET_DATE" 2>/dev/null | grep -v '^audio$' | wc -l | tr -d ' ')
SRC_FILES=$(ls "$DATA_SRC" | wc -l | tr -d ' ')
COPIED_SIZE=$(du -sh "$NAS_DATA/$TARGET_DATE" | cut -f1)
if [ "$COPIED_FILES" -ge "$SRC_FILES" ]; then
printf "\r %-36s ✓ %dm%02ds (%s files, %s)\n" \
"rsync frames → NAS" \
"$(( RSYNC_DUR / 60 ))" "$(( RSYNC_DUR % 60 ))" \
"$COPIED_FILES" "$COPIED_SIZE" | tee -a "$LOG_FILE"
else
printf "\r %-36s ✗ %s / %s files\n" \
"rsync frames → NAS" "$COPIED_FILES" "$SRC_FILES" | tee -a "$LOG_FILE"
fi
else
printf " %-36s %s\n" "rsync frames → NAS" "skipped (no source dir)"
fi
# ─── COPY AUDIO FILES ────────────────────────────────────────────────────────
# Audio is flat in ~/.screenpipe/data/ with the date in the filename, e.g.
# System Audio (output)_2026-05-11_13-48-12.mp4
# soundcore AeroClip (input)_2026-05-10_11-10-32.mp4
# Mirrored to $NAS_DATA/<date>/audio/ so each day's archive is self-contained.
step "Copying audio files for $TARGET_DATE"
shopt -s nullglob
AUDIO_FILES=( "$HOME/.screenpipe/data/"*_"${TARGET_DATE}"_*.mp4 )
shopt -u nullglob
if [ ${#AUDIO_FILES[@]} -gt 0 ]; then
mkdir -p "$NAS_DATA/$TARGET_DATE/audio"
RSYNC_START=$(date +%s)
printf " %-36s " "rsync audio → NAS"
rsync -a --ignore-existing "${AUDIO_FILES[@]}" "$NAS_DATA/$TARGET_DATE/audio/" 2>>"$LOG_FILE"
RSYNC_DUR=$(( $(date +%s) - RSYNC_START ))
COPIED_AUDIO=$(ls "$NAS_DATA/$TARGET_DATE/audio" | wc -l | tr -d ' ')
AUDIO_SIZE=$(du -sh "$NAS_DATA/$TARGET_DATE/audio" | cut -f1)
printf "\r %-36s ✓ %dm%02ds (%s files, %s)\n" \
"rsync audio → NAS" \
"$(( RSYNC_DUR / 60 ))" "$(( RSYNC_DUR % 60 ))" \
"$COPIED_AUDIO" "$AUDIO_SIZE" | tee -a "$LOG_FILE"
else
printf " %-36s %s\n" "rsync audio → NAS" "skipped (no audio for date)"
fi
# ─── COPY LOGS ────────────────────────────────────────────────────────────────
step "Copying screenpipe logs for $TARGET_DATE"
NAS_LOGS="$NAS_MOUNT/logs"
mkdir -p "$NAS_LOGS"
shopt -s nullglob
LOG_FILES=( "$HOME/.screenpipe/screenpipe.$TARGET_DATE."*.log )
shopt -u nullglob
if [ ${#LOG_FILES[@]} -gt 0 ]; then
printf " %-36s " "rsync logs → NAS"
rsync -a "${LOG_FILES[@]}" "$NAS_LOGS/" 2>>"$LOG_FILE"
TOTAL_SIZE=$(du -ch "${LOG_FILES[@]}" | tail -1 | cut -f1)
printf "✓ %d file(s), %s\n" "${#LOG_FILES[@]}" "$TOTAL_SIZE" | tee -a "$LOG_FILE"
else
printf " %-36s %s\n" "rsync logs → NAS" "skipped (no matching logs)"
fi
# ─── SUMMARY ──────────────────────────────────────────────────────────────────
TOTAL_ELAPSED=$(( $(date +%s) - SCRIPT_START ))
DB_SIZE=$(du -sh "$NAS_DB" | cut -f1)
echo ""
log "Archive DB size: $DB_SIZE"
log "Total time: $(( TOTAL_ELAPSED / 60 ))m$(( TOTAL_ELAPSED % 60 ))s"
log "Sync complete for $TARGET_DATE (install $INSTALL_ID)"
log "========================================"
rsync -a "$HOME/.screenpipe/sync.log" "$NAS_LOGS/sync.log" 2>/dev/null || true
Implement and run pipe l…, Editor Group 2
Problems (⇧⌘M)
PROBLEMS
Output (⇧⌘U)
OUTPUT
Debug Console (⇧⌘Y)
DEBUG CONSOLE
Terminal (⌃`)
TERMINAL
Ports - 1 forwarded port
PORTS
1
remote SSH: nas
SSH: nas
screenpipe (Git) - master*, Checkout Branch/Tag...
master*
screenpipe (Git) - Synchronize Changes
No Problems
0
0
Forwarded Ports: 8766
1
Notifications
Sign In
Sign In
Shell Script
Editor Language Status: Inline Suggestions, next: $(copilot) No inline suggestion available, Inline suggestions
LF
UTF-8
Spaces: 2
Ln 675, Col 1
git-commit Not Committed Yet
Not Committed Yet
No results found
Implement and run pipe logic
Session history
New session
Message actions
main.py
main.py
lets implement logic with pipes. how can I run it?
Thinking
Thinking
Let me look at the current project structure to understand what's already in place.
Bash
List project files
IN
find /volume1/screenpipe -type f | head -50 && echo "---" && ls /volume1/screenpipe
Copy code to clipboard
OUT
/volume1/screenpipe/.DS_Store
/volume1/screenpipe/screenpipe.db
/volume1/screenpipe/screenpipe_sync.sh
/volume1/screenpipe/app_settings.json
/volume1/screenpipe/.gitignore
/volume1/screenpipe/archive.db
/volume1/screenpipe/db.sqlite
/volume1/screenpipe/db.sqlite-wal
/volume1/screenpipe/db.sqlite-shm
/volume1/screenpipe/#recycle/desktop.ini
/volume1/screenpipe/#recycle/db.sqlite
/volume1/screenpipe/#recycle/Copy #1 of db.sqlite
/volume1/screenpipe/#recycle/.DS_Store
/volume1/screenpipe/#recycle/Copy #2 of db.sqlite
/volume1/screenpipe/#recycle/archive.db
/volume1/screenpipe/#recycle/Copy #1 of archive.db
/volume1/screenpipe/#recycle/Copy #2 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of archive.db
/volume1/screenpipe/#recycle/Copy #4 of archive.db
/volume1/screenpipe/#recycle/Copy #5 of archive.db
/volume1/screenpipe/#recycle/Copy #3 of db.sqlite
/volume1/screenpipe/#recycle/Copy #4 of db.sqlite
/volume1/screenpipe/#recycle/Copy #6 of archive.db
/volume1/screenpipe/#recycle/test.txt
/volume1/screenpipe/#recycle/Copy #7 of archive.db
/volume1/screenpipe/#recycle/Copy #8 of archive.db
/volume1/screenpipe/#recycle/archive.db-journal
/volume1/screenpipe/#recycle/Copy #1 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #2 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #3 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #4 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #6 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #7 of archive.db-journal
/volume1/screenpipe/#recycle/Copy #5 of db.sqlite
/volume1/screenpipe/pipes/.DS_Store
/volume1/screenpipe/app/.env
/volume1/screenpipe/app/cli.py
/volume1/screenpipe/app/.DS_Store
/volume1/screenpipe/app/db.py
/volume1/screenpipe/app/docker-compose.yml
/volume1/screenpipe/app/main.py
/volume1/screenpipe/app/requirements.txt
/volume1/screenpipe/app/Dockerfile
/volume1/screenpipe/data/.DS_Store
/volume1/screenpipe/.git/description
/volume1/screenpipe/.git/HEAD
/volume1/screenpipe/.git/index
/volume1/screenpipe/.git/COMMIT_EDITMSG
/volume1/screenpipe/#recycle/data/.DS_Store
---
app
app_settings.json
archive.db
data
db.sqlite
db.sqlite-shm
db.sqlite-wal
pipes
#recycle
screenpipe.db
screenpipe_sync.sh
Read
main.py
main.py
Bash
Check pipes directory and docker-compose
IN
ls /volume1/screenpipe/pipes/ && ls /volume1/screenpipe/app/ && cat /volume1/screenpipe/app/docker-compose.yml
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
cli.py
consumers
db.py
docker-compose.yml
Dockerfile
main.py
__pycache__
requirements.txt
static
services:
screenpipe-app:
build: .
container_name: screenpipe-app
restart: unless-stopped
ports:
- "8766:8000"
volumes:
- /volume1/screenpipe:/data
env_file:
- .env
environment:
TZ: Europe/Sofia
DB_PATH: /data/db.sqlite
sqlite-web-archive:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-archive
restart: unless-stopped
ports:
- "8767:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/archive.db"]
sqlite-web-live:
image: ghcr.io/coleifer/sqlite-web:latest
container_name: screenpipe-sqlweb-live
restart: unless-stopped
ports:
- "8768:8080"
volumes:
- /volume1/screenpipe:/data
command: ["-H", "[IP_ADDRESS]", "-r", "/data/db.sqlite"]
Read
requirements.txt
requirements.txt
Bash
Inspect a pipe directory
IN
ls /volume1/screenpipe/pipes/day-recap/ && cat /volume1/screenpipe/pipes/day-recap/pipe.json 2>/dev/null || ls /volume1/screenpipe/pipes/day-recap/
Copy code to clipboard
OUT
pipe.md
pipe.md
Read
cli.py
cli.py
Bash
List all pipes and their contents
IN
ls /volume1/screenpipe/pipes/ && for d in /volume1/screenpipe/pipes/*/; do echo "=== $d ==="; ls "$d"; done
Copy code to clipboard
OUT
ai-habits
day-recap
meeting-summary
standup-update
time-breakdown
video-export
=== /volume1/screenpipe/pipes/ai-habits/ ===
pipe.md
=== /volume1/screenpipe/pipes/day-recap/ ===
pipe.md
=== /volume1/screenpipe/pipes/meeting-summary/ ===
pipe.md
=== /volume1/screenpipe/pipes/standup-update/ ===
pipe.md
=== /volume1/screenpipe/pipes/time-breakdown/ ===
pipe.md
=== /volume1/screenpipe/pipes/video-export/ ===
pipe.md
Bash
Read pipe markdown files
IN
cat /volume1/screenpipe/pipes/day-recap/pipe.md && echo "===" && cat /volume1/screenpipe/pipes/meeting-summary/pipe.md 2>/dev/null | head -50
Copy code to clipboard
OUT
---
schedule: manual
enabled: true
template: true
title: Day Recap
description: "Today's accomplishments, key moments, and unfinished work"
icon: "📋"
featured: true
---
Analyze my screen and audio recordings from today (last 16 hours only).
Read screenpipe skill first.
Use this exact format:
## Summary
One sentence: what I mainly did today.
## Accomplishments
- Top 3 things I finished, with timestamps (e.g. "2:30 PM")
- Name specific apps, files, or projects
## Key Moments
- Important things I saw, said, or heard — with timestamps
## Unfinished Work
- What I should continue tomorrow — name the app/file/task
## Patterns
- Apps I used most, topics that came up repeatedly
Only report what you can verify from the data. End with: "**Next step:** [most important thing to continue]"
===
---
schedule: manual
enabled: true
template: true
title: Meeting Summary
description: "Summarize meeting transcript with key takeaways and action items"
icon: "🤝"
featured: false
---
Summarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.
Read screenpipe skill first.
Use this exact format:
## Meeting Summary
One sentence: what this meeting was about.
## Key Takeaways
- Top 3-5 important points discussed
- Include who said what when relevant
## Action Items
- [ ] Task — assigned to whom, deadline if mentioned
- [ ] Task — assigned to whom
## Decisions Made
- List any decisions or agreements reached
## Open Questions
- Anything unresolved or needing follow-up
Keep it concise and actionable.
Thinking
Thinking
Bash
Read summary consumer
IN
ls /volume1/screenpipe/app/consumers/ && cat /volume1/screenpipe/app/consumers/summary.py
Copy code to clipboard
OUT
activity.py
audio.py
elements.py
__init__.py
interactions.py
ocr.py
__pycache__
report.py
summary.py
"""AI summary generator using Claude."""
import os
from datetime import date
from typing import Any
from consumers.activity import app_time, summary_stats, browser_urls, ui_event_summary
from consumers.ocr import deduplicated_text
from consumers.audio import formatted_transcript
SUMMARY_TYPES = {
"day_recap": {
"title": "Day Recap",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
## Audio/speech:
{audio}
Write a concise day recap using EXACTLY this format:
## Summary
One sentence: what I mainly worked on today.
## Accomplishments
- Top 3 things I finished, with approximate times
- Name specific apps, files, or projects
## Key Moments
- Important things seen or heard, with timestamps
## Unfinished Work
- What to continue tomorrow
## Patterns
- Apps used most, topics that came up repeatedly
Only report what you can verify from the data. End with:
**Next step:** [most important thing to continue]""",
},
"standup": {
"title": "Standup Update",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
## Audio/speech:
{audio}
Write a brief standup update:
**Yesterday:** What I worked on (2-3 bullets)
**Today:** What I plan to continue (1-2 bullets)
**Blockers:** Any issues observed (or "None")
Keep it under 150 words. Only report what's verifiable from the data.""",
},
"focus_time": {
"title": "Focus & Distraction Analysis",
"prompt": """\
You are analyzing a person's computer activity for the day.
## App usage (minutes per app):
{app_time}
## Browser URLs visited:
{browser_urls}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_events}
## Screen content (sampled every 5 minutes):
{ocr_text}
Analyze focus vs distraction patterns:
## Deep Work Periods
- When and how long were sustained focus sessions?
- What was being worked on?
## Distractions
- Which apps/sites were used recreationally?
- How much time was lost to context switching?
## Recommendations
- 2-3 concrete suggestions to improve focus tomorrow
Be specific with times and app names.""",
},
}
def _build_context(for_date: date) -> dict[str, str]:
apps = app_time(for_date)
app_lines = "\n".join(f"- {a['app_name']}: {a['minutes']} min" for a in apps[:20])
urls = browser_urls(for_date, limit=20)
url_lines = "\n".join(
f"- {u['browser_url'][:100]} ({u['minutes']} min)" for u in urls
)
ui_rows = ui_event_summary(for_date)
ui_lines = "\n".join(
f"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches"
for r in ui_rows[:15]
)
ocr_rows = deduplicated_text(for_date, chunk_minutes=5)
ocr_lines = "\n".join(
f"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}"
for r in ocr_rows[:100]
)
audio = formatted_transcript(for_date)
return {
"app_time": app_lines or "(no app data)",
"browser_urls": url_lines or "(no browser data)",
"ui_events": ui_lines or "(no UI event data)",
"ocr_text": ocr_lines or "(no screen data)",
"audio": audio[:3000] if len(audio) > 3000 else audio,
}
def generate(
summary_type: str = "day_recap",
for_date: date | None = None,
api_key: str | None = None,
) -> dict[str, Any]:
"""Generate an AI summary. Returns dict with 'title', 'content', 'date'."""
import anthropic
d = for_date or date.today()
key = api_key or os.environ.get("ANTHROPIC_API_KEY", "")
if not key:
return {
"title": "Error",
"content": "ANTHROPIC_API_KEY not set. Add it to your .env file.",
"date": str(d),
}
spec = SUMMARY_TYPES.get(summary_type)
if not spec:
return {"title": "Error", "content": f"Unknown summary type: {summary_type}", "date": str(d)}
stats = summary_stats(d)
if stats["total_frames"] == 0:
return {
"title": spec["title"],
"content": f"No screen data found for {d}.",
"date": str(d),
}
ctx = _build_context(d)
prompt = spec["prompt"].format(**ctx)
client = anthropic.Anthropic(api_key=key)
message = client.messages.create(
model="claude-haiku-4-5-20251001",
max_tokens=1024,
messages=[{"role": "user", "content": prompt}],
)
return {
"title": spec["title"],
"content": message.content[0].text,
"date": str(d),
"stats": stats,
}
Thinking
Thinking
Bash
Read all pipe.md files
IN
for f in /volume1/screenpipe/pipes/*/pipe.md; do echo "=== $f ==="; cat "$f"; echo; done
Copy code to clipboard
OUT
=== /volume1/screenpipe/pipes/ai-habits/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: AI Habits
description: "How you use AI tools — patterns and insights"
icon: "🤖"
featured: true
---
Search my recordings from the last 24 hours for AI tool usage. Use app_name filter for each tool separately: ChatGPT, Claude, Copilot, Cursor, Gemini, Perplexity. Use limit=5 per search, max 6 searches total.
Read screenpipe skill first.
Use this exact format:
## AI Tools Used
- List each tool with approximate time spent (e.g. "Claude: ~45min")
## What I Used Them For
- For each tool: coding, writing, research, or brainstorming
## Usage Patterns
- Do I switch between tools? Use them in bursts or steadily?
## Effectiveness
- Which tool appeared alongside completed work vs. abandoned attempts
If no AI usage is found, say so clearly. End with: "**Tip:** [one suggestion to use AI tools more effectively]"
=== /volume1/screenpipe/pipes/day-recap/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Day Recap
description: "Today's accomplishments, key moments, and unfinished work"
icon: "📋"
featured: true
---
Analyze my screen and audio recordings from today (last 16 hours only).
Read screenpipe skill first.
Use this exact format:
## Summary
One sentence: what I mainly did today.
## Accomplishments
- Top 3 things I finished, with timestamps (e.g. "2:30 PM")
- Name specific apps, files, or projects
## Key Moments
- Important things I saw, said, or heard — with timestamps
## Unfinished Work
- What I should continue tomorrow — name the app/file/task
## Patterns
- Apps I used most, topics that came up repeatedly
Only report what you can verify from the data. End with: "**Next step:** [most important thing to continue]"
=== /volume1/screenpipe/pipes/meeting-summary/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Meeting Summary
description: "Summarize meeting transcript with key takeaways and action items"
icon: "🤝"
featured: false
---
Summarize the meeting transcript provided in the context. Include key takeaways and action items. If the meeting is marked as ongoing, note that and summarize what's available so far.
Read screenpipe skill first.
Use this exact format:
## Meeting Summary
One sentence: what this meeting was about.
## Key Takeaways
- Top 3-5 important points discussed
- Include who said what when relevant
## Action Items
- [ ] Task — assigned to whom, deadline if mentioned
- [ ] Task — assigned to whom
## Decisions Made
- List any decisions or agreements reached
## Open Questions
- Anything unresolved or needing follow-up
Keep it concise and actionable.
=== /volume1/screenpipe/pipes/standup-update/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Standup Update
description: "What you did, what's next, and any blockers"
icon: "🏢"
featured: true
---
Based on my recordings from the last 24 hours, generate a standup update. Use limit=10 per search, max 3 searches total.
Read screenpipe skill first.
Use this exact format:
## Yesterday
- What I worked on (name specific projects, files, tools, PRs)
## Today
- What I will work on next (based on unfinished tasks and recent activity)
## Blockers
- Issues I hit — errors, slow builds, waiting on someone
- If no blockers, write "None"
Keep it under 150 words. Copy-paste ready for a team standup.
=== /volume1/screenpipe/pipes/time-breakdown/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Time Breakdown
description: "Where your time went — by app, project, and category"
icon: "⏱"
featured: false
---
Analyze my app usage from today (last 12 hours). Use limit=10 per search, max 4 searches. Prefer /raw_sql with COUNT/GROUP BY queries.
Read screenpipe skill first.
Use this exact format with durations and percentages:
## By Application
- List each app with duration and percentage, sorted by time (e.g. "VS Code: 2h 15min (28%)")
## By Category
- Group into: coding, meetings, browsing, writing, communication, other
- Show hours and percentage per category
## By Project
- Group related activities by project/topic. Name specific repos or tasks.
## Productivity Score
- Calculate: focused_work_hours / total_hours as a percentage
- Focused = coding + writing. Unfocused = browsing + switching.
End with: "**Suggestion:** [one specific change to improve tomorrow's productivity]"
=== /volume1/screenpipe/pipes/video-export/pipe.md ===
---
schedule: manual
enabled: true
template: true
title: Export Video Clip
description: "Create a video of your recent screen activity"
icon: "🎬"
featured: false
---
Export a video of my screen activity from the last 5 minutes.
Read screenpipe skill first.
Use the POST /frames/export endpoint with the time range and fps=1.0. Then show me the exported video file path as an inline code block so I can watch it.
If the export is large, suggest a lower fps or shorter time range.
Thinking
Thinking
Now I have a clear picture. The pipes are markdown prompt templates in
/volume1/screenpipe/pipes/
, but there's no code to actually load and run them —
consumers/summary.py
has its own hardcoded prompts instead.
Here's what I'll implement:
consumers/pipes.py
— dynamically loads pipe.md files and runs them via Claude (data injected as system message, pipe body as user prompt)
main.py
— two new endpoints:
GET /api/pipes
and
POST /api/pipes/{pipe_id}/run
cli.py
— a
pipe
command to run pipes from the terminal
Let me build it:
Bash
Check browser_urls signature
IN
cat /volume1/screenpipe/app/consumers/activity.py | grep "def browser_urls" -A 5
Copy code to clipboard
OUT
def browser_urls(
for_date: date | None = None,
app_name: str | None = None,
ts_from: str | None = None,
ts_to: str | None = None,
limit: int = 30,
Write
pipes.py
pipes.py
143 lines
"""Dynamic pipe loader and runner."""
import os
import re
from datetime import date
from pathlib import Path
from typing import Any
def _parse_frontmatter(text: str) -> tuple[dict, str]:
if not text.startswith("---"):
return {}, text
try:
end = text.index("---", 3)
except ValueError:
return {}, text
fm_text = text[3:end].strip()
body = text[end + 3:].strip()
meta: dict = {}
for line in fm_text.splitlines():
if ":" in line:
k, _, v = line.partition(":")
meta[k.strip()] = v.strip().strip('"')
return meta, body
def load_pipes(pipes_dir: Path) -> list[dict]:
if not pipes_dir.exists():
return []
pipes = []
for pipe_dir in sorted(pipes_dir.iterdir()):
if not pipe_dir.is_dir() or pipe_dir.name.startswith("."):
continue
pipe_md = pipe_dir / "pipe.md"
if not pipe_md.exists():
continue
text = pipe_md.read_text(encoding="utf-8")
meta, body = _parse_frontmatter(text)
if meta.get("enabled", "true").lower() == "false":
continue
body = re.sub(r"Read screenpipe skill first\.?\n?", "", body).strip()
pipes.append({
"id": pipe_dir.name,
"title": meta.get("title", pipe_dir.name),
"description": meta.get("description", ""),
"icon": meta.get("icon", ""),
"schedule": meta.get("schedule", "manual"),
"featured": meta.get("featured", "false").lower() == "true",
"prompt": body,
})
return pipes
def _build_system(d: date, stats: dict) -> str:
from consumers.activity import app_time, browser_urls, ui_event_summary
from consumers.ocr import deduplicated_text
from consumers.audio import formatted_transcript
apps = app_time(d)
app_lines = "\n".join(f"- {a['app_name']}: {a['minutes']} min" for a in apps[:20])
urls = browser_urls(d, limit=20)
url_lines = "\n".join(f"- {u['browser_url'][:100]} ({u['minutes']} min)" for u in urls)
ui_rows = ui_event_summary(d)
ui_lines = "\n".join(
f"- {r['app_name']}: {r['clicks']} clicks, {r['keystrokes']} keys, {r['switches']} switches"
for r in ui_rows[:15]
)
ocr_rows = deduplicated_text(d, chunk_minutes=5)
ocr_lines = "\n".join(
f"[{r['bucket']}] {r['app_name']} / {r['window_name'] or ''}: {r['text'][:200]}"
for r in ocr_rows[:100]
)
audio = formatted_transcript(d)
if len(audio) > 3000:
audio = audio[:3000]
return f"""You are analyzing screenpipe data — recordings of a person's computer activity.
## App usage (minutes per app):
{app_lines or '(no app data)'}
## Browser URLs visited:
{url_lines or '(no browser data)'}
## UI activity per app (clicks / keystrokes / app-switches):
{ui_lines or '(no UI event data)'}
## Screen content (sampled every 5 minutes):
{ocr_lines or '(no screen data)'}
## Audio / speech:
{audio or '(no audio data)'}
Date: {d}
Total frames recorded: {stats['total_frames']}"""
def run_pipe(
pipe_id: str,
for_date: date | None = None,
api_key: str | None = None,
pipes_dir: Path | None = None,
) -> dict[str, Any]:
import anthropic
from consumers.activity import summary_stats
d = for_date or date.today()
key = api_key or os.environ.get("ANTHROPIC_API_KEY", "")
if not key:
return {"title": "Error", "content": "ANTHROPIC_API_KEY not set.", "date": str(d)}
_pipes_dir = pipes_dir or Path(os.environ.get("PIPES_DIR", "/data/pipes"))
all_pipes = {p["id"]: p for p in load_pipes(_pipes_dir)}
if pipe_id not in all_pipes:
return {"title": "Error", "content": f"Pipe not found: {pipe_id}", "date": str(d)}
pipe = all_pipes[pipe_id]
stats = summary_stats(d)
if stats["total_frames"] == 0:
return {"title": pipe["title"], "content": f"No screen data found for {d}.", "date": str(d)}
system = _build_system(d, stats)
client = anthropic.Anthropic(api_key=key)
message = client.messages.create(
model="claude-haiku-4-5-20251001",
max_tokens=1024,
system=system,
messages=[{"role": "user", "content": pipe["prompt"]}],
)
return {
"title": pipe["title"],
"content": message.content[0].text,
"date": str(d),
"stats": stats,
}
Now add the API endpoints to
main.py
:...
|
21404
|
NULL
|
NULL
|
NULL
|
|
21432
|
936
|
27
|
2026-05-11T17:50:38.002154+00:00
|
/Users/lukas/.screenpipe/data/data/2026-05-11/1778 /Users/lukas/.screenpipe/data/data/2026-05-11/1778521838002_m1.jpg...
|
Code
|
screenpipe_sync.sh — screenpipe [SSH: nas]
|
1
|
NULL
|
monitor_1
|
NULL
|
NULL
|
NULL
|
NULL
|
Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧ Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER...
|
[{"role":"AXRadioButton","text [{"role":"AXRadioButton","text":"Explorer (⇧⌘E)","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":true,"is_expanded":true},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Search (⇧⌘F)","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Source Control (⌃⇧G) - 10 pending changes","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"10","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Run and Debug (⇧⌘D)","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Remote Explorer","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Extensions (⇧⌘X) - 2 require update","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXStaticText","text":"","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXStaticText","text":"2","depth":22,"on_screen":true,"role_description":"text"},{"role":"AXRadioButton","text":"Claude Code","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXRadioButton","text":"Containers","depth":19,"on_screen":true,"role_description":"tab","subrole":"AXTabButton","is_enabled":true,"is_focused":false,"is_selected":false,"is_expanded":false},{"role":"AXHeading","text":"EXPLORER","depth":17,"on_screen":true,"role_description":"heading"},{"role":"AXStaticText","text":"EXPLORER","depth":18,"on_screen":true,"role_description":"text"}]...
|
-4483864907854100091
|
-5588096711328710260
|
app_switch
|
hybrid
|
NULL
|
Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧ Explorer (⇧⌘E)
Search (⇧⌘F)
Source Control (⌃⇧G) - 10 pending changes
10
Run and Debug (⇧⌘D)
Remote Explorer
Extensions (⇧⌘X) - 2 require update
2
Claude Code
Containers
EXPLORER
EXPLORER
iTerm2ShellEditViewSessionScriptsProfilesWindowHelpDOCKER-rw-r--r=--rw-r--r---rw-r--r---rw-r--r---rw-r--r---rw-r--r---rw-r--r---rw-r--r---rw-r--r---rw-r--r---rw-r--r---rw-r--r---rw-r--r---rw-r--r---rw-r--r---rw-r--r---rw-r--r---rw-r--r---rw-r--r---rw-r--r---rw-r--r---rw-r--r---rw-r--r---rw-r--r---rw-r--r---rw-r--r---rw-r--r---rw-r--r---rw-r--r---rw-r--r---rw-r--r---rw-r--r---rw-r--r---rw-r--r---rw-r--r---rw-r--r---rw-r--r---rw-r--r--₴811 lukaslukaslukas111lukaslukaslukaslukaslukaslukaslukas1lukaslukaslukaslukaslukaslukaslukas1lukas1lukas1 lukaslukaslukaslukas1lukaslukaslukaslukas1lukaslukaslukaslukaslukaslukaslukaslukaslukaslukaslukaslukaslukaslukaslukaslukaslukaslukasstaffstaffstaffstaffstaffstaffstaffstaffstaffstaffstaffstaffstaffstaffstaffstaffstaffstaffstaffstaffstaffstaffstaffstaffstaffstaffstaffstaffstaffstaffstaffstaffstaffstaffstaffstaffstaffstaffstaffstaffstaffstaffstaffstaffstaff-zshDEV (docker)₴2APP (-zsh)883-zsh|728611May14:52SystemAudio (output)_2026-05-11_11-51-57.mp4462011May14:52462011SystemAudio (output)_2026-05-11_11-52-19.mp4May14:53SystemAudio (output)_2026-05-11_11-52-42.mp4462811May14:53SystemAudio (output)_2026-05-11_11-53-05.mp4462011May14:53462811SystemAudio (output)_2026-05-11_11-53-27.mp4May14:54SystemAudio (output)_2026-05-11_11-53-49.mp4462011May14:54SystemAudio (output)_2026-05-11_11-54-12.mp4462011May14:54SystemAudio (output)_2026-05-11_11-54-34.mp4462811May14:55SystemAudio (output)_2026-05-11_11-54-57.mp4462011May14:55SystemAudio (output)_2026-05-11_11-55-19.mp4462011May14:56System462011May14:56SystemAudio (output)_2026-05-11_11-55-42.mp4Audio (output)_2026-05-11_11-56-04.mp4462011May14:56SystemAudio (output)_2026-05-11_11-56-26.mp4462011May14:57SystemAudio (output)_2026-05-11_11-56-49.mp4462011May14:57462011May14:57SystemAudio (output)_2026-05-11_11-57-11.mp4SystemAudio (output)_2026-05-11_11-57-34.mp4462011May14:58System462011Audio (output)_2026-05-11_11-57-56.mp4May14:58SystemAudio (output)_2026-05-11_11-58-19.mp4462011May14:59System Audio (output)_2026-05-11_11-58-41.mp42105011May14:59System Audio (output)_2026-05-11_11-59-04.mp4462811May14:59462011May15:00System Audio (output)_2026-05-11_11-59-26.mp4462011System Audio (output)_2026-05-11_11-59-49.mp4May15:00System Audio (output)_2026-05-11_12-00-11.mp44628 11 May15:00SystemAudio (output)_2026-05-11_12-00-34.mp4462011May15:01462011SystemAudio (output)_2026-05-11_12-00-56.mp4May15:01SystemAudio (output)_2026-05-11_12-01-19.mp4462811May15:02SystemAudio (output)_2026-05-11_12-01-41.mp4462811May15:02SystemAudio (output)_2026-05-11_12-02-04.mp4462811May15:02SystemAudio (output)_2026-05-11_12-02-27.mp4462011May15:03System Audio (output)_2026-05-11_12-02-49.mp4462811May15:03System Audio (output)_2026-05-11_12-03-12.mp4462011May15:03System Audio (output)_2026-05-11_12-03-35.mp4462811May15:04System Audio (output)_2026-05-11_12-03-57.mp4462011May15:04System Audio (output)_2026-05-11_12-04-20.mp4462011May15:05System Audio (output)_2026-05-11_12-04-42.mp4462011May15:05System Audio (output)_2026-05-11_12-05-04.mp4462011May15:05System Audio (output)_2026-05-11_12-05-27.mp4462011May15:06System Audio (output)_2026-05-11_12-05-49.mp4462011May15:06SystemAudio (output)_2026-05-11_12-06-12.mp4462011May15:06System Audio (output)_2026-05-11_12-06-35.mp4462811May15:07System Audio (output)_2026-05-11_12-06-57.mp4462011May15:07System Audio (output)_2026-05-11_12-07-20.mp4462011May15:08System Audio (output)_2026-05-11_12-07-42.mp4462011 May15:08System Audio (output)_2026-05-11_12-08-05 .mp4462811 May15:08 System Audio (output)_2026-05-11_12-08-27.mp484-zsh*5screenpipe"100% <8• Mon 11 May 20:50:37181O ₴6-zshX7...
|
NULL
|
NULL
|
NULL
|
NULL
|