~kris/9p

llm9p

ref: fa3820070ac0cb7b9932cdd5cbf1137886348f4e llm9p/internal d---------
fa382007 — pdfinn 7 months ago
feat(llm): Add extended thinking support and usage tracking

- Add thinking token control via /n/llm/thinking file (max/off/number)
- CLI backend sets MAX_THINKING_TOKENS env var for Claude CLI
- Default to max thinking (31999 tokens) for CLI backend
- Add /n/llm/usage file for token usage monitoring
- Add /n/llm/compact file for conversation summarization
- Extend Backend interface with ThinkingTokens, TotalTokens, ContextLimit, Compact
- Add true streaming support for CLI backend with line-by-line output
- Update example file with thinking documentation

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
4e8ff274 — pdfinn 7 months ago
feat: Add system prompt file for persistent persona configuration

- Add system file (read/write) to set system prompt
- System prompt persists across conversation resets
- Add SystemPrompt() and SetSystemPrompt() to Backend interface
- Update both API and CLI clients to support dedicated system prompt
- Update documentation and examples

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
5165f547 — pdfinn 7 months ago
refactor: Remove unnecessary --dangerously-skip-permissions flag

Testing confirmed that --dangerously-skip-permissions is NOT needed when:
1. --print mode is used (non-interactive)
2. Tools are disabled with --allowedTools ""

The CLI only prompts for permission when tools might take actions.
With tools disabled, it's purely text-in/text-out and no prompts occur.

Added explanatory comments documenting each CLI flag's purpose.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
054039ea — pdfinn 7 months ago
feat: Add CLI backend for Claude Max subscription

Add support for using Claude Code CLI as an alternative backend,
allowing users with Claude Max subscriptions to use llm9p without
API tokens.

New files:
- internal/llm/backend.go: Backend interface for swappable LLM providers
- internal/llm/cli_client.go: CLI-based client using `claude` command

Changes:
- Add -backend flag: 'api' (default) or 'cli'
- Refactor llmfs to use Backend interface instead of concrete Client
- Model names normalized for CLI (opus, sonnet, haiku)

Usage:
  ./llm9p -backend cli  # Uses Claude Max subscription
  ./llm9p -backend api  # Uses Anthropic API (default)

Limitations of CLI backend:
- Token counting not available (always 0)
- Streaming is simulated (full response as single chunk)
- Uses short model names (opus, sonnet, haiku)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
20386977 — pdfinn 7 months ago
feat: Add stream/ask file to trigger streaming requests

- Add StreamAskFile to start streaming via write to stream/ask
- Read chunks from stream/chunk as they arrive
- Update documentation with streaming examples and verified tests
- Update _example file with correct streaming instructions

Streaming workflow:
1. Write prompt to stream/ask to start streaming
2. Read from stream/chunk to get chunks (blocks until available)
3. EOF returned when stream completes

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
68199d2a — pdfinn 7 months ago
feat: Initial implementation of llm9p - LLM as 9P filesystem

Exposes Claude as a 9P filesystem, enabling interaction through
standard file operations:

- ask: write prompt, read response (shim pattern)
- model: read/write current model name
- temperature: read/write sampling temperature
- tokens: read-only token count from last response
- new: write to reset conversation
- context: read JSON history, write to add system message
- _example: usage documentation
- stream/chunk: blocking read for streaming responses

Includes:
- Full 9P2000 protocol implementation (stdlib only)
- Anthropic SDK integration with conversation state
- Streaming support

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>