+
    jHàjµ  ã                  ó®   € R t ^ RIHt ^ RIt^ RIt^ RIHt ^ RIHt ^ RI	H
t
 ^ RIHt  ! R R]4      t] ! R	 R
4      4       tR R ltR R ltR R ltR# )u*  Plugin provenance: the 2x2 reconciliation of install metadata.

Row-presence says "hermes installed this" (the .install-metadata.json
sidecar); ``.git``-presence cross-checks it. The reconciliation IS the
disambiguation â€” ``source`` alone does not distinguish a git install
from a manual copy (settled 2026-09-03, plugin-auto-update plan):

  row+git   = git install      â€” updatable via the recorded source
  neither   = manual drop      â€” not auto-updatable, listed as such
  git only  = self-cloned      â€” adoptable; origin URL carried ready
  row only  = provenance drift â€” flagged with a reinstall remedy

Pure functions over (plugins_dir, sidecar rows) â€” no globals, no
network, fully testable. The sidecar remains the single authority for
what *hermes* installed; this module only reads it.
)ÚannotationsN)Ú	dataclass)ÚEnum)ÚPath)ÚOptionalc                  ó&   € ] tR t^tRtRtRtRtRtR# )ÚProvenanceClassÚgitÚmanualzself-clonedÚdrift© N)	Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__ÚGITÚMANUALÚSELF_CLONEDÚDRIFTÚ__static_attributes__r   ó    ÚB/home/ubuntu/.hermes/hermes-agent/hermes_cli/plugins_provenance.pyr   r      s   † Ø
€CØ€FØ€KØ„Er   r   c                  ó`   € ] tR t^#t$ R]R&   R]R&   R]R&   RtR]R	&   RtR
]R&   RtR
]R&   RtR# )Ú
ProvenanceÚstrÚnamer   Úklassr   ÚpathNzOptional[dict]ÚrowúOptional[str]Ú
origin_urlÚsaved_update_urlr   )	r   r   r   r   Ú__annotations__r   r    r!   r   r   r   r   r   r   #   s1   ‡ à
ƒIØÓØ
ƒJØ€CˆÓØ $€J�Ó$Ø&*Ð�m×*r   r   c               ó    € V ^8„  d   QhRRRR/# )é   Úplugins_dirr   ÚreturnÚdictr   )Úformats   "r   Ú__annotate__r)   -   s   € ÷ 
2ñ 
2 4ð 
2¨Dñ 
2r   c                óø   € V R,          pVP                  4       '       g   / #  \        P                  ! VP                  RR7      4      p\        T\        4      '       d   T# / #   \        \
        3 d    / u # i ; i)ztThe install-metadata rows for this plugins dir; {} when absent
or unreadable (manual-only installs never wrote one).z.install-metadata.jsonú	utf-8-sig©Úencoding)Úis_fileÚjsonÚloadsÚ	read_textÚOSErrorÚ
ValueErrorÚ
isinstancer'   )r%   ÚsidecarÚdatas   &  r   Úread_sidecar_rowsr7   -   sv   € ð Ð4Õ4€GØ�?‰?×ÒØˆ	ðÜ�zŠz˜'×+Ñ+°[Ð+ÓAÓBˆô ˜d¤D×)Ò)ˆ4Ð1¨rÐ1øô ”ZÐ ô ØŠ	ðús   £&A# Á#A9Á8A9c               ó    € V ^8„  d   QhRRRR/# )r$   Ú
plugin_dirr   r&   r   r   )r(   s   "r   r)   r)   :   s   € ÷ .ñ . ð .¨ñ .r   c           
     ó   € ^ RI Hp V! 4       pVem    \        P                  ! VR\	        V 4      RRR.RRRR	^
R
R7      pVP
                  ^ 8X  d/   VP                  ;'       g    RP                  4       pV'       d   V# V R,          R,          pVP                  4       '       g   R#  VP                  RR7      pR
pTP                  4        FŒ  pTP                  4       p	T	R8X  d   RpK  T	P                  R4      '       d   R
pK9  T'       g   KC  T	P                  R4      '       g   K\  T	P                  R4      w   r«TP                  4       pT;'       g    Ru # 	  R#   \        \        P                  3 d     Lüi ; i  \         d     R# i ; i)už   origin's URL from the installed .git â€” remote get-url on a real
repo, config-file parse as the fallback (works for partial/copy
installs where git refuses).)Ú_resolve_git_executableNz-CÚremotezget-urlÚoriginTzutf-8ÚreplaceF)Úcapture_outputÚtextr-   ÚerrorsÚtimeoutÚcheckÚ ú.gitÚconfigr+   r,   z[remote "origin"]Ú[ÚurlÚ=)Úhermes_cli.plugins_cmdr;   Ú
subprocessÚrunr   Ú
returncodeÚstdoutÚstripr2   ÚTimeoutExpiredr.   r1   Ú
splitlinesÚ
startswithÚ	partition)r9   r;   r	   ÚprocrH   rF   r@   Ú	in_originÚlineÚstrippedÚ_Úvalues   &           r   Ú_git_origin_urlrZ   :   sx  € õ ?á
!Ó
#€CØ
‚ð	Ü—>’>Ø�dœC 
›O¨X°yÀ(ÐKØ#Ø G°IØØôˆDð �‰ !Ô#Ø—{‘{×(Ð( b×/Ñ/Ó1�ßØ�Jð
 ˜&Õ  8Õ+€FØ�>‰>×ÒÙðØ×Ñ¨ÐÓ5ˆð €IØ—‘Ö!ˆØ—:‘:“<ˆØÐ*Ô*ØˆIÙØ×Ñ˜s×#Ò#ØˆIÙß‰9˜×,Ñ,¨U×3Ô3Ø"×,Ñ,¨SÓ1‰KˆAˆqØ—+‘+“-ˆCØ—;�;˜$Òñ "ñ øô1 œ×2Ñ2Ð3ô 	Ùð	ûô ô Úðús0   “AE Á#E Á<E Â'E> ÅE;Å:E;Å>FÆFc               ó    € V ^8„  d   QhRRRR/# )r$   r%   r   r&   zlist[Provenance]r   )r(   s   "r   r)   r)   k   s   € ÷ $ñ $ Dð $Ð-=ñ $r   c                óŽ  € \        V 4      p. pV P                  4       '       g   V#  \        V P                  4       R R7      pT EFh  pTP                  4       '       d"   TP
                  P                  R4      '       d   K=  TR,          P                  4       pTP                  TP
                  4      p\        T\        4      '       d   TMRpT'       d   T'       d   \        P                  pMRT'       d   T'       g   \        P                  pM1T'       d   T'       g   \        P                  pM\        P                  pTP!                  \#        TP
                  TTTT\        P                  J d   \%        T4      MRT;'       g    / P                  R4      ;'       g    RR7      4       EKk  	  T#   \         d    Tu # i ; i)z8Classify every plugin dir under plugins_dir per the 2x2.c                ó   € V P                   # )N)r   )Úps   &r   Ú<lambda>Ú$plugins_provenance.<locals>.<lambda>r   s   € ¸a¿fºfr   )ÚkeyÚ.rE   NÚ
update_url)r   r   r   r   r    r!   )r7   Úis_dirÚsortedÚiterdirr2   r   rR   ÚexistsÚgetr4   r'   r   r   r   r   r   Úappendr   rZ   )r%   ÚrowsÚoutÚentriesr9   Úhas_gitr   r   s   &       r   Úplugins_provenancern   k   sX  € ä˜[Ó)€DØ€CØ×Ñ×ÒØˆ
ðÜ˜×,Ñ,Ó.Ñ4DÔEˆô ˆ
Ø× Ñ ×"Ò" j§o¡o×&@Ñ&@À×&EÒ&EÙØ Õ&×.Ñ.Ó0ˆØ�h‰h�z—‘Ó'ˆÜ ¤T×*Ò*‰c°ˆç—7Ü#×'Ñ'‰EßŸÜ#×)Ñ)‰EßŸSÜ#×/Ñ/‰Eä#×*Ñ*ˆEà�
‰
ÜØ—_‘_ØØØØ:?Ä?×C^ÑC^Ó:^œ?¨:Ô6ÐdhØ"%§) )¨§¡°Ó!>×!FÐ!FÀ$ô÷		
ñ! ð4 €Jøô9 ô ØŠ
ðús   §F4 Æ4GÇG)Ú__doc__Ú
__future__r   r/   rK   Údataclassesr   Úenumr   Úpathlibr   Útypingr   r   r   r7   rZ   rn   r   r   r   Ú<module>ru      sV   ðñõ" #ã Û Ý !Ý Ý Ý ô�dô ð ÷+ð +ó ð+õ
2õ.÷b$r   