cortx 1.0.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.
cortx-1.0.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Cortex Agent 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.
cortx-1.0.0/PKG-INFO ADDED
@@ -0,0 +1,176 @@
1
+ Metadata-Version: 2.4
2
+ Name: cortx
3
+ Version: 1.0.0
4
+ Summary: 安全可控的 AI Agent 运行时框架 — Harness Agent 架构 + Agentic Loop 引擎
5
+ Author: Cortex Agent Contributors
6
+ License: MIT
7
+ Keywords: ai-agent,llm,agent-framework,harness,agentic-loop,mcp,browser-automation
8
+ Classifier: Development Status :: 4 - Beta
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
16
+ Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
17
+ Requires-Python: >=3.10
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE
20
+ Requires-Dist: openai>=1.0
21
+ Requires-Dist: httpx>=0.27
22
+ Provides-Extra: dev
23
+ Requires-Dist: pytest>=8; extra == "dev"
24
+ Requires-Dist: pytest-asyncio; extra == "dev"
25
+ Dynamic: license-file
26
+
27
+ # Cortex Agent
28
+
29
+ 安全可控的 AI Agent 运行时 — **Harness Agent 架构 + Agentic Loop 引擎**
30
+
31
+ [![Python](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
32
+ [![TypeScript](https://img.shields.io/badge/typescript-5.x-blue.svg)](https://www.typescriptlang.org/)
33
+ [![Node](https://img.shields.io/badge/node-24+-green.svg)](https://nodejs.org/)
34
+ [![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
35
+
36
+ > **Cortex** = 大脑皮层。如同大脑皮层负责感知推理、血脑屏障严格过滤、海马体持久记忆 — Cortex Agent 将 Agentic Loop(推理)、PolicyEngine(安全)、Memory(记忆)融为一体。
37
+
38
+ ---
39
+
40
+ ## 双语言实现
41
+
42
+ | | Python | TypeScript |
43
+ |---|--------|-----------|
44
+ | 位置 | `python/cortex_agent/` | `src/` |
45
+ | 工具数 | 43 | 43 |
46
+ | 安装 | `pip install cortx` | `npm install -g cortx` |
47
+ | CLI 命令 | `ctx` | `ctx` |
48
+
49
+ > 💡 **PyPI: `pip install cortx`,npm: `npm install -g cortx`。运行只需 `ctx`**
50
+
51
+ ---
52
+
53
+ ## 快速开始
54
+
55
+ ```bash
56
+ # Python (3 字母包名)
57
+ pip install cortx
58
+ ctx
59
+
60
+ # TypeScript
61
+ npm install -g cortx
62
+ ctx
63
+ ctx # 交互 REPL
64
+ ctx -q "hello" # 单次查询
65
+ ctx --model pro # 指定模型
66
+
67
+ # 单次查询
68
+ ctx -q "用 Python 写斐波那契函数"
69
+ ```
70
+
71
+ ---
72
+
73
+ ## 设计哲学
74
+
75
+ ```
76
+ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐
77
+ │ Think │ → │ Guard │ → │ Act │ → │ Reflect │
78
+ │ (LLM流式)│ │(Policy) │ │(Executor)│ │(步数收敛)│
79
+ └──────────┘ └──────────┘ └──────────┘ └──────────┘
80
+ ```
81
+
82
+ | 原则 | 说明 |
83
+ |------|------|
84
+ | **Agent 自主决策** | 不注入行为指令,Agent 从工具结果中自行推理 |
85
+ | **完整中介** | 所有工具调用必经 PolicyEngine 4 级审计 |
86
+ | **Share-nothing 隔离** | 每实例独立 work_dir / executor / observer |
87
+
88
+ ---
89
+
90
+ ## 项目结构
91
+
92
+ ```
93
+ ctx/
94
+ ├── python/cortex_agent/ # Python 包
95
+ │ ├── cortex_agent.py # Agentic Loop 核心引擎
96
+ │ ├── policy.py # PolicyEngine 安全策略
97
+ │ ├── llm.py # LLM Provider (DeepSeek/OpenAI)
98
+ │ ├── tools.py # 核心工具 (25)
99
+ │ ├── tools_mcp.py # MCP 客户端 + 注册表
100
+ │ ├── tools_browser.py # CDP WebSocket 浏览器
101
+ │ ├── tools_computer.py # 桌面控制
102
+ │ ├── tools_network.py # 代理/镜像
103
+ │ ├── tools_rag.py # RAG 知识检索
104
+ │ ├── main.py # CLI 入口
105
+ │ ├── terminal.py # 流式终端
106
+ │ ├── memory.py # 记忆/会话
107
+ │ ├── config.py # 配置加载
108
+ │ └── skills.py # 技能系统
109
+
110
+ ├── src/ # TypeScript 包
111
+ │ ├── core/ # 核心引擎
112
+ │ ├── tools/ # 工具模块 (7 文件)
113
+ │ └── cli/ # CLI 入口
114
+
115
+ ├── cortex_workspace/ # 运行时工作区
116
+ ├── CORTEX.md # 项目知识库
117
+ ├── pyproject.toml # Python 包配置
118
+ ├── package.json # npm 包配置
119
+ └── tsconfig.json # TypeScript 配置
120
+ ```
121
+
122
+ ---
123
+
124
+ ## 43 个工具
125
+
126
+ | 分类 | 工具 |
127
+ |------|------|
128
+ | **文件** | `list_directory` `read_file` `write_file` `edit_file` `glob` `grep` `diff_files` `file_ops` `read_json` `csv_query` |
129
+ | **执行** | `run_shell_command` `run_python` `execute_sql_query` `python_lint` |
130
+ | **网络** | `web_search` `web_fetch` `http_request` `set_proxy` `unset_proxy` `show_proxy` |
131
+ | **记忆** | `remember_fact` `recall_fact` `forget_fact` `ask_user` |
132
+ | **任务** | `task_create` `task_list` `task_update` |
133
+ | **MCP** | `mcp_list_servers` `mcp_list_tools` `mcp_call_tool` `mcp_registry` `mcp_install` `mcp_quick` |
134
+ | **浏览器** | `browser_navigate` `browser_snapshot` `browser_screenshot` |
135
+ | **桌面** | `computer_screenshot` `computer_click` |
136
+ | **镜像** | `pip_mirror` `npm_mirror` |
137
+ | **RAG** | `search_knowledge` `rebuild_knowledge_index` |
138
+ | **时间** | `get_current_time` |
139
+
140
+ ---
141
+
142
+ ## REPL 命令
143
+
144
+ | 命令 | 功能 |
145
+ |------|------|
146
+ | `/help` | 显示帮助 |
147
+ | `/context` | 上下文容量 + 缓存命中率 |
148
+ | `/kb` | 查看知识库 CORTEX.md |
149
+ | `/goal [目标]` | 设置/查看持久化目标 |
150
+ | `/plan [描述]` | 进入规划模式 |
151
+ | `/skills` | 列出所有技能 |
152
+ | `/skill <name>` | 调用技能 |
153
+ | `/mode [s\|a\|y]` | 切换权限模式 (Shift+Tab) |
154
+ | `/model [pro]` | 切换模型 |
155
+ | `/tools` | 列出工具 |
156
+ | `/trace` `/audit` | 审计追踪 |
157
+ | `/memory` | 查看记忆 |
158
+ | `/sessions` | 列出会话 |
159
+ | `@filename` | 文件引用 |
160
+ | `/init` | 初始化项目 |
161
+
162
+ ---
163
+
164
+ ## 权限模式
165
+
166
+ | 模式 | 行为 |
167
+ |------|------|
168
+ | `standard` 🛡️ | SAFE 自动 / WRITE 区内 / SYSTEM 需确认 |
169
+ | `auto-edit` ✏️ | 自动批准编辑 + SYSTEM 放行 |
170
+ | `yolo` ⚠️ | 全部放行 (CI/CD) |
171
+
172
+ ---
173
+
174
+ ## License
175
+
176
+ MIT
cortx-1.0.0/README.md ADDED
@@ -0,0 +1,150 @@
1
+ # Cortex Agent
2
+
3
+ 安全可控的 AI Agent 运行时 — **Harness Agent 架构 + Agentic Loop 引擎**
4
+
5
+ [![Python](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
6
+ [![TypeScript](https://img.shields.io/badge/typescript-5.x-blue.svg)](https://www.typescriptlang.org/)
7
+ [![Node](https://img.shields.io/badge/node-24+-green.svg)](https://nodejs.org/)
8
+ [![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
9
+
10
+ > **Cortex** = 大脑皮层。如同大脑皮层负责感知推理、血脑屏障严格过滤、海马体持久记忆 — Cortex Agent 将 Agentic Loop(推理)、PolicyEngine(安全)、Memory(记忆)融为一体。
11
+
12
+ ---
13
+
14
+ ## 双语言实现
15
+
16
+ | | Python | TypeScript |
17
+ |---|--------|-----------|
18
+ | 位置 | `python/cortex_agent/` | `src/` |
19
+ | 工具数 | 43 | 43 |
20
+ | 安装 | `pip install cortx` | `npm install -g cortx` |
21
+ | CLI 命令 | `ctx` | `ctx` |
22
+
23
+ > 💡 **PyPI: `pip install cortx`,npm: `npm install -g cortx`。运行只需 `ctx`**
24
+
25
+ ---
26
+
27
+ ## 快速开始
28
+
29
+ ```bash
30
+ # Python (3 字母包名)
31
+ pip install cortx
32
+ ctx
33
+
34
+ # TypeScript
35
+ npm install -g cortx
36
+ ctx
37
+ ctx # 交互 REPL
38
+ ctx -q "hello" # 单次查询
39
+ ctx --model pro # 指定模型
40
+
41
+ # 单次查询
42
+ ctx -q "用 Python 写斐波那契函数"
43
+ ```
44
+
45
+ ---
46
+
47
+ ## 设计哲学
48
+
49
+ ```
50
+ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐
51
+ │ Think │ → │ Guard │ → │ Act │ → │ Reflect │
52
+ │ (LLM流式)│ │(Policy) │ │(Executor)│ │(步数收敛)│
53
+ └──────────┘ └──────────┘ └──────────┘ └──────────┘
54
+ ```
55
+
56
+ | 原则 | 说明 |
57
+ |------|------|
58
+ | **Agent 自主决策** | 不注入行为指令,Agent 从工具结果中自行推理 |
59
+ | **完整中介** | 所有工具调用必经 PolicyEngine 4 级审计 |
60
+ | **Share-nothing 隔离** | 每实例独立 work_dir / executor / observer |
61
+
62
+ ---
63
+
64
+ ## 项目结构
65
+
66
+ ```
67
+ ctx/
68
+ ├── python/cortex_agent/ # Python 包
69
+ │ ├── cortex_agent.py # Agentic Loop 核心引擎
70
+ │ ├── policy.py # PolicyEngine 安全策略
71
+ │ ├── llm.py # LLM Provider (DeepSeek/OpenAI)
72
+ │ ├── tools.py # 核心工具 (25)
73
+ │ ├── tools_mcp.py # MCP 客户端 + 注册表
74
+ │ ├── tools_browser.py # CDP WebSocket 浏览器
75
+ │ ├── tools_computer.py # 桌面控制
76
+ │ ├── tools_network.py # 代理/镜像
77
+ │ ├── tools_rag.py # RAG 知识检索
78
+ │ ├── main.py # CLI 入口
79
+ │ ├── terminal.py # 流式终端
80
+ │ ├── memory.py # 记忆/会话
81
+ │ ├── config.py # 配置加载
82
+ │ └── skills.py # 技能系统
83
+
84
+ ├── src/ # TypeScript 包
85
+ │ ├── core/ # 核心引擎
86
+ │ ├── tools/ # 工具模块 (7 文件)
87
+ │ └── cli/ # CLI 入口
88
+
89
+ ├── cortex_workspace/ # 运行时工作区
90
+ ├── CORTEX.md # 项目知识库
91
+ ├── pyproject.toml # Python 包配置
92
+ ├── package.json # npm 包配置
93
+ └── tsconfig.json # TypeScript 配置
94
+ ```
95
+
96
+ ---
97
+
98
+ ## 43 个工具
99
+
100
+ | 分类 | 工具 |
101
+ |------|------|
102
+ | **文件** | `list_directory` `read_file` `write_file` `edit_file` `glob` `grep` `diff_files` `file_ops` `read_json` `csv_query` |
103
+ | **执行** | `run_shell_command` `run_python` `execute_sql_query` `python_lint` |
104
+ | **网络** | `web_search` `web_fetch` `http_request` `set_proxy` `unset_proxy` `show_proxy` |
105
+ | **记忆** | `remember_fact` `recall_fact` `forget_fact` `ask_user` |
106
+ | **任务** | `task_create` `task_list` `task_update` |
107
+ | **MCP** | `mcp_list_servers` `mcp_list_tools` `mcp_call_tool` `mcp_registry` `mcp_install` `mcp_quick` |
108
+ | **浏览器** | `browser_navigate` `browser_snapshot` `browser_screenshot` |
109
+ | **桌面** | `computer_screenshot` `computer_click` |
110
+ | **镜像** | `pip_mirror` `npm_mirror` |
111
+ | **RAG** | `search_knowledge` `rebuild_knowledge_index` |
112
+ | **时间** | `get_current_time` |
113
+
114
+ ---
115
+
116
+ ## REPL 命令
117
+
118
+ | 命令 | 功能 |
119
+ |------|------|
120
+ | `/help` | 显示帮助 |
121
+ | `/context` | 上下文容量 + 缓存命中率 |
122
+ | `/kb` | 查看知识库 CORTEX.md |
123
+ | `/goal [目标]` | 设置/查看持久化目标 |
124
+ | `/plan [描述]` | 进入规划模式 |
125
+ | `/skills` | 列出所有技能 |
126
+ | `/skill <name>` | 调用技能 |
127
+ | `/mode [s\|a\|y]` | 切换权限模式 (Shift+Tab) |
128
+ | `/model [pro]` | 切换模型 |
129
+ | `/tools` | 列出工具 |
130
+ | `/trace` `/audit` | 审计追踪 |
131
+ | `/memory` | 查看记忆 |
132
+ | `/sessions` | 列出会话 |
133
+ | `@filename` | 文件引用 |
134
+ | `/init` | 初始化项目 |
135
+
136
+ ---
137
+
138
+ ## 权限模式
139
+
140
+ | 模式 | 行为 |
141
+ |------|------|
142
+ | `standard` 🛡️ | SAFE 自动 / WRITE 区内 / SYSTEM 需确认 |
143
+ | `auto-edit` ✏️ | 自动批准编辑 + SYSTEM 放行 |
144
+ | `yolo` ⚠️ | 全部放行 (CI/CD) |
145
+
146
+ ---
147
+
148
+ ## License
149
+
150
+ MIT
@@ -0,0 +1,42 @@
1
+ [build-system]
2
+ requires = ["setuptools>=75", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "cortx"
7
+ version = "1.0.0"
8
+ description = "安全可控的 AI Agent 运行时框架 — Harness Agent 架构 + Agentic Loop 引擎"
9
+ readme = "README.md"
10
+ license = {text = "MIT"}
11
+ authors = [
12
+ {name = "Cortex Agent Contributors"}
13
+ ]
14
+ keywords = ["ai-agent", "llm", "agent-framework", "harness", "agentic-loop", "mcp", "browser-automation"]
15
+ classifiers = [
16
+ "Development Status :: 4 - Beta",
17
+ "Intended Audience :: Developers",
18
+ "License :: OSI Approved :: MIT License",
19
+ "Programming Language :: Python :: 3",
20
+ "Programming Language :: Python :: 3.10",
21
+ "Programming Language :: Python :: 3.11",
22
+ "Programming Language :: Python :: 3.12",
23
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
24
+ "Topic :: Software Development :: Libraries :: Application Frameworks",
25
+ ]
26
+ requires-python = ">=3.10"
27
+ dependencies = [
28
+ "openai>=1.0",
29
+ "httpx>=0.27",
30
+ ]
31
+
32
+ [project.optional-dependencies]
33
+ dev = [
34
+ "pytest>=8",
35
+ "pytest-asyncio",
36
+ ]
37
+
38
+ [project.scripts]
39
+ ctx = "cortex_agent.main:main"
40
+
41
+ [tool.setuptools.packages.find]
42
+ where = ["python"]
@@ -0,0 +1,11 @@
1
+ """
2
+ Cortex Agent — Python Package
3
+ ══════════════════════════════════
4
+
5
+ Harness Agent 架构 + Agentic Loop 运行时
6
+ """
7
+
8
+ from .cortex_agent import CortexAgent, AgentConfig, LLMProvider, registry
9
+ from .policy import PolicyEngine
10
+
11
+ __version__ = '1.0.0'
@@ -0,0 +1,163 @@
1
+ """
2
+ 配置加载器 — 从 settings.json 读取配置,合并到 AgentConfig
3
+
4
+ 加载优先级(从低到高):
5
+ 1. 代码默认值 (AgentConfig dataclass defaults)
6
+ 2. settings.json(项目级: {cwd}/.cortex/settings.json)
7
+ 3. settings.json(用户级: ~/.cortex/settings.json)
8
+ 4. 环境变量 (CORTEX_API_KEY, CORTEX_MODEL, etc.)
9
+ 5. CLI 参数
10
+
11
+ settings.json 结构:
12
+ {
13
+ "model": "flash",
14
+ "provider": "deepseek",
15
+ "providers": {
16
+ "deepseek": {
17
+ "api_key": "sk-...",
18
+ "base_url": "https://api.deepseek.com/v1",
19
+ "models": { "flash": "deepseek-v4-flash", "pro": "deepseek-v4-pro" }
20
+ },
21
+ "openai": {
22
+ "api_key": "sk-...",
23
+ "base_url": "https://api.openai.com/v1",
24
+ "models": { "gpt4": "gpt-4o", "gpt4m": "gpt-4o-mini" }
25
+ }
26
+ },
27
+ "max_steps": 10,
28
+ "work_dir": "./cortex_workspace",
29
+ "loop_timeout": 120,
30
+ "think_timeout": 60,
31
+ "auto_extract_memory": true,
32
+ "memory_enabled": true,
33
+ "sessions_enabled": true
34
+ }
35
+ """
36
+
37
+ import os, json
38
+ from typing import Optional
39
+
40
+
41
+ def _find_upwards(filename: str, start: str = None) -> Optional[str]:
42
+ """从 start 向上搜索 filename,返回完整路径或 None。"""
43
+ d = os.path.abspath(start or os.getcwd())
44
+ while True:
45
+ candidate = os.path.join(d, filename)
46
+ if os.path.isfile(candidate):
47
+ return candidate
48
+ parent = os.path.dirname(d)
49
+ if parent == d:
50
+ return None
51
+ d = parent
52
+
53
+
54
+ def load_settings(project_dir: str = None) -> dict:
55
+ """加载合并后的设置字典。用户级覆盖项目级。"""
56
+ merged = {}
57
+
58
+ # 1. 项目级
59
+ proj = _find_upwards(".cortex/settings.json", project_dir or os.getcwd())
60
+ if proj:
61
+ try:
62
+ with open(proj, "r", encoding="utf-8") as f:
63
+ merged.update(json.load(f))
64
+ except Exception:
65
+ pass
66
+
67
+ # 2. 用户级 (~)
68
+ user = os.path.join(os.path.expanduser("~"), ".cortex", "settings.json")
69
+ if os.path.isfile(user):
70
+ try:
71
+ with open(user, "r", encoding="utf-8") as f:
72
+ merged.update(json.load(f))
73
+ except Exception:
74
+ pass
75
+
76
+ # 3. 环境变量覆盖
77
+ if os.environ.get("CORTEX_API_KEY"):
78
+ merged.setdefault("providers", {})
79
+ provider = merged.get("provider", "deepseek")
80
+ merged["providers"].setdefault(provider, {})
81
+ merged["providers"][provider]["api_key"] = os.environ["CORTEX_API_KEY"]
82
+ if os.environ.get("CORTEX_MODEL"):
83
+ merged["model"] = os.environ["CORTEX_MODEL"]
84
+
85
+ return merged
86
+
87
+
88
+ def apply_to_config(config, settings: dict):
89
+ """将 settings dict 应用到 AgentConfig 对象。"""
90
+ from .cortex_agent import LLMProvider
91
+
92
+ # Provider 注册
93
+ LLMProvider.setup(
94
+ providers=settings.get("providers"),
95
+ active=settings.get("provider", "deepseek"),
96
+ )
97
+
98
+ # API key:先取当前 provider 的 api_key,再取 settings 顶层,再取 config 已有值
99
+ active_provider = LLMProvider.provider_name()
100
+ providers = settings.get("providers", {})
101
+ provider_cfg = providers.get(active_provider, {})
102
+ api_key = provider_cfg.get("api_key", "") or settings.get("api_key", "") or config.api_key
103
+ config.api_key = api_key
104
+
105
+ # 简单字段
106
+ for key in ("model", "max_steps", "tool_timeout", "system_prompt",
107
+ "max_context_msgs", "loop_timeout", "think_timeout",
108
+ "work_dir", "memory_dir", "sessions_dir", "skills_dir",
109
+ "memory_enabled", "sessions_enabled", "auto_extract_memory",
110
+ "permission_mode", "permission_remember", "workspace_only",
111
+ "context_limit"):
112
+ if key in settings:
113
+ setattr(config, key, settings[key])
114
+
115
+
116
+ def create_default_settings(path: str) -> dict:
117
+ """在 path 路径创建默认 settings.json。返回写入的 dict。"""
118
+ default = {
119
+ "model": "pro",
120
+ "provider": "deepseek",
121
+ "providers": {
122
+ "deepseek": {
123
+ "api_key": "",
124
+ "base_url": "https://api.deepseek.com/v1",
125
+ "models": {"flash": "deepseek-v4-flash", "pro": "deepseek-v4-pro"},
126
+ }
127
+ },
128
+ "max_steps": 10,
129
+ "loop_timeout": 120,
130
+ "think_timeout": 60,
131
+ "auto_extract_memory": True,
132
+ "memory_enabled": True,
133
+ "sessions_enabled": True,
134
+ "permission_mode": "standard",
135
+ "permission_remember": True,
136
+ "workspace_only": False,
137
+ "context_limit": 1000000,
138
+ "mcpServers": {
139
+ "playwright": {
140
+ "command": "npx",
141
+ "args": ["-y", "@playwright/mcp@latest"],
142
+ "description": "浏览器自动化(Microsoft 官方)"
143
+ },
144
+ "fetch": {
145
+ "command": "python",
146
+ "args": ["-m", "mcp_server_fetch"],
147
+ "description": "HTTP 抓取 + HTML→Markdown"
148
+ },
149
+ "sqlite": {
150
+ "command": "npx",
151
+ "args": ["-y", "@modelcontextprotocol/server-sqlite"],
152
+ "description": "SQLite 数据库查询"
153
+ },
154
+ "context7": {
155
+ "url": "https://mcp.context7.com/mcp",
156
+ "description": "实时库/框架文档查询"
157
+ }
158
+ }
159
+ }
160
+ os.makedirs(os.path.dirname(path), exist_ok=True)
161
+ with open(path, "w", encoding="utf-8") as f:
162
+ json.dump(default, f, ensure_ascii=False, indent=2)
163
+ return default