Lumoswitch 文档
Agent 接入

Crush Agent 接入

Crush 是 Charm 开发的终端编码 Agent,适合在 TUI 中阅读和修改项目、运行命令、切换模型与使用 MCP。它是 CLI 产品;官方提到的“桌面通知”只是终端失焦时的系统提醒,并不是独立 Desktop 应用,也没有官方 IDE 扩展。

开始前,请创建使用 OpenAI-compatible 输出的 Lumoswitch 配置 API。Crush 当前推荐 crushrc 配置;旧 crush.json 仍兼容,但已不再是首选。

方式总览

方式是否支持实现方式
仅本次启动支持CRUSH_GLOBAL_CONFIG 指向临时 crushrc
永久使用支持使用 Agent 支持的 crushrc 路径与可选维护启动器
清除接入支持精确删除专属文件,不删除 Crush 数据目录

准备连接信息

占位符应填写的内容
{{api_base_url}}配置 API 的下游地址,包含 /v1
{{access_key}}当前配置使用的 Lumoswitch Access Key
{{model}}配置 API 显示的下游模型名称
{{crush_config_text}}包含全部下游模型与已核验推理标记的 Crush 配置

下例把上下文窗口暂定为 128000、最大输出暂定为 8192。请按真实模型能力修改;这些值会影响 Crush 的上下文与输出管理。

仅本次启动

(
  set -e
  LUMOSWITCH_CRUSH_CONFIG="$(mktemp "${TMPDIR:-/tmp}/lumoswitch-crush.XXXXXX")"
  trap 'rm -f "$LUMOSWITCH_CRUSH_CONFIG"' EXIT
  cat > "$LUMOSWITCH_CRUSH_CONFIG" <<'LUMOSWITCH_CRUSH_CONFIG_EOF'
{{crush_config_text}}LUMOSWITCH_CRUSH_CONFIG_EOF
  chmod 600 "$LUMOSWITCH_CRUSH_CONFIG"
  env \
    LUMOSWITCH_CRUSH_API_KEY="{{access_key}}" \
    CRUSH_GLOBAL_CONFIG="$LUMOSWITCH_CRUSH_CONFIG" \
    crush --model "lumoswitch/{{model}}"
)

临时文件和 Key 只在该子进程中生效,退出后自动清除。当前项目若有 .crushrccrushrc,它的优先级高于全局配置;出现模型被覆盖时先检查项目配置。

永久使用

set -e
LUMOSWITCH_ROOT="$HOME/.config/lumoswitch/agents/crush"
LUMOSWITCH_ENV="$LUMOSWITCH_ROOT/env.sh"
LUMOSWITCH_LAUNCHER="$HOME/.local/bin/lumoswitch-crush"
mkdir -p "$LUMOSWITCH_ROOT" "$(dirname "$LUMOSWITCH_LAUNCHER")"
umask 077

if [ -f "$LUMOSWITCH_LAUNCHER" ]; then
  LUMOSWITCH_BACKUP="$LUMOSWITCH_LAUNCHER.backup.$(date +%Y%m%d-%H%M%S)-$$"
  cp "$LUMOSWITCH_LAUNCHER" "$LUMOSWITCH_BACKUP"
  chmod 600 "$LUMOSWITCH_BACKUP"
fi

LUMOSWITCH_CRUSH_CONFIG="$LUMOSWITCH_ROOT/crushrc"
cat > "$LUMOSWITCH_CRUSH_CONFIG" <<'LUMOSWITCH_CONFIG_EOF'
{{crush_config_text}}LUMOSWITCH_CONFIG_EOF

cat > "$LUMOSWITCH_ENV" <<'LUMOSWITCH_ENV_EOF'
export CRUSH_GLOBAL_CONFIG="$HOME/.config/lumoswitch/agents/crush/crushrc"
export LUMOSWITCH_CRUSH_API_KEY="{{access_key}}"
export LUMOSWITCH_CRUSH_API_BASE_URL="{{api_base_url}}"
export LUMOSWITCH_CRUSH_MODEL="{{model}}"
LUMOSWITCH_ENV_EOF

case "$SHELL" in
  */zsh) LUMOSWITCH_PROFILE="$HOME/.zshrc" ;;
  */bash) LUMOSWITCH_PROFILE="$HOME/.bashrc" ;;
  *) LUMOSWITCH_PROFILE="$HOME/.profile" ;;
