feat(shell): add /sh shell command execution and persistent shell mode#47
Open
yuanguangshan wants to merge 1 commit intofastclaw-ai:mainfrom
Open
feat(shell): add /sh shell command execution and persistent shell mode#47yuanguangshan wants to merge 1 commit intofastclaw-ai:mainfrom
yuanguangshan wants to merge 1 commit intofastclaw-ai:mainfrom
Conversation
Add WeChat-accessible shell command interface via /sh and /$ commands. ## Features ### /sh <cmd> — Single command execution - Execute read-only shell commands directly from WeChat - Usage: `/sh ls -la`, `/sh cat README.md` - `/$ <cmd>` is an alias ### /sh — Persistent shell mode - Enter interactive shell mode with persistent working directory - Type commands without prefix (like a real terminal) - Exit with `/q` - Prompt displays current path: `/path/to/dir:#` - Auto-runs `ls` after each `cd` ### Security — defense in depth - **Command whitelist**: only safe read-only commands allowed (ls, pwd, cd, cat, head, tail, grep, find, wc, du, df, file, stat, date, echo, basename, dirname, realpath, readlink, which, tree, nl, sort, uniq, cut, awk, sed, tr, xargs) - **Operator blacklist**: blocks `|`, `>`, `&&`, `||`, `;`, `````, `$(` - **Symlink escape protection**: resolves symlinks before cd - **Sandbox support**: optional baseDir restriction per session - **File size guard**: cat files > 50KB are rejected with tips ### UX polish - Shortcut aliases: `ll` → `ls -lh`, `..` → `cd ..`, `...` → `cd ../..` - Auto-enhance `ls` with `-C` (column layout) flag - ANSI escape code stripping for clean WeChat display - Output truncation at 4000 chars (WeChat message limit) - Markdown code block wrapping for monospace rendering ## Files changed - `messaging/handler.go`: shell mode state, routing, handleShell, enterShellMode, handleShellWithState, cleanANSI, helpers - `docs/shell-mode-guide.md`: full user guide with examples
2ed55c7 to
58ed92c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add WeChat-accessible shell command interface via /sh and /$ commands.
Features
/sh — Single command execution
/sh ls -la,/sh cat README.md/$ <cmd>is an alias/sh — Persistent shell mode
/q/path/to/dir:#lsafter eachcdSecurity — defense in depth
|,>,&&,||,;, `````,$(UX polish
ll→ls -lh,..→cd ..,...→cd ../..lswith-C(column layout) flagFiles changed
messaging/handler.go: shell mode state, routing, handleShell, enterShellMode, handleShellWithState, cleanANSI, helpersdocs/shell-mode-guide.md: full user guide with examples