@aria-cli/tools 1.0.1 → 1.0.3
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/dist/.aria-build-stamp.json +1 -1
- package/dist/.tsbuildinfo +1 -1
- package/dist/definitions/code-intelligence.d.ts +9 -0
- package/dist/definitions/code-intelligence.d.ts.map +1 -0
- package/dist/definitions/code-intelligence.js +471 -0
- package/dist/definitions/code-intelligence.js.map +1 -0
- package/dist/definitions/core.d.ts +3 -0
- package/dist/definitions/core.d.ts.map +1 -1
- package/dist/definitions/core.js +13 -1
- package/dist/definitions/core.js.map +1 -1
- package/dist/definitions/filesystem.d.ts +3 -2
- package/dist/definitions/filesystem.d.ts.map +1 -1
- package/dist/definitions/filesystem.js +4 -38
- package/dist/definitions/filesystem.js.map +1 -1
- package/dist/definitions/frg.d.ts +4 -0
- package/dist/definitions/frg.d.ts.map +1 -0
- package/dist/definitions/frg.js +64 -0
- package/dist/definitions/frg.js.map +1 -0
- package/dist/definitions/index.d.ts +3 -0
- package/dist/definitions/index.d.ts.map +1 -1
- package/dist/definitions/index.js +3 -0
- package/dist/definitions/index.js.map +1 -1
- package/dist/definitions/search.d.ts +10 -0
- package/dist/definitions/search.d.ts.map +1 -0
- package/dist/definitions/search.js +61 -0
- package/dist/definitions/search.js.map +1 -0
- package/dist/executors/apply-patch.d.ts.map +1 -1
- package/dist/executors/apply-patch.js +18 -0
- package/dist/executors/apply-patch.js.map +1 -1
- package/dist/executors/code-intelligence.d.ts +139 -0
- package/dist/executors/code-intelligence.d.ts.map +1 -0
- package/dist/executors/code-intelligence.js +883 -0
- package/dist/executors/code-intelligence.js.map +1 -0
- package/dist/executors/filesystem.d.ts.map +1 -1
- package/dist/executors/filesystem.js +14 -8
- package/dist/executors/filesystem.js.map +1 -1
- package/dist/executors/frg-freshness.d.ts +94 -0
- package/dist/executors/frg-freshness.d.ts.map +1 -0
- package/dist/executors/frg-freshness.js +577 -0
- package/dist/executors/frg-freshness.js.map +1 -0
- package/dist/executors/frg.d.ts +28 -0
- package/dist/executors/frg.d.ts.map +1 -0
- package/dist/executors/frg.js +299 -0
- package/dist/executors/frg.js.map +1 -0
- package/dist/executors/index.d.ts +6 -0
- package/dist/executors/index.d.ts.map +1 -1
- package/dist/executors/index.js +5 -0
- package/dist/executors/index.js.map +1 -1
- package/dist/executors/lsp-client.d.ts +39 -0
- package/dist/executors/lsp-client.d.ts.map +1 -0
- package/dist/executors/lsp-client.js +297 -0
- package/dist/executors/lsp-client.js.map +1 -0
- package/dist/executors/restart.d.ts +4 -9
- package/dist/executors/restart.d.ts.map +1 -1
- package/dist/executors/restart.js +20 -51
- package/dist/executors/restart.js.map +1 -1
- package/dist/executors/search-freshness.d.ts +51 -0
- package/dist/executors/search-freshness.d.ts.map +1 -0
- package/dist/executors/search-freshness.js +196 -0
- package/dist/executors/search-freshness.js.map +1 -0
- package/dist/executors/search.d.ts +12 -0
- package/dist/executors/search.d.ts.map +1 -0
- package/dist/executors/search.js +67 -0
- package/dist/executors/search.js.map +1 -0
- package/dist/headless-control-contract.d.ts +4 -0
- package/dist/headless-control-contract.d.ts.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/network-runtime/local-control-contract.d.ts +2 -0
- package/dist/network-runtime/local-control-contract.d.ts.map +1 -1
- package/dist/network-runtime/local-control-contract.js +2 -0
- package/dist/network-runtime/local-control-contract.js.map +1 -1
- package/dist-cjs/.tsbuildinfo +1 -1
- package/dist-cjs/definitions/code-intelligence.d.ts +8 -0
- package/dist-cjs/definitions/code-intelligence.js +474 -0
- package/dist-cjs/definitions/code-intelligence.js.map +1 -0
- package/dist-cjs/definitions/core.d.ts +3 -0
- package/dist-cjs/definitions/core.js +17 -2
- package/dist-cjs/definitions/core.js.map +1 -1
- package/dist-cjs/definitions/filesystem.d.ts +3 -2
- package/dist-cjs/definitions/filesystem.js +3 -37
- package/dist-cjs/definitions/filesystem.js.map +1 -1
- package/dist-cjs/definitions/frg.d.ts +3 -0
- package/dist-cjs/definitions/frg.js +67 -0
- package/dist-cjs/definitions/frg.js.map +1 -0
- package/dist-cjs/definitions/index.d.ts +3 -0
- package/dist-cjs/definitions/index.js +7 -1
- package/dist-cjs/definitions/index.js.map +1 -1
- package/dist-cjs/definitions/search.d.ts +9 -0
- package/dist-cjs/definitions/search.js +64 -0
- package/dist-cjs/definitions/search.js.map +1 -0
- package/dist-cjs/executors/apply-patch.js +18 -0
- package/dist-cjs/executors/apply-patch.js.map +1 -1
- package/dist-cjs/executors/code-intelligence.d.ts +138 -0
- package/dist-cjs/executors/code-intelligence.js +926 -0
- package/dist-cjs/executors/code-intelligence.js.map +1 -0
- package/dist-cjs/executors/filesystem.js +17 -8
- package/dist-cjs/executors/filesystem.js.map +1 -1
- package/dist-cjs/executors/frg-freshness.d.ts +93 -0
- package/dist-cjs/executors/frg-freshness.js +628 -0
- package/dist-cjs/executors/frg-freshness.js.map +1 -0
- package/dist-cjs/executors/frg.d.ts +27 -0
- package/dist-cjs/executors/frg.js +335 -0
- package/dist-cjs/executors/frg.js.map +1 -0
- package/dist-cjs/executors/index.d.ts +6 -0
- package/dist-cjs/executors/index.js +34 -2
- package/dist-cjs/executors/index.js.map +1 -1
- package/dist-cjs/executors/lsp-client.d.ts +38 -0
- package/dist-cjs/executors/lsp-client.js +311 -0
- package/dist-cjs/executors/lsp-client.js.map +1 -0
- package/dist-cjs/executors/restart.d.ts +4 -9
- package/dist-cjs/executors/restart.js +19 -50
- package/dist-cjs/executors/restart.js.map +1 -1
- package/dist-cjs/executors/search-freshness.d.ts +50 -0
- package/dist-cjs/executors/search-freshness.js +235 -0
- package/dist-cjs/executors/search-freshness.js.map +1 -0
- package/dist-cjs/executors/search.d.ts +11 -0
- package/dist-cjs/executors/search.js +103 -0
- package/dist-cjs/executors/search.js.map +1 -0
- package/dist-cjs/headless-control-contract.d.ts +15 -11
- package/dist-cjs/index.d.ts +2 -2
- package/dist-cjs/index.js +22 -2
- package/dist-cjs/index.js.map +1 -1
- package/dist-cjs/network-runtime/local-control-contract.d.ts +2 -0
- package/dist-cjs/network-runtime/local-control-contract.js +2 -0
- package/dist-cjs/network-runtime/local-control-contract.js.map +1 -1
- package/package.json +22 -18
- package/src/definitions/code-intelligence.ts +526 -0
- package/src/definitions/core.ts +13 -1
- package/src/definitions/filesystem.ts +3 -39
- package/src/definitions/frg.ts +67 -0
- package/src/definitions/index.ts +3 -0
- package/src/definitions/search.ts +67 -0
- package/src/executors/apply-patch.ts +20 -0
- package/src/executors/code-intelligence.ts +1179 -0
- package/src/executors/filesystem.ts +15 -8
- package/src/executors/frg-freshness.ts +743 -0
- package/src/executors/frg.ts +394 -0
- package/src/executors/index.ts +58 -0
- package/src/executors/lsp-client.ts +355 -0
- package/src/executors/restart.ts +21 -56
- package/src/executors/search-freshness.ts +249 -0
- package/src/executors/search.ts +89 -0
- package/src/index.ts +25 -0
- package/src/network-runtime/local-control-contract.ts +2 -0
- package/tests/definitions/tool-inventory.test.ts +17 -6
- package/tests/executors/frg-freshness.test.ts +136 -0
- package/tests/executors/frg-merge.test.ts +70 -0
- package/tests/executors/frg-session-content.test.ts +40 -0
- package/tests/executors/frg.test.ts +56 -0
- package/tests/integration/headless-control-contract.integration.test.ts +2 -0
- package/tests/loading-tier.test.ts +6 -6
- package/tests/test-lane-manifest.ts +4 -0
- package/tsconfig.cjs.json +9 -1
- package/tsconfig.json +1 -1
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Native LSP Client — uses vscode-jsonrpc for proper message framing.
|
|
4
|
+
*
|
|
5
|
+
* Same approach as Claude Code: createMessageConnection over stdio.
|
|
6
|
+
* Same configuration as Claude Code's LSP plugins.
|
|
7
|
+
* Supports: TypeScript, Python, Go, Rust, C/C++, Swift, Java, Kotlin, Lua, PHP, Ruby, C#.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.LspServer = exports.LSP_SERVERS = void 0;
|
|
11
|
+
exports.getServerForFile = getServerForFile;
|
|
12
|
+
exports.getLanguageId = getLanguageId;
|
|
13
|
+
exports.getOrCreateServer = getOrCreateServer;
|
|
14
|
+
exports.shutdownAll = shutdownAll;
|
|
15
|
+
const node_child_process_1 = require("node:child_process");
|
|
16
|
+
const node_fs_1 = require("node:fs");
|
|
17
|
+
const node_path_1 = require("node:path");
|
|
18
|
+
const node_url_1 = require("node:url");
|
|
19
|
+
const node_module_1 = require("node:module");
|
|
20
|
+
let vscodeJsonrpc;
|
|
21
|
+
// ESM module path for createRequire
|
|
22
|
+
const __esmFilePath = (0, node_url_1.fileURLToPath)(import.meta.url);
|
|
23
|
+
function getJsonRpc() {
|
|
24
|
+
if (!vscodeJsonrpc) {
|
|
25
|
+
vscodeJsonrpc = (0, node_module_1.createRequire)(__esmFilePath)("vscode-jsonrpc/node");
|
|
26
|
+
}
|
|
27
|
+
return vscodeJsonrpc;
|
|
28
|
+
}
|
|
29
|
+
exports.LSP_SERVERS = {
|
|
30
|
+
typescript: {
|
|
31
|
+
command: "typescript-language-server",
|
|
32
|
+
args: ["--stdio"],
|
|
33
|
+
extensionToLanguage: {
|
|
34
|
+
".ts": "typescript",
|
|
35
|
+
".tsx": "typescriptreact",
|
|
36
|
+
".js": "javascript",
|
|
37
|
+
".jsx": "javascriptreact",
|
|
38
|
+
".mts": "typescript",
|
|
39
|
+
".cts": "typescript",
|
|
40
|
+
".mjs": "javascript",
|
|
41
|
+
".cjs": "javascript",
|
|
42
|
+
},
|
|
43
|
+
startupTimeout: 30_000,
|
|
44
|
+
},
|
|
45
|
+
python: {
|
|
46
|
+
command: "pyright-langserver",
|
|
47
|
+
args: ["--stdio"],
|
|
48
|
+
extensionToLanguage: { ".py": "python", ".pyi": "python" },
|
|
49
|
+
startupTimeout: 60_000,
|
|
50
|
+
},
|
|
51
|
+
go: {
|
|
52
|
+
command: "gopls",
|
|
53
|
+
args: [],
|
|
54
|
+
extensionToLanguage: { ".go": "go" },
|
|
55
|
+
startupTimeout: 30_000,
|
|
56
|
+
},
|
|
57
|
+
rust: {
|
|
58
|
+
command: "rust-analyzer",
|
|
59
|
+
args: [],
|
|
60
|
+
extensionToLanguage: { ".rs": "rust" },
|
|
61
|
+
startupTimeout: 60_000,
|
|
62
|
+
},
|
|
63
|
+
"c/cpp": {
|
|
64
|
+
command: "clangd",
|
|
65
|
+
args: ["--background-index"],
|
|
66
|
+
extensionToLanguage: {
|
|
67
|
+
".c": "c",
|
|
68
|
+
".h": "c",
|
|
69
|
+
".cpp": "cpp",
|
|
70
|
+
".cc": "cpp",
|
|
71
|
+
".cxx": "cpp",
|
|
72
|
+
".hpp": "cpp",
|
|
73
|
+
".hxx": "cpp",
|
|
74
|
+
},
|
|
75
|
+
startupTimeout: 30_000,
|
|
76
|
+
},
|
|
77
|
+
swift: {
|
|
78
|
+
command: "sourcekit-lsp",
|
|
79
|
+
args: [],
|
|
80
|
+
extensionToLanguage: { ".swift": "swift" },
|
|
81
|
+
startupTimeout: 30_000,
|
|
82
|
+
},
|
|
83
|
+
java: {
|
|
84
|
+
command: "jdtls",
|
|
85
|
+
args: [],
|
|
86
|
+
extensionToLanguage: { ".java": "java" },
|
|
87
|
+
startupTimeout: 120_000,
|
|
88
|
+
},
|
|
89
|
+
kotlin: {
|
|
90
|
+
command: "kotlin-language-server",
|
|
91
|
+
args: ["--stdio"],
|
|
92
|
+
extensionToLanguage: { ".kt": "kotlin", ".kts": "kotlin" },
|
|
93
|
+
startupTimeout: 120_000,
|
|
94
|
+
},
|
|
95
|
+
lua: {
|
|
96
|
+
command: "lua-language-server",
|
|
97
|
+
args: [],
|
|
98
|
+
extensionToLanguage: { ".lua": "lua" },
|
|
99
|
+
startupTimeout: 30_000,
|
|
100
|
+
},
|
|
101
|
+
php: {
|
|
102
|
+
command: "intelephense",
|
|
103
|
+
args: ["--stdio"],
|
|
104
|
+
extensionToLanguage: { ".php": "php" },
|
|
105
|
+
startupTimeout: 30_000,
|
|
106
|
+
},
|
|
107
|
+
ruby: {
|
|
108
|
+
command: "ruby-lsp",
|
|
109
|
+
args: [],
|
|
110
|
+
extensionToLanguage: { ".rb": "ruby", ".rake": "ruby", ".gemspec": "ruby" },
|
|
111
|
+
startupTimeout: 30_000,
|
|
112
|
+
},
|
|
113
|
+
csharp: {
|
|
114
|
+
command: "csharp-ls",
|
|
115
|
+
args: [],
|
|
116
|
+
extensionToLanguage: { ".cs": "csharp" },
|
|
117
|
+
startupTimeout: 30_000,
|
|
118
|
+
},
|
|
119
|
+
};
|
|
120
|
+
// Build reverse lookup: file extension → server name
|
|
121
|
+
const EXT_TO_SERVER = new Map();
|
|
122
|
+
for (const [serverName, config] of Object.entries(exports.LSP_SERVERS)) {
|
|
123
|
+
for (const ext of Object.keys(config.extensionToLanguage)) {
|
|
124
|
+
EXT_TO_SERVER.set(ext, serverName);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
function getServerForFile(filePath) {
|
|
128
|
+
const ext = filePath.slice(filePath.lastIndexOf("."));
|
|
129
|
+
return EXT_TO_SERVER.get(ext);
|
|
130
|
+
}
|
|
131
|
+
function getLanguageId(filePath) {
|
|
132
|
+
const ext = filePath.slice(filePath.lastIndexOf("."));
|
|
133
|
+
const serverName = EXT_TO_SERVER.get(ext);
|
|
134
|
+
if (!serverName)
|
|
135
|
+
return undefined;
|
|
136
|
+
return exports.LSP_SERVERS[serverName]?.extensionToLanguage[ext];
|
|
137
|
+
}
|
|
138
|
+
// ---------------------------------------------------------------------------
|
|
139
|
+
// LSP Server Instance — uses vscode-jsonrpc createMessageConnection
|
|
140
|
+
// ---------------------------------------------------------------------------
|
|
141
|
+
class LspServer {
|
|
142
|
+
process = null;
|
|
143
|
+
connection = null;
|
|
144
|
+
initialized = false;
|
|
145
|
+
openFiles = new Set();
|
|
146
|
+
diagnosticsReceived = new Set();
|
|
147
|
+
serverName;
|
|
148
|
+
config;
|
|
149
|
+
rootUri;
|
|
150
|
+
constructor(serverName, rootPath) {
|
|
151
|
+
this.serverName = serverName;
|
|
152
|
+
const cfg = exports.LSP_SERVERS[serverName];
|
|
153
|
+
if (!cfg)
|
|
154
|
+
throw new Error(`Unknown LSP server: ${serverName}`);
|
|
155
|
+
this.config = cfg;
|
|
156
|
+
this.rootUri = `file://${(0, node_path_1.resolve)(rootPath)}`;
|
|
157
|
+
}
|
|
158
|
+
async start() {
|
|
159
|
+
if (this.connection)
|
|
160
|
+
return;
|
|
161
|
+
this.process = (0, node_child_process_1.spawn)(this.config.command, this.config.args, {
|
|
162
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
163
|
+
});
|
|
164
|
+
this.process.stderr?.on("data", () => {
|
|
165
|
+
// Swallow stderr — language servers are noisy
|
|
166
|
+
});
|
|
167
|
+
this.process.on("exit", () => {
|
|
168
|
+
this.connection?.dispose();
|
|
169
|
+
this.connection = null;
|
|
170
|
+
this.process = null;
|
|
171
|
+
this.initialized = false;
|
|
172
|
+
this.openFiles.clear();
|
|
173
|
+
this.diagnosticsReceived.clear();
|
|
174
|
+
});
|
|
175
|
+
// Create vscode-jsonrpc connection — handles Content-Length framing,
|
|
176
|
+
// request/response matching, notification routing. Same as Claude Code.
|
|
177
|
+
const jsonrpc = getJsonRpc();
|
|
178
|
+
this.connection = jsonrpc.createMessageConnection(new jsonrpc.StreamMessageReader(this.process.stdout), new jsonrpc.StreamMessageWriter(this.process.stdin));
|
|
179
|
+
// Listen for diagnostics notifications (signals file analysis complete)
|
|
180
|
+
this.connection.onNotification("textDocument/publishDiagnostics", (params) => {
|
|
181
|
+
const p = params;
|
|
182
|
+
if (p.uri)
|
|
183
|
+
this.diagnosticsReceived.add(p.uri);
|
|
184
|
+
});
|
|
185
|
+
this.connection.listen();
|
|
186
|
+
// Initialize handshake
|
|
187
|
+
await this.connection.sendRequest("initialize", {
|
|
188
|
+
processId: globalThis.process.pid,
|
|
189
|
+
rootUri: this.rootUri,
|
|
190
|
+
capabilities: {
|
|
191
|
+
textDocument: {
|
|
192
|
+
definition: { dynamicRegistration: false },
|
|
193
|
+
references: { dynamicRegistration: false },
|
|
194
|
+
hover: { dynamicRegistration: false, contentFormat: ["plaintext", "markdown"] },
|
|
195
|
+
documentSymbol: { dynamicRegistration: false },
|
|
196
|
+
rename: { dynamicRegistration: false, prepareSupport: false },
|
|
197
|
+
publishDiagnostics: { relatedInformation: true },
|
|
198
|
+
},
|
|
199
|
+
workspace: {
|
|
200
|
+
workspaceFolders: true,
|
|
201
|
+
},
|
|
202
|
+
},
|
|
203
|
+
workspaceFolders: [{ uri: this.rootUri, name: "root" }],
|
|
204
|
+
});
|
|
205
|
+
this.connection.sendNotification("initialized", {});
|
|
206
|
+
this.initialized = true;
|
|
207
|
+
}
|
|
208
|
+
async stop() {
|
|
209
|
+
if (!this.connection)
|
|
210
|
+
return;
|
|
211
|
+
try {
|
|
212
|
+
await this.connection.sendRequest("shutdown");
|
|
213
|
+
this.connection.sendNotification("exit");
|
|
214
|
+
}
|
|
215
|
+
catch {
|
|
216
|
+
// Force kill if graceful shutdown fails
|
|
217
|
+
}
|
|
218
|
+
this.connection.dispose();
|
|
219
|
+
this.connection = null;
|
|
220
|
+
this.process?.kill("SIGTERM");
|
|
221
|
+
this.process = null;
|
|
222
|
+
this.initialized = false;
|
|
223
|
+
}
|
|
224
|
+
// Ensure a file is opened in the language server
|
|
225
|
+
async openFile(filePath) {
|
|
226
|
+
const uri = `file://${(0, node_path_1.resolve)(filePath)}`;
|
|
227
|
+
if (this.openFiles.has(uri))
|
|
228
|
+
return;
|
|
229
|
+
const languageId = getLanguageId(filePath);
|
|
230
|
+
if (!languageId)
|
|
231
|
+
return;
|
|
232
|
+
let text;
|
|
233
|
+
try {
|
|
234
|
+
text = (0, node_fs_1.readFileSync)((0, node_path_1.resolve)(filePath), "utf-8");
|
|
235
|
+
}
|
|
236
|
+
catch {
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
this.connection?.sendNotification("textDocument/didOpen", {
|
|
240
|
+
textDocument: { uri, languageId, version: 1, text },
|
|
241
|
+
});
|
|
242
|
+
this.openFiles.add(uri);
|
|
243
|
+
// No wait needed. LSP servers queue requests after didOpen and respond
|
|
244
|
+
// when ready. Tested: TypeScript responds to hover in 239ms with zero
|
|
245
|
+
// wait (before diagnostics arrive). Pyright responds after its analysis.
|
|
246
|
+
// The sendRequest in the caller will block until the server responds.
|
|
247
|
+
}
|
|
248
|
+
// --- LSP Operations ---
|
|
249
|
+
async definition(filePath, line, character) {
|
|
250
|
+
await this.ensureReady(filePath);
|
|
251
|
+
return this.connection.sendRequest("textDocument/definition", {
|
|
252
|
+
textDocument: { uri: `file://${(0, node_path_1.resolve)(filePath)}` },
|
|
253
|
+
position: { line, character },
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
async references(filePath, line, character) {
|
|
257
|
+
await this.ensureReady(filePath);
|
|
258
|
+
return this.connection.sendRequest("textDocument/references", {
|
|
259
|
+
textDocument: { uri: `file://${(0, node_path_1.resolve)(filePath)}` },
|
|
260
|
+
position: { line, character },
|
|
261
|
+
context: { includeDeclaration: true },
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
async hover(filePath, line, character) {
|
|
265
|
+
await this.ensureReady(filePath);
|
|
266
|
+
return this.connection.sendRequest("textDocument/hover", {
|
|
267
|
+
textDocument: { uri: `file://${(0, node_path_1.resolve)(filePath)}` },
|
|
268
|
+
position: { line, character },
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
async documentSymbols(filePath) {
|
|
272
|
+
await this.ensureReady(filePath);
|
|
273
|
+
return this.connection.sendRequest("textDocument/documentSymbol", {
|
|
274
|
+
textDocument: { uri: `file://${(0, node_path_1.resolve)(filePath)}` },
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
async rename(filePath, line, character, newName) {
|
|
278
|
+
await this.ensureReady(filePath);
|
|
279
|
+
return this.connection.sendRequest("textDocument/rename", {
|
|
280
|
+
textDocument: { uri: `file://${(0, node_path_1.resolve)(filePath)}` },
|
|
281
|
+
position: { line, character },
|
|
282
|
+
newName,
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
// --- Internals ---
|
|
286
|
+
async ensureReady(filePath) {
|
|
287
|
+
if (!this.initialized)
|
|
288
|
+
await this.start();
|
|
289
|
+
await this.openFile(filePath);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
exports.LspServer = LspServer;
|
|
293
|
+
// ---------------------------------------------------------------------------
|
|
294
|
+
// Server Pool — one server per language, shared across queries
|
|
295
|
+
// ---------------------------------------------------------------------------
|
|
296
|
+
const serverPool = new Map();
|
|
297
|
+
function getOrCreateServer(serverName, rootPath) {
|
|
298
|
+
const key = `${serverName}:${rootPath}`;
|
|
299
|
+
let server = serverPool.get(key);
|
|
300
|
+
if (!server) {
|
|
301
|
+
server = new LspServer(serverName, rootPath);
|
|
302
|
+
serverPool.set(key, server);
|
|
303
|
+
}
|
|
304
|
+
return server;
|
|
305
|
+
}
|
|
306
|
+
async function shutdownAll() {
|
|
307
|
+
const stops = [...serverPool.values()].map((s) => s.stop());
|
|
308
|
+
await Promise.allSettled(stops);
|
|
309
|
+
serverPool.clear();
|
|
310
|
+
}
|
|
311
|
+
//# sourceMappingURL=lsp-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lsp-client.js","sourceRoot":"","sources":["../../src/executors/lsp-client.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAkJH,4CAGC;AAED,sCAKC;AA2LD,8CAQC;AAED,kCAIC;AAnWD,2DAA8D;AAC9D,qCAAuC;AACvC,yCAAoC;AACpC,uCAAyC;AACzC,6CAA4C;AAS5C,IAAI,aAAwC,CAAC;AAE7C,oCAAoC;AACpC,MAAM,aAAa,GAAG,IAAA,wBAAa,EAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAErD,SAAS,UAAU;IACjB,IAAI,CAAC,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,MAAM,CAAC,CAAC;IAC9B,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAEM,KAAK,UAAU,WAAW;IAC/B,MAAM,KAAK,GAAG,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IAC5D,MAAM,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IAChC,UAAU,CAAC,KAAK,EAAE,CAAC;AACrB,CAAC"}
|
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @aria/tools - Restart executor
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* respawns automatically.
|
|
9
|
-
*
|
|
10
|
-
* 2. Daemon (daemon-launcher): No supervisor loop. The executor spawns a
|
|
11
|
-
* replacement daemon on the process 'exit' event (after the singleton lock
|
|
12
|
-
* is released), then sends SIGINT to trigger graceful shutdown.
|
|
4
|
+
* Single restart path for both TUI and daemon:
|
|
5
|
+
* Register an 'exit' handler to spawn a replacement process, then SIGINT
|
|
6
|
+
* the current process for graceful shutdown. The replacement starts fresh
|
|
7
|
+
* and goes through normal startup (heap check, createCliContext, REPL/daemon).
|
|
13
8
|
*/
|
|
14
9
|
import type { ToolContext, ToolResult } from "../types.js";
|
|
15
10
|
export interface RestartInput {
|
|
@@ -2,15 +2,10 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* @aria/tools - Restart executor
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* respawns automatically.
|
|
10
|
-
*
|
|
11
|
-
* 2. Daemon (daemon-launcher): No supervisor loop. The executor spawns a
|
|
12
|
-
* replacement daemon on the process 'exit' event (after the singleton lock
|
|
13
|
-
* is released), then sends SIGINT to trigger graceful shutdown.
|
|
5
|
+
* Single restart path for both TUI and daemon:
|
|
6
|
+
* Register an 'exit' handler to spawn a replacement process, then SIGINT
|
|
7
|
+
* the current process for graceful shutdown. The replacement starts fresh
|
|
8
|
+
* and goes through normal startup (heap check, createCliContext, REPL/daemon).
|
|
14
9
|
*/
|
|
15
10
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
16
11
|
if (k2 === undefined) k2 = k;
|
|
@@ -117,7 +112,6 @@ function findDaemonPid() {
|
|
|
117
112
|
async function executeRestart(input, ctx) {
|
|
118
113
|
if (ctx.abortSignal?.aborted)
|
|
119
114
|
return (0, utils_js_1.fail)("Operation cancelled");
|
|
120
|
-
const supervised = process.env[types_1.NO_RELAUNCH_ENV] === "true";
|
|
121
115
|
const reason = (input.reason ?? "").trim() || "Restart requested";
|
|
122
116
|
// Note: tool definition has requiresConfirmation: true, so the framework
|
|
123
117
|
// already prompts the user before execute() is called. No need to confirm again.
|
|
@@ -134,54 +128,29 @@ async function executeRestart(input, ctx) {
|
|
|
134
128
|
process.stderr.write(`[aria] Restarting: ${reason}\n`);
|
|
135
129
|
const sessionId = process.env[types_1.RESUME_SESSION_ENV] ?? null;
|
|
136
130
|
const arionName = process.env[types_1.RESUME_ARION_ENV] || "ARIA";
|
|
137
|
-
// Write disk-backed marker
|
|
131
|
+
// Write disk-backed marker so the replacement process can resume the session.
|
|
138
132
|
(0, types_1.writeRelaunchMarker)({
|
|
139
133
|
sessionId,
|
|
140
134
|
arionName,
|
|
141
135
|
pid: process.ppid || process.pid,
|
|
142
136
|
timestamp: new Date().toISOString(),
|
|
143
137
|
});
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
}
|
|
157
|
-
catch {
|
|
158
|
-
// non-fatal — disk marker is the fallback
|
|
159
|
-
}
|
|
160
|
-
process.exit(types_1.RELAUNCH_EXIT_CODE);
|
|
138
|
+
// Spawn replacement on exit, then SIGINT for graceful shutdown.
|
|
139
|
+
// Works for both TUI and daemon — no supervisor needed.
|
|
140
|
+
const targetPid = findDaemonPid() ?? process.pid;
|
|
141
|
+
process.once("exit", () => {
|
|
142
|
+
(0, node_child_process_1.spawn)(process.execPath, [...process.execArgv, ...process.argv.slice(1)], {
|
|
143
|
+
detached: true,
|
|
144
|
+
stdio: "ignore",
|
|
145
|
+
}).unref();
|
|
146
|
+
});
|
|
147
|
+
process.stderr.write(`[aria] Sending SIGINT to pid ${targetPid} for graceful restart\n`);
|
|
148
|
+
try {
|
|
149
|
+
process.kill(targetPid, "SIGINT");
|
|
161
150
|
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
// Register an 'exit' handler to spawn the replacement AFTER the singleton
|
|
165
|
-
// lock is released (beforeExit releases it). Then SIGINT ourselves to
|
|
166
|
-
// trigger graceful daemon shutdown. The SIGINT handler fires synchronously
|
|
167
|
-
// (just sets controller.abort()), so the tool can still return success.
|
|
168
|
-
const daemonPid = findDaemonPid() ?? process.pid;
|
|
169
|
-
process.once("exit", () => {
|
|
170
|
-
(0, node_child_process_1.spawn)(process.execPath, [...process.execArgv, ...process.argv.slice(1)], {
|
|
171
|
-
detached: true,
|
|
172
|
-
stdio: "ignore",
|
|
173
|
-
}).unref();
|
|
174
|
-
});
|
|
175
|
-
process.stderr.write(`[aria] Sending SIGINT to daemon pid ${daemonPid} for graceful restart\n`);
|
|
176
|
-
try {
|
|
177
|
-
process.kill(daemonPid, "SIGINT");
|
|
178
|
-
}
|
|
179
|
-
catch {
|
|
180
|
-
// PID already dead or not our process — fall back to self
|
|
181
|
-
process.kill(process.pid, "SIGINT");
|
|
182
|
-
}
|
|
151
|
+
catch {
|
|
152
|
+
process.kill(process.pid, "SIGINT");
|
|
183
153
|
}
|
|
184
|
-
// Unreachable in supervised path (process.exit above), but returned in daemon path
|
|
185
154
|
return (0, utils_js_1.success)("Restarting...");
|
|
186
155
|
}
|
|
187
156
|
//# sourceMappingURL=restart.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"restart.js","sourceRoot":"","sources":["../../src/executors/restart.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"restart.js","sourceRoot":"","sources":["../../src/executors/restart.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2EH,wCAkDC;AA1HD,yCAA2C;AAC3C,2DAA2C;AAC3C,qCAAgE;AAChE,yCAAmD;AACnD,4CAA8B;AAC9B,2CAA4F;AAM5F,SAAS,qBAAqB,CAAC,QAAgB;IAC7C,IAAI,GAAG,GAAG,IAAA,mBAAO,EAAC,QAAQ,CAAC,CAAC;IAC5B,OAAO,IAAI,EAAE,CAAC;QACZ,IAAI,IAAA,oBAAU,EAAC,IAAA,gBAAI,EAAC,GAAG,EAAE,qBAAqB,CAAC,CAAC;YAAE,OAAO,GAAG,CAAC;QAC7D,MAAM,MAAM,GAAG,IAAA,mBAAO,EAAC,GAAG,CAAC,CAAC;QAC5B,IAAI,MAAM,KAAK,GAAG;YAAE,OAAO,IAAI,CAAC;QAChC,GAAG,GAAG,MAAM,CAAC;IACf,CAAC;AACH,CAAC;AAED,SAAS,cAAc;IACrB,OAAO,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC;AAC5D,CAAC;AAED,KAAK,UAAU,yBAAyB,CAAC,QAAgB;IACvD,MAAM,IAAI,GAAG,qBAAqB,CAAC,QAAQ,CAAC,CAAC;IAC7C,IAAI,CAAC,IAAI;QAAE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;IAEvC,MAAM,IAAI,GAAG,cAAc,EAAE,CAAC;IAC9B,MAAM,IAAI,OAAO,CAAO,CAAC,cAAc,EAAE,aAAa,EAAE,EAAE;QACxD,MAA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kBAAO,EAAC,eAAe,CAAC,CAAC;AAClC,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Freshness tracker for aria-search (code_search tool).
|
|
3
|
+
*
|
|
4
|
+
* Mirrors frg-freshness.ts patterns to close the freshness gaps:
|
|
5
|
+
* 1. Tracks file mutations from ARIA tool writes (session overlay)
|
|
6
|
+
* 2. Reconciles git-dirty files on each search
|
|
7
|
+
* 3. Generates session overlay for the napi search() call
|
|
8
|
+
*
|
|
9
|
+
* The session overlay gives 0ms visibility for pending mutations —
|
|
10
|
+
* files written by agents/users appear in search results immediately
|
|
11
|
+
* without waiting for an index rebuild or hot.log sync.
|
|
12
|
+
*/
|
|
13
|
+
export type SearchMutationOperation = "write" | "delete";
|
|
14
|
+
export interface SearchMutationRecord {
|
|
15
|
+
path: string;
|
|
16
|
+
operation: SearchMutationOperation;
|
|
17
|
+
content?: string;
|
|
18
|
+
sequence: number;
|
|
19
|
+
}
|
|
20
|
+
export interface SearchSessionOverlay {
|
|
21
|
+
sessionWrites: Array<{
|
|
22
|
+
path: string;
|
|
23
|
+
content: string;
|
|
24
|
+
}>;
|
|
25
|
+
sessionDeletes: string[];
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Record a file mutation from an ARIA tool write/edit/delete.
|
|
29
|
+
* Called alongside recordFrgMutation in filesystem.ts and apply-patch.ts.
|
|
30
|
+
*/
|
|
31
|
+
export declare function recordSearchMutation(filePath: string, operation: SearchMutationOperation, content?: string): void;
|
|
32
|
+
/**
|
|
33
|
+
* Reconcile git-dirty files into the pending mutations map.
|
|
34
|
+
* Runs `git diff --name-status -z HEAD` and `git ls-files -o --exclude-standard -z`
|
|
35
|
+
* to detect files modified/created/deleted by external agents or the user.
|
|
36
|
+
*
|
|
37
|
+
* Throttled to at most once per GIT_RECONCILE_INTERVAL_MS to avoid
|
|
38
|
+
* hammering git on rapid sequential searches.
|
|
39
|
+
*/
|
|
40
|
+
export declare function reconcileSearchGitDirty(root: string): void;
|
|
41
|
+
/**
|
|
42
|
+
* Generate the session overlay for the napi search() call.
|
|
43
|
+
* Reads content from disk for mutations without cached content.
|
|
44
|
+
*/
|
|
45
|
+
export declare function getSearchSessionOverlay(root: string): SearchSessionOverlay;
|
|
46
|
+
/**
|
|
47
|
+
* Clear all pending mutations for a repo root.
|
|
48
|
+
* Called after a full index rebuild (all mutations are now in the base index).
|
|
49
|
+
*/
|
|
50
|
+
export declare function clearSearchMutations(root: string): void;
|