Skip to content

Commit e56dbb6

Browse files
authored
Merge pull request #93 from Lithe-IDEA/feat/2122-venv-toolchain
feat(toolchain): 支持项目内工具环境解释器链接链校验与本机信任存储
2 parents 661ef0f + a3bab79 commit e56dbb6

14 files changed

Lines changed: 1484 additions & 233 deletions

File tree

‎rust/contracts/rust-core-api.md‎

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -497,17 +497,17 @@ or removing a command fails until the table changes in the same commit.
497497
| `toolchains.failureReply` | Build the JSON-RPC error reply for a query that missed its deadline or found no backend, so the host passes it to `toolchains.decodeReply` like a provider's own error; cancellation has none |
498498
| `toolchains.resolvePins` | Validate a captured local document and find the nearest ancestor directory pin, retaining dormant and legacy entries without probing or writing |
499499
| `toolchains.editPins` | Apply one bounded batch of directory pin edits to a captured local document without writing native files |
500-
| `toolchains.catalogState` | Validate machine-wide SDK registrations without a project |
501-
| `toolchains.editCatalog` | Merge confirmed machine-wide SDK registrations and defaults |
500+
| `toolchains.catalogState` | Validate machine-wide SDK registrations and optional workspace project-code trust without a project |
501+
| `toolchains.editCatalog` | Merge confirmed machine-wide SDK registrations, defaults and explicit workspace project-code trust |
502502
| `toolchains.pinStoragePlan` | Declare bounded workspace-native pin and ignore sources |
503503
| `toolchains.decodePinDocument` | Validate a complete native source or supply the absent-source default |
504504
| `toolchains.editPinSources` | Plan deterministic pin and Git ignore source edits without native I/O |
505505
| `toolchains.resolveConsumerPreferences` | Validate an inert consumer preference document and resolve one tool's explicit Run, consumer, directory or workspace choice while keeping workspace/consumer inheritance symbolic; no native files or launch authority |
506506
| `toolchains.editConsumerPreferences` | Edit or reset one exact consumer/directory tool preference; return the document and effective input without native writes |
507-
| `toolchains.resolve` | Resolve the fixed/project/global/automatic layers from one generation-bound snapshot, retaining unmet requirements, unavailable providers with their cause, conflicts and terminal fixed-value failures |
507+
| `toolchains.resolve` | Resolve the fixed/project/global/automatic layers from one generation-bound snapshot, retaining nearest project candidates, unmet requirements, unavailable providers with their cause, conflicts and terminal fixed-value failures |
508508
| `toolchains.checkVersion` | Match captured output with an enabled plugin definition's version expression and compare generic numeric components with an optional minimum; never starts a probe |
509-
| `toolchains.discoveryPlan` | Return platform-filtered definition-owned scan declarations, layouts, probes, PATH entries, login-shell home variables and budgets; never scans native directories |
510-
| `toolchains.candidates` | List one tool's login-shell homes (declared `environment` variables and, from the optional `commandHomes`, declared commands found on the PATH) and host-scanned installations with checked executables, versions or skip reasons, and the automatic-layer choice; never starts a probe. A shell home that checks out is also an `installations` entry with provider `host:shell`, once per canonical home, so a picker can offer every home the resolver may run; `selected` remains the automatic layer's own choice |
509+
| `toolchains.discoveryPlan` | Return platform-filtered definition-owned scan declarations, layouts, probes, PATH entries, login-shell home variables, project-file candidates and budgets; never scans native directories |
510+
| `toolchains.candidates` | List one tool's root project-file candidates, login-shell homes (declared `environment` variables and, from the optional `commandHomes`, declared commands found on the PATH) and host-scanned installations with checked executables, versions or skip reasons, and the automatic-layer choice; never starts a probe. A shell home that checks out is also an `installations` entry with provider `host:shell`, once per canonical home, so a picker can offer every home the resolver may run; `selected` remains the automatic layer's own choice |
511511
| `toolchains.instantiateLaunch` | Expand an enabled tool definition's `launch` template for a selected executable, entry, runtime arguments and arguments; a part the template cannot carry is `plugin.toolchain.launchMismatch`; performs no I/O |
512512
| `run.decodeStart` | Validate a plugin backend's `lithe/host/run/start` params against its manifest and the workspace, and return the normalized start with temporary-file paths substituted |
513513
| `debug.decodeBackendConfiguration` | Validate a plugin backend's `lithe/host/debug/start` params against its manifest and return the qualified adapter, request, label and configuration |
@@ -7234,15 +7234,22 @@ must not infer executable names from opaque runtime IDs.
72347234

