Logo di Project Switching

Project Switching

CommunityPopolare
marcus
project-switching

Project switching implementation in sidecar: project discovery, state management, UI flow, modal rendering, filtering, theme preview, and plugin reinitialization. Use when working on the project switcher feature, project management, worktree switching, or the project configuration system.

Panoramica

Autoremarcus
Repositorysidecar
Nome della skillproject-switching
Stelle
1.1K
Fork
82
File inclusi
1
LicenzaMIT
Link
  • Istruzioni in Markdown

    Un file SKILL.md che il modello carica quando serve, consumando token solo quando una richiesta è effettivamente pertinente.

  • Funziona con qualsiasi LLM

    Le skill IA sono in semplice Markdown, non in codice specifico di un fornitore, quindi funzionano con GPT, Claude, Gemini, Grok o un modello locale.

  • 1 file inclusi

    Script, modelli di documento e riferimenti che il modello può leggere mentre lavora. I file sono di sola lettura e non vengono mai eseguiti.

  • Open source

    Pubblicata da marcus su GitHub. Leggi i sorgenti prima di installarla.

Installazione

Installa la skill IA Project Switching in TypingMind per usarla con qualsiasi LLM, oppure copiala in un altro agente in grado di leggere SKILL.md.

1

Installa in TypingMind

TypingMind installa una skill direttamente dalla sua cartella GitHub: legge SKILL.md, raccoglie i file delle risorse e salva il risultato in locale.

  1. Apri l'app e vai su Plugin → Skill.
  2. Scegli "Installa da GitHub".
  3. Incolla l'URL della cartella della skill riportato qui sotto e conferma.
    https://github.com/marcus/sidecar/tree/main/.claude/skills/project-switching
  4. Attiva la skill in ogni chat in cui vuoi averla a disposizione.
Plugin → Skill → Nuova skill → Da URL GitHub, poi incolla l'URL della cartella e premi Continua.
2

Installa in un altro agente

Qualsiasi agente che legge il formato Agent Skills può usare questa skill: copia la cartella nella cartella delle skill di quell'agente.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/marcus/sidecar.git /tmp/sidecar
mkdir -p .claude/skills
cp -r /tmp/sidecar/.claude/skills/project-switching .claude/skills/project-switching
Dopo la copia, riavvia Claude Code per caricare la nuova skill.

Usala in TypingMind

Attiva Project Switching in qualsiasi chat di TypingMind e al resto pensa il modello. Il nome e la descrizione della skill sono nel prompt di sistema e, non appena arriva una richiesta pertinente, il modello carica da solo le istruzioni complete: non devi mai richiamarla manualmente e non consuma token finché non viene effettivamente usata.

Il modello carica automaticamente Project Switching non appena riceve una richiesta pertinente.

Funziona con qualsiasi modello IA

Le skill IA sono semplici istruzioni in Markdown, non codice specifico di un fornitore, quindi Project Switching non è vincolata al modello per cui è stata scritta. Installala una sola volta in TypingMind e usala con GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama o un modello locale che esegui tu, sempre con le tue chiavi API.

  • Caricata solo quando serve

    Il prompt di sistema contiene solo il nome e la descrizione. Le istruzioni vengono recuperate alla prima richiesta pertinente, quindi una skill inutilizzata non costa nulla.

  • Cambia modello durante la chat

    Poiché la skill è composta da istruzioni e non da codice, continua a funzionare anche se cambi modello: il nuovo modello legge lo stesso file SKILL.md.

Istruzioni della skill

Questo è il contenuto di SKILL.md che il modello carica. Leggilo prima dell'installazione: una skill è un insieme di istruzioni che il tuo modello seguirà.

Project Switching

Switch between git repositories without restarting sidecar. Press @ to open the project switcher modal.

Architecture Overview

The project switcher uses the app's declarative modal library (internal/modal/) for rendering and mouse handling.

Key Files

FileContents
internal/app/model.goState, init, reset, filter, switch, theme preview
internal/app/update.goKeyboard and mouse handlers
internal/app/view.goModal building and section rendering
internal/modal/Modal library (builder, sections, layout)
internal/config/types.goProjectConfig struct
internal/config/loader.goConfig loading with path validation

Model State

