Skip to content

[Change] Optimize Startup Performance #140

@djm81

Description

@djm81

Why

SpecFact CLI startup is currently slow (several seconds delay) due to automated checks for IDE templates and version updates running on every invocation. This degrades user experience and makes the CLI feel unresponsive. Users expect CLI tools to respond within 1-2 seconds maximum.

The current implementation:

  • Checks IDE templates on every startup (file system operations, hash comparisons)
  • Checks PyPI for version updates on every startup (network requests)
  • Both checks block startup until completion

This change optimizes startup performance by:

  1. Only checking IDE templates after version updates are detected (via metadata tracking)
  2. Checking PyPI for updates only once per day (not every startup)
  3. Adding a dedicated update command for manual update checking and installation
  4. Profiling and optimizing any other startup blockers

What Changes

  • NEW: Metadata management module for tracking version and check timestamps in ~/.specfact/metadata.json
  • MODIFY: Optimize startup checks to check metadata before running checks, add conditional execution logic
  • NEW: New specfact update command for manual update checking and installation
  • MODIFY: Register update command, ensure startup checks use optimized logic
  • NEW: Comprehensive tests for metadata management, update command, and startup performance

Acceptance Criteria

  • Startup time reduced from several seconds to < 1-2 seconds
  • IDE template checks only run after version updates are detected
  • PyPI version checks limited to once per day
  • New specfact update command available for manual updates
  • All tests passing with >80% coverage
  • No breaking changes to existing functionality

Performance Impact

  • Startup time: Reduced from several seconds to < 1-2 seconds
  • Network requests: Reduced from every startup to once per day
  • File system operations: Reduced from every startup to only after version changes

OpenSpec Change Proposal: optimize-startup-performance

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions