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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Lithe 的跨平台应用内核,以及插件契约、插件开发资料和官
| [`rust/contracts/`](rust/contracts) | Core 命令的接口契约和 schema |
| [`rust/fixtures/`](rust/fixtures) | Core 命令的测试数据,Core 测试和桌面端测试共用 |
| [`rust/logging/`](rust/logging) | 日志事件目录 |
| [`shared/plugins/`](shared/plugins) | 插件契约 `contract/v1/`、开发指南 `guides/`、参考 `reference/`、官方 SDK `sdk/{node,java,rust}` 和它们的端到端测试 |
| [`shared/plugins/`](shared/plugins) | 插件契约 `contract/v1/`、开发指南 `guides/`、参考 `reference/`、官方 SDK `sdk/{rust,go,node,java}` 和它们的端到端测试 |
| [`scripts/rust-core/`](scripts/rust-core) | Rust Core 的 CI 脚本:选择受影响的 crate、平台测试放置检查、注释规范检查(模块文档、英文注释、`unsafe` 安全说明、导出项 Rustdoc) |
| [`scripts/logging/`](scripts/logging) | 日志事件目录生成器,从 `rust/logging/events/` 生成 `rust/crates/diagnostics/src/catalog_generated.rs` |

Expand Down Expand Up @@ -43,7 +43,7 @@ Lithe's cross-platform application core, and the single source of the plugin con
| [`rust/contracts/`](rust/contracts) | Interface contracts and schemas for Core commands |
| [`rust/fixtures/`](rust/fixtures) | Test data for Core commands, shared by the Core and desktop tests |
| [`rust/logging/`](rust/logging) | The logging event catalog |
| [`shared/plugins/`](shared/plugins) | The plugin contract `contract/v1/`, guides `guides/`, reference `reference/`, the official SDKs `sdk/{node,java,rust}` and their end-to-end tests |
| [`shared/plugins/`](shared/plugins) | The plugin contract `contract/v1/`, guides `guides/`, reference `reference/`, the official SDKs `sdk/{rust,go,node,java}` and their end-to-end tests |
| [`scripts/rust-core/`](scripts/rust-core) | The Rust Core CI scripts: affected crate selection, the platform test placement check, and the comment rules check (module docs, English comments, `unsafe` safety sections, Rustdoc on exported items) |
| [`scripts/logging/`](scripts/logging) | The logging event catalog generator, which turns `rust/logging/events/` into `rust/crates/diagnostics/src/catalog_generated.rs` |

Expand Down
2 changes: 0 additions & 2 deletions rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 5 additions & 7 deletions rust/contracts/rust-core-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -323,13 +323,14 @@ order, and every id a setting may choose, in menu order, so a settings page can
machine. It fails as `outputStyle.decode` does for an unsupported id or an unknown member. See
`rust/fixtures/terminal/output-encoding-v1.json`.

The Rust core is the shared application runtime for macOS SwiftUI and Windows
React/Tauri. macOS calls the stable C ABI while the Tauri host links the Rust
crate directly. The C ABI remains:
The Rust core is the application runtime shared by every Lithe host. The Go
desktop host links the `staticlib` through cgo and calls the stable C ABI:

```c
const char *lithe_core_version(void);
int32_t lithe_core_is_plain_text(const uint8_t *bytes, size_t length);
char *lithe_core_execute_json(const char *request);
char *lithe_core_execute_document_json(const char *request, const uint8_t *bytes, size_t length);
char *lithe_core_execute_json_with_events(const char *request, void (*callback)(const char *, void *), void *context);
int32_t lithe_core_git_askpass(const char *prompt);
int32_t lithe_core_cancel(const char *operation_id);
Expand All @@ -338,10 +339,7 @@ void lithe_core_install_log_waker(void (*callback)(void *), void *context);
int32_t lithe_core_remove_log_waker(void *context);
```

The macOS package uses the small C bridge in `macos/Sources/LitheRustCore/`. The
canonical C declarations are in `rust/crates/core/include/lithe_core.h`.
Native clients link the `staticlib`; Rust hosts call
`lithe_core::execute_json` and `lithe_core::cancel_operation` directly.
The canonical C declarations are in `rust/crates/core/include/lithe_core.h`.
Strings returned by the core are UTF-8 JSON allocated by Rust. The caller must
release response strings with `lithe_core_free_string`.

Expand Down
1 change: 0 additions & 1 deletion rust/crates/agent-runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ lithe-lsp-transport = { path = "../lsp-transport" }
lithe-platform = { path = "../platform" }
lithe-plugin-agents = { path = "../plugin-agents" }
lithe-plugin-manifest = { path = "../plugin-manifest" }
lithe-plugin-model = { path = "../plugin-model" }
lithe-plugin-rpc = { path = "../plugin-rpc" }
lithe-protocol = { path = "../protocol" }
lithe-request-context = { path = "../request-context" }
Expand Down
47 changes: 0 additions & 47 deletions rust/crates/agent-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,53 +63,6 @@ use std::collections::BTreeMap;
use std::sync::{Arc, OnceLock};
use std::time::{SystemTime, UNIX_EPOCH};

/// The commands of the `agents.*` family.
pub const AGENT_COMMANDS: &[&str] = &[
"agents.configure",
"agents.catalog",
"agents.sessions",
"agents.start",
"agents.prompt",
"agents.cancel",
"agents.updateQueue",
"agents.respondQuestion",
"agents.respondPermission",
"agents.setConfigOption",
"agents.close",
"agents.waitEvents",
"agents.projection",
];

/// The commands of the `agentSessions.*` family.
pub const AGENT_SESSION_COMMANDS: &[&str] = &[
"agentSessions.configure",
"agentSessions.sync",
"agentSessions.forget",
"agentSessions.list",
"agentSessions.search",
"agentSessions.read",
"agentSessions.page",
"agentSessions.stats",
"agentSessions.calls",
];

/// The commands of the `agentLibrary.*` family.
pub const AGENT_LIBRARY_COMMANDS: &[&str] = &[
"agentLibrary.configure",
"agentLibrary.read",
"agentLibrary.save",
"agentLibrary.apply",
"agentLibrary.importSkill",
"agentLibrary.removeSkill",
];

/// The commands of the `agentProviders.*` family.
pub const AGENT_PROVIDER_COMMANDS: &[&str] = &[
"agentProviders.read",
"agentProviders.apply",
"agentProviders.restore",
];

/// The agent catalog, the live sessions, the session records and the
/// agent library.
pub(crate) struct Runtime {
Expand Down
2 changes: 1 addition & 1 deletion rust/crates/build/src/test_outcome.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ mod tests {
.unwrap()
}

// The shared fixture is the cross-platform contract: both hosts feed the
// The shared fixture is the cross-platform contract: every host feeds the
// same facts and must show the same verdict.
#[test]
fn shared_fixture_cases_resolve_to_their_expected_verdicts() {
Expand Down
2 changes: 1 addition & 1 deletion rust/crates/build/src/test_outcome_merge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ mod tests {
use super::*;
use serde_json::Value;

// The shared fixture is the cross-platform contract: both hosts build the
// The shared fixture is the cross-platform contract: every host builds the
// same scope and must keep the same history.
#[test]
fn shared_fixture_cases_merge_to_their_expected_history() {
Expand Down
4 changes: 2 additions & 2 deletions rust/crates/core-rules/src/editor/workbench_state.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
//! Membership and selection rules for editor tab groups.
//!
//! Both hosts keep a different shape of the same fact: which tabs live in which group, which tab a
//! Each host keeps its own shape of the same fact: which tabs live in which group, which tab a
//! group shows, and what happens to that when a tab opens, closes or moves. This module defines one
//! canonical group model (the union of what the two hosts track) and one reducer over it. A host
//! canonical group model (the union of what hosts track) and one reducer over it. A host
//! maps its own state into [`State`], runs one [`Action`], and maps the result back.
//!
//! Layout trees, split ratios, pixels and dragging stay in the host. The reducer only reports which
Expand Down
7 changes: 0 additions & 7 deletions rust/crates/core-rules/src/visibility.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,13 +218,6 @@ impl VisibilityRules {
}
}

/// Whether `name` is one of the effective hidden folder names.
pub fn is_hidden_directory_name(&self, name: &str) -> bool {
self.hidden_directories
.iter()
.any(|hidden| hidden.eq_ignore_ascii_case(name))
}

/// Whether a workspace-relative path is hidden. `path` uses `/` separators.
pub fn is_hidden(&self, path: &str, is_directory: bool) -> bool {
self.is_hidden_of_kind(path, Some(is_directory))
Expand Down
1 change: 0 additions & 1 deletion rust/crates/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ lithe-plugin-manifest = { path = "../plugin-manifest" }
lithe-plugin-lifecycle = { path = "../plugin-lifecycle" }
lithe-plugin-marketplace = { path = "../plugin-marketplace" }
lithe-plugin-model = { path = "../plugin-model" }
lithe-plugin-ui = { path = "../plugin-ui" }
lithe-plugin-output-links = { path = "../plugin-output-links" }
lithe-plugin-rpc = { path = "../plugin-rpc" }
lithe-plugin-web-content = { path = "../plugin-web-content" }
Expand Down
23 changes: 0 additions & 23 deletions rust/crates/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,29 +28,6 @@ pub fn execute_json(request: &str) -> String {
runtime::execute_json(request)
}

/// Starts the existing LSP engine with a native resource owner attached before
/// initialization. The callback only records the ID; it must not call Core.
/// Unlike a wire request, this also preserves ownership when the first write
/// fails and the ordinary start command returns an error.
pub fn start_lsp_owned(
mut payload: serde_json::Value,
registered: impl FnOnce(&str),
) -> Result<serde_json::Value, CoreError> {
lithe_document_uri::resolve_request_paths("lsp.startServer", &mut payload)?;
let request = serde_json::from_value(payload).map_err(|error| {
CoreError::new(ErrorCode::InvalidRequest, "Invalid language-server launch.")
.with_details(error.to_string())
})?;
let response = lithe_lsp_engine::start_server_owned(request, registered)?;
serde_json::to_value(response).map_err(|error| {
CoreError::new(
ErrorCode::Unknown,
"Could not encode language-server launch.",
)
.with_details(error.to_string())
})
}

/// Requests cooperative cancellation of an active operation.
///
/// Rust callers use this entry point; C ABI hosts call `lithe_core_cancel`.
Expand Down
7 changes: 3 additions & 4 deletions rust/crates/core/src/protocol/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ pub enum KeymapCommand {
/// Finds conflicts among the final layered shortcut bindings (`keymap.analyzeConflicts`).
AnalyzeConflicts,
/// Advances the double-Shift gesture recognizer by one event (`keymap.modifierGestureStep`).
/// The rule itself lives in `lithe-core-rules` so the Windows frontend can run it synchronously.
/// The rule itself lives in `lithe-core-rules`.
ModifierGestureStep,
/// Reduces named shortcut schemes (`keymap.schemes.reduce`).
SchemesReduce,
Expand Down Expand Up @@ -735,7 +735,7 @@ pub enum WorkspaceCommand {
/// Searches provider-owned text snapshots in one request (`workspace.searchTextBatch`).
SearchTextBatch,
/// Classifies a batch of workspace-relative paths as hidden or visible (`workspace.classifyVisibility`).
/// The rule lives in `lithe-core-rules` so the Windows frontend can run it synchronously.
/// The rule lives in `lithe-core-rules`.
ClassifyVisibility,
/// Returns the default hidden-path lists (`workspace.visibilityDefaults`), also from `lithe-core-rules`.
VisibilityDefaults,
Expand Down Expand Up @@ -778,8 +778,7 @@ pub enum HistoryCommand {
/// The `editor.*` commands; their names live in [`CoreCommand::parse`].
pub enum EditorCommand {
/// Applies one editor-group state transition: open, close, move, pin, preview, merge or normalize
/// (`editor.workbenchState.reduce`). The rule lives in `lithe-core-rules` so the Windows frontend
/// can run it synchronously inside store updates.
/// (`editor.workbenchState.reduce`). The rule lives in `lithe-core-rules`.
WorkbenchStateReduce,
/// Applies one transition to the editor groups and the tree that divides the editor area
/// among them: a workbench state action, opening a tab, dropping a dragged one or removing
Expand Down
2 changes: 1 addition & 1 deletion rust/crates/core/src/tests/declarative_plugins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ fn validation_probe_cannot_use_settings() {
}

/// A setting declaration is part of the normalized manifest, ordered by ID so
/// two hosts show and store the same list.
/// every host shows and stores the same list.
#[test]
fn settings_are_normalized_in_identifier_order() {
let outcome = validate(fixture("node-runtime.plugin.json"));
Expand Down
2 changes: 1 addition & 1 deletion rust/crates/debug/src/variable_paging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ mod tests {
.unwrap()
}

// Each scenario replays the same plan/reduce sequence both hosts run, so a
// Each scenario replays the same plan/reduce sequence a host runs, so a
// change in the stop rules shows up in the shared fixture first.
#[test]
fn variable_page_plan_matches_the_shared_fixture() {
Expand Down
5 changes: 0 additions & 5 deletions rust/crates/diagnostics/src/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@ use std::collections::BTreeSet;

/// Maximum distinct persisted channels in one session, excluding the overflow sink.
pub const MAX_SESSION_CHANNELS: usize = 128;
/// Fixed routing roots shared by both native hosts.
pub const CHANNEL_ROOTS: [&str; 12] = [
"app", "editor", "perf", "lsp", "vcs", "run", "debug", "terminal", "remote", "agent", "update",
"plugins",
];

/// Closed routing domains; hosts may specialize a domain only with validated segments.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
Expand Down
4 changes: 1 addition & 3 deletions rust/crates/diagnostics/src/logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ pub const MAX_LOG_FILE_BYTES: u64 = 10 * 1024 * 1024;
pub const MAX_LOG_TOTAL_BYTES: u64 = 100 * 1024 * 1024;
/// Performance sampling must not consume the general error-log budget.
pub const MAX_PERFORMANCE_BYTES: u64 = 20 * 1024 * 1024;
/// A diagnostic session expires automatically after fifteen minutes.
pub const DIAGNOSTIC_DURATION_MS: u64 = 15 * 60 * 1000;
/// Total uncompressed log evidence accepted into one export or timeline query.
pub const MAX_LOG_EXPORT_BYTES: usize = 10 * 1024 * 1024;

Expand Down Expand Up @@ -272,7 +270,7 @@ fn severity(level: &str) -> u8 {
}
}

/// Merges module files into a stable timeline and applies the same filters on both hosts.
/// Merges module files into a stable timeline and applies the same filters on every host.
pub fn query_logs(request: LogQueryRequest) -> LogQueryResponse {
let mut lines = Vec::new();
let mut remaining = MAX_LOG_EXPORT_BYTES;
Expand Down
4 changes: 2 additions & 2 deletions rust/crates/diff/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ fn fixture() -> Value {

#[test]
fn compare_texts_matches_shared_fixture() {
// Both hosts render these exact rows; any drift changes what Local History
// and agent diffs show on macOS and Windows at once.
// Hosts render these exact rows; any drift changes what Local History
// and agent diffs show on every platform at once.
for case in fixture()["cases"].as_array().expect("cases") {
let response = compare_texts_command(json!({
"oldText": case["oldText"],
Expand Down
7 changes: 3 additions & 4 deletions rust/crates/editor/src/line_edit.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
//! Deterministic line-level editing transforms shared by both products.
//! Deterministic line-level editing transforms shared by every host.
//!
//! The algorithms operate on UTF-16 code units so offsets map directly onto
//! NSTextView ranges on macOS and JavaScript string indices on Windows. The
//! transforms are pure: they take the source text plus a selection and return
//! The algorithms operate on UTF-16 code units; a host converts its own text
//! offsets to them. The transforms are pure: they take the source text plus a selection and return
//! the replacement text, the replaced range, and the selection to restore.
//! Platform code only applies the result through its native text engine.

Expand Down
4 changes: 2 additions & 2 deletions rust/crates/git-host/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
//! Native Git process ownership, incremental pipe reads, and bounded cleanup.
//!
//! This adapter does not construct Git arguments or interpret Git output.
//! The compatibility Core caller supplies policy and cancellation; both hosts
//! share this native adapter while the existing Git command ABI is retained.
//! The compatibility Core caller supplies policy and cancellation; every host
//! shares this native adapter while the existing Git command ABI is retained.
//! [`ProcessTree`] exposes the same process-tree ownership to long-lived
//! processes whose output a host streams itself.

Expand Down
6 changes: 3 additions & 3 deletions rust/crates/git/src/branch_names.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
//! IDEA-compatible new-branch name cleanup and conflict validation.
//!
//! Both native products show the same new-branch dialog, so the cleanup rules
//! Every host shows the same new-branch dialog, so the cleanup rules
//! mirrored from IDEA's `GitRefNameValidator` and the `git.branch.cleanup.symbol`
//! default live here instead of in either platform. The module is pure: it never
//! default live here instead of in a host. The module is pure: it never
//! starts Git and only reads the reference facts the caller already loaded.

use lithe_protocol::{CoreError, ErrorCode};
Expand Down Expand Up @@ -59,7 +59,7 @@ pub enum GitBranchNameReferenceKind {

#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
/// Stable new-branch validation outcomes shared by both products.
/// Stable new-branch validation outcomes shared by every host.
pub enum GitBranchNameErrorCode {
/// The submit-time name is empty.
Empty,
Expand Down
2 changes: 1 addition & 1 deletion rust/crates/git/src/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
//! `GraphColorManagerImpl`, `DottedFilterEdgesGenerator`,
//! `PrintElementGeneratorImpl`, `GraphElementComparatorByLayoutIndex`,
//! `NaturalComparator`), Apache-2.0, Copyright 2000-2024 JetBrains s.r.o. and
//! contributors. See `macos/Resources/GitGraph/NOTICE.txt`.
//! contributors. See `rust/fixtures/git/graph-idea/NOTICE.txt`.

use lithe_core_rules::file_names::compare_reference_names;
use lithe_protocol::{CoreError, ErrorCode};
Expand Down
2 changes: 1 addition & 1 deletion rust/crates/git/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//! serialized responses, which `lithe-core` re-exports unchanged.

// The initial projection/routing IR is deliberately not command- or host-facing
// until both native products can consume the same versioned contract.
// until hosts can consume one versioned contract.
mod authentication_failure;
mod branch_names;
pub mod catalog;
Expand Down
8 changes: 0 additions & 8 deletions rust/crates/lsp-engine/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,6 @@ pub fn start_server(request: StartServerRequest) -> Result<StartServerResponse,
engine().start_server(request)
}

/// Native host ownership hook; it does not add an application command.
pub fn start_server_owned(
request: StartServerRequest,
registered: impl FnOnce(&str),
) -> Result<StartServerResponse, CoreError> {
engine().start_server_owned(request, registered)
}

/// Performs a bounded graceful shutdown while retaining the session record.
pub fn stop_server(request: SessionRequest) -> Result<(), CoreError> {
engine().session(&request.session_id)?.stop()
Expand Down
2 changes: 1 addition & 1 deletion rust/crates/network/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Network proxy policy normalization shared by the macOS and Windows hosts.
//!
//! The user-facing proxy settings (mode, server, credentials, exclusions) are
//! normalized and validated here so both hosts interpret the same stored
//! normalized and validated here so every host interprets the same stored
//! values identically. Platforms only map the returned policy onto their own
//! network stack: `connectionProxyDictionary` plus an authentication delegate
//! on macOS, and the HTTP client configuration on Windows. What an exclusion
Expand Down
2 changes: 1 addition & 1 deletion rust/crates/plugin-manifest/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//!
//! A declarative plugin carries no host-loaded code. The host reads its
//! `plugin.json`, asks this module to validate and normalize it, and launches
//! the declared external processes itself. Both products must produce the
//! the declared external processes itself. Every host must produce the
//! same outcome for the fixtures in `shared/plugins/contract/v1/`.
//!
//! Content problems in a manifest or request are reported as `rejected`
Expand Down
2 changes: 1 addition & 1 deletion rust/crates/plugin-manifest/src/views.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//! declares. The backend answers each view event with a whole view, patches
//! against the view the host drew last, or nothing. Core checks the result
//! against the surface's vocabulary and the plugin's declared settings,
//! actions and tools, so both products draw the same nodes and refuse the
//! actions and tools, so every host draws the same nodes and refuses the
//! same results; the host only renders.

use crate::{validate_manifest_value, DeclarativePluginManifest};
Expand Down
Loading
Loading