daemon-setup

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

/asciinema-tools:daemon-setup

/asciinema-tools:daemon-setup

Interactive wizard to set up the asciinema chunker daemon. This daemon runs independently of Claude Code CLI, using dedicated credentials stored in macOS Keychain.
用于设置asciinema分块守护进程的交互式向导。该守护进程独立于Claude Code CLI运行,使用存储在macOS Keychain中的专用凭证。

Why a Daemon?

为什么要使用守护进程?

Problem with old approachDaemon solution
Uses
gh auth token
(shared)
Uses dedicated PAT from Keychain
Dies when terminal closeslaunchd keeps it running
Silent push failuresLogs + Pushover notifications
Tied to Claude Code sessionCompletely decoupled
旧方案存在的问题守护进程解决方案
使用共享的
gh auth token
使用Keychain中存储的专用PAT
终端关闭时进程退出launchd保持进程持续运行
推送失败无任何提示日志记录 + Pushover通知提醒
与Claude Code会话绑定完全独立解耦

Setup Phases Overview

设置阶段概览

PhaseNameDetails
1Preflight CheckBelow
2Check ExistingBelow
3GitHub PAT SetupPAT Setup Guide
4Pushover SetupPushover Setup Guide
5-6Config + Installlaunchd Installation Guide
7Verify + TroubleshootVerification & Troubleshooting
阶段名称详情
1预检检查见下文
2现有安装检查见下文
3GitHub PAT设置PAT设置指南
4Pushover设置Pushover设置指南
5-6配置+安装launchd安装指南
7验证+问题排查验证与问题排查指南

Execution

执行流程

Phase 1: Preflight Check

阶段1:预检检查

Check required tools:
bash
/usr/bin/env bash << 'PREFLIGHT_EOF'
MISSING=()
for tool in asciinema zstd git curl jq; do
  command -v "$tool" &>/dev/null || MISSING+=("$tool")
done
检查所需工具:
bash
/usr/bin/env bash << 'PREFLIGHT_EOF'
MISSING=()
for tool in asciinema zstd git curl jq; do
  command -v "$tool" &>/dev/null || MISSING+=("$tool")
done

macOS-specific: security command for Keychain

macOS专属:Keychain对应的security命令

