asciinema-converter
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chineseasciinema-converter
asciinema-converter
Convert asciinema .cast recordings to clean .txt files for Claude Code analysis. Achieves 950:1 compression (3.8GB -> 4MB) by stripping ANSI codes and JSON structure.
Platform: macOS, Linux (requires asciinema CLI v2.4+)
将asciinema的.cast录制文件转换为干净的.txt文件,用于Claude Code分析。通过剥离ANSI代码和JSON结构,实现950:1的压缩比(3.8GB → 4MB)。
平台:macOS、Linux(需要asciinema CLI v2.4+版本)
When to Use This Skill
何时使用该工具
Use this skill when:
- Converting .cast recordings to searchable .txt format
- Preparing recordings for Claude Code Read/Grep tools
- Batch converting multiple recordings
- Reducing storage size of session archives
- Extracting clean text from ANSI-coded terminal output
在以下场景使用本工具:
- 将.cast录制文件转换为可搜索的.txt格式
- 为Claude Code的Read/Grep工具准备录制文件
- 批量转换多个录制文件
- 减少会话存档的存储空间
- 从带ANSI编码的终端输出中提取干净文本
Why Convert?
为什么要转换?
| Format | Size (22h session) | Claude Code Compatible | Searchable |
|---|---|---|---|
| .cast | 3.8GB | No (NDJSON + ANSI) | Via jq |
| .txt | ~4MB | Yes (clean text) | Grep/Read |
Key benefit: Claude Code's Read and Grep tools work directly on .txt output.
| 格式 | 22小时会话大小 | 兼容Claude Code | 可搜索性 |
|---|---|---|---|
| .cast | 3.8GB | 否(NDJSON + ANSI) | 需通过jq工具 |
| .txt | ~4MB | 是(干净文本) | 支持Grep/Read |
核心优势:Claude Code的Read和Grep工具可直接处理.txt输出文件。
Requirements
依赖要求
| Component | Required | Installation | Notes |
|---|---|---|---|
| asciinema | Yes | | v2.4+ for convert cmd |
| 组件 | 是否必需 | 安装方式 | 注意事项 |
|---|---|---|---|
| asciinema | 是 | | 需要v2.4+版本以支持convert命令 |
Workflow Phases (ALL MANDATORY)
工作流阶段(全部为必填项)
IMPORTANT: All phases are MANDATORY. Do NOT skip any phase. AskUserQuestion MUST be used at each decision point.
重要提示:所有阶段均为必填项,请勿跳过任何阶段。每个决策点必须使用AskUserQuestion交互。
Phase 0: Preflight Check
阶段0:预检检查
Purpose: Verify asciinema is installed and supports convert command.
bash
/usr/bin/env bash << 'PREFLIGHT_EOF'
if command -v asciinema &>/dev/null; then
VERSION=$(asciinema --version | head -1)
echo "asciinema: $VERSION"
# Check if convert command exists (v2.4+)
if asciinema convert --help &>/dev/null 2>&1; then
echo "convert: available"
else
echo "convert: MISSING (update asciinema to v2.4+)"
fi
else
echo "asciinema: MISSING"
fi
PREFLIGHT_EOFIf asciinema is NOT installed or convert is missing, use AskUserQuestion:
Question: "asciinema CLI issue detected. How would you like to proceed?"
Header: "Setup"
Options:
- Label: "Install/upgrade asciinema (Recommended)"
Description: "Run: brew install asciinema (or upgrade if outdated)"
- Label: "Show manual instructions"
Description: "Display installation commands for all platforms"
- Label: "Cancel"
Description: "Exit without converting"目的:验证asciinema已安装且支持convert命令。
bash
/usr/bin/env bash << 'PREFLIGHT_EOF'
if command -v asciinema &>/dev/null; then
VERSION=$(asciinema --version | head -1)
echo "asciinema: $VERSION"
# Check if convert command exists (v2.4+)
if asciinema convert --help &>/dev/null 2>&1; then
echo "convert: available"
else
echo "convert: MISSING (update asciinema to v2.4+)"
fi
else
echo "asciinema: MISSING"
fi
PREFLIGHT_EOF如果asciinema未安装或缺少convert命令,使用AskUserQuestion交互:
问题:“检测到asciinema CLI问题。您希望如何继续?”
标题:“设置”
选项:
- 标签:“安装/升级asciinema(推荐)”
描述:“执行命令:brew install asciinema(若版本过时则升级)”
- 标签:“显示手动安装说明”
描述:“展示全平台安装命令”
- 标签:“取消”
描述:“退出转换流程”Phase 1: File Discovery & Selection (MANDATORY)
阶段1:文件发现与选择(必填)
Purpose: Discover .cast files and let user select which to convert.
目的:发现.cast文件并让用户选择要转换的文件。
Step 1.1: Discover .cast Files
步骤1.1:发现.cast文件
bash
/usr/bin/env bash << 'DISCOVER_EOF'bash
/usr/bin/env bash << 'DISCOVER_EOF'Search for .cast files with metadata
Search for .cast files with metadata
for file in $(fd -e cast . --max-depth 5 2>/dev/null | head -10); do
SIZE=$(ls -lh "$file" 2>/dev/null | awk '{print $5}')
LINES=$(wc -l < "$file" 2>/dev/null | tr -d ' ')
DURATION=$(head -1 "$file" 2>/dev/null | jq -r '.duration // "unknown"' 2>/dev/null)
BASENAME=$(basename "$file")
echo "FILE:$file|SIZE:$SIZE|LINES:$LINES|DURATION:$DURATION|NAME:$BASENAME"
done
DISCOVER_EOF
undefinedfor file in $(fd -e cast . --max-depth 5 2>/dev/null | head -10); do
SIZE=$(ls -lh "$file" 2>/dev/null | awk '{print $5}')
LINES=$(wc -l < "$file" 2>/dev/null | tr -d ' ')
DURATION=$(head -1 "$file" 2>/dev/null | jq -r '.duration // "unknown"' 2>/dev/null)
BASENAME=$(basename "$file")
echo "FILE:$file|SIZE:$SIZE|LINES:$LINES|DURATION:$DURATION|NAME:$BASENAME"
done
DISCOVER_EOF
undefinedStep 1.2: Present File Selection (MANDATORY AskUserQuestion)
步骤1.2:文件选择交互(必填AskUserQuestion)
Use discovery results to populate options:
Question: "Which recording would you like to convert?"
Header: "Recording"
Options:
- Label: "{filename} ({size})"
Description: "{line_count} events, {duration}s duration"
- Label: "{filename2} ({size2})"
Description: "{line_count2} events, {duration2}s duration"
- Label: "Browse for file"
Description: "Search in a different directory"
- Label: "Enter path"
Description: "Provide a custom path to a .cast file"使用发现结果填充选项:
问题:“您希望转换哪个录制文件?”
标题:“录制文件选择”
选项:
- 标签:“{filename} ({size})”
描述:“{line_count}个事件,时长{duration}秒”
- 标签:“{filename2} ({size2})”
描述:“{line_count2}个事件,时长{duration2}秒”
- 标签:“浏览文件”
描述:“在其他目录中搜索”
- 标签:“输入路径”
描述:“提供.cast文件的自定义路径”Phase 2: Output Options (MANDATORY)
阶段2:输出选项(必填)
Purpose: Let user configure conversion behavior.
Question: "Select conversion options:"
Header: "Options"
multiSelect: true
Options:
- Label: "Plain text output (Recommended)"
Description: "Convert to .txt with all ANSI codes stripped"
- Label: "Create timestamp index"
Description: "Generate [HH:MM:SS] indexed version for navigation"
- Label: "Split by idle time"
Description: "Create separate chunks at 30s+ pauses"
- Label: "Preserve terminal dimensions"
Description: "Add header with original terminal size"目的:让用户配置转换行为。
问题:“选择转换选项:”
标题:“选项”
支持多选:是
选项:
- 标签:“纯文本输出(推荐)”
描述:“转换为.txt格式并剥离所有ANSI代码”
- 标签:“创建时间戳索引”
描述:“生成带[HH:MM:SS]索引的版本以便导航”
- 标签:“按空闲时间拆分”
描述:在30秒以上的停顿处创建独立片段
- 标签:“保留终端尺寸”
描述:“添加包含原始终端尺寸的头部信息”Phase 3: Output Location (MANDATORY)
阶段3:输出位置(必填)
Purpose: Let user choose where to save the output.
Question: "Where should the output be saved?"
Header: "Output"
Options:
- Label: "Same directory as source (Recommended)"
Description: "Save {filename}.txt next to {filename}.cast"
- Label: "Workspace tmp/"
Description: "Save to ${PWD}/tmp/"
- Label: "Custom path"
Description: "Specify a custom output location"目的:让用户选择输出文件的保存位置。
问题:“输出文件应保存至何处?”
标题:“输出位置”
选项:
- 标签:“与源文件同目录(推荐)”
描述:“将{filename}.txt保存到{filename}.cast所在目录”
- 标签:“工作区tmp/目录”
描述:“保存至${PWD}/tmp/”
- 标签:“自定义路径”
描述:“指定自定义输出位置”Phase 4: Execute Conversion
阶段4:执行转换
Purpose: Run the conversion and report results.
目的:运行转换并报告结果。
Step 4.1: Run asciinema convert
步骤4.1:执行asciinema convert命令
bash
/usr/bin/env bash << 'CONVERT_EOF'
INPUT_FILE="${1:?Input file required}"
OUTPUT_FILE="${2:?Output file required}"
echo "Converting: $INPUT_FILE"
echo "Output: $OUTPUT_FILE"
echo ""bash
/usr/bin/env bash << 'CONVERT_EOF'
INPUT_FILE="${1:?Input file required}"
OUTPUT_FILE="${2:?Output file required}"
echo "Converting: $INPUT_FILE"
echo "Output: $OUTPUT_FILE"
echo ""Run conversion
Run conversion
asciinema convert -f txt "$INPUT_FILE" "$OUTPUT_FILE"
if [[ $? -eq 0 && -f "$OUTPUT_FILE" ]]; then
echo "Conversion successful"
else
echo "ERROR: Conversion failed"
exit 1
fi
CONVERT_EOF
undefinedasciinema convert -f txt "$INPUT_FILE" "$OUTPUT_FILE"
if [[ $? -eq 0 && -f "$OUTPUT_FILE" ]]; then
echo "Conversion successful"
else
echo "ERROR: Conversion failed"
exit 1
fi
CONVERT_EOF
undefinedStep 4.2: Report Compression
步骤4.2:报告压缩情况
bash
/usr/bin/env bash << 'REPORT_EOF'
INPUT_FILE="${1:?}"
OUTPUT_FILE="${2:?}"bash
/usr/bin/env bash << 'REPORT_EOF'
INPUT_FILE="${1:?}"
OUTPUT_FILE="${2:?}"Get file sizes (macOS compatible)
Get file sizes (macOS compatible)
INPUT_SIZE=$(stat -f%z "$INPUT_FILE" 2>/dev/null || stat -c%s "$INPUT_FILE" 2>/dev/null)
OUTPUT_SIZE=$(stat -f%z "$OUTPUT_FILE" 2>/dev/null || stat -c%s "$OUTPUT_FILE" 2>/dev/null)
INPUT_SIZE=$(stat -f%z "$INPUT_FILE" 2>/dev/null || stat -c%s "$INPUT_FILE" 2>/dev/null)
OUTPUT_SIZE=$(stat -f%z "$OUTPUT_FILE" 2>/dev/null || stat -c%s "$OUTPUT_FILE" 2>/dev/null)
Calculate ratio
Calculate ratio
if [[ $OUTPUT_SIZE -gt 0 ]]; then
RATIO=$((INPUT_SIZE / OUTPUT_SIZE))
else
RATIO=0
fi
if [[ $OUTPUT_SIZE -gt 0 ]]; then
RATIO=$((INPUT_SIZE / OUTPUT_SIZE))
else
RATIO=0
fi
Human-readable sizes
Human-readable sizes
INPUT_HR=$(numfmt --to=iec "$INPUT_SIZE" 2>/dev/null || echo "$INPUT_SIZE bytes")
OUTPUT_HR=$(numfmt --to=iec "$OUTPUT_SIZE" 2>/dev/null || echo "$OUTPUT_SIZE bytes")
echo ""
echo "=== Conversion Complete ==="
echo "Input: $INPUT_HR"
echo "Output: $OUTPUT_HR"
echo "Compression: ${RATIO}:1"
echo "Output path: $OUTPUT_FILE"
REPORT_EOF
---INPUT_HR=$(numfmt --to=iec "$INPUT_SIZE" 2>/dev/null || echo "$INPUT_SIZE bytes")
OUTPUT_HR=$(numfmt --to=iec "$OUTPUT_SIZE" 2>/dev/null || echo "$OUTPUT_SIZE bytes")
echo ""
echo "=== Conversion Complete ==="
echo "Input: $INPUT_HR"
echo "Output: $OUTPUT_HR"
echo "Compression: ${RATIO}:1"
echo "Output path: $OUTPUT_FILE"
REPORT_EOF
---Phase 5: Create Timestamp Index (if selected)
阶段5:创建时间戳索引(若用户选择)
Purpose: Generate indexed version for navigation.
bash
/usr/bin/env bash << 'INDEX_EOF'
INPUT_CAST="${1:?}"
OUTPUT_INDEX="${2:?}"
echo "Creating timestamp index..."目的:生成带索引的版本以便导航。
bash
/usr/bin/env bash << 'INDEX_EOF'
INPUT_CAST="${1:?}"
OUTPUT_INDEX="${2:?}"
echo "Creating timestamp index..."Process .cast file to indexed format
Process .cast file to indexed format
(
echo "# Recording Index"
echo "# Format: [HH:MM:SS] content"
echo "#"
cumtime=0
tail -n +2 "$INPUT_CAST" | while IFS= read -r line; do
# Extract timestamp and content
ts=$(echo "$line" | jq -r '.[0]' 2>/dev/null)
type=$(echo "$line" | jq -r '.[1]' 2>/dev/null)
content=$(echo "$line" | jq -r '.[2]' 2>/dev/null)
if [[ "$type" == "o" && -n "$content" ]]; then
# Format timestamp as HH:MM:SS
hours=$((${ts%.*} / 3600))
mins=$(((${ts%.*} % 3600) / 60))
secs=$((${ts%.*} % 60))
timestamp=$(printf "%02d:%02d:%02d" "$hours" "$mins" "$secs")
# Clean and output (strip ANSI, limit length)
clean=$(echo "$content" | sed 's/\x1b\[[0-9;]*[a-zA-Z]//g' | tr -d '\r' | head -c 200)
[[ -n "$clean" ]] && echo "[$timestamp] $clean"
fidone
) > "$OUTPUT_INDEX"
echo "Index created: $OUTPUT_INDEX"
wc -l "$OUTPUT_INDEX"
INDEX_EOF
---(
echo "# Recording Index"
echo "# Format: [HH:MM:SS] content"
echo "#"
cumtime=0
tail -n +2 "$INPUT_CAST" | while IFS= read -r line; do
# Extract timestamp and content
ts=$(echo "$line" | jq -r '.[0]' 2>/dev/null)
type=$(echo "$line" | jq -r '.[1]' 2>/dev/null)
content=$(echo "$line" | jq -r '.[2]' 2>/dev/null)
if [[ "$type" == "o" && -n "$content" ]]; then
# Format timestamp as HH:MM:SS
hours=$((${ts%.*} / 3600))
mins=$(((${ts%.*} % 3600) / 60))
secs=$((${ts%.*} % 60))
timestamp=$(printf "%02d:%02d:%02d" "$hours" "$mins" "$secs")
# Clean and output (strip ANSI, limit length)
clean=$(echo "$content" | sed 's/\x1b\[[0-9;]*[a-zA-Z]//g' | tr -d '\r' | head -c 200)
[[ -n "$clean" ]] && echo "[$timestamp] $clean"
fidone
) > "$OUTPUT_INDEX"
echo "Index created: $OUTPUT_INDEX"
wc -l "$OUTPUT_INDEX"
INDEX_EOF
---Phase 6: Next Steps (MANDATORY)
阶段6:后续操作(必填)
Purpose: Guide user to next action.
Question: "Conversion complete. What's next?"
Header: "Next"
Options:
- Label: "Analyze with /asciinema-tools:analyze"
Description: "Run keyword extraction on the converted file"
- Label: "Open in editor"
Description: "View the converted text file"
- Label: "Done"
Description: "Exit - no further action needed"目的:引导用户进行下一步操作。
问题:“转换完成。下一步操作?”
标题:“后续步骤”
选项:
- 标签:“使用/asciinema-tools:analyze进行分析”
描述:“对转换后的文件运行关键词提取”
- 标签:“在编辑器中打开”
描述:“查看转换后的文本文件”
- 标签:“完成”
描述:“退出,无需进一步操作”Batch Mode (Phases 7-9)
批量模式(阶段7-9)
Batch mode converts all .cast files in a directory with organized output. Activated via flag.
--batchUse case: Convert 1000+ iTerm2 auto-logged recordings efficiently.
批量模式可转换目录中的所有.cast文件并整理输出,通过参数激活。
--batch适用场景:高效转换1000+个iTerm2自动录制的文件。
Phase 7: Batch Source Selection
阶段7:批量源目录选择
Purpose: Select source directory for batch conversion.
Trigger: flag without argument.
--batch--sourceQuestion: "Select source directory for batch conversion:"
Header: "Source"
Options:
- Label: "~/asciinemalogs (iTerm2 default)" (Recommended)
Description: "Auto-logged iTerm2 recordings"
- Label: "~/Downloads"
Description: "Recent downloads containing .cast files"
- Label: "Current directory"
Description: "Convert .cast files in current working directory"
- Label: "Custom path"
Description: "Specify a custom source directory"Skip condition: If argument provided, skip this phase.
--source目的:选择批量转换的源目录。
触发条件:使用参数但未提供参数时。
--batch--source问题:“选择批量转换的源目录:”
标题:“源目录”
选项:
- 标签:“~/asciinemalogs(iTerm2默认目录)”(推荐)
描述:“iTerm2自动录制的文件”
- 标签:“~/Downloads”
描述:“包含.cast文件的最近下载目录”
- 标签:“当前目录”
描述:“转换当前工作目录中的.cast文件”
- 标签:“自定义路径”
描述:“指定自定义源目录”跳过条件:若已提供参数,则跳过本阶段。
--sourcePhase 8: Batch Output Organization
阶段8:批量输出整理
Purpose: Configure output directory structure.
Trigger: flag without argument.
--batch--output-dirQuestion: "Where should converted files be saved?"
Header: "Output"
Options:
- Label: "~/Downloads/cast-txt/ (Recommended)"
Description: "Organized output directory, easy to find"
- Label: "Same as source"
Description: "Save .txt files next to .cast files"
- Label: "Custom directory"
Description: "Specify a custom output location"Skip condition: If argument provided, skip this phase.
--output-dir目的:配置输出目录结构。
触发条件:使用参数但未提供参数时。
--batch--output-dir问题:“转换后的文件应保存至何处?”
标题:“输出位置”
选项:
- 标签:“~/Downloads/cast-txt/(推荐)”
描述:“整理后的输出目录,便于查找”
- 标签:“与源文件同目录”
描述:“将.txt文件保存至.cast文件所在目录”
- 标签:“自定义目录”
描述:“指定自定义输出位置”跳过条件:若已提供参数,则跳过本阶段。
--output-dirPhase 9: Execute Batch Conversion
阶段9:执行批量转换
Purpose: Convert all files with progress reporting.
bash
/usr/bin/env bash << 'BATCH_EOF'
SOURCE_DIR="${1:?Source directory required}"
OUTPUT_DIR="${2:?Output directory required}"
SKIP_EXISTING="${3:-true}"
mkdir -p "$OUTPUT_DIR"
echo "=== Batch Conversion ==="
echo "Source: $SOURCE_DIR"
echo "Output: $OUTPUT_DIR"
echo "Skip existing: $SKIP_EXISTING"
echo ""
total=0
converted=0
skipped=0
failed=0
total_input_size=0
total_output_size=0目的:转换所有文件并报告进度。
bash
/usr/bin/env bash << 'BATCH_EOF'
SOURCE_DIR="${1:?Source directory required}"
OUTPUT_DIR="${2:?Output directory required}"
SKIP_EXISTING="${3:-true}"
mkdir -p "$OUTPUT_DIR"
echo "=== Batch Conversion ==="
echo "Source: $SOURCE_DIR"
echo "Output: $OUTPUT_DIR"
echo "Skip existing: $SKIP_EXISTING"
echo ""
total=0
converted=0
skipped=0
failed=0
total_input_size=0
total_output_size=0Count files first
Count files first
total=$(find "$SOURCE_DIR" -maxdepth 1 -name "*.cast" -type f 2>/dev/null | wc -l | tr -d ' ')
echo "Found $total .cast files"
echo ""
for cast_file in "$SOURCE_DIR"/*.cast; do
[[ -f "$cast_file" ]] || continue
basename=$(basename "$cast_file" .cast)
txt_file="$OUTPUT_DIR/${basename}.txt"
Skip if already converted (and skip mode enabled)
if [[ "$SKIP_EXISTING" == "true" && -f "$txt_file" ]]; then
echo "SKIP: $basename (already exists)"
((skipped++))
continue
fi
Get input size
input_size=$(stat -f%z "$cast_file" 2>/dev/null || stat -c%s "$cast_file" 2>/dev/null)
Convert
if asciinema convert -f txt "$cast_file" "$txt_file" 2>/dev/null; then
output_size=$(stat -f%z "$txt_file" 2>/dev/null || stat -c%s "$txt_file" 2>/dev/null)
if [[ $output_size -gt 0 ]]; then
ratio=$((input_size / output_size))
else
ratio=0
fi
echo "OK: $basename (${ratio}:1 compression)"
((converted++))
total_input_size=$((total_input_size + input_size))
total_output_size=$((total_output_size + output_size))
else
echo "FAIL: $basename"
((failed++))
fi
done
echo ""
echo "=== Batch Complete ==="
echo "Converted: $converted"
echo "Skipped: $skipped"
echo "Failed: $failed"
if [[ $total_output_size -gt 0 ]]; then
overall_ratio=$((total_input_size / total_output_size))
echo "Overall compression: ${overall_ratio}:1"
fi
echo "Output directory: $OUTPUT_DIR"
BATCH_EOF
---total=$(find "$SOURCE_DIR" -maxdepth 1 -name "*.cast" -type f 2>/dev/null | wc -l | tr -d ' ')
echo "Found $total .cast files"
echo ""
for cast_file in "$SOURCE_DIR"/*.cast; do
[[ -f "$cast_file" ]] || continue
basename=$(basename "$cast_file" .cast)
txt_file="$OUTPUT_DIR/${basename}.txt"
Skip if already converted (and skip mode enabled)
if [[ "$SKIP_EXISTING" == "true" && -f "$txt_file" ]]; then
echo "SKIP: $basename (already exists)"
((skipped++))
continue
fi
Get input size
input_size=$(stat -f%z "$cast_file" 2>/dev/null || stat -c%s "$cast_file" 2>/dev/null)
Convert
if asciinema convert -f txt "$cast_file" "$txt_file" 2>/dev/null; then
output_size=$(stat -f%z "$txt_file" 2>/dev/null || stat -c%s "$txt_file" 2>/dev/null)
if [[ $output_size -gt 0 ]]; then
ratio=$((input_size / output_size))
else
ratio=0
fi
echo "OK: $basename (${ratio}:1 compression)"
((converted++))
total_input_size=$((total_input_size + input_size))
total_output_size=$((total_output_size + output_size))
else
echo "FAIL: $basename"
((failed++))
fi
done
echo ""
echo "=== Batch Complete ==="
echo "Converted: $converted"
echo "Skipped: $skipped"
echo "Failed: $failed"
if [[ $total_output_size -gt 0 ]]; then
overall_ratio=$((total_input_size / total_output_size))
echo "Overall compression: ${overall_ratio}:1"
fi
echo "Output directory: $OUTPUT_DIR"
BATCH_EOF
---Phase 10: Batch Next Steps
阶段10:批量转换后续操作
Purpose: Guide user after batch conversion.
Question: "Batch conversion complete. What's next?"
Header: "Next"
Options:
- Label: "Batch analyze with /asciinema-tools:analyze --batch"
Description: "Run keyword extraction on all converted files"
- Label: "Open output directory"
Description: "View converted files in Finder"
- Label: "Done"
Description: "Exit - no further action needed"目的:引导用户完成批量转换后的操作。
问题:“批量转换完成。下一步操作?”
标题:“后续步骤”
选项:
- 标签:“使用/asciinema-tools:analyze --batch进行批量分析”
描述:“对所有转换后的文件运行关键词提取”
- 标签:“打开输出目录”
描述:“在Finder中查看转换后的文件”
- 标签:“完成”
描述:“退出,无需进一步操作”iTerm2 Filename Format
iTerm2文件名格式
iTerm2 auto-logged files follow this format:
{creationTimeString}.{profileName}.{termid}.{iterm2.pid}.{autoLogId}.castExample:
20260118_232025.Claude Code.w0t1p1.70C05103-2F29-4B42-8067-BE475DB6126A.68721.4013739999.cast| Component | Description | Example |
|---|---|---|
| creationTimeString | YYYYMMDD_HHMMSS | 20260118_232025 |
| profileName | iTerm2 profile (may have dots) | Claude Code |
| termid | Window/tab/pane identifier | w0t1p1 |
| iterm2.pid | iTerm2 process UUID | 70C05103-2F29-4B42-8067-BE475DB6126A |
| autoLogId | Session auto-log identifier | 68721.4013739999 |
iTerm2自动录制文件遵循以下格式:
{creationTimeString}.{profileName}.{termid}.{iterm2.pid}.{autoLogId}.cast示例:
20260118_232025.Claude Code.w0t1p1.70C05103-2F29-4B42-8067-BE475DB6126A.68721.4013739999.cast| 组件 | 描述 | 示例 |
|---|---|---|
| creationTimeString | YYYYMMDD_HHMMSS格式时间 | 20260118_232025 |
| profileName | iTerm2配置文件名(可能包含点) | Claude Code |
| termid | 窗口/标签/面板标识符 | w0t1p1 |
| iterm2.pid | iTerm2进程UUID | 70C05103-2F29-4B42-8067-BE475DB6126A |
| autoLogId | 会话自动录制标识符 | 68721.4013739999 |
TodoWrite Task Template
TodoWrite任务模板
Single File Mode
单文件模式
1. [Preflight] Check asciinema CLI and convert command
2. [Preflight] Offer installation if missing
3. [Discovery] Find .cast files with metadata
4. [Selection] AskUserQuestion: file to convert
5. [Options] AskUserQuestion: conversion options (multi-select)
6. [Location] AskUserQuestion: output location
7. [Convert] Run asciinema convert -f txt
8. [Report] Display compression ratio and output path
9. [Index] Create timestamp index if requested
10. [Next] AskUserQuestion: next steps1. [预检] 检查asciinema CLI及convert命令
2. [预检] 若缺失则提供安装选项
3. [发现] 查找带元数据的.cast文件
4. [选择] AskUserQuestion:选择要转换的文件
5. [选项] AskUserQuestion:转换选项(多选)
6. [位置] AskUserQuestion:输出位置
7. [转换] 执行asciinema convert -f txt命令
8. [报告] 显示压缩比和输出路径
9. [索引] 若用户要求则创建时间戳索引
10. [后续] AskUserQuestion:下一步操作Batch Mode (--batch flag)
批量模式(--batch参数)
1. [Preflight] Check asciinema CLI and convert command
2. [Preflight] Offer installation if missing
3. [Source] AskUserQuestion: source directory (skip if --source)
4. [Output] AskUserQuestion: output directory (skip if --output-dir)
5. [Batch] Execute batch conversion with progress
6. [Report] Display aggregate compression stats
7. [Next] AskUserQuestion: batch next steps1. [预检] 检查asciinema CLI及convert命令
2. [预检] 若缺失则提供安装选项
3. [源目录] AskUserQuestion:选择源目录(若提供--source则跳过)
4. [输出] AskUserQuestion:选择输出目录(若提供--output-dir则跳过)
5. [批量] 执行批量转换并显示进度
6. [报告] 显示汇总压缩统计
7. [后续] AskUserQuestion:批量转换后续操作Post-Change Checklist
修改后检查清单
After modifying this skill:
修改本工具后,请检查以下内容:
Single File Mode
单文件模式
- Preflight check detects asciinema version correctly
- Discovery uses heredoc wrapper for bash compatibility
- Compression calculation handles macOS stat syntax
- All AskUserQuestion phases are present
- TodoWrite template matches actual workflow
- 预检检查可正确检测asciinema版本
- 文件发现使用heredoc包装以保证bash兼容性
- 压缩计算适配macOS的stat语法
- 所有AskUserQuestion交互阶段均已包含
- TodoWrite模板与实际工作流一致
Batch Mode
批量模式
- flag triggers batch workflow (phases 7-10)
--batch - skips Phase 7 (source selection)
--source - skips Phase 8 (output organization)
--output-dir - prevents re-conversion of existing files
--skip-existing - Aggregate compression ratio calculated correctly
- iTerm2 filename format documented
- 参数可触发批量工作流(阶段7-10)
--batch - 参数可跳过阶段7(源目录选择)
--source - 参数可跳过阶段8(输出目录配置)
--output-dir - 参数可避免重复转换已存在的文件
--skip-existing - 可正确计算汇总压缩比
- iTerm2文件名格式已正确文档化
CLI Quick Reference
CLI快速参考
bash
undefinedbash
undefinedBasic conversion
基础转换
asciinema convert -f txt recording.cast recording.txt
asciinema convert -f txt recording.cast recording.txt
Check asciinema version
检查asciinema版本
asciinema --version
asciinema --version
Verify convert command exists
验证convert命令是否存在
asciinema convert --help
---asciinema convert --help
---Reference Documentation
参考文档
Internal References
内部参考
- Anti-Patterns - Common mistakes to avoid
- Batch Processing - Patterns for bulk conversion
- Integration Guide - Chaining with analyze/summarize
- 反模式 - 需避免的常见错误
- 批量处理 - 批量转换的模式
- 集成指南 - 与分析/总结工具的链式调用
External References
外部参考
- asciinema convert command
- asciinema-cast-format skill
- asciinema convert命令
- asciinema-cast-format工具
Troubleshooting
故障排查
| Issue | Cause | Solution |
|---|---|---|
| convert command not found | asciinema too old | Upgrade: |
| asciinema not installed | Missing CLI | |
| Empty output file | Corrupted .cast input | Verify .cast file has valid NDJSON structure |
| Conversion failed | Invalid cast format | Check header line is valid JSON with |
| numfmt not found | macOS missing coreutils | Use raw byte count or |
| stat syntax error | Linux vs macOS difference | Script handles both; check stat version |
| Batch skipping all files | All .txt already exist | Use |
| Permission denied on output | Directory not writable | Check output directory permissions |
| 问题 | 原因 | 解决方案 |
|---|---|---|
| convert命令未找到 | asciinema版本过旧 | 升级: |
| asciinema未安装 | 缺少CLI工具 | |
| 输出文件为空 | .cast输入文件损坏 | 验证.cast文件有有效的NDJSON结构 |
| 转换失败 | 无效的cast格式 | 使用jq工具检查首行是否为有效JSON |
| numfmt未找到 | macOS缺少coreutils工具 | 使用原始字节计数或安装 |
| stat语法错误 | Linux与macOS语法差异 | 脚本已适配两种环境;检查stat版本 |
| 批量转换跳过所有文件 | 所有.txt文件已存在 | 使用 |
| 输出权限被拒绝 | 目录不可写 | 检查输出目录的权限 |