repomatic.init.local_edits module

Spot the local edits repomatic init overwrites in a skill or agent copy.

init replaces each skill and agent copy it manages with the one the running release bundles. An edit a repository made to its copy, and never sent upstream, is lost to that rewrite, and the diff shows the loss as routine sync churn.

A copy holds no local edit when it matches a file that the release the repository adopted before the run bundled: the release its upstream uses: pins name. The wheel of that release holds every such file, so init reads it from PyPI and compares digests, in the normalized form init writes to disk.

repomatic.init.local_edits.CHECKED_COMPONENTS = frozenset({'skills', 'subagents'})

Components whose copies init checks for local edits before it overwrites them.

Skills and agents are prose a repository edits by hand. The other bundled files differ from the shipped ones for other reasons: labels is staged for one command, and the sync jobs bump the pins of publish-pypi-action between two releases.

repomatic.init.local_edits.shipped_digests(package, version)[source]

The digests of the data files one release of package bundled.

Reads the wheel PyPI serves for version, once its SHA-256 matches the one PyPI records. Hashes every text file under the data/ folder of the package with digest(), which is the form init writes to disk. The folder layout of the release does not matter, so a wheel that bundled a skill under another path still counts.

Parameters:
  • package (str) – The PyPI package name.

  • version (str) – The bare version of the release.

Return type:

frozenset[str] | None

Returns:

The digests, or None when the wheel could not be read.

class repomatic.init.local_edits.LocalEditGuard(package, previous)[source]

Bases: object

Spot the overwrites of one init run that lose a local edit.

package: str

PyPI name of the upstream package, like repomatic.

previous: str

Bare version of the release the repository adopted before the run.

property shipped: frozenset[str] | None[source]

The digests of the files previous bundled.

Read on first use, so a run that overwrites no copy reads nothing. None when the wheel could not be read.

check(label, current, new)[source]

The warning to give when new replaces current.

Parameters:
  • label (str) – The repository-relative path of the copy.

  • current (str) – The text of the copy on disk.

  • new (str) – The bundled text about to replace it.

Return type:

str | None

Returns:

A warning when current matches no file previous bundled. One warning for the whole run when that release cannot be read. None otherwise, as for a change of trailing whitespace only.