Skip to content

feat(matrix): support bang command aliases (salvage #28025) - #38175

Merged
alt-glitch merged 2 commits into
mainfrom
salvage/matrix-bang-commands
Jun 3, 2026
Merged

feat(matrix): support bang command aliases (salvage #28025)#38175
alt-glitch merged 2 commits into
mainfrom
salvage/matrix-bang-commands

Conversation

@alt-glitch

Copy link
Copy Markdown
Collaborator

Summary

Matrix users can now type !command aliases (e.g. !model, !stop, !queue ...) for gateway slash commands, since many Matrix clients (Element etc.) reserve leading / for local client commands. Salvages #28025 by @nepenth onto current main, plus follow-up hardening.

Changes

  • gateway/platforms/matrix.py: normalize known !command/command before dispatch; only known gateway/plugin/skill commands normalize, so !important stays chat text. Slash/bang commands bypass room mention-gating.
  • Follow-up fixes (commit 2):
    • Underscore→hyphen tolerance now emits a resolvable token: !set_home/set-home (was /set_home, which the dispatcher couldn't resolve). Aliases left as-is; the gateway canonicalizes them.
    • Fixed a dead code path: skill-command keys are stored slash-prefixed (/arxiv) in get_skill_commands(), but the check compared the bare token, so !arxiv never normalized. Now !gif-search etc. work.
    • Re-run normalization after Matrix reply-fallback stripping so a quoted-reply bang command reaches parity with the slash form.
    • Replaced silent except: pass with logger.debug(exc_info=True).
  • website/docs/user-guide/messaging/matrix.md: documents !command usage.

Validation

Result
Matrix tests 162 passed (155 original + 7 new)
New tests underscore-alias, skill-command branch, quoted-reply bang + slash parity
py_compile / git diff --check clean
E2E (real imports) normalization + skill-branch verified

Credit

Original work by @nepenth (#28025), cherry-picked with authorship preserved. Duplicate #28710 (@NlDev-hub) targeted the same feature a day later.

nepenth and others added 2 commits June 3, 2026 11:37
…mand branch

Follow-up to the salvaged contributor commit:

- Underscore→hyphen tolerance now emits a resolvable token. Previously
  the detect set accepted the hyphenated variant but emit returned the
  raw token, so '!set_home' produced '/set_home' which the dispatcher
  could not resolve. Now emits '/set-home'. Aliases are left as-is — the
  gateway dispatcher canonicalizes them itself.
- Fix dead skill-command branch: skill command keys are stored
  slash-prefixed (e.g. '/arxiv') in get_skill_commands(), but the check
  compared the bare token, so '!arxiv' never normalized. Now compares
  the '/candidate' form, making skill aliases (e.g. !gif-search) work.
- Re-run bang normalization after Matrix reply-fallback stripping so a
  quoted reply whose content is a bang command reaches command parity
  with the slash form.
- Replace silent 'except Exception: pass' with logger.debug(exc_info=True).
- Add AUTHOR_MAP entry for @nepenth.

Tests: +5 (underscore-alias, skill-command branch, quoted-reply bang +
slash parity). 162 Matrix tests pass.
@alt-glitch
alt-glitch enabled auto-merge (rebase) June 3, 2026 11:45
@github-actions

github-actions Bot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

🔎 Lint report: salvage/matrix-bang-commands vs origin/main

ruff

Total: 0 on HEAD, 0 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 0 pre-existing issues carried over.

ty (type checker)

Total: 9709 on HEAD, 9709 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 5031 pre-existing issues carried over.

Diagnostics are surfaced as warnings — this check never fails the build.

@alt-glitch alt-glitch added type/feature New feature or request P3 Low — cosmetic, nice to have platform/matrix Matrix adapter (E2EE) comp/gateway Gateway runner, session dispatch, delivery labels Jun 3, 2026
@alt-glitch
alt-glitch merged commit a1264e9 into main Jun 3, 2026
23 checks passed
@alt-glitch
alt-glitch deleted the salvage/matrix-bang-commands branch June 3, 2026 11:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery P3 Low — cosmetic, nice to have platform/matrix Matrix adapter (E2EE) type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants