Contributing to okf-generator¶
Thank you for taking the time to contribute! This document covers how to get set up, what kinds of contributions are most useful, and how to submit them.
Table of Contents¶
- Getting Started
- Development Setup
- Running Tests
- Integration Test Spec
- Adding a Language Parser
- Adding a Manifest Parser
- Releasing
- Submitting a Pull Request
- Code Style
- Reporting Issues
- Good First Issues
Getting Started¶
- Fork the repository on GitHub
- Clone your fork locally:
git clone https://github.com/<your-username>/okf-generator cd okf-generator - Create a feature branch:
git checkout -b feat/my-feature
Development Setup¶
# Install in editable mode with dev dependencies
pip install -e ".[dev]"
# Verify installation
okf --help
Running Tests¶
# Run all unit tests (70+ tests)
pytest tests/ -v
# Run a specific test file
pytest tests/test_generator.py -v
pytest tests/test_lookup.py -v
pytest tests/test_manifest_scanner.py -v
# Run with coverage
pytest tests/ --cov=okf --cov-report=term-missing
# Run the full integration test spec (end-to-end CLI tests)
# See TEST.md for detailed instructions
All PRs must pass the full test suite. If you add a new feature, please add tests in the appropriate file:
- tests/test_generator.py — scanner and bundle generation tests
- tests/test_lookup.py — concept search tests
- tests/test_manifest_scanner.py — manifest parser tests
New fixture files go in tests/fixtures/. Use tests/fixtures/complex/ to add languages/manifests to the comprehensive test suite.
Integration Test Spec¶
TEST.md is a step-by-step integration spec that exercises every CLI command against real codebases. It covers:
- All 7 languages (Python, JS, TS, Go, Java, Rust, Ruby)
- All 12 manifest types (pip, npm, cargo, go, composer, maven, rubygems, gradle, swiftpm, clojars, hex)
- Lookup cache (miss, hit, bypass, corrupt, invalidation)
- Edge cases (empty dir, non-existent path, unsupported-only files)
- Static pair generation, summary regeneration
- Production checklist (gitignore, version consistency, stale files)
Run it before any major change or release. See TEST.md for full instructions.
Using with AI agents: Hand TEST.md to any LLM-powered coding agent with:
"Run TEST.md and produce OKF_TEST_REPORT.md"
The spec is formatted as a self-contained script — each phase has exact bash commands and verification criteria. The agent executes it and writes a structured report.
Adding a Language Parser¶
Adding support for a new language is one of the most impactful contributions.
Steps:
-
Install the tree-sitter grammar:
pip install tree-sitter-<language> -
Probe the grammar to find node type names:
from tree_sitter import Language, Parser import tree_sitter_<language> as tslang lang = Language(tslang.language()) parser = Parser(lang) src = b"... sample code ..." tree = parser.parse(src) def all_types(node, depth=0): if depth > 4: return set() types = {node.type} for c in node.children: types |= all_types(c, depth+1) return types print(sorted(all_types(tree.root_node))) -
Subclass
TreeSitterParserinokf/generator.py:class MyLangParser(TreeSitterParser): LANGUAGE = "mylang" EXTENSIONS = {".ml"} _TS_MODULE = "tree_sitter_mylang" _lang_obj = None def _module_doc(self, root, src_bytes): ... def _parse_symbols(self, root, src_bytes, resource, ts, parent_id): ... -
Register it in
_get_parser():if ext in {".ml"}: return MyLangParser() -
Add the dependency to
pyproject.tomlunderdependencies -
Add a fixture file and test cases in
tests/
Good languages to add next: C/C++, C#, Swift, Kotlin, Scala, PHP
Adding a Manifest Parser¶
Manifest parsers live in okf/manifest_scanner.py and follow a simple pattern:
- Add the filename to
MANIFEST_HANDLERSdict - Write a
parse_<format>(path: Path) -> list[dict]function returning deps withname,ecosystem,version,devkeys - Add test cases in
tests/test_manifest_scanner.py - Add a fixture file to
tests/fixtures/complex/(so the e2etest_complex_all_manifest_ecosystemstest covers it)
Requirements:
- Zero external deps (stdlib only: re, json, xml.etree.ElementTree, tomllib)
- Mark dev=True for dev/test-only dependencies
- Handle edge cases: comments, version ranges, platform entries (like ext-*, php)
Good manifests to add next: Cargo.lock, yarn.lock, poetry.lock, packages.config, *.csproj
Releasing¶
See RELEASE.md for the full release process.
Before a release, run the complete test suite and integration spec:
pytest tests/ -q # 70+ unit tests
# Then follow TEST.md # full integration spec
Using with AI agents: Hand RELEASE.md to an LLM-powered coding agent with:
"Follow RELEASE.md to cut a new release"
The agent will: bump version, update changelog, commit, tag, and push — everything the CI pipeline needs to publish automatically.
- Ensure
pytest tests/ -vpasses with no failures - Keep commits focused — one logical change per commit
- Write a clear PR description explaining what and why
- Reference any related issues with
Closes #<issue>
Commit message format:
feat: add C# tree-sitter parser
feat(manifest): add Cargo.lock parser
fix: handle __init__.py in nested packages
docs: broaden AI agent integration guide
test: add manifest parser edge cases
chore: bump v0.1.11
Code Style¶
- Follow PEP 8
- Type hints on all public functions
- Docstrings on all public classes and functions
- Max line length: 100 characters
Reporting Issues¶
Please use GitHub Issues. Include:
- Python version (
python --version) - Package version (
okf --versiononce that's added) - Minimal reproduction case
- Full error traceback if applicable
Good First Issues¶
Look for issues tagged good first issue on GitHub. Some ideas:
- New language: Add parser for C#, Swift, Kotlin, PHP, Scala
- Fuzzy search: Improve scoring for camelCase / snake_case queries
- Docs: Add a
docs/site with mkdocs or sphinx - CLI: Add
okf --versionflag - Performance: Parallelize the scan phase for large codebases
Code of Conduct¶
Be kind and constructive. We follow the Contributor Covenant.