esac
touch "$LUMOSWITCH_PROFILE"
LUMOSWITCH_PROFILE_MARKER='# Lumoswitch Agent: crush'
LUMOSWITCH_SOURCE_LINE='[ -f "$HOME/.config/lumoswitch/agents/crush/env.sh" ] && . "$HOME/.config/lumoswitch/agents/crush/env.sh"'
if ! grep -Fqx "$LUMOSWITCH_SOURCE_LINE" "$LUMOSWITCH_PROFILE"; then
  printf '\n%s\n%s\n' "$LUMOSWITCH_PROFILE_MARKER" "$LUMOSWITCH_SOURCE_LINE" >> "$LUMOSWITCH_PROFILE"
fi
printf '%s\n' "$LUMOSWITCH_PROFILE" > "$LUMOSWITCH_ROOT/profile-path"

cat > "$LUMOSWITCH_LAUNCHER" <<'LUMOSWITCH_LAUNCHER_EOF'
#!/usr/bin/env bash
set -e
LUMOSWITCH_ROOT="$HOME/.config/lumoswitch/agents/crush"
LUMOSWITCH_ENV="$LUMOSWITCH_ROOT/env.sh"
LUMOSWITCH_LAUNCHER="$HOME/.local/bin/lumoswitch-crush"

if [ "$1" = "--lumoswitch-clean" ]; then
  if [ -f "$LUMOSWITCH_ROOT/profile-path" ]; then
    LUMOSWITCH_PROFILE="$(cat "$LUMOSWITCH_ROOT/profile-path")"
    if [ -f "$LUMOSWITCH_PROFILE" ]; then
      LUMOSWITCH_PROFILE_MARKER='# Lumoswitch Agent: crush'
      LUMOSWITCH_SOURCE_LINE='[ -f "$HOME/.config/lumoswitch/agents/crush/env.sh" ] && . "$HOME/.config/lumoswitch/agents/crush/env.sh"'
      LUMOSWITCH_PROFILE_TMP="$LUMOSWITCH_PROFILE.lumoswitch.$$"
      awk -v marker="$LUMOSWITCH_PROFILE_MARKER" -v source="$LUMOSWITCH_SOURCE_LINE" '$0 != marker && $0 != source' "$LUMOSWITCH_PROFILE" > "$LUMOSWITCH_PROFILE_TMP"
      mv "$LUMOSWITCH_PROFILE_TMP" "$LUMOSWITCH_PROFILE"
    fi
  fi
  if [ -d "$LUMOSWITCH_ROOT" ]; then
    find "$LUMOSWITCH_ROOT" -depth \( -type f -o -type l \) -delete
    find "$LUMOSWITCH_ROOT" -depth -type d -exec rmdir {} \; 2>/dev/null || true
  fi
  find "$(dirname "$LUMOSWITCH_LAUNCHER")" -maxdepth 1 -type f -name 'lumoswitch-crush.backup.*' -delete
  rm -f "$LUMOSWITCH_LAUNCHER"
  printf '%s\n' 'Lumoswitch native setup and optional launcher removed. Open a new terminal to refresh the environment.'
  exit 0
fi

if [ -f "$LUMOSWITCH_ENV" ]; then . "$LUMOSWITCH_ENV"; fi
exec crush "$@"
LUMOSWITCH_LAUNCHER_EOF

chmod 600 "$LUMOSWITCH_ENV"
find "$LUMOSWITCH_ROOT" -type f -exec chmod 600 {} \;
chmod 700 "$LUMOSWITCH_LAUNCHER"
. "$LUMOSWITCH_ENV"
printf '%s\n' 'Native Lumoswitch setup saved. Future command: crush'
printf '%s\n' 'Optional maintenance launcher: ~/.local/bin/lumoswitch-crush'
crush

以后运行:

crush

crushrc 引用 Agent 专属环境变量;Key 保存在仅当前用户可读的受管环境文件中,不写入可选启动器。

Windows PowerShell 原生导入

以下命令在 Windows PowerShell 中原生运行,不需要 WSL。它们与本页的 macOS/Linux 模板使用同一组连接值。

仅本次使用(Windows)

