This is the protocol for onboarding your AI Orchestrator onto an existing project. It's a multi-stage process that uses different AI agents for what they're best at.

**Phase 1: Ground Truth Reconnaissance (Using your local In-IDE AI)**

Your local AI (like Cline, Copilot with context, etc.) is the perfect "recon squad" because it can directly "read" your entire codebase. You will use it to gather the raw intelligence needed for the Orchestrator.

**Your Prompt to the Local AI (The "Recon Prompt"):**

> **Objective:** Analyze the entire codebase in this repository and generate a comprehensive "Project Autopsy Report" in Markdown. Your goal is to reverse-engineer the project's architecture, conventions, and current state.
>
> **Instructions:**
> Scan every relevant file and produce a report with the following sections:
>
> 1.  **Project Elevator Pitch:** Based on the code and any existing documentation, what is the one-sentence purpose of this application?
> 2.  **Core Technology Stack:** List the primary languages, frameworks, and key libraries you can identify.
> 3.  **Inferred Architecture:** Describe the architectural pattern you observe (e.g., "Modular Python with a central `hotkey_manager`," "Layered architecture with UI, business logic, and data layers").
> 4.  **Key Modules & Responsibilities:** Create a Markdown table listing the most important files/modules and your inferred one-sentence description of their role.
> 5.  **Inferred Coding Conventions:** Analyze the code and describe the observed conventions:
>     *   **Naming:** `snake_case`, `PascalCase`, etc.
>     *   **Formatting:** Is it consistent with a known formatter like Black or PEP 8?
>     *   **Error Handling:** What is the common pattern? (`try...except` blocks, custom exceptions, etc.)
> 6.  **Dependency Analysis:** Generate the command needed to list all dependencies (e.g., `cat requirements.txt`).
> 7.  **Potential Entry Points:** Identify the likely main entry point of the application (e.g., `main.py`).

**The Outcome:** You will now have a detailed, factual document—the "Autopsy Report"—that describes the *current state* of the project. This is the ground truth.

---

### Phase 2: Strategic Briefing (Creating the Orchestrator's "Brain")

Now you switch to your high-level AI Orchestrator. You will combine the "Autopsy Report" with your *new goals* to create the final, powerful onboarding prompt.

**Your Prompt to the AI Orchestrator (The "Mission Briefing" Prompt):**

> **Objective:** Assimilate the following project information and become the dedicated AI Orchestrator for this ongoing project. Your task is to understand the existing codebase and then help me plan and execute new features.
>
> ---
>
> **Part 1: The "Project Autopsy Report" (Ground Truth)**
> This report was generated by a local AI that scanned the entire codebase. This is what we know about the project as it exists today.
>
> ```markdown
> [[ PASTE THE ENTIRE MARKDOWN OUTPUT FROM YOUR LOCAL AI HERE ]]
> ```
>
> ---
>
> **Part 2: The New Mission (My Goals)**
> Now that you understand the current state, here is what I have been tasked with building.
>
> *   **Primary Goal:** *e.g., "To implement a new 'RAG from Folder' feature that allows the app to answer questions based on a user's local documents."*
> *   **Key New Features (as GitHub Issues):**
>     *   **[Feature] Create a UI for folder selection in the settings window.** *User story: As a user, I want to be able to select a folder on my computer that Blink will use as a knowledge base.*
>     *   **[Feature] Implement a local vector store using ChromaDB.** *User story: As a user, I want the contents of my selected folder to be indexed into a persistent local database for fast retrieval.*
>     *   **[Feature] Integrate RAG into the LLM query pipeline.** *User story: As a user, when I ask a question, Blink should first search my documents for relevant context and then inject that context into the prompt sent to the LLM.*
>
> ---
>
> **Part 3: Your Directive**
>
> You are now the AI Orchestrator for this project.
>
> 1.  **Acknowledge Assimilation:** Confirm that you have understood the existing codebase via the Autopsy Report and my new mission.
> 2.  **Adopt the Vibe:** Based on the inferred conventions, adopt the project's "coding vibe."
> 3.  **Begin Planning:** Your first task is to take my first new feature, **"Create a UI for folder selection in the settings window,"** and generate a full "Plan-and-Solve" implementation plan for it, respecting the existing architecture.

---

### Why This "Reverse Genesis" Protocol is So Powerful

*   **Separation of Concerns:** It uses the right AI for the right job. The local AI is a "scanner," excellent at low-level code analysis. The Orchestrator is a "strategist," excellent at high-level planning.
*   **Grounds the Orchestrator in Reality:** By providing the Autopsy Report, you prevent the Orchestrator from "hallucinating" or suggesting solutions that don't fit the existing patterns. It is forced to work within the constraints of the project as it is.
*   **Combines "What Is" with "What's Next":** This process seamlessly bridges the gap between understanding the past (the existing code) and planning for the future (your new tasks).

You were right—the prompt has to be dope. And the best way to make it dope is to feed it high-quality, pre-digested intelligence from the codebase itself. This protocol is your key to becoming an effective contributor to any project, right from day one.