@octocodeai/octocode-engine 16.6.2 → 16.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +150 -109
- package/dist/lsp/client.d.ts +17 -9
- package/dist/lsp/client.js +25 -25
- package/dist/lsp/config.js +1 -1
- package/dist/lsp/lspClientPool.d.ts +2 -0
- package/dist/lsp/lspClientPool.js +9 -4
- package/dist/lsp/manager.js +25 -3
- package/dist/lsp/native.d.ts +2 -1
- package/dist/lsp/resolver.js +10 -4
- package/dist/lsp/serverManifest.d.ts +5 -4
- package/dist/lsp/serverManifest.js +44 -6
- package/dist/lsp/serverManifestData.js +85 -22
- package/dist/lsp/serverProvisioner.js +13 -4
- package/dist/lsp/types.d.ts +11 -0
- package/dist/security/commandValidator.js +64 -0
- package/dist/security/contentSanitizer.js +4 -3
- package/dist/security/discoveryFilter.js +3 -0
- package/dist/security/ignoredPathFilter.js +5 -2
- package/dist/security/pathValidator.js +17 -19
- package/dist/security/registry.js +27 -9
- package/dist/security/securityConstants.d.ts +1 -1
- package/dist/security/securityConstants.js +22 -1
- package/dist/security/withSecurityValidation.js +15 -3
- package/docs/LSP_SERVER_LIFECYCLE.md +258 -0
- package/index.d.ts +8 -2
- package/package.json +12 -9
package/README.md
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
[](https://github.com/modelcontextprotocol/servers)
|
|
7
7
|
[](https://deepwiki.com/bgauryy/octocode)
|
|
8
|
+
|
|
8
9
|
[](https://octocode.ai)
|
|
9
10
|
[](https://www.youtube.com/@Octocode-ai)
|
|
10
11
|
|
|
@@ -33,21 +34,23 @@ Run it as a **CLI** or an **MCP server**. A **Rust engine** keeps every call fas
|
|
|
33
34
|
- [Skills](#skills)
|
|
34
35
|
- [Architecture](#architecture)
|
|
35
36
|
- [Documentation](#documentation)
|
|
37
|
+
- [Troubleshooting](#troubleshooting)
|
|
36
38
|
|
|
37
39
|
---
|
|
38
40
|
|
|
39
41
|
## Quick Start
|
|
40
42
|
|
|
41
|
-
**1.
|
|
43
|
+
**1. Run the Octocode CLI with `npx`**
|
|
42
44
|
|
|
43
45
|
```bash
|
|
44
|
-
|
|
46
|
+
npx octocode --help
|
|
45
47
|
```
|
|
46
48
|
|
|
47
49
|
**2. Authenticate with GitHub** — optional, but unlocks private repositories and higher API rate limits:
|
|
48
50
|
|
|
49
51
|
```bash
|
|
50
|
-
octocode auth login
|
|
52
|
+
npx octocode auth login
|
|
53
|
+
npx octocode status # verify the active token source
|
|
51
54
|
```
|
|
52
55
|
|
|
53
56
|
**3. Choose your interface.** The same engine and 14 tools run identically either way.
|
|
@@ -55,26 +58,26 @@ octocode auth login
|
|
|
55
58
|
**🖥️ CLI** — research straight from your terminal:
|
|
56
59
|
|
|
57
60
|
```bash
|
|
58
|
-
octocode
|
|
61
|
+
npx octocode
|
|
59
62
|
```
|
|
60
63
|
|
|
61
|
-
**🤖 MCP** —
|
|
62
|
-
|
|
63
|
-
- **Cursor / VS Code** — one-click install:
|
|
64
|
-
|
|
65
|
-
[<img src="https://cursor.com/deeplink/mcp-install-dark.svg" alt="Install in Cursor">](https://cursor.com/en/install-mcp?name=octocode&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyJAb2N0b2NvZGVhaS9tY3BAbGF0ZXN0Il19) [<img src="https://img.shields.io/badge/VS_Code-VS_Code?style=flat-square&label=Install%20Server&color=0098FF" alt="Install in VS Code">](https://insiders.vscode.dev/redirect?url=vscode%3Amcp%2Finstall%3F%257B%2522name%2522%253A%2522octocode%2522%252C%2522command%2522%253A%2522npx%2522%252C%2522args%2522%253A%255B%2522%2540octocodeai%252Fmcp%2540latest%255D%257D) [<img alt="Install in VS Code Insiders" src="https://img.shields.io/badge/VS_Code_Insiders-VS_Code_Insiders?style=flat-square&label=Install%20Server&color=24bfa5">](https://insiders.vscode.dev/redirect?url=vscode-insiders%3Amcp%2Finstall%3F%257B%2522name%2522%253A%2522octocode%2522%252C%2522command%2522%253A%2522npx%2522%252C%2522args%2522%253A%255B%2522%2540octocodeai%252Fmcp%2540latest%255D%257D)
|
|
64
|
+
**🤖 MCP** — one-click install:
|
|
66
65
|
|
|
67
|
-
-
|
|
66
|
+
- [<img src="https://cursor.com/deeplink/mcp-install-dark.svg" alt="Install in Cursor">](https://cursor.com/en/install-mcp?name=octocode&config=eyJjb21tYW5kIjoibnB4IiwidHlwZSI6InN0ZGlvIiwiYXJncyI6WyJAb2N0b2NvZGVhaS9tY3BAbGF0ZXN0Il19)
|
|
67
|
+
- [<img src="https://img.shields.io/badge/VS_Code-Install_Server-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white" alt="Install in VS Code">](https://insiders.vscode.dev/redirect/mcp/install?name=octocode&config=%7B%22command%22%3A%22npx%22%2C%22type%22%3A%22stdio%22%2C%22args%22%3A%5B%22%40octocodeai%2Fmcp%40latest%22%5D%7D)
|
|
68
|
+
- [<img src="https://img.shields.io/badge/VS_Code_Insiders-Install_Server-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white" alt="Install in VS Code Insiders">](https://insiders.vscode.dev/redirect/mcp/install?name=octocode&config=%7B%22command%22%3A%22npx%22%2C%22type%22%3A%22stdio%22%2C%22args%22%3A%5B%22%40octocodeai%2Fmcp%40latest%22%5D%7D&quality=insiders)
|
|
69
|
+
- [<img src="https://img.shields.io/badge/Windsurf-Install_Server-1a1a1a?style=flat-square&logoColor=white" alt="Install in Windsurf">](windsurf://mcp/install?name=octocode&config=%7B%22command%22%3A%22npx%22%2C%22type%22%3A%22stdio%22%2C%22args%22%3A%5B%22%40octocodeai%2Fmcp%40latest%22%5D%7D)
|
|
70
|
+
- [<img src="https://kiro.dev/images/add-to-kiro.svg" alt="Install in Kiro">](https://kiro.dev/launch/mcp/add?name=octocode&config=%7B%22command%22%3A%22npx%22%2C%22type%22%3A%22stdio%22%2C%22args%22%3A%5B%22%40octocodeai%2Fmcp%40latest%22%5D%7D)
|
|
71
|
+
- [<img src="https://goose-docs.ai/img/extension-install-dark.svg" alt="Install in Goose">](https://goose-docs.ai/extension?cmd=npx&arg=%40octocodeai%2Fmcp%40latest&id=octocode&name=octocode&description=Evidence-first%20code%20research%20for%20AI%20agents)
|
|
72
|
+
- [<img src="https://files.lmstudio.ai/deeplink/mcp-install-light.svg" alt="Install in LM Studio">](https://lmstudio.ai/install-mcp?name=octocode&config=eyJjb21tYW5kIjoibnB4IiwidHlwZSI6InN0ZGlvIiwiYXJncyI6WyJAb2N0b2NvZGVhaS9tY3BAbGF0ZXN0Il19)
|
|
68
73
|
|
|
69
|
-
|
|
70
|
-
claude mcp add-json octocode --scope user '{"command":"npx","args":["@octocodeai/mcp@latest"]}'
|
|
71
|
-
```
|
|
74
|
+
**Claude Code:**
|
|
72
75
|
|
|
73
|
-
|
|
76
|
+
```bash
|
|
77
|
+
claude mcp add-json octocode --scope user '{"command":"npx","type":"stdio","args":["@octocodeai/mcp@latest"]}'
|
|
78
|
+
```
|
|
74
79
|
|
|
75
|
-
|
|
76
|
-
octocode install
|
|
77
|
-
```
|
|
80
|
+
**Any other client:** `npx octocode install`
|
|
78
81
|
|
|
79
82
|
➡️ Learn more at **[octocode.ai](https://octocode.ai)**.
|
|
80
83
|
|
|
@@ -113,7 +116,7 @@ See [Quick Start](#quick-start) to install in your terminal or AI assistant.
|
|
|
113
116
|
|
|
114
117
|
## Tools
|
|
115
118
|
|
|
116
|
-
Octocode ships **14 research tools**; the same implementations run identically over [MCP](#mcp) and the [CLI](#cli). Local tools are enabled by default; `ENABLE_LOCAL=false` disables them. `ghCloneRepo` is opt-in for MCP (`ENABLE_CLONE=true`) and enabled by default for CLI. All flags: [Configuration Reference](https://github.com/bgauryy/octocode/blob/main/docs/
|
|
119
|
+
Octocode ships **14 research tools**; the same implementations run identically over [MCP](#mcp) and the [CLI](#cli). Local tools are enabled by default; `ENABLE_LOCAL=false` disables them. `ghCloneRepo` is opt-in for MCP (`ENABLE_CLONE=true`) and enabled by default for CLI. All flags: [Configuration Reference](https://github.com/bgauryy/octocode/blob/main/docs/CONFIGURATION.md).
|
|
117
120
|
|
|
118
121
|
**Token knobs.** `concise:true` returns path/title-only lists. `minify` controls file read density: `symbols` = skeleton with line numbers, `standard` = comments/blanks stripped (default), `none` = exact bytes.
|
|
119
122
|
|
|
@@ -148,7 +151,7 @@ Octocode ships **14 research tools**; the same implementations run identically o
|
|
|
148
151
|
|
|
149
152
|
| Tool | What it does |
|
|
150
153
|
|------|--------------|
|
|
151
|
-
| `lspGetSemantics` | Typed semantic navigation. Raw tools support `definition`, `references`, `callers`, `callees`, `callHierarchy`, `hover`, `documentSymbols`, `typeDefinition`, `implementation`, `workspaceSymbol`, `supertypes`, `subtypes`, and `diagnostic`. The CLI uses `octocode search <file> --op <type>` for semantics and `octocode search <file> --symbols` for file or directory symbol outlines. Navigation runs through installed language servers (see the [LSP Tools Reference](https://github.com/bgauryy/octocode/blob/main/docs/
|
|
154
|
+
| `lspGetSemantics` | Typed semantic navigation. Raw tools support `definition`, `references`, `callers`, `callees`, `callHierarchy`, `hover`, `documentSymbols`, `typeDefinition`, `implementation`, `workspaceSymbol`, `supertypes`, `subtypes`, and `diagnostic`. The CLI uses `npx octocode search <file> --op <type>` for semantics and `npx octocode search <file> --symbols` for file or directory symbol outlines. Navigation runs through installed language servers (see the [LSP Tools Reference](https://github.com/bgauryy/octocode/blob/main/docs/OCTOCODE_TOOLS.md#lsp-tools-reference)). |
|
|
152
155
|
|
|
153
156
|
### OQL Search
|
|
154
157
|
|
|
@@ -156,29 +159,44 @@ Octocode ships **14 research tools**; the same implementations run identically o
|
|
|
156
159
|
|------|--------------|
|
|
157
160
|
| `oqlSearch` | Runs typed OQL queries across code, content, structure, files, semantics, repositories, packages, pull requests, commits, artifacts, diff, research, graph, and materialization targets. |
|
|
158
161
|
|
|
159
|
-
Full schemas, fields, and examples for every tool live in [`docs/
|
|
162
|
+
Full schemas, fields, and examples for every tool live in [`docs/OCTOCODE_TOOLS.md`](https://github.com/bgauryy/octocode/blob/main/docs/OCTOCODE_TOOLS.md) (linked under [Documentation](#documentation)).
|
|
160
163
|
|
|
161
164
|
---
|
|
162
165
|
|
|
163
166
|
## MCP
|
|
164
167
|
|
|
165
|
-
The MCP server exposes the Octocode tool catalog directly to your AI assistant over stdio.
|
|
166
|
-
|
|
167
|
-
**Install:** see [Quick Start](#quick-start) for one-click badges, the `claude mcp add-json` command, or the interactive `octocode install` (non-interactive: `octocode install --ide cursor|claude-code|…`).
|
|
168
|
+
The MCP server exposes the Octocode tool catalog directly to your AI assistant over stdio.
|
|
168
169
|
|
|
169
170
|
https://github.com/user-attachments/assets/de8d14c0-2ead-46ed-895e-09144c9b5071
|
|
170
171
|
|
|
171
172
|
### Manual Configuration
|
|
172
173
|
|
|
173
|
-
Add to your MCP client config
|
|
174
|
+
Add to your MCP client config. Pick the package that matches the version you want:
|
|
175
|
+
|
|
176
|
+
**New Octocode (Rust-powered engine)** — use `@octocodeai/mcp`:
|
|
174
177
|
|
|
175
178
|
```json
|
|
176
179
|
{
|
|
177
|
-
"
|
|
178
|
-
"
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
180
|
+
"octocode": {
|
|
181
|
+
"command": "npx",
|
|
182
|
+
"type": "stdio",
|
|
183
|
+
"args": [
|
|
184
|
+
"@octocodeai/mcp@latest"
|
|
185
|
+
]
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
**Classic octocode-mcp** — use `octocode-mcp`:
|
|
191
|
+
|
|
192
|
+
```json
|
|
193
|
+
{
|
|
194
|
+
"octocode": {
|
|
195
|
+
"command": "npx",
|
|
196
|
+
"type": "stdio",
|
|
197
|
+
"args": [
|
|
198
|
+
"octocode-mcp@latest"
|
|
199
|
+
]
|
|
182
200
|
}
|
|
183
201
|
}
|
|
184
202
|
```
|
|
@@ -192,9 +210,9 @@ Add a GitHub token and options under `env` — see [Authentication](#authenticat
|
|
|
192
210
|
Same research engine, no MCP client needed. Local paths route to local tools; `owner/repo[/path]` routes to GitHub.
|
|
193
211
|
|
|
194
212
|
```bash
|
|
195
|
-
octocode auth login # authenticate once
|
|
196
|
-
octocode status # verify setup
|
|
197
|
-
octocode --help # full usage
|
|
213
|
+
npx octocode auth login # authenticate once
|
|
214
|
+
npx octocode status # verify setup
|
|
215
|
+
npx octocode --help # full usage
|
|
198
216
|
```
|
|
199
217
|
|
|
200
218
|
### Commands
|
|
@@ -203,22 +221,22 @@ octocode --help # full usage
|
|
|
203
221
|
|
|
204
222
|
| Command | What it does |
|
|
205
223
|
|---------|--------------|
|
|
206
|
-
| `octocode search <term> <path\|owner/repo>` | Text, regex, AST structural (`--pattern`), or full OQL (`--query`) |
|
|
207
|
-
| `octocode search <path\|owner/repo> --tree` | Browse directory or repository structure |
|
|
208
|
-
| `octocode search <file>` | Read file content; `--content-view exact\|compact\|symbols` or `--raw` |
|
|
209
|
-
| `octocode search <file> --symbols` | Symbol outline for a file or source tree |
|
|
210
|
-
| `octocode search --query <oql-json>` | Full OQL across all target types (code, commits, PRs, packages, artifacts …) |
|
|
224
|
+
| `npx octocode search <term> <path\|owner/repo>` | Text, regex, AST structural (`--pattern`), or full OQL (`--query`) |
|
|
225
|
+
| `npx octocode search <path\|owner/repo> --tree` | Browse directory or repository structure |
|
|
226
|
+
| `npx octocode search <file>` | Read file content; `--content-view exact\|compact\|symbols` or `--raw` |
|
|
227
|
+
| `npx octocode search <file> --symbols` | Symbol outline for a file or source tree |
|
|
228
|
+
| `npx octocode search --query <oql-json>` | Full OQL across all target types (code, commits, PRs, packages, artifacts …) |
|
|
211
229
|
|
|
212
230
|
#### More commands
|
|
213
231
|
|
|
214
|
-
- **GitHub & npm** — `search <…> --target repositories|packages|pullRequests|commits|artifacts`
|
|
215
|
-
- **LSP** — `search <file> --op definition|references|callers|callees|hover|diagnostic|callHierarchy` (`--symbol`, `--line` to narrow)
|
|
216
|
-
- **Cache & clone** — `clone`, `unzip`, `cache fetch|status|clear`
|
|
217
|
-
- **Skills** — `skill --list | --name <skill> | --add <github-
|
|
218
|
-
- **Language servers** — `lsp-server list|install|status|uninstall`
|
|
219
|
-
- **Setup & introspection** — `install`, `auth`, `status`, `tools`, `context`
|
|
232
|
+
- **GitHub & npm** — `npx octocode search <…> --target repositories|packages|pullRequests|commits|artifacts|diff`
|
|
233
|
+
- **LSP** — `npx octocode search <file> --op definition|references|callers|callees|hover|diagnostic|callHierarchy` (`--symbol`, `--line` to narrow)
|
|
234
|
+
- **Cache & clone** — `npx octocode clone`, `npx octocode unzip`, `npx octocode cache fetch|status|clear`
|
|
235
|
+
- **Skills** — `npx octocode skill --list | --name <skill> | --add <github-path> | --install-all`
|
|
236
|
+
- **Language servers** — `npx octocode lsp-server list|install|status|uninstall|clean`
|
|
237
|
+
- **Setup & introspection** — `npx octocode install`, `npx octocode auth`, `npx octocode status`, `npx octocode tools`, `npx octocode context`
|
|
220
238
|
|
|
221
|
-
Full syntax, flags, and exit codes: [CLI
|
|
239
|
+
Full syntax, flags, and exit codes: [Octocode CLI Guide](https://github.com/bgauryy/octocode/blob/main/docs/OCTOCODE_CLI.md)
|
|
222
240
|
|
|
223
241
|
---
|
|
224
242
|
|
|
@@ -234,7 +252,7 @@ environment variables > <octocode-home>/.octocoderc > built-in defaults
|
|
|
234
252
|
2. **Global config**: `<octocode-home>/.octocoderc`, machine-wide defaults read by **both the CLI and the MCP server**.
|
|
235
253
|
3. **Built-in defaults**: used when neither is set.
|
|
236
254
|
|
|
237
|
-
**Octocode home** (`<octocode-home>`) holds the global config, encrypted credentials, sessions, stats, and tmp materialization caches.
|
|
255
|
+
**Octocode home** (`<octocode-home>`) holds the global config, encrypted credentials, sessions, stats, and tmp materialization caches. It defaults by platform and can be overridden with `OCTOCODE_HOME`:
|
|
238
256
|
|
|
239
257
|
| Platform | Location |
|
|
240
258
|
|----------|----------|
|
|
@@ -242,7 +260,7 @@ environment variables > <octocode-home>/.octocoderc > built-in defaults
|
|
|
242
260
|
| Linux | `${XDG_CONFIG_HOME:-~/.config}/.octocode` |
|
|
243
261
|
| Windows | `%APPDATA%\.octocode` |
|
|
244
262
|
|
|
245
|
-
Set values as MCP `env` entries (per client; these win over `.octocoderc`) or globally in `<octocode-home>/.octocoderc` (JSON with comments). **Tokens never go in `.octocoderc`** — use `env` or `octocode auth login`.
|
|
263
|
+
Set values as MCP `env` entries (per client; these win over `.octocoderc`) or globally in `<octocode-home>/.octocoderc` (JSON with comments). **Tokens never go in `.octocoderc`** — use `env` or `npx octocode auth login`.
|
|
246
264
|
|
|
247
265
|
### Common settings
|
|
248
266
|
|
|
@@ -250,6 +268,7 @@ The **Scope** column shows where a setting applies: `Both`, or `MCP` (the CLI ig
|
|
|
250
268
|
|
|
251
269
|
| Env var | `.octocoderc` key | Default | Scope | What it does |
|
|
252
270
|
|---------|-------------------|---------|-------|--------------|
|
|
271
|
+
| `OCTOCODE_HOME` | env only | platform default | Both | Overrides the Octocode data directory for config, credentials, sessions, stats, and caches. |
|
|
253
272
|
| `OCTOCODE_TOKEN` / `GH_TOKEN` / `GITHUB_TOKEN` | env only | unset | Both | GitHub token, in priority order. Tokens stay in env, never in `.octocoderc`. |
|
|
254
273
|
| `GITHUB_API_URL` | `github.apiUrl` | `https://api.github.com` | Both | API endpoint; use `/api/v3` for GitHub Enterprise. |
|
|
255
274
|
| `ENABLE_LOCAL` | `local.enabled` | `true` | Both | Turns local filesystem + LSP tools on/off; set `false` to disable. |
|
|
@@ -263,19 +282,19 @@ The **Scope** column shows where a setting applies: `Both`, or `MCP` (the CLI ig
|
|
|
263
282
|
|
|
264
283
|
> **Local defaults on; clone differs by surface.** Both CLI and MCP default local tools on; set `ENABLE_LOCAL=false` to disable them. The **CLI** defaults clone on, while the **MCP server** requires `ENABLE_CLONE=true`.
|
|
265
284
|
|
|
266
|
-
Per-project overrides and custom LSP servers live in a workspace `.octocode/` folder. For the full `.octocoderc` schema, a ready-to-copy example, clone-cache tuning, GitHub Enterprise setup, and precedence details, see the [Configuration Reference](https://github.com/bgauryy/octocode/blob/main/docs/
|
|
285
|
+
Per-project overrides and custom LSP servers live in a workspace `.octocode/` folder. For the full `.octocoderc` schema, a ready-to-copy example, clone-cache tuning, GitHub Enterprise setup, and precedence details, see the [Configuration Reference](https://github.com/bgauryy/octocode/blob/main/docs/CONFIGURATION.md).
|
|
267
286
|
|
|
268
287
|
---
|
|
269
288
|
|
|
270
289
|
## Authentication Methods
|
|
271
290
|
|
|
272
|
-
GitHub-backed tools require authentication. Any one method is enough. Full details: [Authentication Setup](https://github.com/bgauryy/octocode/blob/main/docs/
|
|
291
|
+
GitHub-backed tools require authentication. Any one method is enough. Full details: [Authentication Setup](https://github.com/bgauryy/octocode/blob/main/docs/CONFIGURATION.md).
|
|
273
292
|
|
|
274
293
|
### Option 1: Octocode CLI (Recommended)
|
|
275
294
|
|
|
276
295
|
```bash
|
|
277
|
-
octocode auth login
|
|
278
|
-
octocode status # verify the active token source
|
|
296
|
+
npx octocode auth login
|
|
297
|
+
npx octocode status # verify the active token source
|
|
279
298
|
```
|
|
280
299
|
|
|
281
300
|
Interactive login lets you choose Octocode browser OAuth or `gh auth login`. Octocode OAuth credentials are stored encrypted on disk.
|
|
@@ -314,7 +333,7 @@ Create a token at [github.com/settings/tokens](https://github.com/settings/token
|
|
|
314
333
|
- **Schema validation** runs before any tool executes; untrusted input size and shape are bounded.
|
|
315
334
|
- **Credentials.** GitHub auth via env tokens, AES-256-GCM-encrypted on-disk OAuth, or the `gh` CLI; tokens are never logged.
|
|
316
335
|
|
|
317
|
-
**Full security model, pipeline, and threat coverage: [SECURITY.md](https://github.com/bgauryy/octocode/blob/main/docs/SECURITY.md).** Related: [Authentication](https://github.com/bgauryy/octocode/blob/main/docs/
|
|
336
|
+
**Full security model, pipeline, and threat coverage: [SECURITY.md](https://github.com/bgauryy/octocode/blob/main/docs/SECURITY.md).** Related: [Authentication](https://github.com/bgauryy/octocode/blob/main/docs/CONFIGURATION.md) · [Configuration](https://github.com/bgauryy/octocode/blob/main/docs/CONFIGURATION.md) · [Credentials](https://github.com/bgauryy/octocode/blob/main/docs/CONFIGURATION.md#github-token)
|
|
318
337
|
|
|
319
338
|
---
|
|
320
339
|
|
|
@@ -336,31 +355,44 @@ Four code-intelligence axes; three are native to the Rust engine and need no ext
|
|
|
336
355
|
## Skills
|
|
337
356
|
|
|
338
357
|
> [Agent Skills](https://agentskills.io/what-are-skills) are a lightweight, open format for extending AI agent capabilities.
|
|
339
|
-
> Browse and install on [**skills.sh/bgauryy/octocode-mcp**](https://www.skills.sh/bgauryy/octocode-mcp)
|
|
358
|
+
> Browse and install on [**skills.sh/bgauryy/octocode-mcp**](https://www.skills.sh/bgauryy/octocode-mcp)
|
|
359
|
+
|
|
360
|
+
These are the skills the Octocode team itself uses to build Octocode. **Six source skills** live under [`skills/`](https://github.com/bgauryy/octocode/tree/main/skills); the separately managed **Awareness** skill lives under [`packages/octocode-awareness/skills/`](https://github.com/bgauryy/octocode/tree/main/packages/octocode-awareness/skills) and is bundled alongside them. The table below is the full seven-skill index. ⭐ **[Research](https://www.skills.sh/bgauryy/octocode-mcp/octocode-research)** is the recommended starting skill for technical research, code work, reviews, refactors, and repeated evidence loops.
|
|
340
361
|
|
|
341
|
-
|
|
362
|
+
Each skill folder includes a human README with purpose, features, workflow, developer notes, and `npx octocode skill` installation. `SKILL.md` stays the compact agent-facing router.
|
|
363
|
+
|
|
364
|
+
Install them with the Octocode CLI through `npx octocode`; no global install is required. Octocode refreshes the canonical source in `~/.octocode/skills/<skill>` and links it into the platform location by default. Pick the platform your agent reads from, or use `common` for the shared `~/.agents/skills` folder.
|
|
342
365
|
|
|
343
366
|
```bash
|
|
344
|
-
npx octocode skill --list
|
|
345
|
-
npx octocode skill --name octocode-
|
|
346
|
-
npx octocode skill --name octocode-
|
|
347
|
-
npx octocode skill --name octocode-
|
|
348
|
-
npx octocode skill --
|
|
367
|
+
npx octocode skill --list # browse available Octocode skills
|
|
368
|
+
npx octocode skill --name octocode-research # install to ~/.agents/skills (common)
|
|
369
|
+
npx octocode skill --name octocode-awareness # install bundled Awareness by name
|
|
370
|
+
npx octocode skill --name octocode-research --platform pi # install for Pi
|
|
371
|
+
npx octocode skill --name octocode-research --platform all --dry-run # preview before installing everywhere
|
|
372
|
+
npx octocode skill --add --path /path/to/skills/octocode-awareness # install from an agent-known local skill path
|
|
373
|
+
npx octocode skill --add owner/repo/skills/my-skill # install any GitHub skill folder
|
|
374
|
+
npx octocode skill --add owner/repo/skills # install every skill in a GitHub skills library
|
|
375
|
+
npx octocode skill --install-all # install every official Octocode skill to ~/.agents/skills
|
|
376
|
+
npx octocode skill --help # read live flags
|
|
349
377
|
```
|
|
350
378
|
|
|
351
|
-
Platforms: `common` (default, `~/.agents/skills`), `cursor
|
|
379
|
+
Platforms: `common` (default, `~/.agents/skills`), `cursor` (`~/.cursor/skills`), `claude` (`~/.claude/skills` and `~/.claude-desktop/skills`), `codex` (`~/.agents/skills`), `opencode` (`~/.config/opencode/skills`), `pi` (`~/.pi/agent/skills`), `copilot` (`~/.copilot/skills`), `gemini` (`~/.gemini/skills`), `all` · Modes: `symlink` (default), `copy`, `hybrid`
|
|
380
|
+
|
|
381
|
+
The repository's cross-vendor sync helper is plan-first and path-safe: dry-run previews disclose replacements, writes require explicit approval, and destination names must be safe single path segments. Pi bundle sync also discloses removals during dry-run and preserves separately managed skills such as Awareness. Skill scripts use `@octocodeai/config` as the single environment-loading boundary.
|
|
352
382
|
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
|
356
|
-
|
|
357
|
-
| [**
|
|
358
|
-
| [**
|
|
359
|
-
| [**RFC Generator**](https://www.skills.sh/bgauryy/octocode-mcp/octocode-rfc-generator) | `octocode-rfc-generator/` | You need a design doc, RFC, architecture proposal, migration plan, or rollout plan before coding. |
|
|
360
|
-
| [**Roast**](https://www.skills.sh/bgauryy/octocode-mcp/octocode-roast) | `octocode-roast/` | You want
|
|
361
|
-
| [**Skills**](https://www.skills.sh/bgauryy/octocode-mcp/octocode-skills) | `octocode-skills/` | You are working on Agent Skills themselves
|
|
362
|
-
| [**
|
|
363
|
-
| [**
|
|
383
|
+
Workflow contracts are equally explicit: Brainstorming run ledgers and hooks stay workspace-scoped; Research can review a clean file but only recommends `APPROVE` after applicable verification passes; Prompt Optimizer accepts multiple intentional branches when every branch is unambiguous.
|
|
384
|
+
|
|
385
|
+
| Skill | Directory | Install with `npx octocode` | Use it when |
|
|
386
|
+
|-------|-----------|-----------------------------|-------------|
|
|
387
|
+
| [**Brainstorming**](https://www.skills.sh/bgauryy/octocode-mcp/octocode-brainstorming) | `octocode-brainstorming/` | `npx octocode skill --name octocode-brainstorming` | The idea is fuzzy and needs prior-art or opportunity validation. |
|
|
388
|
+
| ⭐ [**Research**](https://www.skills.sh/bgauryy/octocode-mcp/octocode-research) | `octocode-research/` | `npx octocode skill --name octocode-research` | You need evidence-first technical research, code work, review, refactor, architecture analysis, or repeated proof loops. |
|
|
389
|
+
| [**RFC Generator**](https://www.skills.sh/bgauryy/octocode-mcp/octocode-rfc-generator) | `octocode-rfc-generator/` | `npx octocode skill --name octocode-rfc-generator` | You need a design doc, RFC, architecture proposal, migration plan, or rollout plan before coding. |
|
|
390
|
+
| [**Roast**](https://www.skills.sh/bgauryy/octocode-mcp/octocode-roast) | `octocode-roast/` | `npx octocode skill --name octocode-roast` | You want blunt but actionable code critique. |
|
|
391
|
+
| [**Skills**](https://www.skills.sh/bgauryy/octocode-mcp/octocode-skills) | `octocode-skills/` | `npx octocode skill --name octocode-skills` | You are working on Agent Skills themselves. |
|
|
392
|
+
| [**Prompt Optimizer**](https://github.com/bgauryy/octocode/tree/main/skills/octocode-prompt-optimizer) | `octocode-prompt-optimizer/` | `npx octocode skill --name octocode-prompt-optimizer` | You want to optimize, strengthen, or shorten a prompt, `SKILL.md`, or `AGENTS.md`. |
|
|
393
|
+
| [**Awareness**](https://www.skills.sh/bgauryy/octocode-mcp/octocode-awareness) | `packages/octocode-awareness/skills/octocode-awareness/` | `npx octocode skill --name octocode-awareness` | You need shared agent memory, file locks, notifications, handoffs, reflection, hooks, or verify-before-conclude in a shared repo. |
|
|
394
|
+
|
|
395
|
+
Awareness is the primary skill for memory, locks, signals, reflection, schemas, and hooks. Older prompts that name `octocode-reflection` or `octocode-agent-communication` should load the same [`@octocodeai/octocode-awareness`](https://github.com/bgauryy/octocode/tree/main/packages/octocode-awareness) runtime.
|
|
364
396
|
|
|
365
397
|
---
|
|
366
398
|
|
|
@@ -400,64 +432,73 @@ client → sanitize inputs (Rust) → run tool (GitHub / FS / LSP) → sanitize
|
|
|
400
432
|
| Directory | npm package | Role |
|
|
401
433
|
|-----------|-------------|------|
|
|
402
434
|
| [`packages/octocode`](https://github.com/bgauryy/octocode/tree/main/packages/octocode) | `octocode` | CLI: quick commands, raw tool runner, skill installs, auth/login/logout, install, status, context. |
|
|
403
|
-
| [`packages/octocode-mcp`](https://github.com/bgauryy/octocode/tree/main/packages/octocode-mcp) |
|
|
435
|
+
| [`packages/octocode-mcp`](https://github.com/bgauryy/octocode/tree/main/packages/octocode-mcp) | `@octocodeai/mcp` | MCP server (stdio) that registers the tool catalog for AI assistants. |
|
|
404
436
|
| [`packages/octocode-tools-core`](https://github.com/bgauryy/octocode/tree/main/packages/octocode-tools-core) | `@octocodeai/octocode-tools-core` | Shared tool core: implementations, GitHub client, credentials and token resolution, session, pagination, security bridge. |
|
|
405
437
|
| [`packages/octocode-engine`](https://github.com/bgauryy/octocode/tree/main/packages/octocode-engine) | `@octocodeai/octocode-engine` | Rust/napi native engine: security scanning, minification, signatures, structural AST, ripgrep/diff/YAML, LSP. |
|
|
438
|
+
| [`packages/octocode-config`](https://github.com/bgauryy/octocode/tree/main/packages/octocode-config) | `@octocodeai/config` | Zero-dep env + config loader: `getOctocodeHome`, `.env` parsing, `.octocoderc` reading. Single source used by every package and skill. |
|
|
406
439
|
| [`packages/octocode-vscode`](https://github.com/bgauryy/octocode/tree/main/packages/octocode-vscode) | `octocode-mcp-vscode` | VS Code extension: GitHub OAuth + multi-editor MCP install. |
|
|
440
|
+
| [`packages/octocode-awareness`](https://github.com/bgauryy/octocode/tree/main/packages/octocode-awareness) | `@octocodeai/octocode-awareness` | Shared workspace coordination: file locks, durable memory, agent-to-agent signals, and verification gates over one local SQLite store. Runtime behind Awareness, including the legacy Reflection and Agent Communication workflows. |
|
|
441
|
+
| [`packages/octocode-pi-extension`](https://github.com/bgauryy/octocode/tree/main/packages/octocode-pi-extension) | `@octocodeai/pi-extension` | Official [Pi](https://github.com/earendil-works/pi) harness: operating-model system prompt, 13 native research tools registered in-process, memory tools, edit-safety hooks, and bundled workflow skills. |
|
|
442
|
+
| [`packages/octocode-agent`](https://github.com/bgauryy/octocode/tree/main/packages/octocode-agent) | `octocode-agent` | Self-working coding agent CLI: launches Pi with `@octocodeai/pi-extension` as its harness under one branded command. |
|
|
443
|
+
|
|
444
|
+
`packages/octocode-benchmark` (private, not published) holds benchmark methodology, evals, and run artifacts — see [Documentation](#documentation).
|
|
407
445
|
|
|
408
446
|
---
|
|
409
447
|
|
|
410
448
|
## Documentation
|
|
411
449
|
|
|
412
|
-
Website: **[octocode.ai](https://octocode.ai)** · Product docs: **[github.com/bgauryy/octocode/tree/main/docs](https://github.com/bgauryy/octocode/tree/main/docs)
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
- [
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
- [Security Model](https://github.com/bgauryy/octocode/blob/main/docs/SECURITY.md)
|
|
441
|
-
- [CLI Reference](https://github.com/bgauryy/octocode/blob/main/docs/cli/REFERENCE.md)
|
|
442
|
-
- [Skills Guide](https://github.com/bgauryy/octocode/blob/main/docs/SKILLS_GUIDE.md)
|
|
443
|
-
- [Skills Index](https://github.com/bgauryy/octocode/blob/main/skills/README.md)
|
|
444
|
-
|
|
445
|
-
**Shared Internals**
|
|
446
|
-
- [Credentials Architecture](https://github.com/bgauryy/octocode/blob/main/docs/mcp/CREDENTIALS.md) · [Session Persistence](https://github.com/bgauryy/octocode/blob/main/docs/mcp/SESSION.md)
|
|
450
|
+
Website: **[octocode.ai](https://octocode.ai)** · Product docs: **[github.com/bgauryy/octocode/tree/main/docs](https://github.com/bgauryy/octocode/tree/main/docs)**. This section is the canonical documentation index; benchmark methodology, evals, and run artifacts live in [`packages/octocode-benchmark`](https://github.com/bgauryy/octocode/tree/main/packages/octocode-benchmark).
|
|
451
|
+
|
|
452
|
+
| Area | Docs |
|
|
453
|
+
|---|---|
|
|
454
|
+
| MCP server | [Octocode MCP Server](https://github.com/bgauryy/octocode/blob/main/docs/OCTOCODE_MCP.md) · [Configuration](https://github.com/bgauryy/octocode/blob/main/docs/CONFIGURATION.md) · [Authentication](https://github.com/bgauryy/octocode/blob/main/docs/CONFIGURATION.md) |
|
|
455
|
+
| Tools and workflows | [Octocode Tools Reference](https://github.com/bgauryy/octocode/blob/main/docs/OCTOCODE_TOOLS.md) · [Octocode Research Skill](https://github.com/bgauryy/octocode/tree/main/skills/octocode-research) · [Search Guide](https://github.com/bgauryy/octocode/blob/main/docs/context/SEARCH_GUIDE.md) |
|
|
456
|
+
| CLI and query language | [Octocode CLI Guide](https://github.com/bgauryy/octocode/blob/main/docs/OCTOCODE_CLI.md) · [Octocode Query Language](https://github.com/bgauryy/octocode/blob/main/docs/OCTOCODE_QUERY_LANGUAGE.md) · [OQL Research Graph Flow](https://github.com/bgauryy/octocode/blob/main/docs/context/OQL_RESEARCH_GRAPH_FLOW.md) |
|
|
457
|
+
| Agent harness and skills | [Octocode Pi package](https://github.com/bgauryy/octocode/blob/main/packages/octocode-pi-extension/README.md) · [Octocode Awareness package](https://github.com/bgauryy/octocode/blob/main/packages/octocode-awareness/README.md) · [Skills](https://github.com/bgauryy/octocode/tree/main/skills) |
|
|
458
|
+
| Pi | [Pi package README](https://github.com/bgauryy/octocode/blob/main/packages/octocode-pi-extension/README.md) · [Pi APPEND_SYSTEM starter](https://github.com/bgauryy/octocode/blob/main/packages/octocode-pi-extension/docs/PI/APPEND_SYSTEM.md) |
|
|
459
|
+
| Development and security | [Security Model](https://github.com/bgauryy/octocode/blob/main/docs/SECURITY.md) · [LSP Server Lifecycle](https://github.com/bgauryy/octocode/blob/main/docs/LSP_SERVER_LIFECYCLE.md) |
|
|
460
|
+
| Benchmarks and evals | [Benchmark Summary](https://github.com/bgauryy/octocode/blob/main/packages/octocode-benchmark/BENCHMARK.md) · [Unified CLI/Tool/OQL Eval](https://github.com/bgauryy/octocode/blob/main/packages/octocode-benchmark/benchmark/octocode/README.md) · [Benchmark Runbook](https://github.com/bgauryy/octocode/blob/main/packages/octocode-benchmark/recipes/agent-benchmark-runbook.md) · [Support Matrix](https://github.com/bgauryy/octocode/blob/main/docs/LSP_SERVER_LIFECYCLE.md#full-format-support-matrix) |
|
|
461
|
+
| Shared internals | [Credentials Architecture](https://github.com/bgauryy/octocode/blob/main/docs/CONFIGURATION.md#github-token) · [Session Persistence](https://github.com/bgauryy/octocode/blob/main/docs/OCTOCODE_MCP.md#session-persistence) |
|
|
462
|
+
|
|
463
|
+
---
|
|
464
|
+
|
|
465
|
+
## Troubleshooting
|
|
466
|
+
|
|
467
|
+
Having Node.js issues? Run:
|
|
468
|
+
|
|
469
|
+
```bash
|
|
470
|
+
npx node-doctor check --json
|
|
471
|
+
```
|
|
472
|
+
|
|
473
|
+
Read the output and fix accordingly.
|
|
474
|
+
|
|
475
|
+
---
|
|
476
|
+
|
|
477
|
+
## Agent Workflows
|
|
447
478
|
|
|
448
479
|
### Recommended dev mode: Pi + Octocode
|
|
449
480
|
|
|
450
481
|
[Pi](https://github.com/earendil-works/pi) is a fast, local-first coding agent whose stated philosophy is *"CLI tools with READMEs (Skills) over MCP."* Pairing it with Octocode gives a lean, evidence-driven dev loop — **Pi edits, Octocode researches**. Two routes, pick by how much surface you need:
|
|
451
482
|
|
|
452
|
-
- **Skill route — recommended, leanest.** Drop the [`octocode-
|
|
483
|
+
- **Skill route — recommended, leanest.** Drop the [`octocode-research`](https://www.skills.sh/bgauryy/octocode-mcp/octocode-research) skill into Pi's global skills dir. It drives the Octocode **CLI** directly — no MCP transport, minimal token overhead — and Pi auto-discovers it:
|
|
453
484
|
|
|
454
485
|
```bash
|
|
455
|
-
npx octocode skill --name octocode-
|
|
486
|
+
npx octocode skill --name octocode-research --platform pi
|
|
456
487
|
```
|
|
457
488
|
|
|
458
489
|
- **Adapter route — full tool surface.** Install [`pi-mcp-adapter`](https://github.com/nicobailon/pi-mcp-adapter) to expose all 14 Octocode MCP tools behind a single ~200-token proxy tool, so servers stay disconnected until a tool is actually called. Enable clone tools with `ENABLE_CLONE=true`.
|
|
459
490
|
|
|
460
|
-
Tune Pi's behavior with an `APPEND_SYSTEM.md`
|
|
491
|
+
Tune Pi's behavior with an `APPEND_SYSTEM.md` packaged in [`@octocodeai/pi-extension`](https://github.com/bgauryy/octocode/blob/main/packages/octocode-pi-extension/README.md). The full walkthrough — package install, setup commands, skills, optional MCP setup, and custom models — is in the [**Pi package README**](https://github.com/bgauryy/octocode/blob/main/packages/octocode-pi-extension/README.md).
|
|
492
|
+
|
|
493
|
+
### Octocode Harness
|
|
494
|
+
|
|
495
|
+
The Octocode harness is the recommended agent environment for research-driven development: Pi supplies the local coding loop, `npx octocode` supplies structured code research, and Octocode Skills encode the workflows agents should follow before they edit.
|
|
496
|
+
|
|
497
|
+
Docs: [Pi package README](https://github.com/bgauryy/octocode/blob/main/packages/octocode-pi-extension/README.md) · [APPEND_SYSTEM starter](https://github.com/bgauryy/octocode/blob/main/packages/octocode-pi-extension/docs/PI/APPEND_SYSTEM.md)
|
|
498
|
+
|
|
499
|
+
It is deliberately research-oriented because most agent failures start before implementation: the agent guesses the owner of a behavior, trusts a snippet without reading the exact source, or edits before proving blast radius. The harness pushes the agent through a cheaper loop first: orient with trees and discovery output, search with Octocode, read exact evidence, use AST/LSP when identity matters, then patch and verify.
|
|
500
|
+
|
|
501
|
+
That shape keeps the editing surface small while preserving context for what matters: file anchors, symbols, call paths, PR/history evidence, package sources, and the verification command that proves the change. In short, Pi is the hands, Octocode is the map, and the skills/system prompt make the habit repeatable.
|
|
461
502
|
|
|
462
503
|
### The Manifest
|
|
463
504
|
|
package/dist/lsp/client.d.ts
CHANGED
|
@@ -1,22 +1,31 @@
|
|
|
1
|
-
import type { CallHierarchyItem, CodeSnippet, ExactPosition, IncomingCall, LanguageServerConfig, OutgoingCall } from './types.js';
|
|
1
|
+
import type { CallHierarchyItem, CodeSnippet, ExactPosition, IncomingCall, LanguageServerConfig, LspReadiness, OutgoingCall } from './types.js';
|
|
2
2
|
export declare class LSPClient {
|
|
3
3
|
private readonly nativeClient;
|
|
4
4
|
private readonly command;
|
|
5
5
|
private initialized;
|
|
6
|
+
private lastReadiness;
|
|
6
7
|
constructor(config: LanguageServerConfig);
|
|
7
8
|
start(): Promise<void>;
|
|
8
9
|
stop(): Promise<void>;
|
|
9
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Wait for the server to finish post-`initialized` indexing and record the
|
|
12
|
+
* readiness signal. Runtime tolerance: until the native addon is rebuilt with
|
|
13
|
+
* the readiness return, the old binding resolves to `undefined` — treat that
|
|
14
|
+
* as the conservative `settledFallback` (we cannot confirm indexing finished).
|
|
15
|
+
*/
|
|
16
|
+
waitForReady(timeoutMs?: number): Promise<LspReadiness>;
|
|
17
|
+
/**
|
|
18
|
+
* The readiness recorded by the most recent `waitForReady`, or `undefined`
|
|
19
|
+
* if it was never called (e.g. servers that answer immediately and skip the
|
|
20
|
+
* readiness wait). A zero-results semantic query on a client whose readiness
|
|
21
|
+
* is not `progressIdle` may be "not indexed yet" rather than a true absence.
|
|
22
|
+
*/
|
|
23
|
+
getReadiness(): LspReadiness | undefined;
|
|
10
24
|
gotoDefinition(filePath: string, position: ExactPosition, content?: string): Promise<CodeSnippet[]>;
|
|
11
|
-
getDefinition(filePath: string, position: ExactPosition, content?: string): Promise<CodeSnippet[]>;
|
|
12
25
|
findReferences(filePath: string, position: ExactPosition, includeDeclaration?: boolean, content?: string): Promise<CodeSnippet[]>;
|
|
13
|
-
getHover(filePath: string, position: ExactPosition, content?: string): Promise<unknown>;
|
|
14
26
|
hover(filePath: string, position: ExactPosition, content?: string): Promise<unknown>;
|
|
15
|
-
getTypeDefinition(filePath: string, position: ExactPosition, content?: string): Promise<CodeSnippet[]>;
|
|
16
27
|
typeDefinition(filePath: string, position: ExactPosition, content?: string): Promise<CodeSnippet[]>;
|
|
17
|
-
getImplementation(filePath: string, position: ExactPosition, content?: string): Promise<CodeSnippet[]>;
|
|
18
28
|
implementation(filePath: string, position: ExactPosition, content?: string): Promise<CodeSnippet[]>;
|
|
19
|
-
getDocumentSymbols(filePath: string, content?: string): Promise<unknown>;
|
|
20
29
|
documentSymbols(filePath: string, content?: string): Promise<unknown>;
|
|
21
30
|
prepareCallHierarchy(filePath: string, position: ExactPosition, content?: string): Promise<CallHierarchyItem[]>;
|
|
22
31
|
getIncomingCalls(item: CallHierarchyItem): Promise<IncomingCall[]>;
|
|
@@ -26,9 +35,8 @@ export declare class LSPClient {
|
|
|
26
35
|
typeHierarchySupertypes(item: unknown): Promise<unknown[]>;
|
|
27
36
|
typeHierarchySubtypes(item: unknown): Promise<unknown[]>;
|
|
28
37
|
getDiagnostics(filePath: string, content?: string): Promise<unknown>;
|
|
29
|
-
hasCapability(
|
|
38
|
+
hasCapability(capability: string): boolean;
|
|
30
39
|
getRecentStderr(): string[];
|
|
31
40
|
openDocument(filePath: string, content?: string): Promise<void>;
|
|
32
|
-
ensureDocumentSynced(filePath: string, content?: string): Promise<void>;
|
|
33
41
|
closeDocument(filePath: string): Promise<void>;
|
|
34
42
|
}
|
package/dist/lsp/client.js
CHANGED
|
@@ -5,6 +5,7 @@ export class LSPClient {
|
|
|
5
5
|
nativeClient;
|
|
6
6
|
command;
|
|
7
7
|
initialized = false;
|
|
8
|
+
lastReadiness;
|
|
8
9
|
constructor(config) {
|
|
9
10
|
this.command = config.command;
|
|
10
11
|
this.nativeClient = new nativeBinding.NativeLspClient({
|
|
@@ -31,13 +32,27 @@ export class LSPClient {
|
|
|
31
32
|
await this.nativeClient.stop();
|
|
32
33
|
this.initialized = false;
|
|
33
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* Wait for the server to finish post-`initialized` indexing and record the
|
|
37
|
+
* readiness signal. Runtime tolerance: until the native addon is rebuilt with
|
|
38
|
+
* the readiness return, the old binding resolves to `undefined` — treat that
|
|
39
|
+
* as the conservative `settledFallback` (we cannot confirm indexing finished).
|
|
40
|
+
*/
|
|
34
41
|
async waitForReady(timeoutMs = 45_000) {
|
|
35
|
-
await this.nativeClient.waitForReady(timeoutMs);
|
|
42
|
+
const readiness = await this.nativeClient.waitForReady(timeoutMs);
|
|
43
|
+
this.lastReadiness = readiness ?? 'settledFallback';
|
|
44
|
+
return this.lastReadiness;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* The readiness recorded by the most recent `waitForReady`, or `undefined`
|
|
48
|
+
* if it was never called (e.g. servers that answer immediately and skip the
|
|
49
|
+
* readiness wait). A zero-results semantic query on a client whose readiness
|
|
50
|
+
* is not `progressIdle` may be "not indexed yet" rather than a true absence.
|
|
51
|
+
*/
|
|
52
|
+
getReadiness() {
|
|
53
|
+
return this.lastReadiness;
|
|
36
54
|
}
|
|
37
55
|
async gotoDefinition(filePath, position, content) {
|
|
38
|
-
return this.getDefinition(filePath, position, content);
|
|
39
|
-
}
|
|
40
|
-
async getDefinition(filePath, position, content) {
|
|
41
56
|
await this.openDocument(filePath, content);
|
|
42
57
|
return (await this.nativeClient.getDefinition(filePath, position.line, position.character));
|
|
43
58
|
}
|
|
@@ -45,34 +60,22 @@ export class LSPClient {
|
|
|
45
60
|
await this.openDocument(filePath, content);
|
|
46
61
|
return (await this.nativeClient.getReferences(filePath, position.line, position.character, includeDeclaration));
|
|
47
62
|
}
|
|
48
|
-
async
|
|
63
|
+
async hover(filePath, position, content) {
|
|
49
64
|
await this.openDocument(filePath, content);
|
|
50
65
|
return this.nativeClient.getHover(filePath, position.line, position.character);
|
|
51
66
|
}
|
|
52
|
-
async
|
|
53
|
-
return this.getHover(filePath, position, content);
|
|
54
|
-
}
|
|
55
|
-
async getTypeDefinition(filePath, position, content) {
|
|
67
|
+
async typeDefinition(filePath, position, content) {
|
|
56
68
|
await this.openDocument(filePath, content);
|
|
57
69
|
return (await this.nativeClient.getTypeDefinition(filePath, position.line, position.character));
|
|
58
70
|
}
|
|
59
|
-
async
|
|
60
|
-
return this.getTypeDefinition(filePath, position, content);
|
|
61
|
-
}
|
|
62
|
-
async getImplementation(filePath, position, content) {
|
|
71
|
+
async implementation(filePath, position, content) {
|
|
63
72
|
await this.openDocument(filePath, content);
|
|
64
73
|
return (await this.nativeClient.getImplementation(filePath, position.line, position.character));
|
|
65
74
|
}
|
|
66
|
-
async
|
|
67
|
-
return this.getImplementation(filePath, position, content);
|
|
68
|
-
}
|
|
69
|
-
async getDocumentSymbols(filePath, content) {
|
|
75
|
+
async documentSymbols(filePath, content) {
|
|
70
76
|
await this.openDocument(filePath, content);
|
|
71
77
|
return this.nativeClient.getDocumentSymbols(filePath);
|
|
72
78
|
}
|
|
73
|
-
async documentSymbols(filePath, content) {
|
|
74
|
-
return this.getDocumentSymbols(filePath, content);
|
|
75
|
-
}
|
|
76
79
|
async prepareCallHierarchy(filePath, position, content) {
|
|
77
80
|
await this.openDocument(filePath, content);
|
|
78
81
|
const result = await this.nativeClient.prepareCallHierarchy(filePath, position.line, position.character);
|
|
@@ -107,17 +110,14 @@ export class LSPClient {
|
|
|
107
110
|
await this.openDocument(filePath, content);
|
|
108
111
|
return this.nativeClient.getDiagnostics(filePath);
|
|
109
112
|
}
|
|
110
|
-
hasCapability(
|
|
113
|
+
hasCapability(capability) {
|
|
111
114
|
return (this.initialized &&
|
|
112
|
-
(this.nativeClient.hasCapability?.(
|
|
115
|
+
(this.nativeClient.hasCapability?.(capability) ?? true));
|
|
113
116
|
}
|
|
114
117
|
getRecentStderr() {
|
|
115
118
|
return this.nativeClient.getRecentStderr?.() ?? [];
|
|
116
119
|
}
|
|
117
120
|
async openDocument(filePath, content) {
|
|
118
|
-
await this.ensureDocumentSynced(filePath, content ?? (await fs.readFile(filePath, 'utf8')));
|
|
119
|
-
}
|
|
120
|
-
async ensureDocumentSynced(filePath, content) {
|
|
121
121
|
await this.nativeClient.openDocument(filePath, content ?? (await fs.readFile(filePath, 'utf8')));
|
|
122
122
|
}
|
|
123
123
|
async closeDocument(filePath) {
|