Skip to main content

Local VS Code/Copilot session recall CLI for low-token agent handoffs

Project description

code-session-recall

Minimal tool to recover past coding/AI sessions.

State of the union

code-session-recall (csr) is a small, local CLI that helps you rediscover past coding work and AI-assisted sessions. It scans your workspace and local session stores, indexes recent activity, and provides quick lookups so you can run csr before asking large-context tools to search your repo. The goal is to make context retrieval cheap, targeted, and privacy-friendly.

Inspiration: CSR is inspired by Desi Villanueva's article "I Wasted 68 Minutes a Day Re-Explaining My Code. Then I Built auto-memory." and the related auto-memory project. auto-memory targets Copilot CLI's local session database. CSR applies the same recall-first idea to VS Code/GitHub Copilot, where useful state is spread across VS Code workspace storage, chat session JSONL files, extension artifacts, and state databases rather than one easy-to-query CLI database.

Core capabilities

  • Scan and index: crawl specified folders and extract session metadata and touched files.
  • Search: full-text search across indexed sessions and extracted text artifacts.
  • Show: present a single session's details (checkpoints, files, commands, snippets).
  • Export: dump sessions or indexes for backup or sharing.

Intended usage

  • Run csr scan after a focused work session (or let it be scheduled) to capture a session snapshot.
  • Run csr commands before using an expensive workspace-wide search or an LLM prompt to surface recent, relevant context.
  • Use csr show <id> to rehydrate a prior session when you need the exact commands, files, or checkpoints.

Installation

Once published to PyPI:

python -m pip install code-session-recall
csr handoff
csr install-instructions

For local development or pre-release testing from a clone:

python -m pip install -e .
csr --help
csr install-instructions

The repository-local entry point remains available:

python csr.py handoff
python csr.py install-instructions

csr install-instructions prints the exact bootstrap prompt and AGENTS.md snippet to give another coding agent so CSR becomes the first recall step in a workspace.

Release and publishing

GitHub Actions builds and checks the package on every push to main and every pull request. PyPI publishing is intentionally tag-driven: bump pyproject.toml, push the commit, then push a matching tag such as v0.1.1. See docs/RELEASE.md for the Trusted Publishing setup and release checklist.

VS Code + GitHub Copilot integration

  • This tool is designed to complement the GitHub Copilot extension in Visual Studio Code. Use csr to surface local session context before invoking Copilot so prompts sent to Copilot are focused and cheaper.
  • Installation pattern: place the AGENTS-TEMPLATE.md content into ~/.copilot/copilot-instructions.md (or append it) to teach Copilot to run csr first on each prompt. Alternately, copy the template into your workspace notes and reference it from your Copilot config.
  • Recommended flow: run csr files/csr list (or csr search) to collect context, then paste or include the relevant snippets in the Copilot prompt.

Key record types and what they provide

  • Session (primary unit)

    • id: stable session identifier
    • times: start / end / last-modified timestamps
    • summary: short natural-language summary (if available)
    • files: list of file paths touched and small excerpts
    • commands: captured commands and terminal history snippets
    • checkpoints: named snapshots within the session
    • tags/labels: user or auto-generated tags
  • File record

    • path: workspace-relative path
    • last_touched: timestamp
    • diffs/snippets: small context snippets or a short diff for quick review
  • Checkpoint

    • checkpoint id/name
    • description: short note captured at checkpoint time
    • snapshot: list of important files and their short hashes
  • Health / Index metadata

    • schema version: DB layout version
    • index stats: counts, last-scan, errors

Usage (examples)

python csr.py scan python csr.py handoff "keyword" python csr.py handoff python csr.py ask "question" --json python csr.py handoff "keyword" --json python csr.py search "keyword" python csr.py show --json python csr.py install-instructions python csr.py export --out sessions.ndjson

Roadmap

