iee-engine 0.1.0__py3-none-any.whl
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.
- iee_engine/__init__.py +2 -0
- iee_engine/core.py +46 -0
- iee_engine/mcp.py +55 -0
- iee_engine-0.1.0.dist-info/METADATA +103 -0
- iee_engine-0.1.0.dist-info/RECORD +9 -0
- iee_engine-0.1.0.dist-info/WHEEL +5 -0
- iee_engine-0.1.0.dist-info/entry_points.txt +2 -0
- iee_engine-0.1.0.dist-info/licenses/LICENSE +3 -0
- iee_engine-0.1.0.dist-info/top_level.txt +1 -0
iee_engine/__init__.py
ADDED
iee_engine/core.py
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"""IEE 引擎核心算子:本体-架构-算子三段补全。铭文:名定体生,体定用成。"""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
from typing import Any, Dict, List
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def derive(name: str, semantics: str, elements: List[str], constraints: List[str]) -> Dict[str, Any]:
|
|
7
|
+
"""derive:命名+语义 → 逻辑本体(要素/关系/约束)。"""
|
|
8
|
+
ontology = {
|
|
9
|
+
"name": name,
|
|
10
|
+
"semantics": semantics,
|
|
11
|
+
"elements": list(elements),
|
|
12
|
+
"relations": ["要素入本体,本体承约束"],
|
|
13
|
+
"constraints": list(constraints),
|
|
14
|
+
}
|
|
15
|
+
return {"stage": "ontology", "ontology": ontology}
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def blueprint(ontology: Dict[str, Any]) -> Dict[str, Any]:
|
|
19
|
+
"""blueprint:本体 → 架构分层(注册层/算子层/验证层)。"""
|
|
20
|
+
els = ontology.get("elements", [])
|
|
21
|
+
arch = {
|
|
22
|
+
"layers": [
|
|
23
|
+
{"layer": "registry", "duty": "算子注册与解析", "from": els},
|
|
24
|
+
{"layer": "operators", "duty": "要素映射为算子", "from": els},
|
|
25
|
+
{"layer": "verify", "duty": "约束即测试", "from": ontology.get("constraints", [])},
|
|
26
|
+
],
|
|
27
|
+
"from_ontology": ontology.get("name"),
|
|
28
|
+
}
|
|
29
|
+
return {"stage": "architecture", "architecture": arch}
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def emit(architecture: Dict[str, Any]) -> Dict[str, Any]:
|
|
33
|
+
"""emit:架构 → 算子骨架(函数名、注册表键、测试桩名)。"""
|
|
34
|
+
ops = []
|
|
35
|
+
for layer in architecture.get("layers", []):
|
|
36
|
+
for el in layer.get("from", []):
|
|
37
|
+
ops.append({"operator": el, "layer": layer["layer"], "stub": f"def {el}(...) -> Dict[str, Any]"})
|
|
38
|
+
return {"stage": "operators", "skeleton": ops, "dispatch_keys": [o["operator"] for o in ops]}
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
DISPATCH = {"derive": derive, "blueprint": blueprint, "emit": emit}
|
|
42
|
+
TOOLS_META = {
|
|
43
|
+
"derive": {"desc": "命名+语义 → 逻辑本体", "schema": {"type": "object", "properties": {"name": {"type": "string"}, "semantics": {"type": "string"}, "elements": {"type": "array", "items": {"type": "string"}}, "constraints": {"type": "array", "items": {"type": "string"}}}, "required": ["name", "semantics", "elements", "constraints"]}},
|
|
44
|
+
"blueprint": {"desc": "本体 → 架构分层", "schema": {"type": "object", "properties": {"ontology": {"type": "object"}}, "required": ["ontology"]}},
|
|
45
|
+
"emit": {"desc": "架构 → 算子骨架", "schema": {"type": "object", "properties": {"architecture": {"type": "object"}}, "required": ["architecture"]}},
|
|
46
|
+
}
|
iee_engine/mcp.py
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"""Lightweight MCP stdio server: JSON-RPC 2.0, zero external dependencies."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
import sys, json
|
|
4
|
+
|
|
5
|
+
from .core import DISPATCH, TOOLS_META
|
|
6
|
+
|
|
7
|
+
SERVER_INFO = {"name": "iee-engine", "version": "0.1.0"}
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def _reply(req_id, result):
|
|
11
|
+
return json.dumps({"jsonrpc": "2.0", "id": req_id, "result": result}, ensure_ascii=False)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def _error(req_id, code, message):
|
|
15
|
+
return json.dumps({"jsonrpc": "2.0", "id": req_id, "error": {"code": code, "message": message}}, ensure_ascii=False)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def handle(req: dict) -> str:
|
|
19
|
+
method = req.get("method", "")
|
|
20
|
+
req_id = req.get("id")
|
|
21
|
+
if method == "initialize":
|
|
22
|
+
return _reply(req_id, {"protocolVersion": req.get("params", {}).get("protocolVersion", "2024-11-05"), "capabilities": {"tools": {}}, "serverInfo": SERVER_INFO})
|
|
23
|
+
if method == "tools/list":
|
|
24
|
+
return _reply(req_id, {"tools": [{"name": n, "description": m.get("desc", ""), "inputSchema": m.get("schema", {"type": "object", "properties": {}})} for n, m in TOOLS_META.items()]})
|
|
25
|
+
if method == "tools/call":
|
|
26
|
+
params = req.get("params", {})
|
|
27
|
+
name = params.get("name")
|
|
28
|
+
if name not in DISPATCH:
|
|
29
|
+
return _error(req_id, -32602, f"unknown tool: {name}")
|
|
30
|
+
try:
|
|
31
|
+
out = DISPATCH[name](**params.get("arguments", {}))
|
|
32
|
+
except TypeError as e:
|
|
33
|
+
return _error(req_id, -32602, str(e))
|
|
34
|
+
return _reply(req_id, {"content": [{"type": "text", "text": json.dumps(out, ensure_ascii=False)}]})
|
|
35
|
+
return _error(req_id, -32601, f"method not found: {method}")
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def main() -> None:
|
|
39
|
+
for line in sys.stdin:
|
|
40
|
+
line = line.strip()
|
|
41
|
+
if not line:
|
|
42
|
+
continue
|
|
43
|
+
try:
|
|
44
|
+
req = json.loads(line)
|
|
45
|
+
except json.JSONDecodeError:
|
|
46
|
+
sys.stdout.write(_error(None, -32700, "parse error") + "\n")
|
|
47
|
+
continue
|
|
48
|
+
out = handle(req)
|
|
49
|
+
if out:
|
|
50
|
+
sys.stdout.write(out + "\n")
|
|
51
|
+
sys.stdout.flush()
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
if __name__ == "__main__":
|
|
55
|
+
main()
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: iee-engine
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: IEE Engine — ontology-architecture-operator completion MCP. Map a named concept to logical ontology, layered architecture, and operator skeleton. Pure stdlib, zero dependencies.
|
|
5
|
+
Author: 元极恒一 (tanbopiao)
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/tanbopiao/iee-engine
|
|
8
|
+
Project-URL: Repository, https://github.com/tanbopiao/iee-engine
|
|
9
|
+
Keywords: mcp,ontology,architecture,code-generation,scaffold,yuanshu,daotong
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Topic :: Software Development :: Code Generators
|
|
20
|
+
Requires-Python: >=3.9
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
License-File: LICENSE
|
|
23
|
+
Dynamic: license-file
|
|
24
|
+
|
|
25
|
+
# IEE 引擎 · 本体-架构-算子补全 · iee-engine
|
|
26
|
+
|
|
27
|
+
> 铭文:名定体生,体定用成
|
|
28
|
+
|
|
29
|
+
## English
|
|
30
|
+
|
|
31
|
+
**iee-engine** is a lightweight MCP (Model Context Protocol) server that turns a named concept into a complete implementation scaffold in three traceable stages:
|
|
32
|
+
|
|
33
|
+
1. **derive** — name + semantics → logical ontology (elements, relations, constraints)
|
|
34
|
+
2. **blueprint** — ontology → layered architecture (registry / operators / verification)
|
|
35
|
+
3. **emit** — architecture → operator skeleton (function stubs, dispatch table, test stubs)
|
|
36
|
+
|
|
37
|
+
Every stage keeps provenance, so the whole chain from naming to code is auditable. Pure Python standard library, zero dependencies, single stdio transport.
|
|
38
|
+
|
|
39
|
+
### Install
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
pip install iee-engine
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Run as MCP server (stdio)
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
iee-engine-mcp
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Or in an MCP client config:
|
|
52
|
+
|
|
53
|
+
```json
|
|
54
|
+
{
|
|
55
|
+
"mcpServers": {
|
|
56
|
+
"iee-engine": {
|
|
57
|
+
"command": "iee-engine-mcp",
|
|
58
|
+
"args": []
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Use as a library
|
|
65
|
+
|
|
66
|
+
```python
|
|
67
|
+
from iee_engine.core import derive, blueprint, emit
|
|
68
|
+
|
|
69
|
+
ontology = derive(name="ledger", semantics="append-only entries", elements=["register", "resolve"], constraints=["entries are immutable"])
|
|
70
|
+
arch = blueprint(ontology)
|
|
71
|
+
skeleton = emit(arch)
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Tools
|
|
75
|
+
|
|
76
|
+
| Tool | Input | Output |
|
|
77
|
+
| --- | --- | --- |
|
|
78
|
+
| `derive` | `name`, `semantics`, `elements[]`, `constraints[]` | logical ontology |
|
|
79
|
+
| `blueprint` | `ontology` | layered architecture |
|
|
80
|
+
| `emit` | `architecture` | operator skeleton with dispatch keys |
|
|
81
|
+
|
|
82
|
+
## 逻辑本体
|
|
83
|
+
|
|
84
|
+
命名与语义入引擎,三段映射:命名→逻辑本体(要素/关系/约束)→架构(分层)→算子骨架;段段留痕可溯。
|
|
85
|
+
|
|
86
|
+
## 架构
|
|
87
|
+
|
|
88
|
+
```
|
|
89
|
+
补全引擎(三段映射)
|
|
90
|
+
├─ derive:命名+语义 → 逻辑本体
|
|
91
|
+
├─ blueprint:本体 → 架构分层
|
|
92
|
+
└─ emit:架构 → 算子骨架(含注册表与测试桩)
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## 算子注册
|
|
96
|
+
|
|
97
|
+
- `derive`
|
|
98
|
+
- `blueprint`
|
|
99
|
+
- `emit`
|
|
100
|
+
|
|
101
|
+
## 道统谱系
|
|
102
|
+
|
|
103
|
+
iee-engine 是道统工具族的一员,同族还有宗源根(谱系总册)、宗源编年史(时序记事册)、天罡壶(淬炼熔炉)、地格(空间格网)、关台(查验放行)、欧米伽决策(终局裁断)。命名取自华夏道统语义,详见各仓。
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
iee_engine/__init__.py,sha256=0lBceWQkRb46VR1r5Gh76Y0XQknywqrdMBaXgTGiZK4,111
|
|
2
|
+
iee_engine/core.py,sha256=NlMukTWpYf9JVvBdXOeZteVQpn4PY6upbHztZtCaFTI,2449
|
|
3
|
+
iee_engine/mcp.py,sha256=obb2opWrrS6t7IPewoje2nrN1AVaaR-_Suie1SQlJPk,2009
|
|
4
|
+
iee_engine-0.1.0.dist-info/licenses/LICENSE,sha256=NcR8FjaKurBNfmrBnd4bAk6HiA0DS_oCNDYcDvbiGRM,46
|
|
5
|
+
iee_engine-0.1.0.dist-info/METADATA,sha256=T-GIeNA41RDHhGjNeBFkenanDJDhqZ_BrKaYOtC2rNw,3347
|
|
6
|
+
iee_engine-0.1.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
7
|
+
iee_engine-0.1.0.dist-info/entry_points.txt,sha256=DyC_4s18cPlAp5U9eqFK4cv3fFvRS2EQ4BtAGCaUF9g,55
|
|
8
|
+
iee_engine-0.1.0.dist-info/top_level.txt,sha256=SzJvxat_NO0O9oTm_jwXIQ_5r50idOxNshNTjjt3iHQ,11
|
|
9
|
+
iee_engine-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
iee_engine
|