mirror of
https://github.com/ruvnet/ruflo.git
synced 2026-11-24 14:16:34 +09:00
🔖 Task checkpoint: Initialize GitHub checkpoint system ...
This commit is contained in:
1 parent
caf1fcff94
commit
0f0c0ff156
5 files changed
+90
-2346
No files matched your search
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"startTime": 1753976105001,
|
||||
"startTime": 1753978457617,
|
||||
"totalTasks": 1,
|
||||
"successfulTasks": 1,
|
||||
"failedTasks": 0,
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,10 +1,10 @@
|
||||
[
|
||||
{
|
||||
"id": "cmd-hooks-1753976105101",
|
||||
"type": "hooks",
|
||||
"id": "cmd-github-1753978457716",
|
||||
"type": "github",
|
||||
"success": true,
|
||||
"duration": 7.70558299999999,
|
||||
"timestamp": 1753976105109,
|
||||
"duration": 1.3684049999999957,
|
||||
"timestamp": 1753978457717,
|
||||
"metadata": {}
|
||||
}
|
||||
]
|
||||
@@ -1,251 +1,3 @@
|
||||
#!/bin/bash
|
||||
# Claude Checkpoint Manager
|
||||
# Provides easy rollback and management of Claude Code checkpoints
|
||||
|
||||
set -e
|
||||
|
||||
# Colors
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Configuration
|
||||
CHECKPOINT_DIR=".claude/checkpoints"
|
||||
BACKUP_DIR=".claude/backups"
|
||||
|
||||
# Help function
|
||||
show_help() {
|
||||
cat << EOF
|
||||
Claude Checkpoint Manager
|
||||
========================
|
||||
|
||||
Usage: $0 <command> [options]
|
||||
|
||||
Commands:
|
||||
list List all checkpoints
|
||||
show <id> Show details of a specific checkpoint
|
||||
rollback <id> Rollback to a specific checkpoint
|
||||
diff <id> Show diff since checkpoint
|
||||
clean Clean old checkpoints (older than 7 days)
|
||||
summary Show session summary
|
||||
|
||||
Options:
|
||||
--hard For rollback: use git reset --hard (destructive)
|
||||
--soft For rollback: use git reset --soft (default)
|
||||
--branch For rollback: create new branch from checkpoint
|
||||
|
||||
Examples:
|
||||
$0 list
|
||||
$0 show checkpoint-20240130-143022
|
||||
$0 rollback checkpoint-20240130-143022 --branch
|
||||
$0 diff session-end-session-20240130-150000
|
||||
EOF
|
||||
}
|
||||
|
||||
# List all checkpoints
|
||||
function list_checkpoints() {
|
||||
echo -e "${BLUE}📋 Available Checkpoints:${NC}"
|
||||
echo ""
|
||||
|
||||
# List checkpoint tags
|
||||
echo -e "${YELLOW}Git Tags:${NC}"
|
||||
local tags=$(git tag -l 'checkpoint-*' -l 'session-end-*' -l 'task-*' --sort=-creatordate | head -20)
|
||||
if [ -n "$tags" ]; then
|
||||
echo "$tags"
|
||||
else
|
||||
echo "No checkpoint tags found"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
|
||||
# List checkpoint branches
|
||||
echo -e "${YELLOW}Checkpoint Branches:${NC}"
|
||||
local branches=$(git branch -a | grep "checkpoint/" | sed 's/^[ *]*//')
|
||||
if [ -n "$branches" ]; then
|
||||
echo "$branches"
|
||||
else
|
||||
echo "No checkpoint branches found"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
|
||||
# List checkpoint files
|
||||
if [ -d "$CHECKPOINT_DIR" ]; then
|
||||
echo -e "${YELLOW}Recent Checkpoint Files:${NC}"
|
||||
find "$CHECKPOINT_DIR" -name "*.json" -type f -printf "%T@ %p\n" | \
|
||||
sort -rn | head -10 | cut -d' ' -f2- | xargs -I {} basename {}
|
||||
fi
|
||||
}
|
||||
|
||||
# Show checkpoint details
|
||||
function show_checkpoint() {
|
||||
local checkpoint_id="$1"
|
||||
|
||||
echo -e "${BLUE}📍 Checkpoint Details: $checkpoint_id${NC}"
|
||||
echo ""
|
||||
|
||||
# Check if it's a tag
|
||||
if git tag -l "$checkpoint_id" | grep -q "$checkpoint_id"; then
|
||||
echo -e "${YELLOW}Type:${NC} Git Tag"
|
||||
echo -e "${YELLOW}Commit:${NC} $(git rev-list -n 1 "$checkpoint_id")"
|
||||
echo -e "${YELLOW}Date:${NC} $(git log -1 --format=%ai "$checkpoint_id")"
|
||||
echo -e "${YELLOW}Message:${NC}"
|
||||
git log -1 --format=%B "$checkpoint_id" | sed 's/^/ /'
|
||||
echo ""
|
||||
echo -e "${YELLOW}Files changed:${NC}"
|
||||
git diff-tree --no-commit-id --name-status -r "$checkpoint_id" | sed 's/^/ /'
|
||||
# Check if it's a branch
|
||||
elif git branch -a | grep -q "$checkpoint_id"; then
|
||||
echo -e "${YELLOW}Type:${NC} Git Branch"
|
||||
echo -e "${YELLOW}Latest commit:${NC}"
|
||||
git log -1 --oneline "$checkpoint_id"
|
||||
else
|
||||
echo -e "${RED}❌ Checkpoint not found: $checkpoint_id${NC}"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Rollback to checkpoint
|
||||
function rollback_checkpoint() {
|
||||
local checkpoint_id="$1"
|
||||
local mode="$2"
|
||||
|
||||
echo -e "${YELLOW}🔄 Rolling back to checkpoint: $checkpoint_id${NC}"
|
||||
echo ""
|
||||
|
||||
# Verify checkpoint exists
|
||||
if ! git tag -l "$checkpoint_id" | grep -q "$checkpoint_id" && \
|
||||
! git branch -a | grep -q "$checkpoint_id"; then
|
||||
echo -e "${RED}❌ Checkpoint not found: $checkpoint_id${NC}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Create backup before rollback
|
||||
local backup_name="backup-$(date +%Y%m%d-%H%M%S)"
|
||||
echo "Creating backup: $backup_name"
|
||||
git tag "$backup_name" -m "Backup before rollback to $checkpoint_id"
|
||||
|
||||
case "$mode" in
|
||||
"--hard")
|
||||
echo -e "${RED}⚠️ Performing hard reset (destructive)${NC}"
|
||||
git reset --hard "$checkpoint_id"
|
||||
echo -e "${GREEN}✅ Rolled back to $checkpoint_id (hard reset)${NC}"
|
||||
;;
|
||||
"--branch")
|
||||
local branch_name="rollback-$checkpoint_id-$(date +%Y%m%d-%H%M%S)"
|
||||
echo "Creating new branch: $branch_name"
|
||||
git checkout -b "$branch_name" "$checkpoint_id"
|
||||
echo -e "${GREEN}✅ Created branch $branch_name from $checkpoint_id${NC}"
|
||||
;;
|
||||
"--stash"|*)
|
||||
echo "Stashing current changes..."
|
||||
git stash push -m "Stash before rollback to $checkpoint_id"
|
||||
git reset --soft "$checkpoint_id"
|
||||
echo -e "${GREEN}✅ Rolled back to $checkpoint_id (soft reset)${NC}"
|
||||
echo "Your changes are stashed. Use 'git stash pop' to restore them."
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# Show diff since checkpoint
|
||||
function diff_checkpoint() {
|
||||
local checkpoint_id="$1"
|
||||
|
||||
echo -e "${BLUE}📊 Changes since checkpoint: $checkpoint_id${NC}"
|
||||
echo ""
|
||||
|
||||
if git tag -l "$checkpoint_id" | grep -q "$checkpoint_id"; then
|
||||
git diff "$checkpoint_id"
|
||||
elif git branch -a | grep -q "$checkpoint_id"; then
|
||||
git diff "$checkpoint_id"
|
||||
else
|
||||
echo -e "${RED}❌ Checkpoint not found: $checkpoint_id${NC}"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Clean old checkpoints
|
||||
function clean_checkpoints() {
|
||||
local days=${1:-7}
|
||||
|
||||
echo -e "${YELLOW}🧹 Cleaning checkpoints older than $days days...${NC}"
|
||||
echo ""
|
||||
|
||||
# Clean old checkpoint files
|
||||
if [ -d "$CHECKPOINT_DIR" ]; then
|
||||
find "$CHECKPOINT_DIR" -name "*.json" -type f -mtime +$days -delete
|
||||
echo "✅ Cleaned old checkpoint files"
|
||||
fi
|
||||
|
||||
# List old tags (but don't delete automatically)
|
||||
echo ""
|
||||
echo "Old checkpoint tags (manual deletion required):"
|
||||
git tag -l 'checkpoint-*' --sort=-creatordate | tail -n +50 || echo "No old tags found"
|
||||
}
|
||||
|
||||
# Show session summary
|
||||
function show_summary() {
|
||||
echo -e "${BLUE}📊 Session Summary${NC}"
|
||||
echo ""
|
||||
|
||||
# Find most recent session summary
|
||||
if [ -d "$CHECKPOINT_DIR" ]; then
|
||||
local latest_summary=$(find "$CHECKPOINT_DIR" -name "summary-*.md" -type f -printf "%T@ %p\n" | \
|
||||
sort -rn | head -1 | cut -d' ' -f2-)
|
||||
|
||||
if [ -n "$latest_summary" ]; then
|
||||
echo -e "${YELLOW}Latest session summary:${NC}"
|
||||
cat "$latest_summary"
|
||||
else
|
||||
echo "No session summaries found"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Main command handling
|
||||
case "$1" in
|
||||
list)
|
||||
list_checkpoints
|
||||
;;
|
||||
show)
|
||||
if [ -z "$2" ]; then
|
||||
echo -e "${RED}Error: Please specify a checkpoint ID${NC}"
|
||||
show_help
|
||||
exit 1
|
||||
fi
|
||||
show_checkpoint "$2"
|
||||
;;
|
||||
rollback)
|
||||
if [ -z "$2" ]; then
|
||||
echo -e "${RED}Error: Please specify a checkpoint ID${NC}"
|
||||
show_help
|
||||
exit 1
|
||||
fi
|
||||
rollback_checkpoint "$2" "$3"
|
||||
;;
|
||||
diff)
|
||||
if [ -z "$2" ]; then
|
||||
echo -e "${RED}Error: Please specify a checkpoint ID${NC}"
|
||||
show_help
|
||||
exit 1
|
||||
fi
|
||||
diff_checkpoint "$2"
|
||||
;;
|
||||
clean)
|
||||
clean_checkpoints "$2"
|
||||
;;
|
||||
summary)
|
||||
show_summary
|
||||
;;
|
||||
help|--help|-h)
|
||||
show_help
|
||||
;;
|
||||
*)
|
||||
echo -e "${RED}Error: Unknown command: $1${NC}"
|
||||
echo ""
|
||||
show_help
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
# Checkpoint manager for Claude Flow
|
||||
# Use github-checkpoint-hooks.sh for checkpoint operations
|
||||
+63
-19
@@ -5,7 +5,9 @@
|
||||
"CLAUDE_FLOW_HOOKS_ENABLED": "true",
|
||||
"CLAUDE_FLOW_TELEMETRY_ENABLED": "true",
|
||||
"CLAUDE_FLOW_REMOTE_EXECUTION": "true",
|
||||
"CLAUDE_FLOW_GITHUB_INTEGRATION": "true"
|
||||
"CLAUDE_FLOW_GITHUB_INTEGRATION": "true",
|
||||
"CLAUDE_FLOW_CHECKPOINTS_ENABLED": "true",
|
||||
"CREATE_GH_RELEASE": "true"
|
||||
},
|
||||
"permissions": {
|
||||
"allow": [
|
||||
@@ -20,11 +22,32 @@
|
||||
"Bash(git commit *)",
|
||||
"Bash(git push)",
|
||||
"Bash(git config *)",
|
||||
"Bash(git tag *)",
|
||||
"Bash(git branch *)",
|
||||
"Bash(git checkout *)",
|
||||
"Bash(git stash *)",
|
||||
"Bash(git reset *)",
|
||||
"Bash(git rev-parse *)",
|
||||
"Bash(git ls-files *)",
|
||||
"Bash(gh *)",
|
||||
"Bash(node *)",
|
||||
"Bash(which *)",
|
||||
"Bash(pwd)",
|
||||
"Bash(ls *)"
|
||||
"Bash(ls *)",
|
||||
"Bash(jq *)",
|
||||
"Bash(test *)",
|
||||
"Bash(find *)",
|
||||
"Bash(grep *)",
|
||||
"Bash(sed *)",
|
||||
"Bash(awk *)",
|
||||
"Bash(curl *)",
|
||||
"Bash(mkdir *)",
|
||||
"Bash(cd *)",
|
||||
"Bash(cat *)",
|
||||
"Bash(echo *)",
|
||||
"Bash(npx claude-flow@alpha *)",
|
||||
"Bash(./claude-flow *)",
|
||||
"Bash(./.claude/helpers/*)"
|
||||
],
|
||||
"deny": [
|
||||
"Bash(rm -rf /)",
|
||||
@@ -50,6 +73,10 @@
|
||||
{
|
||||
"type": "command",
|
||||
"command": "cat | jq -r '.tool_input.file_path // .tool_input.path // empty' | tr '\\n' '\\0' | xargs -0 -I {} npx claude-flow@alpha hooks pre-edit --file '{}' --auto-assign-agents true --load-context true"
|
||||
},
|
||||
{
|
||||
"type": "command",
|
||||
"command": "./.claude/helpers/github-checkpoint-hooks.sh pre-edit \"{{tool_input}}\""
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -70,6 +97,34 @@
|
||||
{
|
||||
"type": "command",
|
||||
"command": "cat | jq -r '.tool_input.file_path // .tool_input.path // empty' | tr '\\n' '\\0' | xargs -0 -I {} npx claude-flow@alpha hooks post-edit --file '{}' --format true --update-memory true"
|
||||
},
|
||||
{
|
||||
"type": "command",
|
||||
"command": "./.claude/helpers/github-checkpoint-hooks.sh post-edit \"{{tool_input}}\""
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"UserPromptSubmit": [
|
||||
{
|
||||
"hooks": [
|
||||
{
|
||||
"type": "command",
|
||||
"command": "./.claude/helpers/github-checkpoint-hooks.sh task \"{{user_prompt}}\""
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"Stop": [
|
||||
{
|
||||
"hooks": [
|
||||
{
|
||||
"type": "command",
|
||||
"command": "npx claude-flow@alpha hooks session-end --generate-summary true --persist-state true --export-metrics true"
|
||||
},
|
||||
{
|
||||
"type": "command",
|
||||
"command": "./.claude/helpers/github-checkpoint-hooks.sh session-end"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -80,7 +135,7 @@
|
||||
"hooks": [
|
||||
{
|
||||
"type": "command",
|
||||
"command": "/bin/bash -c 'INPUT=$(cat); CUSTOM=$(echo \"$INPUT\" | jq -r \".custom_instructions // \\\"\\\"\"); echo \"🔄 PreCompact Guidance:\"; echo \"📋 IMPORTANT: Review CLAUDE.md in project root for:\"; echo \" • 54 available agents and concurrent usage patterns\"; echo \" • Swarm coordination strategies (hierarchical, mesh, adaptive)\"; echo \" • SPARC methodology workflows with batchtools optimization\"; echo \" • Critical concurrent execution rules (GOLDEN RULE: 1 MESSAGE = ALL OPERATIONS)\"; if [ -n \"$CUSTOM\" ]; then echo \"🎯 Custom compact instructions: $CUSTOM\"; fi; echo \"✅ Ready for compact operation\"'"
|
||||
"command": "/bin/bash -c 'INPUT=$(cat); CUSTOM=$(echo \"$INPUT\" | jq -r \".custom_instructions // \"\"\"); echo \"🔄 PreCompact Guidance:\"; echo \"📋 IMPORTANT: Review CLAUDE.md in project root for:\"; echo \" • 54 available agents and concurrent usage patterns\"; echo \" • Swarm coordination strategies (hierarchical, mesh, adaptive)\"; echo \" • SPARC methodology workflows with batchtools optimization\"; echo \" • Critical concurrent execution rules (GOLDEN RULE: 1 MESSAGE = ALL OPERATIONS)\"; if [ -n \"$CUSTOM\" ]; then echo \"🎯 Custom compact instructions: $CUSTOM\"; fi; echo \"✅ Ready for compact operation\"'"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -93,22 +148,11 @@
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"Stop": [
|
||||
{
|
||||
"hooks": [
|
||||
{
|
||||
"type": "command",
|
||||
"command": "/usr/bin/env bash -c 'if command -v npx >/dev/null 2>&1; then npx claude-flow@alpha hooks session-end --generate-summary true --persist-state true --export-metrics true; else echo \"⚠️ npx not available, skipping Claude Flow session-end hook\"; fi'"
|
||||
},
|
||||
{
|
||||
"type": "command",
|
||||
"command": "/usr/bin/env bash -c 'if [ -f ./.claude/helpers/standard-checkpoint-hooks.sh ]; then ./.claude/helpers/standard-checkpoint-hooks.sh session-end; else echo \"⚠️ Checkpoint hooks not found\"; fi'"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"includeCoAuthoredBy": true,
|
||||
"enabledMcpjsonServers": ["claude-flow", "ruv-swarm"]
|
||||
}
|
||||
"enabledMcpjsonServers": [
|
||||
"claude-flow",
|
||||
"ruv-swarm"
|
||||
]
|
||||
}
|
||||
Reference in new issue
Block a user