MCPcopy Index your code
hub / github.com/dexhorthy/shannon

github.com/dexhorthy/shannon @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
128 symbols 351 edges 10 files 0 documented · 0%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Shannon

Shannon is a CLI and SDK wrapper around the interactive Claude Code CLI. It runs a real claude session inside tmux, sends a prompt, and emits stream JSON.

flowchart LR
    User([Your code / shell])
    subgraph Shannon["@dexh/shannon"]
      SDK["SDK

query()"]
      CLI["CLI

shannon"]
    end
    subgraph Host["Local host"]
      Tmux["tmux session"]
      Claude["claude (interactive)"]
      Transcript[("~/.claude/projects

transcript JSONL")]
    end
    Anthropic[["Anthropic API"]]

    User -->|"prompt"| SDK
    User -->|"prompt"| CLI
    SDK -->|"spawns"| CLI
    CLI -->|"sends keys"| Tmux
    Tmux --> Claude
    Claude <-->|"HTTPS"| Anthropic
    Claude -->|"appends"| Transcript
    CLI -->|"tails"| Transcript
    CLI -->|"stream-json / json / text"| User

The dashed-style boundary: Shannon never calls the Anthropic API directly — it drives a real claude session and reads its on-disk transcript. claude -p is not used internally.

Requirements

  • Bun
  • claude on PATH
  • tmux on PATH
  • A working Claude Code login

CLI

Run without installing:

npx @dexh/shannon -p "Reply with exactly: hello" --output-format=stream-json --verbose

Or install globally:

npm install -g @dexh/shannon
shannon -p "Reply with exactly: hello" --output-format=stream-json --verbose

Output formats: stream-json (JSONL), json (single array), text (final result text).

SDK

npm install @dexh/shannon
import { query } from "@dexh/shannon";

for await (const message of query({
  prompt: "Reply with exactly: hello",
  options: { outputFormat: "stream-json", verbose: true },
})) {
  console.log(JSON.stringify(message));
}

Async input is also accepted for finite user-message streams:

import { query, type ShannonUserMessage } from "@dexh/shannon";

async function* messages(): AsyncIterable<ShannonUserMessage> {
  yield {
    type: "user",
    message: {
      role: "user",
      content: [{ type: "text", text: "Reply with exactly: hello" }],
    },
    parent_tool_use_id: null,
    session_id: "",
  };
}

for await (const message of query({ prompt: messages() })) {
  console.log(JSON.stringify(message));
}

Pass an AbortController in options to terminate the underlying Shannon subprocess.

Agent SDK facade

@dexh/shannon-agent-sdk is a Claude Agent SDK-compatible facade that re-exports Shannon's SDK surface. Full parity is a work in progress (see GOAL_PROGRESS.md).

npm install @dexh/shannon-agent-sdk
import { query } from "@dexh/shannon-agent-sdk";

for await (const message of query({
  prompt: "Reply with exactly: hello",
  options: { outputFormat: "stream-json", verbose: true },
})) {
  console.log(JSON.stringify(message));
}

Development

bun install
bun test
bun run typecheck
bun ./index.ts -p "hello" --output-format=stream-json --verbose

Core symbols most depended-on inside this repo

addString
called by 18
index.ts
addString
called by 15
src/sdk.ts
addBoolean
called by 14
index.ts
addBoolean
called by 13
src/sdk.ts
sessionKey
called by 10
src/sdk.ts
numberFromUsage
called by 9
index.ts
parseArgs
called by 8
index.ts
runCommand
called by 8
index.ts

Shape

Function 128

Languages

TypeScript100%

Modules by API surface

index.ts65 symbols
src/sdk.ts45 symbols
src/test/learning/shannon-sdk.test.ts9 symbols
src/test/learning/shannon-live.test.ts6 symbols
src/test/learning/claude-p-fixture.test.ts3 symbols

For agents

$ claude mcp add shannon \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact