API Reference

This section is generated via Sphinx autodoc.

Note

The public surface area is currently primarily the CLI. The Python API is small and may still evolve.

codecrate.cli

codecrate.cli.main(argv: list[str] | None = None) None[source]

Core modules

codecrate.packer.pack_repo(root: Path, files: list[Path], keep_docstrings: bool = True, dedupe: bool = False, symbol_backend: str = 'auto', *, file_texts: dict[Path, str] | None = None, max_workers: int = 0, encoding_errors: str = 'replace') tuple[PackResult, dict[str, str]][source]
codecrate.markdown.render_markdown_result(pack: PackResult, canonical_sources: dict[str, str], layout: str = 'auto', nav_mode: Literal['compact', 'full'] = 'full', skipped_for_safety_count: int = 0, skipped_for_binary_count: int = 0, redacted_for_safety_count: int = 0, *, include_safety_report: bool = False, safety_report_entries: list[dict[str, str]] | None = None, include_manifest: bool = True, include_repository_guide: bool = True, include_symbol_index: bool = True, include_directory_tree: bool = True, include_environment_setup: bool = True, include_how_to_use: bool = True, manifest_data: dict[str, Any] | None = None, repo_label: str = 'repo', repo_slug: str = 'repo', focus_selection: FocusSelectionResult | None = None, usage_context: MarkdownUsageContext | None = None) RenderedMarkdown[source]
codecrate.markdown.render_markdown(pack: PackResult, canonical_sources: dict[str, str], layout: str = 'auto', nav_mode: Literal['compact', 'full'] = 'full', skipped_for_safety_count: int = 0, skipped_for_binary_count: int = 0, redacted_for_safety_count: int = 0, *, include_safety_report: bool = False, safety_report_entries: list[dict[str, str]] | None = None, include_manifest: bool = True, include_repository_guide: bool = True, include_symbol_index: bool = True, include_directory_tree: bool = True, include_environment_setup: bool = True, include_how_to_use: bool = True, manifest_data: dict[str, Any] | None = None, repo_label: str = 'repo', repo_slug: str = 'repo', usage_context: MarkdownUsageContext | None = None) str[source]
class codecrate.unpacker.UnpackIssue(severity: "Literal['warning', 'error']", path: 'str | None', message: 'str')[source]

Bases: object

severity: Literal['warning', 'error']
path: str | None
message: str
codecrate.unpacker.unpack_to_dir(markdown_text: str, out_dir: Path, *, strict: bool = False, fail_on_warning: bool = False, check_machine_header: bool = False) list[UnpackIssue][source]
class codecrate.validate.ValidationReport(errors: 'list[str]', warnings: 'list[str]', root_drift_paths: 'list[str]', redacted_count: 'int', safety_skip_count: 'int')[source]

Bases: object

errors: list[str]
warnings: list[str]
root_drift_paths: list[str]
redacted_count: int
safety_skip_count: int
codecrate.validate.validate_pack_markdown(markdown_text: str, *, root: Path | None = None, strict: bool = False, encoding_errors: str = 'replace') ValidationReport[source]

Utilities

codecrate.udiff.normalize_newlines(s: str) str[source]
codecrate.udiff.safe_join(root: Path, relpath: str) Path[source]
codecrate.udiff.ensure_parent_dir(path: Path) None[source]
class codecrate.udiff.FileDiff(path: 'str', hunks: 'list[list[str]]', op: "Literal['add', 'modify', 'delete']")[source]

Bases: object

path: str
hunks: list[list[str]]
op: Literal['add', 'modify', 'delete']
codecrate.udiff.parse_unified_diff(diff_text: str) list[FileDiff][source]
codecrate.udiff.apply_hunks_to_text(old_text: str, hunks: list[list[str]]) str[source]

Minimal unified-diff applier. - Expects hunks in order and matching context lines. - Raises ValueError on mismatch.

codecrate.udiff.apply_file_diffs(diffs: list[FileDiff], root: Path, *, dry_run: bool = False, encoding_errors: str = 'replace') list[Path][source]

Applies diffs to files under root. Returns list of modified paths.