soul-loop-soul 0.1.0__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.
- soul_loop_soul-0.1.0/LICENSE +21 -0
- soul_loop_soul-0.1.0/PKG-INFO +239 -0
- soul_loop_soul-0.1.0/README.md +162 -0
- soul_loop_soul-0.1.0/pyproject.toml +94 -0
- soul_loop_soul-0.1.0/setup.cfg +4 -0
- soul_loop_soul-0.1.0/src/soul_lang/__init__.py +7 -0
- soul_loop_soul-0.1.0/src/soul_lang/cli.py +488 -0
- soul_loop_soul-0.1.0/src/soul_lang/discovery/__init__.py +21 -0
- soul_loop_soul-0.1.0/src/soul_lang/discovery/engine.py +145 -0
- soul_loop_soul-0.1.0/src/soul_lang/discovery/file_detector.py +211 -0
- soul_loop_soul-0.1.0/src/soul_lang/discovery/models.py +101 -0
- soul_loop_soul-0.1.0/src/soul_lang/discovery/pattern_detector.py +226 -0
- soul_loop_soul-0.1.0/src/soul_lang/discovery/relationship.py +94 -0
- soul_loop_soul-0.1.0/src/soul_lang/discovery/semantic_analyzer.py +73 -0
- soul_loop_soul-0.1.0/src/soul_lang/errors.py +166 -0
- soul_loop_soul-0.1.0/src/soul_lang/language/__init__.py +22 -0
- soul_loop_soul-0.1.0/src/soul_lang/language/ast_nodes.py +59 -0
- soul_loop_soul-0.1.0/src/soul_lang/language/grammar.lark +55 -0
- soul_loop_soul-0.1.0/src/soul_lang/language/ir.py +236 -0
- soul_loop_soul-0.1.0/src/soul_lang/language/normalizer.py +441 -0
- soul_loop_soul-0.1.0/src/soul_lang/language/parser.py +796 -0
- soul_loop_soul-0.1.0/src/soul_lang/language/semantic.py +134 -0
- soul_loop_soul-0.1.0/src/soul_lang/models_engine/__init__.py +30 -0
- soul_loop_soul-0.1.0/src/soul_lang/models_engine/base.py +36 -0
- soul_loop_soul-0.1.0/src/soul_lang/models_engine/bulletproof.py +243 -0
- soul_loop_soul-0.1.0/src/soul_lang/models_engine/gemini_adapter.py +143 -0
- soul_loop_soul-0.1.0/src/soul_lang/models_engine/ollama_adapter.py +68 -0
- soul_loop_soul-0.1.0/src/soul_lang/models_engine/openai_adapter.py +65 -0
- soul_loop_soul-0.1.0/src/soul_lang/models_engine/registry.py +85 -0
- soul_loop_soul-0.1.0/src/soul_lang/organize/__init__.py +14 -0
- soul_loop_soul-0.1.0/src/soul_lang/organize/models.py +42 -0
- soul_loop_soul-0.1.0/src/soul_lang/organize/organizer.py +233 -0
- soul_loop_soul-0.1.0/src/soul_lang/organize/reporter.py +158 -0
- soul_loop_soul-0.1.0/src/soul_lang/runtime/__init__.py +20 -0
- soul_loop_soul-0.1.0/src/soul_lang/runtime/executor.py +676 -0
- soul_loop_soul-0.1.0/src/soul_lang/runtime/orchestrator.py +120 -0
- soul_loop_soul-0.1.0/src/soul_lang/runtime/state_machine.py +137 -0
- soul_loop_soul-0.1.0/src/soul_lang/runtime/state_store.py +62 -0
- soul_loop_soul-0.1.0/src/soul_lang/security/__init__.py +17 -0
- soul_loop_soul-0.1.0/src/soul_lang/security/permissions.py +96 -0
- soul_loop_soul-0.1.0/src/soul_lang/security/sanitizer.py +47 -0
- soul_loop_soul-0.1.0/src/soul_lang/security/secrets.py +137 -0
- soul_loop_soul-0.1.0/src/soul_lang/transform/__init__.py +11 -0
- soul_loop_soul-0.1.0/src/soul_lang/transform/converter.py +439 -0
- soul_loop_soul-0.1.0/src/soul_lang/transform/models.py +45 -0
- soul_loop_soul-0.1.0/src/soul_loop_soul.egg-info/PKG-INFO +239 -0
- soul_loop_soul-0.1.0/src/soul_loop_soul.egg-info/SOURCES.txt +55 -0
- soul_loop_soul-0.1.0/src/soul_loop_soul.egg-info/dependency_links.txt +1 -0
- soul_loop_soul-0.1.0/src/soul_loop_soul.egg-info/entry_points.txt +2 -0
- soul_loop_soul-0.1.0/src/soul_loop_soul.egg-info/requires.txt +33 -0
- soul_loop_soul-0.1.0/src/soul_loop_soul.egg-info/top_level.txt +1 -0
- soul_loop_soul-0.1.0/tests/test_bulletproof_models.py +105 -0
- soul_loop_soul-0.1.0/tests/test_discovery.py +68 -0
- soul_loop_soul-0.1.0/tests/test_language.py +168 -0
- soul_loop_soul-0.1.0/tests/test_runtime_e2e.py +120 -0
- soul_loop_soul-0.1.0/tests/test_security.py +86 -0
- soul_loop_soul-0.1.0/tests/test_transform_organize.py +108 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Soul Loop Soul Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: soul-loop-soul
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Soul Loop Soul(自循環降靈)程式語言 0.1 核心引擎與 CLI — Give intelligence a structure. Give structure a life.
|
|
5
|
+
Author: Soul Loop Soul Contributors
|
|
6
|
+
License: MIT License
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2026 Soul Loop Soul Contributors
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
furnished to do so, subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in all
|
|
18
|
+
copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
+
SOFTWARE.
|
|
27
|
+
|
|
28
|
+
Project-URL: Homepage, https://github.com/ShiroSakuraEGS/soul-loop-soul
|
|
29
|
+
Project-URL: Documentation, https://shirosakuraegs.github.io/soul-loop-soul/
|
|
30
|
+
Project-URL: Repository, https://github.com/ShiroSakuraEGS/soul-loop-soul
|
|
31
|
+
Project-URL: Issues, https://github.com/ShiroSakuraEGS/soul-loop-soul/issues
|
|
32
|
+
Keywords: programming-language,dsl,ai-agent,ai-character,orchestration,lark,mcp,soul-loop-soul
|
|
33
|
+
Classifier: Development Status :: 3 - Alpha
|
|
34
|
+
Classifier: Environment :: Console
|
|
35
|
+
Classifier: Intended Audience :: Developers
|
|
36
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
37
|
+
Classifier: Operating System :: OS Independent
|
|
38
|
+
Classifier: Programming Language :: Python :: 3
|
|
39
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
40
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
41
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
42
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
43
|
+
Classifier: Topic :: Software Development :: Compilers
|
|
44
|
+
Classifier: Topic :: Software Development :: Interpreters
|
|
45
|
+
Requires-Python: >=3.11
|
|
46
|
+
Description-Content-Type: text/markdown
|
|
47
|
+
License-File: LICENSE
|
|
48
|
+
Requires-Dist: lark>=1.2.2
|
|
49
|
+
Requires-Dist: pydantic>=2.8.0
|
|
50
|
+
Requires-Dist: PyYAML>=6.0.0
|
|
51
|
+
Requires-Dist: typer>=0.12.0
|
|
52
|
+
Requires-Dist: rich>=13.7.0
|
|
53
|
+
Requires-Dist: filetype>=1.2.0
|
|
54
|
+
Requires-Dist: beautifulsoup4>=4.12.0
|
|
55
|
+
Requires-Dist: html2text>=2024.2.26
|
|
56
|
+
Requires-Dist: httpx>=0.27.0
|
|
57
|
+
Provides-Extra: docs
|
|
58
|
+
Requires-Dist: pypdf>=5.0.0; extra == "docs"
|
|
59
|
+
Requires-Dist: python-docx>=1.1.0; extra == "docs"
|
|
60
|
+
Requires-Dist: openpyxl>=3.1.0; extra == "docs"
|
|
61
|
+
Requires-Dist: python-pptx>=1.0.0; extra == "docs"
|
|
62
|
+
Provides-Extra: llm
|
|
63
|
+
Requires-Dist: google-genai>=1.0.0; extra == "llm"
|
|
64
|
+
Requires-Dist: openai>=1.50.0; extra == "llm"
|
|
65
|
+
Provides-Extra: all
|
|
66
|
+
Requires-Dist: pypdf>=5.0.0; extra == "all"
|
|
67
|
+
Requires-Dist: python-docx>=1.1.0; extra == "all"
|
|
68
|
+
Requires-Dist: openpyxl>=3.1.0; extra == "all"
|
|
69
|
+
Requires-Dist: python-pptx>=1.0.0; extra == "all"
|
|
70
|
+
Requires-Dist: google-genai>=1.0.0; extra == "all"
|
|
71
|
+
Requires-Dist: openai>=1.50.0; extra == "all"
|
|
72
|
+
Provides-Extra: dev
|
|
73
|
+
Requires-Dist: pytest>=8.0.0; extra == "dev"
|
|
74
|
+
Requires-Dist: build>=1.2.0; extra == "dev"
|
|
75
|
+
Requires-Dist: twine>=5.0.0; extra == "dev"
|
|
76
|
+
Requires-Dist: pyinstaller>=6.10.0; extra == "dev"
|
|
77
|
+
|
|
78
|
+
<p align="center">
|
|
79
|
+
<img src="docs/assets/soul-logo.svg" alt="Soul Loop Soul Logo" width="110" />
|
|
80
|
+
</p>
|
|
81
|
+
|
|
82
|
+
<h1 align="center">Soul Loop Soul(自循環降靈)v0.1</h1>
|
|
83
|
+
|
|
84
|
+
<p align="center">
|
|
85
|
+
<em>Give intelligence a structure. Give structure a life.</em><br/>
|
|
86
|
+
<strong>讓智能有形,讓角色有魂,讓任務持續運行。</strong>
|
|
87
|
+
</p>
|
|
88
|
+
|
|
89
|
+
<p align="center">
|
|
90
|
+
<a href="LICENSE"><img src="https://img.shields.io/badge/License-MIT-22D3EE.svg" alt="MIT License" /></a>
|
|
91
|
+
<img src="https://img.shields.io/badge/Python-3.11%2B-3776AB.svg" alt="Python 3.11+" />
|
|
92
|
+
<img src="https://img.shields.io/badge/Extension-.souls-818CF8.svg" alt=".souls" />
|
|
93
|
+
<img src="https://img.shields.io/badge/Parser-LALR(1)%20Zero--Conflict-22C55E.svg" alt="LALR(1)" />
|
|
94
|
+
</p>
|
|
95
|
+
|
|
96
|
+
<p align="center">
|
|
97
|
+
<img src="docs/assets/soul-hero-visual.jpg" alt="Soul Loop Soul Hero Artwork" width="100%" />
|
|
98
|
+
</p>
|
|
99
|
+
|
|
100
|
+
**Soul Loop Soul(`.souls`)** 是一款以 **AI Character(AI 虛擬角色)** 與 **AI Agent(人工智能代理)** 為核心的領域專用程式語言與執行架構。它讓開發者、AI 角色設計師與 AI Agent 能將既有資料夾中分散的 System Prompt、角色設定、模型設定、API、MCP Server、知識文件與對話紀錄,透過確定性語法探索、識別、轉換、安全整理並組裝為可運行的 AI 個體。
|
|
101
|
+
|
|
102
|
+
- **官方互動展示網頁**:[ShiroSakuraEGS.github.io/soul-loop-soul](https://shirosakuraegs.github.io/soul-loop-soul/)(或本機直接開啟 `website/index.html`)即可體驗中英雙語語法 × 即時 Canonical IR 編譯對照、自循環引擎視覺化與原始碼導覽。
|
|
103
|
+
- **Windows 免安裝下載**:前往 [GitHub Releases](https://github.com/ShiroSakuraEGS/soul-loop-soul/releases/latest) 直接下載 `soul.exe`。
|
|
104
|
+
- **正式文法與語言規格**:詳見 [docs/SPEC_0.1.md](docs/SPEC_0.1.md)。
|
|
105
|
+
|
|
106
|
+
---
|
|
107
|
+
|
|
108
|
+
## 核心特色(v0.1)
|
|
109
|
+
|
|
110
|
+
1. **中英雙語共構 Canonical IR**:
|
|
111
|
+
- 支援中文語法(Mode A)、英文語法(Mode B)與中英混合語法(Mode C),自動正規化全形引號(`「」`)與標點(`:`、`。`)。
|
|
112
|
+
- 底層採用嚴格零衝突 **Lark LALR(1) + Indenter** 文法,中英文範例編譯出完全一致的內部語義表示(Canonical IR)。
|
|
113
|
+
2. **四層混合資源探索引擎(Structure Before Intelligence)**:
|
|
114
|
+
- **第一層**:Magic Bytes / MIME Type / 副檔名格式偵測與 SHA-256 重複資源檢查。
|
|
115
|
+
- **第二層**:確定性 AI 特徵 Pattern 辨識(模型、API、MCP、System Prompt、角色、Agent、記憶、知識、程式碼)。
|
|
116
|
+
- **第三層**:離線規則優先,僅針對低可信度檔案可選擇性掛接 LLM 語義分析(標記 `inferred_by_llm=True`)。
|
|
117
|
+
- **第四層**:跨檔案顯式參照與組裝鏈關聯圖推導(區分已確認參照與結構推測)。
|
|
118
|
+
3. **多格式資料轉換引擎(AI-Readable Markdown)**:
|
|
119
|
+
- 支援 `TXT`、`MD`、`PDF`(保留頁碼)、`DOCX`(保留標題與表格)、`HTML`、`CSV/TSV`、`JSON`、`YAML`、`XLSX`、`PPTX`、`XML`。
|
|
120
|
+
- 完整保留原檔於 `original/`、自動生成 `converted/*.md`、`metadata/*.json`、`document_index.json` 與 `knowledge_index.md`。
|
|
121
|
+
4. **Safe-by-Default 安全整理與權限防護**:
|
|
122
|
+
- 嚴格執行 `READ → ANALYZE → COPY → ORGANIZE → VERIFY`(不移動、不覆蓋、不刪除原檔)。
|
|
123
|
+
- 自動偵測疑似明文 API Key 並強制遮蔽(`[REDACTED:...]`),禁止外洩至 Markdown 或資源報告。
|
|
124
|
+
- 靜態掃描 Prompt Injection 特徵並封鎖外部未授權程式碼自動執行(`S016`)。
|
|
125
|
+
5. **多模型適配與防彈解析機制**:
|
|
126
|
+
- 支援 Google Gemini / Gemma 4(內建五層備援鏈:`gemma-4-31b-it` → `gemma-4-26b-a4b-it` → `gemini-2.5-flash` → `gemini-2.0-flash` → `gemini-1.5-flash`、Reasoning Shield、防彈 JSON 修復與 Prose-to-JSON 降級)、OpenAI 與本地 Ollama。
|
|
127
|
+
- 無 API Key 時預設純離線執行,並對缺少模型連線誠實回報(絕不假裝啟動成功)。
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
## 安裝與使用方式
|
|
132
|
+
|
|
133
|
+
### 方式 A:Windows 免安裝單檔執行檔(推薦給非工程師)
|
|
134
|
+
無需安裝 Python,直接執行專案打包好的 `dist/soul.exe`(或從 GitHub Releases 下載):
|
|
135
|
+
|
|
136
|
+
```powershell
|
|
137
|
+
.\dist\soul.exe version
|
|
138
|
+
.\dist\soul.exe parse examples\main_zh.souls
|
|
139
|
+
.\dist\soul.exe run examples\main_zh.souls --offline
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
如需自行從原始碼重新打包單檔執行檔:
|
|
143
|
+
|
|
144
|
+
```powershell
|
|
145
|
+
.\scripts\build_exe.ps1
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### 方式 B:透過 pip / uv 安裝(Python 3.11+)
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
# 安裝完整功能版(含 PDF/DOCX/XLSX/PPTX 與 Gemini/OpenAI 支援)
|
|
152
|
+
pip install "soul-loop-soul[all]"
|
|
153
|
+
|
|
154
|
+
# 或於本專案目錄開發模式安裝
|
|
155
|
+
pip install -e ".[all,dev]"
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
---
|
|
159
|
+
|
|
160
|
+
## 快速體驗(離線即可跑通)
|
|
161
|
+
|
|
162
|
+
```powershell
|
|
163
|
+
# 1. 解析並檢視中文版與英文版 Canonical IR
|
|
164
|
+
soul parse examples/main_zh.souls
|
|
165
|
+
soul parse examples/main_en.souls
|
|
166
|
+
|
|
167
|
+
# 2. 唯讀探索範例資料夾並產出資源報告
|
|
168
|
+
soul discover examples/sample_ai_project --report ./resource_report.md
|
|
169
|
+
|
|
170
|
+
# 3. 完整執行中文版主程式(離線模式,不修改任何原始檔)
|
|
171
|
+
soul run examples/main_zh.souls --offline
|
|
172
|
+
|
|
173
|
+
# 4. 查看執行期狀態與離線預覽對話介面
|
|
174
|
+
soul status
|
|
175
|
+
soul chat Aiko --offline-preview
|
|
176
|
+
|
|
177
|
+
# 5. 安全停止執行期狀態
|
|
178
|
+
soul stop
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
---
|
|
182
|
+
|
|
183
|
+
## CLI 指令總覽
|
|
184
|
+
|
|
185
|
+
| 指令 | 說明 |
|
|
186
|
+
|---|---|
|
|
187
|
+
| `soul init [dir]` | 建立標準 Soul Loop Soul 專案目錄結構與範本 `main.souls` |
|
|
188
|
+
| `soul parse <file.souls>` | 解析 `.souls` 程式、靜態檢查並輸出 Canonical IR(支援 `--json`) |
|
|
189
|
+
| `soul discover <folder>` | 執行四層混合資源探索、重複檢測與安全預警(支援 `--report` / `--llm`) |
|
|
190
|
+
| `soul convert <folder>` | 將支援格式轉換為 AI-Readable Markdown、Metadata 與知識索引 |
|
|
191
|
+
| `soul assemble <file.souls>` | 編譯並組裝 AI Character / Agent 規格包 |
|
|
192
|
+
| `soul run <file.souls>` | 完整執行探索 → 轉換 → 安全整理 → 組裝 → 驗證流程 |
|
|
193
|
+
| `soul chat <name>` | 開啟內建互動終端聊天介面(缺件時誠實列出缺少資源) |
|
|
194
|
+
| `soul status` | 檢查目前 Runtime 狀態、已組裝個體與硬體運算資源 |
|
|
195
|
+
| `soul stop` | 安全送出停止指令並更新 Runtime 狀態為 `STOPPED` |
|
|
196
|
+
|
|
197
|
+
---
|
|
198
|
+
|
|
199
|
+
## 專案架構
|
|
200
|
+
|
|
201
|
+
```text
|
|
202
|
+
自循環降靈/
|
|
203
|
+
├── LICENSE # MIT 開源授權條款
|
|
204
|
+
├── pyproject.toml # 標準 PyPI 套件配置與 soul CLI 入口
|
|
205
|
+
├── .github/workflows/ # CI 測試、PyPI + soul.exe Release、GitHub Pages 自動部署
|
|
206
|
+
├── docs/ # 語言規格書(SPEC_0.1.md)與品牌資產(Logo SVG / ICO)
|
|
207
|
+
├── website/ # 官方互動展示網頁(雙語對照、自循環視覺化、程式碼導覽)
|
|
208
|
+
├── scripts/ # Windows 免安裝 soul.exe 打包入口與腳本
|
|
209
|
+
├── examples/ # 中/英/混寫 .souls 範例與擬真 AI 素材資料夾
|
|
210
|
+
├── tests/ # 全套 pytest 自動化測試
|
|
211
|
+
└── src/soul_lang/
|
|
212
|
+
├── errors.py # 標準錯誤碼 S001–S016 與六欄位結構化錯誤報告
|
|
213
|
+
├── language/ # Layer 1:詞法正規化、嚴格 LALR(1) EBNF 文法、AST、IR 與語義檢查
|
|
214
|
+
├── security/ # Safe-by-Default 權限策略、Secret Manager/遮蔽器、Prompt Injection 防護
|
|
215
|
+
├── discovery/ # 四層混合資源探索與跨檔案關聯圖推導引擎
|
|
216
|
+
├── transform/ # 多格式文件轉 AI-Readable Markdown、Metadata 與索引引擎
|
|
217
|
+
├── organize/ # Safe Copy & SHA-256 驗證分類器、soul.manifest.yaml 與 resource_report.md
|
|
218
|
+
├── models_engine/ # Gemini/Gemma 4(五層備援 + 防彈解析)、OpenAI、Ollama 適配器
|
|
219
|
+
├── runtime/ # Layer 2 & 3:15 狀態 Loop 引擎、資源調度器、IR 執行器與狀態持久化
|
|
220
|
+
└── cli.py # Typer + Rich 命令列介面
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
---
|
|
224
|
+
|
|
225
|
+
## 執行自動化測試與打包
|
|
226
|
+
|
|
227
|
+
```powershell
|
|
228
|
+
# 執行全套測試
|
|
229
|
+
pytest -v
|
|
230
|
+
|
|
231
|
+
# 建置 PyPI sdist + wheel 封裝檔
|
|
232
|
+
python -m build
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
---
|
|
236
|
+
|
|
237
|
+
## 授權條款
|
|
238
|
+
|
|
239
|
+
本專案採用 [MIT License](LICENSE) 開源授權,歡迎自由使用、修改與二次分發。
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="docs/assets/soul-logo.svg" alt="Soul Loop Soul Logo" width="110" />
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<h1 align="center">Soul Loop Soul(自循環降靈)v0.1</h1>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<em>Give intelligence a structure. Give structure a life.</em><br/>
|
|
9
|
+
<strong>讓智能有形,讓角色有魂,讓任務持續運行。</strong>
|
|
10
|
+
</p>
|
|
11
|
+
|
|
12
|
+
<p align="center">
|
|
13
|
+
<a href="LICENSE"><img src="https://img.shields.io/badge/License-MIT-22D3EE.svg" alt="MIT License" /></a>
|
|
14
|
+
<img src="https://img.shields.io/badge/Python-3.11%2B-3776AB.svg" alt="Python 3.11+" />
|
|
15
|
+
<img src="https://img.shields.io/badge/Extension-.souls-818CF8.svg" alt=".souls" />
|
|
16
|
+
<img src="https://img.shields.io/badge/Parser-LALR(1)%20Zero--Conflict-22C55E.svg" alt="LALR(1)" />
|
|
17
|
+
</p>
|
|
18
|
+
|
|
19
|
+
<p align="center">
|
|
20
|
+
<img src="docs/assets/soul-hero-visual.jpg" alt="Soul Loop Soul Hero Artwork" width="100%" />
|
|
21
|
+
</p>
|
|
22
|
+
|
|
23
|
+
**Soul Loop Soul(`.souls`)** 是一款以 **AI Character(AI 虛擬角色)** 與 **AI Agent(人工智能代理)** 為核心的領域專用程式語言與執行架構。它讓開發者、AI 角色設計師與 AI Agent 能將既有資料夾中分散的 System Prompt、角色設定、模型設定、API、MCP Server、知識文件與對話紀錄,透過確定性語法探索、識別、轉換、安全整理並組裝為可運行的 AI 個體。
|
|
24
|
+
|
|
25
|
+
- **官方互動展示網頁**:[ShiroSakuraEGS.github.io/soul-loop-soul](https://shirosakuraegs.github.io/soul-loop-soul/)(或本機直接開啟 `website/index.html`)即可體驗中英雙語語法 × 即時 Canonical IR 編譯對照、自循環引擎視覺化與原始碼導覽。
|
|
26
|
+
- **Windows 免安裝下載**:前往 [GitHub Releases](https://github.com/ShiroSakuraEGS/soul-loop-soul/releases/latest) 直接下載 `soul.exe`。
|
|
27
|
+
- **正式文法與語言規格**:詳見 [docs/SPEC_0.1.md](docs/SPEC_0.1.md)。
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## 核心特色(v0.1)
|
|
32
|
+
|
|
33
|
+
1. **中英雙語共構 Canonical IR**:
|
|
34
|
+
- 支援中文語法(Mode A)、英文語法(Mode B)與中英混合語法(Mode C),自動正規化全形引號(`「」`)與標點(`:`、`。`)。
|
|
35
|
+
- 底層採用嚴格零衝突 **Lark LALR(1) + Indenter** 文法,中英文範例編譯出完全一致的內部語義表示(Canonical IR)。
|
|
36
|
+
2. **四層混合資源探索引擎(Structure Before Intelligence)**:
|
|
37
|
+
- **第一層**:Magic Bytes / MIME Type / 副檔名格式偵測與 SHA-256 重複資源檢查。
|
|
38
|
+
- **第二層**:確定性 AI 特徵 Pattern 辨識(模型、API、MCP、System Prompt、角色、Agent、記憶、知識、程式碼)。
|
|
39
|
+
- **第三層**:離線規則優先,僅針對低可信度檔案可選擇性掛接 LLM 語義分析(標記 `inferred_by_llm=True`)。
|
|
40
|
+
- **第四層**:跨檔案顯式參照與組裝鏈關聯圖推導(區分已確認參照與結構推測)。
|
|
41
|
+
3. **多格式資料轉換引擎(AI-Readable Markdown)**:
|
|
42
|
+
- 支援 `TXT`、`MD`、`PDF`(保留頁碼)、`DOCX`(保留標題與表格)、`HTML`、`CSV/TSV`、`JSON`、`YAML`、`XLSX`、`PPTX`、`XML`。
|
|
43
|
+
- 完整保留原檔於 `original/`、自動生成 `converted/*.md`、`metadata/*.json`、`document_index.json` 與 `knowledge_index.md`。
|
|
44
|
+
4. **Safe-by-Default 安全整理與權限防護**:
|
|
45
|
+
- 嚴格執行 `READ → ANALYZE → COPY → ORGANIZE → VERIFY`(不移動、不覆蓋、不刪除原檔)。
|
|
46
|
+
- 自動偵測疑似明文 API Key 並強制遮蔽(`[REDACTED:...]`),禁止外洩至 Markdown 或資源報告。
|
|
47
|
+
- 靜態掃描 Prompt Injection 特徵並封鎖外部未授權程式碼自動執行(`S016`)。
|
|
48
|
+
5. **多模型適配與防彈解析機制**:
|
|
49
|
+
- 支援 Google Gemini / Gemma 4(內建五層備援鏈:`gemma-4-31b-it` → `gemma-4-26b-a4b-it` → `gemini-2.5-flash` → `gemini-2.0-flash` → `gemini-1.5-flash`、Reasoning Shield、防彈 JSON 修復與 Prose-to-JSON 降級)、OpenAI 與本地 Ollama。
|
|
50
|
+
- 無 API Key 時預設純離線執行,並對缺少模型連線誠實回報(絕不假裝啟動成功)。
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## 安裝與使用方式
|
|
55
|
+
|
|
56
|
+
### 方式 A:Windows 免安裝單檔執行檔(推薦給非工程師)
|
|
57
|
+
無需安裝 Python,直接執行專案打包好的 `dist/soul.exe`(或從 GitHub Releases 下載):
|
|
58
|
+
|
|
59
|
+
```powershell
|
|
60
|
+
.\dist\soul.exe version
|
|
61
|
+
.\dist\soul.exe parse examples\main_zh.souls
|
|
62
|
+
.\dist\soul.exe run examples\main_zh.souls --offline
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
如需自行從原始碼重新打包單檔執行檔:
|
|
66
|
+
|
|
67
|
+
```powershell
|
|
68
|
+
.\scripts\build_exe.ps1
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### 方式 B:透過 pip / uv 安裝(Python 3.11+)
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
# 安裝完整功能版(含 PDF/DOCX/XLSX/PPTX 與 Gemini/OpenAI 支援)
|
|
75
|
+
pip install "soul-loop-soul[all]"
|
|
76
|
+
|
|
77
|
+
# 或於本專案目錄開發模式安裝
|
|
78
|
+
pip install -e ".[all,dev]"
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
## 快速體驗(離線即可跑通)
|
|
84
|
+
|
|
85
|
+
```powershell
|
|
86
|
+
# 1. 解析並檢視中文版與英文版 Canonical IR
|
|
87
|
+
soul parse examples/main_zh.souls
|
|
88
|
+
soul parse examples/main_en.souls
|
|
89
|
+
|
|
90
|
+
# 2. 唯讀探索範例資料夾並產出資源報告
|
|
91
|
+
soul discover examples/sample_ai_project --report ./resource_report.md
|
|
92
|
+
|
|
93
|
+
# 3. 完整執行中文版主程式(離線模式,不修改任何原始檔)
|
|
94
|
+
soul run examples/main_zh.souls --offline
|
|
95
|
+
|
|
96
|
+
# 4. 查看執行期狀態與離線預覽對話介面
|
|
97
|
+
soul status
|
|
98
|
+
soul chat Aiko --offline-preview
|
|
99
|
+
|
|
100
|
+
# 5. 安全停止執行期狀態
|
|
101
|
+
soul stop
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## CLI 指令總覽
|
|
107
|
+
|
|
108
|
+
| 指令 | 說明 |
|
|
109
|
+
|---|---|
|
|
110
|
+
| `soul init [dir]` | 建立標準 Soul Loop Soul 專案目錄結構與範本 `main.souls` |
|
|
111
|
+
| `soul parse <file.souls>` | 解析 `.souls` 程式、靜態檢查並輸出 Canonical IR(支援 `--json`) |
|
|
112
|
+
| `soul discover <folder>` | 執行四層混合資源探索、重複檢測與安全預警(支援 `--report` / `--llm`) |
|
|
113
|
+
| `soul convert <folder>` | 將支援格式轉換為 AI-Readable Markdown、Metadata 與知識索引 |
|
|
114
|
+
| `soul assemble <file.souls>` | 編譯並組裝 AI Character / Agent 規格包 |
|
|
115
|
+
| `soul run <file.souls>` | 完整執行探索 → 轉換 → 安全整理 → 組裝 → 驗證流程 |
|
|
116
|
+
| `soul chat <name>` | 開啟內建互動終端聊天介面(缺件時誠實列出缺少資源) |
|
|
117
|
+
| `soul status` | 檢查目前 Runtime 狀態、已組裝個體與硬體運算資源 |
|
|
118
|
+
| `soul stop` | 安全送出停止指令並更新 Runtime 狀態為 `STOPPED` |
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
## 專案架構
|
|
123
|
+
|
|
124
|
+
```text
|
|
125
|
+
自循環降靈/
|
|
126
|
+
├── LICENSE # MIT 開源授權條款
|
|
127
|
+
├── pyproject.toml # 標準 PyPI 套件配置與 soul CLI 入口
|
|
128
|
+
├── .github/workflows/ # CI 測試、PyPI + soul.exe Release、GitHub Pages 自動部署
|
|
129
|
+
├── docs/ # 語言規格書(SPEC_0.1.md)與品牌資產(Logo SVG / ICO)
|
|
130
|
+
├── website/ # 官方互動展示網頁(雙語對照、自循環視覺化、程式碼導覽)
|
|
131
|
+
├── scripts/ # Windows 免安裝 soul.exe 打包入口與腳本
|
|
132
|
+
├── examples/ # 中/英/混寫 .souls 範例與擬真 AI 素材資料夾
|
|
133
|
+
├── tests/ # 全套 pytest 自動化測試
|
|
134
|
+
└── src/soul_lang/
|
|
135
|
+
├── errors.py # 標準錯誤碼 S001–S016 與六欄位結構化錯誤報告
|
|
136
|
+
├── language/ # Layer 1:詞法正規化、嚴格 LALR(1) EBNF 文法、AST、IR 與語義檢查
|
|
137
|
+
├── security/ # Safe-by-Default 權限策略、Secret Manager/遮蔽器、Prompt Injection 防護
|
|
138
|
+
├── discovery/ # 四層混合資源探索與跨檔案關聯圖推導引擎
|
|
139
|
+
├── transform/ # 多格式文件轉 AI-Readable Markdown、Metadata 與索引引擎
|
|
140
|
+
├── organize/ # Safe Copy & SHA-256 驗證分類器、soul.manifest.yaml 與 resource_report.md
|
|
141
|
+
├── models_engine/ # Gemini/Gemma 4(五層備援 + 防彈解析)、OpenAI、Ollama 適配器
|
|
142
|
+
├── runtime/ # Layer 2 & 3:15 狀態 Loop 引擎、資源調度器、IR 執行器與狀態持久化
|
|
143
|
+
└── cli.py # Typer + Rich 命令列介面
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
## 執行自動化測試與打包
|
|
149
|
+
|
|
150
|
+
```powershell
|
|
151
|
+
# 執行全套測試
|
|
152
|
+
pytest -v
|
|
153
|
+
|
|
154
|
+
# 建置 PyPI sdist + wheel 封裝檔
|
|
155
|
+
python -m build
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
---
|
|
159
|
+
|
|
160
|
+
## 授權條款
|
|
161
|
+
|
|
162
|
+
本專案採用 [MIT License](LICENSE) 開源授權,歡迎自由使用、修改與二次分發。
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "soul-loop-soul"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Soul Loop Soul(自循環降靈)程式語言 0.1 核心引擎與 CLI — Give intelligence a structure. Give structure a life."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.11"
|
|
11
|
+
license = {file = "LICENSE"}
|
|
12
|
+
authors = [
|
|
13
|
+
{name = "Soul Loop Soul Contributors"}
|
|
14
|
+
]
|
|
15
|
+
keywords = [
|
|
16
|
+
"programming-language",
|
|
17
|
+
"dsl",
|
|
18
|
+
"ai-agent",
|
|
19
|
+
"ai-character",
|
|
20
|
+
"orchestration",
|
|
21
|
+
"lark",
|
|
22
|
+
"mcp",
|
|
23
|
+
"soul-loop-soul",
|
|
24
|
+
]
|
|
25
|
+
classifiers = [
|
|
26
|
+
"Development Status :: 3 - Alpha",
|
|
27
|
+
"Environment :: Console",
|
|
28
|
+
"Intended Audience :: Developers",
|
|
29
|
+
"License :: OSI Approved :: MIT License",
|
|
30
|
+
"Operating System :: OS Independent",
|
|
31
|
+
"Programming Language :: Python :: 3",
|
|
32
|
+
"Programming Language :: Python :: 3.11",
|
|
33
|
+
"Programming Language :: Python :: 3.12",
|
|
34
|
+
"Programming Language :: Python :: 3.13",
|
|
35
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
36
|
+
"Topic :: Software Development :: Compilers",
|
|
37
|
+
"Topic :: Software Development :: Interpreters",
|
|
38
|
+
]
|
|
39
|
+
dependencies = [
|
|
40
|
+
"lark>=1.2.2",
|
|
41
|
+
"pydantic>=2.8.0",
|
|
42
|
+
"PyYAML>=6.0.0",
|
|
43
|
+
"typer>=0.12.0",
|
|
44
|
+
"rich>=13.7.0",
|
|
45
|
+
"filetype>=1.2.0",
|
|
46
|
+
"beautifulsoup4>=4.12.0",
|
|
47
|
+
"html2text>=2024.2.26",
|
|
48
|
+
"httpx>=0.27.0",
|
|
49
|
+
]
|
|
50
|
+
|
|
51
|
+
[project.optional-dependencies]
|
|
52
|
+
docs = [
|
|
53
|
+
"pypdf>=5.0.0",
|
|
54
|
+
"python-docx>=1.1.0",
|
|
55
|
+
"openpyxl>=3.1.0",
|
|
56
|
+
"python-pptx>=1.0.0",
|
|
57
|
+
]
|
|
58
|
+
llm = [
|
|
59
|
+
"google-genai>=1.0.0",
|
|
60
|
+
"openai>=1.50.0",
|
|
61
|
+
]
|
|
62
|
+
all = [
|
|
63
|
+
"pypdf>=5.0.0",
|
|
64
|
+
"python-docx>=1.1.0",
|
|
65
|
+
"openpyxl>=3.1.0",
|
|
66
|
+
"python-pptx>=1.0.0",
|
|
67
|
+
"google-genai>=1.0.0",
|
|
68
|
+
"openai>=1.50.0",
|
|
69
|
+
]
|
|
70
|
+
dev = [
|
|
71
|
+
"pytest>=8.0.0",
|
|
72
|
+
"build>=1.2.0",
|
|
73
|
+
"twine>=5.0.0",
|
|
74
|
+
"pyinstaller>=6.10.0",
|
|
75
|
+
]
|
|
76
|
+
|
|
77
|
+
[project.urls]
|
|
78
|
+
Homepage = "https://github.com/ShiroSakuraEGS/soul-loop-soul"
|
|
79
|
+
Documentation = "https://shirosakuraegs.github.io/soul-loop-soul/"
|
|
80
|
+
Repository = "https://github.com/ShiroSakuraEGS/soul-loop-soul"
|
|
81
|
+
Issues = "https://github.com/ShiroSakuraEGS/soul-loop-soul/issues"
|
|
82
|
+
|
|
83
|
+
[project.scripts]
|
|
84
|
+
soul = "soul_lang.cli:app"
|
|
85
|
+
|
|
86
|
+
[tool.setuptools.packages.find]
|
|
87
|
+
where = ["src"]
|
|
88
|
+
|
|
89
|
+
[tool.setuptools.package-data]
|
|
90
|
+
soul_lang = ["language/*.lark"]
|
|
91
|
+
|
|
92
|
+
[tool.pytest.ini_options]
|
|
93
|
+
testpaths = ["tests"]
|
|
94
|
+
pythonpath = ["src"]
|