Skip to content

Commit 1d585e9

Browse files
authored
feat(chat): Add ripgrep path and make it executable (#7325)
## Problem - AgenticChat will add a grepSearch tool which depends on ripgrep binary ## Solution - Add ripgrep path and make it executable --- - Treat all work as PUBLIC. Private `feature/x` branches will not be squash-merged at release time. - Your code changes must meet the guidelines in [CONTRIBUTING.md](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines). - License: I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent e564ef6 commit 1d585e9

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

packages/amazonq/src/lsp/lspInstaller.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,17 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6-
import { fs, getNodeExecutableName, BaseLspInstaller, ResourcePaths } from 'aws-core-vscode/shared'
6+
import { fs, getNodeExecutableName, getRgExecutableName, BaseLspInstaller, ResourcePaths } from 'aws-core-vscode/shared'
77
import path from 'path'
88
import { ExtendedAmazonQLSPConfig, getAmazonQLspConfig } from './config'
99

1010
export interface AmazonQResourcePaths extends ResourcePaths {
1111
ui: string
12+
/**
13+
* Path to `rg` (or `rg.exe`) executable/binary.
14+
* Example: `"<cachedir>/aws/toolkits/language-servers/AmazonQ/3.3.0/servers/rg"`
15+
*/
16+
ripGrep: string
1217
}
1318

1419
export class AmazonQLspInstaller extends BaseLspInstaller.BaseLspInstaller<
@@ -22,21 +27,27 @@ export class AmazonQLspInstaller extends BaseLspInstaller.BaseLspInstaller<
2227
protected override async postInstall(assetDirectory: string): Promise<void> {
2328
const resourcePaths = this.resourcePaths(assetDirectory)
2429
await fs.chmod(resourcePaths.node, 0o755)
30+
if (await fs.exists(resourcePaths.ripGrep)) {
31+
await fs.chmod(resourcePaths.ripGrep, 0o755)
32+
}
2533
}
2634

2735
protected override resourcePaths(assetDirectory?: string): AmazonQResourcePaths {
2836
if (!assetDirectory) {
2937
return {
3038
lsp: this.config.path ?? '',
3139
node: getNodeExecutableName(),
40+
ripGrep: `ripgrep/${getRgExecutableName()}`,
3241
ui: this.config.ui ?? '',
3342
}
3443
}
3544

3645
const nodePath = path.join(assetDirectory, `servers/${getNodeExecutableName()}`)
46+
const rgPath = path.join(assetDirectory, `servers/ripgrep/${getRgExecutableName()}`)
3747
return {
3848
lsp: path.join(assetDirectory, 'servers/aws-lsp-codewhisperer.js'),
3949
node: nodePath,
50+
ripGrep: rgPath,
4051
ui: path.join(assetDirectory, 'clients/amazonq-ui.js'),
4152
}
4253
}

packages/core/src/shared/lsp/utils/platform.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ export function getNodeExecutableName(): string {
1313
return process.platform === 'win32' ? 'node.exe' : 'node'
1414
}
1515

16+
export function getRgExecutableName(): string {
17+
return process.platform === 'win32' ? 'rg.exe' : 'rg'
18+
}
19+
1620
/**
1721
* Get a json payload that will be sent to the language server, who is waiting to know what the encryption key is.
1822
* Code reference: https://github.com/aws/language-servers/blob/7da212185a5da75a72ce49a1a7982983f438651a/client/vscode/src/credentialsActivation.ts#L77

0 commit comments

Comments
 (0)