Auto-sync: 2026-02-13 13:26:50
This commit is contained in:
12
skills/macos-notes/SKILL.md
Normal file
12
skills/macos-notes/SKILL.md
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
# macOS Notes
|
||||||
|
Description: Manage Apple Notes via AppleScript.
|
||||||
|
|
||||||
|
## Tools
|
||||||
|
|
||||||
|
### list
|
||||||
|
Description: List recent notes or search by title.
|
||||||
|
Command: osascript skills/macos-notes/list_notes.scpt "{{query}}"
|
||||||
|
|
||||||
|
### add
|
||||||
|
Description: Create a new note or append to an existing one.
|
||||||
|
Command: osascript skills/macos-notes/add_note.scpt "{{title}}" "{{body}}"
|
||||||
33
skills/macos-notes/add_note.scpt
Normal file
33
skills/macos-notes/add_note.scpt
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
#!/usr/bin/osascript
|
||||||
|
on run argv
|
||||||
|
if (count of argv) < 2 then
|
||||||
|
return "Usage: add_note.scpt <title> <body>"
|
||||||
|
end if
|
||||||
|
|
||||||
|
set noteTitle to item 1 of argv
|
||||||
|
set noteBody to item 2 of argv
|
||||||
|
|
||||||
|
-- Apple Notes expects HTML for the body.
|
||||||
|
-- We'll wrap the body in minimal HTML.
|
||||||
|
set htmlBody to "<div>" & noteBody & "</div>"
|
||||||
|
|
||||||
|
-- Replace newlines with <br>
|
||||||
|
set htmlBody to do shell script "echo " & quoted form of htmlBody & " | sed 's/$/<br>/'"
|
||||||
|
|
||||||
|
tell application "Notes"
|
||||||
|
tell default account
|
||||||
|
-- Check if note exists to append, or create new
|
||||||
|
set existingNotes to (notes whose name is noteTitle)
|
||||||
|
if (count of existingNotes) > 0 then
|
||||||
|
set currentNote to item 1 of existingNotes
|
||||||
|
set currentBody to body of currentNote
|
||||||
|
-- Append to existing body
|
||||||
|
set body of currentNote to currentBody & "<br>" & htmlBody
|
||||||
|
return "Appended to note: " & noteTitle
|
||||||
|
else
|
||||||
|
make new note with properties {name:noteTitle, body:htmlBody}
|
||||||
|
return "Created new note: " & noteTitle
|
||||||
|
end if
|
||||||
|
end tell
|
||||||
|
end tell
|
||||||
|
end run
|
||||||
32
skills/macos-notes/list_notes.scpt
Normal file
32
skills/macos-notes/list_notes.scpt
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
#!/usr/bin/osascript
|
||||||
|
on run argv
|
||||||
|
set searchObj to ""
|
||||||
|
if (count of argv) > 0 then
|
||||||
|
set searchObj to item 1 of argv
|
||||||
|
end if
|
||||||
|
|
||||||
|
tell application "Notes"
|
||||||
|
if searchObj is "" then
|
||||||
|
set foundNotes to notes of default account
|
||||||
|
-- limiting to top 10 recent
|
||||||
|
set noteCount to count of foundNotes
|
||||||
|
if noteCount > 10 then set noteCount to 10
|
||||||
|
set subNotes to items 1 thru noteCount of foundNotes
|
||||||
|
else
|
||||||
|
set subNotes to (notes of default account whose name contains searchObj)
|
||||||
|
end if
|
||||||
|
|
||||||
|
set output to ""
|
||||||
|
repeat with aNote in subNotes
|
||||||
|
set nName to name of aNote
|
||||||
|
set nBody to body of aNote -- This is HTML
|
||||||
|
set nModDate to modification date of aNote
|
||||||
|
|
||||||
|
-- Simple HTML cleanup for readability (very basic)
|
||||||
|
set nBodyClean to do shell script "echo " & quoted form of nBody & " | sed -e 's/<[^>]*>//g'"
|
||||||
|
|
||||||
|
set output to output & "Note: " & nName & "\nModified: " & nModDate & "\nBody: " & nBodyClean & "\n---\n"
|
||||||
|
end repeat
|
||||||
|
return output
|
||||||
|
end tell
|
||||||
|
end run
|
||||||
Reference in New Issue
Block a user