https://github.com/bigmoon-dev/dianoia-ai
Distill expert reasoning from corpus into profile.yaml and SKILL.md — inject distilled knowledge into any AI model
https://github.com/bigmoon-dev/dianoia-ai
agent agent-skills ai cli code-review distillation expert-system knowledge-distillation llm prompt-engineering skill-extraction
Last synced: 13 days ago
JSON representation
Distill expert reasoning from corpus into profile.yaml and SKILL.md — inject distilled knowledge into any AI model
- Host: GitHub
- URL: https://github.com/bigmoon-dev/dianoia-ai
- Owner: bigmoon-dev
- License: apache-2.0
- Created: 2026-05-03T14:35:54.000Z (about 1 month ago)
- Default Branch: main
- Last Pushed: 2026-05-18T03:27:23.000Z (26 days ago)
- Last Synced: 2026-05-18T05:35:31.006Z (26 days ago)
- Topics: agent, agent-skills, ai, cli, code-review, distillation, expert-system, knowledge-distillation, llm, prompt-engineering, skill-extraction
- Language: Python
- Homepage:
- Size: 334 KB
- Stars: 5
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: docs/contributing.md
- License: LICENSE
Awesome Lists containing this project
README
# Dianoia AI 格物致知







> Open-source expert reasoning framework distillation tool
[English](#english) | [中文](./README.zh-CN.md)
---
## What is Dianoia?
Dianoia (格物致知) distills expert reasoning patterns from public artifacts — documents, code reviews, design docs — into **profile.yaml** and **SKILL.md** formats that any AI agent can consume.
Unlike knowledge extraction, Dianoia captures **how experts think**: how they define problems, judge quality, prioritize trade-offs, and decide when "good enough" is acceptable.
Inspired by [The Relic Condition](https://arxiv.org/abs/2604.16116) research on reasoning architecture extraction.
## Install
```bash
pip install py-dianoia
```
Requires Python 3.11+
## Quick Start
```bash
# 1. Initialize a project
dianoia init my-expert
# 2. Add corpus files to my-expert/corpus/
cp ~/expert-docs/*.md my-expert/corpus/
# 3. Extract reasoning patterns
dianoia extract my-expert
# 4. Build output files (profile.yaml + SKILL.md)
dianoia build my-expert
# 5. Validate outputs
dianoia validate my-expert
```
## V2 Features
### Interactive TUI for Expert Reasoning
**`dianoia tui init`** — First-run setup wizard to configure your LLM provider, model, API key, and expert directory. Saves to `~/.config/dianoia/config.yaml`.
**`dianoia tui`** — Launch an interactive terminal session to reason with a distilled expert. Select an expert from your configured experts directory and start a phase-guided reasoning conversation.
### Interactive Model Switching
Switch providers and models mid-session with `/model`. Supports 11 providers across international and China markets.
### File Reading and Modification
Mention a file path in chat and the expert auto-reads it. After discussion, use `/apply` to let the expert write changes back — with preview, confirmation, and automatic `.bak` backup.
### Agent Skills Integration
Dianoia ships its own `SKILL.md` in the project root. Drop it into your AI coding agent's skills directory once, then agents automatically load dianoia know-how on demand — no need to read docs.
**Install (pip users):**
```bash
# Download from GitHub
mkdir -p ~/.claude/skills/dianoia-ai
curl -o ~/.claude/skills/dianoia-ai/SKILL.md \
https://raw.githubusercontent.com/bigmoon-dev/dianoia-ai/main/SKILL.md
# Or for other agents:
# OpenCode: ~/.config/opencode/skills/dianoia-ai/SKILL.md
# Claude Code: ~/.claude/skills/dianoia-ai/SKILL.md
# Codex CLI: ~/.agents/skills/dianoia-ai/SKILL.md
```
**How it works:**
| Step | What you say | What happens |
|------|-------------|--------------|
| 1. Deploy | (one-time file copy above) | Agent discovers the skill |
| 2. Distill | "帮我蒸馏一个 AI 架构师专家" | Agent runs `dianoia init → extract → build` |
| 3. Trigger | "去问问 AI 架构师专家这个怎么设计" | Agent loads skill → runs `dianoia tui --profile ...` |
Trigger keywords the agent watches for: `dianoia`, `格物致知`, `蒸馏专家`, `蒸馏推理`, `dianoia init`, `dianoia tui`.
### Supported Providers
| Provider | Models | Env Var |
|----------|--------|---------|
| OpenAI | gpt-4o, o3, o4-mini | `OPENAI_API_KEY` |
| Anthropic | Claude Sonnet 4, Opus 4 | `ANTHROPIC_API_KEY` |
| Google | Gemini 2.5 Pro | `GOOGLE_API_KEY` |
| Groq | llama, mixtral | `GROQ_API_KEY` |
| Mistral | mistral-large, mistral-medium | `MISTRAL_API_KEY` |
| xAI | grok | `XAI_API_KEY` |
| Together AI | open-source models | `TOGETHER_API_KEY` |
| DeepSeek | deepseek-chat, deepseek-reasoner | `DEEPSEEK_API_KEY` |
| Zhipu/智谱 | glm-4-flash, glm-5.1 | `ZHIPU_API_KEY` |
| Moonshot/月之暗面 | moonshot-v1, kimi-k2 | `MOONSHOT_API_KEY` |
| Alibaba Qwen/阿里百炼 | qwen-turbo, qwen-plus, qwen-max | `DASHSCOPE_API_KEY` |
## V2 TUI Quick Start
```bash
# First time setup — configure provider, model, API key, experts directory
dianoia tui init
# Distill an expert (existing CLI workflow)
dianoia init my-expert
cp ~/docs/*.md my-expert/corpus/
dianoia extract my-expert
dianoia build my-expert
# Chat with your distilled expert
dianoia tui
```
## Architecture
```
Corpus Files → ExtractionPipeline (8 layers) → IR → ProfileMapper → profile.yaml
→ SkillRenderer → SKILL.md
```
### Feishu (Lark) Bot Integration
Chat with distilled experts directly in Feishu. Uses WebSocket long connection — no public URL or webhook setup needed.
```bash
pip install -e ".[feishu]"
# Configure credentials
cat > .env << 'EOF'
FEISHU_APP_ID=cli_xxxxx
FEISHU_APP_SECRET=your_secret
FEISHU_EXPERTS_DIR=~/dianoia-experts
EOF
# Start the bot
python -c "from py_dianoia.integrations.feishu.bot import run; run()"
```
**Architecture:** 4-module design reviewed by ai-product-architect expert:
| Module | Responsibility |
|--------|---------------|
| `state.py` | SessionStore (TTL expiry) + Deduplicator (LRU) with thread safety |
| `expert_client.py` | Safe dianoia CLI wrapper (input validation, circuit breaker, timeout) |
| `router.py` | Rule-based intent routing (list/select/chat), zero SDK dependency |
| `bot.py` | FeishuAdapter: WebSocket events → router → expert calls via thread pool |
**User commands in Feishu:**
| Command | Action |
|---------|--------|
| `列表` | List available experts with descriptions |
| `expert-name` | Select an expert (e.g. `ai-product-architect`) |
| Any text | Chat with selected expert |
| `切换 expert-name` | Switch to another expert |
### 8-Layer Extraction Method
| # | Layer | Extracts |
|---|-------|----------|
| 1 | Ontological | Problem boundaries, classification systems |
| 2 | Teleological | Goals, purposes, end-driven reasoning |
| 3 | Methodological | Procedures, systematic approaches |
| 4 | Axiological | Values, priorities, decision criteria |
| 5 | Epistemological | Knowledge sources, evidence standards |
| 6 | Conditional | Context-dependent decisions |
| 7 | Priority | Trade-off ordering (engineering-specific) |
| 8 | Pragmatic | "Good enough" thresholds, practical shortcuts |
### Stability Filtering
Features only survive if they appear in ≥2 independent texts AND ≥3 distinct contexts. This filters noise and ensures distilled patterns represent genuine expert consensus.
## Output Formats
### profile.yaml
Structured data for workflow engines (e.g., kitchen-ent):
```yaml
version: "1.0"
sections:
identity:
- key: domain
value: engineering
confidence: 0.85
sources: [doc1.md, doc2.md]
```
### SKILL.md
Follows the [Agent Skills](https://agentskills.io) open standard:
```markdown
---
name: "my-expert"
description: "Expert reasoning distilled from ..."
---
# My Expert
## Extracted Reasoning Patterns
...
```
## Language Overlay
Distill once in a language-agnostic base profile, then overlay language-specific customizations:
```
base-profile.yaml (language-agnostic skeleton)
+ overlay-python.yaml
+ overlay-rust.yaml
+ overlay-go.yaml
```
## Documentation
- [Distillation Principle](docs/distillation-principle.md)
- [Architecture](docs/architecture.md)
- [CLI Reference](docs/cli-reference.md)
- [Language Overlay](docs/language-overlay.md)
- [Profile Deliverable](docs/profile-deliverable.md)
- [SKILL Deliverable](docs/skill-deliverable.md)
- [Contributing](docs/contributing.md)
## Specifications
- [IR Schema](spec/ir-schema.json) — JSON Schema for the Intermediate Representation
- [Profile Spec](spec/profile-spec.yaml) — profile.yaml format specification
- [SKILL Spec](spec/skill-spec.md) — SKILL.md format specification
## Development
```bash
git clone https://github.com/bigmoon-dev/dianoia-ai.git
cd dianoia-ai
pip install -e ".[dev]"
pytest
```
## License
Apache-2.0