illusion-code 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.
Files changed (214) hide show
  1. illusion/__init__.py +24 -0
  2. illusion/__main__.py +15 -0
  3. illusion/_frontend/dist/index.mjs +39208 -0
  4. illusion/_frontend/package.json +27 -0
  5. illusion/_frontend/src/App.tsx +624 -0
  6. illusion/_frontend/src/components/CommandPicker.tsx +98 -0
  7. illusion/_frontend/src/components/Composer.tsx +55 -0
  8. illusion/_frontend/src/components/ComposerController.tsx +128 -0
  9. illusion/_frontend/src/components/ConversationView.tsx +750 -0
  10. illusion/_frontend/src/components/Footer.tsx +25 -0
  11. illusion/_frontend/src/components/MarkdownContent.tsx +537 -0
  12. illusion/_frontend/src/components/MarkdownTable.tsx +245 -0
  13. illusion/_frontend/src/components/ModalHost.tsx +425 -0
  14. illusion/_frontend/src/components/MultilineTextInput.tsx +250 -0
  15. illusion/_frontend/src/components/PromptInput.tsx +64 -0
  16. illusion/_frontend/src/components/SelectModal.tsx +78 -0
  17. illusion/_frontend/src/components/SidePanel.tsx +175 -0
  18. illusion/_frontend/src/components/Spinner.tsx +77 -0
  19. illusion/_frontend/src/components/StatusBar.tsx +142 -0
  20. illusion/_frontend/src/components/SwarmPanel.tsx +141 -0
  21. illusion/_frontend/src/components/TodoPanel.tsx +126 -0
  22. illusion/_frontend/src/components/ToolCallDisplay.tsx +202 -0
  23. illusion/_frontend/src/components/TranscriptPane.tsx +79 -0
  24. illusion/_frontend/src/components/WelcomeBanner.tsx +37 -0
  25. illusion/_frontend/src/hooks/useBackendSession.ts +468 -0
  26. illusion/_frontend/src/hooks/useTerminalSize.ts +9 -0
  27. illusion/_frontend/src/i18n.ts +78 -0
  28. illusion/_frontend/src/index.tsx +42 -0
  29. illusion/_frontend/src/theme/ThemeContext.tsx +19 -0
  30. illusion/_frontend/src/theme/builtinThemes.ts +89 -0
  31. illusion/_frontend/src/types.ts +110 -0
  32. illusion/_frontend/src/utils/markdown.ts +33 -0
  33. illusion/_frontend/src/utils/thinking.ts +191 -0
  34. illusion/_frontend/tsconfig.json +13 -0
  35. illusion/_web_dist/assets/index-BseIw-ik.css +10 -0
  36. illusion/_web_dist/assets/index-C_0ZWMuW.js +82 -0
  37. illusion/_web_dist/index.html +16 -0
  38. illusion/api/__init__.py +36 -0
  39. illusion/api/client.py +568 -0
  40. illusion/api/codex_client.py +563 -0
  41. illusion/api/compat.py +138 -0
  42. illusion/api/effort.py +128 -0
  43. illusion/api/errors.py +57 -0
  44. illusion/api/openai_client.py +819 -0
  45. illusion/api/provider.py +148 -0
  46. illusion/api/registry.py +479 -0
  47. illusion/api/usage.py +45 -0
  48. illusion/auth/__init__.py +50 -0
  49. illusion/auth/copilot.py +419 -0
  50. illusion/auth/external.py +612 -0
  51. illusion/auth/flows.py +58 -0
  52. illusion/auth/manager.py +214 -0
  53. illusion/auth/storage.py +372 -0
  54. illusion/bridge/__init__.py +38 -0
  55. illusion/bridge/manager.py +190 -0
  56. illusion/bridge/session_runner.py +84 -0
  57. illusion/bridge/types.py +113 -0
  58. illusion/bridge/work_secret.py +131 -0
  59. illusion/cli.py +1228 -0
  60. illusion/commands/__init__.py +32 -0
  61. illusion/commands/registry.py +1934 -0
  62. illusion/config/__init__.py +39 -0
  63. illusion/config/i18n.py +522 -0
  64. illusion/config/paths.py +259 -0
  65. illusion/config/settings.py +564 -0
  66. illusion/coordinator/__init__.py +41 -0
  67. illusion/coordinator/agent_definitions.py +1093 -0
  68. illusion/coordinator/coordinator_mode.py +127 -0
  69. illusion/engine/__init__.py +95 -0
  70. illusion/engine/cost_tracker.py +55 -0
  71. illusion/engine/messages.py +369 -0
  72. illusion/engine/query.py +632 -0
  73. illusion/engine/query_engine.py +343 -0
  74. illusion/engine/stream_events.py +169 -0
  75. illusion/hooks/__init__.py +67 -0
  76. illusion/hooks/events.py +43 -0
  77. illusion/hooks/executor.py +397 -0
  78. illusion/hooks/hot_reload.py +74 -0
  79. illusion/hooks/loader.py +133 -0
  80. illusion/hooks/schemas.py +121 -0
  81. illusion/hooks/types.py +86 -0
  82. illusion/mcp/__init__.py +104 -0
  83. illusion/mcp/client.py +377 -0
  84. illusion/mcp/config.py +140 -0
  85. illusion/mcp/types.py +175 -0
  86. illusion/memory/__init__.py +36 -0
  87. illusion/memory/manager.py +94 -0
  88. illusion/memory/memdir.py +58 -0
  89. illusion/memory/paths.py +57 -0
  90. illusion/memory/scan.py +120 -0
  91. illusion/memory/search.py +83 -0
  92. illusion/memory/types.py +43 -0
  93. illusion/output_styles/__init__.py +15 -0
  94. illusion/output_styles/loader.py +64 -0
  95. illusion/permissions/__init__.py +39 -0
  96. illusion/permissions/checker.py +174 -0
  97. illusion/permissions/modes.py +38 -0
  98. illusion/platforms.py +148 -0
  99. illusion/plugins/__init__.py +71 -0
  100. illusion/plugins/bundled/__init__.py +0 -0
  101. illusion/plugins/installer.py +59 -0
  102. illusion/plugins/loader.py +301 -0
  103. illusion/plugins/schemas.py +51 -0
  104. illusion/plugins/types.py +56 -0
  105. illusion/prompts/__init__.py +29 -0
  106. illusion/prompts/claudemd.py +74 -0
  107. illusion/prompts/context.py +187 -0
  108. illusion/prompts/environment.py +189 -0
  109. illusion/prompts/system_prompt.py +155 -0
  110. illusion/py.typed +0 -0
  111. illusion/sandbox/__init__.py +29 -0
  112. illusion/sandbox/adapter.py +174 -0
  113. illusion/services/__init__.py +59 -0
  114. illusion/services/compact/__init__.py +1015 -0
  115. illusion/services/cron.py +338 -0
  116. illusion/services/cron_scheduler.py +715 -0
  117. illusion/services/file_history.py +258 -0
  118. illusion/services/lsp/__init__.py +455 -0
  119. illusion/services/session_storage.py +237 -0
  120. illusion/services/token_estimation.py +72 -0
  121. illusion/skills/__init__.py +60 -0
  122. illusion/skills/bundled/__init__.py +110 -0
  123. illusion/skills/bundled/content/batch.md +86 -0
  124. illusion/skills/bundled/content/coding-guidelines.md +70 -0
  125. illusion/skills/bundled/content/debug.md +38 -0
  126. illusion/skills/bundled/content/loop.md +82 -0
  127. illusion/skills/bundled/content/remember.md +105 -0
  128. illusion/skills/bundled/content/simplify.md +53 -0
  129. illusion/skills/bundled/content/skillify.md +113 -0
  130. illusion/skills/bundled/content/stuck.md +54 -0
  131. illusion/skills/bundled/content/update-config.md +329 -0
  132. illusion/skills/bundled/content/verify.md +74 -0
  133. illusion/skills/loader.py +219 -0
  134. illusion/skills/registry.py +40 -0
  135. illusion/skills/types.py +24 -0
  136. illusion/state/__init__.py +18 -0
  137. illusion/state/app_state.py +67 -0
  138. illusion/state/store.py +93 -0
  139. illusion/swarm/__init__.py +71 -0
  140. illusion/swarm/agent_executor.py +857 -0
  141. illusion/swarm/in_process.py +259 -0
  142. illusion/swarm/subprocess_backend.py +136 -0
  143. illusion/swarm/team_helpers.py +123 -0
  144. illusion/swarm/types.py +159 -0
  145. illusion/swarm/worktree.py +347 -0
  146. illusion/tasks/__init__.py +33 -0
  147. illusion/tasks/local_agent_task.py +42 -0
  148. illusion/tasks/local_shell_task.py +27 -0
  149. illusion/tasks/manager.py +377 -0
  150. illusion/tasks/stop_task.py +21 -0
  151. illusion/tasks/types.py +88 -0
  152. illusion/tools/__init__.py +126 -0
  153. illusion/tools/agent_tool.py +388 -0
  154. illusion/tools/ask_user_question_tool.py +186 -0
  155. illusion/tools/base.py +149 -0
  156. illusion/tools/bash_tool.py +413 -0
  157. illusion/tools/config_tool.py +90 -0
  158. illusion/tools/cron_tool.py +473 -0
  159. illusion/tools/enter_plan_mode_tool.py +147 -0
  160. illusion/tools/enter_worktree_tool.py +188 -0
  161. illusion/tools/exit_plan_mode_tool.py +69 -0
  162. illusion/tools/exit_worktree_tool.py +225 -0
  163. illusion/tools/file_edit_tool.py +283 -0
  164. illusion/tools/file_read_tool.py +294 -0
  165. illusion/tools/file_write_tool.py +184 -0
  166. illusion/tools/glob_tool.py +165 -0
  167. illusion/tools/grep_tool.py +190 -0
  168. illusion/tools/list_mcp_resources_tool.py +80 -0
  169. illusion/tools/lsp_tool.py +333 -0
  170. illusion/tools/mcp_auth_tool.py +100 -0
  171. illusion/tools/mcp_tool.py +75 -0
  172. illusion/tools/notebook_edit_tool.py +242 -0
  173. illusion/tools/powershell_tool.py +334 -0
  174. illusion/tools/read_mcp_resource_tool.py +63 -0
  175. illusion/tools/repl_tool.py +100 -0
  176. illusion/tools/send_message_tool.py +112 -0
  177. illusion/tools/shell_common.py +187 -0
  178. illusion/tools/skill_tool.py +86 -0
  179. illusion/tools/sleep_tool.py +62 -0
  180. illusion/tools/structured_output_tool.py +58 -0
  181. illusion/tools/task_create_tool.py +98 -0
  182. illusion/tools/task_get_tool.py +94 -0
  183. illusion/tools/task_list_tool.py +94 -0
  184. illusion/tools/task_output_tool.py +55 -0
  185. illusion/tools/task_stop_tool.py +52 -0
  186. illusion/tools/task_update_tool.py +224 -0
  187. illusion/tools/team_create_tool.py +236 -0
  188. illusion/tools/team_delete_tool.py +104 -0
  189. illusion/tools/todo_write_tool.py +198 -0
  190. illusion/tools/tool_search_tool.py +156 -0
  191. illusion/tools/web_fetch_tool.py +264 -0
  192. illusion/tools/web_search_tool.py +186 -0
  193. illusion/ui/__init__.py +23 -0
  194. illusion/ui/app.py +258 -0
  195. illusion/ui/backend_host.py +1180 -0
  196. illusion/ui/input.py +86 -0
  197. illusion/ui/output.py +363 -0
  198. illusion/ui/permission_dialog.py +47 -0
  199. illusion/ui/permission_store.py +99 -0
  200. illusion/ui/protocol.py +384 -0
  201. illusion/ui/react_launcher.py +280 -0
  202. illusion/ui/runtime.py +787 -0
  203. illusion/ui/textual_app.py +603 -0
  204. illusion/ui/web/__init__.py +10 -0
  205. illusion/ui/web/server.py +87 -0
  206. illusion/ui/web/ws_host.py +1197 -0
  207. illusion/utils/__init__.py +0 -0
  208. illusion/utils/ripgrep.py +299 -0
  209. illusion/utils/shell.py +248 -0
  210. illusion_code-0.1.0.dist-info/METADATA +1159 -0
  211. illusion_code-0.1.0.dist-info/RECORD +214 -0
  212. illusion_code-0.1.0.dist-info/WHEEL +4 -0
  213. illusion_code-0.1.0.dist-info/entry_points.txt +2 -0
  214. illusion_code-0.1.0.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,1159 @@
