Skip to content

Include all language files in workspace query #86

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
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
21 changes: 21 additions & 0 deletions commanddash/lib/steps/find_closest_files/embedding_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,27 @@ import 'package:commanddash/repositories/generation_repository.dart';
import 'package:commanddash/utils/embedding_utils.dart';

class EmbeddingGenerator {
static List<WorkspaceFile> getProjectFiles(String workspacePath) {
final directory = Directory(workspacePath);
final gitIgnore = File('${workspacePath}/.gitignore');
String excludePattern = '';
if (gitIgnore.existsSync()) {
final ignorePatterns = gitIgnore.readAsLinesSync();
excludePattern = ignorePatterns
.map((pattern) =>
pattern.replaceAll('/', r"[/\\]").replaceAll('*', '.*'))
.join('|');
}
final dartFiles = directory.listSync(recursive: true).where((file) {
return !RegExp(excludePattern).hasMatch(file.path);
}).toList();
final fileContents = dartFiles.map((file) {
return WorkspaceFile.fromPath(file.path);
}).toList();
fileContents.removeWhere((element) => (element.fileContent).isEmpty);
return fileContents;
}

static List<WorkspaceFile> getDartFiles(String workspacePath) {
final directory = Directory(workspacePath);
const excludePattern =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class SearchInWorkspaceStep extends Step {
taskAssist.sendErrorMessage(message: "No open workspace found", data: {});
throw Exception("No open workspace found");
}
final dartFiles = EmbeddingGenerator.getDartFiles(workspacePath);
final dartFiles = EmbeddingGenerator.getProjectFiles(workspacePath);
final codeCacheHash = jsonDecode((await taskAssist.processStep(
kind: 'cache', args: {}, timeoutKind: TimeoutKind.sync))['value']);
final filesToUpdate =
Expand Down