Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ jobs:
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install pytest for live test-discovery and execution checks
run: python -m pip install --disable-pip-version-check pytest
- uses: actions/download-artifact@v4
with:
name: python-support-archives
Expand Down
94 changes: 49 additions & 45 deletions README.md

Large diffs are not rendered by default.

24 changes: 15 additions & 9 deletions docs/feature-matrix.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,31 @@
# Python Support 功能矩阵(Feature Matrix)

本文档维护 `io.github.lithe-idea.python-support` 插件在 6 个目标发布平台上的实现与真实执行验证状态(插件功能矩阵与测试证据仅在本插件仓库维护,不进入宿主仓库)。
本文档维护 `io.github.lithe-idea.python-support`(`v0.2.0`)插件在 6 个目标发布平台上的实现与真实执行验证状态(插件功能矩阵与测试证据仅在本插件仓库维护,不进入宿主仓库)。

## 状态定义

- `✅ 已验证`:已在目标平台实机完成打包安装、真实上游二进制/运行时进程执行及宿主端到端测试验证。
- `⏳ 待实机验证(pending)`:已在 `plugin.json`、脚本与对应平台归档(`dist/python-support-0.1.0-<platform>.zip`)中完成实现,并通过归档路径/大小写安全检查、Lithe Store 规则校验以及 Unix/Windows 双清单真实 Core `ValidatePluginManifest` 契约校验;但尚未在对应 OS/架构实机或 CI runner 上执行原生子进程工作流,严禁在未实跑前标为已验证。
- `🚧 规划中(M3)`:归属后续 M3 插件后端进程版本。
- `⏳ 待实机验证(pending)`:已在 `plugin.json`、脚本与对应平台归档(`dist/python-support-0.2.0-<platform>.zip`)中完成实现,并通过归档路径/大小写安全检查、Lithe Store 规则校验以及 Unix/Windows 双清单真实 Core `ValidatePluginManifest` 契约校验;但尚未在对应 OS/架构实机或 CI runner 上执行原生子进程工作流,严禁在未实跑前标为已验证。
- `🚧 待宿主开放(blocked on host capability)`:插件端协议与代码已完整实现并通过真实 Core 解码验证,待桌面宿主开放对应能力版本后启用清单声明。

## 跨平台能力与验证矩阵