& {
  $ErrorActionPreference = 'Stop'
  $lumoswitchConfig = Join-Path ([IO.Path]::GetTempPath()) ('lumoswitch-' + [Guid]::NewGuid().ToString('N') + '.json')
  $lumoswitchConfigContent = @'
{{crush_config_text}}
'@
  [IO.File]::WriteAllText($lumoswitchConfig, $lumoswitchConfigContent, [Text.UTF8Encoding]::new($false))
  $lumoswitchEnvironmentNames = @('CRUSH_GLOBAL_CONFIG', 'LUMOSWITCH_CRUSH_API_KEY')
  $lumoswitchPreviousEnvironment = @{}
  foreach ($lumoswitchName in $lumoswitchEnvironmentNames) {
    $lumoswitchPreviousEnvironment[$lumoswitchName] = [Environment]::GetEnvironmentVariable($lumoswitchName, 'Process')
  }
  $lumoswitchExitCode = 0
  try {
    [Environment]::SetEnvironmentVariable('CRUSH_GLOBAL_CONFIG', $lumoswitchConfig, 'Process')
    [Environment]::SetEnvironmentVariable('LUMOSWITCH_CRUSH_API_KEY', '{{access_key}}', 'Process')
    $lumoswitchArguments = @('--model', 'lumoswitch/{{model}}')
    $lumoswitchExecutable = Get-Command 'crush.cmd' -CommandType Application -ErrorAction SilentlyContinue
    if ($null -eq $lumoswitchExecutable) { $lumoswitchExecutable = Get-Command 'crush' -CommandType Application -ErrorAction Stop }
    & $lumoswitchExecutable.Path @lumoswitchArguments
    if ($null -ne $LASTEXITCODE) { $lumoswitchExitCode = $LASTEXITCODE }
  } finally {
    foreach ($lumoswitchName in $lumoswitchEnvironmentNames) {
      [Environment]::SetEnvironmentVariable($lumoswitchName, $lumoswitchPreviousEnvironment[$lumoswitchName], 'Process')
    }
    Remove-Item -LiteralPath $lumoswitchConfig -Force -ErrorAction SilentlyContinue
  }
  if ($lumoswitchExitCode -ne 0) { throw 'crush exited with code ' + $lumoswitchExitCode }
}

永久使用(Windows)

该命令会备份已有的 Lumoswitch 专用文件,并为配置和启动器收紧当前用户的访问权限。

