API¶
Warning
The Python API for Mimeogram is currently unofficial and should be considered unstable. The package is primarily intended for use as a command-line tool. Any direct use of the Python modules may break without warning in future versions.
Package mimeogram
¶
A toolkit for exchanging collections of files with Large Language Models (LLMs). Mimeogram bundles multiple files into a single clipboard-ready document while preserving directory structure and metadata, making it ideal for code reviews, project sharing, and LLM interactions.
Module mimeogram.acquirers
¶
Content acquisition from various sources.
Module mimeogram.apply
¶
Application of mimeograms.
- class mimeogram.apply.Command(*, source: ~typing.Annotated[str, ~tyro.conf._confstruct._ArgConfig(name=None, metavar=None, help=Source file for mimeogram. Defaults to stdin if '--clip' not specified., help_behavior_hint=None, aliases=None, prefix_name=None, constructor_factory=None)] = '-', clip: ~typing.Annotated[bool | None, ~tyro.conf._confstruct._ArgConfig(name=None, metavar=None, help=Read mimeogram from clipboard instead of file or stdin., help_behavior_hint=None, aliases=('--clipboard', '--from-clipboard'), prefix_name=None, constructor_factory=None)] | None = None, mode: ~typing.Annotated[~mimeogram.updaters.ReviewModes | None, ~tyro.conf._confstruct._ArgConfig(name=None, metavar=None, help=Controls how changes are reviewed. 'silent': Apply without review. 'partitive': Review each change interactively. Partitive, if not specified and on a terminal. Silent, if not specified and not on a terminal., help_behavior_hint=None, aliases=('--review-mode', ), prefix_name=None, constructor_factory=None)] | None = None, base: ~typing.Annotated[~pathlib.Path | None, ~tyro.conf._confstruct._ArgConfig(name=None, metavar=None, help=Base directory for relative locations. Defaults to current working directory., help_behavior_hint=None, aliases=('--base-directory', ), prefix_name=None, constructor_factory=None)] | None = None, force: ~typing.Annotated[bool | None, ~tyro.conf._confstruct._ArgConfig(name=None, metavar=None, help=Override protected path checks., help_behavior_hint=None, aliases=None, prefix_name=None, constructor_factory=None)] | None = None)¶
Bases:
CliCommand
Applies mimeogram to filesystem locations.
- base: , help_behavior_hint=None, aliases=('--base-directory',), prefix_name=None, constructor_factory=None)]¶
- clip: , help_behavior_hint=None, aliases=('--clipboard', '--from-clipboard'), prefix_name=None, constructor_factory=None)]¶
- force: , help_behavior_hint=None, aliases=None, prefix_name=None, constructor_factory=None)]¶
- mode: , help_behavior_hint=None, aliases=('--review-mode',), prefix_name=None, constructor_factory=None)]¶
- source: , help_behavior_hint=None, aliases=None, prefix_name=None, constructor_factory=None)]¶
- class mimeogram.apply.ContentAcquirer(*args, **kwargs)¶
Bases:
Protocol
Acquires content for apply command.
- class mimeogram.apply.StandardContentAcquirer¶
Bases:
ContentAcquirer
Standard implementation of content acquisition.
- async mimeogram.apply.apply(auxdata: Globals, command: Command, *, acquirer: ContentAcquirer | AbsentSingleton = absence.absent, parser: Callable[[str], Sequence[Part]] | AbsentSingleton = absence.absent, updater: Callable[[Globals, Sequence[Part], ReviewModes], Coroutine[None, None, None]] | AbsentSingleton = absence.absent) Never ¶
Applies mimeogram.
Module mimeogram.cli
¶
Command-line interface.
- class mimeogram.cli.Cli(*, application: ~mimeogram.__.application.Information, configfile: str | None = None, inscription: ~mimeogram.__.inscription.Control = Control(mode=<Modes.Rich: 'rich'>, level=None), command: ~mimeogram.create.Annotated[~mimeogram.create.Command, ~tyro.conf._confstruct._SubcommandConfig(name=create, default=<tyro._singleton.NonpropagatingMissingType object at 0x7f991edaa350>, description=None, prefix_name=False, constructor_factory=None)] | ~mimeogram.apply.Annotated[~mimeogram.apply.Command, ~tyro.conf._confstruct._SubcommandConfig(name=apply, default=<tyro._singleton.NonpropagatingMissingType object at 0x7f991edaa350>, description=None, prefix_name=False, constructor_factory=None)] | ~mimeogram.prompt.Annotated[~mimeogram.prompt.Command, ~tyro.conf._confstruct._SubcommandConfig(name=provide-prompt, default=<tyro._singleton.NonpropagatingMissingType object at 0x7f991edaa350>, description=None, prefix_name=False, constructor_factory=None)])¶
Bases:
object
Mimeogram: hierarchical data exchange between humans and LLMs.
- application: Information¶
- command: NonpropagatingMissingType object at 0x7f991edaa350>, description=None, prefix_name=False, constructor_factory=None)]¶
- mimeogram.cli.execute()¶
Entrypoint for CLI execution.
Module mimeogram.create
¶
Creation of mimeograms.
- class mimeogram.create.Command(*, sources: ~typing.Annotated[list[str], Positional, ~tyro.conf._confstruct._ArgConfig(name=None, metavar=None, help=Filesystem locations or URLs., help_behavior_hint=None, aliases=None, prefix_name=False, constructor_factory=None)], clip: ~typing.Annotated[bool | None, ~tyro.conf._confstruct._ArgConfig(name=None, metavar=None, help=Copy mimeogram to clipboard., help_behavior_hint=None, aliases=('--clipboard', '--to-clipboard'), prefix_name=None, constructor_factory=None)] | None = None, edit: ~typing.Annotated[bool, ~tyro.conf._confstruct._ArgConfig(name=None, metavar=None, help=Spawn editor to capture an introductory message., help_behavior_hint=None, aliases=('-e', '--edit-message'), prefix_name=None, constructor_factory=None)] = False, prepend_prompt: ~typing.Annotated[bool, ~tyro.conf._confstruct._ArgConfig(name=None, metavar=None, help=Prepend mimeogram format instructions., help_behavior_hint=None, aliases=None, prefix_name=None, constructor_factory=None)] = False, recurse: ~typing.Annotated[bool | None, ~tyro.conf._confstruct._ArgConfig(name=None, metavar=None, help=Recurse into directories., help_behavior_hint=None, aliases=('-r', '--recurse-directories', '--recursive'), prefix_name=None, constructor_factory=None)] | None = None)¶
Bases:
CliCommand
Creates mimeogram from filesystem locations or URLs.
- clip: , help_behavior_hint=None, aliases=('--clipboard', '--to-clipboard'), prefix_name=None, constructor_factory=None)]¶
- edit: , help_behavior_hint=None, aliases=('-e', '--edit-message'), prefix_name=None, constructor_factory=None)]¶
- prepend_prompt: , help_behavior_hint=None, aliases=None, prefix_name=None, constructor_factory=None)]¶
- recurse: , help_behavior_hint=None, aliases=('-r', '--recurse-directories', '--recursive'), prefix_name=None, constructor_factory=None)]¶
- sources: , help_behavior_hint=None, aliases=None, prefix_name=False, constructor_factory=None)]¶
- async mimeogram.create.create(auxdata: ~mimeogram.__.state.Globals, command: ~mimeogram.create.Command, *, editor: ~collections.abc.Callable[[], ~collections.abc.Coroutine[None, None, str]] = <function _edit_message>, clipcopier: ~collections.abc.Callable[[str], ~collections.abc.Coroutine[None, None, None]] = <function _copy_to_clipboard>, prompter: ~collections.abc.Callable[[~mimeogram.__.state.Globals], ~collections.abc.Coroutine[None, None, str]] = <function _acquire_prompt>) Never ¶
Creates mimeogram.
Module mimeogram.differences
¶
Content differences management.
- class mimeogram.differences.ConsoleDisplay(*, context_lines: int = 3, inline_threshold: int = 24)¶
Bases:
DifferencesDisplay
Default display of differences to console.
- class mimeogram.differences.ConsoleInteractor(*args, **kwargs)¶
Bases:
DifferencesInteractor
Default console-based interaction handler.
- async mimeogram.differences.select_segments(target: Target, revision: str, display: DifferencesDisplay | AbsentSingleton = absence.absent, interactor: DifferencesInteractor | AbsentSingleton = absence.absent) str ¶
Selects which diff hunks to apply.
Module mimeogram.display
¶
System pager interaction.
Module mimeogram.edit
¶
System editor interaction.
Module mimeogram.exceptions
¶
Family of exceptions for package API.
Omniexception
: Base for all package exceptionsOmnierror
: Base for all package errors
- exception mimeogram.exceptions.ContentAcquireFailure(location: str | Path)¶
Bases:
Omnierror
Failure to acquire content from location.
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- args¶
- exception mimeogram.exceptions.ContentDecodeFailure(location: str | Path, charset: str)¶
Bases:
Omnierror
Failure to decode content as character set from location.
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- args¶
- exception mimeogram.exceptions.ContentUpdateFailure(location: str | Path)¶
Bases:
Omnierror
Failure to update content at location.
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- args¶
- exception mimeogram.exceptions.DifferencesProcessFailure(reason: str)¶
Bases:
Omnierror
Failure during diff processing.
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- args¶
- exception mimeogram.exceptions.EditorFailure(cause: str | Exception)¶
Bases:
Omnierror
Failure while operating editor.
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- args¶
- exception mimeogram.exceptions.LocationInvalidity(location: str | Path)¶
Bases:
Omnierror
Invalid location.
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- args¶
- exception mimeogram.exceptions.MimeogramFormatEmpty¶
Bases:
Omnierror
Attempt to format empty mimeogram.
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- args¶
- exception mimeogram.exceptions.MimeogramParseFailure(reason: str)¶
Bases:
Omnierror
Failure to parse mimeogram content.
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- args¶
- exception mimeogram.exceptions.Omnierror¶
Bases:
Omniexception
,Exception
Base for error exceptions raised by package API.
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- args¶
- exception mimeogram.exceptions.Omniexception¶
Bases:
BaseException
Base for all exceptions raised by package API.
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- args¶
- exception mimeogram.exceptions.PagerFailure(cause: str | Exception)¶
Bases:
Omnierror
Failure while operating pager.
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- args¶
- exception mimeogram.exceptions.ProgramAbsenceError(species: str)¶
Bases:
Omnierror
Could not discover valid editor.
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- args¶
- exception mimeogram.exceptions.TextualMimetypeInvalidity(location: str | Path, mimetype: str)¶
Bases:
Omnierror
Invalid textual MIME type for content at location.
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- args¶
- exception mimeogram.exceptions.UrlSchemeNoSupport(url: str)¶
Bases:
Omnierror
Unsupported URL scheme.
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- args¶
- exception mimeogram.exceptions.UserOperateCancellation(cause: BaseException)¶
Bases:
Omniexception
Operation cancelled by user.
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- args¶
Module mimeogram.formatters
¶
Formatting of mimeogram bundles.
Module mimeogram.interactions
¶
User interactions and automations.
- class mimeogram.interactions.GenericInteractor(*, prompter: ~collections.abc.Callable[[~mimeogram.parts.Target, str, bool], str] = <function _prompt_action>, cdisplayer: ~collections.abc.Callable[[~mimeogram.parts.Target, str], ~collections.abc.Coroutine[None, None, None]] = <function _display_content>, ddisplayer: ~collections.abc.Callable[[~mimeogram.parts.Target, str], ~collections.abc.Coroutine[None, None, None]] = <function _display_differences>, editor: ~collections.abc.Callable[[~mimeogram.parts.Target, str], ~collections.abc.Coroutine[None, None, str]] = <function _edit_content>, sselector: ~collections.abc.Callable[[~mimeogram.parts.Target, str], ~collections.abc.Coroutine[None, None, str]] = <function _select_segments>, validator: ~collections.abc.Callable[[~mimeogram.parts.Target, str], None] = <function _validate_choice>)¶
Bases:
PartInteractor
Default console-based interaction handler.
- async mimeogram.interactions.interact(target: Target, interactor: PartInteractor | AbsentSingleton = absence.absent) tuple[Resolutions, str] ¶
Performs interaction for part.
Module mimeogram.interfaces
¶
Abstract bases and interfaces.
- class mimeogram.interfaces.DifferencesDisplay(*args, **kwargs)¶
Bases:
Protocol
Configuration for content differences display.
Module mimeogram.parsers
¶
Parsers for mimeograms and their constituents.
Module mimeogram.parts
¶
Mimeogram parts.
- class mimeogram.parts.LineSeparators(value)¶
Bases:
Enum
Line separators for various platforms.
- classmethod detect_bytes(content: bytes, limit=1024) LineSeparators | None ¶
Detects newline characters in bytes array.
- classmethod normalize_universal(content: str) str ¶
Normalizes all varieties of newline characters in text.
- CR = '\r'¶
- CRLF = '\r\n'¶
- LF = '\n'¶
- class mimeogram.parts.Part(*, location: str, mimetype: str, charset: str, linesep: LineSeparators, content: str)¶
Bases:
object
Part of mimeogram.
- linesep: LineSeparators¶
Module mimeogram.prompt
¶
Mimeogram prompt text for LLMs.
- class mimeogram.prompt.Command(*, clip: ~typing.Annotated[bool | None, ~tyro.conf._confstruct._ArgConfig(name=None, metavar=None, help=Copy prompt to clipboard., help_behavior_hint=None, aliases=('--clipboard', '--to-clipboard'), prefix_name=None, constructor_factory=None)] | None = None)¶
Bases:
CliCommand
Provides LLM prompt text for mimeogram format.
- clip: , help_behavior_hint=None, aliases=('--clipboard', '--to-clipboard'), prefix_name=None, constructor_factory=None)]¶
Module mimeogram.updaters
¶
File content updates.
- class mimeogram.updaters.Queue(*, updates: list[tuple[~mimeogram.parts.Part, ~pathlib.Path, str]] = <factory>, reverter: ~mimeogram.updaters.Reverter = <factory>)¶
Bases:
object
Manages queued file updates for batch application.
- class mimeogram.updaters.Reverter(*, originals: dict[~pathlib.Path, str] = <factory>, revisions: list[~pathlib.Path] = <factory>)¶
Bases:
object
Backup and restore filesystem state.
- class mimeogram.updaters.ReviewModes(value)¶
Bases:
Enum
Controls how updates are reviewed and applied.
- Partitive = 'partitive'¶
- Silent = 'silent'¶
- async mimeogram.updaters.update(auxdata: Globals, parts: Sequence[Part], mode: ReviewModes, base: Path | AbsentSingleton = absence.absent, interactor: PartInteractor | AbsentSingleton = absence.absent, protector: Protector | AbsentSingleton = absence.absent) None ¶
Updates filesystem locations from mimeogram.
- async mimeogram.updaters.update_part(auxdata: Globals, target: Target, mode: ReviewModes, interactor: PartInteractor | AbsentSingleton = absence.absent) tuple[Resolutions, str] ¶
Updates filesystem location from mimeogram part.
Package mimeogram.fsprotect
¶
A subpackage providing filesystem protection features to prevent dangerous modifications to sensitive paths.
Module mimeogram.fsprotect.cache
¶
Cache for filesystem protection checks.
- class mimeogram.fsprotect.cache.Cache(*, rules: dict[Reasons, Rule], defaults_disablement: frozenset[str], rules_supercession: Dictionary[Path, tuple[frozenset[str], frozenset[str]]])¶
Bases:
Protector
Cache of protected paths and patterns for platform.
- class mimeogram.fsprotect.cache.Rule(*, paths: frozenset[Path], patterns: frozenset[str] = frozenset({}))¶
Bases:
object
Rule for path protection.
- mimeogram.fsprotect.cache.discover_platform_locations(auxdata: Globals, rules: dict[Reasons, Rule]) None ¶
Discovers system and user locations based on platform.
Module mimeogram.fsprotect.core
¶
Core entities for filesystem protection.
- class mimeogram.fsprotect.core.Protector(*args, **kwargs)¶
Bases:
Protocol
Filesystem protection checker.
- class mimeogram.fsprotect.core.Reasons(value)¶
Bases:
Enum
Reasons why location may be protected.
- Concealment = 'Hidden file or directory'¶
- Credentials = 'Credentials or secrets location'¶
- CustomAddition = 'User-specified custom location'¶
- OsDirectory = 'Operating system directory'¶
- PlatformSensitive = 'Platform-sensitive location'¶
- UserConfiguration = 'User configuration directory'¶
- VersionControl = 'Version control internals'¶
Module mimeogram.fsprotect.home
¶
Sensitive filesystem locations relative to user homes.
Module mimeogram.fsprotect.macos
¶
Sensitive filesystem locations on macOS.
Module mimeogram.fsprotect.project
¶
Sensitive filesystem locations relative to project directory.
Module mimeogram.fsprotect.unix
¶
Sensitive filesystem locations on Unix/POSIX/Linux.
Module mimeogram.fsprotect.windows
¶
Sensitive filesystem locations on Windows.