Skip to main content

Core application services for Spec-Kit - Service implementations and application bridge

Project description

spec-kit-core

Core application services for the Spec-Kit ecosystem.

Overview

This package provides concrete implementations of the service interfaces defined in spec-kit-contracts. These services are injected into plugins at runtime, providing them with controlled access to system resources.

Installation

pip install spec-kit-core

Services Provided

ConfigService

Configuration management with YAML support:

from spec_kit_core.services import ConfigService

config = ConfigService(config_path=".specify/config.yaml")

# Get configuration values
value = config.get("plugins.design.template_style", default="standard")

# Set configuration
config.set("plugins.design.enabled", True)

# Save changes
config.save()

FileSystemService

Safe file operations with path validation:

from spec_kit_core.services import FileSystemService

fs = FileSystemService(base_path="./project")

# Read file
content = fs.read_file("specs/feature/spec.md")

# Write file (creates directories as needed)
fs.write_file("specs/feature/plan.md", content)

# Check existence
if fs.exists("specs/feature"):
    files = fs.list_directory("specs/feature")

TemplateService

Jinja2 template rendering:

from spec_kit_core.services import TemplateService

templates = TemplateService()

# Register template
templates.register_template("hld", "# HLD: {{ feature_name }}\n...")

# Render
content = templates.render("hld", {
    "feature_name": "User Authentication",
    "version": "1.0",
})

LoggingService

Structured logging:

from spec_kit_core.services import LoggingService

logger = LoggingService(name="my-plugin")

logger.info("Plugin initialized", extra={"config": config})
logger.warning("Deprecated feature used")
logger.error("Operation failed", exc_info=True)

EventService

Pub/sub event system:

from spec_kit_core.services import EventService

events = EventService()

# Subscribe to events
def on_file_saved(data):
    print(f"File saved: {data['path']}")

events.subscribe("file:saved", on_file_saved)

# Emit events
events.emit("file:saved", {"path": "/project/file.py"})

StateService

Persistent state management:

from spec_kit_core.services import StateService

state = StateService(storage_path=".specify/state")

# Save state
state.set("plugin:design:last_run", datetime.now().isoformat())

# Get state
last_run = state.get("plugin:design:last_run")

# Clear state
state.clear("plugin:design:*")

Application Bridge

The RuntimeBridge connects core services to the plugin runtime:

from spec_kit_core import RuntimeBridge
from spec_kit_runtime import PluginContainer

# Create bridge with services
bridge = RuntimeBridge(
    config_path=".specify/config.yaml",
    base_path="./project",
)

# Connect to plugin container
container = PluginContainer()
bridge.connect(container)

# Services are now available to plugins

Service Registry

The ServiceRegistry manages service registration and lookup:

from spec_kit_core import ServiceRegistry
from spec_kit_contracts import IFileSystemService

registry = ServiceRegistry()

# Register service
registry.register(IFileSystemService, fs_instance)

# Get service
fs = registry.get(IFileSystemService)

# Check availability
if registry.has(IFileSystemService):
    ...

Architecture

┌─────────────────────────────────────────────────┐
│                  spec-kit-core                   │
│                                                 │
│  ┌─────────────────────────────────────────┐   │
│  │            RuntimeBridge                 │   │
│  │  Connects services to plugin runtime     │   │
│  └──────────────────┬──────────────────────┘   │
│                     │                          │
│  ┌──────────────────┴──────────────────────┐   │
│  │           ServiceRegistry                │   │
│  │  DI container for service lookup         │   │
│  └──────────────────┬──────────────────────┘   │
│                     │                          │
│  ┌──────────────────┴──────────────────────┐   │
│  │              Services                    │   │
│  │  ┌─────────┐  ┌─────────┐  ┌─────────┐  │   │
│  │  │ Config  │  │   FS    │  │Template │  │   │
│  │  └─────────┘  └─────────┘  └─────────┘  │   │
│  │  ┌─────────┐  ┌─────────┐  ┌─────────┐  │   │
│  │  │ Logging │  │  Event  │  │  State  │  │   │
│  │  └─────────┘  └─────────┘  └─────────┘  │   │
│  └──────────────────────────────────────────┘   │
└─────────────────────────────────────────────────┘
         │                    │
         ▼                    ▼
┌─────────────────┐  ┌─────────────────┐
│ spec-kit-runtime│  │spec-kit-contracts│
│  (plugin mgmt)  │  │  (interfaces)   │
└─────────────────┘  └─────────────────┘

Dependencies

  • spec-kit-contracts>=1.0.0 - Interface contracts
  • spec-kit-runtime>=1.0.0 - Plugin runtime
  • pyyaml>=6.0 - Configuration parsing
  • jinja2>=3.0 - Template rendering

License

MIT License - see LICENSE file for details.

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

spec_kit_core-1.0.0.tar.gz (20.9 kB view details)

Uploaded Source

Built Distribution

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

spec_kit_core-1.0.0-py3-none-any.whl (27.1 kB view details)

Uploaded Python 3

File details

Details for the file spec_kit_core-1.0.0.tar.gz.

File metadata

  • Download URL: spec_kit_core-1.0.0.tar.gz
  • Upload date:
  • Size: 20.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for spec_kit_core-1.0.0.tar.gz
Algorithm Hash digest
SHA256 8eec5f4ab340e5b8b26def0777c49858522d2bab7af066425adffc5ea646a795
MD5 5eaa7d755b97566408c2b54755948ba1
BLAKE2b-256 00f0f48808e49f9ce750738e3efcc718a7b284fa7b950953feaafe5b0f2cb0bc

See more details on using hashes here.

File details

Details for the file spec_kit_core-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: spec_kit_core-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 27.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for spec_kit_core-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 97982423bcdd61640032a35094d01ef0bb0f228d9458118fca11af456acbc078
MD5 61b5a185b25b5e2d4a9108b7aed74c58
BLAKE2b-256 d43bc610a25f5f96883d6dfe7786123af4eb03987c167d6e1a7cbcdd666a4572

See more details on using hashes here.

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