| 能力域 | 功能项 | `darwin-arm64` | `darwin-x64` | `windows-x64` / `windows-arm64` | `linux-x64` / `linux-arm64` | 最近实机验证 | 实现与测试证据路径(本仓库) |
| --- | --- | --- | --- | --- | --- | --- | --- |
| 语言基础 (`languages`) | `.py` / `.pyi` / `.pyw` 识别、`#` 行注释、括号/引号配对、项目标记与 `.venv` / `venv` 依赖目录 | ✅ 已验证 | ⏳ pending(归档与清单已校验) | ⏳ pending(归档与 Windows 清单已校验) | ⏳ pending(归档与清单已校验) | `2026-11-18`(`darwin-arm64`) | `io.github.lithe-idea.python-support/plugin.json`<br>`scripts/test.mjs`<br>`e2e/host/desktop/internal/workbench/python_support_plugin_e2e_test.go` |
| 语言服务器 (`languageServers`) | 内置打包 `pyrefly` `1.4.1`(`bin/pyrefly` / `bin/pyrefly.exe`、`lsp`、`--version`、`workspaceConfiguration`、`indexingExclusions`,保留 `.venv` 原生自动发现) | ✅ 已验证 | ⏳ pending(`macos-x86_64` 二进制已打包校验) | ⏳ pending(`bin/pyrefly.exe` 已打包与契约校验) | ⏳ pending(`musl` 二进制已打包校验) | `2026-11-18`(`darwin-arm64`) | `io.github.lithe-idea.python-support/plugin.json`<br>`vendor-lock.json`<br>`scripts/package.mjs`<br>`scripts/package/archives.test.mjs`<br>`scripts/test.mjs`<br>`e2e/host/desktop/internal/workbench/python_support_plugin_e2e_test.go` |
| 工具链与虚拟环境 (`toolDefinitions`) | `python` 4 层解析:项目绑定 → `.venv` / `venv`(受工作区信任门控,保留字面软链路径)→ 全局设置 → `VIRTUAL_ENV` + `PATH` → 16 条跨平台自动发现规则 | ✅ 已验证 | ⏳ pending(清单与 Core 规则已校验) | ⏳ pending(`Scripts/python.exe` / `python.exe` 布局与发现规则已通过 Core 校验) | ⏳ pending(清单与 Core 规则已校验) | `2026-11-18`(`darwin-arm64`) | `io.github.lithe-idea.python-support/plugin.json`<br>`scripts/test.mjs`<br>`e2e/host/desktop/internal/workbench/python_support_plugin_e2e_test.go` |
| 构建模型与运行 (`buildSystems: python`) | `scripts/build_model.py`(`-I -B`,纯 AST + `tomllib` / `vendor/tomli` 零代码执行)静态发现 `[project.scripts]`、包 `__main__.py`、顶层 `__main__` 脚本、Django `manage.py`、FastAPI ASGI、Flask WSGI 并派生 `run` 配置 | ✅ 已验证 | ⏳ pending(归档已校验) | ⏳ pending(归档已校验) | ⏳ pending(归档已校验) | `2026-11-18`(`darwin-arm64`) | `io.github.lithe-idea.python-support/scripts/build_model.py`<br>`io.github.lithe-idea.python-support/plugin.json`<br>`scripts/test.mjs`<br>`e2e/host/desktop/internal/workbench/python_support_plugin_e2e_test.go` |
| 任务与测试 (`buildSystems: python`) | `pip install -r requirements.txt`、`mypy`(含诊断 `lineMatcher`)、`pytest`(支持工作区/项目/目标及 `suite` / `case` 过滤,解析 `.pytest_cache/lithe-junit.xml`) | ✅ 已验证 | ⏳ pending(归档已校验) | ⏳ pending(归档已校验) | ⏳ pending(归档已校验) | `2026-11-18`(`darwin-arm64`) | `io.github.lithe-idea.python-support/plugin.json`<br>`scripts/test.mjs`<br>`e2e/host/desktop/internal/workbench/python_support_plugin_e2e_test.go` |
| 语言基础 (`languages`) | `.py` / `.pyi` / `.pyw` 识别、`#` 行注释、括号/引号配对、项目标记与 `.venv` / `venv` / `.conda` 依赖目录 | ✅ 已验证 | ⏳ pending(归档与清单已校验) | ⏳ pending(归档与 Windows 清单已校验) | ⏳ pending(归档与清单已校验) | `2026-11-18`(`darwin-arm64`) | `io.github.lithe-idea.python-support/plugin.json`<br>`scripts/test.mjs`<br>`e2e/host/desktop/internal/workbench/python_support_plugin_e2e_test.go` |
| 插件后端与语言服务器启动解析 (`backend` + `languageServers`) | 纯 Python(`python -I -B`)stdio JSON-RPC 后端 `scripts/backend.py`(协商 `litheLogging` 0 与 `litheFunctions` 0);`pyrefly.resolveLaunch` 按 `platform.os` 返回包内 `bin/pyrefly`(Unix)或 `bin/pyrefly.exe`(Windows)与 `["lsp"]`,在宿主传入 `tools.python.executable` 时自动注入 `workspaceConfiguration.python.pythonPath`(支持项目外 conda / uv / pyenv 解释器),缺失或未信任项目环境时优雅省略 `pythonPath` 回退 `pyrefly 1.4.1` 原生 `.venv` 发现 | ✅ 已验证 | ⏳ pending(`macos-x86_64` 二进制与纯 Python 后端已打包校验) | ⏳ pending(`bin/pyrefly.exe` 平台分支已通过 Core `DecodePluginLanguageServerLaunch` 校验) | ⏳ pending(`musl` 二进制与纯 Python 后端已打包校验) | `2026-11-18`(`darwin-arm64`) | `io.github.lithe-idea.python-support/scripts/lithe_rpc.py`<br>`io.github.lithe-idea.python-support/scripts/backend.py`<br>`io.github.lithe-idea.python-support/plugin.json`<br>`scripts/test.mjs`<br>`e2e/host/desktop/internal/workbench/python_support_plugin_e2e_test.go` |
| 工具链与环境自动发现 (`toolDefinitions`) | `python` 4 层解析:项目绑定 → `.venv` / `venv` / `.conda`(受工作区信任门控,保留字面软链路径)→ 全局设置 → `VIRTUAL_ENV` + `PATH` → 16 条跨平台自动发现规则(覆盖 `UV_PYTHON_INSTALL_DIR`、`XDG_DATA_HOME`、`PYENV_ROOT`、`CONDA_ENVS_PATH`、`CONDA_PREFIX`、`WORKON_HOME`、`LOCALAPPDATA`、`APPDATA`、Homebrew、Framework、`~/.pyenv`、`~/.local/share/uv`、`*conda*/envs/*`、`miniforge*/envs/*`) | ✅ 已验证 | ⏳ pending(清单与 Core 规则已校验) | ⏳ pending(`Scripts/python.exe` / `python.exe` 布局与环境变量发现规则已通过 Core 校验) | ⏳ pending(清单与 Core 规则已校验) | `2026-11-18`(`darwin-arm64`) | `io.github.lithe-idea.python-support/plugin.json`<br>`scripts/test.mjs`<br>`e2e/host/desktop/internal/workbench/python_support_plugin_e2e_test.go` |
| 构建模型与运行 (`buildSystems: python` + `provider`) | `scripts/build_provider.py`(`python -I -B`,`lithe/build/model`)复用 `scripts/build_model.py` 纯 AST + `tomllib` / `vendor/tomli` 静态提取 `[project.scripts]`、包 `__main__.py`、顶层 `__main__` 脚本、Django `manage.py`、FastAPI ASGI、Flask WSGI 并派生 7 类声明式 `run` 配置;支持损坏 `pyproject.toml` 降级与修复后恢复诊断,并在协商 `litheBuild` 1 时支持 `lithe/build/runEntrypoints` | ✅ 已验证 | ⏳ pending(归档已校验) | ⏳ pending(归档已校验) | ⏳ pending(归档已校验) | `2026-11-18`(`darwin-arm64`) | `io.github.lithe-idea.python-support/scripts/build_model.py`<br>`io.github.lithe-idea.python-support/scripts/build_provider.py`<br>`io.github.lithe-idea.python-support/plugin.json`<br>`scripts/test.mjs`<br>`e2e/host/desktop/internal/workbench/python_support_plugin_e2e_test.go` |
| 动态 `pytest` 测试树与测试执行 (`litheTestDiscovery` + `junitXml`) | `lithe/build/discoverTests` 通过有界可取消 `pytest --collect-only` 收集函数、测试类方法与 `@pytest.mark.parametrize` 参数化用例(缓存写入 `${workspaceStateDir}`,按条数和 UTF-8 字节限制返回 `litheTestDiscovery` v0);`lithe/build/test` 支持精确 node ID 与 JUnit 类名重跑,单个用例须带套件、`lithe/build/progress` 流式输出及 `.pytest_cache/lithe-junit.xml` 解码;保留 `pip install -r requirements.txt` 与 `mypy` 任务 | ✅ 已验证 | ⏳ pending(归档已校验) | ⏳ pending(归档已校验) | ⏳ pending(归档已校验) | `2026-11-18`(`darwin-arm64`) | `io.github.lithe-idea.python-support/scripts/build_provider.py`<br>`io.github.lithe-idea.python-support/plugin.json`<br>`scripts/test.mjs`<br>`e2e/host/desktop/internal/workbench/python_support_plugin_e2e_test.go` |
| 独立工具构建系统 (`uv` / `conda` / `ruff`) | `uv`(`sync` / `lock`)、`conda`(`env update --file environment.yml --prune`)、`ruff`(`check` 含 `lineMatcher` / `format`)按各自标记文件独立检测与规划 | ✅ 已验证 | ⏳ pending(归档已校验) | ⏳ pending(归档已校验) | ⏳ pending(归档已校验) | `2026-11-18`(`darwin-arm64`) | `io.github.lithe-idea.python-support/plugin.json`<br>`scripts/test.mjs`<br>`e2e/host/desktop/internal/workbench/python_support_plugin_e2e_test.go` |
| 调试器 (`debugAdapters: debugpy`) | 内置打包 `debugpy` `1.8.22`(`stdio` DAP,`["-I", "-B"]` + `scripts/debugpy_adapter.py`、`--log-dir ${logDir}`、适配器与 `launch` 双重设置 `PYTHONDONTWRITEBYTECODE=1` 保持插件目录零写入、支持远程 `attach` + `pathMappings`) | ✅ 已验证 | ⏳ pending(归档已校验) | ⏳ pending(归档已校验) | ⏳ pending(归档已校验) | `2026-11-18`(`darwin-arm64`) | `io.github.lithe-idea.python-support/plugin.json`<br>`io.github.lithe-idea.python-support/scripts/debugpy_adapter.py`<br>`vendor-lock.json`<br>`scripts/test.mjs`<br>`e2e/host/desktop/internal/workbench/python_support_plugin_e2e_test.go` |
| 终端输出跳转 (`outputLinkMatchers`) | Python Traceback `File "...", line N` 点击定位源码与行号 | ✅ 已验证 | ⏳ pending(归档已校验) | ⏳ pending(归档已校验) | ⏳ pending(归档已校验) | `2026-11-18`(`darwin-arm64`) | `io.github.lithe-idea.python-support/plugin.json`<br>`scripts/test.mjs`<br>`e2e/host/desktop/internal/workbench/python_support_plugin_e2e_test.go` |
| 新建项目向导 (`projectGenerators`) | `python-project`:选择并固定项目级 `python` 工具链(`pinAs: "project"`),可选 `none` / `venv (.venv)` / `uv (.venv)` 与示例代码生成(Windows 自动将 `python3` 命令切换为 `python`) | ✅ 已验证 | ⏳ pending(归档已校验) | ⏳ pending(Windows 清单 `python` 命令切换已校验) | ⏳ pending(归档已校验) | `2026-11-18`(`darwin-arm64`) | `io.github.lithe-idea.python-support/plugin.json`<br>`io.github.lithe-idea.python-support/templates/python/`<br>`scripts/package/archives.test.mjs`<br>`e2e/host/desktop/internal/projectgen/python_integration_test.go` |
| 国际化 (`l10n`) | 英文默认文案 + `l10n/zh-Hans.json` 简体中文完整设置与分组翻译 | ✅ 已验证 | ⏳ pending(归档与 Core `settingsState` 已校验) | ⏳ pending(归档与 Core `settingsState` 已校验) | ⏳ pending(归档与 Core `settingsState` 已校验) | `2026-11-18`(`darwin-arm64`) | `io.github.lithe-idea.python-support/l10n/zh-Hans.json`<br>`scripts/test.mjs`<br>`e2e/host/desktop/internal/workbench/python_support_plugin_e2e_test.go` |
| 插件后端高级能力(M3) | `pytest --collect-only` 原生测试树发现、依赖树视图、`pyproject.toml` 原生配置页编辑器、工具链后端深度枚举 | 🚧 规划中(M3) | 🚧 规划中(M3) | 🚧 规划中(M3) | 🚧 规划中(M3) | — | — |
| 工具链 Provider 协议 (`litheToolchains` / `toolchains/query`) | `scripts/toolchain_provider.py` 与 `backend.py` 已完整实现 `toolchains/query`(解析 `~/.conda/environments.txt`、`CONDA_ENVS_PATH`、`UV_PYTHON_INSTALL_DIR`、`PYENV_ROOT`、Poetry/Pipenv 外部虚拟环境、`.python-version` 与 `pyproject.toml` `requires-python`,严格排除工作区内目录并通过真实 Core `toolchains.decodeReply` 校验);清单层待桌面宿主开放 `toolchainProviders` 后启用(见下方前置说明) | 🚧 待宿主开放 `toolchainProviders`(后端协议与 Core 解码已在 `darwin-arm64` 实测通过) | 🚧 待宿主开放 `toolchainProviders` | 🚧 待宿主开放 `toolchainProviders` | 🚧 待宿主开放 `toolchainProviders` | `2026-11-18`(协议与 Core 解码验证) | `io.github.lithe-idea.python-support/scripts/toolchain_provider.py`<br>`io.github.lithe-idea.python-support/scripts/backend.py`<br>`scripts/test.mjs`<br>`e2e/host/desktop/internal/workbench/python_support_plugin_e2e_test.go` |

## `toolchainProviders` 宿主前置条件说明

1. **桌面宿主能力门禁**:`Lithe-core-rust` 已支持 `toolchainProviders: 0`(`litheToolchains` 的 `toolchains/query` 与 `toolchains.decodeReply`),但当前桌面宿主 `desktop/internal/pluginhost/pluginhost.go` 的 `Declared()` 尚未声明 `toolchainProviders`。若在 `plugin.json` 中直接写入 `"requires": {"toolchainProviders": 0}`,当前桌面宿主安装校验会拒绝安装整个插件。
2. **自举约束**:Core 清单校验(`validate_packaged_provider_backend`)要求声明 `toolchainProviders` 的插件后端必须使用包内可执行文件(`packaged`)或包内自带运行时(`packagedRuntime`)自举,不能依赖所要发现的外部 `tool: "python"` 启动。
3. **当前落地方案**:桌面宿主通过 `toolDefinitions` 中的 16 条声明式规则和新增的 `.conda` 项目环境候选发现解释器。独立协议测试协商 `experimental.litheToolchains` 并验证 `toolchains/query` 响应。正式接线仍需桌面宿主开放能力、清单声明及打包后端自举,当前安装包通过固定宿主校验。
Loading
Loading