Skip to content

feat: pyauto-status shell function for cross-repo drift dashboard #2

Description

@Jammy2211

Overview

A two-keystroke command that prints the sync state of every PyAuto repo against
its origin tracking branch. Catches commit drift early — the 2026-04-27 audit
found 12 repos up to 101 commits behind origin and only noticed by accident.
Wires into the PyAuto / PyAutoGPU / PyAutoNoJAX venv activation aliases
so the dashboard prints automatically every time the user enters the workspace.

Plan

  • Create PyAutoPrompt/scripts/pyauto_status.sh defining a pyauto-status shell function
  • The function dynamically discovers all git repos under ~/Code/PyAutoLabs/, fetches in parallel, and prints one line per repo: branch, upstream, behind/ahead counts, dirty count, flag glyphs
  • Handle the failure modes the audit surfaced: missing upstream → NONE flag, renamed default branch → use @{u} not hard-coded origin/main, non-git directories → skip cleanly, fetch failures → don't crash the sweep
  • Source the script from ~/.bashrc so the function is available in every shell
  • Modify the PyAuto, PyAutoGPU, PyAutoNoJAX shell functions in ~/.bashrc to call pyauto-status at the end so the dashboard prints automatically after venv activation
  • Optionally extend PyAutoPrompt/scripts/status.sh with a --repos flag that delegates to pyauto-status
  • Verify acceptance: full sweep <10s, all repos one screen, non-default branches visible, no-upstream flagged
Detailed implementation plan

Affected Repositories

  • PyAutoPrompt (primary — only tracked changes)

Plus a manual append/edit to ~/.bashrc (personal env, no PR).

Work Classification

Library (treated as such for the standard /start_library → worktree → /ship_library flow, even though PyAutoPrompt is workflow tooling rather than a runtime library).

Branch Survey

Repository Current Branch Dirty?
./PyAutoPrompt main 1 modified + 1 untracked (both pre-existing, unrelated — weak/1_simulator.md and autolens/point_simulator_errors.md.txt)

Suggested branch: feature/pyauto-status-shell
Worktree root: ~/Code/PyAutoLabs-wt/pyauto-status-shell/ (created later by /start_library)

Implementation Steps

  1. PyAutoPrompt/scripts/pyauto_status.sh (new) — sourceable script defining pyauto-status().

    • Discovery: find ~/Code/PyAutoLabs -maxdepth 2 \( -name .git -type d -o -name .git -type f \) -printf '%h\n' | sort (the -type f clause picks up linked worktrees, whose .git is a file).
    • Parallel fetch: spawn git -C "$repo" fetch --quiet origin & per repo, then wait.
    • Per repo collect: branch (rev-parse --abbrev-ref HEAD, mark (detached) if literal HEAD), upstream (rev-parse --abbrev-ref @{u} 2>/dev/nullNONE if empty), behind/ahead (rev-list --left-right --count "$upstream"...HEAD), dirty count (status --porcelain | wc -l).
    • Print: header + per-repo row via printf with fixed columns. Flag glyphs: behind, ahead, * dirty, ! no upstream or fetch failed.
    • Wrap each repo's collection in error handling so one bad repo doesn't kill the sweep.
  2. PyAutoPrompt/scripts/status.sh (edit) — add a --repos arg near the top of the script that sources pyauto_status.sh and runs pyauto-status, then exits. Leave --full and default behavior untouched.

  3. ~/.bashrc (edit, personal env, no PR) — done after the PR merges:

    • Append a sourcing line so the function loads in every shell:
      `bash

      PyAuto cross-repo sync status

      [ -f ~/Code/PyAutoLabs/PyAutoPrompt/scripts/pyauto_status.sh ] &&
      source ~/Code/PyAutoLabs/PyAutoPrompt/scripts/pyauto_status.sh
      `
    • Edit the PyAuto(), PyAutoGPU(), PyAutoNoJAX() functions to add pyauto-status as the last line inside each. Skip PyAutoOld() (it targets /mnt/c/Users/Jammy/Code/PyAuto, not the labs root).

