Repository navigation
fix(derive_name): bump basename cap 12 → 20 so repo names fit - #69
Conversation
The 12-char truncation was producing awkward stubs in the auto-derived agent name. `~/Development/ideem/authenticator` came back as `authenticato-fd63` instead of `authenticator-fd63`; the missing trailing 'r' was an immediate cognitive speed bump for anyone trying to match agent names to repos in a busy multi-tab room. Bump the cap to 20 chars so common repo names fit cleanly: authenticator → authenticator-d1f4 vHSM → vhsm-d1f4 trusted-app-service → trusted-app-service-993e merchant-browser-sim → merchant-browser-sim-XXXX airc → airc-d1f4 Also tighten the sanitization pipeline: collapse runs of dashes (`cambriantech--airc-src` → `cambriantech-airc-src`), strip leading and trailing dashes, and re-strip after the cut so a truncation that falls on a dash doesn't leave a dangling tail. Pure cosmetic — safer default, no behavior change beyond the cap. Within an auto-scoped room, every peer is from the same org by construction (see infer_repo_org from #66), so the org prefix would just be redundant noise on every name. The repo basename + 4-char hash is the right granularity for the room's audience. Existing names persist in `<scope>/.airc/identity` — derive_name fires on first-init, not on every connect. To pick up the new form in an existing scope: `airc nick <new>` for in-place rename, or `airc teardown --flush && airc join` for a fresh derive. 97/97 integration tests pass. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
There was a problem hiding this comment.
Pull request overview
Updates derive_name so auto-derived peer nicknames better fit common repo names and are more consistently sanitized.
Changes:
- Increase derived basename cap from 12 → 20 characters.
- Tighten basename sanitization (collapse repeated dashes; strip leading/trailing dashes).
- Update
derive_namedoc comment to reflect the naming intent in org-scoped rooms.
Comments suppressed due to low confidence (1)
airc:85
derive_namecomputeshashvia ashasum | cutpipeline underset -euo pipefail. Ifshasumis missing or errors, the script will exit immediately and thecksumfallback below will never run. Consider guarding withcommand -v shasum(or otherwise making theshasumattempt non-fatal) so the fallback is actually reachable.
hash=$(printf '%s' "$dir" | shasum -a 256 2>/dev/null | cut -c1-4)
[ -z "$hash" ] && hash=$(printf '%s' "$dir" | cksum | cut -c1-4)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # Format: <repo>-<4-char-hash> when in a git repo (basename of the git | ||
| # top-level), or <dir-basename>-<4-char-hash> otherwise. Hash | ||
| # disambiguates same-name directories across different parent paths | ||
| # (two "src" dirs, two clones of the same repo, etc.). | ||
| # | ||
| # Within a room scoped to a single org (which is the auto-scope default | ||
| # — see infer_repo_org), every peer is from that org by construction, so | ||
| # adding the org as a name prefix is redundant and lengthens @-mentions. | ||
| # Cap is 20 chars on the basename, comfortably fitting common repo names | ||
| # (`authenticator-d1f4`, `merchant-browser-d1f4`) without truncation. | ||
| # Users can override any time with `airc nick`. | ||
| derive_name() { | ||
| local dir="${1:-$(pwd -P)}" | ||
| # Prefer git root basename — more meaningful than a subdir basename when | ||
| # the user happens to be deep in a repo — but hash the actual cwd so | ||
| # subdirs still get unique names. | ||
| local base_dir git_root | ||
| local base_dir git_root base | ||
| git_root=$(cd "$dir" 2>/dev/null && git rev-parse --show-toplevel 2>/dev/null) | ||
| base_dir="${git_root:-$dir}" | ||
| local base | ||
| base=$(basename "$base_dir" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9-]/-/g' | cut -c1-12) | ||
| base=$(basename "$base_dir" \ | ||
| | tr '[:upper:]' '[:lower:]' \ | ||
| | sed 's/[^a-z0-9-]/-/g' \ | ||
| | sed 's/--*/-/g; s/^-*//; s/-*$//' \ | ||
| | cut -c1-20 \ | ||
| | sed 's/-*$//') |
There was a problem hiding this comment.
This PR updates bash derive_name to cap/sanitize repo basenames, but the Windows implementation in airc.ps1 (Derive-Name, currently caps at 12 and doesn’t collapse/trim dashes; see airc.ps1:145-164) still derives different/truncated names. If Windows is a supported platform, the PowerShell version should be updated in the same way (or the docs should clarify the behavior divergence).
| base=$(basename "$base_dir" \ | ||
| | tr '[:upper:]' '[:lower:]' \ | ||
| | sed 's/[^a-z0-9-]/-/g' \ | ||
| | sed 's/--*/-/g; s/^-*//; s/-*$//' \ | ||
| | cut -c1-20 \ | ||
| | sed 's/-*$//') |
There was a problem hiding this comment.
The basename sanitization + length cap behavior here is user-visible and easy to regress, but it isn’t covered by the integration suite today (the suite typically sets AIRC_NAME). Consider adding a small test that runs airc debug-name in temp dirs with representative names (e.g., long repo name, leading dot, double dashes) to assert the expected <base>-<hash> shape and the 20-char cap.
Summary
derive_namewas truncating common repo names:~/Development/ideem/authenticatorcame back asauthenticato-fd63(missing trailing 'r'). Bump the cap from 12 to 20 chars so full names fit, plus tighten the sanitization pipeline (collapse double dashes, strip leading/trailing).~/Development/ideem/authenticatorauthenticato-fd63authenticator-d1f4~/Development/ideem/vHSMvhsm-2c84vhsm-d1f4(unchanged shape)~/Development/ideem/trusted-app-servicetrusted-app-s-XXXXtrusted-app-service-993e~/.airc-src(wascambriantech--airc-src)airc-src-7079Why short-form, not
<org>-<repo>We considered
useideem-authenticator-448fto give cross-room context, but within an auto-scoped room every peer is from the same org by construction (see #66'sinfer_repo_org), so the org prefix is redundant noise.<repo>-<hash>is the right granularity for the room's audience — easy@-typing, immediately recognizable, no cognitive truncation tax.Migration note
Existing names persist in
<scope>/.airc/identity(derive_namefires on first-init, not every connect). To adopt the new form on a pre-existing scope:airc nick <new>— in-place rename, paired peers auto-update.airc teardown --flush && airc join— fresh derive.Test plan
test/integration.sh— 97/97 pass on this branch🤖 Generated with Claude Code