[Feature] Token-efficient AI-to-AI orchestration output modes

## Problem

The Genie CLI was originally designed for human consumption with rich, verbose outputs. It's now used for AI-to-AI orchestration (main Genie orchestrating subagent neurons), but the verbose output format causes token explosion.

**Current cost:**
- Single session view: ~16k tokens (804 lines)
- Orchestrating 3-4 subagents: 36-48k tokens just for monitoring (18-24% of budget!)
- Forces premature context trimming
- Limits complex multi-agent orchestration patterns

## Solution: Architectural Simplification

Replace the current 4-layer rendering pipeline with a direct 2-layer markdown pipeline.

### Current Architecture (4 layers of overhead)

```
1. Executors emit JSONL events
   ↓ (stored in log files)
2. Log viewers parse JSONL → ChatMessage[]
   ↓ (.genie/cli/src/executors/*-log-viewer.ts)
3. View builders create ViewEnvelope tree
   ↓ (.genie/cli/src/views/*.ts)
4. Ink renderer → React components → terminal ANSI
   ↓ (.genie/cli/src/view/render.tsx - 560 lines)
   Terminal output (verbose, 16k tokens)
```

**Layers 3-4 are heavyweight overhead:**
- ViewEnvelope/ViewNode tree construction
- Ink (React for CLIs) rendering with component hierarchy
- Complex ANSI escape code generation
- No token efficiency consideration

### Proposed Architecture (2 layers, clean)

```
1. Executors emit JSONL events
   ↓ (stored in log files)  
2. Log viewers parse JSONL → ChatMessage[]
   ↓ (.genie/cli/src/executors/transcript-utils.ts)
   [NEW] Markdown formatter → compact markdown
   ↓
   Output (markdown by default, optional json/html)
```

**Key insight:** We already have structured `ChatMessage[]` data with role, title, and body. Just need to format it as compact markdown instead of building a React component tree.

### Why Markdown-Only

- ✅ Works for both humans and AI
- ✅ Can be rendered in UI later if needed
- ✅ Simpler implementation (no mode detection)
- ✅ Consistent format across all consumers
- ✅ Future-proof for rendering
- ✅ 96-98% token reduction

### Three Output Modes

1. **'final'** (completed tasks) → Only last message (mini-report), no wrapper
2. **'recent'** (in-progress, default) → Latest 5 messages, compact markdown
3. **'overview'** (full:true) → Session metadata + checkpoints + state

**Token targets:**
- Completed tasks: 16k → 0.5k (96% reduction)
- In-progress monitoring: 16k → 0.3k (98% reduction)
- Session overviews: 16k → 0.4k (97% reduction)

## Implementation Plan

### Phase 1: Markdown Formatter (NEW)
**Create:** `.genie/cli/src/lib/markdown-formatter.ts` (~150 lines)

**Functions:**
- `formatTranscriptMarkdown(messages: ChatMessage[], meta, mode): string`
  - Formats session transcripts with 3 modes
  - Includes metadata (tokens, tool calls, model)
  - Token budget limits (max 500 tokens per response)
- `formatSessionListMarkdown(sessions): string`
  - Formats session overview tables
  - Compact single-line per session
- `formatMetadata(metrics): string`
  - Formats header metadata compactly

**No changes to:**
- JSONL event parsing (transcript-utils.ts)
- ChatMessage[] structure
- Executor implementations

### Phase 2: Replace View Layer
**Modify:**
- `.genie/cli/src/commands/view.ts` - Use markdown formatter instead of buildChatView
- `.genie/cli/src/commands/list.ts` - Use markdown formatter instead of buildRunsOverviewView

**Keep:**
- JSON output mode (already exists at render.tsx:45-49)
- Optional HTML output (future enhancement)

### Phase 3: Remove Ink Rendering
**Delete:**
- `.genie/cli/src/view/render.tsx` (560 lines of Ink/React rendering)
- `.genie/cli/src/views/chat.ts` (buildChatView, ViewEnvelope construction)
- `.genie/cli/src/views/runs.ts` (buildRunsOverviewView)
- ViewEnvelope/ViewNode type definitions

**Keep:**
- `.genie/cli/src/lib/executor-prompt.tsx` (interactive executor selection - still uses Ink)

### Phase 4: MCP Integration
**Modify:**
- `.genie/cli/src/cli-core/handlers/view.ts` (or wherever MCP view is handled)
- MCP server returns compact markdown directly (currently wraps in ViewEnvelope)
- Enables efficient AI-to-AI orchestration

## Files Affected

**Remove entirely:**
- `.genie/cli/src/view/render.tsx` (Ink rendering, 560 lines)
- `.genie/cli/src/views/chat.ts` (ViewEnvelope builders)
- `.genie/cli/src/views/runs.ts` (session list builders)
- ViewEnvelope/ViewNode abstractions (view-model.ts types)

**Add new:**
- `.genie/cli/src/lib/markdown-formatter.ts` (~150 lines)

**Modify:**
- Command handlers (view, list) to use markdown formatter
- MCP response formatting

**Keep unchanged:**
- `.genie/cli/src/executors/transcript-utils.ts` (JSONL → ChatMessage[] parsing)
- `.genie/cli/src/executors/claude-log-viewer.ts` (conversation parsing)
- `.genie/cli/src/executors/codex-log-viewer.ts` (metrics extraction)
- `.genie/cli/src/lib/executor-prompt.tsx` (interactive selector still uses Ink)
- ChatMessage[] structure
- Session storage

**Current Ink usage (only 2 files):**
- `.genie/cli/src/view/render.tsx` ← DELETE
- `.genie/cli/src/lib/executor-prompt.tsx` ← KEEP

## Success Metrics

- ✅ Token savings: 96-98% for AI orchestration
- ✅ Overall orchestration cost: 36k → 1.5k tokens (for 3 subagents)
- ✅ Budget freed: ~17% for actual reasoning
- ✅ Information loss: <5%
- ✅ Backward compatible: existing workflows unchanged
- ✅ Simpler codebase: 2 layers instead of 4
- ✅ Faster rendering: no React/Ink overhead

## Use Cases

1. **Orchestrator monitoring** - Check subagent progress (400 tokens vs 16k)
2. **Completed task check** - Get final mini-report only (500 tokens vs 12k)
3. **Parallel orchestration** - Monitor 10+ subagents within budget (currently limited to 3-4)

## Migration Strategy

**Backward compatible:** Existing ChatMessage[] structure unchanged, so all parsing logic remains valid.

**Output format:** Markdown by default (simpler). Optional JSON/HTML modes for structured data or future UI needs.

**No breaking changes:** Commands work the same, just output format is more compact.

## Context

Discovered during natural-routing-skills wish execution when orchestrator neuron session views consumed excessive tokens. This blocks efficient multi-agent orchestration and limits Genie's ability to use specialist neurons effectively.


Labels: type:enhancement, priority:high
State: closed