72357235
### Global SDK registrations without an open project
72367236

7237-
`toolchains.catalogState` accepts `{document:string|null,platform,filesystemCaseSensitive?}`
7238-
and returns `{status:"ok",state:{document,storage:{relativePath:"toolchains/global.json",maximumBytes:262144}}}`.
7237+
`toolchains.catalogState` accepts `{document:string|null,platform,filesystemCaseSensitive?,workspaceRoot?}`
7238+
and returns `{status:"ok",state:{document,storage:{relativePath:"toolchains/global.json",maximumBytes:262144},projectCodeAllowed?}}`.
7239+
When `workspaceRoot` is supplied, `projectCodeAllowed` reports whether that normalized workspace
7240+
root is in the machine-local `trustedWorkspaces` list (`false` when `workspaceRoot` is `""`);
7241+
when `workspaceRoot` is omitted, `projectCodeAllowed` is omitted.
72397242
Native clients resolve the relative path below their platform user-preference directory,
72407243
never below a workspace, SDK, installed package or application bundle. Reading an absent
72417244
source returns `{version:1,tools:{}}` and must not create a directory or file.
72427245

7243-
`toolchains.editCatalog` accepts the same source fields and a nonempty `edits` array of
7244-
`{tool,homes:[absoluteHome],defaultHome:string|null}`. Each edit replaces only that tool's
7245-
registrations and default; other tools, including dormant plugins, remain intact. At most
7246+
`toolchains.editCatalog` accepts `{document:string|null,platform,filesystemCaseSensitive?,edits?,workspaceTrust?}`,
7247+
where at least one of a nonempty `edits` array of `{tool,homes:[absoluteHome],defaultHome:string|null}`
7248+
or `workspaceTrust:{workspace,trusted}` is required. Each tool edit replaces only that tool's
7249+
registrations and default; other tools, dormant plugins and `trustedWorkspaces` remain intact.
7250+
`workspaceTrust` grants or revokes machine-local `projectCodeAllowed` trust for one normalized
7251+
workspace root (at most 256 distinct workspaces), preserving `tools`; revoking trust on an absent
7252+
document returns `changed:false,document:null` and creates no file. At most
72467253
64 tools and 32 distinct homes per tool are accepted. Native platform path normalization
72477254
and case identity apply before deduplication. A selected default is registered if needed;
72487255
null clears only the default. Empty registrations plus null remove the tool entry.
@@ -7270,3 +7277,9 @@ existing precedence remains fixed consumer choice, project override, global defa
72707277
automatic discovery. Clearing the global default exposes live automatic selection without
72717278
removing manual registrations. Each new consumer resolves fresh facts and probes; already
72727279
running processes retain their launch-time environment.
7280+
7281+
When no candidate resolves, `toolchains.resolve` reports the first failure in resolution
7282+
order. A nearer directory masks the project root even when the workspace is a filesystem
7283+
root. Optional project discovery omits paths outside the supported native bounds, so a
7284+
usable pin still resolves. Both project and external installations can omit `pathPrepend`
7285+
directories explicitly observed as missing.

‎rust/contracts/toolchain-global-v1.schema.json‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,15 @@
3737
}
3838
}
3939
}
40+
},
41+
"trustedWorkspaces": {
42+
"type": "array",
43+
"maxItems": 256,
44+
"uniqueItems": true,
45+
"items": {
46+
"type": "string",
47+
"minLength": 1
48+
}
4049
}
4150
}
4251
}

0 commit comments

Comments
 (0)