mirror of
https://github.com/affaan-m/everything-claude-code.git
synced 2026-03-30 13:43:26 +08:00
feat: add .trae directory with install/uninstall scripts
- Add install.sh for Trae IDE integration - Add uninstall.sh with manifest-based safe removal - Add README.md (English) - Add README.zh-CN.md (Chinese) - Support local and global installation - Support TRAE_ENV=cn for CN environment - Non-destructive installation (won't overwrite existing files) - Manifest-based uninstallation (preserves user files) Change-Id: I9870874e272fffd9e1966d9bc40d20142314b969
This commit is contained in:
183
.trae/README.md
Normal file
183
.trae/README.md
Normal file
@@ -0,0 +1,183 @@
|
||||
# Everything Claude Code for Trae
|
||||
|
||||
Bring [Everything Claude Code](https://github.com/anthropics/courses/tree/master/everything-claude-code) (ECC) workflows to Trae IDE. This repository provides custom commands, agents, skills, and rules that can be installed into any Trae project with a single command.
|
||||
|
||||
## Quick Start
|
||||
|
||||
### Option 1: Local Installation (Current Project Only)
|
||||
|
||||
```bash
|
||||
# Install to current project
|
||||
cd /path/to/your/project
|
||||
TRAE_ENV=cn .trae/install.sh
|
||||
```
|
||||
|
||||
This creates `.trae-cn/` in your project directory.
|
||||
|
||||
### Option 2: Global Installation (All Projects)
|
||||
|
||||
```bash
|
||||
# Install globally to ~/.trae-cn/
|
||||
cd /path/to/your/project
|
||||
TRAE_ENV=cn .trae/install.sh ~
|
||||
|
||||
# Or from the .trae folder directly
|
||||
cd /path/to/your/project/.trae
|
||||
TRAE_ENV=cn ./install.sh ~
|
||||
```
|
||||
|
||||
This creates `~/.trae-cn/` which applies to all Trae projects.
|
||||
|
||||
### Option 3: Quick Install to Current Directory
|
||||
|
||||
```bash
|
||||
# If already in project directory with .trae folder
|
||||
cd .trae
|
||||
./install.sh
|
||||
```
|
||||
|
||||
The installer uses non-destructive copy - it will not overwrite your existing files.
|
||||
|
||||
## Installation Modes
|
||||
|
||||
### Local Installation
|
||||
|
||||
Install to the current project's `.trae-cn` directory:
|
||||
|
||||
```bash
|
||||
cd /path/to/your/project
|
||||
TRAE_ENV=cn .trae/install.sh
|
||||
```
|
||||
|
||||
This creates `/path/to/your/project/.trae-cn/` with all ECC components.
|
||||
|
||||
### Global Installation
|
||||
|
||||
Install to your home directory's `.trae-cn` directory (applies to all Trae projects):
|
||||
|
||||
```bash
|
||||
# From project directory
|
||||
TRAE_ENV=cn .trae/install.sh ~
|
||||
|
||||
# Or directly from .trae folder
|
||||
cd .trae
|
||||
TRAE_ENV=cn ./install.sh ~
|
||||
```
|
||||
|
||||
This creates `~/.trae-cn/` with all ECC components. All Trae projects will use these global installations.
|
||||
|
||||
**Note**: Global installation is useful when you want to maintain a single copy of ECC across all your projects.
|
||||
|
||||
## Environment Support
|
||||
|
||||
- **Default**: Uses `.trae` directory
|
||||
- **CN Environment**: Uses `.trae-cn` directory (set via `TRAE_ENV=cn`)
|
||||
|
||||
### Force Environment
|
||||
|
||||
```bash
|
||||
# Force CN environment (global setting)
|
||||
TRAE_ENV=cn ./install.sh
|
||||
|
||||
# Use default environment (default)
|
||||
./install.sh
|
||||
```
|
||||
|
||||
**Note**: `TRAE_ENV` is a global environment variable that applies to the entire installation session.
|
||||
|
||||
## Uninstall
|
||||
|
||||
The uninstaller uses a manifest file (`.ecc-manifest`) to track installed files, ensuring safe removal:
|
||||
|
||||
```bash
|
||||
# Uninstall from current directory (if already inside .trae or .trae-cn)
|
||||
cd .trae-cn
|
||||
./uninstall.sh
|
||||
|
||||
# Or uninstall from project root
|
||||
cd /path/to/your/project
|
||||
TRAE_ENV=cn .trae/uninstall.sh
|
||||
|
||||
# Uninstall globally from home directory
|
||||
TRAE_ENV=cn .trae/uninstall.sh ~
|
||||
|
||||
# Will ask for confirmation before uninstalling
|
||||
```
|
||||
|
||||
### Uninstall Behavior
|
||||
|
||||
- **Safe removal**: Only removes files tracked in the manifest (installed by ECC)
|
||||
- **User files preserved**: Any files you added manually are kept
|
||||
- **Non-empty directories**: Directories containing user-added files are skipped
|
||||
- **Manifest-based**: Requires `.ecc-manifest` file (created during install)
|
||||
|
||||
### Environment Support
|
||||
|
||||
Uninstall respects the same `TRAE_ENV` environment variable as install:
|
||||
|
||||
```bash
|
||||
# Uninstall from .trae-cn (CN environment)
|
||||
TRAE_ENV=cn ./uninstall.sh
|
||||
|
||||
# Uninstall from .trae (default environment)
|
||||
./uninstall.sh
|
||||
```
|
||||
|
||||
**Note**: If no manifest file is found (old installation), the uninstaller will ask whether to remove the entire directory.
|
||||
|
||||
## What's Included
|
||||
|
||||
### Commands
|
||||
|
||||
Commands are on-demand workflows invocable via the `/` menu in Trae chat. All commands are reused directly from the project root's `commands/` folder.
|
||||
|
||||
### Agents
|
||||
|
||||
Agents are specialized AI assistants with specific tool configurations. All agents are reused directly from the project root's `agents/` folder.
|
||||
|
||||
### Skills
|
||||
|
||||
Skills are on-demand workflows invocable via the `/` menu in chat. All skills are reused directly from the project's `skills/` folder.
|
||||
|
||||
### Rules
|
||||
|
||||
Rules provide always-on rules and context that shape how the agent works with your code. All rules are reused directly from the project root's `rules/` folder.
|
||||
|
||||
## Usage
|
||||
|
||||
1. Type `/` in chat to open the commands menu
|
||||
2. Select a command or skill
|
||||
3. The agent will guide you through the workflow with specific instructions and checklists
|
||||
|
||||
## Project Structure
|
||||
|
||||
```
|
||||
.trae/ (or .trae-cn/)
|
||||
├── commands/ # Command files (reused from project root)
|
||||
├── agents/ # Agent files (reused from project root)
|
||||
├── skills/ # Skill files (reused from skills/)
|
||||
├── rules/ # Rule files (reused from project root)
|
||||
├── install.sh # Install script
|
||||
├── uninstall.sh # Uninstall script
|
||||
└── README.md # This file
|
||||
```
|
||||
|
||||
## Customization
|
||||
|
||||
All files are yours to modify after installation. The installer never overwrites existing files, so your customizations are safe across re-installs.
|
||||
|
||||
**Note**: The `install.sh` and `uninstall.sh` scripts are automatically copied to the target directory during installation, so you can run these commands directly from your project.
|
||||
|
||||
## Recommended Workflow
|
||||
|
||||
1. **Start with planning**: Use `/plan` command to break down complex features
|
||||
2. **Write tests first**: Invoke `/tdd` command before implementing
|
||||
3. **Review your code**: Use `/code-review` after writing code
|
||||
4. **Check security**: Use `/code-review` again for auth, API endpoints, or sensitive data handling
|
||||
5. **Fix build errors**: Use `/build-fix` if there are build errors
|
||||
|
||||
## Next Steps
|
||||
|
||||
- Open your project in Trae
|
||||
- Type `/` to see available commands
|
||||
- Enjoy the ECC workflows!
|
||||
191
.trae/README.zh-CN.md
Normal file
191
.trae/README.zh-CN.md
Normal file
@@ -0,0 +1,191 @@
|
||||
# Everything Claude Code for Trae
|
||||
|
||||
为 Trae IDE 带来 [Everything Claude Code](https://github.com/anthropics/courses/tree/master/everything-claude-code) (ECC) 工作流。此仓库提供自定义命令、智能体、技能和规则,可以通过单个命令安装到任何 Trae 项目中。
|
||||
|
||||
## 快速开始
|
||||
|
||||
### 方式一:本地安装到 `.trae` 目录(默认环境)
|
||||
|
||||
```bash
|
||||
# 安装到当前项目的 .trae 目录
|
||||
cd /path/to/your/project
|
||||
.trae/install.sh
|
||||
```
|
||||
|
||||
这将在您的项目目录中创建 `.trae/`。
|
||||
|
||||
### 方式二:本地安装到 `.trae-cn` 目录(CN 环境)
|
||||
|
||||
```bash
|
||||
# 安装到当前项目的 .trae-cn 目录
|
||||
cd /path/to/your/project
|
||||
TRAE_ENV=cn .trae/install.sh
|
||||
```
|
||||
|
||||
这将在您的项目目录中创建 `.trae-cn/`。
|
||||
|
||||
### 方式三:全局安装到 `~/.trae` 目录(默认环境)
|
||||
|
||||
```bash
|
||||
# 全局安装到 ~/.trae/
|
||||
cd /path/to/your/project
|
||||
.trae/install.sh ~
|
||||
```
|
||||
|
||||
这将创建 `~/.trae/`,适用于所有 Trae 项目。
|
||||
|
||||
### 方式四:全局安装到 `~/.trae-cn` 目录(CN 环境)
|
||||
|
||||
```bash
|
||||
# 全局安装到 ~/.trae-cn/
|
||||
cd /path/to/your/project
|
||||
TRAE_ENV=cn .trae/install.sh ~
|
||||
```
|
||||
|
||||
这将创建 `~/.trae-cn/`,适用于所有 Trae 项目。
|
||||
|
||||
安装程序使用非破坏性复制 - 它不会覆盖您现有的文件。
|
||||
|
||||
## 安装模式
|
||||
|
||||
### 本地安装
|
||||
|
||||
安装到当前项目的 `.trae` 或 `.trae-cn` 目录:
|
||||
|
||||
```bash
|
||||
# 安装到当前项目的 .trae 目录(默认)
|
||||
cd /path/to/your/project
|
||||
.trae/install.sh
|
||||
|
||||
# 安装到当前项目的 .trae-cn 目录(CN 环境)
|
||||
cd /path/to/your/project
|
||||
TRAE_ENV=cn .trae/install.sh
|
||||
```
|
||||
|
||||
### 全局安装
|
||||
|
||||
安装到您主目录的 `.trae` 或 `.trae-cn` 目录(适用于所有 Trae 项目):
|
||||
|
||||
```bash
|
||||
# 全局安装到 ~/.trae/(默认)
|
||||
.trae/install.sh ~
|
||||
|
||||
# 全局安装到 ~/.trae-cn/(CN 环境)
|
||||
TRAE_ENV=cn .trae/install.sh ~
|
||||
```
|
||||
|
||||
**注意**:全局安装适用于希望在所有项目之间维护单个 ECC 副本的场景。
|
||||
|
||||
## 环境支持
|
||||
|
||||
- **默认**:使用 `.trae` 目录
|
||||
- **CN 环境**:使用 `.trae-cn` 目录(通过 `TRAE_ENV=cn` 设置)
|
||||
|
||||
### 强制指定环境
|
||||
|
||||
```bash
|
||||
# 强制使用 CN 环境
|
||||
TRAE_ENV=cn ./install.sh
|
||||
|
||||
# 使用默认环境
|
||||
./install.sh
|
||||
```
|
||||
|
||||
**注意**:`TRAE_ENV` 是一个全局环境变量,适用于整个安装会话。
|
||||
|
||||
## 卸载
|
||||
|
||||
卸载程序使用清单文件(`.ecc-manifest`)跟踪已安装的文件,确保安全删除:
|
||||
|
||||
```bash
|
||||
# 从当前目录卸载(如果已经在 .trae 或 .trae-cn 目录中)
|
||||
cd .trae-cn
|
||||
./uninstall.sh
|
||||
|
||||
# 或者从项目根目录卸载
|
||||
cd /path/to/your/project
|
||||
TRAE_ENV=cn .trae/uninstall.sh
|
||||
|
||||
# 从主目录全局卸载
|
||||
TRAE_ENV=cn .trae/uninstall.sh ~
|
||||
|
||||
# 卸载前会询问确认
|
||||
```
|
||||
|
||||
### 卸载行为
|
||||
|
||||
- **安全删除**:仅删除清单中跟踪的文件(由 ECC 安装的文件)
|
||||
- **保留用户文件**:您手动添加的任何文件都会被保留
|
||||
- **非空目录**:包含用户添加文件的目录会被跳过
|
||||
- **基于清单**:需要 `.ecc-manifest` 文件(在安装时创建)
|
||||
|
||||
### 环境支持
|
||||
|
||||
卸载程序遵循与安装程序相同的 `TRAE_ENV` 环境变量:
|
||||
|
||||
```bash
|
||||
# 从 .trae-cn 卸载(CN 环境)
|
||||
TRAE_ENV=cn ./uninstall.sh
|
||||
|
||||
# 从 .trae 卸载(默认环境)
|
||||
./uninstall.sh
|
||||
```
|
||||
|
||||
**注意**:如果找不到清单文件(旧版本安装),卸载程序将询问是否删除整个目录。
|
||||
|
||||
## 包含的内容
|
||||
|
||||
### 命令
|
||||
|
||||
命令是通过 Trae 聊天中的 `/` 菜单调用的按需工作流。所有命令都直接复用自项目根目录的 `commands/` 文件夹。
|
||||
|
||||
### 智能体
|
||||
|
||||
智能体是具有特定工具配置的专门 AI 助手。所有智能体都直接复用自项目根目录的 `agents/` 文件夹。
|
||||
|
||||
### 技能
|
||||
|
||||
技能是通过聊天中的 `/` 菜单调用的按需工作流。所有技能都直接复用自项目的 `skills/` 文件夹。
|
||||
|
||||
### 规则
|
||||
|
||||
规则提供始终适用的规则和上下文,塑造智能体处理代码的方式。所有规则都直接复用自项目根目录的 `rules/` 文件夹。
|
||||
|
||||
## 使用方法
|
||||
|
||||
1. 在聊天中输入 `/` 以打开命令菜单
|
||||
2. 选择一个命令或技能
|
||||
3. 智能体将通过具体说明和检查清单指导您完成工作流
|
||||
|
||||
## 项目结构
|
||||
|
||||
```
|
||||
.trae/ (或 .trae-cn/)
|
||||
├── commands/ # 命令文件(复用自项目根目录)
|
||||
├── agents/ # 智能体文件(复用自项目根目录)
|
||||
├── skills/ # 技能文件(复用自 skills/)
|
||||
├── rules/ # 规则文件(复用自项目根目录)
|
||||
├── install.sh # 安装脚本
|
||||
├── uninstall.sh # 卸载脚本
|
||||
└── README.md # 此文件
|
||||
```
|
||||
|
||||
## 自定义
|
||||
|
||||
安装后,所有文件都归您修改。安装程序永远不会覆盖现有文件,因此您的自定义在重新安装时是安全的。
|
||||
|
||||
**注意**:安装时会自动将 `install.sh` 和 `uninstall.sh` 脚本复制到目标目录,这样您可以在项目本地直接运行这些命令。
|
||||
|
||||
## 推荐的工作流
|
||||
|
||||
1. **从计划开始**:使用 `/plan` 命令分解复杂功能
|
||||
2. **先写测试**:在实现之前调用 `/tdd` 命令
|
||||
3. **审查您的代码**:编写代码后使用 `/code-review`
|
||||
4. **检查安全性**:对于身份验证、API 端点或敏感数据处理,再次使用 `/code-review`
|
||||
5. **修复构建错误**:如果有构建错误,使用 `/build-fix`
|
||||
|
||||
## 下一步
|
||||
|
||||
- 在 Trae 中打开您的项目
|
||||
- 输入 `/` 以查看可用命令
|
||||
- 享受 ECC 工作流!
|
||||
198
.trae/install.sh
Executable file
198
.trae/install.sh
Executable file
@@ -0,0 +1,198 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# ECC Trae Installer
|
||||
# Installs Everything Claude Code workflows into a Trae project.
|
||||
#
|
||||
# Usage:
|
||||
# ./install.sh # Install to current directory
|
||||
# ./install.sh ~ # Install globally to ~/.trae/ or ~/.trae-cn/
|
||||
#
|
||||
# Environment:
|
||||
# TRAE_ENV=cn # Force use .trae-cn directory
|
||||
#
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# When globs match nothing, expand to empty list instead of the literal pattern
|
||||
shopt -s nullglob
|
||||
|
||||
# Resolve the directory where this script lives (the repo root)
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
REPO_ROOT="$(dirname "$SCRIPT_DIR")"
|
||||
|
||||
# Get the trae directory name (.trae or .trae-cn)
|
||||
get_trae_dir() {
|
||||
if [ "${TRAE_ENV:-}" = "cn" ]; then
|
||||
echo ".trae-cn"
|
||||
else
|
||||
echo ".trae"
|
||||
fi
|
||||
}
|
||||
|
||||
# Install function
|
||||
do_install() {
|
||||
local target_dir="$PWD"
|
||||
local trae_dir="$(get_trae_dir)"
|
||||
|
||||
# Check if ~ was specified (or expanded to $HOME)
|
||||
if [ "$#" -ge 1 ]; then
|
||||
if [ "$1" = "~" ] || [ "$1" = "$HOME" ]; then
|
||||
target_dir="$HOME"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Check if we're already inside a .trae or .trae-cn directory
|
||||
local current_dir_name="$(basename "$target_dir")"
|
||||
local trae_full_path
|
||||
|
||||
if [ "$current_dir_name" = ".trae" ] || [ "$current_dir_name" = ".trae-cn" ]; then
|
||||
# Already inside the trae directory, use it directly
|
||||
trae_full_path="$target_dir"
|
||||
else
|
||||
# Normal case: append trae_dir to target_dir
|
||||
trae_full_path="$target_dir/$trae_dir"
|
||||
fi
|
||||
|
||||
echo "ECC Trae Installer"
|
||||
echo "=================="
|
||||
echo ""
|
||||
echo "Source: $REPO_ROOT"
|
||||
echo "Target: $trae_full_path/"
|
||||
echo ""
|
||||
|
||||
# Subdirectories to create
|
||||
SUBDIRS="commands agents skills rules"
|
||||
|
||||
# Create all required trae subdirectories
|
||||
for dir in $SUBDIRS; do
|
||||
mkdir -p "$trae_full_path/$dir"
|
||||
done
|
||||
|
||||
# Manifest file to track installed files
|
||||
MANIFEST="$trae_full_path/.ecc-manifest"
|
||||
rm -f "$MANIFEST"
|
||||
|
||||
# Counters for summary
|
||||
commands=0
|
||||
agents=0
|
||||
skills=0
|
||||
rules=0
|
||||
other=0
|
||||
|
||||
# Copy commands from repo root
|
||||
if [ -d "$REPO_ROOT/commands" ]; then
|
||||
for f in "$REPO_ROOT/commands"/*.md; do
|
||||
[ -f "$f" ] || continue
|
||||
local_name=$(basename "$f")
|
||||
target_path="$trae_full_path/commands/$local_name"
|
||||
if [ ! -f "$target_path" ]; then
|
||||
cp "$f" "$target_path" 2>/dev/null || true
|
||||
echo "commands/$local_name" >> "$MANIFEST"
|
||||
commands=$((commands + 1))
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
# Copy agents from repo root
|
||||
if [ -d "$REPO_ROOT/agents" ]; then
|
||||
for f in "$REPO_ROOT/agents"/*.md; do
|
||||
[ -f "$f" ] || continue
|
||||
local_name=$(basename "$f")
|
||||
target_path="$trae_full_path/agents/$local_name"
|
||||
if [ ! -f "$target_path" ]; then
|
||||
cp "$f" "$target_path" 2>/dev/null || true
|
||||
echo "agents/$local_name" >> "$MANIFEST"
|
||||
agents=$((agents + 1))
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
# Copy skills from repo root (if available)
|
||||
if [ -d "$REPO_ROOT/skills" ]; then
|
||||
for d in "$REPO_ROOT/skills"/*/; do
|
||||
[ -d "$d" ] || continue
|
||||
skill_name="$(basename "$d")"
|
||||
target_skill_dir="$trae_full_path/skills/$skill_name"
|
||||
if [ ! -d "$target_skill_dir" ]; then
|
||||
mkdir -p "$target_skill_dir"
|
||||
cp -r "$d"* "$target_skill_dir/" 2>/dev/null || true
|
||||
for skill_file in "$target_skill_dir"/*; do
|
||||
[ -f "$skill_file" ] || continue
|
||||
relative_path="skills/$skill_name/$(basename "$skill_file")"
|
||||
echo "$relative_path" >> "$MANIFEST"
|
||||
done
|
||||
echo "skills/$skill_name" >> "$MANIFEST"
|
||||
skills=$((skills + 1))
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
# Copy rules from repo root
|
||||
if [ -d "$REPO_ROOT/rules" ]; then
|
||||
if [ -d "$REPO_ROOT/rules/common" ]; then
|
||||
for f in "$REPO_ROOT/rules/common"/*.md; do
|
||||
[ -f "$f" ] || continue
|
||||
local_name=$(basename "$f")
|
||||
target_path="$trae_full_path/rules/$local_name"
|
||||
if [ ! -f "$target_path" ]; then
|
||||
cp "$f" "$target_path" 2>/dev/null || true
|
||||
echo "rules/$local_name" >> "$MANIFEST"
|
||||
rules=$((rules + 1))
|
||||
fi
|
||||
done
|
||||
fi
|
||||
fi
|
||||
|
||||
# Copy README files from this directory
|
||||
for readme_file in "$SCRIPT_DIR/README.md" "$SCRIPT_DIR/README.zh-CN.md"; do
|
||||
if [ -f "$readme_file" ]; then
|
||||
local_name=$(basename "$readme_file")
|
||||
target_path="$trae_full_path/$local_name"
|
||||
if [ ! -f "$target_path" ]; then
|
||||
cp "$readme_file" "$target_path" 2>/dev/null || true
|
||||
echo "$local_name" >> "$MANIFEST"
|
||||
other=$((other + 1))
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
# Copy install and uninstall scripts
|
||||
for script_file in "$SCRIPT_DIR/install.sh" "$SCRIPT_DIR/uninstall.sh"; do
|
||||
if [ -f "$script_file" ]; then
|
||||
local_name=$(basename "$script_file")
|
||||
target_path="$trae_full_path/$local_name"
|
||||
if [ ! -f "$target_path" ]; then
|
||||
cp "$script_file" "$target_path" 2>/dev/null || true
|
||||
chmod +x "$target_path" 2>/dev/null || true
|
||||
echo "$local_name" >> "$MANIFEST"
|
||||
other=$((other + 1))
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
# Add manifest file itself to manifest
|
||||
echo ".ecc-manifest" >> "$MANIFEST"
|
||||
|
||||
# Installation summary
|
||||
echo "Installation complete!"
|
||||
echo ""
|
||||
echo "Components installed:"
|
||||
echo " Commands: $commands"
|
||||
echo " Agents: $agents"
|
||||
echo " Skills: $skills"
|
||||
echo " Rules: $rules"
|
||||
echo ""
|
||||
echo "Directory: $(basename "$trae_full_path")"
|
||||
echo ""
|
||||
echo "Next steps:"
|
||||
echo " 1. Open your project in Trae"
|
||||
echo " 2. Type / to see available commands"
|
||||
echo " 3. Enjoy the ECC workflows!"
|
||||
echo ""
|
||||
echo "To uninstall later:"
|
||||
echo " cd $trae_full_path"
|
||||
echo " ./uninstall.sh"
|
||||
}
|
||||
|
||||
# Main logic
|
||||
do_install "$@"
|
||||
161
.trae/uninstall.sh
Executable file
161
.trae/uninstall.sh
Executable file
@@ -0,0 +1,161 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# ECC Trae Uninstaller
|
||||
# Uninstalls Everything Claude Code workflows from a Trae project.
|
||||
#
|
||||
# Usage:
|
||||
# ./uninstall.sh # Uninstall from current directory
|
||||
# ./uninstall.sh ~ # Uninstall globally from ~/.trae/
|
||||
#
|
||||
# Environment:
|
||||
# TRAE_ENV=cn # Force use .trae-cn directory
|
||||
#
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# Resolve the directory where this script lives
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
|
||||
# Get the trae directory name (.trae or .trae-cn)
|
||||
get_trae_dir() {
|
||||
# Check environment variable first
|
||||
if [ "${TRAE_ENV:-}" = "cn" ]; then
|
||||
echo ".trae-cn"
|
||||
else
|
||||
echo ".trae"
|
||||
fi
|
||||
}
|
||||
|
||||
# Main uninstall function
|
||||
do_uninstall() {
|
||||
local target_dir="$PWD"
|
||||
local trae_dir="$(get_trae_dir)"
|
||||
|
||||
# Check if ~ was specified (or expanded to $HOME)
|
||||
if [ "$#" -ge 1 ]; then
|
||||
if [ "$1" = "~" ] || [ "$1" = "$HOME" ]; then
|
||||
target_dir="$HOME"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Check if we're already inside a .trae or .trae-cn directory
|
||||
local current_dir_name="$(basename "$target_dir")"
|
||||
local trae_full_path
|
||||
|
||||
if [ "$current_dir_name" = ".trae" ] || [ "$current_dir_name" = ".trae-cn" ]; then
|
||||
# Already inside the trae directory, use it directly
|
||||
trae_full_path="$target_dir"
|
||||
else
|
||||
# Normal case: append trae_dir to target_dir
|
||||
trae_full_path="$target_dir/$trae_dir"
|
||||
fi
|
||||
|
||||
echo "ECC Trae Uninstaller"
|
||||
echo "===================="
|
||||
echo ""
|
||||
echo "Target: $trae_full_path/"
|
||||
echo ""
|
||||
|
||||
if [ ! -d "$trae_full_path" ]; then
|
||||
echo "Error: $trae_dir directory not found at $target_dir"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Manifest file path
|
||||
MANIFEST="$trae_full_path/.ecc-manifest"
|
||||
|
||||
if [ ! -f "$MANIFEST" ]; then
|
||||
echo "Warning: No manifest file found (.ecc-manifest)"
|
||||
echo ""
|
||||
echo "This could mean:"
|
||||
echo " 1. ECC was installed with an older version without manifest support"
|
||||
echo " 2. The manifest file was manually deleted"
|
||||
echo ""
|
||||
read -p "Do you want to remove the entire $trae_dir directory? (y/N) " -n 1 -r
|
||||
echo
|
||||
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
||||
echo "Uninstall cancelled."
|
||||
exit 0
|
||||
fi
|
||||
rm -rf "$trae_full_path"
|
||||
echo "Uninstall complete!"
|
||||
echo ""
|
||||
echo "Removed: $trae_full_path/"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "Found manifest file - will only remove files installed by ECC"
|
||||
echo ""
|
||||
read -p "Are you sure you want to uninstall ECC from $trae_dir? (y/N) " -n 1 -r
|
||||
echo
|
||||
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
||||
echo "Uninstall cancelled."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Counters
|
||||
removed=0
|
||||
skipped=0
|
||||
|
||||
# Read manifest and remove files
|
||||
while IFS= read -r file_path; do
|
||||
[ -z "$file_path" ] && continue
|
||||
|
||||
full_path="$trae_full_path/$file_path"
|
||||
|
||||
if [ -f "$full_path" ]; then
|
||||
rm -f "$full_path"
|
||||
echo "Removed: $file_path"
|
||||
removed=$((removed + 1))
|
||||
elif [ -d "$full_path" ]; then
|
||||
# Only remove directory if it's empty
|
||||
if [ -z "$(ls -A "$full_path" 2>/dev/null)" ]; then
|
||||
rmdir "$full_path" 2>/dev/null || true
|
||||
if [ ! -d "$full_path" ]; then
|
||||
echo "Removed: $file_path/"
|
||||
removed=$((removed + 1))
|
||||
fi
|
||||
else
|
||||
echo "Skipped: $file_path/ (not empty - contains user files)"
|
||||
skipped=$((skipped + 1))
|
||||
fi
|
||||
else
|
||||
skipped=$((skipped + 1))
|
||||
fi
|
||||
done < "$MANIFEST"
|
||||
|
||||
# Try to remove subdirectories if they're empty
|
||||
for subdir in commands agents skills rules; do
|
||||
subdir_path="$trae_full_path/$subdir"
|
||||
if [ -d "$subdir_path" ] && [ -z "$(ls -A "$subdir_path" 2>/dev/null)" ]; then
|
||||
rmdir "$subdir_path" 2>/dev/null || true
|
||||
if [ ! -d "$subdir_path" ]; then
|
||||
echo "Removed: $subdir/"
|
||||
removed=$((removed + 1))
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
# Try to remove the main trae directory if it's empty
|
||||
if [ -d "$trae_full_path" ] && [ -z "$(ls -A "$trae_full_path" 2>/dev/null)" ]; then
|
||||
rmdir "$trae_full_path" 2>/dev/null || true
|
||||
if [ ! -d "$trae_full_path" ]; then
|
||||
echo "Removed: $trae_dir/"
|
||||
removed=$((removed + 1))
|
||||
fi
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "Uninstall complete!"
|
||||
echo ""
|
||||
echo "Summary:"
|
||||
echo " Removed: $removed items"
|
||||
echo " Skipped: $skipped items (not found or user-modified)"
|
||||
echo ""
|
||||
if [ -d "$trae_full_path" ]; then
|
||||
echo "Note: $trae_dir directory still exists (contains user-added files)"
|
||||
fi
|
||||
}
|
||||
|
||||
# Execute uninstall
|
||||
do_uninstall "$@"
|
||||
Reference in New Issue
Block a user