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/run_checklist_note.sh

View on GitHub
#!/usr/bin/env bash
set -euo pipefail

NOTE_TITLE="${1:-AGENT TODO LIST}"
DISPATCH_SCRIPT="/Users/ivancampos/.codex/skills/apple-notes/scripts/dispatch_skill_item.sh"

if [[ ! -x "$DISPATCH_SCRIPT" ]]; then
  echo "Dispatch script is missing or not executable: $DISPATCH_SCRIPT" >&2
  exit 1
fi

resolve_note_id() {
  local note_title="$1"

  osascript - "$note_title" <<'APPLESCRIPT'
on run argv
  set noteTitle to item 1 of argv
  tell application "Notes"
    set targetNote to missing value
    repeat with a in accounts
      repeat with f in folders of a
        repeat with n in notes of f
          if name of n is noteTitle then
            set targetNote to n
            exit repeat
          end if
        end repeat
        if targetNote is not missing value then exit repeat
      end repeat
      if targetNote is not missing value then exit repeat
    end repeat

    if targetNote is missing value then
      error "Note not found: " & noteTitle
    end if

    return id of targetNote
  end tell
end run
APPLESCRIPT
}

get_note_body_by_id() {
  local note_id="$1"

  osascript - "$note_id" <<'APPLESCRIPT'
on run argv
  set noteID to item 1 of argv
  tell application "Notes"
    try
      return body of (note id noteID)
    on error
      error "Note not found by id: " & noteID
    end try
  end tell
end run
APPLESCRIPT
}

set_note_body_by_id() {
  local note_id="$1"
  local note_body="$2"

  osascript - "$note_id" "$note_body" <<'APPLESCRIPT'
on run argv
  set noteID to item 1 of argv
  set noteBody to item 2 of argv
  tell application "Notes"
    try
      set body of (note id noteID) to noteBody
    on error
      error "Note not found by id: " & noteID
    end try
  end tell
end run
APPLESCRIPT
}

