|
51 | 51 | AI_CHOICES = { |
52 | 52 | "copilot": "GitHub Copilot", |
53 | 53 | "claude": "Claude Code", |
54 | | - "gemini": "Gemini CLI" |
| 54 | + "gemini": "Gemini CLI", |
| 55 | + "qchat": "Amazon Q Developer CLI" |
55 | 56 | } |
56 | 57 |
|
| 58 | +# Embedded fallback agent config for qchat (used only if templates/agent is not found) |
| 59 | +QCHAT_AGENT_CONFIG = """{ |
| 60 | + "name": "spec-kit-agent", |
| 61 | + "description": "Spec-driven development agent for Amazon Q Developer CLI", |
| 62 | + "prompt": "You are a spec-driven development assistant. Help users create specifications, implementation plans, and break down tasks for software development projects.", |
| 63 | + "resources": [ |
| 64 | + "file://AmazonQ.md", |
| 65 | + "file://memory/**/*.md", |
| 66 | + "file://templates/**/*.md" |
| 67 | + ] |
| 68 | +}""" |
| 69 | + |
| 70 | +# Saved prompts for qchat |
| 71 | +QCHAT_PROMPT_SPECIFY = """# Specify Feature |
| 72 | +
|
| 73 | +Create a new feature specification and branch. |
| 74 | +
|
| 75 | +## Arguments |
| 76 | +- description (required): Feature description |
| 77 | +
|
| 78 | +## Prompt |
| 79 | +Create a specification for: {{description}} |
| 80 | +
|
| 81 | +Please run `scripts/create-new-feature.sh --json "{{description}}"` to set up the branch and specification file, then fill in the specification template with concrete details. |
| 82 | +""" |
| 83 | + |
| 84 | +QCHAT_PROMPT_PLAN = """# Plan Implementation |
| 85 | +
|
| 86 | +Create an implementation plan for a feature. |
| 87 | +
|
| 88 | +## Arguments |
| 89 | +- context (optional): Additional implementation context |
| 90 | +
|
| 91 | +## Prompt |
| 92 | +Create an implementation plan for the current feature specification. |
| 93 | +
|
| 94 | +{{#context}} |
| 95 | +Additional context: {{context}} |
| 96 | +{{/context}} |
| 97 | +
|
| 98 | +Please run `scripts/setup-plan.sh --json` to set up the plan file, then create a detailed implementation plan including phases, research, data models, and contracts as needed. |
| 99 | +""" |
| 100 | + |
| 101 | +QCHAT_PROMPT_TASKS = """# Break Down Tasks |
| 102 | +
|
| 103 | +Break down the implementation plan into executable tasks. |
| 104 | +
|
| 105 | +## Prompt |
| 106 | +Break down the current implementation plan into specific, executable tasks. |
| 107 | +
|
| 108 | +Please run `scripts/check-task-prerequisites.sh --json` to check prerequisites, then create numbered tasks (T001, T002, ...) with clear file paths and dependency notes. Mark parallel tasks with [P]. |
| 109 | +""" |
| 110 | + |
57 | 111 | # ASCII Art Banner |
58 | 112 | BANNER = """ |
59 | 113 | ███████╗██████╗ ███████╗ ██████╗██╗███████╗██╗ ██╗ |
@@ -405,23 +459,31 @@ def download_template_from_github(ai_assistant: str, download_dir: Path, *, verb |
405 | 459 | console.print(f"[red]Error fetching release information:[/red] {e}") |
406 | 460 | raise typer.Exit(1) |
407 | 461 |
|
408 | | - # Find the template asset for the specified AI assistant |
| 462 | + # Find the template asset for the specified AI assistant, with fallback for 'qchat' -> 'copilot' |
409 | 463 | pattern = f"spec-kit-template-{ai_assistant}" |
410 | | - matching_assets = [ |
411 | | - asset for asset in release_data.get("assets", []) |
412 | | - if pattern in asset["name"] and asset["name"].endswith(".zip") |
413 | | - ] |
414 | | - |
415 | | - if not matching_assets: |
| 464 | + assets = release_data.get("assets", []) |
| 465 | + matching_assets = [a for a in assets if pattern in a["name"] and a["name"].endswith(".zip")] |
| 466 | + |
| 467 | + asset = None |
| 468 | + if matching_assets: |
| 469 | + asset = matching_assets[0] |
| 470 | + elif ai_assistant == "qchat": |
| 471 | + # Fallback to copilot template if qchat-specific template is not published yet |
| 472 | + fallback_pattern = "spec-kit-template-copilot" |
| 473 | + fallback_assets = [a for a in assets if fallback_pattern in a["name"] and a["name"].endswith(".zip")] |
| 474 | + if fallback_assets: |
| 475 | + asset = fallback_assets[0] |
| 476 | + if verbose: |
| 477 | + console.print("[yellow]No 'qchat' template found; falling back to 'copilot' template.[/yellow]") |
| 478 | + |
| 479 | + if asset is None: |
416 | 480 | if verbose: |
417 | 481 | console.print(f"[red]Error:[/red] No template found for AI assistant '{ai_assistant}'") |
418 | 482 | console.print(f"[yellow]Available assets:[/yellow]") |
419 | | - for asset in release_data.get("assets", []): |
420 | | - console.print(f" - {asset['name']}") |
| 483 | + for a in assets: |
| 484 | + console.print(f" - {a['name']}") |
421 | 485 | raise typer.Exit(1) |
422 | 486 |
|
423 | | - # Use the first matching asset |
424 | | - asset = matching_assets[0] |
425 | 487 | download_url = asset["browser_download_url"] |
426 | 488 | filename = asset["name"] |
427 | 489 | file_size = asset["size"] |
@@ -737,6 +799,10 @@ def init( |
737 | 799 | if not check_tool("gemini", "Install from: https://github.com/google-gemini/gemini-cli"): |
738 | 800 | console.print("[red]Error:[/red] Gemini CLI is required for Gemini projects") |
739 | 801 | agent_tool_missing = True |
| 802 | + elif selected_ai == "qchat": |
| 803 | + if not check_tool("qchat", "Install from: https://docs.aws.amazon.com/amazonq/latest/qdeveloper-ug/command-line.html"): |
| 804 | + console.print("[red]Error:[/red] Amazon Q Developer CLI is required for qchat projects") |
| 805 | + agent_tool_missing = True |
740 | 806 | # GitHub Copilot check is not needed as it's typically available in supported IDEs |
741 | 807 |
|
742 | 808 | if agent_tool_missing: |
@@ -765,13 +831,53 @@ def init( |
765 | 831 | ("final", "Finalize") |
766 | 832 | ]: |
767 | 833 | tracker.add(key, label) |
| 834 | + # qchat only: show progress for saved prompts setup |
| 835 | + if selected_ai == "qchat": |
| 836 | + tracker.add("commands", "Setup saved prompts") |
768 | 837 |
|
769 | 838 | # Use transient so live tree is replaced by the final static render (avoids duplicate output) |
770 | 839 | with Live(tracker.render(), console=console, refresh_per_second=8, transient=True) as live: |
771 | 840 | tracker.attach_refresh(lambda: live.update(tracker.render())) |
772 | 841 | try: |
773 | 842 | download_and_extract_template(project_path, selected_ai, here, verbose=False, tracker=tracker) |
774 | 843 |
|
| 844 | + # qchat only: setup agent config and saved prompts |
| 845 | + if selected_ai == "qchat": |
| 846 | + tracker.start("commands") |
| 847 | + try: |
| 848 | + amazonq_dir = project_path / ".amazonq" |
| 849 | + |
| 850 | + # Create agent.json |
| 851 | + agent_config_file = amazonq_dir / "agent.json" |
| 852 | + if not agent_config_file.exists(): |
| 853 | + amazonq_dir.mkdir(parents=True, exist_ok=True) |
| 854 | + agent_config_file.write_text(QCHAT_AGENT_CONFIG, encoding="utf-8") |
| 855 | + |
| 856 | + # Create prompts directory and files |
| 857 | + prompts_dir = amazonq_dir / "prompts" |
| 858 | + prompts_dir.mkdir(parents=True, exist_ok=True) |
| 859 | + |
| 860 | + prompt_files = [ |
| 861 | + ("specify.md", QCHAT_PROMPT_SPECIFY), |
| 862 | + ("plan.md", QCHAT_PROMPT_PLAN), |
| 863 | + ("tasks.md", QCHAT_PROMPT_TASKS) |
| 864 | + ] |
| 865 | + |
| 866 | + created_count = 0 |
| 867 | + for filename, content in prompt_files: |
| 868 | + prompt_file = prompts_dir / filename |
| 869 | + if not prompt_file.exists(): |
| 870 | + prompt_file.write_text(content, encoding="utf-8") |
| 871 | + created_count += 1 |
| 872 | + |
| 873 | + if created_count > 0: |
| 874 | + tracker.complete("commands", f"created {created_count} saved prompts") |
| 875 | + else: |
| 876 | + tracker.skip("commands", "prompts already exist") |
| 877 | + |
| 878 | + except Exception as e: |
| 879 | + tracker.error("commands", str(e)) |
| 880 | + |
775 | 881 | # Git step |
776 | 882 | if not no_git: |
777 | 883 | tracker.start("git") |
@@ -823,6 +929,13 @@ def init( |
823 | 929 | steps_lines.append(" - See GEMINI.md for all available commands") |
824 | 930 | elif selected_ai == "copilot": |
825 | 931 | steps_lines.append(f"{step_num}. Open in Visual Studio Code and use [bold cyan]/specify[/], [bold cyan]/plan[/], [bold cyan]/tasks[/] commands with GitHub Copilot") |
| 932 | + elif selected_ai == "qchat": |
| 933 | + steps_lines.append(f"{step_num}. Use Amazon Q Developer CLI with saved prompts") |
| 934 | + steps_lines.append(" - Run q chat to start interactive session") |
| 935 | + steps_lines.append(" - Use @specify \"description\" to create specifications") |
| 936 | + steps_lines.append(" - Use @plan to create implementation plans") |
| 937 | + steps_lines.append(" - Use @tasks to break down into tasks") |
| 938 | + steps_lines.append(" - Saved prompts are in .amazonq/prompts/") |
826 | 939 |
|
827 | 940 | step_num += 1 |
828 | 941 | steps_lines.append(f"{step_num}. Update [bold magenta]CONSTITUTION.md[/bold magenta] with your project's non-negotiable principles") |
@@ -855,11 +968,12 @@ def check(): |
855 | 968 | console.print("\n[cyan]Optional AI tools:[/cyan]") |
856 | 969 | claude_ok = check_tool("claude", "Install from: https://docs.anthropic.com/en/docs/claude-code/setup") |
857 | 970 | gemini_ok = check_tool("gemini", "Install from: https://github.com/google-gemini/gemini-cli") |
| 971 | + qchat_ok = check_tool("qchat", "Install from: https://docs.aws.amazon.com/amazonq/latest/qdeveloper-ug/command-line.html") |
858 | 972 |
|
859 | 973 | console.print("\n[green]✓ Specify CLI is ready to use![/green]") |
860 | 974 | if not git_ok: |
861 | 975 | console.print("[yellow]Consider installing git for repository management[/yellow]") |
862 | | - if not (claude_ok or gemini_ok): |
| 976 | + if not (claude_ok or gemini_ok or qchat_ok): |
863 | 977 | console.print("[yellow]Consider installing an AI assistant for the best experience[/yellow]") |
864 | 978 |
|
865 | 979 |
|
|
0 commit comments