1
+ Metadata-Version: 2.4
2
+ Name: illusion-code
3
+ Version: 0.1.0
4
+ Summary: Open-source Python port of Claude Code - an AI-powered CLI coding assistant
5
+ Project-URL: Homepage, https://github.com/YunTaiHua/illusion-code
6
+ Project-URL: Repository, https://github.com/YunTaiHua/illusion-code
7
+ Project-URL: Issues, https://github.com/YunTaiHua/illusion-code/issues
8
+ Author-email: YunTaiHua <3597489498@qq.com>
9
+ License-Expression: MIT
10
+ License-File: LICENSE
11
+ Keywords: ai,claude-code,cli,coding-agent,llm,terminal
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Environment :: Console
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
23
+ Requires-Python: >=3.10
24
+ Requires-Dist: anthropic>=0.40.0
25
+ Requires-Dist: croniter>=2.0.0
26
+ Requires-Dist: fastapi>=0.115.0
27
+ Requires-Dist: httpx>=0.27.0
28
+ Requires-Dist: mcp>=1.0.0
29
+ Requires-Dist: openai>=1.0.0
30
+ Requires-Dist: prompt-toolkit>=3.0.0
31
+ Requires-Dist: pydantic>=2.0.0
32
+ Requires-Dist: pyperclip>=1.9.0
33
+ Requires-Dist: pyyaml>=6.0
34
+ Requires-Dist: rich>=13.0.0
35
+ Requires-Dist: textual>=0.80.0
36
+ Requires-Dist: typer>=0.12.0
37
+ Requires-Dist: uvicorn[standard]>=0.34.0
38
+ Requires-Dist: watchfiles>=0.20.0
39
+ Requires-Dist: websockets>=12.0
40
+ Provides-Extra: dev
41
+ Requires-Dist: mypy>=1.10.0; extra == 'dev'
42
+ Requires-Dist: pexpect>=4.9.0; extra == 'dev'
43
+ Requires-Dist: pytest-asyncio>=0.23.0; extra == 'dev'
44
+ Requires-Dist: pytest-cov>=5.0.0; extra == 'dev'
45
+ Requires-Dist: pytest>=8.0.0; extra == 'dev'
46
+ Requires-Dist: ruff>=0.5.0; extra == 'dev'
47
+ Description-Content-Type: text/markdown
48
+
49
+ # IllusionCode
50
+
51
+ <div align="center">
52
+
53
+ **AI-Powered Command-Line Programming Assistant**
54
+
55
+ *The best of many worlds, unified into one intelligent coding tool*
56
+
57
+ [ไธญๆ–‡็‰ˆ](README.zh-CN.md) | English
58
+
59
+ </div>
60
+
61
+ ---
62
+
63
+ ## ๐Ÿ“– Introduction
64
+
65
+ IllusionCode is an open-source AI-powered command-line programming assistant that brings together the best ideas from many projects and adds its own innovations. It inherits Claude Code's complete prompt system and tool architecture, draws inspiration from OpenHarness's Python architecture design, uses the same Cron task scheduling architecture as OpenClaw, and implements flexible proxy routing through cc-switch. On this foundation, IllusionCode provides deep Windows optimization, full bilingual (Chinese/English) interface support, more comprehensive Markdown terminal rendering than comparable projects, and a browser-based Web UI for a modern chat experience.
66
+
67
+ ### Core Features
68
+
69
+ - ๐ŸŒ **Web UI Interface** - Browser-based chat interface with `illusion web`, featuring warm color design, session management, and real-time streaming (supplementary to the recommended terminal interface)
70
+ - ๐ŸชŸ **Deep Windows Optimization** - Auto-detect Git, PowerShell support, path compatibility optimization
71
+ - ๐Ÿ–ฅ๏ธ **Zero Terminal Flicker** - Stable rendering based on Ink Static component, suppressing resize event interference
72
+ - ๐ŸŒ **Bilingual Interface** - All CLI output automatically switches between Chinese and English based on `ui_language` setting
73
+ - ๐Ÿ“ **Comprehensive Markdown Rendering** - Box-drawing tables, rounded card-style code blocks, multi-color rich text, links and more
74
+ - ๐Ÿ“‚ **Project-Level Config Friendly** - Auto-generate skills, rules, mcp, plugins directories, project-level skills override global ones
75
+ - ๐Ÿค– **Multi AI Provider Support** - Anthropic Claude, OpenAI, GitHub Copilot, OpenAI Codex, and any OpenAI-compatible endpoint
76
+ - ๐Ÿ› ๏ธ **Rich Toolset** - 34 built-in tools + MCP dynamic tool extension
77
+ - โŒจ๏ธ **47 Slash Commands** - Covering session management, configuration, project operations, task scheduling, etc.
78
+ - ๐Ÿง  **Multi-Agent Collaboration** - 7 built-in specialized Agents, supporting task orchestration
79
+ - ๐Ÿ”Œ **Flexible Extension System** - Plugins, hooks, skills, MCP servers
80
+ - ๐Ÿ” **Comprehensive Permission Control** - Three modes + fine-grained rules + Always Allow one-click approval
81
+ - ๐Ÿ’พ **Memory & Context** - Project knowledge persistence and dynamic retrieval
82
+ - ๐ŸŽจ **Dual Interface** - Modern React + Ink terminal TUI + browser-based Web UI
83
+ - ๐ŸŽฏ **Reasoning Effort Control** - Supports low/medium/high/xhigh/max five reasoning effort levels with automatic fallback
84
+
85
+ ### Interface Preview
86
+
87
+ <div align="center">
88
+ <p>Welcome screen & rich text rendering</p>
89
+ <img src="docs/images/image1.png" alt="IllusionCode welcome screen" width="48%" />
90
+ <img src="docs/images/image2.png" alt="IllusionCode rich text rendering" width="48%" />
91
+ </div>
92
+
93
+ <div align="center">
94
+ <p>Demo video</p>
95
+ <a href="https://www.youtube.com/watch?v=Hongxz0vhrg">
96
+ <img src="docs/images/image1.png" alt="Click to watch demo video" width="720" />
97
+ </a>
98
+ <p><a href="https://www.youtube.com/watch?v=Hongxz0vhrg">๐Ÿ“บ Watch demo on YouTube</a></p>
99
+ </div>
100
+
101
+ ### Design Origins & Innovations
102
+
103
+ **Inherited from Claude Code**: Complete injection of Claude Code's system prompts, tool definitions, permission model, and multi-agent coordination architecture, ensuring behavioral consistency.
104
+
105
+ **Inspired by OpenHarness**: Python architecture design references OpenHarness's ideas.
106
+
107
+ **Cron Architecture Aligned with OpenClaw**: The scheduled task system uses the same scheduler architecture as OpenClaw, supporting independent session execution, execution history tracking, and consecutive error monitoring.
108
+
109
+ **cc-switch Proxy Routing**: Local proxy routing through the cc-switch reverse proxy tool, supporting request forwarding to different AI providers.
110
+
111
+ **Deep Windows Optimization**: Auto-detect Git installation path, unified PowerShell and Bash tool processing, automatic path separator compatibility, out-of-the-box experience for Windows users.
112
+
113
+ **Zero Terminal Flicker**: Uses Ink `<Static>` component architecture, static rendering for completed messages, dynamic rendering for streaming messages, completely solving terminal flicker issues.
114
+
115
+ **Bilingual Interface**: All CLI output (auth, mcp, plugin, cron, session, etc.) automatically switches language via the i18n system based on the `ui_language` field. Language preference can be selected on first run.
116
+
117
+ **Comprehensive Markdown Rendering**: Full rendering of box-drawing tables, rounded card-style code blocks, multi-color rich text (bold, italic, inline code, links), significantly improving AI response readability.
118
+
119
+ **Project-Level Config Automation**: Auto-generate `<project>/.illusion/rules/` and `<project>/.illusion/skills/` directories, project-level configuration takes precedence over global configuration, facilitating team collaboration.
120
+
121
+ **Web UI Interface**: Browser-based chat interface powered by React + Vite + Tailwind CSS frontend and FastAPI + WebSocket backend. Features warm color design, session management, sidebar navigation, real-time streaming responses, right panel with context usage display, and full i18n support. Launch with `illusion web`. Note: The terminal interface is recommended as the primary mode for full feature support and better performance; the Web UI is intended as a supplementary option for scenarios where a terminal is unavailable.
122
+
123
+ ---
124
+
125
+ ## ๐Ÿš€ Quick Start
126
+
127
+ ### Requirements
128
+
129
+ - Python >= 3.10
130
+ - Node.js (for frontend TUI)
131
+ - Supports Windows, macOS, Linux
132
+ - Windows users: Auto-detect Git, no manual PATH configuration needed
133
+
134
+ ### Installation
135
+
136
+ #### Recommended: pip install (one-step setup)
137
+
138
+ `pip install .` triggers the hatch build hook to automatically build both frontends (terminal TUI and Web UI), and registers the `illusion` command globally. This is the simplest way to get started.
139
+
140
+ ```bash
141
+ git clone https://github.com/your-repo/illusion-code.git
142
+ cd illusion-code
143
+ pip install .
144
+ ```
145
+
146
+ After installation, `illusion` is available globally from any directory. Requires Node.js 18+ (for frontend build).
147
+
148
+ #### Alternative: uv sync (for development)
149
+
150
+ `uv sync` creates an editable install within the project directory. It does **not** trigger the hatch build hook, so you must build frontends manually. This is recommended for developers who want to modify the source code.
151
+
152
+ ```bash
153
+ git clone https://github.com/your-repo/illusion-code.git
154
+ cd illusion-code
155
+ uv sync
156
+
157
+ # Build frontends manually (required after uv sync)
158
+ python scripts/build_frontend.py # Build both
159
+ python scripts/build_frontend.py --terminal # Terminal TUI only
160
+ python scripts/build_frontend.py --web # Web UI only
161
+ ```
162
+
163
+ > **Note**: `uv sync` does NOT register `illusion` globally. To use it:
164
+ >
165
+ > ```bash
166
+ > # Option 1: Use uv run from the project directory
167
+ > cd illusion-code
168
+ > uv run illusion
169
+ >
170
+ > # Option 2: Activate the virtual environment
171
+ > # Windows
172
+ > .venv\Scripts\activate
173
+ > # macOS / Linux
174
+ > source .venv/bin/activate
175
+ > illusion
176
+ >
177
+ > # Option 3: Install globally with pip (recommended)
178
+ > pip install .
179
+ > ```
180
+
181
+ #### Manual frontend build (for both methods)
182
+
183
+ If you need to rebuild frontends manually (e.g., after updating frontend code):
184
+
185
+ **Build script (recommended)**
186
+
187
+ ```bash
188
+ python scripts/build_frontend.py # Build both
189
+ python scripts/build_frontend.py --terminal # Terminal TUI only
190
+ python scripts/build_frontend.py --web # Web UI only
191
+ ```
192
+
193
+ **npm directly**
194
+
195
+ ```bash
196
+ # Terminal TUI (esbuild โ†’ dist/index.mjs)
197
+ cd frontend/terminal
198
+ npm install --no-fund --no-audit
199
+ npm run build
200
+ cd ../..
201
+
202
+ # Web UI (Vite โ†’ dist/)
203
+ cd frontend/web
204
+ npm install --no-fund --no-audit
205
+ npm run build
206
+ cd ../..
207
+ ```
208
+
209
+ #### Key differences
210
+
211
+ | | `pip install .` | `uv sync` |
212
+ |---|---|---|
213
+ | Frontend build | Automatic (hatch hook) | Manual |
214
+ | `illusion` command | Global | Project-only (via `uv run` or venv activation) |
215
+ | Install type | Standard | Editable |
216
+ | Best for | End users | Developers |
217
+
218
+ ### Basic Usage
219
+
220
+ > **First-time setup**: Run `illusion auth login` first to configure your API credentials. Without authentication (or if the model is unavailable), the program may exit with an error code.
221
+
222
+ ```bash
223
+ # First-time: configure authentication
224
+ illusion auth login
225
+
226
+ # Start interactive session (recommended)
227
+ illusion
228
+
229
+ # Launch Web UI in browser
230
+ illusion web
231
+
232
+ # Web UI with custom port
233
+ illusion web --port 8080
234
+
235
+ # Non-interactive print mode
236
+ illusion -p "Analyze the structure of this project"
237
+
238
+ # Specify model
239
+ illusion -m env_1.model_2
240
+
241
+ # Continue most recent session
242
+ illusion --continue
243
+
244
+ # Restore specific session
245
+ illusion --resume <session-id>
246
+
247
+ # Set permission mode
248
+ illusion --permission-mode full_auto
249
+
250
+ # Specify API format
251
+ illusion --api-format openai
252
+ ```
253
+
254
+ > **Note**: The terminal interface (`illusion`) is the recommended primary mode. The Web UI (`illusion web`) is a supplementary option for scenarios where a terminal is unavailable.
255
+
256
+ ---
257
+
258
+ ## ๐Ÿ“š Command System
259
+
260
+ ### Subcommands
261
+
262
+ ```bash
263
+ # Web UI
264
+ illusion web # Launch Web UI in browser (default port 3000)
265
+ illusion web --port 8080 # Launch with custom port
266
+
267
+ # Authentication management
268
+ illusion auth login # Interactive provider setup (Custom/Anthropic/OpenAI/Copilot/Codex)
269
+ illusion auth status # View credential status for all environments
270
+ illusion auth logout [env_N] # Clear environment credentials
271
+ illusion auth switch [env_N] # Switch active environment
272
+ illusion auth add-model <env_N> <model_name> # Add a model to an existing environment
273
+
274
+ # MCP management
275
+ illusion mcp list # List MCP servers
276
+ illusion mcp add <name> <config> # Add server
277
+ illusion mcp remove <name> # Remove server
278
+
279
+ # Plugin management
280
+ illusion plugin list # List plugins
281
+ illusion plugin install <source> # Install plugin
282
+ illusion plugin uninstall <name> # Uninstall plugin
283
+
284
+ # Scheduled tasks
285
+ illusion cron start # Start scheduler
286
+ illusion cron stop # Stop scheduler
287
+ illusion cron status # View status
288
+ illusion cron list # List tasks
289
+ illusion cron toggle <name> <true|false> # Enable/disable task
290
+ illusion cron run <name> # Manually trigger task
291
+ illusion cron history # View execution history
292
+ illusion cron logs # View scheduler logs
293
+ ```
294
+
295
+ ### Interactive Slash Commands
296
+
297
+ In interactive sessions, you can use the following commands:
298
+
299
+ | Category | Command Examples | Description |
300
+ |----------|------------------|-------------|
301
+ | Session Management | `/help`, `/clear`, `/exit`, `/rewind`, `/delete` | Manage session state |
302
+ | Memory Snapshots | `/memory`, `/resume`, `/export`, `/rules` | Memory and session management |
303
+ | Configuration | `/config`, `/model`, `/permissions`, `/plan`, `/thinking` | Adjust runtime configuration |
304
+ | Plugin Extensions | `/skills`, `/hooks`, `/mcp`, `/plugin` | Manage extension features |
305
+ | Project Git | `/init`, `/diff`, `/branch`, `/commit` | Project and version control |
306
+ | Multi-Agent | `/continue` | Agent collaboration |
307
+
308
+ ---
309
+
310
+ ## ๐Ÿ—๏ธ Project Architecture
311
+
312
+ ```
313
+ illusion-code/
314
+ โ”œโ”€โ”€ src/illusion/ # Main source code
315
+ โ”‚ โ”œโ”€โ”€ api/ # API clients (Anthropic, OpenAI, etc.)
316
+ โ”‚ โ”œโ”€โ”€ auth/ # Authentication management
317
+ โ”‚ โ”œโ”€โ”€ commands/ # Slash command system (47 commands)
318
+ โ”‚ โ”œโ”€โ”€ config/ # Configuration system
319
+ โ”‚ โ”œโ”€โ”€ coordinator/ # Multi-agent coordinator
320
+ โ”‚ โ”œโ”€โ”€ engine/ # Core conversation engine
321
+ โ”‚ โ”œโ”€โ”€ hooks/ # Hook system
322
+ โ”‚ โ”œโ”€โ”€ mcp/ # MCP client
323
+ โ”‚ โ”œโ”€โ”€ memory/ # Memory system
324
+ โ”‚ โ”œโ”€โ”€ permissions/ # Permission system
325
+ โ”‚ โ”œโ”€โ”€ plugins/ # Plugin system
326
+ โ”‚ โ”œโ”€โ”€ prompts/ # Prompt system
327
+ โ”‚ โ”œโ”€โ”€ skills/ # Skill system
328
+ โ”‚ โ”œโ”€โ”€ tasks/ # Task management
329
+ โ”‚ โ”œโ”€โ”€ tools/ # Toolset (34 base tools)
330
+ โ”‚ โ”œโ”€โ”€ ui/ # User interface
331
+ โ”‚ โ”‚ โ”œโ”€โ”€ web/ # Web backend (FastAPI + WebSocket)
332
+ โ”‚ โ”‚ โ””โ”€โ”€ ...
333
+ โ”‚ โ””โ”€โ”€ cli.py # CLI entry point
334
+ โ”œโ”€โ”€ frontend/
335
+ โ”‚ โ”œโ”€โ”€ terminal/ # React Ink TUI frontend
336
+ โ”‚ โ””โ”€โ”€ web/ # React Web frontend (Vite + Tailwind)
337
+ โ”œโ”€โ”€ tests/ # Test suite
338
+ โ””โ”€โ”€ pyproject.toml # Project configuration
339
+ ```
340
+
341
+ ---
342
+
343
+ ## ๐Ÿ”ง Core Modules
344
+
345
+ ### API Client Layer
346
+
347
+ Supports multiple AI providers:
348
+
349
+ | Provider | API Format | Authentication |
350
+ |----------|------------|----------------|
351
+ | Anthropic Claude | anthropic | API Key |
352
+ | OpenAI / Compatible | openai | API Key |
353
+ | GitHub Copilot | openai | OAuth Device Flow |
354
+ | OpenAI Codex | openai | External CLI (Codex CLI) |
355
+ | Custom Provider | anthropic / openai | API Key |
356
+
357
+ ### Tool System
358
+
359
+ Provides 34 core tools, covering:
360
+
361
+ - **File Operations**: `file_read`, `file_write`, `file_edit`, `notebook_edit`
362
+ - **Command Execution**: `bash`, `powershell`, `repl`
363
+ - **Search**: `glob`, `grep`, `web_fetch`, `web_search`, `tool_search`
364
+ - **Task Management**: `task_create`, `task_get`, `task_list`, `task_update`, `task_output`, `task_stop`
365
+ - **Agent Collaboration**: `agent`, `send_message`, `team_create`, `team_delete`
366
+ - **Mode Switching**: `enter_plan_mode`, `exit_plan_mode`
367
+ - **Session Control**: `enter_worktree`, `exit_worktree`, `todo_write`, `sleep`
368
+ - **Config & Debug**: `config`, `lsp`, `mcp_auth`, `skill`, `structured_output`
369
+ - **Interaction**: `ask_user_question`
370
+ - **Scheduled Tasks**: `cron` (unified tool with status/list/add/update/remove/run actions)
371
+
372
+ ### Permission System
373
+
374
+ Three permission modes:
375
+
376
+ | Mode | Description |
377
+ |------|-------------|
378
+ | `default` | Modification tools require user confirmation |
379
+ | `plan` | Block all modification tools |
380
+ | `full_auto` | Allow all operations |
381
+
382
+ ### Multi-Agent Coordinator
383
+
384
+ Built-in 7 specialized Agents:
385
+
386
+ | Agent | Purpose |
387
+ |-------|---------|
388
+ | `general-purpose` | General research and multi-step tasks |
389
+ | `Explore` | File search and code exploration expert |
390
+ | `Plan` | Architecture design and implementation planning expert |
391
+ | `verification` | Adversarial verification expert |
392
+ | `worker` | Implementation-oriented Worker |
393
+ | `statusline-setup` | Shell PS1 converter |
394
+ | `illusion-guide` | Illusion Code / SDK / API documentation expert |
395
+
396
+ ---
397
+
398
+ ## ๐ŸŽจ Frontend Tech Stack
399
+
400
+ ### Terminal TUI (Ink)
401
+
402
+ | Technology | Version | Purpose |
403
+ |------------|---------|---------|
404
+ | React | 18.3.1 | UI framework |
405
+ | Ink | 5.1.0 | Terminal UI component library |
406
+ | TypeScript | 5.7.3 | Type safety |
407
+
408
+ ### Web UI
409
+
410
+ | Technology | Version | Purpose |
411
+ |------------|---------|---------|
412
+ | React | 18.x | UI framework |
413
+ | Vite | 6.x | Build tool and dev server |
414
+ | Tailwind CSS | 3.x | Utility-first CSS framework |
415
+ | TypeScript | 5.x | Type safety |
416
+ | FastAPI | - | Backend API framework |
417
+ | WebSocket | - | Real-time bidirectional communication |
418
+
419
+ ---
420
+
421
+ ## ๐Ÿ“ฆ Main Dependencies
422
+
423
+ | Dependency | Purpose |
424
+ |------------|---------|
425
+ | anthropic | Anthropic SDK |
426
+ | openai | OpenAI SDK |
427
+ | rich | Rich text output |
428
+ | prompt-toolkit | Advanced input processing |
429
+ | textual | TUI framework |
430
+ | typer | CLI framework |
431
+ | pydantic | Data validation |
432
+ | httpx | HTTP client |
433
+ | mcp | MCP protocol |
434
+ | fastapi | Web backend API framework |
435
+ | uvicorn | ASGI server for Web backend |
436
+
437
+ ---
438
+
439
+ ## โš™๏ธ Configuration Files
440
+
441
+ ### Configuration Overview
442
+
443
+ | File | Location | Scope | Purpose |
444
+ |------|----------|-------|---------|
445
+ | `settings.json` | `~/.illusion/settings.json` | Global | Main settings file, API config, permissions, hooks, etc. |
446
+ | `credentials.json` | `~/.illusion/credentials.json` | Global | Secure credential storage (API keys, etc.) |
447
+ | `CLAUDE.md` | Project root | Project-level | Project instructions and context |
448
+ | `MEMORY.md` | Project root | Project-level | Memory entry file |
449
+ | `.illusion/mcp/*.json` | Project root | Project-level | MCP server configuration |
450
+ | `.illusion/rules/*.md` | Project root | Project-level | Project rule files |
451
+
452
+ #### Credentials File (credentials.json)
453
+
454
+ The credentials file is located at `~/.illusion/credentials.json` for secure API key storage. It is automatically managed by the `illusion auth login` command, but can also be edited manually. Credentials are stored by `env_N` groups, corresponding to the environment configurations in `settings.json`.
455
+
456
+ ```json
457
+ {
458
+ "env_1": {
459
+ "api_key": "sk-ant-xxxxx"
460
+ },
461
+ "env_2": {
462
+ "api_key": "sk-xxxxx"
463
+ }
464
+ }
465
+ ```
466
+
467
+ **Field description:**
468
+ - Top-level keys are environment identifiers (env_1, env_2, etc.), matching env_N in settings.json
469
+ - Each environment stores credentials like `api_key`
470
+ - File permissions are automatically set to 600 (see explanation below)
471
+
472
+ **API Key Storage Options**: API keys can be stored in two ways, choose based on your needs:
473
+
474
+ | Method | Location | Advantage | Disadvantage |
475
+ |--------|----------|-----------|--------------|
476
+ | **Secure mode** | `credentials.json` (managed by `illusion auth login`) | Keys separated from config, easier management, file permissions protected | Requires extra file |
477
+ | **Convenient mode** | `env_N.api_key` field in `settings.json` | All config in one file, simple and direct | Keys in plaintext, be careful when sharing config |
478
+
479
+ Both methods can be mixed. Runtime read priority: `env_N.api_key` > environment variables > `credentials.json`.
480
+
481
+ > **File Permission 600 Explained**: `600` is a Unix/Linux file permission code meaning "only the file owner can read and write, all other users have no access." In numeric notation: `rw-------`, where `6` (read+write) applies to the owner, `0` to the group, and `0` to others. On Windows systems, this setting is silently skipped (Windows uses a different ACL permission model). This restriction protects API keys from being read by other users on the same system.
482
+
483
+ ### Configuration Priority
484
+
485
+ Configuration resolution priority (from high to low):
486
+
487
+ 1. **CLI Arguments** - Command-line arguments have the highest priority
488
+ 2. **Environment Variables** - Such as `ANTHROPIC_API_KEY`, `ANTHROPIC_MODEL`, etc.
489
+ 3. **Configuration Files** - `~/.illusion/settings.json`
490
+ 4. **Default Values** - Built-in default configurations
491
+
492
+ ---
493
+
494
+ ### Global Configuration (settings.json)
495
+
496
+ Global configuration file is located at `~/.illusion/settings.json` and applies to all projects.
497
+
498
+ #### Configuration Methods
499
+
500
+ settings.json uses the `env_N` grouped format to manage multiple environment/provider configurations. Each `env_N` is an independent environment configuration (EnvConfig) containing API format, endpoint, API key, and model list. The `model` field references `env_N.model_N` to select the currently active model.
501
+
502
+ ```json
503
+ {
504
+ "env_1": {
505
+ "api_format": "anthropic",
506
+ "base_url": null,
507
+ "model_1": "claude-sonnet-4-6",
508
+ "model_2": "claude-opus-4-6"
509
+ },
510
+ "env_2": {
511
+ "api_format": "openai",
512
+ "base_url": "https://api.openai.com/v1",
513
+ "model_1": "gpt-5.4"
514
+ },
515
+ "model": "env_1.model_1",
516
+ "context_window": 200000,
517
+ "system_prompt": null
518
+ }
519
+ ```
520
+
521
+ > **Tip**: The `model` field format is `env_N.model_N`, used to specify which model of which environment to use. You can switch interactively via the `/model` command. API keys can be placed directly in `env_N.api_key`, or stored in credentials.json via `illusion auth login` (more secure).
522
+
523
+ #### Complete Configuration Structure
524
+
525
+ ```json
526
+ {
527
+ "env_1": {
528
+ "api_format": "anthropic",
529
+ "base_url": null,
530
+ "model_1": "claude-sonnet-4-6",
531
+ "model_2": "claude-opus-4-6"
532
+ },
533
+ "env_2": {
534
+ "api_format": "openai",
535
+ "base_url": "https://api.openai.com/v1",
536
+ "model_1": "gpt-5.4"
537
+ },
538
+ "model": "env_1.model_1",
539
+ "context_window": 200000,
540
+ "system_prompt": null,
541
+ "max_tokens": 16384,
542
+ "max_turns": 200,
543
+ "permission": {
544
+ "mode": "default",
545
+ "allowed_tools": [],
546
+ "denied_tools": [],
547
+ "path_rules": [],
548
+ "denied_commands": []
549
+ },
550
+ "hooks": {},
551
+ "memory": {
552
+ "enabled": true,
553
+ "max_files": 5,
554
+ "max_entrypoint_lines": 200
555
+ },
556
+ "sandbox": {
557
+ "enabled": false,
558
+ "fail_if_unavailable": false,
559
+ "enabled_platforms": [],
560
+ "network": {
561
+ "allowed_domains": [],
562
+ "denied_domains": []
563
+ },
564
+ "filesystem": {
565
+ "allow_read": [],
566
+ "deny_read": [],
567
+ "allow_write": ["."],
568
+ "deny_write": []
569
+ }
570
+ },
571
+ "enabled_plugins": {},
572
+ "mcp_servers": {},
573
+ "ui_language": "en-US",
574
+ "output_style": "default",
575
+ "fast_mode": false,
576
+ "effort": "medium",
577
+ "passes": 1,
578
+ "verbose": false
579
+ }
580
+ ```
581
+
582
+ #### Configuration Field Description
583
+
584
+ | Field | Type | Default | Description | Example |
585
+ |-------|------|---------|-------------|---------|
586
+ | `env_N` | object | - | Environment config group (EnvConfig), supports dynamic env_1, env_2... | See EnvConfig field description below |
587
+ | `model` | string | "env_1.model_1" | Active model reference, format: `env_N.model_N` | `"env_2.model_1"` |
588
+ | `context_window` | int | 200000 | Context window size | `128000` |
589
+ | `system_prompt` | string\|null | null | Custom system prompt (global override) | `"You are a professional Python developer"` |
590
+ | `max_tokens` | int | 16384 | Maximum output token count | `32768` |
591
+ | `max_turns` | int | 200 | Maximum conversation turns | `500` |
592
+ | `ui_language` | string | "en-US" | UI language | `"zh-CN"` |
593
+ | `fast_mode` | bool | false | Fast mode | `true` |
594
+ | `effort` | string | "medium" | Reasoning effort level: low/medium/high/xhigh/max | `"high"` |
595
+ | `passes` | int | 1 | Reasoning pass count (1-8), controls how many times the AI iterates on the same problem; higher values = deeper reasoning but longer time | `2` |
596
+ | `verbose` | bool | false | Verbose output mode | `true` |
597
+
598
+ ---
599
+
600
+ ### Environment Configuration (EnvConfig)
601
+
602
+ IllusionCode supports managing multiple environment/provider configurations through `env_N` groups. Each environment configuration (EnvConfig) corresponds to an independent API provider setup.
603
+
604
+ #### EnvConfig Field Description
605
+
606
+ | Field | Type | Required | Description |
607
+ |-------|------|----------|-------------|
608
+ | `api_format` | string | Yes | API format: anthropic / openai |
609
+ | `base_url` | string\|null | No | Custom API endpoint, null uses default endpoint |
610
+ | `api_key` | string | No | API key (can be filled directly, or left empty for `illusion auth login` to store in credentials.json) |
611
+ | `system_prompt` | string\|null | No | System prompt for this environment (overrides global) |
612
+ | `model_N` | string | No | Model name, supports multiple: model_1, model_2, model_3... |
613
+
614
+ #### Multi-Model Configuration Example
615
+
616
+ Configure multiple models under the same environment, switch via `env_N.model_N`:
617
+
618
+ ```json
619
+ {
620
+ "env_1": {
621
+ "api_format": "openai",
622
+ "base_url": "https://integrate.api.nvidia.com/v1",
623
+ "model_1": "stepfun-ai/step-3.5-flash",
624
+ "model_2": "minimaxai/minimax-m2.7",
625
+ "model_3": "meta/llama-3.1-405b-instruct"
626
+ },
627
+ "model": "env_1.model_1"
628
+ }
629
+ ```
630
+
631
+ **Ways to switch models**:
632
+
633
+ ```bash
634
+ # Method 1: Use /model command to switch interactively
635
+ /model
636
+
637
+ # Method 2: Use -m parameter to specify model
638
+ illusion -m env_1.model_2
639
+
640
+ # Method 3: Modify the model field in settings.json
641
+ # Change "model" to "env_1.model_2"
642
+ ```
643
+
644
+ ---
645
+
646
+ ### Provider Configuration Examples
647
+
648
+ #### 1. Anthropic Claude API
649
+
650
+ ```json
651
+ {
652
+ "env_1": {
653
+ "api_format": "anthropic",
654
+ "base_url": null,
655
+ "model_1": "claude-sonnet-4-6",
656
+ "model_2": "claude-opus-4-6"
657
+ },
658
+ "model": "env_1.model_1"
659
+ }
660
+ ```
661
+
662
+ > API key can be placed directly in `env_N.api_key`, or stored in credentials.json via `illusion auth login` (more secure).
663
+
664
+ **Authentication**:
665
+ - Interactive setup: `illusion auth login` โ†’ select Anthropic
666
+ - Environment variable: `ANTHROPIC_API_KEY`
667
+
668
+ ---
669
+
670
+ #### 2. OpenAI API
671
+
672
+ ```json
673
+ {
674
+ "env_1": {
675
+ "api_format": "openai",
676
+ "base_url": "https://api.openai.com/v1",
677
+ "model_1": "gpt-5.4"
678
+ },
679
+ "model": "env_1.model_1"
680
+ }
681
+ ```
682
+
683
+ > API key can be placed directly in `env_N.api_key`, or stored in credentials.json via `illusion auth login` (more secure).
684
+
685
+ **Authentication**:
686
+ - Interactive setup: `illusion auth login` โ†’ select OpenAI
687
+ - Environment variable: `OPENAI_API_KEY`
688
+
689
+ ---
690
+
691
+ #### 3. Custom Provider
692
+
693
+ After selecting "Custom provider" in `illusion auth login`, enter:
694
+
695
+ 1. API format (openai / anthropic)
696
+ 2. API endpoint
697
+ 3. API key
698
+ 4. Model name
699
+
700
+ ```json
701
+ {
702
+ "env_1": {
703
+ "api_format": "openai",
704
+ "base_url": "https://api.your-llm.com/v1",
705
+ "model_1": "your-model-name"
706
+ },
707
+ "model": "env_1.model_1"
708
+ }
709
+ ```
710
+
711
+ ---
712
+
713
+ #### 4. GitHub Copilot
714
+
715
+ ```bash
716
+ # Interactive setup
717
+ illusion auth login # Select GitHub Copilot
718
+ ```
719
+
720
+ After completing GitHub authorization in the browser, it configures automatically. Auth data is stored in `~/.illusion/copilot_auth.json`.
721
+
722
+ ```json
723
+ {
724
+ "env_1": {
725
+ "api_format": "openai",
726
+ "base_url": "https://api.githubcopilot.com",
727
+ "model_1": "gpt-5.5",
728
+ "provider": "copilot"
729
+ },
730
+ "model": "env_1.model_1"
731
+ }
732
+ ```
733
+
734
+ **Authentication**: GitHub OAuth device code flow (handled automatically by `illusion auth login`)
735
+
736
+ **Requirement**: An active GitHub Copilot subscription.
737
+
738
+ **Supported models**: gpt-5.5, gpt-5.3-codex, claude-opus-4.6, gemini-3.1-pro-preview, etc. (depends on subscription plan)
739
+
740
+ ---
741
+
742
+ #### 5. OpenAI Codex (ChatGPT Subscription)
743
+
744
+ ```bash
745
+ # First install and authenticate Codex CLI
746
+ codex auth login
747
+
748
+ # Then configure in IllusionCode
749
+ illusion auth login # Select OpenAI Codex
750
+ ```
751
+
752
+ Codex mode uses ChatGPT subscription authentication, reading credentials from the Codex CLI's auth file (`~/.codex/auth.json`).
753
+
754
+ ```json
755
+ {
756
+ "env_1": {
757
+ "api_format": "openai",
758
+ "base_url": "https://chatgpt.com/backend-api",
759
+ "model_1": "codex-mini",
760
+ "provider": "codex"
761
+ },
762
+ "model": "env_1.model_1"
763
+ }
764
+ ```
765
+
766
+ **Authentication**: External CLI credential binding (requires Codex CLI authentication first)
767
+
768
+ **Requirement**: [Codex CLI](https://github.com/openai/codex) installed with a ChatGPT Plus/Pro/Team subscription.
769
+
770
+ ---
771
+
772
+ #### 6. Multi-Provider Mixed Configuration
773
+
774
+ Configure multiple environments via `illusion auth login`, switch using `illusion auth switch` or `/model`:
775
+
776
+ ```json
777
+ {
778
+ "env_1": {
779
+ "api_format": "anthropic",
780
+ "base_url": null,
781
+ "model_1": "claude-sonnet-4-6",
782
+ "model_2": "claude-opus-4-6"
783
+ },
784
+ "env_2": {
785
+ "api_format": "openai",
786
+ "base_url": "https://api.openai.com/v1",
787
+ "model_1": "gpt-5.4"
788
+ },
789
+ "env_3": {
790
+ "api_format": "openai",
791
+ "base_url": "https://api.githubcopilot.com",
792
+ "model_1": "gpt-5.5",
793
+ "provider": "copilot"
794
+ },
795
+ "model": "env_1.model_1"
796
+ }
797
+ ```
798
+
799
+ > API keys can be placed directly in `env_N.api_key`, or stored in credentials.json (more secure, managed by `illusion auth login`). Copilot/Codex authentication is managed by their respective OAuth flows and does not require manual API key entry.
800
+
801
+ **Switching methods**:
802
+ ```bash
803
+ # Interactive environment switch
804
+ illusion auth switch
805
+
806
+ # Directly specify environment
807
+ illusion auth switch env_2
808
+
809
+ # Use /model command to switch interactively
810
+ /model
811
+
812
+ # Use -m parameter to specify directly
813
+ illusion -m env_2.model_1
814
+ ```
815
+
816
+ ---
817
+
818
+ ### Project-Level Configuration
819
+
820
+ Project-level configuration only applies to the current project and is placed in the project root directory.
821
+
822
+ #### CLAUDE.md - Project Instructions
823
+
824
+ Create a `CLAUDE.md` file in the project root to provide project-specific context and instructions for AI:
825
+
826
+ ```markdown
827
+ # Project Description
828
+
829
+ This is a Python Web project using the FastAPI framework.
830
+
831
+ ## Code Standards
832
+
833
+ - Use Python 3.10+ features
834
+ - Follow PEP 8 code style
835
+ - Use type hints
836
+
837
+ ## Directory Structure
838
+
839
+ - src/api: API routes
840
+ - src/models: Data models
841
+ - src/services: Business logic
842
+
843
+ ## Notes
844
+
845
+ - Do not modify files in the tests/ directory
846
+ - Run pytest before committing
847
+ ```
848
+
849
+ #### .illusion/rules/ - Rule Files
850
+
851
+ Create `.md` files in the `.illusion/rules/` directory, each file is an independent rule:
852
+
853
+ ```
854
+ Project Root/
855
+ โ”œโ”€โ”€ .illusion/
856
+ โ”‚ โ””โ”€โ”€ rules/
857
+ โ”‚ โ”œโ”€โ”€ python-style.md
858
+ โ”‚ โ”œโ”€โ”€ git-workflow.md
859
+ โ”‚ โ””โ”€โ”€ testing.md
860
+ ```
861
+
862
+ #### MCP Server Configuration
863
+
864
+ MCP servers support three configuration methods, with priority from high to low: **Plugin > Project-level > Global settings**
865
+
866
+ ##### 1. Global Configuration (settings.json)
867
+
868
+ Configure in the `mcp_servers` field of `~/.illusion/settings.json`, applies to all projects. Both `mcp_servers` (snake_case) and `mcpServers` (camelCase) key names are supported:
869
+
870
+ ```json
871
+ {
872
+ "mcp_servers": {
873
+ "solidworks": {
874
+ "type": "stdio",
875
+ "command": "python",
876
+ "args": ["E:\\claudecode\\SolidWorks-MCP\\server.py"],
877
+ "enabled": true
878
+ }
879
+ }
880
+ }
881
+ ```
882
+
883
+ You can also manage via command line:
884
+ ```bash
885
+ illusion mcp list # List MCP servers
886
+ illusion mcp add <name> <config> # Add server
887
+ illusion mcp remove <name> # Remove server
888
+ ```
889
+
890
+ ##### 2. Project-level Configuration (.illusion/mcp/)
891
+
892
+ Create `.json` files in the `.illusion/mcp/` directory under the project root, only applies to the current project (directory auto-generated):
893
+
894
+ **Method 1: Single Server Configuration (filename as server name)**
895
+
896
+ ```json
897
+ // .illusion/mcp/solidworks.json
898
+ {
899
+ "type": "stdio",
900
+ "command": "python",
901
+ "args": ["E:\\claudecode\\SolidWorks-MCP\\server.py"],
902
+ "enabled": true
903
+ }
904
+ ```
905
+
906
+ **Method 2: Multiple Server Configuration (using mcpServers key)**
907
+
908
+ ```json
909
+ // .illusion/mcp/servers.json
910
+ {
911
+ "mcpServers": {
912
+ "filesystem": {
913
+ "type": "stdio",
914
+ "command": "npx",
915
+ "args": ["-y", "@modelcontextprotocol/server-filesystem", "./data"],
916
+ "env": {
917
+ "NODE_OPTIONS": "--max-old-space-size=4096"
918
+ }
919
+ },
920
+ "database": {
921
+ "type": "stdio",
922
+ "command": "python",
923
+ "args": ["-m", "mcp_server_postgres"],
924
+ "env": {
925
+ "DATABASE_URL": "postgresql://localhost/mydb"
926
+ }
927
+ },
928
+ "remote-api": {
929
+ "type": "http",
930
+ "url": "https://api.example.com/mcp",
931
+ "headers": {
932
+ "Authorization": "Bearer your-token"
933
+ }
934
+ },
935
+ "websocket-service": {
936
+ "type": "ws",
937
+ "url": "wss://ws.example.com/mcp",
938
+ "headers": {}
939
+ }
940
+ }
941
+ }
942
+ ```
943
+
944
+ ##### 3. Plugin Configuration
945
+
946
+ Place `.mcp.json` or `mcp.json` files in the plugin directory, loaded automatically with the plugin:
947
+
948
+ ```
949
+ ~/.illusion/plugins/my-plugin/
950
+ โ”œโ”€โ”€ plugin.json # Plugin manifest
951
+ โ”œโ”€โ”€ .mcp.json # MCP config (or mcp.json)
952
+ โ””โ”€โ”€ ...
953
+ ```
954
+
955
+ MCP servers from plugins are registered with the format `plugin_name:server_name` to avoid conflicts with other configurations.
956
+
957
+ ##### MCP Server Configuration Types
958
+
959
+ | Type | Fields | Description |
960
+ |------|--------|-------------|
961
+ | `stdio` | command, args, env, cwd, log_file, enabled | Communication via standard input/output |
962
+ | `http` | url, headers, enabled | Communication via HTTP protocol |
963
+ | `ws` | url, headers, enabled | Communication via WebSocket protocol |
964
+
965
+ > **`enabled` field**: All MCP server types support the `enabled` field (defaults to `true`). Set to `false` to disable a single server without removing its configuration. Both `mcpServers` and `mcp_servers` key names are supported in project-level config files.
966
+
967
+ ---
968
+
969
+ ### Permission Configuration
970
+
971
+ #### Permission Modes
972
+
973
+ | Mode | Value | Description |
974
+ |------|-------|-------------|
975
+ | Default Mode | `default` | Modification tools require user confirmation |
976
+ | Plan Mode | `plan` | Block all modification tools |
977
+ | Full Auto Mode | `full_auto` | Allow all operations |
978
+
979
+ #### Permission Configuration Example
980
+
981
+ ```json
982
+ {
983
+ "permission": {
984
+ "mode": "default",
985
+ "allowed_tools": ["read_file", "grep", "glob"],
986
+ "denied_tools": ["bash"],
987
+ "path_rules": [
988
+ {"pattern": "src/**", "allow": true},
989
+ {"pattern": "secrets/**", "allow": false}
990
+ ],
991
+ "denied_commands": ["/init", "/commit"]
992
+ }
993
+ }
994
+ ```
995
+
996
+ ---
997
+
998
+ ### Hook Configuration
999
+
1000
+ Hooks allow executing custom operations when specific events occur.
1001
+
1002
+ #### Supported Hook Types
1003
+
1004
+ | Hook Event | Description |
1005
+ |------------|-------------|
1006
+ | `PRE_TOOL_USE` | Before tool execution |
1007
+ | `POST_TOOL_USE` | After tool execution |
1008
+ | `USER_PROMPT_SUBMIT` | After user prompt submission |
1009
+
1010
+ #### Hook Configuration Example
1011
+
1012
+ ```json
1013
+ {
1014
+ "hooks": {
1015
+ "PRE_TOOL_USE": [
1016
+ {
1017
+ "type": "command",
1018
+ "command": "echo 'Tool: $TOOL_NAME' >> /tmp/tool.log",
1019
+ "timeout_seconds": 30,
1020
+ "block_on_failure": false
1021
+ }
1022
+ ],
1023
+ "POST_TOOL_USE": [
1024
+ {
1025
+ "type": "http",
1026
+ "url": "https://hooks.example.com/tool-complete",
1027
+ "headers": {"Authorization": "Bearer token"},
1028
+ "timeout_seconds": 10
1029
+ }
1030
+ ],
1031
+ "USER_PROMPT_SUBMIT": [
1032
+ {
1033
+ "type": "prompt",
1034
+ "prompt": "Check if user input contains sensitive information",
1035
+ "block_on_failure": true
1036
+ }
1037
+ ]
1038
+ }
1039
+ }
1040
+ ```
1041
+
1042
+ #### Hook Type Details
1043
+
1044
+ | Type | Required Fields | Optional Fields | Description |
1045
+ |------|-----------------|-----------------|-------------|
1046
+ | `command` | command | timeout_seconds, matcher, block_on_failure | Execute Shell command |
1047
+ | `prompt` | prompt | model, timeout_seconds, matcher, block_on_failure | Use LLM for verification |
1048
+ | `http` | url | headers, timeout_seconds, matcher, block_on_failure | Send HTTP request |
1049
+ | `agent` | prompt | model, timeout_seconds, matcher, block_on_failure | Use Agent for verification |
1050
+
1051
+ ---
1052
+
1053
+ ### Environment Variables
1054
+
1055
+ Supported environment variables:
1056
+
1057
+ | Variable Name | Description |
1058
+ |---------------|-------------|
1059
+ | `ANTHROPIC_API_KEY` | Anthropic API key |
1060
+ | `OPENAI_API_KEY` | OpenAI API key |
1061
+ | `ANTHROPIC_MODEL` | Default model |
1062
+ | `ANTHROPIC_BASE_URL` | API endpoint |
1063
+ | `ILLUSION_MAX_TOKENS` | Maximum token count |
1064
+ | `ILLUSION_MAX_TURNS` | Maximum conversation turns |
1065
+ | `ILLUSION_SANDBOX_ENABLED` | Whether to enable sandbox |
1066
+ | `ILLUSION_CONFIG_DIR` | Configuration directory path |
1067
+ | `ILLUSION_DATA_DIR` | Data directory path |
1068
+ | `ILLUSION_LOGS_DIR` | Logs directory path |
1069
+
1070
+ ---
1071
+
1072
+ ### Memory System Configuration
1073
+
1074
+ ```json
1075
+ {
1076
+ "memory": {
1077
+ "enabled": true,
1078
+ "max_files": 5,
1079
+ "max_entrypoint_lines": 200
1080
+ }
1081
+ }
1082
+ ```
1083
+
1084
+ | Field | Default | Description |
1085
+ |-------|---------|-------------|
1086
+ | `enabled` | true | Whether to enable memory function |
1087
+ | `max_files` | 5 | Maximum number of memory files |
1088
+ | `max_entrypoint_lines` | 200 | Maximum lines for entry file |
1089
+
1090
+ ---
1091
+
1092
+ ### Sandbox Configuration
1093
+
1094
+ ```json
1095
+ {
1096
+ "sandbox": {
1097
+ "enabled": true,
1098
+ "fail_if_unavailable": false,
1099
+ "enabled_platforms": ["linux", "darwin"],
1100
+ "network": {
1101
+ "allowed_domains": ["api.anthropic.com"],
1102
+ "denied_domains": ["internal.company.com"]
1103
+ },
1104
+ "filesystem": {
1105
+ "allow_read": ["./src", "./docs"],
1106
+ "deny_read": ["./secrets"],
1107
+ "allow_write": ["./output"],
1108
+ "deny_write": ["./.git"]
1109
+ }
1110
+ }
1111
+ }
1112
+ ```
1113
+
1114
+ ---
1115
+
1116
+ ## ๐Ÿ”Œ Extension Development
1117
+
1118
+ ### Hook System
1119
+
1120
+ Supports multiple hook types:
1121
+
1122
+ - `PRE_TOOL_USE` - Before tool execution
1123
+ - `POST_TOOL_USE` - After tool execution
1124
+ - `USER_PROMPT_SUBMIT` - After user prompt submission
1125
+
1126
+ ### Plugin System
1127
+
1128
+ Defined through `plugin.json` manifest:
1129
+
1130
+ - Skills
1131
+ - Commands
1132
+ - Hooks
1133
+ - MCP Servers
1134
+
1135
+ ## ๐Ÿงช Development & Testing
1136
+
1137
+ ```bash
1138
+ # Install development dependencies
1139
+ uv sync --dev
1140
+
1141
+ # Run tests
1142
+ pytest
1143
+ ```
1144
+
1145
+ ---
1146
+
1147
+ ## ๐Ÿ“„ License
1148
+
1149
+ This project is open-sourced under the [MIT](LICENSE) license.
1150
+
1151
+ ---
1152
+
1153
+ ## ๐Ÿค Contributing
1154
+
1155
+ Welcome to submit Issues and Pull Requests!
1156
+
1157
+ ---
1158
+
1159
+ </div>