Skip to content

IvanCampos/agents / skills/apple-notes

apple-notes

Flagged

Read Apple Notes content and execute checklist-driven automations in order. Use when a user asks to run tasks from an Apple Note (especially a checklist note like "AGENT TODO LIST"), or to fetch a specific note body for automation.

FileKindSize
SKILL.mdskill md3.1 KB
agents/openai.yamlconfig201 B
scripts/dispatch_skill_item.shexecutablescript20.0 KB
scripts/manage_notes.applescriptother8.9 KB
scripts/manage_notes.shexecutablescript8.1 KB
scripts/run_checklist_note.shexecutablescript5.8 KB

scripts/manage_notes.applescript

View on GitHub
on run argv
	if (count of argv) is not 14 then error "Expected 14 args, got " & (count of argv)
	
	set actionName to item 1 of argv
	set titleText to item 2 of argv
	set noteIDText to item 3 of argv
	set bodyText to item 4 of argv
	set bodySetText to item 5 of argv
	set titleNewText to item 6 of argv
	set titleNewSetText to item 7 of argv
	set queryText to item 8 of argv
	set fieldType to item 9 of argv
	set formatType to item 10 of argv
	set allFlagText to item 11 of argv
	set limitText to item 12 of argv
	set accountName to item 13 of argv
	set folderName to item 14 of argv
	
	set allFlag to (allFlagText is "true")
	set bodySet to (bodySetText is "true")
	set titleNewSet to (titleNewSetText is "true")
	set limitValue to (limitText as integer)
	
	if actionName is "create" then
		set targetFolderRec to my resolveTargetFolder(accountName, folderName)
		tell application "Notes"
			set newNote to make new note at (folderRef of targetFolderRec) with properties {name:titleText, body:bodyText}
			set newRow to {noteID:(id of newNote), noteName:(name of newNote), folderName:(folderName of targetFolderRec), accountName:(accountName of targetFolderRec)}
		end tell
		return my joinLines({"Created note:", my noteSummaryLine(newRow)})
	end if
	
	if actionName is "read" then
		set matches to my resolveTargetNotes(noteIDText, titleText, allFlag, accountName, folderName)
		set outLines to {}
		repeat with row in matches
			set end of outLines to my renderNote(row, formatType)
			set end of outLines to "===="
		end repeat
		if (count of outLines) > 0 then set outLines to items 1 thru -2 of outLines
		return my joinLines(outLines)
	end if
	
	if actionName is "update" then
		set matches to my resolveTargetNotes(noteIDText, titleText, allFlag, accountName, folderName)
		repeat with row in matches
			set noteIDCurrent to noteID of row
			set n to my noteRefByID(noteIDCurrent)
			tell application "Notes"
				if bodySet then set body of n to bodyText
				if titleNewSet then set name of n to titleNewText
			end tell
		end repeat
		
		set outLines to {"Updated notes: " & (count of matches)}
		repeat with row in matches
			set noteIDCurrent to noteID of row
			set n to my noteRefByID(noteIDCurrent)
			set updatedName to noteName of row
			tell application "Notes"
				try
					set updatedName to name of n
				end try
			end tell
			set updatedRow to {noteID:noteIDCurrent, noteName:updatedName, folderName:(folderName of row), accountName:(accountName of row)}
			set end of outLines to my noteSummaryLine(updatedRow)
		end repeat
		return my joinLines(outLines)
	end if
	
	if actionName is "delete" then
		set matches to my resolveTargetNotes(noteIDText, titleText, allFlag, accountName, folderName)
		set deletedCount to count of matches
		repeat with row in matches
			set noteIDCurrent to noteID of row
			set n to my noteRefByID(noteIDCurrent)
			tell application "Notes"
				delete n
			end tell
		end repeat
		return "Deleted notes: " & deletedCount
	end if
	
	if actionName is "search" then
		set matches to my searchNotes(queryText, fieldType, limitValue, accountName, folderName)
		if (count of matches) is 0 then return "No notes matched."
		return my joinLines(matches)
	end if
	
	if actionName is "list" then
		set matches to my listNotes(limitValue, accountName, folderName)
		if (count of matches) is 0 then return "No notes found."
		return my joinLines(matches)
	end if
	
	error "Unsupported action: " & actionName
end run

on resolveTargetFolder(accountName, folderName)
	tell application "Notes"
		if accountName is not "" then
			set targetAccount to my findAccount(accountName)
			set accountLabel to name of targetAccount
			
			if folderName is "" then
				set targetFolder to first folder of targetAccount
				return {folderRef:targetFolder, folderName:(name of targetFolder), accountName:accountLabel}
			end if
			
			repeat with f in folders of targetAccount
				if name of f is folderName then
					return {folderRef:f, folderName:folderName, accountName:accountLabel}
				end if
			end repeat
			error "Folder not found in account '" & accountName & "': " & folderName
		end if
		
		if folderName is not "" then
			repeat with a in accounts
				set accountLabel to name of a
				repeat with f in folders of a
					if name of f is folderName then
						return {folderRef:f, folderName:folderName, accountName:accountLabel}
					end if
				end repeat
			end repeat
			error "Folder not found: " & folderName
		end if
		
		set defaultAccount to first account
		set defaultFolder to first folder of defaultAccount
		return {folderRef:defaultFolder, folderName:(name of defaultFolder), accountName:(name of defaultAccount)}
	end tell
