Add @deepseek-ai/dsh-tmux-context: an opt-in per-turn context plugin that
reads which tmux session/window/pane this agent process runs in (plus the
window layout tree) via the ctx.bash seam, and injects it as one durable,
source-attributed user/message when the location changes.
- Pull on the first step of each turn; no tmux hook or background process.
- Detect a real pane by tty, not $TMUX_PANE alone: a terminal launched from
a tmux shell inherits $TMUX/$TMUX_PANE from that ancestor, so the command
also matches the pane's #{pane_tty} against this process's controlling
terminal and emits fields only on a match.
- No-op outside a real pane, without a bash executor, or on a malformed
reading.
- Own location and layout only: no pane sizes, no sibling-pane scraping.
- Unit tests at 100% per-file coverage, plus a keyless Loader e2e with a
mock bash provider so it replays without tmux.
- Agent Note: 2026-07-27-tmux-location-context.
23 lines
899 B
TypeScript
23 lines
899 B
TypeScript
import type { Context } from 'cordis'
|
|
import { LlmAdapter, type StreamChunk } from '@deepseek-ai/dsh-llm'
|
|
|
|
/** Deterministic one-step adapter for the tmux-context Loader fixture. */
|
|
class TmuxContextMockAdapter extends LlmAdapter {
|
|
async * stream(): AsyncIterable<StreamChunk> {
|
|
const text = 'tmux context sampled'
|
|
yield { type: 'block-start', index: 0, blockType: 'text' }
|
|
yield { type: 'text-delta', index: 0, text }
|
|
yield { type: 'block-end', index: 0, block: { type: 'text', text } }
|
|
yield { type: 'usage', usage: { inputTokens: 1, outputTokens: 1 } }
|
|
yield { type: 'finish', reason: { kind: 'stop' } }
|
|
}
|
|
}
|
|
|
|
export const name = 'tmux-context-mock-llm'
|
|
export const inject = ['llm']
|
|
|
|
/** Register the test-only `tmux-context-mock` adapter. */
|
|
export function apply(ctx: Context): void {
|
|
ctx.llm.registerAdapter(['tmux-context-mock'], new TmuxContextMockAdapter())
|
|
}
|