soma-wisdom 0.3.0b1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. soma_wisdom-0.3.0b1/.github/workflows/ci.yml +74 -0
  2. soma_wisdom-0.3.0b1/.gitignore +75 -0
  3. soma_wisdom-0.3.0b1/CHANGELOG.md +126 -0
  4. soma_wisdom-0.3.0b1/CONTRIBUTING.md +178 -0
  5. soma_wisdom-0.3.0b1/INTRO.md +15 -0
  6. soma_wisdom-0.3.0b1/LICENSE +201 -0
  7. soma_wisdom-0.3.0b1/PKG-INFO +566 -0
  8. soma_wisdom-0.3.0b1/README.md +325 -0
  9. soma_wisdom-0.3.0b1/README_zh.md +327 -0
  10. soma_wisdom-0.3.0b1/dash/__init__.py +0 -0
  11. soma_wisdom-0.3.0b1/dash/app.py +59 -0
  12. soma_wisdom-0.3.0b1/dash/components/__init__.py +0 -0
  13. soma_wisdom-0.3.0b1/dash/components/chat_tab.py +74 -0
  14. soma_wisdom-0.3.0b1/dash/components/framework_tab.py +85 -0
  15. soma_wisdom-0.3.0b1/dash/components/memory_tab.py +67 -0
  16. soma_wisdom-0.3.0b1/dash/frontend/index.html +14 -0
  17. soma_wisdom-0.3.0b1/dash/frontend/package-lock.json +1438 -0
  18. soma_wisdom-0.3.0b1/dash/frontend/package.json +21 -0
  19. soma_wisdom-0.3.0b1/dash/frontend/src/App.vue +76 -0
  20. soma_wisdom-0.3.0b1/dash/frontend/src/api/index.js +104 -0
  21. soma_wisdom-0.3.0b1/dash/frontend/src/components/ActivationSankey.vue +128 -0
  22. soma_wisdom-0.3.0b1/dash/frontend/src/components/DecompositionGraph.vue +171 -0
  23. soma_wisdom-0.3.0b1/dash/frontend/src/components/LanguageSwitcher.vue +54 -0
  24. soma_wisdom-0.3.0b1/dash/frontend/src/components/PromptPreview.vue +172 -0
  25. soma_wisdom-0.3.0b1/dash/frontend/src/locales/en.js +285 -0
  26. soma_wisdom-0.3.0b1/dash/frontend/src/locales/zh.js +285 -0
  27. soma_wisdom-0.3.0b1/dash/frontend/src/main.js +19 -0
  28. soma_wisdom-0.3.0b1/dash/frontend/src/router/index.js +16 -0
  29. soma_wisdom-0.3.0b1/dash/frontend/src/style.css +355 -0
  30. soma_wisdom-0.3.0b1/dash/frontend/src/views/AnalyticsView.vue +646 -0
  31. soma_wisdom-0.3.0b1/dash/frontend/src/views/BenchmarkView.vue +415 -0
  32. soma_wisdom-0.3.0b1/dash/frontend/src/views/ChatView.vue +263 -0
  33. soma_wisdom-0.3.0b1/dash/frontend/src/views/FrameworkView.vue +242 -0
  34. soma_wisdom-0.3.0b1/dash/frontend/src/views/MemoryView.vue +258 -0
  35. soma_wisdom-0.3.0b1/dash/frontend/src/views/SettingsView.vue +377 -0
  36. soma_wisdom-0.3.0b1/dash/frontend/src/views/TestReportsView.vue +288 -0
  37. soma_wisdom-0.3.0b1/dash/frontend/vite.config.js +15 -0
  38. soma_wisdom-0.3.0b1/dash/providers.py +198 -0
  39. soma_wisdom-0.3.0b1/dash/server.py +920 -0
  40. soma_wisdom-0.3.0b1/dashboard_data_backup/ablation_results.json +1 -0
  41. soma_wisdom-0.3.0b1/dashboard_data_backup/analytics.db +0 -0
  42. soma_wisdom-0.3.0b1/dashboard_data_backup/benchmark_results.json +857 -0
  43. soma_wisdom-0.3.0b1/dashboard_data_backup/episodic.db +0 -0
  44. soma_wisdom-0.3.0b1/dashboard_data_backup/evolver.db +0 -0
  45. soma_wisdom-0.3.0b1/dashboard_data_backup/mock_vs_real_results.json +700 -0
  46. soma_wisdom-0.3.0b1/dashboard_data_backup/semantic.db +0 -0
  47. soma_wisdom-0.3.0b1/dashboard_data_backup/skills.db +0 -0
  48. soma_wisdom-0.3.0b1/docs/Sun Yan/357/274/232SOMA - Intelligence Transcends Memory, a Framework-Prioritized Cognitive Architecture for AI Agents.pdf +0 -0
  49. soma_wisdom-0.3.0b1/docs/api/index.md +287 -0
  50. soma_wisdom-0.3.0b1/docs/architecture.md +213 -0
  51. soma_wisdom-0.3.0b1/docs/architecture_zh.md +213 -0
  52. soma_wisdom-0.3.0b1/docs/guides/customization.md +475 -0
  53. soma_wisdom-0.3.0b1/docs/index.md +51 -0
  54. soma_wisdom-0.3.0b1/docs/philosophy.md +119 -0
  55. soma_wisdom-0.3.0b1/docs/philosophy_zh.md +119 -0
  56. soma_wisdom-0.3.0b1/docs/quickstart.md +123 -0
  57. soma_wisdom-0.3.0b1/docs/quickstart_zh.md +123 -0
  58. soma_wisdom-0.3.0b1/docs//345/255/231/345/262/251/357/274/232SOMA/342/200/224/342/200/224/346/231/272/346/205/247/350/266/205/350/266/212/350/256/260/345/277/206/357/274/214/344/270/272AI Agent/346/236/204/345/273/272/347/232/204/346/241/206/346/236/266/344/274/230/345/205/210/345/274/217/350/256/244/347/237/245/346/236/266/346/236/204.pdf +0 -0
  59. soma_wisdom-0.3.0b1/examples/basic_usage.py +151 -0
  60. soma_wisdom-0.3.0b1/examples/integration_guide.py +354 -0
  61. soma_wisdom-0.3.0b1/examples/langchain_demo.py +77 -0
  62. soma_wisdom-0.3.0b1/mkdocs.yml +59 -0
  63. soma_wisdom-0.3.0b1/pyproject.toml +82 -0
  64. soma_wisdom-0.3.0b1/reports/001-batch-v0.3.0-en.pdf +0 -0
  65. soma_wisdom-0.3.0b1/reports/001-batch-v0.3.0-zh.pdf +0 -0
  66. soma_wisdom-0.3.0b1/reports/001-batch-v0.3.0.md +242 -0
  67. soma_wisdom-0.3.0b1/scripts/__init__.py +0 -0
  68. soma_wisdom-0.3.0b1/scripts/ablation_test.py +282 -0
  69. soma_wisdom-0.3.0b1/scripts/batch_test.py +182 -0
  70. soma_wisdom-0.3.0b1/scripts/batch_test_results.json +8030 -0
  71. soma_wisdom-0.3.0b1/scripts/benchmark_test.py +196 -0
  72. soma_wisdom-0.3.0b1/scripts/generate_report_pdfs.py +602 -0
  73. soma_wisdom-0.3.0b1/scripts/import_ablation.py +146 -0
  74. soma_wisdom-0.3.0b1/scripts/import_benchmark.py +90 -0
  75. soma_wisdom-0.3.0b1/scripts/import_mock_vs_real.py +109 -0
  76. soma_wisdom-0.3.0b1/scripts/mock_vs_real.py +235 -0
  77. soma_wisdom-0.3.0b1/soma/__init__.py +196 -0
  78. soma_wisdom-0.3.0b1/soma/__main__.py +79 -0
  79. soma_wisdom-0.3.0b1/soma/abc.py +71 -0
  80. soma_wisdom-0.3.0b1/soma/agent.py +217 -0
  81. soma_wisdom-0.3.0b1/soma/analytics.py +413 -0
  82. soma_wisdom-0.3.0b1/soma/base.py +45 -0
  83. soma_wisdom-0.3.0b1/soma/benchmarks.py +470 -0
  84. soma_wisdom-0.3.0b1/soma/config.py +58 -0
  85. soma_wisdom-0.3.0b1/soma/embedder.py +48 -0
  86. soma_wisdom-0.3.0b1/soma/engine.py +110 -0
  87. soma_wisdom-0.3.0b1/soma/evolve.py +329 -0
  88. soma_wisdom-0.3.0b1/soma/hub/__init__.py +8 -0
  89. soma_wisdom-0.3.0b1/soma/hub/_core.py +86 -0
  90. soma_wisdom-0.3.0b1/soma/hub/_ranker.py +83 -0
  91. soma_wisdom-0.3.0b1/soma/hub/_retriever.py +14 -0
  92. soma_wisdom-0.3.0b1/soma/hub/_scorer.py +9 -0
  93. soma_wisdom-0.3.0b1/soma/hub.py +12 -0
  94. soma_wisdom-0.3.0b1/soma/langchain_tool.py +56 -0
  95. soma_wisdom-0.3.0b1/soma/law_discovery.py +291 -0
  96. soma_wisdom-0.3.0b1/soma/memory/__init__.py +6 -0
  97. soma_wisdom-0.3.0b1/soma/memory/core.py +161 -0
  98. soma_wisdom-0.3.0b1/soma/memory/episodic.py +232 -0
  99. soma_wisdom-0.3.0b1/soma/memory/semantic.py +163 -0
  100. soma_wisdom-0.3.0b1/soma/memory/skill.py +103 -0
  101. soma_wisdom-0.3.0b1/soma/plugin.py +108 -0
  102. soma_wisdom-0.3.0b1/soma/vector_store.py +148 -0
  103. soma_wisdom-0.3.0b1/soma/wisdom_laws.yaml +54 -0
  104. soma_wisdom-0.3.0b1/tests/__init__.py +0 -0
  105. soma_wisdom-0.3.0b1/tests/test_abc.py +71 -0
  106. soma_wisdom-0.3.0b1/tests/test_agent.py +129 -0
  107. soma_wisdom-0.3.0b1/tests/test_base.py +91 -0
  108. soma_wisdom-0.3.0b1/tests/test_config.py +93 -0
  109. soma_wisdom-0.3.0b1/tests/test_edge_cases.py +87 -0
  110. soma_wisdom-0.3.0b1/tests/test_embedder.py +64 -0
  111. soma_wisdom-0.3.0b1/tests/test_engine.py +122 -0
  112. soma_wisdom-0.3.0b1/tests/test_episodic.py +87 -0
  113. soma_wisdom-0.3.0b1/tests/test_evolve.py +37 -0
  114. soma_wisdom-0.3.0b1/tests/test_evolve_full.py +271 -0
  115. soma_wisdom-0.3.0b1/tests/test_hub.py +118 -0
  116. soma_wisdom-0.3.0b1/tests/test_integration.py +229 -0
  117. soma_wisdom-0.3.0b1/tests/test_langchain_tool.py +50 -0
  118. soma_wisdom-0.3.0b1/tests/test_law_discovery.py +211 -0
  119. soma_wisdom-0.3.0b1/tests/test_memory_core.py +73 -0
  120. soma_wisdom-0.3.0b1/tests/test_semantic.py +62 -0
  121. soma_wisdom-0.3.0b1/tests/test_skill.py +29 -0
  122. soma_wisdom-0.3.0b1/tests/test_vector_store.py +133 -0
  123. soma_wisdom-0.3.0b1/wisdom_laws.yaml +54 -0