end resolveTargetFolder

on findAccount(accountName)
	tell application "Notes"
		repeat with a in accounts
			if name of a is accountName then return a
		end repeat
	end tell
	error "Account not found: " & accountName
end findAccount

on collectScopedNotes(accountName, folderName)
	set rows to {}
	set includeRecentlyDeleted to (folderName is "Recently Deleted")
	tell application "Notes"
		repeat with a in accounts
			set accountLabel to name of a
			if (accountName is "") or (accountLabel is accountName) then
				repeat with f in folders of a
					set folderLabel to name of f
					if (folderName is "") or (folderLabel is folderName) then
						if includeRecentlyDeleted or (folderLabel is not "Recently Deleted") then
							repeat with n in notes of f
								try
									set end of rows to {noteID:(id of n), noteName:(name of n), folderName:folderLabel, accountName:accountLabel}
								end try
							end repeat
						end if
					end if
				end repeat
			end if
		end repeat
	end tell
	return rows
end collectScopedNotes

on noteRefByID(noteIDText)
	tell application "Notes"
		try
			return note id noteIDText
		on error
			error "Note not found by id: " & noteIDText
		end try
	end tell
end noteRefByID

on resolveTargetNotes(noteIDText, titleText, allFlag, accountName, folderName)
	set rows to my collectScopedNotes(accountName, folderName)
	set matches to {}
	
	if noteIDText is not "" then
		repeat with row in rows
			if (noteID of row) is noteIDText then set end of matches to row
		end repeat
		if (count of matches) is 0 then error "Note not found by id: " & noteIDText
		return matches
	end if
	
	repeat with row in rows
		if (noteName of row) is titleText then set end of matches to row
	end repeat
	
	if (count of matches) is 0 then
		error "No notes found with title: " & titleText
	end if
	
	if (not allFlag) and ((count of matches) > 1) then
		set outLines to {"Multiple notes matched title '" & titleText & "'. Use --all or --id."}
		repeat with row in matches
			set end of outLines to my noteSummaryLine(row)
		end repeat
		error my joinLines(outLines)
	end if
	
	return matches
end resolveTargetNotes

on searchNotes(queryText, fieldType, limitValue, accountName, folderName)
	set rows to my collectScopedNotes(accountName, folderName)
	set matches to {}
	repeat with row in rows
		set titleValue to noteName of row
		set bodyValue to ""
		set noteIDCurrent to noteID of row
		set n to my noteRefByID(noteIDCurrent)
		tell application "Notes"
			try
				set bodyValue to plaintext of n
			end try
		end tell
		
		set isMatch to false
		ignoring case
			if fieldType is "title" then
				if titleValue contains queryText then set isMatch to true
			else if fieldType is "body" then
				if bodyValue contains queryText then set isMatch to true
			else
				if (titleValue contains queryText) or (bodyValue contains queryText) then set isMatch to true
			end if
		end ignoring
		
		if isMatch then
			set end of matches to my noteSummaryLine(row)
			if (limitValue > 0) and ((count of matches) is greater than or equal to limitValue) then exit repeat
		end if
	end repeat
	return matches
end searchNotes

on listNotes(limitValue, accountName, folderName)
	set rows to my collectScopedNotes(accountName, folderName)
	set outLines to {}
	repeat with row in rows
		set end of outLines to my noteSummaryLine(row)
		if (limitValue > 0) and ((count of outLines) is greater than or equal to limitValue) then exit repeat
	end repeat
	return outLines
end listNotes

on renderNote(row, formatType)
	set contentText to ""
	set noteIDCurrent to noteID of row
	set n to my noteRefByID(noteIDCurrent)
	tell application "Notes"
		if formatType is "body" then
			set contentText to body of n
		else
			set contentText to plaintext of n
		end if
	end tell
	
	set outLines to {"ID: " & (noteID of row), "Title: " & (noteName of row), "Folder: " & (folderName of row), "Account: " & (accountName of row), "----", contentText}
	return my joinLines(outLines)
end renderNote

on noteSummaryLine(row)
	return "ID: " & (noteID of row) & " | Title: " & (noteName of row) & " | Folder: " & (folderName of row) & " | Account: " & (accountName of row)
end noteSummaryLine

on joinLines(itemsList)
	set oldTID to AppleScript's text item delimiters
	set AppleScript's text item delimiters to linefeed
	set outputText to itemsList as text
	set AppleScript's text item delimiters to oldTID
	return outputText
end joinLines
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 470kUpdated Claude CodeCodexVerifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 322kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 322kUpdated Claude CodeCodexVerifiedInstall
executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is availableStars: 322kUpdated Claude CodeCodexVerifiedInstall