mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-10 02:24:35 +08:00
feat: Update workflow architecture documentation and clean up scripts
- Update agent definitions with enhanced context and flow control - Standardize command templates for consistent CLI tool integration - Improve gemini-wrapper with better token management and path handling - Simplify qwen-wrapper for streamlined execution - Enhance intelligent-tools-strategy with directory navigation patterns - Add proper quoting for Windows path compatibility in all commands - Update workflow planning documentation with current architectural insights These changes align the command system with the four-layer architecture analysis and improve cross-platform compatibility. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -3,8 +3,8 @@
|
||||
# Location: ~/.claude/scripts/gemini-wrapper
|
||||
#
|
||||
# This wrapper automatically manages --all-files flag based on project token count
|
||||
# Usage: gemini-wrapper [-C <directory>] [all gemini options]
|
||||
# -C <directory> Change to specified directory before analysis (relative or absolute path)
|
||||
# Usage: gemini-wrapper [all gemini options]
|
||||
# Note: Executes in current working directory
|
||||
|
||||
set -e
|
||||
|
||||
@@ -18,20 +18,72 @@ GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Function to count tokens (approximate: chars/4)
|
||||
# Function to count tokens (approximate: chars/4) - optimized version
|
||||
count_tokens() {
|
||||
local total_chars=0
|
||||
local file_count=0
|
||||
|
||||
# Count characters in common source files
|
||||
while IFS= read -r -d '' file; do
|
||||
if [[ -f "$file" && -r "$file" ]]; then
|
||||
local chars=$(wc -c < "$file" 2>/dev/null || echo 0)
|
||||
total_chars=$((total_chars + chars))
|
||||
file_count=$((file_count + 1))
|
||||
|
||||
# Use single find with bulk wc for better performance
|
||||
# Common source file extensions
|
||||
local extensions="py js ts tsx jsx java cpp c h rs go md txt json yaml yml xml html css scss sass php rb sh bash"
|
||||
|
||||
# Build find command with extension patterns
|
||||
local find_cmd="find . -type f \("
|
||||
local first=true
|
||||
for ext in $extensions; do
|
||||
if [[ "$first" == true ]]; then
|
||||
find_cmd+=" -name \"*.$ext\""
|
||||
first=false
|
||||
else
|
||||
find_cmd+=" -o -name \"*.$ext\""
|
||||
fi
|
||||
done < <(find . -type f \( -name "*.py" -o -name "*.js" -o -name "*.ts" -o -name "*.tsx" -o -name "*.jsx" -o -name "*.java" -o -name "*.cpp" -o -name "*.c" -o -name "*.h" -o -name "*.rs" -o -name "*.go" -o -name "*.md" -o -name "*.txt" -o -name "*.json" -o -name "*.yaml" -o -name "*.yml" -o -name "*.xml" -o -name "*.html" -o -name "*.css" -o -name "*.scss" -o -name "*.sass" -o -name "*.php" -o -name "*.rb" -o -name "*.sh" -o -name "*.bash" \) -not -path "*/node_modules/*" -not -path "*/.git/*" -not -path "*/dist/*" -not -path "*/build/*" -not -path "*/.next/*" -not -path "*/.nuxt/*" -not -path "*/target/*" -not -path "*/vendor/*" -print0 2>/dev/null)
|
||||
|
||||
done
|
||||
find_cmd+=" \)"
|
||||
|
||||
# Exclude common build/cache directories
|
||||
find_cmd+=" -not -path \"*/node_modules/*\""
|
||||
find_cmd+=" -not -path \"*/.git/*\""
|
||||
find_cmd+=" -not -path \"*/dist/*\""
|
||||
find_cmd+=" -not -path \"*/build/*\""
|
||||
find_cmd+=" -not -path \"*/.next/*\""
|
||||
find_cmd+=" -not -path \"*/.nuxt/*\""
|
||||
find_cmd+=" -not -path \"*/target/*\""
|
||||
find_cmd+=" -not -path \"*/vendor/*\""
|
||||
find_cmd+=" -not -path \"*/__pycache__/*\""
|
||||
find_cmd+=" -not -path \"*/.cache/*\""
|
||||
find_cmd+=" 2>/dev/null"
|
||||
|
||||
# Use efficient bulk processing with wc
|
||||
if command -v wc >/dev/null 2>&1; then
|
||||
# Try bulk wc first - much faster for many files
|
||||
local wc_output
|
||||
wc_output=$(eval "$find_cmd" | xargs wc -c 2>/dev/null | tail -n 1)
|
||||
|
||||
# Parse the total line (last line of wc output when processing multiple files)
|
||||
if [[ -n "$wc_output" && "$wc_output" =~ ^[[:space:]]*([0-9]+)[[:space:]]+total[[:space:]]*$ ]]; then
|
||||
total_chars="${BASH_REMATCH[1]}"
|
||||
file_count=$(eval "$find_cmd" | wc -l 2>/dev/null || echo 0)
|
||||
else
|
||||
# Fallback: single file processing
|
||||
while IFS= read -r file; do
|
||||
if [[ -f "$file" && -r "$file" ]]; then
|
||||
local chars=$(wc -c < "$file" 2>/dev/null || echo 0)
|
||||
total_chars=$((total_chars + chars))
|
||||
file_count=$((file_count + 1))
|
||||
fi
|
||||
done < <(eval "$find_cmd")
|
||||
fi
|
||||
else
|
||||
# No wc available - fallback method
|
||||
while IFS= read -r file; do
|
||||
if [[ -f "$file" && -r "$file" ]]; then
|
||||
local chars=$(stat -c%s "$file" 2>/dev/null || echo 0)
|
||||
total_chars=$((total_chars + chars))
|
||||
file_count=$((file_count + 1))
|
||||
fi
|
||||
done < <(eval "$find_cmd")
|
||||
fi
|
||||
|
||||
local estimated_tokens=$((total_chars / 4))
|
||||
echo "$estimated_tokens $file_count"
|
||||
}
|
||||
@@ -39,13 +91,10 @@ count_tokens() {
|
||||
# Parse arguments to check for flags
|
||||
has_all_files=false
|
||||
has_approval_mode=false
|
||||
change_dir=""
|
||||
args=()
|
||||
|
||||
# Check for existing flags and -c parameter
|
||||
i=0
|
||||
while [[ $i -lt $# ]]; do
|
||||
arg="${!i}"
|
||||
# Check for existing flags
|
||||
for arg in "$@"; do
|
||||
case "$arg" in
|
||||
"--all-files")
|
||||
has_all_files=true
|
||||
@@ -55,39 +104,14 @@ while [[ $i -lt $# ]]; do
|
||||
has_approval_mode=true
|
||||
args+=("$arg")
|
||||
;;
|
||||
"-C")
|
||||
# Next argument is the directory
|
||||
i=$((i + 1))
|
||||
if [[ $i -lt $# ]]; then
|
||||
change_dir="${!i}"
|
||||
echo -e "${YELLOW}📁 Directory change requested: $change_dir${NC}" >&2
|
||||
else
|
||||
echo -e "${RED}❌ Error: -C requires a directory path${NC}" >&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
args+=("$arg")
|
||||
;;
|
||||
esac
|
||||
i=$((i + 1))
|
||||
done
|
||||
|
||||
# Change directory if requested
|
||||
original_dir=""
|
||||
if [[ -n "$change_dir" ]]; then
|
||||
original_dir=$(pwd)
|
||||
if [[ -d "$change_dir" ]]; then
|
||||
echo -e "${GREEN}📁 Changing to directory: $change_dir${NC}" >&2
|
||||
cd "$change_dir" || {
|
||||
echo -e "${RED}❌ Error: Cannot change to directory: $change_dir${NC}" >&2
|
||||
exit 1
|
||||
}
|
||||
else
|
||||
echo -e "${RED}❌ Error: Directory does not exist: $change_dir${NC}" >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
# Analyze current working directory
|
||||
echo -e "${GREEN}📁 Analyzing current directory: $(pwd)${NC}" >&2
|
||||
|
||||
# Count tokens (in the target directory if -c was used)
|
||||
echo -e "${YELLOW}🔍 Analyzing project size...${NC}" >&2
|
||||
@@ -137,5 +161,5 @@ fi
|
||||
# Show final command (for transparency)
|
||||
echo -e "${YELLOW}🚀 Executing: gemini ${args[*]}${NC}" >&2
|
||||
|
||||
# Execute gemini with adjusted arguments
|
||||
exec gemini "${args[@]}"
|
||||
# Execute gemini with adjusted arguments (we're already in the right directory)
|
||||
gemini "${args[@]}"
|
||||
@@ -3,8 +3,8 @@
|
||||
# Location: ~/.claude/scripts/qwen-wrapper
|
||||
#
|
||||
# This wrapper automatically manages --all-files flag based on project token count
|
||||
# Usage: qwen-wrapper [-C <directory>] [all qwen options]
|
||||
# -C <directory> Change to specified directory before analysis (relative or absolute path)
|
||||
# Usage: qwen-wrapper [all qwen options]
|
||||
# Note: Executes in current working directory
|
||||
|
||||
set -e
|
||||
|
||||
@@ -39,13 +39,10 @@ count_tokens() {
|
||||
# Parse arguments to check for flags
|
||||
has_all_files=false
|
||||
has_approval_mode=false
|
||||
change_dir=""
|
||||
args=()
|
||||
|
||||
# Check for existing flags and -c parameter
|
||||
i=0
|
||||
while [[ $i -lt $# ]]; do
|
||||
arg="${!i}"
|
||||
# Check for existing flags
|
||||
for arg in "$@"; do
|
||||
case "$arg" in
|
||||
"--all-files")
|
||||
has_all_files=true
|
||||
@@ -55,39 +52,14 @@ while [[ $i -lt $# ]]; do
|
||||
has_approval_mode=true
|
||||
args+=("$arg")
|
||||
;;
|
||||
"-C")
|
||||
# Next argument is the directory
|
||||
i=$((i + 1))
|
||||
if [[ $i -lt $# ]]; then
|
||||
change_dir="${!i}"
|
||||
echo -e "${YELLOW}📁 Directory change requested: $change_dir${NC}" >&2
|
||||
else
|
||||
echo -e "${RED}❌ Error: -C requires a directory path${NC}" >&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
args+=("$arg")
|
||||
;;
|
||||
esac
|
||||
i=$((i + 1))
|
||||
done
|
||||
|
||||
# Change directory if requested
|
||||
original_dir=""
|
||||
if [[ -n "$change_dir" ]]; then
|
||||
original_dir=$(pwd)
|
||||
if [[ -d "$change_dir" ]]; then
|
||||
echo -e "${GREEN}📁 Changing to directory: $change_dir${NC}" >&2
|
||||
cd "$change_dir" || {
|
||||
echo -e "${RED}❌ Error: Cannot change to directory: $change_dir${NC}" >&2
|
||||
exit 1
|
||||
}
|
||||
else
|
||||
echo -e "${RED}❌ Error: Directory does not exist: $change_dir${NC}" >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
# Analyze current working directory
|
||||
echo -e "${GREEN}📁 Analyzing current directory: $(pwd)${NC}" >&2
|
||||
|
||||
# Count tokens (in the target directory if -c was used)
|
||||
echo -e "${YELLOW}🔍 Analyzing project size...${NC}" >&2
|
||||
@@ -137,5 +109,5 @@ fi
|
||||
# Show final command (for transparency)
|
||||
echo -e "${YELLOW}🚀 Executing: qwen ${args[*]}${NC}" >&2
|
||||
|
||||
# Execute qwen with adjusted arguments
|
||||
exec qwen "${args[@]}"
|
||||
# Execute qwen with adjusted arguments (we're already in the right directory)
|
||||
qwen "${args[@]}"
|
||||
Reference in New Issue
Block a user