& {
  $ErrorActionPreference = 'Stop'
  $lumoswitchRoot = Join-Path $env:LOCALAPPDATA 'Lumoswitch\agents\crush'
  $lumoswitchLauncher = Join-Path $env:LOCALAPPDATA 'Lumoswitch\bin\lumoswitch-crush.ps1'
  $lumoswitchBackupSuffix = (Get-Date -Format 'yyyyMMdd-HHmmss') + '-' + $PID

  function Protect-LumoswitchFile([string] $Path) {
    $lumoswitchSid = [Security.Principal.WindowsIdentity]::GetCurrent().User.Value
    & icacls.exe $Path '/inheritance:r' '/grant:r' ('*' + $lumoswitchSid + ':(F)') '*S-1-5-18:(F)' '*S-1-5-32-544:(F)' | Out-Null
    if ($LASTEXITCODE -ne 0) { throw "Could not restrict access to $Path" }
  }

  function Install-LumoswitchFile([string] $Path, [string] $Content) {
    [IO.Directory]::CreateDirectory((Split-Path -Parent $Path)) | Out-Null
    if (Test-Path -LiteralPath $Path) {
      $lumoswitchItem = Get-Item -LiteralPath $Path -Force
      if ($lumoswitchItem.PSIsContainer -or ($lumoswitchItem.Attributes -band [IO.FileAttributes]::ReparsePoint)) {
        throw "Lumoswitch refused to replace a directory or link: $Path"
      }
      $lumoswitchBackup = $Path + '.backup.' + $lumoswitchBackupSuffix
      Copy-Item -LiteralPath $Path -Destination $lumoswitchBackup
      Protect-LumoswitchFile $lumoswitchBackup
    }
    $lumoswitchTemporary = $Path + '.' + [Guid]::NewGuid().ToString('N') + '.tmp'
    try {
      [IO.File]::WriteAllText($lumoswitchTemporary, $Content, [Text.UTF8Encoding]::new($false))
      Move-Item -LiteralPath $lumoswitchTemporary -Destination $Path -Force
      Protect-LumoswitchFile $Path
    } finally {
      Remove-Item -LiteralPath $lumoswitchTemporary -Force -ErrorAction SilentlyContinue
    }
  }

  [IO.Directory]::CreateDirectory($lumoswitchRoot) | Out-Null
  $lumoswitchCrushConfig = Join-Path $lumoswitchRoot 'crushrc'
  $lumoswitchConfigContent = @'
{{crush_config_text}}
'@
  Install-LumoswitchFile $lumoswitchCrushConfig $lumoswitchConfigContent

  $lumoswitchEnvironment = [ordered]@{}
  $lumoswitchEnvironment['CRUSH_GLOBAL_CONFIG'] = (Join-Path $lumoswitchRoot 'crushrc')
  $lumoswitchEnvironment['LUMOSWITCH_CRUSH_API_KEY'] = '{{access_key}}'
  $lumoswitchEnvironment['LUMOSWITCH_CRUSH_API_BASE_URL'] = '{{api_base_url}}'
  $lumoswitchEnvironment['LUMOSWITCH_CRUSH_MODEL'] = '{{model}}'
  foreach ($lumoswitchEntry in $lumoswitchEnvironment.GetEnumerator()) {
    [Environment]::SetEnvironmentVariable($lumoswitchEntry.Key, $lumoswitchEntry.Value, 'User')
    [Environment]::SetEnvironmentVariable($lumoswitchEntry.Key, $lumoswitchEntry.Value, 'Process')
  }

  $lumoswitchLauncherContent = @'
param([Parameter(ValueFromRemainingArguments = $true)][string[]] $AgentArgs)
$ErrorActionPreference = 'Stop'
$lumoswitchRoot = Join-Path $env:LOCALAPPDATA 'Lumoswitch\agents\crush'
$lumoswitchLauncher = Join-Path $env:LOCALAPPDATA 'Lumoswitch\bin\lumoswitch-crush.ps1'

function Remove-LumoswitchFile([string] $Path) {
  if (-not (Test-Path -LiteralPath $Path)) { return }
  $lumoswitchItem = Get-Item -LiteralPath $Path -Force
  if ($lumoswitchItem.PSIsContainer -or ($lumoswitchItem.Attributes -band [IO.FileAttributes]::ReparsePoint)) {
    throw "Lumoswitch refused to remove a directory or link: $Path"
  }
  Remove-Item -LiteralPath $Path -Force
}

if ($AgentArgs.Count -gt 0 -and $AgentArgs[0] -eq '--lumoswitch-clean') {
  foreach ($lumoswitchName in @('CRUSH_GLOBAL_CONFIG', 'LUMOSWITCH_CRUSH_API_KEY', 'LUMOSWITCH_CRUSH_API_BASE_URL', 'LUMOSWITCH_CRUSH_MODEL')) {
    [Environment]::SetEnvironmentVariable($lumoswitchName, $null, 'User')
    [Environment]::SetEnvironmentVariable($lumoswitchName, $null, 'Process')
  }
  if (Test-Path -LiteralPath $lumoswitchRoot -PathType Container) {
    $lumoswitchRootItem = Get-Item -LiteralPath $lumoswitchRoot -Force
    if ($lumoswitchRootItem.Attributes -band [IO.FileAttributes]::ReparsePoint) { throw 'Lumoswitch refused to clean through a linked directory.' }
    foreach ($lumoswitchFile in @(Get-ChildItem -LiteralPath $lumoswitchRoot -File -Recurse -Force)) { Remove-LumoswitchFile $lumoswitchFile.FullName }
    foreach ($lumoswitchDirectory in @(Get-ChildItem -LiteralPath $lumoswitchRoot -Directory -Recurse -Force | Sort-Object FullName -Descending)) {
      if ($null -eq (Get-ChildItem -LiteralPath $lumoswitchDirectory.FullName -Force | Select-Object -First 1)) { Remove-Item -LiteralPath $lumoswitchDirectory.FullName -Force }
    }
    if ($null -eq (Get-ChildItem -LiteralPath $lumoswitchRoot -Force | Select-Object -First 1)) { Remove-Item -LiteralPath $lumoswitchRoot -Force }
  }
  $lumoswitchBin = Split-Path -Parent $lumoswitchLauncher
  if (Test-Path -LiteralPath $lumoswitchBin -PathType Container) {
    foreach ($lumoswitchBackup in @(Get-ChildItem -LiteralPath $lumoswitchBin -Filter 'lumoswitch-crush.ps1.backup.*' -File -Force)) { Remove-LumoswitchFile $lumoswitchBackup.FullName }
  }
  Remove-LumoswitchFile $lumoswitchLauncher
  Write-Host 'Lumoswitch native setup and optional launcher removed. Open a new terminal to refresh the environment.'
  exit 0
}

$lumoswitchEnvironment = [ordered]@{}
$lumoswitchEnvironment['CRUSH_GLOBAL_CONFIG'] = (Join-Path $lumoswitchRoot 'crushrc')
$lumoswitchEnvironment['LUMOSWITCH_CRUSH_API_KEY'] = '{{access_key}}'
$lumoswitchEnvironment['LUMOSWITCH_CRUSH_API_BASE_URL'] = '{{api_base_url}}'
$lumoswitchEnvironment['LUMOSWITCH_CRUSH_MODEL'] = '{{model}}'
foreach ($lumoswitchEntry in $lumoswitchEnvironment.GetEnumerator()) {
  [Environment]::SetEnvironmentVariable($lumoswitchEntry.Key, $lumoswitchEntry.Value, 'Process')
}
$lumoswitchExecutable = Get-Command 'crush.cmd' -CommandType Application -ErrorAction SilentlyContinue
if ($null -eq $lumoswitchExecutable) { $lumoswitchExecutable = Get-Command 'crush.exe' -CommandType Application -ErrorAction SilentlyContinue }
if ($null -eq $lumoswitchExecutable) { $lumoswitchExecutable = Get-Command 'crush' -CommandType Application -ErrorAction Stop }
$lumoswitchArguments = @()
& $lumoswitchExecutable.Path @lumoswitchArguments @AgentArgs
if ($null -ne $LASTEXITCODE) { exit $LASTEXITCODE }
'@
  Install-LumoswitchFile $lumoswitchLauncher $lumoswitchLauncherContent
  Write-Host 'Native Lumoswitch setup saved. Future command: crush'
  Write-Host 'Optional maintenance launcher:' $lumoswitchLauncher
  $lumoswitchExecutable = Get-Command 'crush.cmd' -CommandType Application -ErrorAction SilentlyContinue
  if ($null -eq $lumoswitchExecutable) { $lumoswitchExecutable = Get-Command 'crush.exe' -CommandType Application -ErrorAction SilentlyContinue }
  if ($null -eq $lumoswitchExecutable) { $lumoswitchExecutable = Get-Command 'crush' -CommandType Application -ErrorAction Stop }
  $lumoswitchArguments = @()
  & $lumoswitchExecutable.Path @lumoswitchArguments
  if ($null -ne $LASTEXITCODE -and $LASTEXITCODE -ne 0) { throw 'crush exited with code ' + $LASTEXITCODE }
}

