Jiki Architectural Refactor & Documentation Plan
Plans a six-phase refactor of Jiki into modular packages with defined interfaces, plus a documentation overhaul and release strategy.
What this file does
Plans a six-phase refactor of Jiki into modular packages with defined interfaces, plus a documentation overhaul and release strategy.
When to use it
- Planning a modular refactor of an existing MCP client library
- Structuring documentation improvements for a developer tool
- Defining interfaces for transport, tools, prompts, and resources
- Organizing a phased release with testing and community support
Assumes this stack
Jiki Architectural Refactor & Documentation Plan
Vision & Goals
- Provide a lean, modular orchestrator layer ("under the skin") that can manage clients, servers, tools, prompts, resources, sampling and transports without unnecessary bloat.
- Ensure full interoperability and extensibility via well‑defined interfaces and pluggable components.
- Keep core code minimal while enabling advanced customization through optional modules.
- Create comprehensive, code-first documentation that makes Jiki accessible to new users while providing depth for advanced use cases.
- Build community around Jiki by providing clear pathways for adoption, customization, and contribution.
Phase 1: Audit & Documentation
- Inventory current codebase: list all modules, their responsibilities, and dependencies.
- Identify cross‑cutting concerns (e.g., logging, tracing, serialization, error handling).
- Document existing workflows: tool discovery, execution flow, prompt generation, resource access.
- Write up desired component boundaries and responsibilities.
Phase 2: Define Core Interfaces & Contracts
- Transport: define
ITransportprotocol for stdio, SSE, HTTP, WebSockets, etc. - ToolClient: specify abstract methods for discovering, validating, and invoking tools.
- PromptBuilder: create contract for constructing initial context, tool‑call wrappers, and result‑injection templates.
- ResourceManager: interface for listing, reading, and subscribing to resources.
- SamplerConfig: structure for passing sampling parameters (temperature, top_p, max_tokens) to LLM calls.
- RootManager: API for snapshotting conversation roots and resuming from saved contexts.
- Serializer: standard fallback JSON serializer with hooks for custom types.
Phase 3: Modularize & Refactor
- Move existing implementations into discrete packages:
jiki.transportsjiki.toolsjiki.promptsjiki.resourcesjiki.samplingjiki.rootsjiki.serialization
- Refactor
EnhancedMCPClientto implementToolClientandTransportseparately. - Refactor
JikiOrchestratorto depend only on interfaces and compose pluggable modules. - Replace hardcoded imports with dynamic registration and dependency injection.
Phase 4: Validation & Testing
- Write unit tests for each core interface and module.
- Implement end‑to‑end scenarios: tool calls, resource reads, sampled responses.
- Add integration tests using a mock MCP server (stdio and SSE).
- Validate JSON‑RPC error handling and edge cases.
Phase 5: Documentation Overhaul
5.1: Code-First Documentation
-
README.md: Restructure to focus on practical usage with copy-paste ready commands and examples
- Streamline introduction to 1-2 sentences
- Expand "Quick Start" with minimal but complete examples
- Add troubleshooting section
- Include "Next Steps" section with pathways to examples by use case
-
Command-Line Documentation:
- Create comprehensive CLI examples with expected outputs
- Provide cheat sheet with common patterns
- Include environment configuration guide
-
Code Examples:
- Create dedicated examples directory with complete, runnable scripts
- Add progressive examples from basic to advanced
- Include extensive comments explaining each step
5.2: Task-Based Guides
-
Getting Started Guide:
- Rewrite to be task-oriented
- Include installation, setup, first run steps
- Add screenshots and expected outputs
- Provide complete minimal working example
-
Use Case Tutorials:
- Calculator example tutorial
- Custom tools creation guide
- Web deployment walkthrough
- Conversation state management tutorial
- Integration with other frameworks
5.3: API Reference
-
Core Components:
- Document main factory function (
Jiki()) - Document JikiOrchestrator class
- Document JikiClient and BaseMCPClient
- Document IPromptBuilder interface
- Document main factory function (
-
Tools Documentation:
- Explain tool schema format
- Provide examples of valid tool definitions
- Include step-by-step guide for creating tools
5.4: Visual Documentation
- Diagrams:
- Create architecture overview diagram
- Add sequence diagram for tool call workflow
- Develop component relationship diagram
- Include data flow visualization
5.5: Community Support
-
Contributing Guide:
- Create clear contribution guidelines
- Document development setup
- Add code style and PR process documentation
-
Showcase:
- Highlight community projects
- Collect use cases and testimonials
Phase 6: Release & Maintenance
- Bump version and tag release.
- Announce changes in changelog.
- Gather feedback and iterate on modular APIs.
- Plan roadmap items for additional MCP spec features (e.g., notifications, progress reports).
- Establish feedback channels for documentation improvements.
- Create regular documentation update schedule.
What's inside
6 phases, 7 interface definitions, 7 package names, 5 documentation subsections, 4 testing types, 6 release steps.
Change this for your project
- Replace
JikiOrchestratorwith your orchestrator class name - Replace
EnhancedMCPClientwith your client class name - Replace
jiki.transportsand other package names with your own module paths - Replace
Jiki()with your main factory function name
Where it goes
Save in docs/ or the repository root. Gives agents and new contributors a map of the codebase.
Worth borrowing
- Separating interface contracts from implementations for pluggability
- Using a phased approach with audit before refactoring
- Pairing code-first docs with task-based guides and diagrams
Related Documents
Design Document: BharatSeva AI
Describes a 10-agent AWS system that helps India's informal workers access government schemes via voice-first, serverless architecture.
OpenClaw Enterprise Transformation Plan
Transforms a single-user AI agent into a dual-mode platform supporting both viral open-source and Fortune 500 enterprise deployments through phased security, IAM, audit, multi-tenancy, and Kubernetes features.
Qwen Image and Edit: Open-sourcing and Local GGUF Generations with Lightning
Documents the Qwen-Image and Qwen-Image-Edit models, covering architecture, training, benchmarks, ComfyUI setup, and prompting techniques for local GGUF deployment.
University of Guelph Rocketry Club - Complete Tech Stack
Documents the full tech stack of a university rocketry club website with AI chatbot, member management, and project showcases.