@@ -0,0 +1,74 @@
1
+ name: SOMA CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main, develop]
6
+ paths-ignore:
7
+ - '*.md'
8
+ - 'docs/**'
9
+ pull_request:
10
+ branches: [main]
11
+ paths-ignore:
12
+ - '*.md'
13
+ - 'docs/**'
14
+
15
+ jobs:
16
+ test:
17
+ runs-on: ubuntu-latest
18
+ strategy:
19
+ fail-fast: false
20
+ matrix:
21
+ python-version: ["3.10", "3.11", "3.12"]
22
+
23
+ steps:
24
+ - uses: actions/checkout@v4
25
+
26
+ - name: Install system deps
27
+ run: |
28
+ sudo apt-get update -qq
29
+ sudo apt-get install -y -qq build-essential libgomp1
30
+
31
+ - name: Set up Python ${{ matrix.python-version }}
32
+ uses: actions/setup-python@v5
33
+ with:
34
+ python-version: ${{ matrix.python-version }}
35
+ cache: 'pip'
36
+
37
+ - name: Install dependencies
38
+ run: |
39
+ python -m pip install --upgrade pip
40
+ pip install numpy # faiss-cpu 需要预装 numpy
41
+ pip install -e ".[dev,alpha]"
42
+
43
+ - name: Debug installed packages
44
+ run: |
45
+ pip list 2>/dev/null | grep -iE "litellm|fastembed|faiss|chroma|pytest"
46
+
47
+ - name: Check import
48
+ run: |
49
+ python -c "import soma; print('soma import OK')"
50
+
51
+ - name: Run tests
52
+ run: |
53
+ pytest -v --tb=long --timeout=60 -ra
54
+
55
+ build:
56
+ runs-on: ubuntu-latest
57
+ needs: test
58
+ steps:
59
+ - uses: actions/checkout@v4
60
+
61
+ - name: Set up Python
62
+ uses: actions/setup-python@v5
63
+ with:
64
+ python-version: "3.12"
65
+
66
+ - name: Build package
67
+ run: |
68
+ pip install build
69
+ python -m build
70
+
71
+ - name: Verify wheel
72
+ run: |
73
+ pip install twine
74
+ twine check dist/*
@@ -0,0 +1,75 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ *.so
6
+ *.egg-info/
7
+ dist/
8
+ build/
9
+ eggs/
10
+ *.egg
11
+ .eggs/
12
+
13
+ # Virtual environments
14
+ venv/
15
+ .venv/
16
+ env/
17
+ .env/
18
+
19
+ # IDE
20
+ .vscode/
21
+ .idea/
22
+ *.swp
23
+ *.swo
24
+ *~
25
+
26
+ # Testing
27
+ .pytest_cache/
28
+ .coverage
29
+ htmlcov/
30
+ *.cover
31
+
32
+ # Type checking
33
+ .mypy_cache/
34
+
35
+ # ChromaDB persistence (user data)
36
+ chroma_data/
37
+
38
+ # Environment
39
+ .env
40
+ .env.local
41
+ .env.*.local
42
+
43
+ # OS
44
+ .DS_Store
45
+ Thumbs.db
46
+
47
+ # SOMA specific
48
+ *.log
49
+ soma_runs/
50
+ soma_data/
51
+ dashboard_data/
52
+
53
+ # LLM config (contains API keys — NEVER commit)
54
+ dash/llm_config.json
55
+
56
+ # Integration guide example data directories
57
+ soma_test_data/
58
+ soma_langchain_data/
59
+
60
+ # Frontend
61
+ dash/frontend/dist/
62
+ dash/frontend/node_modules/
63
+
64
+ # Jupyter
65
+ .ipynb_checkpoints/
66
+ *.ipynb
67
+
68
+ # Ruff
69
+ .ruff_cache/
70
+
71
+ # Benchmarks
72
+ benchmark_results/
73
+
74
+ # Screenshots (source materials)
75
+ ysimages/
@@ -0,0 +1,126 @@
1
+ # Changelog
2
+
3
+ All notable changes to SOMA will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ---
9
+
10
+ ## [0.3.0b1] — Unreleased
11
+
12
+ ### Added
13
+ - **MMR diversity re-ranking**: ActivationHub now uses Maximal Marginal Relevance to balance relevance with content/source diversity, preventing near-duplicate memories from dominating results
14
+ - **Hub pluggable architecture**: `ActivationHub` decomposed into 3-stage pipeline — `MemoryRetriever` (recall), `RelevanceScorer` (scoring), `MMRRanker` (re-ranking) — all replaceable via constructor injection or `pyproject.toml` entry points
15
+ - **Entry points plugin system**: `[project.entry-points."soma.plugins"]` — external packages can register custom retriever/scorer/ranker implementations
16
+ - **Frontend route lazy loading**: Vue Router dynamic imports reduce initial JS payload by 75% (756KB → 188KB)
17
+
18
+ ### Changed
19
+ - `soma/hub.py` → facade re-export; implementation moved to `soma/hub/` sub-package
20
+ - `hub.activate()` now applies threshold AFTER MMR re-ranking for wider candidate pool
21
+ - Hard dedup at >88% Jaccard similarity during MMR selection
22
+
23
+ ### Fixed
24
+ - Version strings unified to "0.3.0b1" across all modules
25
+ - `benchmarksRun()` API function added to frontend
26
+
27
+ ---
28
+
29
+ ## [0.2.0-alpha] — 2026-04-26
30
+
31
+ ### Added
32
+ - **Semantic Search**: ONNX-powered vector embeddings (fastembed) with FAISS ANN search, replacing pure keyword matching
33
+ - **Bidirectional Activation**: Weighted Reciprocal Rank Fusion (semantic ×2 + keyword ×1) for memory retrieval
34
+ - **WisdomEngine v2**: jieba Chinese tokenization with stopword filtering and expanded trigger sets
35
+ - **MetaEvolver**: Full evolution loop — auto-adjust law weights every 10 sessions (±2%), skill solidification
36
+ - **Memory Dedup**: SHA256 content-hash based deduplication for episodic memories
37
+ - **Dashboard**: Vue 3 + Vite frontend with 6 views (Chat, Framework, Memory, Analytics, Benchmark, Settings)
38
+ - **REST API**: FastAPI server with SSE streaming, API key auth, multi-provider LLM management
39
+ - **3D Benchmark Engine**: Memory / Wisdom / Evolution dimensions with competitor comparison data
40
+ - **AnalyticsStore**: SQLite-based session tracking with full context recording
41
+ - **LangChain Tool**: `create_soma_tool()` for LangChain agent integration
42
+ - **CLI Quickstart**: `python -m soma` for one-command verification
43
+ - **CI/CD**: GitHub Actions pipeline (ruff + mypy + pytest + build + benchmark) on Python 3.10/3.11/3.12
44
+
45
+ ### Changed
46
+ - Vector store: ChromaDB → SQLite + FAISS (zero-dependency deployment)
47
+ - Embedding: OpenAI API → ONNX fastembed (CPU inference, offline capable)
48
+ - Keyword engine: simple split → jieba + stopword + punctuation filtering
49
+ - Wisdom law triggers expanded (5 → 12 items per law on average)
50
+
51
+ ### Fixed
52
+ - Memory recall threshold tuning for better precision/recall balance
53
+ - Edge case: empty memory store graceful degradation
54
+ - Dedup race condition on concurrent inserts
55
+
56
+ ---
57
+
58
+ ## [0.1.0] — 2025-05
59
+
60
+ ### Added
61
+ - **WisdomEngine**: Hardcoded 5-law wisdom framework with keyword trigger matching
62
+ - **MemoryCore**: ChromaDB episodic storage + NetworkX semantic graph
63
+ - **ActivationHub**: Keyword-match memory recall with simple relevance sorting
64
+ - **SOMA_Agent**: End-to-end `respond()` pipeline (decompose → recall → template synthesis)
65
+ - **Unit tests**: Core module test coverage
66
+ - **wisdom_laws.yaml**: Initial framework configuration
67
+
68
+ ---
69
+
70
+ ## 变更日志
71
+
72
+ 格式基于 [Keep a Changelog](https://keepachangelogen/zh-CN/1.0.0/)。
73
+
74
+ ### [0.3.0b1] — Unreleased
75
+
76
+ #### 新增
77
+ - **MMR 多样性重排**: ActivationHub 使用最大边界相关性算法平衡关联度与内容/来源多样性,避免高度重复记忆占据全部结果
78
+ - **Hub 可插拔架构**: `ActivationHub` 拆分为三段式管道 — `MemoryRetriever`(多路召回)、`RelevanceScorer`(相关性打分)、`MMRRanker`(多样性重排)— 均可通过构造器注入或 `pyproject.toml` entry points 替换
79
+ - **Entry points 插件体系**: `[project.entry-points."soma.plugins"]` — 外部包可注册自定义 retriever/scorer/ranker 实现
80
+ - **前端路由懒加载**: Vue Router 动态 import 将首屏 JS 体积压缩 75%(756KB → 188KB)
81
+
82
+ #### 变更
83
+ - `soma/hub.py` → 门面 re-export;实现迁移至 `soma/hub/` 子包
84
+ - `hub.activate()` 阈值过滤移至 MMR 重排之后,扩大候选池
85
+ - MMR 选择阶段 >88% Jaccard 相似度硬去重
86
+
87
+ #### 修复
88
+ - 全模块版本字符串统一为 "0.3.0b1"
89
+ - 前端补全 `benchmarksRun()` API 函数
90
+
91
+ ### [0.2.0-alpha] — 2026-04-26
92
+
93
+ #### 新增
94
+ - **语义搜索**: ONNX 向量嵌入 (fastembed) + FAISS 近邻搜索,替代纯关键词匹配
95
+ - **双向激活**: 加权倒数排序融合(语义×2 + 关键词×1)记忆检索
96
+ - **WisdomEngine v2**: jieba 中文分词 + 停用词过滤 + 扩展触发词集
97
+ - **MetaEvolver**: 完整进化闭环 — 每10次会话自动调权(±2%)、技能固化
98
+ - **记忆去重**: 基于 SHA256 内容哈希的情节记忆去重
99
+ - **Dashboard**: Vue 3 + Vite 前端(6 个视图)
100
+ - **REST API**: FastAPI 服务 + SSE 流式 + API Key 认证 + 多模型管理
101
+ - **3D 基准引擎**: 记忆/智慧/进化三维评测 + 竞品对比数据
102
+ - **AnalyticsStore**: SQLite 会话追踪与完整上下文记录
103
+ - **LangChain 工具**: `create_soma_tool()` 集成
104
+ - **CLI 快速入口**: `python -m soma` 一键验证
105
+ - **CI/CD**: GitHub Actions (ruff + mypy + pytest + build + benchmark),支持 Python 3.10/3.11/3.12
106
+
107
+ #### 变更
108
+ - 向量存储: ChromaDB → SQLite + FAISS
109
+ - 嵌入模型: OpenAI API → ONNX fastembed
110
+ - 关键词引擎: 简单分割 → jieba + 停用词 + 标点过滤
111
+ - 规律触发词扩充(平均 5 → 12 个)
112
+
113
+ #### 修复
114
+ - 记忆召回阈值微调,提升精确率/召回率平衡
115
+ - 空记忆库的优雅降级
116
+ - 并发写入的去重竞态
117
+
118
+ ### [0.1.0] — 2025-05
119
+
120
+ #### 新增
121
+ - WisdomEngine: 5条硬编码规律 + 关键词触发匹配
122
+ - MemoryCore: ChromaDB 情节存储 + NetworkX 语义图谱
123
+ - ActivationHub: 关键词匹配召回 + 简单关联排序
124
+ - SOMA_Agent: 端到端 respond() 管道(拆解→召回→模板合成)
125
+ - 单元测试覆盖核心模块
126
+ - wisdom_laws.yaml 初始框架配置
@@ -0,0 +1,178 @@
1
+ # Contributing to SOMA
2
+
3
+ Thank you for your interest in contributing. SOMA is an open-source project under Apache 2.0 license, and we welcome contributions of all kinds.
4
+
5
+ ## Code of Conduct
6
+
7
+ Be respectful. Be constructive. Assume good intent.
8
+
9
+ ## How to Contribute
10
+
11
+ ### Report Bugs
12
+
13
+ Open a GitHub Issue with:
14
+ - SOMA version (`python -c "import soma; print(soma.__version__)"`)
15
+ - Python version (`python --version`)
16
+ - Minimal reproduction steps
17
+ - Expected vs actual behavior
18
+
19
+ ### Suggest Features
20
+
21
+ Open a GitHub Issue with:
22
+ - Problem statement (what pain does this solve?)
23
+ - Proposed solution sketch
24
+ - Why it belongs in SOMA core vs an external plugin
25
+
26
+ ### Submit Code
27
+
28
+ 1. **Fork** the repository
29
+ 2. **Create a branch**: `feature/your-feature` or `fix/your-bug`
30
+ 3. **Write code** following the conventions below
31
+ 4. **Add tests** covering your changes
32
+ 5. **Run the full suite**: `pytest -v --cov=soma --cov-report=term`
33
+ 6. **Run linting**: `ruff check soma/ tests/`
34
+ 7. **Run type checks**: `mypy soma/ --ignore-missing-imports`
35
+ 8. **Commit** using conventional commit format (see below)
36
+ 9. **Open a Pull Request** against the `main` branch
37
+
38
+ ## Development Setup
39
+
40
+ ```bash
41
+ git clone https://github.com/soma-project/soma-core.git
42
+ cd soma-core
43
+ pip install -e ".[dev]"
44
+ ```
45
+
46
+ ## Code Conventions
47
+
48
+ ### Style
49
+ - Follow PEP 8, enforced by Ruff
50
+ - Line length: 100 characters
51
+ - Use type hints for public APIs
52
+
53
+ ### Tests
54
+ - Framework: pytest
55
+ - Coverage target: > 80% for new code
56
+ - Pattern: table-driven tests preferred
57
+ - Assertions: plain `assert` statements
58
+
59
+ ### Docstrings
60
+ - Public modules, classes, and functions must have docstrings
61
+ - Use Google-style docstring format
62
+
63
+ ### Commit Format
64
+
65
+ ```
66
+ <type>(<scope>): <description>
67
+ ```
68
+
69
+ Types: `feat`, `fix`, `docs`, `test`, `refactor`, `chore`
70
+
71
+ Examples:
72
+ - `feat(engine): add jieba Chinese tokenization`
73
+ - `fix(memory): resolve dedup race condition`
74
+ - `docs(api): add SOMA.respond examples`
75
+
76
+ ## Project Structure
77
+
78
+ ```
79
+ soma/ # Core library — strict API stability
80
+ dash/ # Dashboard + REST server — may change
81
+ tests/ # All tests
82
+ docs/ # Documentation
83
+ examples/ # Integration examples
84
+ scripts/ # Benchmarks and utilities
85
+ ```
86
+
87
+ ## Pull Request Process
88
+
89
+ 1. PR description must include: what, why, how tested
90
+ 2. CI must pass (ruff + mypy + pytest + build)
91
+ 3. At least one maintainer review required
92
+ 4. PRs that change public API must update docs and CHANGELOG.md
93
+
94
+ ## License
95
+
96
+ By contributing, you agree that your contributions will be licensed under the Apache License 2.0.
97
+
98
+ ---
99
+
100
+ # 贡献指南
101
+
102
+ 感谢你对 SOMA 的关注。SOMA 是 Apache 2.0 许可下的开源项目,欢迎各种形式的贡献。
103
+
104
+ ## 行为准则
105
+
106
+ 尊重他人。建设性讨论。假定善意。
107
+
108
+ ## 贡献方式
109
+
110
+ ### 报告 Bug
111
+
112
+ 提交 GitHub Issue,包含:
113
+ - SOMA 版本
114
+ - Python 版本
115
+ - 最小复现步骤
116
+ - 预期行为 vs 实际行为
117
+
118
+ ### 建议功能
119
+
120
+ 提交 GitHub Issue,包含:
121
+ - 问题描述(解决什么痛点?)
122
+ - 方案草图
123
+ - 为什么应该放在 SOMA 核心而非外部插件
124
+
125
+ ### 提交代码
126
+
127
+ 1. **Fork** 仓库
128
+ 2. **创建分支**: `feature/功能名` 或 `fix/问题名`
129
+ 3. **编写代码**,遵循以下规范
130
+ 4. **添加测试**覆盖你的改动
131
+ 5. **运行完整套件**: `pytest -v --cov=soma --cov-report=term`
132
+ 6. **运行代码检查**: `ruff check soma/ tests/`
133
+ 7. **运行类型检查**: `mypy soma/ --ignore-missing-imports`
134
+ 8. **提交**使用约定式提交格式
135
+ 9. **发起 Pull Request** 目标分支 `main`
136
+
137
+ ## 开发环境配置
138
+
139
+ ```bash
140
+ git clone https://github.com/soma-project/soma-core.git
141
+ cd soma-core
142
+ pip install -e ".[dev]"
143
+ ```
144
+
145
+ ## 代码规范
146
+
147
+ ### 风格
148
+ - 遵循 PEP 8,Ruff 强制执行
149
+ - 行长度: 100 字符
150
+ - 公开 API 使用类型标注
151
+
152
+ ### 测试
153
+ - 框架: pytest
154
+ - 覆盖率目标: 新代码 > 80%
155
+ - 模式: 优先使用 table-driven tests
156
+
157
+ ### 文档字符串
158
+ - 公开模块、类、函数必须有 docstring
159
+ - 使用 Google 风格 docstring 格式
160
+
161
+ ### 提交格式
162
+
163
+ ```
164
+ <type>(<scope>): <description>
165
+ ```
166
+
167
+ 类型: `feat`、`fix`、`docs`、`test`、`refactor`、`chore`
168
+
169
+ ## PR 流程
170
+
171
+ 1. PR 描述必须包含: 做了什么、为什么、如何测试
172
+ 2. CI 必须通过 (ruff + mypy + pytest + build)
173
+ 3. 至少一位维护者审核
174
+ 4. 修改公开 API 的 PR 必须同步更新文档和 CHANGELOG.md
175
+
176
+ ## 许可
177
+
178
+ 贡献即表示你同意将贡献以 Apache License 2.0 许可发布。
@@ -0,0 +1,15 @@
1
+ # SOMA: Wisdom over Memory
2
+
3
+ Most AI memory systems treat memory as passive storage — store everything, retrieve by similarity, hope it's relevant. This is the "high-IQ archive clerk" model: impressive recall, no framework for understanding what matters and why.
4
+
5
+ SOMA inverts this paradigm. Instead of asking "what stored knowledge is similar to this query?", it asks a deeper question: **"What thinking patterns does this problem activate, and what memories become relevant under those patterns?"**
6
+
7
+ At its core sits an explicit wisdom framework — seven thinking laws drawn from cognitive science and strategic reasoning: First Principles (regress to fundamentals), Systems Thinking (map interconnections), Contradiction Analysis (surface hidden tensions), Pareto Principle (find the critical few), Inversion (reason backwards), Analogical Reasoning (bridge domains), and Evolutionary Lens (track what adapts). Each law carries weighted keyword triggers and defined inter-relationships. When a problem arrives, SOMA decomposes it through these lenses, identifying which dimensions of thought apply and why — then assembles a structured prompt that guides the LLM rather than merely feeding it context.
8
+
9
+ This decomposition drives **bidirectional activation**. Rather than one-directional similarity search, SOMA computes the associative potential between each analysis focus and each stored memory — producing a ranked set of truly relevant knowledge, not just keyword-matched text. The framework acts as the index; memory supplies the substance.
10
+
11
+ The four-stage pipeline — Decompose, Activate, Synthesize, Evolve — runs with every query. After synthesis, SOMA reflects on which memories proved useful and adjusts law weights over time. Laws that consistently generate insight grow stronger; underused ones naturally fade. A law discovery module can even propose new thinking patterns from high-cohesion memory clusters, subject to human approval.
12
+
13
+ Built as a lightweight Python library with zero mandatory dependencies beyond the standard library, SOMA integrates in five minutes via pip. It ships with a REST API for remote access, a Vue.js dashboard for visual management, native LangChain tooling, and dual memory stores — episodic for experiences and semantic for knowledge triples — with optional vector search for cross-lingual semantic recall. The architecture is fully mockable: every LLM-dependent component accepts an interface, making it trivial to test without API calls. All 139 tests pass at 97% coverage. Zero API keys in the repository.
14
+
15
+ **Not "make AI remember more." Make AI understand deeper.**
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2025 SOMA Project Team
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.