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
6 changes: 3 additions & 3 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
"request": "launch",
"name": "Debug clice",
"program": "${workspaceFolder}/build/Debug/bin/clice",
"args": ["server", "--mode", "socket", "--port", "50051"],
"args": ["serve", "--mode", "socket", "--port", "50051"],
"cwd": "${workspaceFolder}"
},
{
"type": "lldb",
"request": "launch",
"name": "Debug clice (socket, RelWithDebInfo)",
"name": "Debug clice (tcp, RelWithDebInfo)",
"program": "${workspaceFolder}/build/RelWithDebInfo/bin/clice",
"args": ["server", "--mode", "socket", "--port", "50051"],
"args": ["serve", "--mode", "socket", "--port", "50051"],
"cwd": "${workspaceFolder}"
},
{
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Download the latest binary from the [releases page](https://github.com/clice-io/
| **VS Code** | Install the [clice extension](https://marketplace.visualstudio.com/items?itemName=ykiko.clice-vscode) from the Marketplace |
| **Neovim** | Add `editors/nvim` to your runtime path: `vim.opt.rtp:append("/path/to/clice/editors/nvim")` |
| **Zed** | Load `editors/zed` as a local extension |
| **Other** | Any LSP client works — point it at `clice server` |
| **Other** | Any LSP client works — point it at `clice serve` |

### Project Setup

Expand Down
16 changes: 3 additions & 13 deletions docs/en/dev/test-and-debug.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Equivalent to:

### Integration Tests

End-to-end tests that start a real clice server and communicate via LSP protocol.
End-to-end tests that start a real `clice serve` instance and communicate via LSP protocol.

```bash
pixi run integration-test # default RelWithDebInfo
Expand Down Expand Up @@ -82,21 +82,11 @@ Prerequisites outside the pixi env:
If you want to attach a debugger to clice, start it in socket mode independently, then connect a client.

```shell
./build/Debug/bin/clice server --mode socket --port 50051
./build/Debug/bin/clice serve --mode socket --port 50051
```

After the server starts, you can connect a client in two ways:

### Connect via pytest

Run a single integration test against the running instance:

```shell
pytest -s --log-cli-level=INFO \
tests/integration/lifecycle/test_file_operation.py::test_did_open \
--mode=socket --port=50051
```

### Connect via VS Code

Configure the clice extension to connect to your running instance:
Expand Down Expand Up @@ -130,6 +120,6 @@ The extension lives in-tree at `editors/vscode/`:

2. Open the **repository root** in VS Code (the launch configurations are in `.vscode/launch.json` at the root).

3. Create `.vscode/settings.json` with the socket config above.
3. Create `.vscode/settings.json` with the tcp config above.

4. Press `F5` and select `VSCode Extension (pipe)` or `VSCode Extension (socket)` to launch an Extension Development Host window.
8 changes: 4 additions & 4 deletions docs/en/guide/editors.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Add to `~/.config/helix/languages.toml`:
```toml
[language-server.clice]
command = "clice"
args = ["server"]
args = ["serve"]

[[language]]
name = "cpp"
Expand All @@ -53,7 +53,7 @@ With the built-in eglot:
(with-eval-after-load 'eglot
(add-to-list 'eglot-server-programs
'((c-mode c-ts-mode c++-mode c++-ts-mode)
. ("clice" "server"))))
. ("clice" "serve"))))
```

### Sublime Text
Expand All @@ -65,7 +65,7 @@ Install the [LSP package](https://packagecontrol.io/packages/LSP), then add to i
"clients": {
"clice": {
"enabled": true,
"command": ["clice", "server"],
"command": ["clice", "serve"],
"selector": "source.c | source.c++"
}
}
Expand All @@ -80,7 +80,7 @@ Open `Settings → Configure Kate → LSP Client → User Server Settings` and a
{
"servers": {
"c": {
"command": ["clice", "server"],
"command": ["clice", "serve"],
"url": "https://github.com/clice-io/clice",
"highlightingModeRegex": "^(C|C\\+\\+)$"
}
Expand Down
12 changes: 1 addition & 11 deletions docs/zh/dev/test-and-debug.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,21 +82,11 @@ pixi 环境之外的依赖:
如果想在 clice 上附加调试器,推荐先以 socket 模式单独启动 clice,然后连接客户端。

```shell
./build/Debug/bin/clice server --mode socket --port 50051
./build/Debug/bin/clice serve --mode socket --port 50051
```

服务器启动后,可以通过以下两种方式连接客户端:

### 通过 pytest 连接

运行单个集成测试连接到正在运行的 clice 实例:

```shell
pytest -s --log-cli-level=INFO \
tests/integration/lifecycle/test_file_operation.py::test_did_open \
--mode=socket --port=50051
```

### 通过 VS Code 连接

配置 clice 插件连接到正在运行的实例:
Expand Down
8 changes: 4 additions & 4 deletions docs/zh/guide/editors.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Zed 扩展位于 [`editors/zed`](https://github.com/clice-io/clice/tree/main/edi
```toml
[language-server.clice]
command = "clice"
args = ["server"]
args = ["serve"]