go
// internal/app/model.go
showProjectSwitcher         bool
projectSwitcherCursor       int
projectSwitcherScroll       int
projectSwitcherInput        textinput.Model
projectSwitcherFiltered     []config.ProjectConfig
projectSwitcherModal        *modal.Modal           // Cached modal instance
projectSwitcherModalWidth   int                    // Width for cache invalidation
projectSwitcherMouseHandler *mouse.Handler

Project vs Worktree Switching

  • Project Switching (@): Switch between configured projects from config.json (arbitrary repos)
  • Worktree Switching (W): Switch between git worktrees within the current repository

Configuration

Projects are configured in ~/.config/sidecar/config.json:

json
{
  "projects": {
    "list": [
      {"name": "sidecar", "path": "~/code/sidecar"},
      {"name": "td", "path": "~/code/td", "theme": "dark"}
    ]
  }
}

Paths support ~ expansion. Projects can have per-project themes.

Core Flow

Opening (@ key)

go
case "@":
    m.showProjectSwitcher = !m.showProjectSwitcher
    if m.showProjectSwitcher {
        m.activeContext = "project-switcher"
        m.initProjectSwitcher()
    } else {
        m.resetProjectSwitcher()
        m.updateContext()
    }

Initialization (model.go:433-454)

initProjectSwitcher() clears cached modal, creates text input with "Filter projects..." placeholder, loads all projects, pre-selects current project, and previews its theme.

Cleanup (model.go:413-423)

resetProjectSwitcher() resets all state, clears modal cache, and restores current project's theme (undoing any live preview).

Modal Rendering

Uses internal/modal/ with a builder pattern and lazy caching.

Modal Structure

+-------------------------------------------+
| Switch Project                            |  <- Title
| [Filter projects...                    ]  |  <- Input section
| 3 of 10 projects                          |  <- Count section
|   ^ 2 more above                          |  <- Scroll indicator
| > sidecar                                 |  <- Selected item
|   ~/code/sidecar                          |
|   td (current)                            |  <- Current project (green)
|   v 5 more below                          |  <- Scroll indicator
| enter switch  up/down navigate  esc close |  <- Hints section
+-------------------------------------------+

Caching (view.go:114-137)

ensureProjectSwitcherModal() builds modal only when it does not exist or width changed. Call clearProjectSwitcherModal() when content changes (filter input, cursor movement with scroll).

Section Types

TypeFactoryPurpose
Inputmodal.Input()Text input with focus
Custommodal.Custom()Complex content with focusables
Textmodal.Text()Static text
Buttonsmodal.Buttons()Button row

Keyboard Handling (update.go:600-690)

Priority: KeyType switch (special keys) -> String switch (named keys) -> Fallthrough to textinput.

KeyAction
EscClear filter (if set) or close modal
EnterSwitch to selected project
Up/DownArrow navigation
ctrl+n/ctrl+pEmacs-style navigation
Other keysForwarded to text input for filtering

Esc Behavior

First Esc clears filter if set. Second Esc (or first with empty filter) closes modal.

Navigation

Cursor movement updates projectSwitcherCursor and calls projectSwitcherEnsureCursorVisible() to maintain scroll window (max 8 visible items).

Filtering (model.go:457-470)

filterProjects() does case-insensitive substring match on both Name and Path fields. On filter change: clear modal cache, clamp cursor, reset scroll, preview theme.

Mouse Handling (update.go:1073-1115)

Uses modal library's HandleMouse(). Each project item has a focusable ID (project-switcher-item-N). Click on item triggers switch. Hover state managed by modal library via hoverID string.

Theme Preview (model.go:580-586)

previewProjectTheme() applies the selected project's theme live. Called on init, cursor movement, and filter changes. Theme is restored in resetProjectSwitcher().

Project Switching (model.go:485-577)

switchProject() performs:

  1. Skip if same project (show toast)
  2. Save active plugin state for old workdir
  3. Check for saved worktree to restore
  4. Update m.ui.WorkDir and repo name
  5. Apply project-specific theme
  6. Reinitialize all plugins via m.registry.Reinit(targetPath)
  7. Send WindowSizeMsg for layout recalculation
  8. Restore previously active plugin for new workdir
  9. Return toast notification

