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.
- illusion/__init__.py +24 -0
- illusion/__main__.py +15 -0
- illusion/_frontend/dist/index.mjs +39208 -0
- illusion/_frontend/package.json +27 -0
- illusion/_frontend/src/App.tsx +624 -0
- illusion/_frontend/src/components/CommandPicker.tsx +98 -0
- illusion/_frontend/src/components/Composer.tsx +55 -0
- illusion/_frontend/src/components/ComposerController.tsx +128 -0
- illusion/_frontend/src/components/ConversationView.tsx +750 -0
- illusion/_frontend/src/components/Footer.tsx +25 -0
- illusion/_frontend/src/components/MarkdownContent.tsx +537 -0
- illusion/_frontend/src/components/MarkdownTable.tsx +245 -0
- illusion/_frontend/src/components/ModalHost.tsx +425 -0
- illusion/_frontend/src/components/MultilineTextInput.tsx +250 -0
- illusion/_frontend/src/components/PromptInput.tsx +64 -0
- illusion/_frontend/src/components/SelectModal.tsx +78 -0
- illusion/_frontend/src/components/SidePanel.tsx +175 -0
- illusion/_frontend/src/components/Spinner.tsx +77 -0
- illusion/_frontend/src/components/StatusBar.tsx +142 -0
- illusion/_frontend/src/components/SwarmPanel.tsx +141 -0
- illusion/_frontend/src/components/TodoPanel.tsx +126 -0
- illusion/_frontend/src/components/ToolCallDisplay.tsx +202 -0
- illusion/_frontend/src/components/TranscriptPane.tsx +79 -0
- illusion/_frontend/src/components/WelcomeBanner.tsx +37 -0
- illusion/_frontend/src/hooks/useBackendSession.ts +468 -0
- illusion/_frontend/src/hooks/useTerminalSize.ts +9 -0
- illusion/_frontend/src/i18n.ts +78 -0
- illusion/_frontend/src/index.tsx +42 -0
- illusion/_frontend/src/theme/ThemeContext.tsx +19 -0
- illusion/_frontend/src/theme/builtinThemes.ts +89 -0
- illusion/_frontend/src/types.ts +110 -0
- illusion/_frontend/src/utils/markdown.ts +33 -0
- illusion/_frontend/src/utils/thinking.ts +191 -0
- illusion/_frontend/tsconfig.json +13 -0
- illusion/_web_dist/assets/index-BseIw-ik.css +10 -0
- illusion/_web_dist/assets/index-C_0ZWMuW.js +82 -0
- illusion/_web_dist/index.html +16 -0
- illusion/api/__init__.py +36 -0
- illusion/api/client.py +568 -0
- illusion/api/codex_client.py +563 -0
- illusion/api/compat.py +138 -0
- illusion/api/effort.py +128 -0
- illusion/api/errors.py +57 -0
- illusion/api/openai_client.py +819 -0
- illusion/api/provider.py +148 -0
- illusion/api/registry.py +479 -0
- illusion/api/usage.py +45 -0
- illusion/auth/__init__.py +50 -0
- illusion/auth/copilot.py +419 -0
- illusion/auth/external.py +612 -0
- illusion/auth/flows.py +58 -0
- illusion/auth/manager.py +214 -0
- illusion/auth/storage.py +372 -0
- illusion/bridge/__init__.py +38 -0
- illusion/bridge/manager.py +190 -0
- illusion/bridge/session_runner.py +84 -0
- illusion/bridge/types.py +113 -0
- illusion/bridge/work_secret.py +131 -0
- illusion/cli.py +1228 -0
- illusion/commands/__init__.py +32 -0
- illusion/commands/registry.py +1934 -0
- illusion/config/__init__.py +39 -0
- illusion/config/i18n.py +522 -0
- illusion/config/paths.py +259 -0
- illusion/config/settings.py +564 -0
- illusion/coordinator/__init__.py +41 -0
- illusion/coordinator/agent_definitions.py +1093 -0
- illusion/coordinator/coordinator_mode.py +127 -0
- illusion/engine/__init__.py +95 -0
- illusion/engine/cost_tracker.py +55 -0
- illusion/engine/messages.py +369 -0
- illusion/engine/query.py +632 -0
- illusion/engine/query_engine.py +343 -0
- illusion/engine/stream_events.py +169 -0
- illusion/hooks/__init__.py +67 -0
- illusion/hooks/events.py +43 -0
- illusion/hooks/executor.py +397 -0
- illusion/hooks/hot_reload.py +74 -0
- illusion/hooks/loader.py +133 -0
- illusion/hooks/schemas.py +121 -0
- illusion/hooks/types.py +86 -0
- illusion/mcp/__init__.py +104 -0
- illusion/mcp/client.py +377 -0
- illusion/mcp/config.py +140 -0
- illusion/mcp/types.py +175 -0
- illusion/memory/__init__.py +36 -0
- illusion/memory/manager.py +94 -0
- illusion/memory/memdir.py +58 -0
- illusion/memory/paths.py +57 -0
- illusion/memory/scan.py +120 -0
- illusion/memory/search.py +83 -0
- illusion/memory/types.py +43 -0
- illusion/output_styles/__init__.py +15 -0
- illusion/output_styles/loader.py +64 -0
- illusion/permissions/__init__.py +39 -0
- illusion/permissions/checker.py +174 -0
- illusion/permissions/modes.py +38 -0
- illusion/platforms.py +148 -0
- illusion/plugins/__init__.py +71 -0
- illusion/plugins/bundled/__init__.py +0 -0
- illusion/plugins/installer.py +59 -0
- illusion/plugins/loader.py +301 -0
- illusion/plugins/schemas.py +51 -0
- illusion/plugins/types.py +56 -0
- illusion/prompts/__init__.py +29 -0
- illusion/prompts/claudemd.py +74 -0
- illusion/prompts/context.py +187 -0
- illusion/prompts/environment.py +189 -0
- illusion/prompts/system_prompt.py +155 -0
- illusion/py.typed +0 -0
- illusion/sandbox/__init__.py +29 -0
- illusion/sandbox/adapter.py +174 -0
- illusion/services/__init__.py +59 -0
- illusion/services/compact/__init__.py +1015 -0
- illusion/services/cron.py +338 -0
- illusion/services/cron_scheduler.py +715 -0
- illusion/services/file_history.py +258 -0
- illusion/services/lsp/__init__.py +455 -0
- illusion/services/session_storage.py +237 -0
- illusion/services/token_estimation.py +72 -0
- illusion/skills/__init__.py +60 -0
- illusion/skills/bundled/__init__.py +110 -0
- illusion/skills/bundled/content/batch.md +86 -0
- illusion/skills/bundled/content/coding-guidelines.md +70 -0
- illusion/skills/bundled/content/debug.md +38 -0
- illusion/skills/bundled/content/loop.md +82 -0
- illusion/skills/bundled/content/remember.md +105 -0
- illusion/skills/bundled/content/simplify.md +53 -0
- illusion/skills/bundled/content/skillify.md +113 -0
- illusion/skills/bundled/content/stuck.md +54 -0
- illusion/skills/bundled/content/update-config.md +329 -0
- illusion/skills/bundled/content/verify.md +74 -0
- illusion/skills/loader.py +219 -0
- illusion/skills/registry.py +40 -0
- illusion/skills/types.py +24 -0
- illusion/state/__init__.py +18 -0
- illusion/state/app_state.py +67 -0
- illusion/state/store.py +93 -0
- illusion/swarm/__init__.py +71 -0
- illusion/swarm/agent_executor.py +857 -0
- illusion/swarm/in_process.py +259 -0
- illusion/swarm/subprocess_backend.py +136 -0
- illusion/swarm/team_helpers.py +123 -0
- illusion/swarm/types.py +159 -0
- illusion/swarm/worktree.py +347 -0
- illusion/tasks/__init__.py +33 -0
- illusion/tasks/local_agent_task.py +42 -0
- illusion/tasks/local_shell_task.py +27 -0
- illusion/tasks/manager.py +377 -0
- illusion/tasks/stop_task.py +21 -0
- illusion/tasks/types.py +88 -0
- illusion/tools/__init__.py +126 -0
- illusion/tools/agent_tool.py +388 -0
- illusion/tools/ask_user_question_tool.py +186 -0
- illusion/tools/base.py +149 -0
- illusion/tools/bash_tool.py +413 -0
- illusion/tools/config_tool.py +90 -0
- illusion/tools/cron_tool.py +473 -0
- illusion/tools/enter_plan_mode_tool.py +147 -0
- illusion/tools/enter_worktree_tool.py +188 -0
- illusion/tools/exit_plan_mode_tool.py +69 -0
- illusion/tools/exit_worktree_tool.py +225 -0
- illusion/tools/file_edit_tool.py +283 -0
- illusion/tools/file_read_tool.py +294 -0
- illusion/tools/file_write_tool.py +184 -0
- illusion/tools/glob_tool.py +165 -0
- illusion/tools/grep_tool.py +190 -0
- illusion/tools/list_mcp_resources_tool.py +80 -0
- illusion/tools/lsp_tool.py +333 -0
- illusion/tools/mcp_auth_tool.py +100 -0
- illusion/tools/mcp_tool.py +75 -0
- illusion/tools/notebook_edit_tool.py +242 -0
- illusion/tools/powershell_tool.py +334 -0
- illusion/tools/read_mcp_resource_tool.py +63 -0
- illusion/tools/repl_tool.py +100 -0
- illusion/tools/send_message_tool.py +112 -0
- illusion/tools/shell_common.py +187 -0
- illusion/tools/skill_tool.py +86 -0
- illusion/tools/sleep_tool.py +62 -0
- illusion/tools/structured_output_tool.py +58 -0
- illusion/tools/task_create_tool.py +98 -0
- illusion/tools/task_get_tool.py +94 -0
- illusion/tools/task_list_tool.py +94 -0
- illusion/tools/task_output_tool.py +55 -0
- illusion/tools/task_stop_tool.py +52 -0
- illusion/tools/task_update_tool.py +224 -0
- illusion/tools/team_create_tool.py +236 -0
- illusion/tools/team_delete_tool.py +104 -0
- illusion/tools/todo_write_tool.py +198 -0
- illusion/tools/tool_search_tool.py +156 -0
- illusion/tools/web_fetch_tool.py +264 -0
- illusion/tools/web_search_tool.py +186 -0
- illusion/ui/__init__.py +23 -0
- illusion/ui/app.py +258 -0
- illusion/ui/backend_host.py +1180 -0
- illusion/ui/input.py +86 -0
- illusion/ui/output.py +363 -0
- illusion/ui/permission_dialog.py +47 -0
- illusion/ui/permission_store.py +99 -0
- illusion/ui/protocol.py +384 -0
- illusion/ui/react_launcher.py +280 -0
- illusion/ui/runtime.py +787 -0
- illusion/ui/textual_app.py +603 -0
- illusion/ui/web/__init__.py +10 -0
- illusion/ui/web/server.py +87 -0
- illusion/ui/web/ws_host.py +1197 -0
- illusion/utils/__init__.py +0 -0
- illusion/utils/ripgrep.py +299 -0
- illusion/utils/shell.py +248 -0
- illusion_code-0.1.0.dist-info/METADATA +1159 -0
- illusion_code-0.1.0.dist-info/RECORD +214 -0
- illusion_code-0.1.0.dist-info/WHEEL +4 -0
- illusion_code-0.1.0.dist-info/entry_points.txt +2 -0
- illusion_code-0.1.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"""
|
|
2
|
+
应用状态模块
|
|
3
|
+
===========
|
|
4
|
+
|
|
5
|
+
本模块定义 IllusionCode 应用状态数据模型。
|
|
6
|
+
|
|
7
|
+
主要功能:
|
|
8
|
+
- 定义共享的UI/会话状态数据结构
|
|
9
|
+
- 支持状态属性的不可变更新
|
|
10
|
+
|
|
11
|
+
类说明:
|
|
12
|
+
- AppState: 应用状态数据类
|
|
13
|
+
|
|
14
|
+
使用示例:
|
|
15
|
+
>>> from illusion.state import AppState
|
|
16
|
+
>>> state = AppState(model="claude-3-5-sonnet-20241022", permission_mode="default")
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
from __future__ import annotations
|
|
20
|
+
|
|
21
|
+
from dataclasses import dataclass
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
@dataclass
|
|
25
|
+
class AppState:
|
|
26
|
+
"""共享的可变UI/会话状态数据类
|
|
27
|
+
|
|
28
|
+
Attributes:
|
|
29
|
+
model: 当前使用的模型名称
|
|
30
|
+
permission_mode: 权限模式 (default/plan/bypassPermissions 等)
|
|
31
|
+
ui_language: UI语言 (默认 zh-CN)
|
|
32
|
+
cwd: 当前工作目录
|
|
33
|
+
provider: API提供者名称
|
|
34
|
+
auth_status: 认证状态
|
|
35
|
+
base_url: API基础URL
|
|
36
|
+
fast_mode: 是否启用快速模式
|
|
37
|
+
effort: 推理 Effort 级别 (low/medium/high)
|
|
38
|
+
passes: 推理通过次数
|
|
39
|
+
mcp_connected: 已连接的MCP服务器数量
|
|
40
|
+
mcp_failed: 失败的MCP服务器数量
|
|
41
|
+
bridge_sessions: 活跃的桥接会话数量
|
|
42
|
+
output_style: 输出样式名称
|
|
43
|
+
show_thinking: 是否显示思考过程
|
|
44
|
+
phase: 会话阶段 (idle/thinking/tool_executing)
|
|
45
|
+
team_context: 当前会话的团队上下文(若已创建团队)
|
|
46
|
+
"""
|
|
47
|
+
|
|
48
|
+
model: str # 模型名称
|
|
49
|
+
permission_mode: str # 权限模式
|
|
50
|
+
ui_language: str = "zh-CN" # UI语言
|
|
51
|
+
cwd: str = "." # 当前工作目录
|
|
52
|
+
provider: str = "unknown" # API提供者
|
|
53
|
+
auth_status: str = "missing" # 认证状态
|
|
54
|
+
base_url: str = "" # API基础URL
|
|
55
|
+
fast_mode: bool = False # 快速模式标志
|
|
56
|
+
effort: str = "medium" # 推理 Effort 级别
|
|
57
|
+
passes: int = 1 # 推理通过次数
|
|
58
|
+
mcp_connected: int = 0 # 已连接的MCP服务器数量
|
|
59
|
+
mcp_failed: int = 0 # 失败的MCP服务器数量
|
|
60
|
+
bridge_sessions: int = 0 # 活跃的桥接会话数量
|
|
61
|
+
output_style: str = "default" # 输出样式名称
|
|
62
|
+
show_thinking: bool = True # 是否显示思考过程
|
|
63
|
+
phase: str = "idle" # 会话阶段: idle / thinking / tool_executing
|
|
64
|
+
session_id: str = "" # 当前会话 ID
|
|
65
|
+
context_window: int = 0 # 上下文窗口大小(tokens)
|
|
66
|
+
context_tokens: int = 0 # 当前已用 tokens(估算)
|
|
67
|
+
team_context: dict[str, object] | None = None # 团队上下文
|
illusion/state/store.py
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"""
|
|
2
|
+
状态存储模块
|
|
3
|
+
===========
|
|
4
|
+
|
|
5
|
+
本模块实现可观察的应用状态存储容器。
|
|
6
|
+
|
|
7
|
+
主要功能:
|
|
8
|
+
- 提供响应式状态管理
|
|
9
|
+
- 支持状态变更监听和通知
|
|
10
|
+
|
|
11
|
+
类说明:
|
|
12
|
+
- AppStateStore: 应用状态存储容器
|
|
13
|
+
- Listener: 状态监听器类型
|
|
14
|
+
|
|
15
|
+
使用示例:
|
|
16
|
+
>>> from illusion.state import AppState, AppStateStore
|
|
17
|
+
>>> store = AppStateStore(AppState(model="claude", permission_mode="default", theme="default"))
|
|
18
|
+
>>> state = store.get()
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
from __future__ import annotations
|
|
22
|
+
|
|
23
|
+
from collections.abc import Callable
|
|
24
|
+
from dataclasses import replace
|
|
25
|
+
|
|
26
|
+
from illusion.state.app_state import AppState
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
# 状态监听器类型别名:接收AppState并返回None的Callable
|
|
30
|
+
Listener = Callable[[AppState], None]
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class AppStateStore:
|
|
34
|
+
"""可观察的应用状态存储容器
|
|
35
|
+
|
|
36
|
+
提供 immutable 风格的状态更新,通过监听器模式通知状态变更。
|
|
37
|
+
|
|
38
|
+
Attributes:
|
|
39
|
+
_state: 当前的应用状态快照
|
|
40
|
+
_listeners: 注册的状态监听器列表
|
|
41
|
+
|
|
42
|
+
Example:
|
|
43
|
+
>>> store = AppStateStore(initial_state)
|
|
44
|
+
>>> store.subscribe(lambda state: print(f"State changed: {state.model}"))
|
|
45
|
+
>>> store.set(model="new-model") # 触发所有监听器
|
|
46
|
+
"""
|
|
47
|
+
|
|
48
|
+
def __init__(self, initial_state: AppState) -> None:
|
|
49
|
+
"""初始化状态存储容器
|
|
50
|
+
|
|
51
|
+
Args:
|
|
52
|
+
initial_state: 初始的应用状态
|
|
53
|
+
"""
|
|
54
|
+
self._state = initial_state # 内部状态存储
|
|
55
|
+
self._listeners: list[Listener] = [] # 监听器列表初始化
|
|
56
|
+
|
|
57
|
+
def get(self) -> AppState:
|
|
58
|
+
"""获取当前状态的快照
|
|
59
|
+
|
|
60
|
+
Returns:
|
|
61
|
+
AppState: 当前应用状态的副本
|
|
62
|
+
"""
|
|
63
|
+
return self._state # 返回当前状态
|
|
64
|
+
|
|
65
|
+
def set(self, **updates) -> AppState:
|
|
66
|
+
"""更新状态并通知所有监听器
|
|
67
|
+
|
|
68
|
+
Keyword Args:
|
|
69
|
+
updates: 要更新的状态属性
|
|
70
|
+
Returns:
|
|
71
|
+
AppState: 更新后的新状态
|
|
72
|
+
"""
|
|
73
|
+
self._state = replace(self._state, **updates) # 使用dataclasses.replace创建新状态
|
|
74
|
+
for listener in list(self._listeners): # 通知所有监听器
|
|
75
|
+
listener(self._state)
|
|
76
|
+
return self._state # 返回更新后的状态
|
|
77
|
+
|
|
78
|
+
def subscribe(self, listener: Listener) -> Callable[[], None]:
|
|
79
|
+
"""注册状态监听器并返回取消订阅的回调函数
|
|
80
|
+
|
|
81
|
+
Args:
|
|
82
|
+
listener: 状态变更时调用的监听器函数
|
|
83
|
+
Returns:
|
|
84
|
+
Callable[[], None]: 用于取消订阅的回调函数
|
|
85
|
+
"""
|
|
86
|
+
self._listeners.append(listener) # 添加监听器
|
|
87
|
+
|
|
88
|
+
def _unsubscribe() -> None:
|
|
89
|
+
"""取消订阅的内部函数"""
|
|
90
|
+
if listener in self._listeners: # 检查监听器是否存在
|
|
91
|
+
self._listeners.remove(listener) # 移除监听器
|
|
92
|
+
|
|
93
|
+
return _unsubscribe # 返回取消订阅函数
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Agent 派发后端抽象模块
|
|
3
|
+
=====================
|
|
4
|
+
|
|
5
|
+
本模块提供代理执行的后端抽象功能。
|
|
6
|
+
|
|
7
|
+
主要组件:
|
|
8
|
+
- agent_executor: 代理执行器核心模块
|
|
9
|
+
- in_process: 进程内执行后端
|
|
10
|
+
- subprocess_backend: 子进程执行后端
|
|
11
|
+
- types: 类型定义
|
|
12
|
+
- worktree: Git worktree 管理
|
|
13
|
+
|
|
14
|
+
使用示例:
|
|
15
|
+
>>> from illusion.swarm import InProcessBackend, SubprocessBackend
|
|
16
|
+
>>> from illusion.swarm.agent_executor import run_agent_in_process
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
from __future__ import annotations
|
|
20
|
+
|
|
21
|
+
# 导入核心组件
|
|
22
|
+
from illusion.swarm.agent_executor import (
|
|
23
|
+
AgentAbortController,
|
|
24
|
+
AgentExecutionContext,
|
|
25
|
+
AgentResult,
|
|
26
|
+
AgentSpawnConfig,
|
|
27
|
+
TaskNotification,
|
|
28
|
+
TeammateMessage,
|
|
29
|
+
format_task_notification,
|
|
30
|
+
get_active_agent,
|
|
31
|
+
get_active_agent_by_name,
|
|
32
|
+
get_agent_context,
|
|
33
|
+
list_active_agents,
|
|
34
|
+
parse_task_notification,
|
|
35
|
+
resolve_agent_tools,
|
|
36
|
+
run_agent_in_process,
|
|
37
|
+
run_agent_subprocess,
|
|
38
|
+
)
|
|
39
|
+
from illusion.swarm.in_process import InProcessBackend
|
|
40
|
+
from illusion.swarm.subprocess_backend import SubprocessBackend
|
|
41
|
+
from illusion.swarm.types import (
|
|
42
|
+
BackendType,
|
|
43
|
+
SpawnResult,
|
|
44
|
+
TeammateExecutor,
|
|
45
|
+
TeammateSpawnConfig,
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
# 导出列表:定义公开 API
|
|
49
|
+
__all__ = [
|
|
50
|
+
"AgentAbortController",
|
|
51
|
+
"AgentExecutionContext",
|
|
52
|
+
"AgentResult",
|
|
53
|
+
"AgentSpawnConfig",
|
|
54
|
+
"BackendType",
|
|
55
|
+
"InProcessBackend",
|
|
56
|
+
"SpawnResult",
|
|
57
|
+
"SubprocessBackend",
|
|
58
|
+
"TaskNotification",
|
|
59
|
+
"TeammateExecutor",
|
|
60
|
+
"TeammateMessage",
|
|
61
|
+
"TeammateSpawnConfig",
|
|
62
|
+
"format_task_notification",
|
|
63
|
+
"get_active_agent",
|
|
64
|
+
"get_active_agent_by_name",
|
|
65
|
+
"get_agent_context",
|
|
66
|
+
"list_active_agents",
|
|
67
|
+
"parse_task_notification",
|
|
68
|
+
"resolve_agent_tools",
|
|
69
|
+
"run_agent_in_process",
|
|
70
|
+
"run_agent_subprocess",
|
|
71
|
+
]
|