The code and docs are mid-migration from an earlier machine/user profile. The near-term goal is to make csr discover the active VS Code/Copilot environment from local state instead of relying on hard-coded usernames, storage folders, or session ids.

  • Implemented / present in this repo

    • scan - crawl and index workspace and session stores
    • search - full-text search across indexed records
    • list - list recent indexed sessions
    • show - display a single session
    • export - export sessions or slices
    • health - basic DB/workspaceStorage/workspace check
    • formatter fact extraction - Copilot chat formatting now extracts compact files, commands, errors, nextSteps, editedFiles, and toolEvents facts before recent-turn previews
    • handoff - produce compact agent-ready markdown from matched or recent sessions
    • ask - compatibility alias for handoff so natural agent recall commands work
  • Highest priority

    • VS Code storage discovery - support Stable (Code), Insiders (Code - Insiders), and user-supplied roots; prefer environment-derived paths such as APPDATA, TERM_PROGRAM_VERSION, VSCODE_*, and terminal/tool metadata captured in Copilot sessions.
    • Session discovery - infer the active workspace/session from chat.ChatSessionStore.index, chatSessions/*.jsonl, terminal command metadata, and conversation titles instead of hard-coded WORKSPACE_CURRENT_CHAT_SESSION_ID.
    • Environment-aware recall - index Copilot terminal/tool records, including command, cwd, language, exit code, command URI, and useful environment variables, so future scans can locate the right database/session without guessing.
    • Improve deterministic handoff compression - continue refining csr handoff <query> scoring, workspace affinity, and typed fact ranking; see docs/HANDOFF_DESIGN.md.
    • Docs parity - keep README, docs/TOOL_DOCUMENTATION.md, AGENTS-TEMPLATE.md, and csr --help aligned with actual CLI behavior.
  • Roadmap / desirable commands and flags

    • files - list recently touched files with metadata (useful for quick context): csr files --json --limit 10
    • checkpoints - list or search named checkpoints across sessions
    • enhanced health - 8-dimension health check report for the local datastore, VS Code storage discovery, current workspace/session, parser coverage, and index freshness
    • schema-check - validate DB schema and guide migrations after upgrades
    • finer --days N filtering for list, files, search, checkpoints (convenience flag)

Notes and conventions

  • We intentionally keep sample data and temporary investigation outputs out of version control by default; see .gitignore.
  • Raw discovery outputs belong in ignored unsanitized/; only sanitized derivatives should be committed to docs/ or code.
  • The intended downstream install pattern is a local code-session-recall/ subdirectory inside each workspace; see docs/INSTALL.md for .gitignore entries, optional wrapper commands, and merging AGENTS-TEMPLATE.md into that workspace's top-level agent instructions.
  • Sessions are meant to be local by default; export if you need to share or archive them.

Contributing and extensions

  • The csr architecture is intentionally small — new extractors and exporters can be added as modules. If you want a tighter IDE integration or a remote sync feature, add it as an optional plugin.

License / attribution

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

code_session_recall-0.1.0.tar.gz (25.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

code_session_recall-0.1.0-py3-none-any.whl (25.5 kB view details)

Uploaded Python 3

File details

Details for the file code_session_recall-0.1.0.tar.gz.

File metadata

  • Download URL: code_session_recall-0.1.0.tar.gz
  • Upload date:
  • Size: 25.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for code_session_recall-0.1.0.tar.gz
Algorithm Hash digest
SHA256 abed691b2e36e6696c5171fec1cd6f50887b1eeed0e5cf2c772cb2b3723c6608
MD5 e4d1ea0530647d060666654ea973f683
BLAKE2b-256 e06abbdf69347c09c79e5b844d07ba61f107f01c718a54373dd5b13755406c1a

See more details on using hashes here.

Provenance

The following attestation bundles were made for code_session_recall-0.1.0.tar.gz:

Publisher: publish.yml on sle118/code-session-recall

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file code_session_recall-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for code_session_recall-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1e345d7d082e777b281eaa443ba1ccc3a8e5bae0c6b700919c8e9bfe65c597b5
MD5 f126bb0b6a9139fd7898e2b028d9bf31
BLAKE2b-256 abc71b1bd5e892cf6b5abbe7b0fc14344409241bd4ac396bbd27ebfb2e438e39

See more details on using hashes here.

Provenance

The following attestation bundles were made for code_session_recall-0.1.0-py3-none-any.whl:

Publisher: publish.yml on sle118/code-session-recall

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page