if [[ "$(uname)" == "Darwin" ]]; then command -v security &>/dev/null || MISSING+=("security (macOS Keychain)") fi
if [[ ${#MISSING[@]} -gt 0 ]]; then echo "MISSING:${MISSING[*]}" exit 1 fi
echo "PREFLIGHT:OK" PREFLIGHT_EOF

**If MISSING not empty, use AskUserQuestion:**
Question: "Missing required tools: {MISSING}. How would you like to proceed?" Header: "Dependencies" Options:
  • label: "Install via Homebrew (Recommended)" description: "Run: brew install {MISSING}"
  • label: "I'll install manually" description: "Pause setup and show install instructions"
  • label: "Abort setup" description: "Exit the setup wizard"

**If "Install via Homebrew"**: Run `brew install {MISSING}` and continue.

---
if [[ "$(uname)" == "Darwin" ]]; then command -v security &>/dev/null || MISSING+=("security (macOS Keychain)") fi
if [[ ${#MISSING[@]} -gt 0 ]]; then echo "MISSING:${MISSING[*]}" exit 1 fi
echo "PREFLIGHT:OK" PREFLIGHT_EOF

**如果存在缺失工具,调用AskUserQuestion:**
Question: "缺失所需工具:{MISSING}。你希望如何继续?" Header: "依赖项检查" Options:
  • label: "通过Homebrew安装(推荐)" description: "执行命令:brew install {MISSING}"
  • label: "手动安装" description: "暂停设置并展示安装说明"
  • label: "中止设置" description: "退出设置向导"

**如果选择「通过Homebrew安装」:** 执行`brew install {MISSING}`后继续流程。

---

Phase 2: Check Existing Installation

阶段2:现有安装检查

bash
/usr/bin/env bash << 'CHECK_EXISTING_EOF'
PLIST_PATH="$HOME/Library/LaunchAgents/com.cc-skills.asciinema-chunker.plist"
DAEMON_RUNNING="false"

if [[ -f "$PLIST_PATH" ]]; then
  echo "PLIST_EXISTS:true"
  if launchctl list 2>/dev/null | grep -q "asciinema-chunker"; then
    DAEMON_RUNNING="true"
  fi
else
  echo "PLIST_EXISTS:false"
fi

echo "DAEMON_RUNNING:$DAEMON_RUNNING"
bash
/usr/bin/env bash << 'CHECK_EXISTING_EOF'
PLIST_PATH="$HOME/Library/LaunchAgents/com.cc-skills.asciinema-chunker.plist"
DAEMON_RUNNING="false"

if [[ -f "$PLIST_PATH" ]]; then
  echo "PLIST_EXISTS:true"
  if launchctl list 2>/dev/null | grep -q "asciinema-chunker"; then
    DAEMON_RUNNING="true"
  fi
else
  echo "PLIST_EXISTS:false"
fi

echo "DAEMON_RUNNING:$DAEMON_RUNNING"

Check if PAT already in Keychain

检查Keychain中是否已存在PAT

if security find-generic-password -s "asciinema-github-pat" -a "$USER" -w &>/dev/null 2>&1; then echo "PAT_EXISTS:true" else echo "PAT_EXISTS:false" fi CHECK_EXISTING_EOF

**If PLIST_EXISTS=true, use AskUserQuestion:**
Question: "Existing daemon installation found. What would you like to do?" Header: "Existing" Options:
  • label: "Reinstall (keep credentials)" description: "Update daemon script and plist, keep Keychain credentials"
  • label: "Fresh install (reset everything)" description: "Remove existing credentials and start fresh"
  • label: "Cancel" description: "Exit without changes"

---
if security find-generic-password -s "asciinema-github-pat" -a "$USER" -w &>/dev/null 2>&1; then echo "PAT_EXISTS:true" else echo "PAT_EXISTS:false" fi CHECK_EXISTING_EOF

**如果PLIST_EXISTS=true,调用AskUserQuestion:**
Question: "检测到已存在守护进程安装,你希望执行什么操作?" Header: "已有安装检测" Options:
  • label: "重新安装(保留凭证)" description: "更新守护进程脚本和plist文件,保留Keychain中存储的凭证"
  • label: "全新安装(重置所有内容)" description: "删除现有所有凭证,从头开始设置"
  • label: "取消" description: "不做任何修改直接退出"

---

Phase 3: GitHub PAT Setup

阶段3:GitHub PAT设置

See PAT Setup Guide for the full interactive flow: PAT creation walkthrough, Keychain storage, and verification.

完整交互流程请参考PAT设置指南:包含PAT创建引导、Keychain存储和验证步骤。

Phase 4: Pushover Setup (Optional)

阶段4:Pushover设置(可选)

See Pushover Setup Guide for the full interactive flow: Pushover explanation, app creation, credential storage, and test notification.

完整交互流程请参考Pushover设置指南:包含Pushover功能介绍、应用创建、凭证存储和测试通知步骤。

Phase 5-6: Daemon Configuration and launchd Installation

阶段5-6:守护进程配置与launchd安装

See launchd Installation Guide for chunking settings selection, plist generation from template, and service installation.

分块参数选择、模板生成plist文件、服务安装步骤请参考launchd安装指南

Phase 7: Verification

阶段7:验证

See Verification & Troubleshooting for daemon health checks, post-install verification, the final success message, and the troubleshooting table.
守护进程健康检查、安装后验证、最终成功提示以及问题排查表请参考验证与问题排查指南

Quick Reference

快速参考

Troubleshooting

问题排查

IssueCauseSolution
Keychain access deniedmacOS permission not grantedGrant access in System Settings
PAT test failedToken expired or invalid scopeGenerate new token with
repo
scope
launchctl load failedplist syntax errorCheck
plutil -lint <plist-path>
Daemon keeps stoppingScript error or crashCheck
/asciinema-tools:daemon-logs
Pushover not workingInvalid credentialsRe-run setup with correct app/user key
Health file missingDaemon not runningRun
/asciinema-tools:daemon-start
问题原因解决方案
Keychain访问被拒绝未授予macOS对应权限在系统设置中授予对应权限
PAT测试失败Token过期或权限范围无效生成带有
repo
权限范围的新Token
launchctl加载失败plist语法错误执行
plutil -lint <plist-path>
检查语法
守护进程持续崩溃退出脚本错误或运行异常查看
/asciinema-tools:daemon-logs
日志
Pushover通知不生效凭证无效使用正确的应用/用户密钥重新运行设置
健康检查文件缺失守护进程未运行执行
/asciinema-tools:daemon-start
启动进程

Related Commands

相关命令

CommandDescription
/asciinema-tools:daemon-status
Check daemon health
/asciinema-tools:daemon-logs
View logs
/asciinema-tools:daemon-stop
Stop daemon
/asciinema-tools:daemon-start
Start daemon
命令描述
/asciinema-tools:daemon-status
检查守护进程健康状态
/asciinema-tools:daemon-logs
查看运行日志
/asciinema-tools:daemon-stop
停止守护进程
/asciinema-tools:daemon-start
启动守护进程