Skip to content

PowerShell module: Index and search Copilot CLI session history across machines.

Notifications You must be signed in to change notification settings

bryansrevision/CopilotSessionTracker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

CopilotSessionTracker

Cross-machine Copilot CLI session index with fast offline search. Maintains a local JSON index of all session workspaces — query instantly without re-scanning the filesystem.

Architecture

~/.copilot/session-state/          ← Session folders (workspace.yaml + plan.md)
        │
        ▼  Sync-CopilotSessions (incremental scan)
        ▼
~/.copilot/session-index.json      ← Local JSON index (fast queries)
        │
        ▼  Find-CopilotSession / Get-RecentSessions
        ▼
Instant search results (no re-scan)
  • Index location: ~/.copilot/session-index.json
  • Auto-sync: Windows Scheduled Task \Copilot\CopilotSessionSync every 15 minutes
  • Current index: ~80 sessions indexed
  • Incremental sync: Only processes new/modified session folders — subsequent syncs are near-instant

Installation

# Option 1: Import directly
Import-Module "C:\Users\Dylan\Dev\PowerShell\Modules\CopilotSessionTracker\CopilotSessionTracker.psm1"

# Option 2: Clone to PSModulePath
git clone https://github.com/bryansrevision/CopilotSessionTracker `
    "$($env:PSModulePath.Split(';')[0])\CopilotSessionTracker"
Import-Module CopilotSessionTracker

# Register scheduled task (run once)
Register-SessionSyncTask

# Add to $PROFILE for auto-load
Import-Module "C:\Users\Dylan\Dev\PowerShell\Modules\CopilotSessionTracker\CopilotSessionTracker.psm1" -Force

Prerequisites

Requirement Details
PowerShell 7+ Required
~/.copilot/session-state/ Populated by Copilot CLI
pwsh.exe in PATH Required for scheduled task

Function Reference

Function Description
Sync-CopilotSessions Scan session-state dir and update the JSON index. Use -Force to rebuild from scratch
Find-CopilotSession Search sessions by text, date range, machine, or plan presence
Get-RecentSessions Show the most recent N sessions (default 15)
Get-CopilotSessionDetail Show full details + plan.md for a session by ID
Register-SessionSyncTask Register Windows Scheduled Task for auto-sync every 15 min
Get-SessionIndexInfo Show index stats: session count, machines, oldest/newest, last sync

Usage Examples

# Import module
Import-Module CopilotSessionTracker

# Sync index (first time or force rebuild)
Sync-CopilotSessions
Sync-CopilotSessions -Force

# Show last 10 sessions (default)
Find-CopilotSession

# Show last 20 sessions
Get-RecentSessions -Count 20

# Search by text
Find-CopilotSession -Search "proxmox"
Find-CopilotSession -Search "bitwarden" -Days 30

# Filter by date range
Find-CopilotSession -Days 7

# Filter by machine
Find-CopilotSession -Machine "DYLAN-PC"

# Sessions with a plan.md
Find-CopilotSession -HasPlan

# Get full session detail (first 8 chars of ID is enough)
Get-CopilotSessionDetail 334c0101

# Get raw objects for scripting
$sessions = Find-CopilotSession -Search "homeassistant" -Raw

# View index stats
Get-SessionIndexInfo

# Register auto-sync task
Register-SessionSyncTask
Register-SessionSyncTask -IntervalMinutes 5

Scheduled Task

The Windows Scheduled Task \Copilot\CopilotSessionSync runs Sync-CopilotSessions every 15 minutes in a non-interactive PowerShell session. Register it with:

Register-SessionSyncTask

Task details:

  • Path: \Copilot\CopilotSessionSync
  • Interval: Every 15 minutes
  • Execution limit: 2 minutes
  • Overlap policy: IgnoreNew (skip if already running)

copilot-session-agent.sh

The included copilot-session-agent.sh is a Linux/Python indexer deployed to on-prem servers via GitHub Actions. It scans Copilot session-state directories on Linux machines and writes compatible index data.

Deployed targets:

  • Proxmox VEpve (192.168.1.185), runs every 15 min via crontab
  • HA Dev VM — VM 102 (192.168.1.134), deployed via Proxmox SSH hop

Deployment: See bryansrevision/proxmox-docker.github/workflows/deploy-session-agent.yml

The agent is deployed automatically when changes are pushed to the scripts/copilot-session-agent.sh path. Only one GitHub secret is required: BWS_ACCESS_TOKEN (all SSH credentials are fetched from BSM at runtime).

Index Format

Each session entry in session-index.json:

{
  "id": "334c0101-4023-4c33-aca4-918b7b2acb91",
  "machine": "DYLAN-PC",
  "summary": "Fix proxmox workflow BSM auth",
  "repository": "bryansrevision/proxmox-docker",
  "branch": "master",
  "cwd": "C:\\Users\\Dylan\\Dev\\active\\proxmox-docker",
  "created_at": "2026-02-01T10:00:00Z",
  "updated_at": "2026-02-01T11:30:00Z",
  "dir_mtime": "2026-02-01T11:30:00Z",
  "plan_excerpt": "First 200 chars of plan.md...",
  "has_plan": true
}

About

PowerShell module: Index and search Copilot CLI session history across machines.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •