+
    j:              
          R t ^ RIt^ RIt^ RIt^ RIt^ RIt^RIHtHtH	t	 ^RI
HtHtHtHtHtHt ^RIHtHt ^RIHtHtHt ^RIHtHtHt ^RIHtHtHt ^RIH t  ^R	I!Ht" ^R	I#Ht$ ^R
I%H&t& ^RI'H(t( ^RI)H*t*H+t+H,t,H-t- ^RI.H/t/H0t0 ^RI1H2t2H3t3 ^RI4H5t5H6t6H7t7 RRRRRRRRRR/t8Rt9Rt:Rt;R t<R]2 R2t=R t>R t?R t@R  tA]BR!8X  d
   ]A! 4        R# R# )"u  sshj.connect — banner, connect(), and main() (composition root).

B2 step 4d: moved verbatim from sshj_cli.py (single-file era) — no
behavior change. main() is the TOP of the dependency graph: it
constructs every subsystem and hands them together; nothing imports
connect (except the __init__/__main__ entry shims, which are the thin
launcher / `python -m` seams). Owns the ANSI_* banner colors and the
exit-code contract (0 ok / 1 cannot run / 2 no match / 130 abort /
N ssh's rc). Edges: every module (composition root by design).
N)DOWN_CONNECT_TIMEOUTssh_cmd_argsssh_cmd_str)	Discoverydiscover_candidatesexpand_hosts	make_hostparse_configsresolve)direct_selectsort_by_last_used)record_last_usedrecord_last_successseed_from_history)PROBE_TIMEOUTCheckerprobe)_insert_into_input_insert_via_relaypick)selftest)run)	SpeedScan)Conns)magicdns_onmerge_tailnetself_dnsnametailnet_peers)_GRID_BOTTOM_ROW_stdout_is_tty)VERdetect_theme)STATUS_GLYPHapply_themems_fmtupz[32mdownz[31mcheckz[33m z[2mz[1mz[0mc                     \         P                  P                  V R ,           4       \         P                  P                  4        R# )
N)sysstderrwriteflush)texts   &src/sshj/connect.py_errr1   -   s(    JJTD[!JJ    zsshj ue   — an atuin-style SSH target picker (inline grid at your prompt line)

Usage:
  sshj              open the grid (hosts from ssh config, tailnet, history/rc)
  sshj 1            run the LAST connection directly (row 1 = most-recently-used)
  sshj <string>     fuzzy direct: best match on name/address/username, execute
  sshj -<flag> …    first arg starting with '-' = ssh passthrough, not direct mode
  sshj --selftest   probe the environment (tty, size, kernel, shell, relay,
                    python) and exit 0/1/2 — no grid
  sshj doctor       machine-readable self-diagnostics (JSON; --info tier 2)
  sshj update-check check the published version against this one and set the
                    update flag (the one explicit network command; --now
                    bypasses the once-a-day cache)
  sshj --help       this text

Passthrough: any ssh flag placed before the target passes to ssh verbatim
(value-taking: -l -p -i -o -F -E -e -c -J -L -R -D -W -M -S -I -s).
Examples: sshj -t wsl · sshj -p 2222 myhost · sshj -o ConnectTimeout=5 -- host

In the grid:
  arrows        move        PgUp/PgDn  page       Home/End   first/last row
  type          fuzzy filter over name, address, username (no letter is a
                grid key by default — every character searches)
  digits + Enter numpick (1-based into the filtered list)
  Enter         connect to the selected row
  Tab           two-stage, the ADDRESS command (the name swapped for
                user@host — the footer's right side): Tab-1 stages it into
                the [source] line, Tab-2 commits it to your shell input
                field (editable); Enter runs it there, Ctrl-C discards
  Right         two-stage, the ALIAS command (for an alias, just
                `ssh <name>` — runnable as-is, no `--`): right-1 stages it
                into the [source] line, right-2 places it in your shell
                input field (same placement as the Tab commit)
  Ctrl-R        cycle sort: last used -> last SUCCESS -> alphabetical
                (the active mode shows at the input line's right edge;
                last-success sorts by the last rc==0 connection)
  Left          cancel: empty input field closes sshj outright; with a
                staged command / filter, clears it first, then closes
  Ctrl-T/X/Y/N/A/F/V   toggle -t -X -Y -N -A -f -v (shown in the footer,
                ridden into the final command)
  Esc          quit (restores your terminal)           mouse wheel: scroll

Keymap & sort: ~/.config/sshj/config.json (SSHJ_CONFIG_FILE overrides) —
  { "sort": "last" | "last_success" | "alpha",
    "keymap": { "down": ["down", "j"], "up": ["up", "k"] } }
No single letter is bound by default. Binding one (vim-style j/k) is
opt-in and deliberate; a bound single-char key acts as a grid key only
while the input field is EMPTY — the moment it has any content (even a
leading space), it and everything after it is search text.

Exit codes: 0 ok · 1 cannot run (terminal too small, < 8 rows or < 50 cols) ·
2 no match (direct mode) · 130 user quit · otherwise ssh's own exit code.

Environment: SSHJ_THEME (auto|nord|light|plain), NO_COLOR, SSHJ_STATE_DIR,
SSHJ_SSH_CMD (dry-run hook; also skips probing), SSHJ_PROBE_CONCURRENCY,
SSHJ_MAGICDNS, SSHJ_UPDATE (force the "- UPDATE" banner), SSHJ_UPDATE_URL
(update-check endpoint) — full table: sshj --selftest output and
docs/reference.md.
c                    \         P                  P                  4       '       g   R # \        P                  ! VR4      p\        \        V,           \         V RV R,           \         R\         V R,           \         R24       R # )N   · aliastargetu    — connecting)
r+   r,   isattyr"   getr1   ANSI	ANSI_BOLDANSI_ENDANSI_DIM)hoststatusgs   && r0   _banner_openrA   o   sm    ::&ADL>)QCqgz:d8n%hZ
@ Ar2   c                     \         P                  P                  4       '       g   R # \        P                  ! VR4      p\        \         RV RV R,           RVR RV \         2
4       R # )Nr4   u   ← r5   r6   u    · z.0fu
   s · exit )r+   r,   r8   r"   r9   r1   r=   r<   )r>   r?   rcelapsedr@   s   &&&& r0   _banner_closerE   w   sa    ::&AH:T!Ad7m_D >XJ
  !r2   c                R   \        WV4      p\        P                  P                  R4      pV'       d   \	        W4       \        RV,           R,           RP                  R V 4       4      ,           4       \        W^ R4       \        V R,          4       \        V R,          4       \        P                  ! ^ 4       \	        W4       \        \         RRP                  R V 4       4       \         24       Rp\        4       '       g'    \        P                   ! R	\        P"                  4      p\&        P&                  ! 4       p Ve   \(        P*                  ! W5WUR
7      pM\(        P*                  ! V4      pVP,                  pVe    \        P2                  ! V4       M \        V R,          4       V^ 8X  d   \        V R,          4       \        WV\&        P&                  ! 4       V,
          4       V'       d   \        RV 2\        P4                  R7       \        P                  ! V4       R#   \$         d    Rp ELi ; i  \.         d    ^p L\0         d    ^p Li ; i  \$         d     Li ; i  Te*    \        P2                  ! T4       i   \$         d     i i ; ii ; i)zsRun (or dry-run via SSHJ_SSH_CMD) the ssh for a selected host; routes ssh's stdio to /dev/tty when stdout is piped.SSHJ_SSH_CMDz$ r5   c              3   N   "   T F  p\         P                  ! V4      x  K  	  R # 5iNshlexquote.0as   & r0   	<genexpr>connect.<locals>.<genexpr>   s     )G$Q%++a..$   #%g        r6   c              3   N   "   T F  p\         P                  ! V4      x  K  	  R # 5irI   rJ   rM   s   & r0   rP   rQ      s      >AQrR   Nz/dev/tty)stdinstdoutr,   z
sshj: ssh exited file)r   osenvironr9   rA   printjoinrE   r   r   r+   exitr1   r=   r<   r   openO_RDWROSErrortime
subprocessr   
returncodeKeyboardInterrupt	Exceptioncloser,   )	r>   
extra_argsr?   argscmdttyt0rrC   s	   &&&      r0   connectrl      s	   j1D
**..
(C
T"dSj3)G$)G!GGHdAs+g'DM*H:R > >>?z	JK
 C	''*bii0C 
B?tsGAt$A\\ ? 
 T']#	Qw 	DM*$DIIK"$45	#B4(szz:HHRL9  	C	      ?  s~   
%H1 ?I 	I& 1III#I7 I#I# I7 "I##I7 &I43I47J&=JJ&J"J&!J""J&c                   aa  \         P                  R,          p RV 9   d/   \         P                  ! \        P                  ! \
        4      4       V '       d5   V ^ ,          R8X  d'   \         P                  ! \        V R,          4      4       V '       d5   V ^ ,          R8X  d'   \         P                  ! \        V R,          4      4       \        \        4       4       V '       d4   V ^ ,          R'9   d&   \        \        4       \         P                  ! ^ 4       \        4       p. o \        V4       F  p\        VR,          VR,          4      pRVR,          /VCRVR,          RVP                  RR	4      /CpVR
,          ;'       g
    VR,          pVR,          '       d"   VR,          R8w  d   VRVR,           2,          pVR,          '       d   VR,           RV 2pWTR&   S P!                  V4       K  	  \#        4       w  rgV'       dO   \$        P&                  P                  RR4      R8g  ;'       d    \)        \+        4       4      p\-        S WgV4      w  o p	\/        S 4      p
\1        4       pS  F  pVP3                  VR,          4       VP                  R
4      '       d   VP3                  VR
,          4       VP                  R4      '       g   Kc  VP                  R
4      '       g   K|  VP3                  VR,           RVR
,           24       K  	  \5        S 4      p\7        W4      o\9        VV 3R l4      pVP;                  4        \=        V4      pS '       g   \        R\         P>                  R7       V '       Ed   V ^ ,          PA                  R4      '       Egw   V ^ ,          p\C        V R,          4      p\E        S 4      p^ p\G        V4       FR  pV^8  d    MJ\I        V!  pV'       g   K  VP                  R
4      '       g   K8  VP!                  V4       V^,          pKT  	  \K        VV
4      p\M        VW4      w  ppVf_   \        RV: R\O        S 4       R\O        V4      \O        S 4      ,
           R2\         P>                  R7       \         P                  ! ^4       \O        V4      ^8  do   V^ ,          pVR,           F7  p\Q        \R         RVR,           RVP                  RR	4       \T         24       K9  	  \Q        \R         RVR,           \T         24       Rp\$        P&                  P                  R 4      '       g    \W        V\X        4      w  ppV'       d   R!MR"pV'       dP   VeL   \        \R         \Z        R!,           R#VR,           R#\]        V4       \T         2\         P>                  R7       MG\        \R         \Z        R",           R#VR,           R$\^         R%\T         2\         P>                  R7        \c        VVV4       \e        S WSWV4      w  pppppVf   \         P                  ! ^4       V'       d#   VPf                  P                  VR,          4      MRp\C        \i        V4      4      \C        V 4      ,           pVR&8X  d   V'       g   \k        VVV4      p\m        4       '       dE   \o        V4      '       g3   \q        T\r        ^ ,          ;'       g    R	4      '       g   \        V4       M\        V4       \         P                  ! ^ 4       \c        VVV4       R#   \`         d     EL:i ; i)(zkComposition root: build every subsystem, hand them to the grid, connect or exit per the exit-code contract.:   NNz
--selftestdoctorzupdate-checkr6   optsdispfromr(   hostnameport22:user@r7   SSHJ_MAGICDNS10c                  2   < SS P                  4       ,           # rI   )snapshot)	discoveryhostss   r0   <lambda>main.<locals>.<lambda>   s    %)"4"4"66r2   u;   sshj: no hosts in config — waiting for history/rc scan…rV   -Nzsshj: no match for z (z
 config + z discovered hosts)z  ~ z  zbest match: rG   r%   r&   r5   u    down — trying with z	s timeoutinsert)z-hz--help):r+   argvr\   r   r   r    
doctor_runupdate_check_runr#   r!   rZ   HELPr	   r   r
   r9   appendr   rX   rY   r   r   r   r   setaddr   r   r   
first_passr   r,   
startswithtuplelistr   r   r   r   lenr1   r=   r<   r   r   r"   r$   r   rd   rl   r   r?   sortedr   r   r   r   r   )!rf   entrieseinfohr7   self_ippeersmdns_on_ts_new	last_usedknowncheckerconns
speed_scanq	pass_argspooln_disccanddhchosencandsbestr?   r%   msmoder/   toggledeff_argsr~   r   s!                                  @@r0   mainr      s   "J z!c"# jmx/JrN+, jm~5!*R.12z!}(88doGE'"qz1V9-aj (D (&!G*QUU62&(j!//QwZ<<DLD0$v,((F<<V~Qvh/F(Q # #_NG**..#6#= , ,LN+ 	&uggFw!%(IEE		!G*55IIa
m$55==QUU:..II61Qz]O45  enG%)I67E	7#JK::	 z*Q-22377qM*R.)	 E{'.D}D!BrbffZ((B! / !y1%dA9>'u -%j\CIE
,B+C D&'-0ZZ9 HHQKu:>8D2YYzai[15523F2GzRS H:\$v,zBCzz~~n--v}5B!#".XJ|D'9&:!F6N;K1#BZL
4:=**F XJ|F';&<AfVn=M N22F1Gy%J(.1jj:
 		6*+/y9e,M(FGT4~4;W^^w0F VG_%j(99Hx vvx8D &d++()9!)<)B)BD D$K $KFHf%I  s    &\1 /A\1 >A\1 1] ?] __main__)C__doc__rX   rK   ra   r+   r`   rh   r   r   r   discoverr   r   r   r   r	   r
   fuzzyr   r   lastusedr   r   r   r   r   r   r   r   r   r   r(   r   ro   r   updatecheckr   scanr   stater   tailnetr   r   r   r   termr   r   themer    r!   uir"   r#   r$   r:   r=   r;   r<   r1   r   rA   rE   rl   r   __name__ r2   r0   <module>r      s   	 
   
  @ @' ' 3 N N 0 0 < <  % 0    2 $ 1 1 	j&*gzb"b	
  : :zA!1hU&p zF r2   