导入会写入 Agent 支持的持久化配置,并直接启动 crush。保存的 Lumoswitch 维护脚本不是启动 Agent 的必需入口;需要恢复或移除此接入时,运行它并追加 --lumoswitch-clean

清除 Lumoswitch 接入

Windows PowerShell

先退出该 Agent 的所有 Lumoswitch 会话,再运行下面的命令。可选维护启动器会删除受管原生配置、恢复已保留的共享文件、清除 Lumoswitch 用户环境变量,并移除自身。

& {
  $lumoswitchLauncher = Join-Path $env:LOCALAPPDATA 'Lumoswitch\bin\lumoswitch-crush.ps1'
  if (-not (Test-Path -LiteralPath $lumoswitchLauncher -PathType Leaf)) {
    throw 'The optional Lumoswitch maintenance launcher is missing. Run persistent import again before cleanup.'
  }
  & powershell.exe -NoLogo -NoProfile -ExecutionPolicy Bypass -File $lumoswitchLauncher --lumoswitch-clean
}

macOS / Linux

"$HOME/.local/bin/lumoswitch-crush" --lumoswitch-clean

命令不会删除 ~/.config/crush/crushrc、项目 crushrc、会话数据或其他提供方。如果你曾手动把 provider add lumoswitch 合并到共享配置,还需要只移除该 provider 与对应 model 命令,不能删除整个配置文件。

Desktop 与 IDE 边界

Crush 官方只提供终端 Agent。它可以发送系统桌面通知,但没有需要另行配置 Lumoswitch 的 Desktop 应用或 IDE 面板。在 IDE 内置终端运行上面的命令,仍然只是同一个 Crush CLI 进程,因此临时与永久行为不变。

验证与排查

  • Lumoswitch 应使用 openai-compat,而不是面向 OpenAI 原生行为的 openai
  • crushrc 是可信代码;不要在未审查的仓库配置中执行 Crush。
  • 先测试普通回复,再验证工具调用和长上下文。可用 crush logs --follow 查看日志。

参考:Crush 官方仓库与配置Custom Providers配置 Schema。最近核验:2026-08-27。

维护者发布字段
  • 平台 ID:crush
  • 展示名称:Crush CLI
  • 下游协议:openai-compatible
  • commandTemplate:复制「仅本次启动」代码框的完整内容
  • 永久策略:native
  • persistentCommandTemplate:复制「永久使用」代码框的完整内容
  • futureCommandcrush
  • 展示顺序:120
  • 最近核验:2026-08-27

On this page