platform-lsp-integrate
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseUsing the Salesforce LSP
使用Salesforce LSP
The plugin hosts a local MCP server named
that lazily spawns Salesforce Language Server children and
exposes their semantic capabilities as MCP tools. This skill is the contract
other skills follow when they call those tools, and the answer to "how do I use
the Salesforce LSP?" — what each tool does, how to read its result, what every
error code means, and how to fall back when the host is absent.
salesforce-developmentsalesforce-lspThis is a documentation/reference skill. It does not author or deploy code; it
tells you (and other skills) how to drive the LSP tools correctly.
This plugin build vendors Apex + SOQL only. Thehost ships the Apex language server (salesforce-lsp) and the SOQL language server. The LWC language server is intentionally not bundled in this plugin — the@salesforce/apex-lstools are registered by the host but will always return anlwc.*-class envelope here. Treat anyunavailablecall as unavailable and use the fallback (read the component source / deploy-compile).lwc.*
salesforce-developmentsalesforce-lsp这是一个文档/参考类技能,不负责编写或部署代码;它会告诉你(以及其他技能)如何正确调用LSP工具。
本插件版本仅支持Apex + SOQL。主机包含Apex语言服务器(salesforce-lsp)和SOQL语言服务器。LWC语言服务器未包含在本插件中——主机虽注册了@salesforce/apex-ls工具,但在此版本中始终返回lwc.*类型的响应。请将任何unavailable调用视为不可用,并使用回退方案(读取组件源码/部署编译)。lwc.*
When to Use This Skill
何时使用本技能
- A user asks how to use the Salesforce LSP, or which LSP/MCP tools are available.
- A user asks what a specific tool does (,
apex.diagnostics,validate_soql, etc.) or how to read its output.complete_soql - An LSP tool returned an error envelope (,
lsp_disabled,spawn_timeout,circuit_open,no_apex_workspace) and you need to know what it means and how to recover.no_org_connected - You're authoring or reviewing another skill that calls an LSP tool and need the canonical call/fallback pattern.
- The LSP seems broken and you need to debug it (,
lsp.health, the kill switch).${CLAUDE_PLUGIN_ROOT}/bin/lsp-doctor
- 用户询问如何使用Salesforce LSP,或有哪些可用的LSP/MCP工具。
- 用户询问特定工具的功能(如、
apex.diagnostics、validate_soql等)或如何读取其输出。complete_soql - LSP工具返回错误响应(、
lsp_disabled、spawn_timeout、circuit_open、no_apex_workspace),你需要了解其含义及恢复方法。no_org_connected - 你正在编写或审核另一个调用LSP工具的技能,需要规范的调用/回退模式。
- LSP出现故障,你需要调试它(使用、
lsp.health、终止开关)。${CLAUDE_PLUGIN_ROOT}/bin/lsp-doctor
The Tools
工具列表
All tools are served by the MCP server (invoke names follow
the plugin-prefixed pattern:
, where dots in
tool names become underscores — e.g. becomes
). Spawning
is lazy: a tool that needs a language server brings the child up on first call (a
one-time cold start of a few seconds for Apex), then reuses it. The pure
static-analysis tools never spawn anything.
salesforce-lspmcp__plugin_salesforce-development_salesforce-lsp__<tool_name>apex.diagnosticsmcp__plugin_salesforce-development_salesforce-lsp__apex_diagnostics所有工具均由MCP服务器****提供服务(调用名称遵循插件前缀格式:,工具名称中的点会替换为下划线——例如变为)。启动是延迟式的:需要语言服务器的工具会在首次调用时启动子进程(Apex的首次冷启动需要几秒时间),之后会复用该进程。纯静态分析工具从不启动任何进程。
salesforce-lspmcp__plugin_salesforce-development_salesforce-lsp__<tool_name>apex.diagnosticsmcp__plugin_salesforce-development_salesforce-lsp__apex_diagnosticsApex (spawns the Apex LSP)
Apex(启动Apex LSP)
| Tool | Purpose | Key input | Key output |
|---|---|---|---|
| Compile-check a | | |
| Type/signature at a position | | hover markdown |
| Outline of a file's symbols | | symbol tree |
| Code-completion at a position | | completion items |
| 工具 | 用途 | 关键输入 | 关键输出 |
|---|---|---|---|
| 检查 | | |
| 获取指定位置的类型/签名信息 | | 悬停信息(markdown格式) |
| 获取文件的符号大纲 | | 符号树 |
| 获取指定位置的代码补全建议 | | 补全项 |
SOQL
SOQL
| Tool | Purpose | Spawns? | Key output |
|---|---|---|---|
| Parse a SOQL string for syntax errors | SOQL LSP | |
| Schema-aware completion at a cursor (SObjects, fields, picklist values resolved against the org) | SOQL LSP | |
| Statically pull every inline | No (pure static) | |
| Selectivity heuristics (optional org LIMIT-0 probe) | No by default | selectivity report |
| Invalidate the cached org describe so completion re-fetches | No | |
Just deployed a field/object and it won't resolve? When a SOQL or Apex reference to a freshly-deployed field fails (e.g., orNo such column 'Foo__c'doesn't offer it) right after a deploy, the cached org describe is stale — callcomplete_soqlto invalidate it, then re-run the check before assuming a code error or renaming anything. This is the lever for post-deploy schema lag; reach for it before treating the failure as a bug in your query/class. (It only clears the local cache; it can't speed up server-side propagation, so if the org itself hasn't finished publishing the field, re-running after a moment is the fallback.)refresh_org_schema
| 工具 | 用途 | 是否启动进程? | 关键输出 |
|---|---|---|---|
| 解析SOQL字符串,检查语法错误 | SOQL LSP | |
| 基于光标位置的 schema 感知补全(根据组织解析SObjects、字段、选择列表值) | SOQL LSP | |
| 从Apex中静态提取所有内联 | 否(纯静态分析) | |
| 选择性启发式分析(可选的组织LIMIT-0探测) | 默认否 | 选择性报告 |
| 使缓存的组织描述失效,以便补全操作重新获取最新信息 | 否 | |
刚部署了字段/对象但无法解析? 当部署后立即引用新部署的字段(例如,或No such column 'Foo__c'未提供该字段的补全建议)失败时,说明缓存的组织描述已过期——调用**complete_soql**使其失效,然后重新运行检查,不要直接认为是代码错误或重命名字段。这是解决部署后 schema 延迟的方法;在将失败视为查询/类中的bug之前,请先使用此方法。(它仅清除本地缓存;无法加快服务器端的传播速度,因此如果组织本身尚未完成字段发布,回退方案是等待片刻后重新运行。)refresh_org_schema
LWC — not available in this build
LWC——本版本不可用
The tools (, , ,
, ) are registered by the host but the LWC
language server is not vendored in this plugin. Every call returns an
unavailable envelope. For LWC work, fall back to reading the component
source/templates directly or deploy-compiling and reading the CLI errors.
lwc.*lwc.diagnosticslwc.hoverlwc.definitionlwc.completionlwc.workspace_symbolslwc.*lwc.*lwc.diagnosticslwc.hoverlwc.definitionlwc.completionlwc.workspace_symbolslwc.*Diagnostics / health
诊断/健康检查
| Tool | Purpose | Spawns? |
|---|---|---|
| Read-only view of kill-switch mode, workspace, per-server state, circuit-breaker state, cold-spawn timing, apex-ls version | No — never spawns |
Coordinates everywhere are one-based (/).
diagnostic coordinates are relative to the query string, not a file — when a
query came from , translate back using that query's range.
linecolumnvalidate_soqlextract_soql_from_apex| 工具 | 用途 | 是否启动进程? |
|---|---|---|
| 只读查看终止开关模式、工作区、每个服务器的状态、断路器状态、冷启动时间、apex-ls版本 | 否——从不启动进程 |
所有坐标均为基于1的索引(/)。的诊断坐标是相对于查询字符串的,而非文件——当查询来自时,请使用该查询的范围转换坐标。
linecolumnvalidate_soqlextract_soql_from_apexThe Call / Fallback Contract
调用/回退约定
Every skill that calls an LSP tool follows the same three rules:
- Prefer the LSP tool over guessing. If a tool exists for the step (validate a query, compile-check a class, complete against the org schema), call it before falling back to hand-analysis.
- Treat an error envelope as "unavailable," never as "passed." A tool may
return instead of a result (see Error Codes). On any such code, record
{ error: <code> }in your report and continue down the fallback path — never report the input as valid/clean just because the check didn't run.<tool>=unavailable: <code> - Degrade, don't fail. The LSP is an accelerator, not a hard dependency. If
the host isn't available at all, the tools simply won't exist — fall back to the CLI/manual path for that step and say so.
salesforce-lsp
每个调用LSP工具的技能都遵循以下三条规则:
- 优先使用LSP工具而非猜测。 如果某步骤有对应的工具(验证查询、检查类编译情况、根据组织schema补全),请先调用工具,再回退到手动分析。
- 将错误响应视为“不可用”,而非“通过”。 工具可能返回而非结果(参见错误代码)。对于任何此类代码,请在报告中记录
{ error: <code> },并继续执行回退路径——绝不要因为检查未运行就将输入视为有效/无问题。<tool>=unavailable: <code> - 降级处理,而非失败。 LSP是加速器,而非硬依赖。如果主机完全不可用,工具将不存在——请回退到该步骤的CLI/手动路径,并告知用户。
salesforce-lsp
When the LSP host is absent
当LSP主机不可用时
If the plugin/host isn't available, the MCP tools above are not registered, so a
call to (e.g.) will not resolve. Detect this the same way you
detect an error envelope — the tool is unavailable — and use the documented
fallback:
validate_soql| LSP tool unavailable | Fallback |
|---|---|
| Deploy/compile via |
| Smoke-check by running the query read-only via |
| |
| Read the file(s) and locate |
| Read the source directly |
| Read the component source/templates directly, or deploy-compile and read CLI errors |
如果插件/主机不可用,上述MCP工具未注册,因此调用(例如)将无法解析。检测方式与检测错误响应相同——工具不可用——并使用文档中记录的回退方案:
validate_soql| LSP工具不可用 | 回退方案 |
|---|---|
| 通过 |
| 通过 |
| 使用 |
| 读取文件并手动定位 |
| 直接读取源码 |
| 直接读取组件源码/模板,或通过部署编译并读取CLI错误 |
Error Codes
错误代码
A tool returns (or, for , a ) instead of
a result. Each maps to a recovery:
{ error: <code> }complete_soqlhint| Code | Meaning | What to do |
|---|---|---|
| The kill switch ( | Use the non-LSP fallback; or re-enable the LSP (see Debugging) |
| The language server didn't come up in time | Retry once; if it persists, fall back and run |
| Repeated spawn failures tripped the breaker; calls are short-circuited | Fall back now; investigate with |
| No | Expected in a non-Apex project; nothing to check |
| ( | Keyword completion still works; ask for exact field/object names or connect an org. Do not surface |
The first three are transient/config states shared by every spawning tool; the
rest are expected, healthy states for a particular workspace/org/file context —
not signs of a broken install. ( / are
LWC-only codes; in this build the LWC server is not vendored, so returns
unavailable regardless.)
no_lwc_bundlesunsupported_lwc_filelwc.*工具会返回(对于,则返回)而非结果。每个代码对应一种恢复方法:
{ error: <code> }complete_soqlhint| 代码 | 含义 | 处理方法 |
|---|---|---|
| 终止开关( | 使用非LSP回退方案;或重新启用LSP(参见调试部分) |
| 语言服务器未及时启动 | 重试一次;如果问题持续,回退并运行 |
| 多次启动失败触发了断路器;调用被短路 | 立即回退;使用 |
| 任何包目录下都没有 | 非Apex项目中的预期情况;无需检查 |
| ( | 关键字补全仍可工作;询问用户确切的字段/对象名称或连接组织。请勿将 |
前三个是所有启动进程的工具共享的临时/配置状态;其余是特定工作区/组织/文件上下文的预期健康状态——并非安装损坏的迹象。( / 是LWC专属代码;在本版本中,LWC服务器未包含,因此始终返回不可用。)
no_lwc_bundlesunsupported_lwc_filelwc.*Debugging the LSP
调试LSP
Three layers, cheapest first:
-
(MCP tool). The fastest check — never spawns a child. Reports the kill-switch mode, resolved workspace, per-server status, circuit-breaker state, last cold-spawn timing, and the vendored apex-ls version. Ask Claude to "run lsp.health," or call the
lsp.healthtool directly.lsp.health -
(CLI). A deeper, install-level diagnostic for support and onboarding. Verifies the committed bundles exist, the vendored apex-ls artifacts resolve, the org-schema cache is parseable, and each LSP child can actually spawn. Exits
bin/lsp-doctorwhen healthy,0with structured per-check output when something is wrong.1bash"${CLAUDE_PLUGIN_ROOT}"/bin/lsp-doctor # human-readable report "${CLAUDE_PLUGIN_ROOT}"/bin/lsp-doctor --json # machine-readable "${CLAUDE_PLUGIN_ROOT}"/bin/lsp-doctor --no-spawn # skip child-spawn probes (CI/restricted)(In this buildwill report the LWC server as missing — that is expected; only Apex + SOQL are vendored here.)lsp-doctor -
. Emits single-line JSON telemetry (spawn timing, cache hits, circuit events, per-tool latency) to stderr. Off by default (zero overhead).
SFDX_LSP_DEBUG=1
分为三个层面,按成本从低到高排列:
-
(MCP工具)。 最快的检查方法——从不启动子进程。报告终止开关模式、已解析的工作区、每个服务器的状态、断路器状态、上次冷启动时间,以及包含的apex-ls版本。请Claude“运行lsp.health”,或直接调用
lsp.health工具。lsp.health -
(CLI)。 用于支持和入门的深度安装级诊断工具。验证已提交的包是否存在、包含的apex-ls工件是否可解析、组织schema缓存是否可解析,以及每个LSP子进程是否实际可启动。健康时退出码为
bin/lsp-doctor;出现问题时退出码为0,并输出结构化的检查结果。1bash"${CLAUDE_PLUGIN_ROOT}"/bin/lsp-doctor # 人类可读报告 "${CLAUDE_PLUGIN_ROOT}"/bin/lsp-doctor --json # 机器可读格式 "${CLAUDE_PLUGIN_ROOT}"/bin/lsp-doctor --no-spawn # 跳过子进程启动探测(CI/受限环境)(在本版本中,会报告LWC服务器缺失——这是预期情况;仅包含Apex + SOQL。)lsp-doctor -
。 将单行JSON遥测数据(启动时间、缓存命中、断路器事件、每个工具的延迟)输出到stderr。默认关闭(零开销)。
SFDX_LSP_DEBUG=1
The kill switch — SFDX_LSP
SFDX_LSP终止开关——SFDX_LSP
SFDX_LSPThe fast way to control or disable the LSP. Set the environment variable:
| Effect |
|---|---|
unset / | Every vendored LSP may spawn (default) |
| Only the Apex LSP may spawn; SOQL tools return |
| No LSP spawns; every LSP tool returns |
To rule the LSP in or out of a problem, set and re-run: if the
issue persists it isn't the LSP, and skills will have fallen back to their non-LSP
paths automatically. An unknown value defaults to (with a warning) so a typo
never silently disables the feature.
SFDX_LSP=disabledall快速控制或禁用LSP的方法。设置环境变量:
| 效果 |
|---|---|
未设置 / | 所有包含的LSP均可启动(默认) |
| 仅Apex LSP可启动;SOQL工具返回 |
| 不启动任何LSP;所有LSP工具返回 |
要确定问题是否与LSP相关,请设置并重新运行:如果问题仍然存在,则与LSP无关,技能会自动回退到非LSP路径。未知值默认视为(并发出警告),因此输入错误不会静默禁用功能。
SFDX_LSP=disabledallPre-deploy diagnostics gate
部署前诊断网关
A hook () runs Apex diagnostics on the
/ files a / is about to push,
and emits a decision. It is fail-open: any error (including a missing/slow
LSP) allows the deploy. Mode is controlled by
( | | , default ) — surfaces diagnostics without
blocking; denies a deploy that has Apex compile errors.
PreToolUsebin/lsp-precheck.cls.triggersf project deploy startvalidateSFDX_LSP_DEPLOY_GATEoffwarnblockwarnwarnblockPreToolUsebin/lsp-prechecksf project deploy startvalidate.cls.triggerSFDX_LSP_DEPLOY_GATEoffwarnblockwarnwarnblockVerification
验证
- Asked "how do I use the Salesforce LSP tools?", this skill is the match and lists the tools, their inputs/outputs, and the fallback contract.
- Appears in the listing as
/skills.platform-lsp-integrate - Given an error code (e.g. ), it explains the meaning and the correct recovery without treating the unrun check as a pass.
no_apex_workspace
- 当被询问“如何使用Salesforce LSP工具?”时,本技能会匹配并列出工具、其输入/输出以及回退约定。
- 在列表中显示为
/skills。platform-lsp-integrate - 给定错误代码(例如),它会解释含义和正确的恢复方法,不会将未运行的检查视为通过。
no_apex_workspace
Cross-Skill Integration
跨技能集成
| Need | Delegate to |
|---|---|
| Compile-check + analyze Apex you just wrote | |
Validate inline SOQL in | |
| Author & run a SOQL query against the org | |
| Pre-deploy diagnostics gate behavior | see "Pre-deploy diagnostics gate" above |
| 需求 | 委托给 |
|---|---|
| 编译检查 + 分析刚编写的Apex | |
验证 | |
| 编写并针对组织运行SOQL查询 | |
| 部署前诊断网关行为 | 参见上述“部署前诊断网关”部分 |