Skip to main content

cosh-shell Overview

cosh-shell is the AI-enhanced interactive terminal of cosh-ng. It layers AI analysis capabilities, tool approval controls, and inline card rendering on top of a native bash/zsh PTY, providing users with a secure and observable Agent interaction experience.

Positioning

cosh-shell is the user-facing frontend layer:

  • Manages the PTY host (bash/zsh subprocess)
  • Connects to backends via AI adapters (default: cosh-core)
  • Renders approval cards and AI analysis results
  • Implements tool approval control protocol

Run Modes

# Default startup (uses configured adapter and shell)
cosh-shell

# Explicitly specify adapter (positional argument)
cosh-shell raw cosh-core
cosh-shell raw claude
cosh-shell raw qwen

# Specify underlying shell
cosh-shell --shell zsh
cosh-shell raw co --shell bash

# Pass-through mode: execute single command then exit
cosh-shell -c 'ls -la'
cosh-shell -- git status

# Login shell mode
cosh-shell --login
cosh-shell -l

# Isolated mode (skip user rcfile)
cosh-shell --isolated

Supported AI Adapters

AdapterBackendDescription
cosh-corecosh-core processDefault adapter, full control protocol
claudeClaude Code CLIClaude adapter
qwenQwen Code CLIQwen adapter
fakeMockFor development testing, no backend required

Adapter Capabilities

CapabilityDescription
text_streamText streaming output
thinking_streamThinking process streaming output
session_resumeSession resume
tool_intentTool call intent awareness
user_questionAsk user questions
cancellableSupports cancelling running requests
control_protocolFull control protocol support

Core Features

FeatureDescriptionDocumentation
PTY InteractionNative bash/zsh terminalinteractive-mode.md
AI AnalysisStreaming command analysisai-analysis.md
Tool ApprovalVisual approval cardsapproval.md

Architecture Overview

┌────────────────────────────────────────────┐
│ cosh-shell │
│ ┌───────────┐ ┌──────────┐ ┌─────────┐ │
│ │ PTY Host │ │ Adapter │ │ UI │ │
│ │ (bash/zsh)│ │(cosh-core│ │(ratatui)│ │
│ └───────────┘ │/claude..)│ └─────────┘ │
│ ┌───────────┐ └──────────┘ ┌─────────┐ │
│ │ Hooks │ ┌──────────┐ │Approval │ │
│ │ Engine │ │ Tools │ │ Broker │ │
│ └───────────┘ └──────────┘ └─────────┘ │
└────────────────────────────────────────────┘
│ │
▼ ▼
bash/zsh PTY cosh-core process

Configuration

cosh-shell specific configuration is in the [ui] and [shell] sections of ~/.copilot-shell/config.toml. See Configuration for details.

Project Trust

cosh-shell maintains project-level trust storage. On first launch in a new project directory, it prompts the user to confirm whether to trust the project. Trust status determines:

  • Whether to load .cosh/hooks from the project directory
  • Whether to apply project-level configuration overrides