[[language]]
name = "cpp"
Expand All @@ -53,7 +53,7 @@ language-servers = ["clice"]
(with-eval-after-load 'eglot
(add-to-list 'eglot-server-programs
'((c-mode c-ts-mode c++-mode c++-ts-mode)
. ("clice" "server"))))
. ("clice" "serve"))))
```

### Sublime Text
Expand All @@ -65,7 +65,7 @@ language-servers = ["clice"]
"clients": {
"clice": {
"enabled": true,
"command": ["clice", "server"],
"command": ["clice", "serve"],
"selector": "source.c | source.c++"
}
}
Expand All @@ -80,7 +80,7 @@ language-servers = ["clice"]
{
"servers": {
"c": {
"command": ["clice", "server"],
"command": ["clice", "serve"],
"url": "https://github.com/clice-io/clice",
"highlightingModeRegex": "^(C|C\\+\\+)$"
}
Expand Down
2 changes: 1 addition & 1 deletion editors/nvim/doc/clice.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ local clice = {

cmd = {
'clice',
'server',
'serve',
},
}

Expand Down
2 changes: 1 addition & 1 deletion editors/nvim/tests/e2e.lua
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ end
local plugin_root = vim.fn.fnamemodify(arg[0], ':p:h:h')
local config = dofile(plugin_root .. '/doc/clice.lua')
config.name = 'clice'
config.cmd = { clice_path, 'server' }
config.cmd = { clice_path, 'serve' }
config.root_dir = fixture_dir

local main_file_uri = vim.uri_from_fname(fixture_dir .. '/' .. scenario.file)
Expand Down
2 changes: 1 addition & 1 deletion editors/vscode/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export async function activate(context: ExtensionContext) {
}
}

let args = ["server"];
let args = ["serve"];
serverOptions = {
run: { command: executable, args: args },
debug: { command: executable, args: args },
Expand Down
2 changes: 1 addition & 1 deletion editors/zed/src/clice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ impl zed::Extension for CliceExtension {
Ok(zed::Command {
command: binary.path,
args: vec![
"server".to_string(),
"serve".to_string(),
],
env: Default::default(),
})
Expand Down
23 changes: 5 additions & 18 deletions src/clice.cc
Original file line number Diff line number Diff line change
Expand Up @@ -84,30 +84,17 @@ int main(int argc, const char** argv) {

int exit_code = 1;

auto server_cmd = deco::cli::command<clice::ServerOptions>("clice server [OPTIONS]");
server_cmd
auto serve_cmd = deco::cli::command<clice::ServerOptions>("clice serve [OPTIONS]");
serve_cmd
.matchAll([&](clice::ServerOptions opts) {
if(opts.help) {
clice::print_usage(server_cmd);
clice::print_usage(serve_cmd);
exit_code = 0;
return;
}
if(!clice::apply_log_level(opts.log_level.value_or("info")))
return;
using clice::ServerMode;
auto mode = opts.mode.value_or(ServerMode::Pipe);
if(mode == ServerMode::Relay) {
exit_code = clice::run_relay_mode(opts.socket.value_or(""));
} else if(mode == ServerMode::Daemon) {
auto workspace = opts.workspace.value_or("");
if(workspace.empty()) {
LOG_ERROR("--workspace is required for daemon mode");
return;
}
exit_code = clice::run_daemon_mode(opts, self_path);
} else {
exit_code = clice::run_server_mode(opts, self_path);
}
exit_code = clice::run_serve_mode(opts, self_path);
})
.on_error([](auto err) { LOG_ERROR("{}", err.message); });

Expand Down Expand Up @@ -181,7 +168,7 @@ int main(int argc, const char** argv) {
clice::print_usage(clice);
};

clice.add({.name = "server", .description = "Start LSP server"}, server_cmd)
clice.add({.name = "serve", .description = "Start LSP server"}, serve_cmd)
Comment thread
16bit-ykiko marked this conversation as resolved.
Comment thread
16bit-ykiko marked this conversation as resolved.
.add({.name = "query", .description = "Query symbol information from a running server"},
query_cmd)
.add({.name = "worker"}, worker_cmd)
Expand Down
45 changes: 0 additions & 45 deletions src/server/service/agentic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include <string>

#include "server/protocol/agentic.h"
#include "support/filesystem.h"
#include "support/logging.h"

#include "kota/async/async.h"
Expand Down Expand Up @@ -126,48 +125,4 @@ int run_agentic_mode(const QueryOptions& opts) {
return exit_code;
}

static kota::task<> relay_forward(kota::ipc::Transport& from, kota::ipc::Transport& to) {
while(true) {
auto msg = co_await from.read_message();
if(!msg)
break;
co_await to.write_message(*msg);
}
to.close();
}

static kota::task<> relay_main(kota::event_loop& loop, int& exit_code, std::string socket_path) {
auto stdio = kota::ipc::StreamTransport::open_stdio(loop);
if(!stdio) {
LOG_ERROR("failed to open stdio transport");
loop.stop();
co_return;
}

auto conn = co_await kota::pipe::connect(socket_path, {}, loop);
if(!conn) {
LOG_ERROR("failed to connect to {}", socket_path);
loop.stop();
co_return;
}

auto socket = std::make_unique<kota::ipc::StreamTransport>(std::move(*conn));

co_await kota::when_all(relay_forward(**stdio, *socket), relay_forward(*socket, **stdio));
exit_code = 0;
loop.stop();
}

int run_relay_mode(llvm::StringRef socket_path) {
logging::stderr_logger("relay", logging::options);

auto path = socket_path.empty() ? path::default_socket_path() : socket_path.str();

kota::event_loop loop;
int exit_code = 1;
loop.schedule(relay_main(loop, exit_code, std::move(path)));
loop.run();
return exit_code;
}

} // namespace clice
2 changes: 0 additions & 2 deletions src/server/service/agentic.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,4 @@ struct QueryOptions {

int run_agentic_mode(const QueryOptions& opts);

int run_relay_mode(llvm::StringRef socket_path);

} // namespace clice
Loading
Loading