What Happens on Switch

  1. All plugins stop (file watchers, git commands, etc.)
  2. Plugin context updates to new working directory
  3. All plugins reinitialize with new path
  4. Previously active plugin for that project is restored
  5. Toast notification confirms the switch

State Persistence

Per-project state saved in ~/.config/sidecar/state.json:

  • Active plugin per project
  • File browser cursor position and expanded directories
  • Sidebar widths and view preferences

Common Pitfalls

  1. Forgetting updateContext() -- Call after closing modal to restore app context
  2. Stale modal cache -- Call clearProjectSwitcherModal() when content changes
  3. Cursor out of bounds -- Always clamp after filtering
  4. Printable keys vs navigation -- Keep printable characters routed to textinput
  5. Theme preview cleanup -- Always restore theme in resetProjectSwitcher()
  6. Focusable coordinates -- Each project takes 2 lines (name + path)

Adding Features

See references/implementation-details.md for detailed implementation patterns including adding keyboard shortcuts, project metadata, filter algorithms, and new modal sections.

File inclusi

Il modello legge questi file quando servono, mentre la skill è caricata. Sono accessibili in sola lettura e non vengono mai eseguiti.

Domande frequenti

Cosa fa la skill IA Project Switching?

Project switching implementation in sidecar: project discovery, state management, UI flow, modal rendering, filtering, theme preview, and plugin reinitialization. Use when working on the project switcher feature, project management, worktree switching, or the project configuration system.

Perché usare Project Switching su TypingMind?

Perché la installi una volta e la usi con qualsiasi modello. Project Switching è scritta in semplice Markdown anziché in codice specifico di un fornitore, quindi la stessa skill funziona con GPT-5, Claude, Gemini, Grok o un modello locale, e puoi cambiare modello durante la chat senza che smetta di funzionare. TypingMind usa le tue chiavi API, quindi paghi direttamente i fornitori anziché un abbonamento per posto utente, e le tue skill e chat restano nel tuo spazio di archiviazione.

Come installo Project Switching in TypingMind?

Apri Plugin → Skill → Installa da GitHub in TypingMind e incolla https://github.com/marcus/sidecar/tree/main/.claude/skills/project-switching. TypingMind legge il file SKILL.md, include i file associati e installa la skill, che puoi abilitare per ogni singola chat.

Quali modelli IA possono usare Project Switching?

Qualsiasi modello che colleghi in TypingMind. Le skill IA sono semplici istruzioni in Markdown anziché codice specifico di un fornitore, quindi GPT, Claude, Gemini, Grok e i modelli locali possono tutti caricare questa skill quando una richiesta corrisponde al suo scopo.

Quanti modelli IA posso usare con Project Switching?

Quanti ne vuoi. Se un modello supporta le skill, puoi usarlo con Project Switching: GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama e molti altri, tutti su TypingMind con le tue chiavi API.

La skill IA Project Switching è gratuita?

Sì. È pubblicata su GitHub da marcus con licenza MIT. Paghi solo il tuo fornitore IA per i token che usi.

Cosa sono le skill IA?

Una skill IA è un pacchetto di istruzioni riutilizzabili che insegna a un modello IA come svolgere un'attività specifica. Segue il formato aperto Agent Skills: un file SKILL.md con un nome e una descrizione, più eventuali script, modelli o file di riferimento di cui il modello potrebbe aver bisogno. Il modello legge le istruzioni solo quando la tua richiesta corrisponde alla skill, quindi una skill installata non comporta costi finché non viene usata.

In cosa si differenziano le skill IA dai plugin o dai server MCP?

Un plugin o un server MCP fornisce a un modello nuovi strumenti da richiamare: codice che viene eseguito da qualche parte e restituisce un risultato. Una skill IA, invece, fornisce al modello conoscenze e procedure: come affrontare un'attività, quali passaggi seguire e quali caratteristiche deve avere un buon output. Le skill sono semplici istruzioni in Markdown, quindi non richiedono server, chiavi API né ambienti di esecuzione e funzionano con qualsiasi modello.

Vedi tutti

Crea subito la tua area di lavoro IA

Iscriviti alla nostra newsletter per ricevere aggiornamenti sulle nuove funzionalità e sulle prossime iniziative a premi 👇