ctx-tui 2.0.4

Manage repo-scoped work contexts: fresh checkouts wrapped in terminal multiplexer sessions
Documentation
�

"�j_&��\�%SrSSKrSSKrSSKrSSKJrJr SSKJr Sr	Sr
SS0rS	rS
r
S\\\-S\S
\S-4SjrS\S\S
\S-4SjrS\S
\S-4SjrS\S
\4SjrS\S
\\\44SjrS\S\S\S
\S-4SjrS\S
\S-4SjrS\S
\S-4Sjr\\S.rSSSSS S!S"S#S$.0r\\\\\44\S%'SS&S'S(S)S*S+S,S$.0r\\\\\44\S-'S?S.\S/\S0\S
\4S1jjr S/\S
\S-4S2jr!S3S4S3S3S5S5S6S6S6S6S6S5S3S7S8S9.r"S.\S
\4S:jr#S\S.\S
\S-4S;jr$S\S
\4S<jr%S=\S\S
\\4S>jr&g)@z:Status column providers: user commands plus the built-ins.�N)�Config�StatusColumn)�Contextg@g �@�githubg>@ai
query($owner: String!, $repo: String!, $branch: String!) {
  repository(owner: $owner, name: $repo) {
    pullRequests(headRefName: $branch, first: 1, orderBy: {field: CREATED_AT, direction: DESC}) {
      nodes {
        state
        isDraft
        mergeable
        commits(last: 1) { nodes { commit { statusCheckRollup { state } } } }
      }
    }
  }
}
z�.data.repository.pullRequests.nodes[0] | if . == null then empty else [.state, (.isDraft | tostring), .mergeable, (.commits.nodes[0].commit.statusCheckRollup.state // "NONE")] | join(" ") end�args�ctx�returnc��N# �0[REURURS.En[R
R[R
RpC[U[5(a)[R"XRX#US9IShv�NnO*[R"XRX#US.6IShv�Nn[R"UR5[ 5IShv�NupgUR(S:wagUR+SS9R-5R/5nU(aUSR-5$S$N�N�![a gf=fNr!["a, UR%5 UR'5IShv�N gf=f7f)a<First line of a command's output, run in the checkout; None if it yields nothing.

A string runs through the shell, a list directly. Failures (non-zero exit,
timeout, missing executable) also yield None: the contract is "produce a
status or stay quiet", so a broken or inapplicable provider must not break
listings.
)�CTX_REPO�CTX_NAME)�cwd�env�stdout�stderrNr�replace)�errors)�os�environ�repo�name�asyncio�
subprocess�PIPE�DEVNULL�
isinstance�str�create_subprocess_shell�path�create_subprocess_exec�OSError�wait_for�communicate�_TIMEOUT�TimeoutError�kill�wait�
returncode�decode�strip�
splitlines)	rrr�pipe�devnull�procr�_�liness	         �D/Users/michael/dev/contexts/ctx/rewrite-it-in-rust/src/ctx/status.py�_runr1*sU���E�R�Z�Z�
D�S�X�X�3�8�8�
D�C��&�&�+�+�W�-?�-?�-G�-G�'�
��d�C� � � �8�8��(�(�����D�!�7�7��8�8��'���D�
�!�*�*�4�+;�+;�+=�x�H�H�	��
���!����M�M��M�+�1�1�3�>�>�@�E�$�5��8�>�>��.�$�.�%��������I�����	�	���i�i�k�����s��AF%�"8E�E�E�F%� $E�E�E�	F%�,E,�7E*�8E,�>AF%�E�E�
E'�$F%�&E'�'F%�*E,�,-F"�F�F"�F%�!F"�"F%�commandc��4# �[X5IShv�N$N7f)z8The `command` provider: a user-configured shell command.N)r1)rr2s  r0�command_statusr4Ks����g�#�#�#�#�s���c��# �URS-S-nUR5Rn[R"5U-
[:�agUR5R
5R5nU(dgUSR
5nUS;a&US[[R"5U-
53$U$![a gf=f7f)u}The `agent` built-in: the checkout's agent-status file.

Agent harness hooks write a word (e.g. working/blocked/idle) to
`.git/agent-status`, rewriting it only when the state changes, so the
file's mtime is the state's start; active states show their age from it.
A file untouched for an hour is stale — the agent likely died without
its hooks firing — and reads as no status.
�.gitzagent-statusNr)�working�
monitoring� )
r�stat�st_mtime�time�_AGENT_STALE_SECONDS�	read_textr)r*r �_elapsed)rr�mtimer/�words     r0�agent_statusrBPs�����8�8�f��~�-�D���	�	��$�$���9�9�;���!5�5����� �&�&�(�3�3�5������8�>�>��D��(�(���q��$�)�)�+��"5�6�7�8�8��K������s5�C�:C�C�,C�=A	C�
C�C�C�C�secondsc�l�[U5nUS:aUS3$US:aUS-S3$US-SUS-S-S3$)z^Seconds only under the first minute: a table full of ticking
second-counters reads as nervous.�<�si�m�h)�int)rC�wholes  r0r?r?isY��
��L�E��r�z����{���t�|��2�+��a� � ��t�m�_�A�e�d�l�b�0�1��3�3��urlc���URS5RSS5RSS5n[U5S:dUS(a
US(d[	SUS35eUSUS4$)	zFThe (owner, repo) of a git remote URL, tolerating ssh/https/scp forms.r6�:�/���z)cannot parse owner/repo from remote URL '�')�removesuffixr�rsplit�len�
ValueError)rL�partss  r0�github_reporYtsk�����V�$�,�,�S�#�6�=�=�c�1�E�E�
�5�z�A�~�U�1�X�U�1�X��D�S�E��K�L�L���8�U�1�X��rK�query�jqc��Z# �[R"[/SQU5[/SQU55IShv�Nup4UbUcg[U5upV[SSSSSU3SS	U3SS
U3SSU3S
U/
U5IShv�NnU(aUR5$S$Na![a gf=fN/7f)z�A GraphQL query via gh for the checkout's branch, lowercased.

No `gh`, a non-GitHub remote, or an empty jq result all read as no status.
)�git�remotezget-url�origin)r]�branchz--show-currentN�gh�api�graphqlz-Fzowner=zrepo=zbranch=z-fzquery=z--jq)r�gatherr1rYrW�lower)rrZr[r_r`�ownerr�states        r0�
_github_queryrh|s����
#�>�>��
3�S�9��
0�#�6���N�F��~�����!�&�)���������U�G����D�6�N���f�X����U�G����	
�	�!�
�E�$"�5�;�;�=�+�t�+�9�������
�s?�3B+�B�
B+�
B�(B+�9B)�:B+�
B&�#B+�%B&�&B+c��p# �[U[[5IShv�NnU(a[U5$S$N7f)z�The `github` built-in: the branch's latest PR collapsed into one cell.

Shows the most urgent fact about the PR: merged / closed / conflicts /
failing / draft / pending / ready. No PR reads as no status.
N)rh�
_GITHUB_QUERY�
_GITHUB_JQ�
_github_state)r�raws  r0�
github_statusrn�s/����c�=�*�=�
=�C�!$�=���.�$�.�>�s�6�4�6rmc��UR5upp4US;aU$US:XagUS;agUS:XagUS	;ag
g![a gf=f)zFCollapse '<state> <draft> <mergeable> <ci>' into the most urgent fact.N)�merged�closed�conflicting�	conflicts)�failure�error�failing�true�draft)�pending�expectedry�ready)�splitrW)rmrgrx�	mergeable�cis     r0rlrl�sk���&)�i�i�k�#��i�
�$�$����M�!��	�
!�!������	�
$�$��������s�:�
A�A)�agentruuuuuuu)rprqrsrvrxryr{�_BUILTIN_ICONSu◆u⊘u⚠u✖u✎u◌u✔�_FALLBACK_ICONS�column�cell�	nerd_fontc���U(a[O[RUR=(d S05nUR	S5upEnURXD5nU(aUSU3$U$)z�A cell's display form: its leading word mapped through the built-in's icons.

Any detail after the word (e.g. the elapsed time in "working 1m30s")
is kept as is.
�r9)r�r��get�builtin�	partition)r�r�r��iconsrAr.�rest�displays        r0�	cell_iconr��s]�� )�^�o�B�B�6�>�>�CW�UW�Y[�\�E��N�N�3�'�M�D�T��i�i��#�G�"&�g�Y�a��v��3�G�3rKc�P�[RURS5S5$)zDA cell's colour: the shared vocabulary's style for its leading word.r9r)�
STATUS_STYLESr�r�)r�s r0�
cell_styler��s!�����T�^�^�C�0��3�4�4rKzbold bright_greenzbold bright_cyanzbold bright_yellowzbold bright_redzbold bright_magenta�bright_black)r7r8�open�success�idlery�blockedrqrtrurvrsr{rprxc��URbUR$[RUR=(d SS5$)z?Seconds between runs of a column's provider; 0 means every ask.r�g)�interval�_DEFAULT_INTERVALSr�r�)r�s r0�refresh_intervalr�s2��
���"������!�!�&�.�.�"6�B��<�<rKc���# �URb[XR5IShv�N$URce[UR"U5IShv�N$N4N7f�N)r2r4r��BUILTINS)rr�s  r0�
column_statusr�sP���
�~�~�!�#�C���8�8�8��>�>�%�%�%��&�.�.�)�#�.�.�.�9�.�s!�&A!�A�/A!�A�A!�A!c��# �[R"[/SQU5[/SQU55IShv�Nup/nU(aURS5 U(aUS:waURSU35 SR	U5$NR7f)uLCompact git state: `*` for uncommitted changes, `↑n` for unpushed commits.)r]�statusz--porcelain)r]zrev-listz--countz
--branchesz--notz	--remotesN�*�0u↑r9)rrdr1�append�join)r�dirty�unpushedrXs    r0�	git_stater�sv���#�N�N��
-�s�3��
O�QT�U���O�E�
�E��
���S���H��O�
���s�8�*�%�&��8�8�E�?���s�3B
�B�AB
�cfgc
��>^# �[R"[T5/U4SjUR5Q76IShv�Ntp#U=(d S/[	URUSS9VVs/sH$upEU(a[XEUR5OSPM& snn-$NYs snnf7f)zFThe STATUS column's value plus one display cell per configured column.c3�<># �UHn[TU5v� M g7fr�)r�)�.0�colrs  �r0�	<genexpr>�status_cells.<locals>.<genexpr>#s����H�Z�c�-��S�1�1�Z�s�Nr�T)�strict)rrdr�r��zipr�r�)r�rrg�cellsr�r�s `    r0�status_cellsr� s�����!�.�.��#���H�S�Z�Z�H���M�E�
�K�R�=��S�Z�Z��t�<��<�I�C�04�	�#�S�]�]�+��;�<�������s!�8B�B�(B�$+B�B�B)T)'�__doc__rrr<�
ctx.configrr�ctx.contextsrr#r=r�rjrk�listrr1r4rB�floatr?�tuplerYrhrnrlr�r��dict�__annotations__r��boolr�r�r�r�r�r�r��rKr0�<module>r�s{��@��	��+� �����
��%��
�
���/�T�#�Y��_�/�7�/�s�T�z�/�B$�g�$��$��d�
�$�
�G���d�
��24�e�4��4��S��U�3��8�_��!,�W�!,�S�!,�c�!,�c�D�j�!,�H/�W�/��t��/��s��s�T�z��(����
���������
-���S�$�s�C�x�.�(�)�
�
���������
.���c�4��S��>�)�*�
�	4�l�	4�#�	4�$�	4�#�	4�5�S�5�S�4�Z�5�#�$��"� �#� �� �
� �%�
 �#�
��
�&=�\�=�e�=�/�W�/�l�/�s�T�z�/����S���F����T�#�Y�rK