Skip to content

lanfuli/aleabito-serenity-skills / skills/follow-aleabito

follow-aleabito

Verified

Track Serenity / @aleabitoreddit on X and turn the feed into (1) a beginner-friendly Chinese iMessage digest with first-principles + Buffett-style judgement, (2) cumulative 60-day ticker mention analytics CSVs for a website, (3) a Xiaohongshu writing brief, and (4) a durable private research map. Trigger on requests like "follow aleabitoreddit / AleaBito / Serenity", "daily Chinese updates from that X account", "60-day mention analytics", "ticker mention count", "写小红书 aleabito", "aleabito 研究地图 / research map", or any request for Chinese commentary derived from @aleabitoreddit posts.

FileKindSize
SKILL.mdskill md7.7 KB
agents/openai.yamlconfig403 B
references/analysis-framework.mdmarkdown3.6 KB
references/analytics.mdmarkdown1.5 KB
references/xhs-style.mdmarkdown1.7 KB
scripts/analyze-mentions.jsscript24.9 KB
scripts/build-digest-brief.jsexecutablescript7.8 KB
scripts/build-xhs-brief.jsscript9.7 KB
scripts/fetch-updates.jsexecutablescript22.7 KB
scripts/mark-seen.jsexecutablescript1.6 KB
scripts/send-imessage.jsexecutablescript3.3 KB
scripts/setup-config.jsexecutablescript2.3 KB
scripts/update-research-map.jsscript6.6 KB

scripts/send-imessage.js

View on GitHub
#!/usr/bin/env node

import { readFile } from "fs/promises";
import { existsSync } from "fs";
import { join } from "path";
import { homedir } from "os";
import { spawn } from "child_process";

const USER_DIR = join(homedir(), ".follow-aleabito");
const CONFIG_PATH = join(USER_DIR, "config.json");

function argValue(name) {
  const idx = process.argv.indexOf(name);
  return idx === -1 ? null : process.argv[idx + 1] || null;
}

function hasFlag(name) {
  return process.argv.includes(name);
}

async function readInput() {
  const message = argValue("--message");
  if (message) return message;

  const file = argValue("--file");
  if (file) return readFile(file, "utf-8");

  const chunks = [];
  for await (const chunk of process.stdin) chunks.push(chunk);
  return Buffer.concat(chunks).toString("utf-8");
}

async function readConfig() {
  if (!existsSync(CONFIG_PATH)) return {};
  return JSON.parse(await readFile(CONFIG_PATH, "utf-8"));
}

function splitMessage(text, maxLen = 3500) {
  const chunks = [];
  let remaining = text.trim();
  while (remaining.length > maxLen) {
    let splitAt = remaining.lastIndexOf("\n", maxLen);
    if (splitAt < maxLen * 0.5) splitAt = maxLen;
    chunks.push(remaining.slice(0, splitAt).trim());
    remaining = remaining.slice(splitAt).trim();
  }
  if (remaining) chunks.push(remaining);
  return chunks;
}

function runOsaScript(recipient, message) {
  const script = `
on run argv
  set targetAddress to item 1 of argv
  set messageText to item 2 of argv
  tell application "Messages"
    set targetService to 1st service whose service type = iMessage
    set targetBuddy to buddy targetAddress of targetService
    send messageText to targetBuddy
  end tell
end run
`;

  return new Promise((resolve, reject) => {
    const child = spawn("osascript", ["-e", script, recipient, message], {
      stdio: ["ignore", "pipe", "pipe"],
    });
    let stdout = "";
    let stderr = "";
    child.stdout.on("data", (chunk) => (stdout += chunk));
    child.stderr.on("data", (chunk) => (stderr += chunk));
    child.on("close", (code) => {
      if (code === 0) resolve({ stdout, stderr });
      else reject(new Error(stderr.trim() || `osascript exited with code ${code}`));
    });
  });
}

async function main() {
  const config = await readConfig();
  const recipient = argValue("--to") || config.delivery?.recipient;
  const text = await readInput();

  if (!recipient) {
    throw new Error(
      `Missing iMessage recipient. Run: node ${join(
        homedir(),
        ".codex",
        "skills",
        "follow-aleabito",
        "scripts",
        "setup-config.js",
      )} --recipient "<phone-or-apple-id>"`,
    );
  }
  if (!text.trim()) throw new Error("Refusing to send an empty message");

  const chunks = splitMessage(text);
  if (hasFlag("--dry-run")) {
    console.log(JSON.stringify({ status: "dry-run", recipient, chunks: chunks.length }, null, 2));
    return;
  }

  for (const chunk of chunks) {
    await runOsaScript(recipient, chunk);
    if (chunks.length > 1) await new Promise((resolve) => setTimeout(resolve, 700));
  }

  console.log(JSON.stringify({ status: "ok", method: "imessage", recipient, chunks: chunks.length }, null, 2));
}

main().catch((err) => {
  console.error(JSON.stringify({ status: "error", message: err.message }, null, 2));
  process.exit(1);
});
deprecation-and-migrationaddyosmani/agent-skillsManages deprecation and migration. Use when removing old systems, APIs, or features. Use when migrating users from one implementation to another. Use when migrating a database schema in production, such as renaming or dropping a column without downtime (expand/contract). Use when deciding whether to maintain or sunset existing code.Stars: 119kUpdated Claude CodeCodexVerifiedInstall
performance-optimizationaddyosmani/agent-skillsOptimizes application performance across frontend, backend, queries, and databases. Use when performance requirements exist, when you suspect performance regressions, when Core Web Vitals or load times need improvement, when N+1 query patterns need fixing, or when profiling reveals bottlenecks.Stars: 119kUpdated Claude CodeCodexVerifiedInstall
agent-cost-reportthedotmack/claude-memBelievable agent cost report for any period, default the last 7 full days PT, not counting today. Measured tokens from Claude Code transcripts priced at OpenRouter list prices (ESTIMATED), measured provider spend when a sanctioned source exists, note-taker cost separate, Timing-style HTML/PDF plus report.json, line-items.csv, evidence.json.Stars: 118kUpdated Claude CodeCodexVerifiedInstall
agent-cost-reportthedotmack/claude-memBelievable agent cost report for any period, default the last 7 full days PT, not counting today. Measured tokens from Claude Code transcripts priced at OpenRouter list prices (ESTIMATED), measured provider spend when a sanctioned source exists, note-taker cost separate, Timing-style HTML/PDF plus report.json, line-items.csv, evidence.json.Stars: 118kUpdated Claude CodeCodexVerifiedInstall