Key Files

  • PyAutoPrompt/scripts/pyauto_status.sh — new shell function (the bulk of the work).
  • PyAutoPrompt/scripts/status.sh — extended with --repos flag.
  • ~/.bashrc — sourced once + venv aliases extended (out-of-PR personal config).

Acceptance Verification

  • time pyauto-status from a fresh shell — assert wall-clock < 10s.
  • Verify all ~19 repos under ~/Code/PyAutoLabs/ appear in the output.
  • Temporarily checkout a feature branch in one repo and re-run — confirm no auto-checkout, flag column shows /* correctly.
  • Confirm a no-upstream repo (e.g. autolens_workspace_developer per prompt 06) prints NONE and ! flag.
  • Open a fresh shell, run PyAuto — dashboard prints automatically right after cd ~/Code/PyAutoLabs.

Naming clash to be aware of

There is already a /pyauto-status slash command in PyAutoPrompt/skills/pyauto-status/ that prints the workflow-registry dashboard (planned/active/complete tasks). The shell function reuses the name in the terminal namespace for git drift. Different surfaces, no collision, but worth noting in the README/docstring.

Out of scope

  • Auto-pulling — handled by prompt 05's /sync slash command later.
  • Pretty colors / TUI — plain text only.

Original Prompt

Click to expand starting prompt

Cross-repo sync status dashboard

⚠️ Caveat — drafted from a stale repo state. This prompt was drafted on 2026-04-27 during a forensic sweep that found local checkouts up to 101 commits behind origin. The trigger looked like a structural workflow flaw, but later analysis showed the drift was largely driven by stale local checkouts being edited without git pull first, not by missing tooling. Now that PyAutoPrompt is the canonical source-of-truth and skills/install.sh auto-discovers across both repos, some of the recommendations below may be over-engineered for the day-to-day case. Re-evaluate whether each measure is still warranted — the cheap habits (pull before edit, never rewrite history) buy most of the win.

Drift across PyAuto repos is currently invisible — there's no single command
that shows whether each library and workspace is in sync with origin/main.
The 2026-04-27 audit found 12 repos with up to 101 commits of behind-origin
state, and we only noticed because of an unrelated investigation. Catching it
early needs a dashboard that's two keystrokes away.

What to build

A shell function pyauto-status (loaded via ~/.bashrc or ~/.local/bin/)
that, for every git repo under ~/Code/PyAutoLabs/, prints:

  • repo name
  • current branch
  • upstream tracking ref (or NONE if missing — a real failure mode that hid
    autolens_workspace_developer for weeks)
  • behind / ahead counts vs @{u}
  • dirty file count
  • a single-glyph flag column: for behind, for ahead, * for dirty

Implementation notes:

  • Run git fetch origin --quiet per repo before counting (a stale dashboard is
    worse than none).
  • Skip directories that aren't git repos cleanly (warn, don't crash).
  • Use the upstream branch from git rev-parse --abbrev-ref @{u}, not a
    hardcoded origin/main. PyAutoFit recently moved from main_buildmain
    and a hardcoded version would have hidden that.

A working draft is included in
PyAutoPrompt/autoprompt/snippets/pyauto_status.sh (see file). Test it; tune the
column widths; either inline it into ~/.bashrc or symlink from ~/.local/bin/.

Acceptance

  • Running pyauto-status from any directory shows all 12 repos in one screen.
  • A repo on a non-default branch is visible (don't auto-checkout main).
  • A repo with no upstream is flagged, not silently skipped.
  • The whole sweep finishes in well under 10 seconds (parallel-friendly fetch).

Out of scope

  • Auto-pulling. This is a status command only — fixing drift is a separate
    prompt (05_sync_slash_command.md).
  • Pretty colors / TUI. Plain text is faster to read and pipe.

Files touched

  • ~/.bashrc (or ~/.local/bin/pyauto-status + chmod +x)
  • Optionally: PyAutoPrompt/scripts/status.sh already prints prompt-registry
    counts; consider adding a --repos flag that delegates to this function.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions