Skip to content

[infra] Scaffold template for contextweaver plugin projects #122

@dgenio

Description

@dgenio

Problem

Developers wanting to create contextweaver plugins (custom retrievers, event hooks, store backends, summarizers) have no template or scaffold. They must reverse-engineer the protocol definitions, entry-point configuration, and testing patterns from the main repo. This friction discourages ecosystem contributions.

Proposal

Add a contextweaver init --plugin CLI command that scaffolds a minimal plugin project:

python -m contextweaver init --plugin my-retriever

Generates:

contextweaver-my-retriever/
├── pyproject.toml          # entry-point pre-configured
├── src/
│   └── contextweaver_my_retriever/
│       ├── __init__.py
│       └── retriever.py    # stub implementing Retriever protocol
├── tests/
│   └── test_retriever.py   # protocol conformance test
├── README.md               # usage instructions
└── .github/
    └── workflows/
        └── ci.yml          # basic CI (lint + test)

Plugin types supported

The --type flag selects which protocol to scaffold:

Type Protocol Stub
retriever (default) Retriever score() method
hook EventHook on_event() method
store EventLog / ArtifactStore CRUD methods
summarizer Summarizer summarize() method

Template content

  • pyproject.toml with correct [project.entry-points] section
  • Stub class implementing the chosen protocol
  • Conformance test using isinstance() and basic smoke test
  • README with installation and registration instructions

Acceptance Criteria

  • python -m contextweaver init --plugin <name> creates a valid project directory
  • --type flag supports retriever, hook, store, summarizer
  • Generated pyproject.toml includes correct entry-point configuration
  • Protocol stub passes type checking with mypy --strict
  • Generated tests pass with pytest out of the box
  • Generated README explains how to install and register the plugin
  • Templates are stored as importlib.resources data (not hardcoded strings)

Implementation Notes

  • Use importlib.resources to load templates from a templates/ package directory
  • String interpolation (not Jinja) to avoid adding dependencies
  • Add the init --plugin subcommand to __main__.py
  • Keep templates minimal — users can expand as needed

File Paths

  • src/contextweaver/__main__.py (edit — add init subcommand)
  • src/contextweaver/templates/ (new package with template files)
  • tests/test_cli.py (edit — test init subcommand)

Cross-references

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/infraCI, builds, tooling, project infrastructurecomplexity/simpleStraightforward change, minimal riskenhancementNew feature or requestmilestone/v0.5v0.5 Advanced routing & scalepriority/lowLower priority — scale & validation

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions