From cab139ba93d690944789cffd0c69002f9ea87041 Mon Sep 17 00:00:00 2001 From: wolone Date: Tue, 7 Oct 2025 12:47:09 +0800 Subject: [PATCH 1/2] feat: Add support for Trae AI Added support for Trae AI across multiple files, including: - Updated CI scripts to include Trae AI release packages - Added Trae AI installation instructions in documentation - Added Trae AI integration guide in AGENTS.md - Updated Python and Shell scripts to support Trae AI' --- .../workflows/scripts/create-github-release.sh | 2 ++ .../workflows/scripts/create-release-packages.sh | 5 ++++- AGENTS.md | 16 ++++++++++++---- README.md | 5 +++-- docs/installation.md | 3 ++- scripts/bash/update-agent-context.sh | 15 ++++++++++++--- scripts/powershell/update-agent-context.ps1 | 9 ++++++--- src/specify_cli/__init__.py | 10 +++++++--- 8 files changed, 48 insertions(+), 17 deletions(-) diff --git a/.github/workflows/scripts/create-github-release.sh b/.github/workflows/scripts/create-github-release.sh index 26b08880a..443de5e37 100644 --- a/.github/workflows/scripts/create-github-release.sh +++ b/.github/workflows/scripts/create-github-release.sh @@ -40,5 +40,7 @@ gh release create "$VERSION" \ .genreleases/spec-kit-template-roo-ps-"$VERSION".zip \ .genreleases/spec-kit-template-q-sh-"$VERSION".zip \ .genreleases/spec-kit-template-q-ps-"$VERSION".zip \ + .genreleases/spec-kit-template-trae-sh-"$VERSION".zip \ + .genreleases/spec-kit-template-trae-ps-"$VERSION".zip \ --title "Spec Kit Templates - $VERSION_NO_V" \ --notes-file release_notes.md \ No newline at end of file diff --git a/.github/workflows/scripts/create-release-packages.sh b/.github/workflows/scripts/create-release-packages.sh index 82601c600..6565fdaf7 100644 --- a/.github/workflows/scripts/create-release-packages.sh +++ b/.github/workflows/scripts/create-release-packages.sh @@ -175,13 +175,16 @@ build_variant() { q) mkdir -p "$base_dir/.amazonq/prompts" generate_commands q md "\$ARGUMENTS" "$base_dir/.amazonq/prompts" "$script" ;; + trae) + mkdir -p "$base_dir/.trae/workflows" + generate_commands trae md "\$ARGUMENTS" "$base_dir/.trae/workflows" "$script" ;; esac ( cd "$base_dir" && zip -r "../spec-kit-template-${agent}-${script}-${NEW_VERSION}.zip" . ) echo "Created $GENRELEASES_DIR/spec-kit-template-${agent}-${script}-${NEW_VERSION}.zip" } # Determine agent list -ALL_AGENTS=(claude gemini copilot cursor qwen opencode windsurf codex kilocode auggie roo q) +ALL_AGENTS=(claude gemini copilot cursor qwen opencode windsurf codex kilocode auggie roo q trae) ALL_SCRIPTS=(sh ps) diff --git a/AGENTS.md b/AGENTS.md index 6cae67031..a6b54a9d7 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -39,6 +39,7 @@ Specify supports multiple AI agents by generating agent-specific command files a | **opencode** | `.opencode/command/` | Markdown | `opencode` | opencode CLI | | **Windsurf** | `.windsurf/workflows/` | Markdown | N/A (IDE-based) | Windsurf IDE workflows | | **Amazon Q Developer CLI** | `.amazonq/prompts/` | Markdown | `q` | Amazon Q Developer CLI | +| **Trae AI** | `.trae/workflows/` | Markdown | `trae` | Trae AI IDE-based Agent | ### Step-by-Step Integration Guide @@ -58,7 +59,8 @@ AI_CHOICES = { "qwen": "Qwen Code", "opencode": "opencode", "windsurf": "Windsurf", - "q": "Amazon Q Developer CLI" # Add new agent here + "q": "Amazon Q Developer CLI", + "trae": "Trae AI" # Add new agent here } ``` @@ -76,7 +78,8 @@ agent_folder_map = { "kilocode": ".kilocode/", "auggie": ".auggie/", "copilot": ".github/", - "q": ".amazonq/" # Add new agent folder here + "q": ".amazonq/", + "trae": ".trae/" # Add new agent folder here } ``` @@ -103,7 +106,7 @@ Modify `.github/workflows/scripts/create-release-packages.sh`: ##### Add to ALL_AGENTS array: ```bash -ALL_AGENTS=(claude gemini copilot cursor qwen opencode windsurf q) +ALL_AGENTS=(claude gemini copilot cursor qwen opencode windsurf q trae) ``` ##### Add case statement for directory structure: @@ -112,7 +115,10 @@ case $agent in # ... existing cases ... windsurf) mkdir -p "$base_dir/.windsurf/workflows" - generate_commands windsurf md "\$ARGUMENTS" "$base_dir/.windsurf/workflows" "$script" ;; + generate_commands windsurf md "$ARGUMENTS" "$base_dir/.windsurf/workflows" "$script" ;; + trae) + mkdir -p "$base_dir/.trae/workflows" + generate_commands trae md "$ARGUMENTS" "$base_dir/.trae/workflows" "$script" ;; esac ``` @@ -125,6 +131,8 @@ gh release create "$VERSION" \ # ... existing packages ... .genreleases/spec-kit-template-windsurf-sh-"$VERSION".zip \ .genreleases/spec-kit-template-windsurf-ps-"$VERSION".zip \ + .genreleases/spec-kit-template-trae-sh-"$VERSION".zip \ + .genreleases/spec-kit-template-trae-ps-"$VERSION".zip \ # Add new agent packages here ``` diff --git a/README.md b/README.md index 4d7a8fb0c..f321c48cb 100644 --- a/README.md +++ b/README.md @@ -135,6 +135,7 @@ Want to see Spec Kit in action? Watch our [video overview](https://www.youtube.c | [Roo Code](https://roocode.com/) | ✅ | | | [Codex CLI](https://github.com/openai/codex) | ✅ | | | [Amazon Q Developer CLI](https://aws.amazon.com/developer/learning/q-developer-cli/) | ⚠️ | Amazon Q Developer CLI [does not support](https://github.com/aws/amazon-q-developer-cli/issues/3064) custom arguments for slash commands. | +| [Trae AI](https://trae.ai/) | ✅ | | ## 🔧 Specify CLI Reference @@ -145,14 +146,14 @@ The `specify` command supports the following options: | Command | Description | |-------------|----------------------------------------------------------------| | `init` | Initialize a new Specify project from the latest template | -| `check` | Check for installed tools (`git`, `claude`, `gemini`, `code`/`code-insiders`, `cursor-agent`, `windsurf`, `qwen`, `opencode`, `codex`) | +| `check` | Check for installed tools (`git`, `claude`, `gemini`, `code`/`code-insiders`, `cursor-agent`, `windsurf`, `qwen`, `opencode`, `codex`, `trae`) | ### `specify init` Arguments & Options | Argument/Option | Type | Description | |------------------------|----------|------------------------------------------------------------------------------| | `` | Argument | Name for your new project directory (optional if using `--here`, or use `.` for current directory) | -| `--ai` | Option | AI assistant to use: `claude`, `gemini`, `copilot`, `cursor`, `qwen`, `opencode`, `codex`, `windsurf`, `kilocode`, `auggie`, `roo`, or `q` | +| `--ai` | Option | AI assistant to use: `claude`, `gemini`, `copilot`, `cursor`, `qwen`, `opencode`, `codex`, `windsurf`, `kilocode`, `auggie`, `roo`, `q`, or `trae` | | `--script` | Option | Script variant to use: `sh` (bash/zsh) or `ps` (PowerShell) | | `--ignore-agent-tools` | Flag | Skip checks for AI agent tools like Claude Code | | `--no-git` | Flag | Skip git repository initialization | diff --git a/docs/installation.md b/docs/installation.md index b30b09482..715583d2e 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -3,7 +3,7 @@ ## Prerequisites - **Linux/macOS** (or Windows; PowerShell scripts now supported without WSL) -- AI coding agent: [Claude Code](https://www.anthropic.com/claude-code), [GitHub Copilot](https://code.visualstudio.com/), or [Gemini CLI](https://github.com/google-gemini/gemini-cli) +- AI coding agent: [Claude Code](https://www.anthropic.com/claude-code), [GitHub Copilot](https://code.visualstudio.com/), [Gemini CLI](https://github.com/google-gemini/gemini-cli), or [Trae AI](https://trae.ai/) - [uv](https://docs.astral.sh/uv/) for package management - [Python 3.11+](https://www.python.org/downloads/) - [Git](https://git-scm.com/downloads) @@ -34,6 +34,7 @@ You can proactively specify your AI agent during initialization: uvx --from git+https://github.com/github/spec-kit.git specify init --ai claude uvx --from git+https://github.com/github/spec-kit.git specify init --ai gemini uvx --from git+https://github.com/github/spec-kit.git specify init --ai copilot +uvx --from git+https://github.com/github/spec-kit.git specify init --ai trae ``` ### Specify Script Type (Shell vs PowerShell) diff --git a/scripts/bash/update-agent-context.sh b/scripts/bash/update-agent-context.sh index 036d6b21f..bc47f080d 100644 --- a/scripts/bash/update-agent-context.sh +++ b/scripts/bash/update-agent-context.sh @@ -70,6 +70,7 @@ KILOCODE_FILE="$REPO_ROOT/.kilocode/rules/specify-rules.md" AUGGIE_FILE="$REPO_ROOT/.augment/rules/specify-rules.md" ROO_FILE="$REPO_ROOT/.roo/rules/specify-rules.md" Q_FILE="$REPO_ROOT/AGENTS.md" +TRAE_FILE="$REPO_ROOT/.trae/rules/specify-rules.md" # Template file TEMPLATE_FILE="$REPO_ROOT/.specify/templates/agent-file-template.md" @@ -581,12 +582,15 @@ update_specific_agent() { roo) update_agent_file "$ROO_FILE" "Roo Code" ;; - q) + q) update_agent_file "$Q_FILE" "Amazon Q Developer CLI" ;; + trae) + update_agent_file "$TRAE_FILE" "Trae AI" + ;; *) log_error "Unknown agent type '$agent_type'" - log_error "Expected: claude|gemini|copilot|cursor|qwen|opencode|codex|windsurf|kilocode|auggie|roo|q" + log_error "Expected: claude|gemini|copilot|cursor|qwen|opencode|codex|windsurf|kilocode|auggie|roo|q|trae" exit 1 ;; esac @@ -651,6 +655,11 @@ update_all_existing_agents() { found_agent=true fi + if [[ -f "$TRAE_FILE" ]]; then + update_agent_file "$TRAE_FILE" "Trae AI" + found_agent=true + fi + # If no agent files exist, create a default Claude file if [[ "$found_agent" == false ]]; then log_info "No existing agent files found, creating default Claude file..." @@ -674,7 +683,7 @@ print_summary() { fi echo - log_info "Usage: $0 [claude|gemini|copilot|cursor|qwen|opencode|codex|windsurf|kilocode|auggie|q]" + log_info "Usage: $0 [claude|gemini|copilot|cursor|qwen|opencode|codex|windsurf|kilocode|auggie|roo|q|trae]" } #============================================================================== diff --git a/scripts/powershell/update-agent-context.ps1 b/scripts/powershell/update-agent-context.ps1 index 1743eee64..c6dd419dd 100644 --- a/scripts/powershell/update-agent-context.ps1 +++ b/scripts/powershell/update-agent-context.ps1 @@ -25,7 +25,7 @@ Relies on common helper functions in common.ps1 #> param( [Parameter(Position=0)] - [ValidateSet('claude','gemini','copilot','cursor','qwen','opencode','codex','windsurf','kilocode','auggie','roo','q')] + [ValidateSet('claude','gemini','copilot','cursor','qwen','opencode','codex','windsurf','kilocode','auggie','roo','q','trae')] [string]$AgentType ) @@ -55,6 +55,7 @@ $KILOCODE_FILE = Join-Path $REPO_ROOT '.kilocode/rules/specify-rules.md' $AUGGIE_FILE = Join-Path $REPO_ROOT '.augment/rules/specify-rules.md' $ROO_FILE = Join-Path $REPO_ROOT '.roo/rules/specify-rules.md' $Q_FILE = Join-Path $REPO_ROOT 'AGENTS.md' +$TRAE_FILE = Join-Path $REPO_ROOT '.trae/rules/specify-rules.md' $TEMPLATE_FILE = Join-Path $REPO_ROOT '.specify/templates/agent-file-template.md' @@ -378,7 +379,8 @@ function Update-SpecificAgent { 'auggie' { Update-AgentFile -TargetFile $AUGGIE_FILE -AgentName 'Auggie CLI' } 'roo' { Update-AgentFile -TargetFile $ROO_FILE -AgentName 'Roo Code' } 'q' { Update-AgentFile -TargetFile $Q_FILE -AgentName 'Amazon Q Developer CLI' } - default { Write-Err "Unknown agent type '$Type'"; Write-Err 'Expected: claude|gemini|copilot|cursor|qwen|opencode|codex|windsurf|kilocode|auggie|roo|q'; return $false } + 'trae' { Update-AgentFile -TargetFile $TRAE_FILE -AgentName 'Trae AI' } + default { Write-Err "Unknown agent type '$Type'"; Write-Err 'Expected: claude|gemini|copilot|cursor|qwen|opencode|codex|windsurf|kilocode|auggie|roo|q|trae'; return $false } } } @@ -396,6 +398,7 @@ function Update-AllExistingAgents { if (Test-Path $AUGGIE_FILE) { if (-not (Update-AgentFile -TargetFile $AUGGIE_FILE -AgentName 'Auggie CLI')) { $ok = $false }; $found = $true } if (Test-Path $ROO_FILE) { if (-not (Update-AgentFile -TargetFile $ROO_FILE -AgentName 'Roo Code')) { $ok = $false }; $found = $true } if (Test-Path $Q_FILE) { if (-not (Update-AgentFile -TargetFile $Q_FILE -AgentName 'Amazon Q Developer CLI')) { $ok = $false }; $found = $true } + if (Test-Path $TRAE_FILE) { if (-not (Update-AgentFile -TargetFile $TRAE_FILE -AgentName 'Trae AI')) { $ok = $false }; $found = $true } if (-not $found) { Write-Info 'No existing agent files found, creating default Claude file...' if (-not (Update-AgentFile -TargetFile $CLAUDE_FILE -AgentName 'Claude Code')) { $ok = $false } @@ -410,7 +413,7 @@ function Print-Summary { if ($NEW_FRAMEWORK) { Write-Host " - Added framework: $NEW_FRAMEWORK" } if ($NEW_DB -and $NEW_DB -ne 'N/A') { Write-Host " - Added database: $NEW_DB" } Write-Host '' - Write-Info 'Usage: ./update-agent-context.ps1 [-AgentType claude|gemini|copilot|cursor|qwen|opencode|codex|windsurf|kilocode|auggie|roo|q]' + Write-Info 'Usage: ./update-agent-context.ps1 [-AgentType claude|gemini|copilot|cursor|qwen|opencode|codex|windsurf|kilocode|auggie|roo|q|trae]' } function Main { diff --git a/src/specify_cli/__init__.py b/src/specify_cli/__init__.py index 7ab114fb0..26443a6d0 100644 --- a/src/specify_cli/__init__.py +++ b/src/specify_cli/__init__.py @@ -78,6 +78,7 @@ def _github_auth_headers(cli_token: str | None = None) -> dict: "auggie": "Auggie CLI", "roo": "Roo Code", "q": "Amazon Q Developer CLI", + "trae": "Trae AI", } # Add script type choices SCRIPT_TYPE_CHOICES = {"sh": "POSIX Shell (bash/zsh)", "ps": "PowerShell"} @@ -751,7 +752,7 @@ def ensure_executable_scripts(project_path: Path, tracker: StepTracker | None = @app.command() def init( project_name: str = typer.Argument(None, help="Name for your new project directory (optional if using --here, or use '.' for current directory)"), - ai_assistant: str = typer.Option(None, "--ai", help="AI assistant to use: claude, gemini, copilot, cursor, qwen, opencode, codex, windsurf, kilocode, auggie or q"), + ai_assistant: str = typer.Option(None, "--ai", help="AI assistant to use: claude, gemini, copilot, cursor, qwen, opencode, codex, windsurf, kilocode, auggie, roo, q or trae"), script_type: str = typer.Option(None, "--script", help="Script type to use: sh or ps"), ignore_agent_tools: bool = typer.Option(False, "--ignore-agent-tools", help="Skip checks for AI agent tools like Claude Code"), no_git: bool = typer.Option(False, "--no-git", help="Skip git repository initialization"), @@ -1037,7 +1038,8 @@ def init( "auggie": ".augment/", "copilot": ".github/", "roo": ".roo/", - "q": ".amazonq/" + "q": ".amazonq/", + "trae": ".trae/" } if selected_ai in agent_folder_map: @@ -1116,6 +1118,7 @@ def check(): tracker.add("codex", "Codex CLI") tracker.add("auggie", "Auggie CLI") tracker.add("q", "Amazon Q Developer CLI") + tracker.add("trae", "Trae AI") git_ok = check_tool_for_tracker("git", tracker) claude_ok = check_tool_for_tracker("claude", tracker) @@ -1130,6 +1133,7 @@ def check(): codex_ok = check_tool_for_tracker("codex", tracker) auggie_ok = check_tool_for_tracker("auggie", tracker) q_ok = check_tool_for_tracker("q", tracker) + trae_ok = check_tool_for_tracker("trae", tracker) console.print(tracker.render()) @@ -1137,7 +1141,7 @@ def check(): if not git_ok: console.print("[dim]Tip: Install git for repository management[/dim]") - if not (claude_ok or gemini_ok or cursor_ok or qwen_ok or windsurf_ok or kilocode_ok or opencode_ok or codex_ok or auggie_ok or q_ok): + if not (claude_ok or gemini_ok or cursor_ok or qwen_ok or windsurf_ok or kilocode_ok or opencode_ok or codex_ok or auggie_ok or q_ok or trae_ok): console.print("[dim]Tip: Install an AI assistant for the best experience[/dim]") From 19e89d2bd4220041187cc7c5337549887169f97f Mon Sep 17 00:00:00 2001 From: Hanzhi Yang Date: Sun, 26 Oct 2025 23:21:57 -0700 Subject: [PATCH 2/2] 1. fix specify command local run issue 2. update some description to align with what we describe IDE-based agents 3. add "--template-file" option so that we can load templates locally instead of github remote to boost local testing when adding new agents --- README.md | 2 +- docs/installation.md | 2 +- scripts/bash/update-agent-context.sh | 5 +- scripts/powershell/update-agent-context.ps1 | 2 +- src/specify_cli/__init__.py | 131 +++++++++++--------- 5 files changed, 75 insertions(+), 67 deletions(-) diff --git a/README.md b/README.md index 662b22d47..dc73dc347 100644 --- a/README.md +++ b/README.md @@ -149,7 +149,7 @@ Want to see Spec Kit in action? Watch our [video overview](https://www.youtube.c | [Roo Code](https://roocode.com/) | ✅ | | | [Codex CLI](https://github.com/openai/codex) | ✅ | | | [Amazon Q Developer CLI](https://aws.amazon.com/developer/learning/q-developer-cli/) | ⚠️ | Amazon Q Developer CLI [does not support](https://github.com/aws/amazon-q-developer-cli/issues/3064) custom arguments for slash commands. | -| [Trae AI](https://trae.ai/) | ✅ | | +| [Trae](https://trae.ai/) | ✅ | | | [Amp](https://ampcode.com/) | ✅ | | ## 🔧 Specify CLI Reference diff --git a/docs/installation.md b/docs/installation.md index 994103182..f48ccbdf1 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -3,7 +3,7 @@ ## Prerequisites - **Linux/macOS** (or Windows; PowerShell scripts now supported without WSL) -- AI coding agent: [Claude Code](https://www.anthropic.com/claude-code), [GitHub Copilot](https://code.visualstudio.com/), [Codebuddy CLI](https://www.codebuddy.ai/cli) or [Gemini CLI](https://github.com/google-gemini/gemini-cli), or [Trae AI](https://trae.ai/) +- AI coding agent: [Claude Code](https://www.anthropic.com/claude-code), [GitHub Copilot](https://code.visualstudio.com/), [Codebuddy CLI](https://www.codebuddy.ai/cli) or [Gemini CLI](https://github.com/google-gemini/gemini-cli), or [Trae](https://trae.ai/) - [uv](https://docs.astral.sh/uv/) for package management - [Python 3.11+](https://www.python.org/downloads/) - [Git](https://git-scm.com/downloads) diff --git a/scripts/bash/update-agent-context.sh b/scripts/bash/update-agent-context.sh index 6bf639b60..af3e17e77 100644 --- a/scripts/bash/update-agent-context.sh +++ b/scripts/bash/update-agent-context.sh @@ -613,7 +613,6 @@ update_specific_agent() { roo) update_agent_file "$ROO_FILE" "Roo Code" ;; - q) codebuddy) update_agent_file "$CODEBUDDY_FILE" "CodeBuddy CLI" ;; @@ -624,7 +623,7 @@ update_specific_agent() { update_agent_file "$Q_FILE" "Amazon Q Developer CLI" ;; trae) - update_agent_file "$TRAE_FILE" "Trae AI" + update_agent_file "$TRAE_FILE" "Trae IDE" ;; *) log_error "Unknown agent type '$agent_type'" @@ -699,7 +698,7 @@ update_all_existing_agents() { fi if [[ -f "$TRAE_FILE" ]]; then - update_agent_file "$TRAE_FILE" "Trae AI" + update_agent_file "$TRAE_FILE" "Trae IDE" found_agent=true fi diff --git a/scripts/powershell/update-agent-context.ps1 b/scripts/powershell/update-agent-context.ps1 index 509326ea9..3fe58d6d6 100644 --- a/scripts/powershell/update-agent-context.ps1 +++ b/scripts/powershell/update-agent-context.ps1 @@ -402,7 +402,7 @@ function Update-AllExistingAgents { if (Test-Path $ROO_FILE) { if (-not (Update-AgentFile -TargetFile $ROO_FILE -AgentName 'Roo Code')) { $ok = $false }; $found = $true } if (Test-Path $CODEBUDDY_FILE) { if (-not (Update-AgentFile -TargetFile $CODEBUDDY_FILE -AgentName 'CodeBuddy CLI')) { $ok = $false }; $found = $true } if (Test-Path $Q_FILE) { if (-not (Update-AgentFile -TargetFile $Q_FILE -AgentName 'Amazon Q Developer CLI')) { $ok = $false }; $found = $true } - if (Test-Path $TRAE_FILE) { if (-not (Update-AgentFile -TargetFile $TRAE_FILE -AgentName 'Trae AI')) { $ok = $false }; $found = $true } + if (Test-Path $TRAE_FILE) { if (-not (Update-AgentFile -TargetFile $TRAE_FILE -AgentName 'Trae IDE')) { $ok = $false }; $found = $true } if (-not $found) { Write-Info 'No existing agent files found, creating default Claude file...' if (-not (Update-AgentFile -TargetFile $CLAUDE_FILE -AgentName 'Claude Code')) { $ok = $false } diff --git a/src/specify_cli/__init__.py b/src/specify_cli/__init__.py index 453b9a8a2..3cc9079e5 100644 --- a/src/specify_cli/__init__.py +++ b/src/specify_cli/__init__.py @@ -64,22 +64,6 @@ def _github_auth_headers(cli_token: str | None = None) -> dict: token = _github_token(cli_token) return {"Authorization": f"Bearer {token}"} if token else {} -AI_CHOICES = { - "copilot": "GitHub Copilot", - "claude": "Claude Code", - "gemini": "Gemini CLI", - "cursor-agent": "Cursor", - "qwen": "Qwen Code", - "opencode": "opencode", - "codex": "Codex CLI", - "windsurf": "Windsurf", - "kilocode": "Kilo Code", - "auggie": "Auggie CLI", - "roo": "Roo Code", - "q": "Amazon Q Developer CLI", - "amp": "Amp", - "trae": "Trae AI" -} # Agent configuration with name, folder, install URL, and CLI tool requirement AGENT_CONFIG = { "copilot": { @@ -166,6 +150,12 @@ def _github_auth_headers(cli_token: str | None = None) -> dict: "install_url": "https://ampcode.com/manual#install", "requires_cli": True, }, + "trae-agent": { + "name": "Trae", + "folder": ".trae/", + "install_url": None, # IDE-based, no CLI check needed + "requires_cli": False, + }, } SCRIPT_TYPE_CHOICES = {"sh": "POSIX Shell (bash/zsh)", "ps": "PowerShell"} @@ -834,6 +824,59 @@ def download_and_extract_template(project_path: Path, ai_assistant: str, script_ return project_path +def extract_local_template(zip_path: Path, project_path: Path, is_current_dir: bool = False, *, verbose: bool = True, tracker: StepTracker | None = None) -> Path: + """Extract a local template zip into project_path. + + This mirrors the minimal behavior of download_and_extract_template but + uses a locally-provided zip file instead of downloading from GitHub. + """ + if tracker: + tracker.start("extract", "Extract local template") + elif verbose: + console.print("Extracting local template...") + + try: + if not is_current_dir: + project_path.mkdir(parents=True, exist_ok=True) + + with zipfile.ZipFile(zip_path, 'r') as zip_ref: + zip_contents = zip_ref.namelist() + if tracker: + tracker.start("zip-list") + tracker.complete("zip-list", f"{len(zip_contents)} entries") + elif verbose: + console.print(f"[cyan]ZIP contains {len(zip_contents)} items[/cyan]") + + if is_current_dir: + # Extract into a temp dir first then merge to cwd to avoid + # accidental overwrites of working dir metadata. + with tempfile.TemporaryDirectory() as temp_dir: + zip_ref.extractall(temp_dir) + for item in Path(temp_dir).iterdir(): + dest = Path.cwd() / item.name + if item.is_dir(): + shutil.copytree(item, dest, dirs_exist_ok=True) + else: + shutil.copy2(item, dest) + else: + zip_ref.extractall(project_path) + + except Exception as e: + if tracker: + tracker.error("extract", str(e)) + else: + if verbose: + console.print(f"[red]Error extracting local template:[/red] {e}") + # Clean up partially created folder on error + if not is_current_dir and project_path.exists(): + shutil.rmtree(project_path) + raise + else: + if tracker: + tracker.complete("extract") + return project_path + + def ensure_executable_scripts(project_path: Path, tracker: StepTracker | None = None) -> None: """Ensure POSIX .sh scripts under .specify/scripts (recursively) have execute bits (no-op on Windows).""" if os.name == "nt": @@ -883,6 +926,7 @@ def init( project_name: str = typer.Argument(None, help="Name for your new project directory (optional if using --here, or use '.' for current directory)"), ai_assistant: str = typer.Option(None, "--ai", help="AI assistant to use: claude, gemini, copilot, cursor-agent, qwen, opencode, codex, windsurf, kilocode, auggie, trae, codebuddy, amp, or q"), script_type: str = typer.Option(None, "--script", help="Script type to use: sh or ps"), + template_file: str = typer.Option(None, "--template-file", help="Path to local template zip to use instead of downloading from GitHub"), ignore_agent_tools: bool = typer.Option(False, "--ignore-agent-tools", help="Skip checks for AI agent tools like Claude Code"), no_git: bool = typer.Option(False, "--no-git", help="Skip git repository initialization"), here: bool = typer.Option(False, "--here", help="Initialize project in the current directory instead of creating a new one"), @@ -1060,7 +1104,16 @@ def init( local_ssl_context = ssl_context if verify else False local_client = httpx.Client(verify=local_ssl_context) - download_and_extract_template(project_path, selected_ai, selected_script, here, verbose=False, tracker=tracker, client=local_client, debug=debug, github_token=github_token) + if template_file: + zip_path = Path(template_file).expanduser() + if not zip_path.exists(): + tracker.error("fetch", f"Local template not found: {zip_path}") + console.print(Panel(f"Local template file not found: [cyan]{zip_path}[/cyan]", title="Template Error", border_style="red")) + raise typer.Exit(1) + # Use local template zip + extract_local_template(zip_path, project_path, here, verbose=False, tracker=tracker) + else: + download_and_extract_template(project_path, selected_ai, selected_script, here, verbose=False, tracker=tracker, client=local_client, debug=debug, github_token=github_token) ensure_executable_scripts(project_path, tracker=tracker) @@ -1119,25 +1172,6 @@ def init( ) console.print(git_error_panel) - # Agent folder security notice - agent_folder_map = { - "claude": ".claude/", - "gemini": ".gemini/", - "cursor": ".cursor/", - "qwen": ".qwen/", - "opencode": ".opencode/", - "codex": ".codex/", - "windsurf": ".windsurf/", - "kilocode": ".kilocode/", - "auggie": ".augment/", - "copilot": ".github/", - "roo": ".roo/", - "q": ".amazonq/", - "trae": ".trae/" - } - - if selected_ai in agent_folder_map: - agent_folder = agent_folder_map[selected_ai] agent_config = AGENT_CONFIG.get(selected_ai) if agent_config: agent_folder = agent_config["folder"] @@ -1224,30 +1258,6 @@ def check(): code_ok = check_tool("code", tracker=tracker) tracker.add("code-insiders", "Visual Studio Code Insiders") - tracker.add("cursor-agent", "Cursor IDE agent") - tracker.add("windsurf", "Windsurf IDE") - tracker.add("kilocode", "Kilo Code IDE") - tracker.add("opencode", "opencode") - tracker.add("codex", "Codex CLI") - tracker.add("auggie", "Auggie CLI") - tracker.add("q", "Amazon Q Developer CLI") - tracker.add("trae", "Trae AI") - - - git_ok = check_tool_for_tracker("git", tracker) - claude_ok = check_tool_for_tracker("claude", tracker) - gemini_ok = check_tool_for_tracker("gemini", tracker) - qwen_ok = check_tool_for_tracker("qwen", tracker) - code_ok = check_tool_for_tracker("code", tracker) - code_insiders_ok = check_tool_for_tracker("code-insiders", tracker) - cursor_ok = check_tool_for_tracker("cursor-agent", tracker) - windsurf_ok = check_tool_for_tracker("windsurf", tracker) - kilocode_ok = check_tool_for_tracker("kilocode", tracker) - opencode_ok = check_tool_for_tracker("opencode", tracker) - codex_ok = check_tool_for_tracker("codex", tracker) - auggie_ok = check_tool_for_tracker("auggie", tracker) - q_ok = check_tool_for_tracker("q", tracker) - trae_ok = check_tool_for_tracker("trae", tracker) code_insiders_ok = check_tool("code-insiders", tracker=tracker) console.print(tracker.render()) @@ -1256,7 +1266,6 @@ def check(): if not git_ok: console.print("[dim]Tip: Install git for repository management[/dim]") - if not (claude_ok or gemini_ok or cursor_ok or qwen_ok or windsurf_ok or kilocode_ok or opencode_ok or codex_ok or auggie_ok or q_ok or trae_ok): if not any(agent_results.values()): console.print("[dim]Tip: Install an AI assistant for the best experience[/dim]")