Package Discovery Tracking
Relevant source files
The following files were used as context for generating this wiki page:
Package Discovery Tracking identifies, suggests, and records software libraries relevant to specific development tasks within the Sequential Thinking MCP environment. This system helps you determine which tools are already installed or should be acquired to solve the problem defined in your session.
The feature integrates with the session lifecycle, triggering during session initialization and thought addition to ensure that architectural decisions remain grounded in available or recommended technical assets.
Sources: session_manager.py:53-76, models.py
Package Data Model
The system represents every discovered library as a PackageInfo object. This structure maintains metadata used for relevance ranking and architectural documentation.
PackageInfo Fields
| Field | Type | Description |
|---|---|---|
name | str | The unique identifier of the package. |
version | str | The specific version string of the library. |
description | str | A brief summary of the package's purpose. |
relevance_score | float | A value from 0.0 to 1.0 indicating task alignment. |
installation_status | str | Current state (e.g., "installed"). |
api_signatures | List[str] | List of key functions or classes provided by the package. |
discovered_at | datetime | Timestamp of when the package was first identified. |
Sources: models.py, tests/test_models.py:200-230
Relationship Diagram
This diagram shows how PackageInfo relates to the UnifiedSession and other session components.
Sources: models.py, session_manager.py:84-150
Discovery and Exploration Logic
The discovery process runs through the UnifiedSessionManager.explore_packages method. It scans the environment's metadata and compares package information against the task description.
Discovery Workflow
- Scanning: The system accesses
importlib.metadata.distributions()to retrieve all packages installed in the current environment. - Scoring: It invokes
_calculate_relevanceto compare the package name and description against thetask_description. - Filtering: Packages with a relevance score exceeding 0.3 are added to the session's
discovered_packageslist. - Persistence: The manager saves the updated list to the session's Markdown file under the "## Discovered Packages" heading.
Sources: session_manager.py:284-307, session_manager.py:126-136
Sources: session_manager.py:284-307
Relevance and Keyword Mapping
The system utilizes a internal keyword map to suggest packages even if they are not currently installed. This helps you identify necessary tools during the planning phase.
Relevance Calculation
The system calculates relevance using basic string matching:
- Exact Match: A package name appearing directly in the task description receives a score of 0.8.
- Partial Match: Common words shared between the task and package name result in a score of 0.5.
- Default: Unrelated packages receive a baseline score of 0.1.
Sources: session_manager.py:401-409
Keyword Suggestions
When you add a thought with explore_packages=True, the system checks for specific keywords in your text to suggest relevant libraries.
| Keyword | Suggested Packages |
|---|---|
http | requests, httpx, urllib3 |
web | flask, django, fastapi |
data | pandas, numpy, sqlite3 |
test | pytest, unittest, mock |
json | json, jsonschema, pydantic |
async | asyncio, aiohttp, tornado |
Sources: session_manager.py:388-397
MCP Tool Integration
The MCPToolsHandler exposes package discovery through specific tool endpoints, allowing the AI agent to trigger exploration manually or automatically.
Tool: explore_packages
This tool performs a deep scan of the environment based on a provided description.
Automatic Exploration
Automatic discovery occurs under two conditions:
- Session Start: If
session_typeiscodingandpackage_exploration_requiredisTrue. - Thought Addition: If the
add_thoughtcall includes theexplore_packages=Trueargument.
Sources: session_manager.py:74-76, session_manager.py:186-193
Summary of Capabilities
Package Discovery Tracking serves as the bridge between abstract reasoning and concrete implementation. By scanning installed distributions and mapping keywords to known libraries, the system ensures that you are aware of the technical resources available to solve a specific problem. All discovered data is persisted in the memory-bank/sessions/ directory, providing a permanent record of the technical environment for every session.
Sources: session_manager.py:126-136, README.md