parse_checklist_items() {
  local note_html="$1"

  printf '%s\n' "$note_html" | perl -0777 -ne '
sub decode_entities {
  my ($s) = @_;
  $s =~ s/&nbsp;/ /g;
  $s =~ s/&amp;/&/g;
  $s =~ s/&lt;/</g;
  $s =~ s/&gt;/>/g;
  $s =~ s/&quot;/"/g;
  $s =~ s/&#39;/'\''/g;
  return $s;
}

sub is_checked {
  my ($inner) = @_;
  return 1 if $inner =~ /<strike\b/i;
  return 1 if $inner =~ /<s\b/i;
  return 1 if $inner =~ /\bdata-checked\s*=\s*["'\'']?true/i;
  return 1 if $inner =~ /\baria-checked\s*=\s*["'\'']?true/i;
  return 1 if $inner =~ /\bclass\s*=\s*["'\''][^"'\'']*\bchecked\b/i;
  return 1 if $inner =~ /<input[^>]*type=["'\'']checkbox["'\''][^>]*\bchecked\b/i;
  return 0;
}

my $html = $_;
my $index = 0;
while ($html =~ /<li[^>]*>(.*?)<\/li>/gsi) {
  my $inner = $1;
  my $text = $inner;
  $text =~ s/<[^>]+>//g;
  $text = decode_entities($text);
  $text =~ s/^\s+|\s+$//g;
  $text =~ s/[\t\r\n]+/ /g;
  next unless length($text);

  my $checked = is_checked($inner) ? 1 : 0;
  print join("\t", $index, $checked, $text), "\n";
  $index++;
}
'
}

mark_item_completed_html() {
  local note_html="$1"
  local target_index="$2"

  perl - "$target_index" "$note_html" <<'PERL'
use strict;
use warnings;

my $target = shift @ARGV;
my $html = shift @ARGV;

sub decode_entities {
  my ($s) = @_;
  $s =~ s/&nbsp;/ /g;
  $s =~ s/&amp;/&/g;
  $s =~ s/&lt;/</g;
  $s =~ s/&gt;/>/g;
  $s =~ s/&quot;/"/g;
  $s =~ s/&#39;/'/g;
  return $s;
}

sub visible_text {
  my ($inner) = @_;
  my $text = $inner;
  $text =~ s/<[^>]+>//g;
  $text = decode_entities($text);
  $text =~ s/^\s+|\s+$//g;
  return $text;
}

sub is_checked {
  my ($inner) = @_;
  return 1 if $inner =~ /<strike\b/i;
  return 1 if $inner =~ /<s\b/i;
  return 1 if $inner =~ /\bdata-checked\s*=\s*["'\'']?true/i;
  return 1 if $inner =~ /\baria-checked\s*=\s*["'\'']?true/i;
  return 1 if $inner =~ /\bclass\s*=\s*["'\''][^"'\'']*\bchecked\b/i;
  return 1 if $inner =~ /<input[^>]*type=["'\'']checkbox["'\''][^>]*\bchecked\b/i;
  return 0;
}

my $index = 0;
my $changed = 0;
$html =~ s{<li([^>]*)>(.*?)</li>}{
  my ($attrs, $inner) = ($1, $2);
  my $text = visible_text($inner);
  my $replacement = "<li$attrs>$inner</li>";

  if (length($text)) {
    if ($index == $target && !is_checked($inner)) {
      my $trimmed = $inner;
      $trimmed =~ s/<br\s*\/?>(\s*)$/$1/i;
      $trimmed =~ s/^\s+|\s+$//g;
      $replacement = "<li$attrs><strike>$trimmed</strike></li>";
      $changed = 1;
    }
    $index++;
  }

  $replacement;
}gsei;

die "Failed to mark checklist item index $target as completed\n" unless $changed;
print $html;
PERL
}

NOTE_ID="$(resolve_note_id "$NOTE_TITLE")"
NOTE_HTML="$(get_note_body_by_id "$NOTE_ID")"

ITEM_INDEXES=()
ITEM_COMPLETED=()
ITEM_TEXTS=()
while IFS=$'\t' read -r index completed item_text; do
  [[ -z "${index:-}" ]] && continue
  ITEM_INDEXES+=("$index")
  ITEM_COMPLETED+=("$completed")
  ITEM_TEXTS+=("$item_text")
done < <(parse_checklist_items "$NOTE_HTML")

if [[ ${#ITEM_INDEXES[@]} -eq 0 ]]; then
  echo "No checklist items found in note: $NOTE_TITLE"
  exit 0
fi

echo "Running checklist from note: $NOTE_TITLE"

ran_unchecked_item=0
for i in "${!ITEM_INDEXES[@]}"; do
  item_index="${ITEM_INDEXES[$i]}"
  item_completed="${ITEM_COMPLETED[$i]}"
  item_text="${ITEM_TEXTS[$i]}"

  if [[ "$item_completed" == "1" ]]; then
    echo "- Skipping completed item: $item_text"
    continue
  fi

  ran_unchecked_item=1
  normalized="$(printf '%s' "$item_text" | tr '[:upper:]' '[:lower:]' | tr -s ' ' | sed 's/^ *//;s/ *$//')"
  if "$DISPATCH_SCRIPT" --note-title "$NOTE_TITLE" --item "$item_text" --normalized "$normalized"; then
    :
  else
    status=$?
    if [[ "$status" -eq 2 ]]; then
      echo "Unsupported checklist item: $item_text" >&2
    fi
    exit 1
  fi

  # Refresh from Notes so item actions that mutate note content are preserved
  # before we apply checklist completion markup.
  NOTE_HTML="$(get_note_body_by_id "$NOTE_ID")"
  NOTE_HTML="$(mark_item_completed_html "$NOTE_HTML" "$item_index")"
  set_note_body_by_id "$NOTE_ID" "$NOTE_HTML"
  echo "  Marked completed in Notes."
done

if [[ "$ran_unchecked_item" -eq 0 ]]; then
  echo "No unchecked checklist items to run in note: $NOTE_TITLE"
  exit 0
fi

echo "Checklist completed."
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