SuperAPI AI Directory

lx-sh

General & other

View repository

Updated 10-16 08:34

About this skill

Virtual Shell

Prerequisites: requires lx CLI to be configured and logged in.

⚡ When should you use this skill?

Scenarios for use:

  • The user says "browse the knowledge base"/"look at the knowledge base structure"
  • The user says "search file contents"/"view document contents"
  • The user says "run grep/ls/cat in the knowledge base"

Prohibited in this skill:

  • Do not modify content: the user says "edit a certain page"/"push changes" → immediately switch to the lx-git or lx-block skill
  • Shell is read-only:/kb is a read-only file system,rm/mv/cp/mkdir/touch and other write commands will be intercepted

⚡ How to choose commands? (Decision tree)

识别场景 →
├── 交互式浏览知识库内容? → lx sh(REPL 模式)
├── 执行单条命令后退出? → lx sh --exec "<command>"
├── 连接远程知识库(无需本地 clone)? → lx sh --space sp_xxx
├── 在已有 worktree 中浏览? → cd <worktree> && lx sh
├── 搜索知识库内容? → lx sh --exec "grep -r <pattern> /kb"
├── 查看文档结构? → lx sh --exec "tree /kb"
└── 需要修改内容(push/commit)? → 切换到 lx-git skill

⚠️ High-risk operations and default preferred paths

Read-only file system:

  • In Shell, /kb is read-only,rm/mv/cp/mkdir/touch and other write commands will be intercepted
  • To modify content, use lx git or lx block commands

Default preferred path:

  1. Agent should preferentially use lx sh --exec "..." for a single execution, avoiding starting the REPL
  2. Do not want to clone → use MCP remote mode lx sh --space sp_xxx
  3. Already have a local worktree → execute in the worktree directory lx sh

Two running modes:

Mode Startup method /kb mapping Applicable scenarios
Worktree cd <worktree> && lx sh Local disk An already cloned knowledge base that needs to be browsed quickly
MCP remote lx sh --space sp_xxx Remote MCP API Do not want to clone, browse remote content directly

Available tools

Startup command

Command Description
lx sh Start REPL interactive mode
lx sh --exec "<cmd>" Execute a single command and exit
lx sh --space sp_xxx MCP remote mode
lx sh --path <dir> Specify the worktree path

Detailed parameters:lx sh --help

Shell built-in commands (used in lx sh )

Category Command
File browsing ls, cat, tree, stat
Search grep, find, fzf
Text processing head, tail, wc, sort, uniq, awk, cut, tr
Navigation cd, pwd, echo
Bridge commands search, mcp, git

Detailed parameters:lx sh --help, or enter within the Shell help

🎯 Execution rules

  1. Read-only file system: in Shell, /kb is read-only,rm/mv/cp/mkdir/touch and other write commands will be intercepted. To modify content, use lx git or lx block commands.
  2. Pipes and redirection: fully supports | pipes and > redirection. Such as grep -r "API" /kb | head -20。
  3. Alias system:rg → grep -rn、eza → ls、fd → find、bat → cat. Automatically converts when users use modern tool names.
  4. git in Shell is read-only: enter in the Shell git status/git log/git diff available (read-only), but git push/git commit and other write operations will prompt you to exit the Shell and use lx git to execute.
  5. /tmp writable:/tmp directory is a memory filesystem, where temporary data can be written.
  6. Non-interactive mode: Agents should prefer using lx sh --exec "..." for one-shot execution, avoiding starting a REPL.
  7. search command: The Shell's built-in search <keyword> is a shortcut wrapper for the MCP search_kb_search .
  8. mcp passthrough: Within the Shell, mcp <tool_name> [json_args] can directly call any MCP tool.

Typical combined workflow

Browse the structure of a remote knowledge base

# 直接连接远程,不需要 clone
lx sh --space sp_xxx

# 在 Shell 中:
tree /kb --depth 2
ls -la /kb/项目文档/
cat /kb/项目文档/README.md

Search for content in the knowledge base

# 单次执行
lx sh --exec "grep -r 'OAuth' /kb | head -10"

# 或使用内置 search
lx sh --exec "search OAuth 认证"

Analyze document content

lx sh --exec "wc -l /kb/**/*.md"
lx sh --exec "grep -rl 'TODO' /kb"
lx sh --exec "find /kb -name '*.md' | wc -l"

Programming API usage (Agent integration)

# 执行命令并获取输出
lx sh --exec "grep -r 'API 设计' /kb | head -5"

# 透传 MCP 调用
lx sh --exec 'mcp entry_describe_entry {"entry_id": "entry_xxx"}'