Shell IntegrationSAFE
Use sidecar next to CLI agents for diffs, file trees, conversation history, and task management with td
Overview
Use sidecar next to CLI agents for diffs, file trees, conversation history, and task management with td
a69114b893d1OBSERVED · 2026-10-10Host compatibility
What the documentation claims. We have not run a compatibility test.
| Host | Status | Notes |
|---|---|---|
| cursor | mentioned |
What it tells the agent
The instruction file, verbatim from the audited commit — this is the text the model reads, and the surface the audit's instruction layer examines. Quoted here so you can judge it without cloning anything.
---
name: shell-integration
description: >
Interactive shell/TTY integration with tmux session management, shell command
execution, control-mode output capture with polling fallback, native cursor
rendering, lazy scrollback, selection, paste handling, and inline editing.
Use when working on shell integration, tmux features, command execution, or
interactive mode.
user-invocable: false
---
# Shell Integration
Sidecar's interactive shell allows users to type directly into tmux sessions
from within the TUI. Tmux remains the PTY backend. Sidecar renders ordered
control-mode bytes through the shared `tty.Model`, whose VT behavior is behind
the `screenmodel` adapter rather than implemented in plugin code.
## Package Structure
```
internal/tty/ # Shared tmux terminal abstraction
tty.go # Core Model and State types
keymap.go # Bubble Tea -> tmux key translation
messages.go # Owner/target/generation-scoped messages
session.go # tmux operations (send-keys, capture-pane, resize)
scheduler.go # Keyed fallback-poll generation ownership
control_*.go # Session-keyed tmux -C transport and manager
capture_range.go # Atomic bounded history capture
cursor.go # Cursor positioning helpers
paste.go # Paste handling (clipboard, bracketed paste)
terminal_mode.go # Capture-fallback mode recovery
output_buffer.go # Absolute, bounded live/history buffer
editor_session.go # Shared inline-editor tmux lifecycle
internal/plugins/workspace/
interactive.go # Workspace-specific interactive mode logic
interactive_selection.go # Text selection in interactive mode
terminal_viewport.go # Pure shared terminal viewport renderer
terminal_control.go # Workspace target/layout policy for tty.Model
terminal_history.go # Lazy absolute scrollback loading
terminal_search.go # Loaded-history search
terminal_links.go # Safe URL/path detection and activation
native_terminal.go # Native cursor and contextual mouse mode
view_preview.go # Agent/shell preview composition
mouse.go # Scroll handling
types.go # InteractiveState type
internal/plugins/filebrowser/
inline_edit.go # Inline editor mode using tty.Model
handlers.go # Message handling for inline edit
```
## Data Flow
```
User Keypress -> handleInteractiveKeys() -> tty.MapKeyToTmux() -> tmux send-keys
Pane output -> tmux -C ordered %output bytes
-> session-pooled control actor
-> seeded screenmodel adapter
-> adaptive per-feed presentation publication
-> owner/target/generation-scoped Tea message
-> OutputBuffer + cursor/modes/history
-> pure terminal viewport + native Bubble Tea cursor
Open/resync/history -> bounded capture seed/range
Control unavailable/dead -> one scoped capture-poll fallback + clean reseed
```
## Core Abstractions
### tty.Model
Embeddable component for interactive tmux functionality:
```go
type Model struct {
Config Config // Exit key, copy/paste keys, scrollback lines
State *State // Current interactive state
Width int
Height int
OnExit func() tea.Cmd
OnAttach func() tea.Cmd
}
// Usage:
p.inlineEditor = tty.New(&tty.Config{
ExitKey: "ctrl+\\",
ScrollbackLines: 600,
})
cmd := p.inlineEditor.Enter(sessionName, paneID)
```
### tty.State
```go
type State struct {
Active bool
TargetPane string // tmux pane ID (e.g., "%12")
TargetSession string
LastKeyTime time.Time // Input timing and fallback polling decay
CursorRow, CursorCol int
CursorVisible bool
PaneHeight, PaneWidth int
BracketedPasteEnabled bool
MouseReportingEnabled bool
OutputBuf *OutputBuffer
PollGeneration int // For invalidating stale fallback polls
}
```
### tty.OutputBuffer
Thread-safe bounded buffer with hash-based change detection:
```go
func (b *OutputBuffer) Update(content string) bool {
rawHash := maphash.String(seed, content)
if rawHash == b.lastRawHash { return false } // Skip ALL processing
content = mouseEscapeRegex.ReplaceAllString(content, "")
b.lines = strings.Split(content, "\n")
return true
}
func (b *OutputBuffer) LinesRange(start, end int) []string
```
## Key Mapping (`keymap.go`)
```go
func MapKeyToTmux(msg tea.KeyPressMsg) (key string, useLiteral bool) {
if msg.Mod.Contains(tea.ModCtrl) && msg.Code >= 'a' && msg.Code <= 'z' {
return "C-" + string(msg.Code), false
}
switch msg.Code {
case tea.KeyEnter: return "Enter", false
case tea.KeyBackspace: return "BSpace", false
case tea.KeyTab: return "Tab", false
case tea.KeyUp: return "Up", false
}
if msg.Text != "" {
return msg.Text, true // Literal mode
}
return "", true
}
```
Modified keys use CSI sequences:
```go
case "shift+up": return "\x1b[1;2A", true
case "ctrl+up": return "\x1b[1;5A", true
case "alt+up": return "\x1b[1;3A", true
case "shift+tab": return "\x1b[Z", true
```
For printable characters, `tmux send-keys -l` prevents interpretation.
## Capture fallback and semantic observation
```go
const (
PollingDecayFast = 50ms // During active typing
PollingDecayMedium = 200ms // After 2s inactivity
PollingDecaySlow = 250ms // After 10s inactivity
KeystrokeDebounce = 20ms // Delay after keystroke
)
```
Control-mode bytes are the ordinary presentation source for every visible
terminal surface. Adaptive capture polling exists only until the first seeded
frame and after control/model failure. WorkspTrust audit
SAFEgrade B · trust 89/100 Nothing in the source contradicts what it says it does. Grade A is reserved for packages that have also passed the behavioural sandbox.
| Layer | What it checks | Result |
|---|---|---|
| L0 | Provenance & inventory | WARN |
| L1 | Static analysis of the code | NA |
| L2 | Instruction surface (what it tells the agent) | PASS |
| L3 | Class-specific surface | PASS |
| L4 | Behavioural (sandbox) | SKIPPED |
What the source does
- Filesystem
- none-observed
- Network
- none-observed
- Shell
- none-observed
- Dependencies
- pinned
- Secrets in source
- none-found
Findings (2)
.codex/skills
GEMINI.md
Gates applied: no_behavioural_pass.
a69114b893d1full audit observations/trust-audit/skill/marcus__shell-integration.json · Report an issue / request a re-scanAudit history
Every audit this skill has had.
| Date | Source | Verdict | Grade | Score | Change |
|---|---|---|---|---|---|
| 2026-10-10 | a69114b893d1 | SAFE | B | 89 | first audit |
Questions
What does the Shell Integration skill do?
Use sidecar next to CLI agents for diffs, file trees, conversation history, and task management with td
Is Shell Integration safe to install?
The audit found nothing in the source that contradicts what it says it does, and graded it B (89/100). Grade A is held back for packages that have also passed a sandboxed behavioural run, which is why a clean skill reads B.
What can Shell Integration access on my machine?
The audit observed no filesystem, network or shell use at all in its source.
Which assistants does Shell Integration work with?
Its documentation mentions cursor. That is what the text claims, not a compatibility test we ran.
How current is this page?
The grade is for one exact copy of the source (a69114b893d1), read on 2026-10-10. The repository is watched, and a new audit runs when it changes — this is the first audit.