Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type": "Feature",
"description": "Add grepSearch dependency for agentic chat"
}
13 changes: 12 additions & 1 deletion packages/amazonq/src/lsp/lspInstaller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,17 @@
* SPDX-License-Identifier: Apache-2.0
*/

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

export interface AmazonQResourcePaths extends ResourcePaths {
ui: string
/**
* Path to `rg` (or `rg.exe`) executable/binary.
* Example: `"<cachedir>/aws/toolkits/language-servers/AmazonQ/3.3.0/servers/rg"`
*/
rg: string
}

export class AmazonQLspInstaller extends BaseLspInstaller.BaseLspInstaller<
Expand All @@ -22,21 +27,27 @@ export class AmazonQLspInstaller extends BaseLspInstaller.BaseLspInstaller<
protected override async postInstall(assetDirectory: string): Promise<void> {
const resourcePaths = this.resourcePaths(assetDirectory)
await fs.chmod(resourcePaths.node, 0o755)
if (await fs.exists(resourcePaths.rg)) {
await fs.chmod(resourcePaths.rg, 0o755)
}
}

protected override resourcePaths(assetDirectory?: string): AmazonQResourcePaths {
if (!assetDirectory) {
return {
lsp: this.config.path ?? '',
node: getNodeExecutableName(),
rg: `ripgrep/${getRgExecutableName()}`,
ui: this.config.ui ?? '',
}
}

const nodePath = path.join(assetDirectory, `servers/${getNodeExecutableName()}`)
const rgPath = path.join(assetDirectory, `servers/ripgrep/${getRgExecutableName()}`)
return {
lsp: path.join(assetDirectory, 'servers/aws-lsp-codewhisperer.js'),
node: nodePath,
rg: rgPath,
ui: path.join(assetDirectory, 'clients/amazonq-ui.js'),
}
}
Expand Down
4 changes: 4 additions & 0 deletions packages/core/src/shared/lsp/utils/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ export function getNodeExecutableName(): string {
return process.platform === 'win32' ? 'node.exe' : 'node'
}

export function getRgExecutableName(): string {
return process.platform === 'win32' ? 'rg.exe' : 'rg'
}

/**
* Get a json payload that will be sent to the language server, who is waiting to know what the encryption key is.
* Code reference: https://github.com/aws/language-servers/blob/7da212185a5da75a72ce49a1a7982983f438651a/client/vscode/src/credentialsActivation.ts#L77
Expand Down
Loading