From 584a9e15f984539996751e8b69a6393daeb75d5d Mon Sep 17 00:00:00 2001 From: Mehdi Hadeli Date: Thu, 28 Nov 2024 17:09:23 +0100 Subject: [PATCH] =?UTF-8?q?ci:=20=F0=9F=91=B7=20Add=20AIAssist=20dotnet=20?= =?UTF-8?q?tool=20to=20Nuget=20for=20installation=20(#16)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/labeler.yml | 166 ++++++++++++++++ .github/multi-labeler.yml | 88 +++++++++ .github/release-drafter.yml | 147 ++++++++++++++ .github/release.yml | 63 ++++++ .github/workflows/build-test.yml | 61 ++++++ .github/workflows/labeler.yml | 53 +++++ .github/workflows/publish.yml | 182 ++++++++++++++++++ .github/workflows/release-drafter.yml | 32 +++ .gitignore | 3 +- AIAssistant.sln | 75 +++----- readme.md => README.md | 5 +- scripts/ci_install_tree_sitter.sh | 162 ++++++++++++++++ scripts/install_tree_sitter.sh | 19 +- src/{AIAssistant => AIAssist}/.aiassistignore | 0 .../AIAssist.csproj} | 39 +++- src/AIAssist/AIAssist.nuspec | 45 +++++ .../AIAssistConstants.cs} | 4 +- .../Chat/Models/ChatCost.cs | 2 +- .../Chat/Models/ChatHistory.cs | 2 +- .../Chat/Models/ChatHistoryItem.cs | 2 +- .../Chat/Models/ChatItem.cs | 2 +- .../Chat/Models/ChatSession.cs | 2 +- .../Commands/AIAssistCommand.cs | 2 +- .../Commands/ChatAssistCommand.cs | 2 +- .../Commands/CodeAssistCommand.cs | 90 ++++----- .../Commands/CodeExplanationCommand.cs | 2 +- .../Commands/HostPluginsCommand.cs | 2 +- .../InternalCommands/AddFileCommand.cs | 6 +- .../Commands/InternalCommands/ClearCommand.cs | 6 +- .../InternalCommands/ClearHistoryCommand.cs | 6 +- .../FoldersTreeListCommand.cs | 6 +- .../Commands/InternalCommands/HelpCommand.cs | 4 +- .../Commands/InternalCommands/QuitCommand.cs | 6 +- .../Commands/InternalCommands/RunCommand.cs | 19 +- .../InternalCommands/SummarizeCommand.cs | 6 +- .../Commands/InternalCommands/TokenCommand.cs | 6 +- src/AIAssist/Commands/PlanCommand.cs | 3 + .../Commands/ReviewCommand.cs | 2 +- .../Commands/TreeStructureCommand.cs | 2 +- .../Contracts/CodeAssist/ICodeAssist.cs | 2 +- .../CodeAssist/ICodeAssistFactory.cs | 3 +- .../CodeAssist/ICodeAssistantManager.cs | 7 +- .../Contracts/Diff/ICodeDiffManager.cs | 4 +- .../Contracts/Diff/ICodeDiffParser.cs | 4 +- .../Contracts/Diff/ICodeDiffParserFactory.cs | 3 +- .../Contracts/Diff/ICodeDiffUpdater.cs | 4 +- .../Contracts/IChatSessionManager.cs | 5 +- .../ICodeFileTreeGeneratorService.cs | 2 +- .../Contracts/IContextService.cs | 4 +- .../Contracts/IEmbeddingService.cs | 11 +- .../Contracts/IFileService.cs | 2 +- .../Contracts/ILLMClientManager.cs | 4 +- .../Contracts/IPromptManager.cs | 4 +- .../Data/CodeEmbeddingDocument.cs | 2 +- .../Data/CodeEmbeddingsRepository.cs | 4 +- .../Data/ICodeEmbeddingsRepository.cs | 4 +- .../Diff/CodeBlockDiffParser.cs | 6 +- .../Diff/CodeDiffManager.cs | 6 +- .../Diff/CodeDiffParserFactory.cs | 4 +- .../Diff/CodeDiffUpdater.cs | 6 +- .../Diff/SearchReplaceParser.cs | 6 +- .../Diff/UnifiedCodeDiffParser.cs | 6 +- src/AIAssist/DotnetToolSettings.xml | 6 + .../Dtos/AddEmbeddingsForFilesResult.cs | 2 +- .../Dtos/GetBatchEmbeddingResult.cs | 2 +- .../Dtos/GetEmbeddingResult.cs | 2 +- .../Dtos/GetRelatedEmbeddingsResult.cs | 4 +- .../Extensions/ConfigurationExtensions.cs | 4 +- .../DependencyInjectionExtensions.cs | 32 +-- src/{AIAssistant => AIAssist}/MetadataRoot.cs | 2 +- .../Models/ActionType.cs | 2 +- .../Models/ChangeType.cs | 2 +- .../Models/CodeBase.cs | 2 +- .../Models/CodeEmbedding.cs | 2 +- .../Models/CodeSummary.cs | 2 +- .../Models/CommandType.cs | 2 +- .../Models/Context.cs | 2 +- .../Models/ContextTreeLevel.cs | 2 +- .../Models/DiffResult.cs | 2 +- .../Models/FileBatch.cs | 2 +- .../Models/FileChunkGroup.cs | 2 +- src/{AIAssistant => AIAssist}/Models/Hunk.cs | 2 +- .../Models/Options/AppOptions.cs | 2 +- .../Models/PromptInformation.cs | 2 +- .../Models/Replacement.cs | 2 +- src/{AIAssistant => AIAssist}/Program.cs | 4 +- .../Prompts/PromptManager.cs | 16 +- .../Templates/ask-more-context.template | 0 .../code-assist-search-replace-diff.template | 0 .../code-assistant-code-block-diff.template | 0 .../code-assistant-unified-diff.template | 0 .../Prompts/Templates/code-block.template | 0 .../Prompts/Templates/code-context.template | 0 .../Prompts/Templates/code-embedding.template | 0 .../Services/ChatSessionManager.cs | 7 +- .../CodeAssistStrategies/CodeAssistFactory.cs | 4 +- .../EmbeddingCodeAssist.cs | 12 +- .../TreeSitterCodeAssistSummary.cs | 6 +- .../Services/CodeAssistantManager.cs | 11 +- .../Services/CodeFilesTreeGeneratorService.cs | 6 +- .../Services/ContextService.cs | 8 +- .../Services/EmbeddingService.cs | 37 ++-- .../Services/FileService.cs | 12 +- .../Services/LLMClientManager.cs | 6 +- .../aiassist-config.json | 0 src/AIAssistant/AIAssistant.sln | 42 ---- src/AIAssistant/Commands/PlanCommand.cs | 3 - .../{DotEnv => Environments}/DotEnv.cs | 2 +- src/Clients/CacheModels.cs | 7 +- src/Clients/Contracts/ICacheModels.cs | 2 +- src/Directory.Build.props | 23 +++ src/Directory.Packages.props | 3 + .../TreeSitter.Bindings.csproj | 5 +- .../ApplicationFixture.cs | 2 +- ...ddingCodeAssistStrategyIntegrationTests.cs | 4 +- .../CodeAssistantManagerIntegrationTests.cs | 5 +- .../ApplicationFixture.cs | 2 +- .../OllamaClientStrategyIntegrationTests.cs | 1 - .../OpenAIClientStrategyIntegrationTests.cs | 1 - .../Diff/CodeDiffUpdaterTests.cs | 4 +- .../Diff/UnifiedCodeDiffParserTests.cs | 4 +- .../Services/CodeLoaderServiceTests.cs | 3 +- version.json | 18 ++ 123 files changed, 1378 insertions(+), 393 deletions(-) create mode 100644 .github/labeler.yml create mode 100644 .github/multi-labeler.yml create mode 100644 .github/release-drafter.yml create mode 100644 .github/release.yml create mode 100644 .github/workflows/build-test.yml create mode 100644 .github/workflows/labeler.yml create mode 100644 .github/workflows/publish.yml create mode 100644 .github/workflows/release-drafter.yml rename readme.md => README.md (96%) create mode 100644 scripts/ci_install_tree_sitter.sh rename src/{AIAssistant => AIAssist}/.aiassistignore (100%) rename src/{AIAssistant/AIAssistant.csproj => AIAssist/AIAssist.csproj} (57%) create mode 100644 src/AIAssist/AIAssist.nuspec rename src/{AIAssistant/AIAssistantConstants.cs => AIAssist/AIAssistConstants.cs} (95%) rename src/{AIAssistant => AIAssist}/Chat/Models/ChatCost.cs (96%) rename src/{AIAssistant => AIAssist}/Chat/Models/ChatHistory.cs (97%) rename src/{AIAssistant => AIAssist}/Chat/Models/ChatHistoryItem.cs (93%) rename src/{AIAssistant => AIAssist}/Chat/Models/ChatItem.cs (85%) rename src/{AIAssistant => AIAssist}/Chat/Models/ChatSession.cs (98%) rename src/{AIAssistant => AIAssist}/Commands/AIAssistCommand.cs (96%) rename src/{AIAssistant => AIAssist}/Commands/ChatAssistCommand.cs (95%) rename src/{AIAssistant => AIAssist}/Commands/CodeAssistCommand.cs (73%) rename src/{AIAssistant => AIAssist}/Commands/CodeExplanationCommand.cs (98%) rename src/{AIAssistant => AIAssist}/Commands/HostPluginsCommand.cs (53%) rename src/{AIAssistant => AIAssist}/Commands/InternalCommands/AddFileCommand.cs (93%) rename src/{AIAssistant => AIAssist}/Commands/InternalCommands/ClearCommand.cs (79%) rename src/{AIAssistant => AIAssist}/Commands/InternalCommands/ClearHistoryCommand.cs (79%) rename src/{AIAssistant => AIAssist}/Commands/InternalCommands/FoldersTreeListCommand.cs (80%) rename src/{AIAssistant => AIAssist}/Commands/InternalCommands/HelpCommand.cs (80%) rename src/{AIAssistant => AIAssist}/Commands/InternalCommands/QuitCommand.cs (81%) rename src/{AIAssistant => AIAssist}/Commands/InternalCommands/RunCommand.cs (84%) rename src/{AIAssistant => AIAssist}/Commands/InternalCommands/SummarizeCommand.cs (78%) rename src/{AIAssistant => AIAssist}/Commands/InternalCommands/TokenCommand.cs (78%) create mode 100644 src/AIAssist/Commands/PlanCommand.cs rename src/{AIAssistant => AIAssist}/Commands/ReviewCommand.cs (50%) rename src/{AIAssistant => AIAssist}/Commands/TreeStructureCommand.cs (93%) rename src/{AIAssistant => AIAssist}/Contracts/CodeAssist/ICodeAssist.cs (88%) rename src/{AIAssistant => AIAssist}/Contracts/CodeAssist/ICodeAssistFactory.cs (62%) rename src/{AIAssistant => AIAssist}/Contracts/CodeAssist/ICodeAssistantManager.cs (77%) rename src/{AIAssistant => AIAssist}/Contracts/Diff/ICodeDiffManager.cs (77%) rename src/{AIAssistant => AIAssist}/Contracts/Diff/ICodeDiffParser.cs (68%) rename src/{AIAssistant => AIAssist}/Contracts/Diff/ICodeDiffParserFactory.cs (65%) rename src/{AIAssistant => AIAssist}/Contracts/Diff/ICodeDiffUpdater.cs (67%) rename src/{AIAssistant => AIAssist}/Contracts/IChatSessionManager.cs (75%) rename src/{AIAssistant => AIAssist}/Contracts/ICodeFileTreeGeneratorService.cs (92%) rename src/{AIAssistant => AIAssist}/Contracts/IContextService.cs (88%) rename src/{AIAssistant => AIAssist}/Contracts/IEmbeddingService.cs (79%) rename src/{AIAssistant => AIAssist}/Contracts/IFileService.cs (95%) rename src/{AIAssistant => AIAssist}/Contracts/ILLMClientManager.cs (90%) rename src/{AIAssistant => AIAssist}/Contracts/IPromptManager.cs (95%) rename src/{AIAssistant => AIAssist}/Data/CodeEmbeddingDocument.cs (77%) rename src/{AIAssistant => AIAssist}/Data/CodeEmbeddingsRepository.cs (98%) rename src/{AIAssistant => AIAssist}/Data/ICodeEmbeddingsRepository.cs (75%) rename src/{AIAssistant => AIAssist}/Diff/CodeBlockDiffParser.cs (98%) rename src/{AIAssistant => AIAssist}/Diff/CodeDiffManager.cs (84%) rename src/{AIAssistant => AIAssist}/Diff/CodeDiffParserFactory.cs (80%) rename src/{AIAssistant => AIAssist}/Diff/CodeDiffUpdater.cs (98%) rename src/{AIAssistant => AIAssist}/Diff/SearchReplaceParser.cs (99%) rename src/{AIAssistant => AIAssist}/Diff/UnifiedCodeDiffParser.cs (99%) create mode 100644 src/AIAssist/DotnetToolSettings.xml rename src/{AIAssistant => AIAssist}/Dtos/AddEmbeddingsForFilesResult.cs (75%) rename src/{AIAssistant => AIAssist}/Dtos/GetBatchEmbeddingResult.cs (91%) rename src/{AIAssistant => AIAssist}/Dtos/GetEmbeddingResult.cs (84%) rename src/{AIAssistant => AIAssist}/Dtos/GetRelatedEmbeddingsResult.cs (72%) rename src/{AIAssistant => AIAssist}/Extensions/ConfigurationExtensions.cs (92%) rename src/{AIAssistant => AIAssist}/Extensions/DependencyInjectionExtensions.cs (97%) rename src/{AIAssistant => AIAssist}/MetadataRoot.cs (54%) rename src/{AIAssistant => AIAssist}/Models/ActionType.cs (68%) rename src/{AIAssistant => AIAssist}/Models/ChangeType.cs (69%) rename src/{AIAssistant => AIAssist}/Models/CodeBase.cs (90%) rename src/{AIAssistant => AIAssist}/Models/CodeEmbedding.cs (85%) rename src/{AIAssistant => AIAssist}/Models/CodeSummary.cs (83%) rename src/{AIAssistant => AIAssist}/Models/CommandType.cs (78%) rename src/{AIAssistant => AIAssist}/Models/Context.cs (98%) rename src/{AIAssistant => AIAssist}/Models/ContextTreeLevel.cs (77%) rename src/{AIAssistant => AIAssist}/Models/DiffResult.cs (92%) rename src/{AIAssistant => AIAssist}/Models/FileBatch.cs (94%) rename src/{AIAssistant => AIAssist}/Models/FileChunkGroup.cs (92%) rename src/{AIAssistant => AIAssist}/Models/Hunk.cs (91%) rename src/{AIAssistant => AIAssist}/Models/Options/AppOptions.cs (93%) rename src/{AIAssistant => AIAssist}/Models/PromptInformation.cs (81%) rename src/{AIAssistant => AIAssist}/Models/Replacement.cs (95%) rename src/{AIAssistant => AIAssist}/Program.cs (97%) rename src/{AIAssistant => AIAssist}/Prompts/PromptManager.cs (90%) rename src/{AIAssistant => AIAssist}/Prompts/Templates/ask-more-context.template (100%) rename src/{AIAssistant => AIAssist}/Prompts/Templates/code-assist-search-replace-diff.template (100%) rename src/{AIAssistant => AIAssist}/Prompts/Templates/code-assistant-code-block-diff.template (100%) rename src/{AIAssistant => AIAssist}/Prompts/Templates/code-assistant-unified-diff.template (100%) rename src/{AIAssistant => AIAssist}/Prompts/Templates/code-block.template (100%) rename src/{AIAssistant => AIAssist}/Prompts/Templates/code-context.template (100%) rename src/{AIAssistant => AIAssist}/Prompts/Templates/code-embedding.template (100%) rename src/{AIAssistant => AIAssist}/Services/ChatSessionManager.cs (90%) rename src/{AIAssistant => AIAssist}/Services/CodeAssistStrategies/CodeAssistFactory.cs (72%) rename src/{AIAssistant => AIAssist}/Services/CodeAssistStrategies/EmbeddingCodeAssist.cs (95%) rename src/{AIAssistant => AIAssist}/Services/CodeAssistStrategies/TreeSitterCodeAssistSummary.cs (94%) rename src/{AIAssistant => AIAssist}/Services/CodeAssistantManager.cs (91%) rename src/{AIAssistant => AIAssist}/Services/CodeFilesTreeGeneratorService.cs (98%) rename src/{AIAssistant => AIAssist}/Services/ContextService.cs (99%) rename src/{AIAssistant => AIAssist}/Services/EmbeddingService.cs (92%) rename src/{AIAssistant => AIAssist}/Services/FileService.cs (85%) rename src/{AIAssistant => AIAssist}/Services/LLMClientManager.cs (97%) rename src/{AIAssistant => AIAssist}/aiassist-config.json (100%) delete mode 100644 src/AIAssistant/AIAssistant.sln delete mode 100644 src/AIAssistant/Commands/PlanCommand.cs rename src/BuildingBlocks/{DotEnv => Environments}/DotEnv.cs (94%) create mode 100644 version.json diff --git a/.github/labeler.yml b/.github/labeler.yml new file mode 100644 index 0000000..8399f3e --- /dev/null +++ b/.github/labeler.yml @@ -0,0 +1,166 @@ +# https://github.com/actions/labeler + +# In some configurations (like Release Drafter), regex is enclosed with slashes (e.g., /build\/.+/), which signifies the start and end of the regular expression. +# However, in GitHub Actions' labeler.yml, you do not need to wrap your regex patterns in slashes. The tool expects just the regex itself, without the delimiters. + +ansible: +- changed-files: + - any-glob-to-any-file: + - '.ansible-lint' + - 'ansible.cfg' + - 'ansible/*' + - 'molecule/*' + +configuration: +- changed-files: + - any-glob-to-any-file: + - '.github/*yml' + - '.gitignore' + - '.gitattributes' + - '.vscode/*' + - '.devcontainer/*' + - '.editorconfig' + - '.yamllint.yml' + - '.ansible-lint' + +docker: +- changed-files: + - any-glob-to-any-file: + - '**/Dockerfile' + - '**/docker-compose.yml' + - '**/docker-compose.yaml' + - '**/docker-compose.test.yml' + +github: +- any: + - changed-files: + - any-glob-to-any-file: + - '.github/*' + - '!.github/workflows/' + +source: +- all: + - changed-files: + - any-glob-to-any-file: 'src/**/*' + - all-globs-to-all-files: '!src/docs/*' + +policy: +- changed-files: + - any-glob-to-any-file: + - '.github/ISSUE_TEMPLATE/*' + - '.github/PULL_TEMPLATE/*' + - 'LICENSE' + - 'SECURITY.md' + +terraform: +- changed-files: + - any-glob-to-any-file: + - 'terraform/*' + - '**/*.tf' + - '**/*.lock.hcl' + +vscode: +- changed-files: + - any-glob-to-any-file: + - '.vscode/*' + +feature: +- head-branch: + - '^(feat)(\([a-z ]+\))?\/.' + - '^(feature)(\([a-z ]+\))?\/.' +- changed-files: + - any-glob-to-any-file: + - src/* + +ci-cd: +- head-branch: + - '^(ci)(\([a-z ]+\))?\/.' +- changed-files: + - any-glob-to-any-file: + - '.github/workflows/*' + - '.github/*' + +devops: +- head-branch: + - '^(ci)(\([a-z ]+\))?\/.' +- changed-files: + - any-glob-to-any-file: + - 'deployments/*' + - '.github/workflows/*' + - '.github/*' + - 'terraform/*' + - '**/*.tf' + - '**/*.lock.hcl' + - '**/Dockerfile' + - '**/docker-compose.yml' + - '**/docker-compose.yaml' + - '**/docker-compose.test.yml' + +style: +- head-branch: + - '^(style)(\([a-z ]+\))?\/.' +- changed-files: + - any-glob-to-any-file: + - src/* + +documentation: +- head-branch: + - '^(docs)(\([a-z ]+\))?\/.' +- changed-files: + - any-glob-to-any-file: + - '**/*.md' + - '**/*.rst' + - '**/*.txt' + - docs/** + - guides/* + +performance: +- head-branch: + - '^(perf)(\([a-z ]+\))?\/.' +- changed-files: + - any-glob-to-any-file: + - src/* + +bug: +- head-branch: + - '^(fix)(\([a-z ]+\))?\/.' +- changed-files: + - any-glob-to-any-file: + - src/* + +enhancement: +- head-branch: + - '^(refactor)(\([a-z ]+\))?\/.' +- changed-files: + - any-glob-to-any-file: + - src/* + +build: +- head-branch: + - '^(build)(\([a-z ]+\))?\/.' + +dependencies: +- head-branch: + - '^(build)(\([a-z ]+\))?\/.' + +chore: +- head-branch: + - '^(chore)(\([a-z ]+\))?\/.' + +test: +- head-branch: + - '^(test)(\([a-z ]+\))?\/.' +- changed-files: + - any-glob-to-any-file: + - 'test/*' + - 'molecule/*' + - 'docker-compose.test.yml' + +minor: +- head-branch: + - '^(feat)(\([a-z ]+\))?\/.' + +patch: +- head-branch: + - '^(fix)(\([a-z ]+\))?\/.' + - '^(ci)(\([a-z ]+\))?\/.' diff --git a/.github/multi-labeler.yml b/.github/multi-labeler.yml new file mode 100644 index 0000000..d83f975 --- /dev/null +++ b/.github/multi-labeler.yml @@ -0,0 +1,88 @@ +# https://github.com/fuxingloh/multi-labeler +# https://stackoverflow.com/questions/58899999/regexp-to-match-conventional-commit-syntax +version: v1 + +labels: +- label: "feature" + matcher: + title: '/^(feat)(\([a-z ]+\))?: .+/' + commits: '/^(feat)(\([a-z ]+\))?: .+/' + branch: '/^(feat)(\([a-z ]+\))?\/.+/' + +- label: "bug" + matcher: + title: '/^(fix)(\([a-z ]+\))?: .+/' + commits: '/^(fix)(\([a-z ]+\))?: .+/' + branch: '/^(fix)(\([a-z ]+\))?\/.+/' + +- label: "chore" + matcher: + title: '/^(chore)(\([a-z ]+\))?: .+/' + commits: '/^(chore)(\([a-z ]+\))?: .+/' + branch: '/^(chore)(\([a-z ]+\))?\/.+/' + +- label: "documentation" + matcher: + title: '/^(docs)(\([a-z ]+\))?: .+/' + commits: '/^(docs)(\([a-z ]+\))?: .+/' + branch: '/^(docs)(\([a-z ]+\))?\/.+/' + +- label: "devops" + matcher: + title: '/^(ci)(\([a-z ]+\))?: .+/' + commits: '/^(ci)(\([a-z ]+\))?: .+/' + branch: '/^(ci)(\([a-z ]+\))?\/.+/' + +- label: "ci-cd" + matcher: + title: '/^(ci)(\([a-z ]+\))?: .+/' + commits: '/^(ci)(\([a-z ]+\))?: .+/' + branch: '/^(ci)(\([a-z ]+\))?\/.+/' + +- label: "enhancement" + matcher: + title: '/^(refactor)(\([a-z ]+\))?: .+/' + commits: '/^(refactor)(\([a-z ]+\))?: .+/' + branch: '/^(refactor)(\([a-z ]+\))?\/.+/' + +- label: "style" + matcher: + title: '/^(style)(\([a-z ]+\))?: .+/' + commits: '/^(style)(\([a-z ]+\))?: .+/' + branch: '/^(style)(\([a-z ]+\))?\/.+/' + +- label: "performance" + matcher: + title: '/^(perf)(\([a-z ]+\))?: .+/' + commits: '/^(perf)(\([a-z ]+\))?: .+/' + branch: '/^(perf)(\([a-z ]+\))?\/.+/' + +- label: "build" + matcher: + title: '/^(build)(\([a-z ]+\))?: .+/' + commits: '/^(build)(\([a-z ]+\))?: .+/' + branch: '/^(build)(\([a-z ]+\))?\/.+/' + +- label: "test" + matcher: + title: '/^(test)(\([a-z ]+\))?: .+/' + commits: '/^(test)(\([a-z ]+\))?: .+/' + branch: '/^(test)(\([a-z ]+\))?\/.+/' + +- label: "dependencies" + matcher: + title: '/^(build)(\([a-z ]+\))?: .+/' + commits: '/^(build)(\([a-z ]+\))?: .+/' + branch: '/^(build)(\([a-z ]+\))?\/.+/' + +- label: "minor" + matcher: + title: '/^(feat)(\([a-z ]+\))?: .+/' + commits: '/^(feat)(\([a-z ]+\))?: .+/' + branch: '/^(feat)(\([a-z ]+\))?\/.+/' + +- label: "patch" + matcher: + title: '/^(fix)(\([a-z ]+\))?: .+/' + commits: '/^(fix)(\([a-z ]+\))?: .+/' + branch: '/^(fix)(\([a-z ]+\))?\/.+/' diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml new file mode 100644 index 0000000..840a85a --- /dev/null +++ b/.github/release-drafter.yml @@ -0,0 +1,147 @@ +# https://johanneskonings.dev/github/2021/02/28/github_automatic_releases_and-changelog/ +# https://tiagomichaelsousa.dev/articles/stop-writing-your-changelogs-manually + +# This release drafter follows the conventions +# from https://keepachangelog.com + +# https://github.com/release-drafter/release-drafter/issues/551 +# https://github.com/release-drafter/release-drafter/pull/1013 +# https://github.com/release-drafter/release-drafter/issues/139 +# https://github.com/atk4/data/blob/develop/.github/release-drafter.yml +name-template: 'v$RESOLVED_VERSION' +tag-template: 'v$RESOLVED_VERSION' +template: | + ## What Changed 👀 + $CHANGES + **Full Changelog**: https://github.com/$OWNER/$REPOSITORY/compare/$PREVIOUS_TAG...v$RESOLVED_VERSION +categories: +- title: 🚀 Features + labels: + - feature + - feat +- title: ♻️ Enhancement + labels: + - enhancement + - refactor +- title: 🐛 Bug Fixes + labels: + - fix + - bug +- title: 👷 CI + labels: + - ci + - ci-cd + - devops +- title: ⚠️ Breaking Changes + labels: + - breaking-changes + - major +- title: ⛔️ Deprecated + labels: + - deprecated +- title: 🗑 Removed + labels: + - removed +- title: 🔐 Security + labels: + - security +- title: 🎨 Style & Formatting + labels: + - style +- title: 🧪 Test + labels: + - test +- title: 📄 Documentation + labels: + - docs + - documentation +- title: 🧩 Dependency Updates + labels: + - deps + - build + - dependencies +- title: 🧰 Maintenance + label: 'chore' +- title: 🧺 Miscellaneous #Everything except ABAP + label: misc +- title: 🚩 Other changes + ## putting no labels pr to `Other Changes` category with no label - https://github.com/release-drafter/release-drafter/issues/139#issuecomment-480473934 + +# https://www.trywilco.com/post/wilco-ci-cd-github-heroku +# https://github.com/release-drafter/release-drafter#autolabeler +# https://github.com/fuxingloh/multi-labeler +# Using regex for defining rules - https://regexr.com/ +# https://stackoverflow.com/questions/58899999/regexp-to-match-conventional-commit-syntax +# Note: because of escaping logic inside of release drafter our regex should be escaped correctly and drafter wil un-escape it internally +# - Escaped regex: When writing a regular expression as a string in code, special characters like (, ), and : need to be escaped with a backslash (\) because these characters have special meanings in regex. +# - Unescaped regex: If you use a raw regex literal (i.e., surrounded by slashes /.../), the regex engine interprets it directly, and you don’t need to double-escape the special characters. +autolabeler: +- label: 'chore' + branch: + - '/^(chore)(\([a-z ]+\))?\/.+/' + title: + - '/^(chore)(\([a-z ]+\))?: .+/' +- label: 'enhancement' + branch: + - '/^(refactor)(\([a-z ]+\))?\/.+/' + title: + - '/^(refactor)(\([a-z ]+\))?: .+/' +- label: 'documentation' + branch: + - '/^(docs)(\([a-z ]+\))?\/.+/' + title: + - '/^(docs)(\([a-z ]+\))?: .+/' +- label: 'ci-cd' + branch: + - '/^(ci)(\([a-z ]+\))?\/.+/' + title: + - '/^(ci)(\([a-z ]+\))?: .+/' +- label: 'test' + branch: + - '/^(test)(\([a-z ]+\))?\/.+/' + title: + - '/^(test)(\([a-z ]+\))?: .+/' +- label: 'bug' + branch: + - '/^(fix)(\([a-z ]+\))?\/.+/' + title: + - '/^(fix)(\([a-z ]+\))?: .+/' +- label: 'style' + branch: + - '/^(style)(\([a-z ]+\))?\/.+/' + title: + - '/^(style)(\([a-z ]+\))?: .+/' +- label: 'feature' + branch: + - '/^(feat)(\([a-z ]+\))?\/.+/' + title: + - '/^(feat)(\([a-z ]+\))?: .+/' +- label: 'minor' + branch: + - '/^(feat)(\([a-z ]+\))?\/.+/' + title: + - '/^(feat)(\([a-z ]+\))?: .+/' +- label: 'patch' + branch: + - '/^(fix)(\([a-z ]+\))?\/.+/' + - '/^(ci)(\([a-z ]+\))?\/.+/' + title: + - '/^(fix)(\([a-z ]+\))?: .+/' + - '/^(ci)(\([a-z ]+\))?: .+/' + +change-template: '- $TITLE @$AUTHOR (#$NUMBER)' +change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks. +version-resolver: + major: + labels: + - breaking-changes + minor: + labels: + - minor + patch: + labels: + - patch + default: patch + +exclude-labels: +- skip-changelog diff --git a/.github/release.yml b/.github/release.yml new file mode 100644 index 0000000..04570c8 --- /dev/null +++ b/.github/release.yml @@ -0,0 +1,63 @@ +# https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes +# https://github.com/bcoe/conventional-release-labels +# https://dev.to/github/how-to-automatically-generate-release-notes-for-your-project-2ng8 +# https://www.conventionalcommits.org/en/v1.0.0/ + +# github release pre-defined template +changelog: + exclude: + labels: + - ignore-for-release + categories: + - title: 🚀 Features + labels: + - feature + - feat + - title: ♻️ Enhancement + labels: + - enhancement + - refactor + - title: 🐛 Bug Fixes + labels: + - fix + - bug + - title: 👷 CI + labels: + - ci + - ci-cd + - devops + - title: ⚠️ Breaking Changes + labels: + - breaking-changes + - major + - title: ⛔️ Deprecated + labels: + - deprecated + - title: 🗑 Removed + labels: + - removed + - title: 🔐 Security + labels: + - security + - title: 🎨 Style & Formatting + labels: + - style + - title: 🧪 Test + labels: + - test + - title: 📄 Documentation + labels: + - docs + - documentation + - title: 🧩 Dependency Updates + labels: + - deps + - build + - dependencies + - title: 🧰 Maintenance + label: 'chore' + - title: 🧺 Miscellaneous #Everything except ABAP + label: misc + - title: Other Changes + labels: + - "*" diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml new file mode 100644 index 0000000..cd496ff --- /dev/null +++ b/.github/workflows/build-test.yml @@ -0,0 +1,61 @@ +name: Build-Test + +on: + push: + branches: + - "main" + paths-ignore: + - "tree-sitter/**" + - "scripts/**" + pull_request: + branches: + - "main" + paths-ignore: + - "tree-sitter/**" + - "scripts/**" + +env: + DOTNET_VERSION: "8.0.*" + +jobs: + + build-test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + with: + # https://github.com/dotnet/Nerdbank.GitVersioning/blob/main/doc/cloudbuild.md#github-actions + fetch-depth: 0 # doing deep clone and avoid shallow clone so nbgv can do its work. + + - name: Setup .NET Core + uses: actions/setup-dotnet@v4 + with: + dotnet-version: ${{ env.DOTNET_VERSION }} + + - name: Cache NuGet packages + uses: actions/cache@v4 + with: + path: ~/.nuget/packages + key: nuget-cache-${{ runner.os }}-${{ env.DOTNET_VERSION }}-build-test + + # https://github.com/dotnet/Nerdbank.GitVersioning/blob/main/doc/nbgv-cli.md + - name: Install Nerdbank.GitVersioning + run: dotnet tool install -g nbgv + + - name: Get PackageVersion + id: get_version + run: | + nugetVersion=$(nbgv get-version | grep "NuGetPackageVersion" | awk -F': ' '{print $2}' | xargs) + echo "NuGetPackageVersion: $nugetVersion" + echo "::set-output name=nuget_version::$nugetVersion" + + - name: Restore dependencies + run: dotnet restore AIAssistant.sln + + - name: Build Version ${{ steps.get_version.outputs.nuget_version }} + run: dotnet build AIAssistant.sln -c Release --no-restore + + - name: Test Version ${{ steps.get_version.outputs.nuget_version }} + run: | + dotnet test AIAssistant.sln -c Release --no-restore --no-build diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml new file mode 100644 index 0000000..630a728 --- /dev/null +++ b/.github/workflows/labeler.yml @@ -0,0 +1,53 @@ +name: Auto Labeler + +on: + pull_request: + types: + - opened + - synchronize + - reopened + - labeled + - unlabeled + # pull_request_target: + +jobs: + auto-labeler: + name: Auto Labeler + runs-on: ubuntu-latest + permissions: + # write permission is required for autolabeler + # otherwise, read permission is required at least + pull-requests: write + contents: read + ## just for multi-labeler + # statuses: write + # checks: write + + steps: + - uses: release-drafter/release-drafter@v6 + with: + config-name: release-drafter.yml + disable-releaser: true # releaser mode is disabled. + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + # - uses: fuxingloh/multi-labeler@v1 + # name: conventional-commits-pull-request-labeler + # with: + # github-token: ${{secrets.GITHUB_TOKEN}} # optional, default to '${{ github.token }}' + # config-path: .github/multi-labeler.yml # optional, default to '.github/labeler.yml' + + # # https://github.com/actions/labeler + # - uses: actions/labeler@v5 + # with: + # repo-token: "${{ secrets.GITHUB_TOKEN }}" + # sync-labels: true + + # https://docs.github.com/en/actions/using-workflows/about-workflows#creating-dependent-jobs + # https://docs.github.com/en/actions/using-jobs/using-jobs-in-a-workflow + - name: check-conventional-commits-labels + uses: docker://agilepathway/pull-request-label-checker:latest + if: success() + with: + any_of: feature,bug,enhancement,refactor,deprecated,security,documentation,build,ci/cd,devops,chore,performance,formatting,dependencies,test,major,minor,patch + repo_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..d30576a --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,182 @@ +name: Publish-Nuget + +on: + push: + tags: + - 'v*' # Matches tag names like v1.0.0 for releases + branches: + - "main" + paths-ignore: + - "tests/**" + +env: + GHC_SOURCE: ${{ vars.GHC_SOURCE }} + FEED_SOURCE: https://api.nuget.org/v3/index.json + FEED_API_KEY: ${{ secrets.FEED_API_KEY }} + NuGetDirectory: nuget + AIAssistBuildOutput: src/AIAssist/bin/Release/net8.0 + DownloadOutput: download + DOTNET_VERSION: "8.0.*" + +jobs: + + build-tree-sitter: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ ubuntu-latest, windows-latest ] + + steps: + - uses: actions/checkout@v4 + with: + submodules: true + # https://github.com/dotnet/Nerdbank.GitVersioning/blob/main/doc/cloudbuild.md#github-actions + fetch-depth: 0 # doing deep clone and avoid shallow clone so nbgv can do its work. + + - name: Set up GCC (Linux only) + if: runner.os == 'Linux' + run: sudo apt-get update && sudo apt-get install -y gcc + + - name: Set up GCC (Windows only) + if: runner.os == 'Windows' + uses: msys2/setup-msys2@v2 + with: + msystem: MINGW64 + install: gcc + + - name: Build Tree-Sitter binaries on ${{ matrix.os }} + run: | + if [[ "$(uname)" == "Linux" ]]; then + chmod +x ./scripts/ci_install_tree_sitter.sh + fi + ./scripts/ci_install_tree_sitter.sh + shell: bash + + - name: Upload all Linux binaries + if: matrix.os == 'ubuntu-latest' + uses: actions/upload-artifact@v4 + with: + retention-days: 1 + name: tree-sitter-ubuntu-binaries + path: | + tree-sitter/bins/*.so + tree-sitter/grammars/bins/*.so + + - name: Upload all Windows binaries + if: matrix.os == 'windows-latest' + uses: actions/upload-artifact@v4 + with: + name: tree-sitter-windows-binaries + retention-days: 1 + path: | + tree-sitter/bins/*.dll + tree-sitter/grammars/bins/*.dll + + create-nuget: + runs-on: ubuntu-latest + + needs: [ build-tree-sitter ] + + steps: + - uses: actions/checkout@v4 + with: + # https://github.com/dotnet/Nerdbank.GitVersioning/blob/main/doc/cloudbuild.md#github-actions + fetch-depth: 0 # avoid shallow clone so nbgv can do its work. + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: ${{ env.DOTNET_VERSION }} + + - name: Cache NuGet packages + uses: actions/cache@v4 + with: + path: ~/.nuget/packages + key: nuget-cache-${{ runner.os }}-${{ env.DOTNET_VERSION }}-publish + + - name: Download Linux binaries + uses: actions/download-artifact@v4 + with: + name: tree-sitter-ubuntu-binaries + path: ${{ env.DownloadOutput }} + + - name: Download Windows binaries + uses: actions/download-artifact@v4 + with: + name: tree-sitter-windows-binaries + path: ${{ env.DownloadOutput }} + + # https://github.com/dotnet/Nerdbank.GitVersioning/blob/main/doc/nbgv-cli.md + - name: Install Nerdbank.GitVersioning + run: dotnet tool install -g nbgv + + - name: Get NuGetPackageVersion + id: get_version + run: | + nugetVersion=$(nbgv get-version | grep "NuGetPackageVersion" | awk -F': ' '{print $2}' | xargs) + echo "NuGetPackageVersion: $nugetVersion" + echo "::set-output name=nuget_version::$nugetVersion" + + - name: Restore dependencies + run: dotnet restore AIAssistant.sln + + - name: Build Version ${{ steps.get_version.outputs.nuget_version }} + run: dotnet build AIAssistant.sln -c Release --no-restore + + - name: Flatten tree-sitter binaries to AIAssistBuildOutput + run: | + mv ${{ env.DownloadOutput }}/bins/* ${{ env.AIAssistBuildOutput }} + mv ${{ env.DownloadOutput }}/grammars/bins/* ${{ env.AIAssistBuildOutput }} + rm -rf ${{ env.DownloadOutput }} + + # https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-pack + - name: Pack NuGet Package Version ${{ steps.get_version.outputs.nuget_version }} + run: dotnet pack src/AIAssist/AIAssist.csproj -o ${{ env.NuGetDirectory }} -c Release --no-restore --no-build + # Publish the NuGet package as an artifact, so they can be used in the following jobs + - uses: actions/upload-artifact@v4 + with: + name: nuget + if-no-files-found: error + retention-days: 1 + path: ${{ env.NuGetDirectory }}/*.nupkg + + deploy-nuget: + runs-on: ubuntu-latest + + # https://docs.github.com/en/repositories/releasing-projects-on-github/managing-releases-in-a-repository + needs: [ create-nuget ] + steps: + - uses: actions/checkout@v4 + with: + # https://github.com/dotnet/Nerdbank.GitVersioning/blob/main/doc/cloudbuild.md#github-actions + fetch-depth: 0 # doing deep clone and avoid shallow clone so nbgv can do its work. + # Download the NuGet package created in the previous job and copy in the root + - uses: actions/download-artifact@v4 + with: + name: nuget + ## Optional. Default is $GITHUB_WORKSPACE + path: ${{ github.workspace}} + + # Install the .NET SDK indicated in the global.json file + - name: Setup .NET Core + uses: actions/setup-dotnet@v4 + with: + dotnet-version: ${{ env.DOTNET_VERSION }} + + # https://github.com/dotnet/Nerdbank.GitVersioning/blob/main/doc/nbgv-cli.md + - name: Install Nerdbank.GitVersioning + run: dotnet tool install -g nbgv + + - name: Get PackageVersion + id: get_version + run: | + nugetVersion=$(nbgv get-version | grep "NuGetPackageVersion" | awk -F': ' '{print $2}' | xargs) + echo "NuGetPackageVersion: $nugetVersion" + echo "::set-output name=nuget_version::$nugetVersion" + + # Publish all NuGet packages to NuGet.org + # Use --skip-duplicate to prevent errors if a package with the same version already exists. + # If you retry a failed workflow, already published packages will be skipped without error. + # https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-nuget-push + - name: Publish NuGet Package Version ${{ steps.get_version.outputs.nuget_version }} to Nuget + run: dotnet nuget push *.nupkg --skip-duplicate --source ${{ env.FEED_SOURCE }} --api-key ${{ env.FEED_API_KEY }} + if: github.event_name == 'push' && startswith(github.ref, 'refs/tags') diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml new file mode 100644 index 0000000..b5bce64 --- /dev/null +++ b/.github/workflows/release-drafter.yml @@ -0,0 +1,32 @@ +# https://johanneskonings.dev/github/2021/02/28/github_automatic_releases_and-changelog/ +# https://tiagomichaelsousa.dev/articles/stop-writing-your-changelogs-manually +name: Release Drafter + +on: + push: + branches: + - "main" + +jobs: + update-release-draft: + name: Release drafter + runs-on: ubuntu-latest + + permissions: + # write permission is required to create a github release + contents: write + steps: + - name: Update Release Draft + uses: release-drafter/release-drafter@v6 + id: semantic + with: + config-name: release-drafter.yml + disable-autolabeler: true + ## Default versioning just increase the path version as default. but the can use minor, patch and breaking-changes labels to apply semver + # version: 1.29.1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + # - name: Do something when a new release published + # run: | + # echo ${{ $RESOLVED_VERSION steps.semantic.outputs }} diff --git a/.gitignore b/.gitignore index b35091e..c531f63 100644 --- a/.gitignore +++ b/.gitignore @@ -389,4 +389,5 @@ env .git/ -temp/ \ No newline at end of file +temp/ +nuget/ \ No newline at end of file diff --git a/AIAssistant.sln b/AIAssistant.sln index 61493ab..25f73fc 100644 --- a/AIAssistant.sln +++ b/AIAssistant.sln @@ -22,8 +22,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "solution items", "solution .gitignore = .gitignore docker-compose.yml = docker-compose.yml global.json = global.json - readme.md = readme.md + README.md = README.md .editorconfig = .editorconfig + version.json = version.json EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "BuildingBlocks", "BuildingBlocks", "{5A9D49CF-CECC-48B4-BE93-CB907CA4455A}" @@ -34,6 +35,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "scripts", "scripts", "{0A4F ProjectSection(SolutionItems) = preProject scripts\install_tree_sitter.sh = scripts\install_tree_sitter.sh scripts\generate_tree_sitter_bindings.sh = scripts\generate_tree_sitter_bindings.sh + scripts\ci_install_tree_sitter.sh = scripts\ci_install_tree_sitter.sh EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "TreeSitter.Bindings", "TreeSitter.Bindings", "{E295F56D-BF6F-4725-96E5-617DED7E0E21}" @@ -59,25 +61,26 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{7BC2BC67 tests\Packages.props = tests\Packages.props EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "AIAssistant", "AIAssistant", "{DED0DC02-AB86-4BFC-843B-8B7AFB372906}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AIAssistant", "src\AIAssistant\AIAssistant.csproj", "{81EA39C7-67E1-46E4-A6DF-60361B79ED63}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "UnitTests", "UnitTests", "{CF49F264-D5C4-4A9F-BF9C-8706559CFC53}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AIAssistant.UnitTests", "tests\UnitTests\AIAssistant.UnitTests\AIAssistant.UnitTests.csproj", "{C4416370-05BD-44AC-A3B7-1E620903DA0E}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BuildingBlocks.UnitTests", "tests\UnitTests\BuildingBlocks.UnitTests\BuildingBlocks.UnitTests.csproj", "{21AAB851-F969-49E0-8DBD-00916855CB84}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Clients.UnitTests", "tests\UnitTests\Clients.UnitTests\Clients.UnitTests.csproj", "{02887CE1-CD8B-46C1-9530-298023100202}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "IntegrationTests", "IntegrationTests", "{D7123F7A-8B09-4A1B-AD28-67C7915F88A3}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TreeSitter.Bindings.UnitTests", "tests\UnitTests\TreeSitter.Bindings.UnitTests\TreeSitter.Bindings.UnitTests.csproj", "{E12F766D-5C4D-4B0B-B020-396393A105DC}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github", ".github", "{6456834B-EA6C-48EA-9434-A4185D70F65F}" + ProjectSection(SolutionItems) = preProject + .github\release-drafter.yml = .github\release-drafter.yml + EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "IntegrationTests", "IntegrationTests", "{D7123F7A-8B09-4A1B-AD28-67C7915F88A3}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{FA8BD80F-036B-4D0C-BE2D-62EA5FAF9C8C}" + ProjectSection(SolutionItems) = preProject + .github\workflows\build-test.yml = .github\workflows\build-test.yml + .github\workflows\labeler.yml = .github\workflows\labeler.yml + .github\workflows\publish.yml = .github\workflows\publish.yml + .github\workflows\release-drafter.yml = .github\workflows\release-drafter.yml + EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AIAssistant.IntegrationTests", "tests\IntegrationTests\AIAssistant.IntegrationTests\AIAssistant.IntegrationTests.csproj", "{FEB2F364-6E48-4BA8-9AAD-E1442DE6CD33}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "AIAssist", "AIAssist", "{4FAC7598-86FC-495F-B310-C641F424A904}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Clients.IntegrationTests", "tests\IntegrationTests\Clients.IntegrationTests\Clients.IntegrationTests.csproj", "{06AC02DF-07BD-4D51-8818-5EE2B06D4D8C}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AIAssist", "src\AIAssist\AIAssist.csproj", "{A4801AE4-5836-47CF-8AA4-DF99918BE2CC}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -96,16 +99,12 @@ Global {E295F56D-BF6F-4725-96E5-617DED7E0E21} = {97D741A1-DEFC-4241-99BC-7123A2D981E4} {98525E13-4C8A-483D-A7AE-7323E9BA5CEA} = {E295F56D-BF6F-4725-96E5-617DED7E0E21} {BB0678E4-DD42-4A8C-9F31-26EC955967D3} = {01301B5F-71C0-476B-BC8F-C25F1B6E2A46} - {DED0DC02-AB86-4BFC-843B-8B7AFB372906} = {97D741A1-DEFC-4241-99BC-7123A2D981E4} - {81EA39C7-67E1-46E4-A6DF-60361B79ED63} = {DED0DC02-AB86-4BFC-843B-8B7AFB372906} {CF49F264-D5C4-4A9F-BF9C-8706559CFC53} = {7BC2BC67-2994-4A8A-94CC-974C7CFB7D32} - {C4416370-05BD-44AC-A3B7-1E620903DA0E} = {CF49F264-D5C4-4A9F-BF9C-8706559CFC53} - {21AAB851-F969-49E0-8DBD-00916855CB84} = {CF49F264-D5C4-4A9F-BF9C-8706559CFC53} - {02887CE1-CD8B-46C1-9530-298023100202} = {CF49F264-D5C4-4A9F-BF9C-8706559CFC53} - {E12F766D-5C4D-4B0B-B020-396393A105DC} = {CF49F264-D5C4-4A9F-BF9C-8706559CFC53} {D7123F7A-8B09-4A1B-AD28-67C7915F88A3} = {7BC2BC67-2994-4A8A-94CC-974C7CFB7D32} - {FEB2F364-6E48-4BA8-9AAD-E1442DE6CD33} = {D7123F7A-8B09-4A1B-AD28-67C7915F88A3} - {06AC02DF-07BD-4D51-8818-5EE2B06D4D8C} = {D7123F7A-8B09-4A1B-AD28-67C7915F88A3} + {6456834B-EA6C-48EA-9434-A4185D70F65F} = {01301B5F-71C0-476B-BC8F-C25F1B6E2A46} + {FA8BD80F-036B-4D0C-BE2D-62EA5FAF9C8C} = {6456834B-EA6C-48EA-9434-A4185D70F65F} + {4FAC7598-86FC-495F-B310-C641F424A904} = {97D741A1-DEFC-4241-99BC-7123A2D981E4} + {A4801AE4-5836-47CF-8AA4-DF99918BE2CC} = {4FAC7598-86FC-495F-B310-C641F424A904} EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {4973B5D3-67CE-47CC-A0C7-55EC268A2268}.Debug|Any CPU.ActiveCfg = Debug|Any CPU @@ -120,33 +119,9 @@ Global {98525E13-4C8A-483D-A7AE-7323E9BA5CEA}.Debug|Any CPU.Build.0 = Debug|Any CPU {98525E13-4C8A-483D-A7AE-7323E9BA5CEA}.Release|Any CPU.ActiveCfg = Release|Any CPU {98525E13-4C8A-483D-A7AE-7323E9BA5CEA}.Release|Any CPU.Build.0 = Release|Any CPU - {81EA39C7-67E1-46E4-A6DF-60361B79ED63}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {81EA39C7-67E1-46E4-A6DF-60361B79ED63}.Debug|Any CPU.Build.0 = Debug|Any CPU - {81EA39C7-67E1-46E4-A6DF-60361B79ED63}.Release|Any CPU.ActiveCfg = Release|Any CPU - {81EA39C7-67E1-46E4-A6DF-60361B79ED63}.Release|Any CPU.Build.0 = Release|Any CPU - {C4416370-05BD-44AC-A3B7-1E620903DA0E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C4416370-05BD-44AC-A3B7-1E620903DA0E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C4416370-05BD-44AC-A3B7-1E620903DA0E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C4416370-05BD-44AC-A3B7-1E620903DA0E}.Release|Any CPU.Build.0 = Release|Any CPU - {21AAB851-F969-49E0-8DBD-00916855CB84}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {21AAB851-F969-49E0-8DBD-00916855CB84}.Debug|Any CPU.Build.0 = Debug|Any CPU - {21AAB851-F969-49E0-8DBD-00916855CB84}.Release|Any CPU.ActiveCfg = Release|Any CPU - {21AAB851-F969-49E0-8DBD-00916855CB84}.Release|Any CPU.Build.0 = Release|Any CPU - {02887CE1-CD8B-46C1-9530-298023100202}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {02887CE1-CD8B-46C1-9530-298023100202}.Debug|Any CPU.Build.0 = Debug|Any CPU - {02887CE1-CD8B-46C1-9530-298023100202}.Release|Any CPU.ActiveCfg = Release|Any CPU - {02887CE1-CD8B-46C1-9530-298023100202}.Release|Any CPU.Build.0 = Release|Any CPU - {E12F766D-5C4D-4B0B-B020-396393A105DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E12F766D-5C4D-4B0B-B020-396393A105DC}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E12F766D-5C4D-4B0B-B020-396393A105DC}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E12F766D-5C4D-4B0B-B020-396393A105DC}.Release|Any CPU.Build.0 = Release|Any CPU - {FEB2F364-6E48-4BA8-9AAD-E1442DE6CD33}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {FEB2F364-6E48-4BA8-9AAD-E1442DE6CD33}.Debug|Any CPU.Build.0 = Debug|Any CPU - {FEB2F364-6E48-4BA8-9AAD-E1442DE6CD33}.Release|Any CPU.ActiveCfg = Release|Any CPU - {FEB2F364-6E48-4BA8-9AAD-E1442DE6CD33}.Release|Any CPU.Build.0 = Release|Any CPU - {06AC02DF-07BD-4D51-8818-5EE2B06D4D8C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {06AC02DF-07BD-4D51-8818-5EE2B06D4D8C}.Debug|Any CPU.Build.0 = Debug|Any CPU - {06AC02DF-07BD-4D51-8818-5EE2B06D4D8C}.Release|Any CPU.ActiveCfg = Release|Any CPU - {06AC02DF-07BD-4D51-8818-5EE2B06D4D8C}.Release|Any CPU.Build.0 = Release|Any CPU + {A4801AE4-5836-47CF-8AA4-DF99918BE2CC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A4801AE4-5836-47CF-8AA4-DF99918BE2CC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A4801AE4-5836-47CF-8AA4-DF99918BE2CC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A4801AE4-5836-47CF-8AA4-DF99918BE2CC}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection EndGlobal diff --git a/readme.md b/README.md similarity index 96% rename from readme.md rename to README.md index 991a330..82ed1da 100644 --- a/readme.md +++ b/README.md @@ -2,12 +2,13 @@ > `Context Aware` AI assistant for coding, chat, code explanation, review with supporting local and online language models. -`AIAssist` is compatible with [OpenAI](https://platform.openai.com/docs/api-reference/introduction) and [Azure AI Services](https://azure.microsoft.com/en-us/products/ai-services) through apis or [Ollama models](https://ollama.com/search) through [ollama engine](https://ollama.com/) locally. +`AIAssist` is compatible with [OpenAI](https://platform.openai.com/docs/api-reference/introduction) and [Azure AI Services](https://azure.microsoft.com/en-us/products/ai-services) through apis and [Ollama models](https://ollama.com/search) through [ollama engine](https://ollama.com/) locally. > [!TIP] > You can use ollama and its models that are more compatible with code like [deepseek-v2.5](https://ollama.com/library/deepseek-v2.5) or [qwen2.5-coder](https://ollama.com/library/qwen2.5-coder) locally. To use local models, you will need to run [Ollama](https://github.com/ollama/ollama) process first. For running ollama you can use [ollama docker](https://ollama.com/blog/ollama-is-now-available-as-an-official-docker-image) container. -Note: `vscode` and `jetbrains` plugins are in the plan and I will add them soon. +> [!NOTE] +> Development of `vscode` and `jetbrains` plugins are in the plan and I will add them soon. ## Features diff --git a/scripts/ci_install_tree_sitter.sh b/scripts/ci_install_tree_sitter.sh new file mode 100644 index 0000000..b8f4e51 --- /dev/null +++ b/scripts/ci_install_tree_sitter.sh @@ -0,0 +1,162 @@ +#!/bin/bash + +# Create tree-sitter folder structure +mkdir -p tree-sitter/grammars/bins +mkdir -p tree-sitter/bins + +# Get the OS type +OS=$(uname -s) + +# Define paths for the source files and output binary +lib_src="tree-sitter/tree-sitter/lib/src/lib.c" +treesitter_bin_output="tree-sitter/bins" + +# Check for Linux +if [[ "$OS" == "Linux" ]]; then + echo "Detected Linux OS. Compiling for Linux..." + + # Array of output files + linux_tree_sitter_output_files=("${treesitter_bin_output}/tree-sitter.so") + + # Iterate over the arrays + for i in "${!linux_tree_sitter_output_files[@]}"; do + echo "Compiling ${linux_tree_sitter_output_files[$i]}..." + gcc -o "${linux_tree_sitter_output_files[$i]}" -shared "$lib_src" -I./tree-sitter/tree-sitter/lib/src -I./tree-sitter/tree-sitter/lib/include -fPIC + if [ $? -eq 0 ]; then + echo "Successfully compiled tree-sitter.so" + else + echo "Error during compilation of tree-sitter.so" + exit 1 + fi + done +# Check for Windows (MINGW or MSYS environments) +elif [[ "$OS" == "MINGW"* || "$OS" == "MSYS"* ]]; then + echo "Detected Windows OS. Compiling for Windows..." + + # Array of output files + windows_tree_sitter_output_files=("${treesitter_bin_output}/tree-sitter.dll") + + # Iterate over the arrays + for i in "${!windows_tree_sitter_output_files[@]}"; do + echo "Compiling ${windows_tree_sitter_output_files[$i]}..." + gcc -o "${windows_tree_sitter_output_files[$i]}" -shared "$lib_src" -I./tree-sitter/tree-sitter/lib/src -I./tree-sitter/tree-sitter/lib/include + if [ $? -eq 0 ]; then + echo "Successfully compiled tree-sitter.dll" + else + echo "Error during compilation of tree-sitter.dll" + exit 1 + fi + done +# Unsupported OS +else + echo "Unsupported operating system: $OS" + exit 1 +fi + +# File containing the list of URLs +grammar_file="tree-sitter/tree-sitter-grammar.txt" + +# Check if the grammar file exists +if [ ! -f "$grammar_file" ]; then + echo "Error: File $grammar_file not found!" + exit 1 +fi + +# Read the list of URLs from the file into an array, skipping empty lines and stopping at the first empty line +repos=() +while IFS= read -r line; do + # Trim leading/trailing whitespace and check if the line is empty + trimmed_line=$(echo "$line" | xargs) + + if [ -z "$trimmed_line" ]; then + # Stop parsing when an empty line is encountered + break + fi + + # Add the non-empty line to the repos array + repos+=("$trimmed_line") +done < "$grammar_file" + + +# Iterate over each URL in the list and perform operations +for repo in "${repos[@]}"; do + echo "Processing repository: $repo" + + # Get the repository name from the URL by extracting everything after the last / + repo_name=$(basename "$repo") + + # Trim any trailing or leading whitespace (including newlines) from repo_name + repo_name=$(echo "$repo_name" | tr -d '[:space:]') + + echo "Repository name (trimmed): $repo_name" + + # Define paths for the source files and output binary + scanner_src="tree-sitter/grammars/$repo_name/src/scanner.c" + parser_src="tree-sitter/grammars/$repo_name/src/parser.c" + grammar_bin_output="tree-sitter/grammars/bins" + + # Debugging: print paths to ensure correctness + echo "Scanner source path: $scanner_src" + echo "Parser source path: $parser_src" + + # Check if source files exist + if [[ ! -f "$scanner_src" && ! -f "$parser_src" ]]; then + echo "Error: both scanner.c and parser.c files not found for $repo_name!" + continue + fi + + # Check if parser.c exists (it should always exist) + if [ ! -f "$parser_src" ]; then + echo "Error: parser.c not found for $repo_name!" + continue + fi + + # Prepare the GCC command based on available files + if [ -f "$scanner_src" ]; then + inputs="$scanner_src $parser_src" + else + inputs="$parser_src" + fi + + # Run the appropriate gcc command based on the OS + if [[ "$OS" == "Linux" ]]; then + echo "Detected Linux OS. Compiling for Linux..." + + # Array of output files + linux_grammar_output_files=("${grammar_bin_output}/${repo_name}.so") + + # Iterate over the arrays + for i in "${!linux_grammar_output_files[@]}"; do + echo "Compiling ${linux_grammar_output_files[$i]}..." + gcc -o "${linux_grammar_output_files[$i]}" -shared $inputs -fPIC + if [ $? -eq 0 ]; then + echo "Successfully compiled ${repo_name}.so" + else + echo "Error during compilation of ${repo_name}.so" + exit 1 + fi + done + elif [[ "$OS" == "MINGW"* || "$OS" == "MSYS"* ]]; then + echo "Detected Windows OS. Compiling for Windows..." + + # Array of output files + windows_grammar_output_files=("${grammar_bin_output}/${repo_name}.dll") + + # Iterate over the arrays + for i in "${!windows_grammar_output_files[@]}"; do + echo "Compiling ${windows_grammar_output_files[$i]}..." + gcc -o "${windows_grammar_output_files[$i]}" -shared $inputs + if [ $? -eq 0 ]; then + echo "Successfully compiled ${repo_name}.dll" + else + echo "Error during compilation of ${repo_name}.dll" + exit 1 + fi + done + else + echo "Unsupported operating system: $OS" + exit 1 + fi + + echo "Compilation complete for: $repo_name" +done diff --git a/scripts/install_tree_sitter.sh b/scripts/install_tree_sitter.sh index 9ab7f91..483793e 100644 --- a/scripts/install_tree_sitter.sh +++ b/scripts/install_tree_sitter.sh @@ -26,16 +26,17 @@ lib_src="tree-sitter/tree-sitter/lib/src/lib.c" treesitter_bin_output="tree-sitter/bins" test_bin_path="tests/UnitTests/TreeSitter.Bindings.UnitTests/bin/${mode}/$dotnet_version" ai_assist_integration_test_bin_path="tests/IntegrationTests/AIAssistant.IntegrationTests/bin/${mode}/$dotnet_version" -app_bin_path="src/App/bin/${mode}/$dotnet_version" - +app_bin_path="src/AIAssist/bin/${mode}/$dotnet_version" + # Create the directory if it doesn't exist mkdir -p "${test_bin_path}" +mkdir -p "${ai_assist_integration_test_bin_path}" mkdir -p "${app_bin_path}" - + # Check for Linux if [[ "$OS" == "Linux" ]]; then echo "Detected Linux OS. Compiling for Linux..." - + # Array of output files linux_tree_sitter_output_files=("${treesitter_bin_output}/tree-sitter.so" "${app_bin_path}/tree-sitter.so" "${test_bin_path}/tree-sitter.so" "${ai_assist_integration_test_bin_path}/tree-sitter.so") @@ -53,7 +54,7 @@ if [[ "$OS" == "Linux" ]]; then # Check for Windows (MINGW or MSYS environments) elif [[ "$OS" == "MINGW"* || "$OS" == "MSYS"* ]]; then echo "Detected Windows OS. Compiling for Windows..." - + # Array of output files windows_tree_sitter_output_files=("${treesitter_bin_output}/tree-sitter.dll" "${app_bin_path}/tree-sitter.dll" "${test_bin_path}/tree-sitter.dll" "${ai_assist_integration_test_bin_path}/tree-sitter.dll") @@ -88,12 +89,12 @@ repos=() while IFS= read -r line; do # Trim leading/trailing whitespace and check if the line is empty trimmed_line=$(echo "$line" | xargs) - + if [ -z "$trimmed_line" ]; then # Stop parsing when an empty line is encountered break fi - + # Add the non-empty line to the repos array repos+=("$trimmed_line") done < "$grammar_file" @@ -105,7 +106,7 @@ for repo in "${repos[@]}"; do # Get the repository name from the URL by extracting everything after the last / repo_name=$(basename "$repo") - + # Trim any trailing or leading whitespace (including newlines) from repo_name repo_name=$(echo "$repo_name" | tr -d '[:space:]') @@ -180,4 +181,4 @@ for repo in "${repos[@]}"; do fi echo "Compilation complete for: $repo_name" -done \ No newline at end of file +done diff --git a/src/AIAssistant/.aiassistignore b/src/AIAssist/.aiassistignore similarity index 100% rename from src/AIAssistant/.aiassistignore rename to src/AIAssist/.aiassistignore diff --git a/src/AIAssistant/AIAssistant.csproj b/src/AIAssist/AIAssist.csproj similarity index 57% rename from src/AIAssistant/AIAssistant.csproj rename to src/AIAssist/AIAssist.csproj index f8d7948..549c197 100644 --- a/src/AIAssistant/AIAssistant.csproj +++ b/src/AIAssist/AIAssist.csproj @@ -1,16 +1,14 @@  - - - + + + + - - - aiassist - AIAssist - 1.0.0 + true + aiassist Exe - AIAssistant + AIAssist @@ -47,8 +45,29 @@ + + + + + + + - + + + + + + + true + tools\$(TargetFramework)\any + + + true + tools\$(TargetFramework)\any + + + diff --git a/src/AIAssist/AIAssist.nuspec b/src/AIAssist/AIAssist.nuspec new file mode 100644 index 0000000..6089a18 --- /dev/null +++ b/src/AIAssist/AIAssist.nuspec @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + AIAssist + AIAssist + $version$ + Mehdi Hadeli + Mehdi Hadeli + Apache-2.0 + https://github.com/mehdihadeli/AIAssist + ai gpt ollama azure-ai + + Context aware AI coding assistant inside terminal to help in code development, code explanation, + code refactor and review, bug fix and chat with supporting local and online language models. + + + Context aware AI coding assistant inside terminal to help in code development, code explanation, code + refactor and review, bug fix and chat with supporting local and online language models. + + Copyright © Mehdi Hadeli + + + + + + + + + + + + + + + diff --git a/src/AIAssistant/AIAssistantConstants.cs b/src/AIAssist/AIAssistConstants.cs similarity index 95% rename from src/AIAssistant/AIAssistantConstants.cs rename to src/AIAssist/AIAssistConstants.cs index e5b7a5d..33aec62 100644 --- a/src/AIAssistant/AIAssistantConstants.cs +++ b/src/AIAssist/AIAssistConstants.cs @@ -1,6 +1,6 @@ -namespace AIAssistant; +namespace AIAssist; -public class AIAssistantConstants +public class AIAssistConstants { public const string PromptsTemplatesNamespace = "Prompts.Templates"; diff --git a/src/AIAssistant/Chat/Models/ChatCost.cs b/src/AIAssist/Chat/Models/ChatCost.cs similarity index 96% rename from src/AIAssistant/Chat/Models/ChatCost.cs rename to src/AIAssist/Chat/Models/ChatCost.cs index 0dbf68b..d612431 100644 --- a/src/AIAssistant/Chat/Models/ChatCost.cs +++ b/src/AIAssist/Chat/Models/ChatCost.cs @@ -1,6 +1,6 @@ using BuildingBlocks.Utils; -namespace AIAssistant.Chat.Models; +namespace AIAssist.Chat.Models; public record ChatCost(int InputTokenCount, decimal InputCostPerToken, int OutputTokenCount, decimal OutputCostPerToken) { diff --git a/src/AIAssistant/Chat/Models/ChatHistory.cs b/src/AIAssist/Chat/Models/ChatHistory.cs similarity index 97% rename from src/AIAssistant/Chat/Models/ChatHistory.cs rename to src/AIAssist/Chat/Models/ChatHistory.cs index 52f659c..ba3fde0 100644 --- a/src/AIAssistant/Chat/Models/ChatHistory.cs +++ b/src/AIAssist/Chat/Models/ChatHistory.cs @@ -2,7 +2,7 @@ using Clients.Models; using Humanizer; -namespace AIAssistant.Chat.Models; +namespace AIAssist.Chat.Models; public class ChatHistory(ChatSession chatSession) { diff --git a/src/AIAssistant/Chat/Models/ChatHistoryItem.cs b/src/AIAssist/Chat/Models/ChatHistoryItem.cs similarity index 93% rename from src/AIAssistant/Chat/Models/ChatHistoryItem.cs rename to src/AIAssist/Chat/Models/ChatHistoryItem.cs index d537294..a7b65e5 100644 --- a/src/AIAssistant/Chat/Models/ChatHistoryItem.cs +++ b/src/AIAssist/Chat/Models/ChatHistoryItem.cs @@ -1,6 +1,6 @@ using Clients.Models; -namespace AIAssistant.Chat.Models; +namespace AIAssist.Chat.Models; public record ChatHistoryItem(string Prompt, RoleType Role, ChatCost? ChatCost) { diff --git a/src/AIAssistant/Chat/Models/ChatItem.cs b/src/AIAssist/Chat/Models/ChatItem.cs similarity index 85% rename from src/AIAssistant/Chat/Models/ChatItem.cs rename to src/AIAssist/Chat/Models/ChatItem.cs index b4c7bb1..32dc900 100644 --- a/src/AIAssistant/Chat/Models/ChatItem.cs +++ b/src/AIAssist/Chat/Models/ChatItem.cs @@ -1,6 +1,6 @@ using Clients.Models; -namespace AIAssistant.Chat.Models; +namespace AIAssist.Chat.Models; public record ChatItem(RoleType Role, string Prompt) { diff --git a/src/AIAssistant/Chat/Models/ChatSession.cs b/src/AIAssist/Chat/Models/ChatSession.cs similarity index 98% rename from src/AIAssistant/Chat/Models/ChatSession.cs rename to src/AIAssist/Chat/Models/ChatSession.cs index 88258ec..f7c6be0 100644 --- a/src/AIAssistant/Chat/Models/ChatSession.cs +++ b/src/AIAssist/Chat/Models/ChatSession.cs @@ -1,6 +1,6 @@ using Clients.Models; -namespace AIAssistant.Chat.Models; +namespace AIAssist.Chat.Models; /// /// Managing a single chat session and its history diff --git a/src/AIAssistant/Commands/AIAssistCommand.cs b/src/AIAssist/Commands/AIAssistCommand.cs similarity index 96% rename from src/AIAssistant/Commands/AIAssistCommand.cs rename to src/AIAssist/Commands/AIAssistCommand.cs index 4989144..8e3a481 100644 --- a/src/AIAssistant/Commands/AIAssistCommand.cs +++ b/src/AIAssist/Commands/AIAssistCommand.cs @@ -2,7 +2,7 @@ using Spectre.Console; using Spectre.Console.Cli; -namespace AIAssistant.Commands; +namespace AIAssist.Commands; // commands should be state-less after each run public class AIAssistCommand : Command diff --git a/src/AIAssistant/Commands/ChatAssistCommand.cs b/src/AIAssist/Commands/ChatAssistCommand.cs similarity index 95% rename from src/AIAssistant/Commands/ChatAssistCommand.cs rename to src/AIAssist/Commands/ChatAssistCommand.cs index 38ecf5d..8d0b319 100644 --- a/src/AIAssistant/Commands/ChatAssistCommand.cs +++ b/src/AIAssist/Commands/ChatAssistCommand.cs @@ -2,7 +2,7 @@ using Spectre.Console; using Spectre.Console.Cli; -namespace AIAssistant.Commands; +namespace AIAssist.Commands; [Description("Provide a chat assistant with ai for asking any questions.")] public sealed class ChatAssistCommand : Command diff --git a/src/AIAssistant/Commands/CodeAssistCommand.cs b/src/AIAssist/Commands/CodeAssistCommand.cs similarity index 73% rename from src/AIAssistant/Commands/CodeAssistCommand.cs rename to src/AIAssist/Commands/CodeAssistCommand.cs index fce8ffb..7d2c683 100644 --- a/src/AIAssistant/Commands/CodeAssistCommand.cs +++ b/src/AIAssist/Commands/CodeAssistCommand.cs @@ -1,18 +1,17 @@ using System.ComponentModel; -using AIAssistant.Contracts; -using AIAssistant.Contracts.CodeAssist; -using AIAssistant.Models.Options; +using AIAssist.Contracts; +using AIAssist.Contracts.CodeAssist; +using AIAssist.Models.Options; using BuildingBlocks.SpectreConsole.Contracts; using Clients.Contracts; using Clients.Models; using Clients.Options; -using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; using Spectre.Console; using Spectre.Console.Cli; -namespace AIAssistant.Commands; +namespace AIAssist.Commands; [Description("Provide code assistance or enhance existing code or add some new features to our application context.")] public class CodeAssistCommand( @@ -29,6 +28,11 @@ IOptions appOptions { private readonly LLMOptions _llmOptions = llmOptions.Value; private readonly AppOptions _appOptions = appOptions.Value; + private readonly Model _chatModel = + cacheModels.GetModel(llmOptions.Value.ChatModel) + ?? throw new KeyNotFoundException($"Model '{llmOptions.Value.ChatModel}' not found in the ModelCache."); + private readonly Model? _embeddingModel = cacheModels.GetModel(llmOptions.Value.EmbeddingsModel); + private static bool _running = true; public sealed class Settings : CommandSettings @@ -115,12 +119,21 @@ public override async Task ExecuteAsync(CommandContext context, Settings se using var scope = serviceScopeFactory.CreateScope(); var codeAssistantManager = scope.ServiceProvider.GetRequiredService(); + SetupOptions(settings); + spectreUtilities.InformationText("Code assist mode is activated!"); + spectreUtilities.InformationText($"Chat model: {_chatModel.Name}"); + + if (_embeddingModel is not null) + { + spectreUtilities.InformationText($"Embedding model: {_embeddingModel.Name}"); + } + + spectreUtilities.InformationText($"CodeAssistType: {_chatModel.ModelOption.CodeAssistType}"); + spectreUtilities.InformationText($"CodeDiffType: {_chatModel.ModelOption.CodeDiffType}"); spectreUtilities.InformationText("Please 'Ctrl+H' to see all available commands in the code assist mode."); spectreUtilities.WriteRule(); - SetupOptions(settings); - await AnsiConsole .Console.Status() .Spinner(Spinner.Known.Star) @@ -182,58 +195,42 @@ private void SetupOptions(Settings settings) if (!string.IsNullOrEmpty(settings.ChatModelApiKey)) { - ArgumentException.ThrowIfNullOrEmpty(_llmOptions.ChatModel); - var chatModel = cacheModels.GetModel(_llmOptions.ChatModel); - chatModel.ModelOption.ApiKey = settings.ChatModelApiKey.Trim(); + _chatModel.ModelOption.ApiKey = settings.ChatModelApiKey.Trim(); } if (!string.IsNullOrEmpty(settings.ChatApiVersion)) { - ArgumentException.ThrowIfNullOrEmpty(_llmOptions.ChatModel); - var chatModel = cacheModels.GetModel(_llmOptions.ChatModel); - chatModel.ModelOption.ApiVersion = settings.ChatApiVersion.Trim(); + _chatModel.ModelOption.ApiVersion = settings.ChatApiVersion.Trim(); } if (!string.IsNullOrEmpty(settings.ChatDeploymentId)) { - ArgumentException.ThrowIfNullOrEmpty(_llmOptions.ChatModel); - var chatModel = cacheModels.GetModel(_llmOptions.ChatModel); - chatModel.ModelOption.DeploymentId = settings.ChatDeploymentId.Trim(); + _chatModel.ModelOption.DeploymentId = settings.ChatDeploymentId.Trim(); } if (!string.IsNullOrEmpty(settings.ChatBaseAddress)) { - ArgumentException.ThrowIfNullOrEmpty(_llmOptions.ChatModel); - var chatModel = cacheModels.GetModel(_llmOptions.ChatModel); - chatModel.ModelOption.BaseAddress = settings.ChatBaseAddress.Trim(); + _chatModel.ModelOption.BaseAddress = settings.ChatBaseAddress.Trim(); } - if (!string.IsNullOrEmpty(settings.EmbeddingsModelApiKey)) + if (!string.IsNullOrEmpty(settings.EmbeddingsModelApiKey) && _embeddingModel is not null) { - ArgumentException.ThrowIfNullOrEmpty(_llmOptions.EmbeddingsModel); - var embeddingModel = cacheModels.GetModel(_llmOptions.EmbeddingsModel); - embeddingModel.ModelOption.ApiKey = settings.EmbeddingsModelApiKey.Trim(); + _embeddingModel.ModelOption.ApiKey = settings.EmbeddingsModelApiKey.Trim(); } - if (!string.IsNullOrEmpty(settings.EmbeddingsApiVersion)) + if (!string.IsNullOrEmpty(settings.EmbeddingsApiVersion) && _embeddingModel is not null) { - ArgumentException.ThrowIfNullOrEmpty(_llmOptions.EmbeddingsModel); - var embeddingModel = cacheModels.GetModel(_llmOptions.EmbeddingsModel); - embeddingModel.ModelOption.ApiVersion = settings.EmbeddingsApiVersion.Trim(); + _embeddingModel.ModelOption.ApiVersion = settings.EmbeddingsApiVersion.Trim(); } - if (!string.IsNullOrEmpty(settings.EmbeddingsDeploymentId)) + if (!string.IsNullOrEmpty(settings.EmbeddingsDeploymentId) && _embeddingModel is not null) { - ArgumentException.ThrowIfNullOrEmpty(_llmOptions.EmbeddingsModel); - var embeddingModel = cacheModels.GetModel(_llmOptions.EmbeddingsModel); - embeddingModel.ModelOption.DeploymentId = settings.EmbeddingsDeploymentId.Trim(); + _embeddingModel.ModelOption.DeploymentId = settings.EmbeddingsDeploymentId.Trim(); } - if (!string.IsNullOrEmpty(settings.EmbeddingsBaseAddress)) + if (!string.IsNullOrEmpty(settings.EmbeddingsBaseAddress) && _embeddingModel is not null) { - ArgumentException.ThrowIfNullOrEmpty(_llmOptions.EmbeddingsModel); - var embeddingModel = cacheModels.GetModel(_llmOptions.EmbeddingsModel); - embeddingModel.ModelOption.BaseAddress = settings.EmbeddingsBaseAddress.Trim(); + _embeddingModel.ModelOption.BaseAddress = settings.EmbeddingsBaseAddress.Trim(); } _appOptions.ContextWorkingDirectory = !string.IsNullOrEmpty(settings.ContextWorkingDirectory) @@ -254,34 +251,25 @@ private void SetupOptions(Settings settings) if (settings.CodeDiffType is not null) { - ArgumentException.ThrowIfNullOrEmpty(_llmOptions.ChatModel); - var chatModel = cacheModels.GetModel(_llmOptions.ChatModel); - chatModel.ModelOption.CodeDiffType = settings.CodeDiffType.Value; + _chatModel.ModelOption.CodeDiffType = settings.CodeDiffType.Value; } if (settings.CodeAssistType is not null) { - ArgumentException.ThrowIfNullOrEmpty(_llmOptions.ChatModel); - var chatModel = cacheModels.GetModel(_llmOptions.ChatModel); - chatModel.ModelOption.CodeAssistType = settings.CodeAssistType.Value; + _chatModel.ModelOption.CodeAssistType = settings.CodeAssistType.Value; } - if (settings.Threshold is not null) + if (settings.Threshold is not null && _embeddingModel is not null) { - ArgumentException.ThrowIfNullOrEmpty(_llmOptions.EmbeddingsModel); - var embeddingsModel = cacheModels.GetModel(_llmOptions.EmbeddingsModel); - embeddingsModel.ModelOption.Threshold = settings.Threshold.Value; + _embeddingModel.ModelOption.Threshold = settings.Threshold.Value; } if (settings.Temperature is not null) { - ArgumentException.ThrowIfNullOrEmpty(_llmOptions.ChatModel); - var chatModel = cacheModels.GetModel(_llmOptions.ChatModel); - chatModel.ModelOption.Temperature = settings.Temperature.Value; + _chatModel.ModelOption.Temperature = settings.Temperature.Value; - ArgumentException.ThrowIfNullOrEmpty(_llmOptions.EmbeddingsModel); - var embeddingsModel = cacheModels.GetModel(_llmOptions.EmbeddingsModel); - embeddingsModel.ModelOption.Temperature = settings.Temperature.Value; + if (_embeddingModel is not null) + _embeddingModel.ModelOption.Temperature = settings.Temperature.Value; } } } diff --git a/src/AIAssistant/Commands/CodeExplanationCommand.cs b/src/AIAssist/Commands/CodeExplanationCommand.cs similarity index 98% rename from src/AIAssistant/Commands/CodeExplanationCommand.cs rename to src/AIAssist/Commands/CodeExplanationCommand.cs index 69ca361..df94cf2 100644 --- a/src/AIAssistant/Commands/CodeExplanationCommand.cs +++ b/src/AIAssist/Commands/CodeExplanationCommand.cs @@ -3,7 +3,7 @@ using Spectre.Console; using Spectre.Console.Cli; -namespace AIAssistant.Commands; +namespace AIAssist.Commands; [Description("Provide explaination for the code.")] public class CodeExplanationCommand : Command diff --git a/src/AIAssistant/Commands/HostPluginsCommand.cs b/src/AIAssist/Commands/HostPluginsCommand.cs similarity index 53% rename from src/AIAssistant/Commands/HostPluginsCommand.cs rename to src/AIAssist/Commands/HostPluginsCommand.cs index c419372..ee99517 100644 --- a/src/AIAssistant/Commands/HostPluginsCommand.cs +++ b/src/AIAssist/Commands/HostPluginsCommand.cs @@ -1,3 +1,3 @@ -namespace AIAssistant.Commands; +namespace AIAssist.Commands; public class HostPluginsCommand { } diff --git a/src/AIAssistant/Commands/InternalCommands/AddFileCommand.cs b/src/AIAssist/Commands/InternalCommands/AddFileCommand.cs similarity index 93% rename from src/AIAssistant/Commands/InternalCommands/AddFileCommand.cs rename to src/AIAssist/Commands/InternalCommands/AddFileCommand.cs index c9067c0..f8b84ec 100644 --- a/src/AIAssistant/Commands/InternalCommands/AddFileCommand.cs +++ b/src/AIAssist/Commands/InternalCommands/AddFileCommand.cs @@ -1,14 +1,14 @@ -using AIAssistant.Models.Options; +using AIAssist.Models.Options; using BuildingBlocks.SpectreConsole.Contracts; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.FileSystemGlobbing; using Microsoft.Extensions.FileSystemGlobbing.Abstractions; -namespace AIAssistant.Commands.InternalCommands; +namespace AIAssist.Commands.InternalCommands; public class AddFileCommand(ISpectreUtilities spectreUtilities, AppOptions appOptions) : IInternalConsoleCommand { - public string Name => AIAssistantConstants.InternalCommands.AddFiles; + public string Name => AIAssistConstants.InternalCommands.AddFiles; public string Command => $":{Name}"; public string? ShortCommand => ":a"; public ConsoleKey? ShortcutKey => ConsoleKey.A; diff --git a/src/AIAssistant/Commands/InternalCommands/ClearCommand.cs b/src/AIAssist/Commands/InternalCommands/ClearCommand.cs similarity index 79% rename from src/AIAssistant/Commands/InternalCommands/ClearCommand.cs rename to src/AIAssist/Commands/InternalCommands/ClearCommand.cs index c275bed..54c2b7d 100644 --- a/src/AIAssistant/Commands/InternalCommands/ClearCommand.cs +++ b/src/AIAssist/Commands/InternalCommands/ClearCommand.cs @@ -1,13 +1,13 @@ -using AIAssistant.Models.Options; +using AIAssist.Models.Options; using BuildingBlocks.SpectreConsole.Contracts; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; -namespace AIAssistant.Commands.InternalCommands; +namespace AIAssist.Commands.InternalCommands; public class ClearCommand(ISpectreUtilities spectreUtilities, IOptions appOptions) : IInternalConsoleCommand { - public string Name => AIAssistantConstants.InternalCommands.Clear; + public string Name => AIAssistConstants.InternalCommands.Clear; public string Command => $":{Name}"; public string? ShortCommand => ":c"; public ConsoleKey? ShortcutKey => ConsoleKey.F; diff --git a/src/AIAssistant/Commands/InternalCommands/ClearHistoryCommand.cs b/src/AIAssist/Commands/InternalCommands/ClearHistoryCommand.cs similarity index 79% rename from src/AIAssistant/Commands/InternalCommands/ClearHistoryCommand.cs rename to src/AIAssist/Commands/InternalCommands/ClearHistoryCommand.cs index 5158583..af8623b 100644 --- a/src/AIAssistant/Commands/InternalCommands/ClearHistoryCommand.cs +++ b/src/AIAssist/Commands/InternalCommands/ClearHistoryCommand.cs @@ -1,14 +1,14 @@ -using AIAssistant.Models.Options; +using AIAssist.Models.Options; using BuildingBlocks.SpectreConsole.Contracts; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; -namespace AIAssistant.Commands.InternalCommands; +namespace AIAssist.Commands.InternalCommands; public class ClearHistoryCommand(ISpectreUtilities spectreUtilities, IOptions appOptions) : IInternalConsoleCommand { - public string Name => AIAssistantConstants.InternalCommands.ClearHistory; + public string Name => AIAssistConstants.InternalCommands.ClearHistory; public string Command => $":{Name}"; public string? ShortCommand => ":g"; public ConsoleKey? ShortcutKey => ConsoleKey.G; diff --git a/src/AIAssistant/Commands/InternalCommands/FoldersTreeListCommand.cs b/src/AIAssist/Commands/InternalCommands/FoldersTreeListCommand.cs similarity index 80% rename from src/AIAssistant/Commands/InternalCommands/FoldersTreeListCommand.cs rename to src/AIAssist/Commands/InternalCommands/FoldersTreeListCommand.cs index 8eb9ee5..c10805d 100644 --- a/src/AIAssistant/Commands/InternalCommands/FoldersTreeListCommand.cs +++ b/src/AIAssist/Commands/InternalCommands/FoldersTreeListCommand.cs @@ -1,14 +1,14 @@ -using AIAssistant.Models.Options; +using AIAssist.Models.Options; using BuildingBlocks.SpectreConsole.Contracts; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; -namespace AIAssistant.Commands.InternalCommands; +namespace AIAssist.Commands.InternalCommands; public class FoldersTreeListCommand(ISpectreUtilities spectreUtilities, IOptions appOptions) : IInternalConsoleCommand { - public string Name => AIAssistantConstants.InternalCommands.TreeList; + public string Name => AIAssistConstants.InternalCommands.TreeList; public string Command => $":{Name}"; public string? ShortCommand => ":l"; public ConsoleKey? ShortcutKey => ConsoleKey.L; diff --git a/src/AIAssistant/Commands/InternalCommands/HelpCommand.cs b/src/AIAssist/Commands/InternalCommands/HelpCommand.cs similarity index 80% rename from src/AIAssistant/Commands/InternalCommands/HelpCommand.cs rename to src/AIAssist/Commands/InternalCommands/HelpCommand.cs index 5e9dc75..3d75b6e 100644 --- a/src/AIAssistant/Commands/InternalCommands/HelpCommand.cs +++ b/src/AIAssist/Commands/InternalCommands/HelpCommand.cs @@ -1,11 +1,11 @@ using BuildingBlocks.SpectreConsole.Contracts; using Microsoft.Extensions.DependencyInjection; -namespace AIAssistant.Commands.InternalCommands; +namespace AIAssist.Commands.InternalCommands; public class HelpCommand(string HelpText, ISpectreUtilities spectreUtilities) : IInternalConsoleCommand { - public string Name => AIAssistantConstants.InternalCommands.Help; + public string Name => AIAssistConstants.InternalCommands.Help; public string Command => $":{Name}"; public string? ShortCommand => ":h"; public ConsoleKey? ShortcutKey => ConsoleKey.H; diff --git a/src/AIAssistant/Commands/InternalCommands/QuitCommand.cs b/src/AIAssist/Commands/InternalCommands/QuitCommand.cs similarity index 81% rename from src/AIAssistant/Commands/InternalCommands/QuitCommand.cs rename to src/AIAssist/Commands/InternalCommands/QuitCommand.cs index 34e7889..0196872 100644 --- a/src/AIAssistant/Commands/InternalCommands/QuitCommand.cs +++ b/src/AIAssist/Commands/InternalCommands/QuitCommand.cs @@ -1,13 +1,13 @@ -using AIAssistant.Models.Options; +using AIAssist.Models.Options; using BuildingBlocks.SpectreConsole.Contracts; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; -namespace AIAssistant.Commands.InternalCommands; +namespace AIAssist.Commands.InternalCommands; public class QuitCommand(ISpectreUtilities spectreUtilities, IOptions appOptions) : IInternalConsoleCommand { - public string Name => AIAssistantConstants.InternalCommands.Quit; + public string Name => AIAssistConstants.InternalCommands.Quit; public string Command => $":{Name}"; public string? ShortCommand => ":q"; public ConsoleKey? ShortcutKey => ConsoleKey.C; diff --git a/src/AIAssistant/Commands/InternalCommands/RunCommand.cs b/src/AIAssist/Commands/InternalCommands/RunCommand.cs similarity index 84% rename from src/AIAssistant/Commands/InternalCommands/RunCommand.cs rename to src/AIAssist/Commands/InternalCommands/RunCommand.cs index cce88db..76c8810 100644 --- a/src/AIAssistant/Commands/InternalCommands/RunCommand.cs +++ b/src/AIAssist/Commands/InternalCommands/RunCommand.cs @@ -1,14 +1,13 @@ -using AIAssistant.Chat.Models; -using AIAssistant.Contracts; -using AIAssistant.Contracts.CodeAssist; -using AIAssistant.Models.Options; -using AIAssistant.Prompts; +using AIAssist.Chat.Models; +using AIAssist.Contracts; +using AIAssist.Contracts.CodeAssist; +using AIAssist.Models.Options; using BuildingBlocks.SpectreConsole; using BuildingBlocks.SpectreConsole.Contracts; using Microsoft.Extensions.DependencyInjection; using Spectre.Console; -namespace AIAssistant.Commands.InternalCommands; +namespace AIAssist.Commands.InternalCommands; public class RunCommand( ISpectreUtilities spectreUtilities, @@ -18,7 +17,7 @@ public class RunCommand( AppOptions appOptions ) : IInternalConsoleCommand { - public string Name => AIAssistantConstants.InternalCommands.Run; + public string Name => AIAssistConstants.InternalCommands.Run; public string Command => $":{Name}"; public string? ShortCommand => ":r"; public ConsoleKey? ShortcutKey => ConsoleKey.R; @@ -47,7 +46,7 @@ public async Task ExecuteAsync(IServiceScope scope, string? input) if (confirmation) { - await codeAssistantManager.AddOrUpdateCodeFilesToCache(requiredFiles); + await codeAssistantManager.AddOrUpdateCodeFiles(requiredFiles); var fullFilesContentForContext = await codeAssistantManager.GetCodeTreeContentsFromCache(requiredFiles); var newQueryWithAddedFiles = promptManager.FilesAddedToChat(fullFilesContentForContext); @@ -55,6 +54,8 @@ public async Task ExecuteAsync(IServiceScope scope, string? input) $"{string.Join(",", requiredFiles.Select(file => $"'{file}'"))} added to the context." ); + // wait a second before query with more provided context by user. + await Task.Delay(TimeSpan.FromSeconds(1)); await ExecuteAsync(scope, newQueryWithAddedFiles); } } @@ -70,7 +71,7 @@ public async Task ExecuteAsync(IServiceScope scope, string? input) if (confirmation) { codeAssistantManager.ApplyChanges([diffResult], appOptions.ContextWorkingDirectory); - await codeAssistantManager.AddOrUpdateCodeFilesToCache([diffResult.ModifiedPath]); + await codeAssistantManager.AddOrUpdateCodeFiles([diffResult.ModifiedPath]); } } diff --git a/src/AIAssistant/Commands/InternalCommands/SummarizeCommand.cs b/src/AIAssist/Commands/InternalCommands/SummarizeCommand.cs similarity index 78% rename from src/AIAssistant/Commands/InternalCommands/SummarizeCommand.cs rename to src/AIAssist/Commands/InternalCommands/SummarizeCommand.cs index cbb5557..9144f78 100644 --- a/src/AIAssistant/Commands/InternalCommands/SummarizeCommand.cs +++ b/src/AIAssist/Commands/InternalCommands/SummarizeCommand.cs @@ -1,14 +1,14 @@ -using AIAssistant.Models.Options; +using AIAssist.Models.Options; using BuildingBlocks.SpectreConsole.Contracts; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; -namespace AIAssistant.Commands.InternalCommands; +namespace AIAssist.Commands.InternalCommands; public class SummarizeCommand(ISpectreUtilities spectreUtilities, IOptions appOptions) : IInternalConsoleCommand { - public string Name => AIAssistantConstants.InternalCommands.Summarize; + public string Name => AIAssistConstants.InternalCommands.Summarize; public string Command => $":{Name}"; public string? ShortCommand => ":s"; public ConsoleKey? ShortcutKey => ConsoleKey.S; diff --git a/src/AIAssistant/Commands/InternalCommands/TokenCommand.cs b/src/AIAssist/Commands/InternalCommands/TokenCommand.cs similarity index 78% rename from src/AIAssistant/Commands/InternalCommands/TokenCommand.cs rename to src/AIAssist/Commands/InternalCommands/TokenCommand.cs index 0e39261..06415a0 100644 --- a/src/AIAssistant/Commands/InternalCommands/TokenCommand.cs +++ b/src/AIAssist/Commands/InternalCommands/TokenCommand.cs @@ -1,13 +1,13 @@ -using AIAssistant.Models.Options; +using AIAssist.Models.Options; using BuildingBlocks.SpectreConsole.Contracts; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; -namespace AIAssistant.Commands.InternalCommands; +namespace AIAssist.Commands.InternalCommands; public class TokenCommand(ISpectreUtilities spectreUtilities, IOptions appOptions) : IInternalConsoleCommand { - public string Name => AIAssistantConstants.InternalCommands.Tokens; + public string Name => AIAssistConstants.InternalCommands.Tokens; public string Command => $":{Name}"; public string? ShortCommand => ":t"; public ConsoleKey? ShortcutKey => ConsoleKey.T; diff --git a/src/AIAssist/Commands/PlanCommand.cs b/src/AIAssist/Commands/PlanCommand.cs new file mode 100644 index 0000000..261528f --- /dev/null +++ b/src/AIAssist/Commands/PlanCommand.cs @@ -0,0 +1,3 @@ +namespace AIAssist.Commands; + +public class PlanCommand { } diff --git a/src/AIAssistant/Commands/ReviewCommand.cs b/src/AIAssist/Commands/ReviewCommand.cs similarity index 50% rename from src/AIAssistant/Commands/ReviewCommand.cs rename to src/AIAssist/Commands/ReviewCommand.cs index b9faa13..45611cb 100644 --- a/src/AIAssistant/Commands/ReviewCommand.cs +++ b/src/AIAssist/Commands/ReviewCommand.cs @@ -1,3 +1,3 @@ -namespace AIAssistant.Commands; +namespace AIAssist.Commands; public class ReviewCommand { } diff --git a/src/AIAssistant/Commands/TreeStructureCommand.cs b/src/AIAssist/Commands/TreeStructureCommand.cs similarity index 93% rename from src/AIAssistant/Commands/TreeStructureCommand.cs rename to src/AIAssist/Commands/TreeStructureCommand.cs index 8bb7a93..89e955a 100644 --- a/src/AIAssistant/Commands/TreeStructureCommand.cs +++ b/src/AIAssist/Commands/TreeStructureCommand.cs @@ -2,7 +2,7 @@ using Spectre.Console; using Spectre.Console.Cli; -namespace AIAssistant.Commands; +namespace AIAssist.Commands; [Description("Provide tree structure of our application context.")] public sealed class TreeStructureCommand : Command diff --git a/src/AIAssistant/Contracts/CodeAssist/ICodeAssist.cs b/src/AIAssist/Contracts/CodeAssist/ICodeAssist.cs similarity index 88% rename from src/AIAssistant/Contracts/CodeAssist/ICodeAssist.cs rename to src/AIAssist/Contracts/CodeAssist/ICodeAssist.cs index ab5e66f..73c3ea6 100644 --- a/src/AIAssistant/Contracts/CodeAssist/ICodeAssist.cs +++ b/src/AIAssist/Contracts/CodeAssist/ICodeAssist.cs @@ -1,4 +1,4 @@ -namespace AIAssistant.Contracts.CodeAssist; +namespace AIAssist.Contracts.CodeAssist; public interface ICodeAssist { diff --git a/src/AIAssistant/Contracts/CodeAssist/ICodeAssistFactory.cs b/src/AIAssist/Contracts/CodeAssist/ICodeAssistFactory.cs similarity index 62% rename from src/AIAssistant/Contracts/CodeAssist/ICodeAssistFactory.cs rename to src/AIAssist/Contracts/CodeAssist/ICodeAssistFactory.cs index b7310de..203d39d 100644 --- a/src/AIAssistant/Contracts/CodeAssist/ICodeAssistFactory.cs +++ b/src/AIAssist/Contracts/CodeAssist/ICodeAssistFactory.cs @@ -1,7 +1,6 @@ -using AIAssistant.Models; using Clients.Models; -namespace AIAssistant.Contracts.CodeAssist; +namespace AIAssist.Contracts.CodeAssist; public interface ICodeAssistFactory { diff --git a/src/AIAssistant/Contracts/CodeAssist/ICodeAssistantManager.cs b/src/AIAssist/Contracts/CodeAssist/ICodeAssistantManager.cs similarity index 77% rename from src/AIAssistant/Contracts/CodeAssist/ICodeAssistantManager.cs rename to src/AIAssist/Contracts/CodeAssist/ICodeAssistantManager.cs index be824af..f93588e 100644 --- a/src/AIAssistant/Contracts/CodeAssist/ICodeAssistantManager.cs +++ b/src/AIAssist/Contracts/CodeAssist/ICodeAssistantManager.cs @@ -1,13 +1,12 @@ -using System.Collections; -using AIAssistant.Models; +using AIAssist.Models; -namespace AIAssistant.Contracts.CodeAssist; +namespace AIAssist.Contracts.CodeAssist; public interface ICodeAssistantManager { Task LoadCodeFiles(string contextWorkingDirectory, IList? codeFiles); IAsyncEnumerable QueryAsync(string userQuery); - Task AddOrUpdateCodeFilesToCache(IList? codeFiles); + Task AddOrUpdateCodeFiles(IList? codeFiles); Task> GetCodeTreeContentsFromCache(IList? codeFiles); bool CheckExtraContextForResponse(string response, out IList requiredFiles); IList ParseDiffResults(string diffContent, string contextWorkingDirectory); diff --git a/src/AIAssistant/Contracts/Diff/ICodeDiffManager.cs b/src/AIAssist/Contracts/Diff/ICodeDiffManager.cs similarity index 77% rename from src/AIAssistant/Contracts/Diff/ICodeDiffManager.cs rename to src/AIAssist/Contracts/Diff/ICodeDiffManager.cs index 18c3ed1..1aae35f 100644 --- a/src/AIAssistant/Contracts/Diff/ICodeDiffManager.cs +++ b/src/AIAssist/Contracts/Diff/ICodeDiffManager.cs @@ -1,6 +1,6 @@ -using AIAssistant.Models; +using AIAssist.Models; -namespace AIAssistant.Contracts.Diff; +namespace AIAssist.Contracts.Diff; public interface ICodeDiffManager { diff --git a/src/AIAssistant/Contracts/Diff/ICodeDiffParser.cs b/src/AIAssist/Contracts/Diff/ICodeDiffParser.cs similarity index 68% rename from src/AIAssistant/Contracts/Diff/ICodeDiffParser.cs rename to src/AIAssist/Contracts/Diff/ICodeDiffParser.cs index 9dafc6b..514de11 100644 --- a/src/AIAssistant/Contracts/Diff/ICodeDiffParser.cs +++ b/src/AIAssist/Contracts/Diff/ICodeDiffParser.cs @@ -1,6 +1,6 @@ -using AIAssistant.Models; +using AIAssist.Models; -namespace AIAssistant.Contracts.Diff; +namespace AIAssist.Contracts.Diff; public interface ICodeDiffParser { diff --git a/src/AIAssistant/Contracts/Diff/ICodeDiffParserFactory.cs b/src/AIAssist/Contracts/Diff/ICodeDiffParserFactory.cs similarity index 65% rename from src/AIAssistant/Contracts/Diff/ICodeDiffParserFactory.cs rename to src/AIAssist/Contracts/Diff/ICodeDiffParserFactory.cs index f2de850..b251501 100644 --- a/src/AIAssistant/Contracts/Diff/ICodeDiffParserFactory.cs +++ b/src/AIAssist/Contracts/Diff/ICodeDiffParserFactory.cs @@ -1,7 +1,6 @@ -using AIAssistant.Models; using Clients.Models; -namespace AIAssistant.Contracts.Diff; +namespace AIAssist.Contracts.Diff; public interface ICodeDiffParserFactory { diff --git a/src/AIAssistant/Contracts/Diff/ICodeDiffUpdater.cs b/src/AIAssist/Contracts/Diff/ICodeDiffUpdater.cs similarity index 67% rename from src/AIAssistant/Contracts/Diff/ICodeDiffUpdater.cs rename to src/AIAssist/Contracts/Diff/ICodeDiffUpdater.cs index 7e3d1af..4ece331 100644 --- a/src/AIAssistant/Contracts/Diff/ICodeDiffUpdater.cs +++ b/src/AIAssist/Contracts/Diff/ICodeDiffUpdater.cs @@ -1,6 +1,6 @@ -using AIAssistant.Models; +using AIAssist.Models; -namespace AIAssistant.Contracts.Diff; +namespace AIAssist.Contracts.Diff; public interface ICodeDiffUpdater { diff --git a/src/AIAssistant/Contracts/IChatSessionManager.cs b/src/AIAssist/Contracts/IChatSessionManager.cs similarity index 75% rename from src/AIAssistant/Contracts/IChatSessionManager.cs rename to src/AIAssist/Contracts/IChatSessionManager.cs index b96baee..18d8eec 100644 --- a/src/AIAssistant/Contracts/IChatSessionManager.cs +++ b/src/AIAssist/Contracts/IChatSessionManager.cs @@ -1,7 +1,6 @@ -using AIAssistant.Chat.Models; -using AIAssistant.Models; +using AIAssist.Chat.Models; -namespace AIAssistant.Contracts; +namespace AIAssist.Contracts; public interface IChatSessionManager { diff --git a/src/AIAssistant/Contracts/ICodeFileTreeGeneratorService.cs b/src/AIAssist/Contracts/ICodeFileTreeGeneratorService.cs similarity index 92% rename from src/AIAssistant/Contracts/ICodeFileTreeGeneratorService.cs rename to src/AIAssist/Contracts/ICodeFileTreeGeneratorService.cs index 3078c76..31edb4e 100644 --- a/src/AIAssistant/Contracts/ICodeFileTreeGeneratorService.cs +++ b/src/AIAssist/Contracts/ICodeFileTreeGeneratorService.cs @@ -1,6 +1,6 @@ using TreeSitter.Bindings.CustomTypes.TreeParser; -namespace AIAssistant.Contracts; +namespace AIAssist.Contracts; public interface ICodeFileTreeGeneratorService { diff --git a/src/AIAssistant/Contracts/IContextService.cs b/src/AIAssist/Contracts/IContextService.cs similarity index 88% rename from src/AIAssistant/Contracts/IContextService.cs rename to src/AIAssist/Contracts/IContextService.cs index 90cf2ed..844091e 100644 --- a/src/AIAssistant/Contracts/IContextService.cs +++ b/src/AIAssist/Contracts/IContextService.cs @@ -1,6 +1,6 @@ -using AIAssistant.Models; +using AIAssist.Models; -namespace AIAssistant.Contracts; +namespace AIAssist.Contracts; public interface IContextService { diff --git a/src/AIAssistant/Contracts/IEmbeddingService.cs b/src/AIAssist/Contracts/IEmbeddingService.cs similarity index 79% rename from src/AIAssistant/Contracts/IEmbeddingService.cs rename to src/AIAssist/Contracts/IEmbeddingService.cs index da68bf1..9932b19 100644 --- a/src/AIAssistant/Contracts/IEmbeddingService.cs +++ b/src/AIAssist/Contracts/IEmbeddingService.cs @@ -1,11 +1,10 @@ -using System.Collections; -using AIAssistant.Chat.Models; -using AIAssistant.Data; -using AIAssistant.Dtos; -using AIAssistant.Models; +using AIAssist.Chat.Models; +using AIAssist.Data; +using AIAssist.Dtos; +using AIAssist.Models; using TreeSitter.Bindings.CustomTypes.TreeParser; -namespace AIAssistant.Contracts; +namespace AIAssist.Contracts; public interface IEmbeddingService { diff --git a/src/AIAssistant/Contracts/IFileService.cs b/src/AIAssist/Contracts/IFileService.cs similarity index 95% rename from src/AIAssistant/Contracts/IFileService.cs rename to src/AIAssist/Contracts/IFileService.cs index b102f4a..4956542 100644 --- a/src/AIAssistant/Contracts/IFileService.cs +++ b/src/AIAssist/Contracts/IFileService.cs @@ -1,6 +1,6 @@ using System.Reflection; -namespace AIAssistant.Contracts; +namespace AIAssist.Contracts; public interface IFileService { diff --git a/src/AIAssistant/Contracts/ILLMClientManager.cs b/src/AIAssist/Contracts/ILLMClientManager.cs similarity index 90% rename from src/AIAssistant/Contracts/ILLMClientManager.cs rename to src/AIAssist/Contracts/ILLMClientManager.cs index ac829e7..1a865f8 100644 --- a/src/AIAssistant/Contracts/ILLMClientManager.cs +++ b/src/AIAssist/Contracts/ILLMClientManager.cs @@ -1,7 +1,7 @@ -using AIAssistant.Dtos; +using AIAssist.Dtos; using Clients.Models; -namespace AIAssistant.Contracts; +namespace AIAssist.Contracts; public interface ILLMClientManager { diff --git a/src/AIAssistant/Contracts/IPromptManager.cs b/src/AIAssist/Contracts/IPromptManager.cs similarity index 95% rename from src/AIAssistant/Contracts/IPromptManager.cs rename to src/AIAssist/Contracts/IPromptManager.cs index 2f44a0d..2613022 100644 --- a/src/AIAssistant/Contracts/IPromptManager.cs +++ b/src/AIAssist/Contracts/IPromptManager.cs @@ -1,7 +1,7 @@ -using AIAssistant.Models; +using AIAssist.Models; using Clients.Models; -namespace AIAssistant.Contracts; +namespace AIAssist.Contracts; public interface IPromptManager { diff --git a/src/AIAssistant/Data/CodeEmbeddingDocument.cs b/src/AIAssist/Data/CodeEmbeddingDocument.cs similarity index 77% rename from src/AIAssistant/Data/CodeEmbeddingDocument.cs rename to src/AIAssist/Data/CodeEmbeddingDocument.cs index 08daefd..eebbc38 100644 --- a/src/AIAssistant/Data/CodeEmbeddingDocument.cs +++ b/src/AIAssist/Data/CodeEmbeddingDocument.cs @@ -1,5 +1,5 @@ using BuildingBlocks.InMemoryVectorDatabase; -namespace AIAssistant.Data; +namespace AIAssist.Data; public class CodeEmbeddingDocument : Document; diff --git a/src/AIAssistant/Data/CodeEmbeddingsRepository.cs b/src/AIAssist/Data/CodeEmbeddingsRepository.cs similarity index 98% rename from src/AIAssistant/Data/CodeEmbeddingsRepository.cs rename to src/AIAssist/Data/CodeEmbeddingsRepository.cs index 27d779b..a18d07e 100644 --- a/src/AIAssistant/Data/CodeEmbeddingsRepository.cs +++ b/src/AIAssist/Data/CodeEmbeddingsRepository.cs @@ -1,8 +1,8 @@ -using AIAssistant.Models; +using AIAssist.Models; using BuildingBlocks.InMemoryVectorDatabase.Contracts; using Humanizer; -namespace AIAssistant.Data; +namespace AIAssist.Data; public class CodeEmbeddingsRepository(IVectorContext vectorDatabase) : ICodeEmbeddingsRepository { diff --git a/src/AIAssistant/Data/ICodeEmbeddingsRepository.cs b/src/AIAssist/Data/ICodeEmbeddingsRepository.cs similarity index 75% rename from src/AIAssistant/Data/ICodeEmbeddingsRepository.cs rename to src/AIAssist/Data/ICodeEmbeddingsRepository.cs index b3c6ec9..57937a8 100644 --- a/src/AIAssistant/Data/ICodeEmbeddingsRepository.cs +++ b/src/AIAssist/Data/ICodeEmbeddingsRepository.cs @@ -1,6 +1,6 @@ -using AIAssistant.Models; +using AIAssist.Models; using BuildingBlocks.InMemoryVectorDatabase.Contracts; -namespace AIAssistant.Data; +namespace AIAssist.Data; public interface ICodeEmbeddingsRepository : IGenericVectorRepository; diff --git a/src/AIAssistant/Diff/CodeBlockDiffParser.cs b/src/AIAssist/Diff/CodeBlockDiffParser.cs similarity index 98% rename from src/AIAssistant/Diff/CodeBlockDiffParser.cs rename to src/AIAssist/Diff/CodeBlockDiffParser.cs index cf7c0c9..0c6b2c7 100644 --- a/src/AIAssistant/Diff/CodeBlockDiffParser.cs +++ b/src/AIAssist/Diff/CodeBlockDiffParser.cs @@ -1,7 +1,7 @@ -using AIAssistant.Contracts.Diff; -using AIAssistant.Models; +using AIAssist.Contracts.Diff; +using AIAssist.Models; -namespace AIAssistant.Diff; +namespace AIAssist.Diff; public class CodeBlockDiffParser : ICodeDiffParser { diff --git a/src/AIAssistant/Diff/CodeDiffManager.cs b/src/AIAssist/Diff/CodeDiffManager.cs similarity index 84% rename from src/AIAssistant/Diff/CodeDiffManager.cs rename to src/AIAssist/Diff/CodeDiffManager.cs index 5daac1e..6429083 100644 --- a/src/AIAssistant/Diff/CodeDiffManager.cs +++ b/src/AIAssist/Diff/CodeDiffManager.cs @@ -1,7 +1,7 @@ -using AIAssistant.Contracts.Diff; -using AIAssistant.Models; +using AIAssist.Contracts.Diff; +using AIAssist.Models; -namespace AIAssistant.Diff; +namespace AIAssist.Diff; public class CodeDiffManager(ICodeDiffUpdater codeDiffUpdater, ICodeDiffParser codeDiffParser) : ICodeDiffManager { diff --git a/src/AIAssistant/Diff/CodeDiffParserFactory.cs b/src/AIAssist/Diff/CodeDiffParserFactory.cs similarity index 80% rename from src/AIAssistant/Diff/CodeDiffParserFactory.cs rename to src/AIAssist/Diff/CodeDiffParserFactory.cs index 7c3f751..58b592e 100644 --- a/src/AIAssistant/Diff/CodeDiffParserFactory.cs +++ b/src/AIAssist/Diff/CodeDiffParserFactory.cs @@ -1,7 +1,7 @@ -using AIAssistant.Contracts.Diff; +using AIAssist.Contracts.Diff; using Clients.Models; -namespace AIAssistant.Diff; +namespace AIAssist.Diff; public class CodeDiffParserFactory(IDictionary strategies) : ICodeDiffParserFactory { diff --git a/src/AIAssistant/Diff/CodeDiffUpdater.cs b/src/AIAssist/Diff/CodeDiffUpdater.cs similarity index 98% rename from src/AIAssistant/Diff/CodeDiffUpdater.cs rename to src/AIAssist/Diff/CodeDiffUpdater.cs index 2c6b3dd..6e1ea3c 100644 --- a/src/AIAssistant/Diff/CodeDiffUpdater.cs +++ b/src/AIAssist/Diff/CodeDiffUpdater.cs @@ -1,8 +1,8 @@ -using AIAssistant.Contracts.Diff; -using AIAssistant.Models; +using AIAssist.Contracts.Diff; +using AIAssist.Models; using BuildingBlocks.SpectreConsole.Contracts; -namespace AIAssistant.Diff; +namespace AIAssist.Diff; public class CodeDiffUpdater(ISpectreUtilities spectreUtilities) : ICodeDiffUpdater { diff --git a/src/AIAssistant/Diff/SearchReplaceParser.cs b/src/AIAssist/Diff/SearchReplaceParser.cs similarity index 99% rename from src/AIAssistant/Diff/SearchReplaceParser.cs rename to src/AIAssist/Diff/SearchReplaceParser.cs index 6f1b947..42d6682 100644 --- a/src/AIAssistant/Diff/SearchReplaceParser.cs +++ b/src/AIAssist/Diff/SearchReplaceParser.cs @@ -1,8 +1,8 @@ -using AIAssistant.Contracts.Diff; -using AIAssistant.Models; +using AIAssist.Contracts.Diff; +using AIAssist.Models; using BuildingBlocks.Utils; -namespace AIAssistant.Diff; +namespace AIAssist.Diff; public class SearchReplaceParser : ICodeDiffParser { diff --git a/src/AIAssistant/Diff/UnifiedCodeDiffParser.cs b/src/AIAssist/Diff/UnifiedCodeDiffParser.cs similarity index 99% rename from src/AIAssistant/Diff/UnifiedCodeDiffParser.cs rename to src/AIAssist/Diff/UnifiedCodeDiffParser.cs index 1820316..c8e559b 100644 --- a/src/AIAssistant/Diff/UnifiedCodeDiffParser.cs +++ b/src/AIAssist/Diff/UnifiedCodeDiffParser.cs @@ -1,8 +1,8 @@ using System.Text.RegularExpressions; -using AIAssistant.Contracts.Diff; -using AIAssistant.Models; +using AIAssist.Contracts.Diff; +using AIAssist.Models; -namespace AIAssistant.Diff; +namespace AIAssist.Diff; // https://en.wikipedia.org/wiki/Diff#Unified_format diff --git a/src/AIAssist/DotnetToolSettings.xml b/src/AIAssist/DotnetToolSettings.xml new file mode 100644 index 0000000..dce492d --- /dev/null +++ b/src/AIAssist/DotnetToolSettings.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/AIAssistant/Dtos/AddEmbeddingsForFilesResult.cs b/src/AIAssist/Dtos/AddEmbeddingsForFilesResult.cs similarity index 75% rename from src/AIAssistant/Dtos/AddEmbeddingsForFilesResult.cs rename to src/AIAssist/Dtos/AddEmbeddingsForFilesResult.cs index e4b4932..17b8cb8 100644 --- a/src/AIAssistant/Dtos/AddEmbeddingsForFilesResult.cs +++ b/src/AIAssist/Dtos/AddEmbeddingsForFilesResult.cs @@ -1,3 +1,3 @@ -namespace AIAssistant.Dtos; +namespace AIAssist.Dtos; public record AddEmbeddingsForFilesResult(int TotalTokensCount, decimal TotalCost); diff --git a/src/AIAssistant/Dtos/GetBatchEmbeddingResult.cs b/src/AIAssist/Dtos/GetBatchEmbeddingResult.cs similarity index 91% rename from src/AIAssistant/Dtos/GetBatchEmbeddingResult.cs rename to src/AIAssist/Dtos/GetBatchEmbeddingResult.cs index f703ac4..5d4c3dc 100644 --- a/src/AIAssistant/Dtos/GetBatchEmbeddingResult.cs +++ b/src/AIAssist/Dtos/GetBatchEmbeddingResult.cs @@ -1,4 +1,4 @@ -namespace AIAssistant.Dtos; +namespace AIAssist.Dtos; public class GetBatchEmbeddingResult(IList> embeddings, int totalTokensCount, decimal totalCost) { diff --git a/src/AIAssistant/Dtos/GetEmbeddingResult.cs b/src/AIAssist/Dtos/GetEmbeddingResult.cs similarity index 84% rename from src/AIAssistant/Dtos/GetEmbeddingResult.cs rename to src/AIAssist/Dtos/GetEmbeddingResult.cs index 4c5b112..b56c27b 100644 --- a/src/AIAssistant/Dtos/GetEmbeddingResult.cs +++ b/src/AIAssist/Dtos/GetEmbeddingResult.cs @@ -1,4 +1,4 @@ -namespace AIAssistant.Dtos; +namespace AIAssist.Dtos; public record GetEmbeddingResult( IList> Embeddings, // Multiple embeddings for batch diff --git a/src/AIAssistant/Dtos/GetRelatedEmbeddingsResult.cs b/src/AIAssist/Dtos/GetRelatedEmbeddingsResult.cs similarity index 72% rename from src/AIAssistant/Dtos/GetRelatedEmbeddingsResult.cs rename to src/AIAssist/Dtos/GetRelatedEmbeddingsResult.cs index 071afcd..dd79842 100644 --- a/src/AIAssistant/Dtos/GetRelatedEmbeddingsResult.cs +++ b/src/AIAssist/Dtos/GetRelatedEmbeddingsResult.cs @@ -1,6 +1,6 @@ -using AIAssistant.Models; +using AIAssist.Models; -namespace AIAssistant.Dtos; +namespace AIAssist.Dtos; public record GetRelatedEmbeddingsResult( IEnumerable CodeEmbeddings, diff --git a/src/AIAssistant/Extensions/ConfigurationExtensions.cs b/src/AIAssist/Extensions/ConfigurationExtensions.cs similarity index 92% rename from src/AIAssistant/Extensions/ConfigurationExtensions.cs rename to src/AIAssist/Extensions/ConfigurationExtensions.cs index b50a324..e61c1b5 100644 --- a/src/AIAssistant/Extensions/ConfigurationExtensions.cs +++ b/src/AIAssist/Extensions/ConfigurationExtensions.cs @@ -2,7 +2,7 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Hosting; -namespace AIAssistant.Extensions; +namespace AIAssist.Extensions; public static class ConfigurationExtensions { @@ -23,7 +23,7 @@ public static HostApplicationBuilder AddDefaultConfigurations(this HostApplicati private static void AddEmbeddedConfiguration(HostApplicationBuilder builder) { var assembly = Assembly.GetExecutingAssembly(); - var resourceName = $"{nameof(AIAssistant)}.aiassist-config.json"; + var resourceName = $"{nameof(AIAssist)}.aiassist-config.json"; using var stream = assembly.GetManifestResourceStream(resourceName); diff --git a/src/AIAssistant/Extensions/DependencyInjectionExtensions.cs b/src/AIAssist/Extensions/DependencyInjectionExtensions.cs similarity index 97% rename from src/AIAssistant/Extensions/DependencyInjectionExtensions.cs rename to src/AIAssist/Extensions/DependencyInjectionExtensions.cs index 1990388..0a70674 100644 --- a/src/AIAssistant/Extensions/DependencyInjectionExtensions.cs +++ b/src/AIAssist/Extensions/DependencyInjectionExtensions.cs @@ -1,16 +1,16 @@ using System.Net.Http.Headers; -using AIAssistant.Commands; -using AIAssistant.Commands.InternalCommands; -using AIAssistant.Contracts; -using AIAssistant.Contracts.CodeAssist; -using AIAssistant.Contracts.Diff; -using AIAssistant.Data; -using AIAssistant.Diff; -using AIAssistant.Models; -using AIAssistant.Models.Options; -using AIAssistant.Prompts; -using AIAssistant.Services; -using AIAssistant.Services.CodeAssistStrategies; +using AIAssist.Commands; +using AIAssist.Commands.InternalCommands; +using AIAssist.Contracts; +using AIAssist.Contracts.CodeAssist; +using AIAssist.Contracts.Diff; +using AIAssist.Data; +using AIAssist.Diff; +using AIAssist.Models; +using AIAssist.Models.Options; +using AIAssist.Prompts; +using AIAssist.Services; +using AIAssist.Services.CodeAssistStrategies; using BuildingBlocks.Extensions; using BuildingBlocks.InMemoryVectorDatabase; using BuildingBlocks.InMemoryVectorDatabase.Contracts; @@ -35,7 +35,7 @@ using TreeSitter.Bindings.Services; using TreeSitter.Bindings.Utilities; -namespace AIAssistant.Extensions; +namespace AIAssist.Extensions; public static class DependencyInjectionExtensions { @@ -226,19 +226,19 @@ private static void AddPromptDependencies(HostApplicationBuilder builder) var promptStorage = new PromptManager(fileService); promptStorage.AddPrompt( - AIAssistantConstants.Prompts.CodeAssistantUnifiedDiffTemplate, + AIAssistConstants.Prompts.CodeAssistantUnifiedDiffTemplate, CommandType.Code, CodeDiffType.UnifiedDiff ); promptStorage.AddPrompt( - AIAssistantConstants.Prompts.CodeAssistantCodeBlockdDiffTemplate, + AIAssistConstants.Prompts.CodeAssistantCodeBlockdDiffTemplate, CommandType.Code, CodeDiffType.CodeBlockDiff ); promptStorage.AddPrompt( - AIAssistantConstants.Prompts.CodeAssistantSearchReplaceDiffTemplate, + AIAssistConstants.Prompts.CodeAssistantSearchReplaceDiffTemplate, CommandType.Code, CodeDiffType.SearchReplaceDiff ); diff --git a/src/AIAssistant/MetadataRoot.cs b/src/AIAssist/MetadataRoot.cs similarity index 54% rename from src/AIAssistant/MetadataRoot.cs rename to src/AIAssist/MetadataRoot.cs index 7eb1db9..d4b8b25 100644 --- a/src/AIAssistant/MetadataRoot.cs +++ b/src/AIAssist/MetadataRoot.cs @@ -1,3 +1,3 @@ -namespace AIAssistant; +namespace AIAssist; public class MetadataRoot; diff --git a/src/AIAssistant/Models/ActionType.cs b/src/AIAssist/Models/ActionType.cs similarity index 68% rename from src/AIAssistant/Models/ActionType.cs rename to src/AIAssist/Models/ActionType.cs index 738f84c..b0a19e6 100644 --- a/src/AIAssistant/Models/ActionType.cs +++ b/src/AIAssist/Models/ActionType.cs @@ -1,4 +1,4 @@ -namespace AIAssistant.Models; +namespace AIAssist.Models; public enum ActionType { diff --git a/src/AIAssistant/Models/ChangeType.cs b/src/AIAssist/Models/ChangeType.cs similarity index 69% rename from src/AIAssistant/Models/ChangeType.cs rename to src/AIAssist/Models/ChangeType.cs index 23e912f..816724a 100644 --- a/src/AIAssistant/Models/ChangeType.cs +++ b/src/AIAssist/Models/ChangeType.cs @@ -1,4 +1,4 @@ -namespace AIAssistant.Models; +namespace AIAssist.Models; public enum ChangeType { diff --git a/src/AIAssistant/Models/CodeBase.cs b/src/AIAssist/Models/CodeBase.cs similarity index 90% rename from src/AIAssistant/Models/CodeBase.cs rename to src/AIAssist/Models/CodeBase.cs index 51eaefd..47aa068 100644 --- a/src/AIAssistant/Models/CodeBase.cs +++ b/src/AIAssist/Models/CodeBase.cs @@ -1,4 +1,4 @@ -namespace AIAssistant.Models; +namespace AIAssist.Models; public class CodeBase { diff --git a/src/AIAssistant/Models/CodeEmbedding.cs b/src/AIAssist/Models/CodeEmbedding.cs similarity index 85% rename from src/AIAssistant/Models/CodeEmbedding.cs rename to src/AIAssist/Models/CodeEmbedding.cs index 098183d..0a16fb2 100644 --- a/src/AIAssistant/Models/CodeEmbedding.cs +++ b/src/AIAssist/Models/CodeEmbedding.cs @@ -1,4 +1,4 @@ -namespace AIAssistant.Models; +namespace AIAssist.Models; public class CodeEmbedding : CodeSummary { diff --git a/src/AIAssistant/Models/CodeSummary.cs b/src/AIAssist/Models/CodeSummary.cs similarity index 83% rename from src/AIAssistant/Models/CodeSummary.cs rename to src/AIAssist/Models/CodeSummary.cs index 512848a..899e3ed 100644 --- a/src/AIAssistant/Models/CodeSummary.cs +++ b/src/AIAssist/Models/CodeSummary.cs @@ -1,4 +1,4 @@ -namespace AIAssistant.Models; +namespace AIAssist.Models; public class CodeSummary : CodeBase { diff --git a/src/AIAssistant/Models/CommandType.cs b/src/AIAssist/Models/CommandType.cs similarity index 78% rename from src/AIAssistant/Models/CommandType.cs rename to src/AIAssist/Models/CommandType.cs index 1764819..7222adb 100644 --- a/src/AIAssistant/Models/CommandType.cs +++ b/src/AIAssist/Models/CommandType.cs @@ -1,4 +1,4 @@ -namespace AIAssistant.Models; +namespace AIAssist.Models; public enum CommandType { diff --git a/src/AIAssistant/Models/Context.cs b/src/AIAssist/Models/Context.cs similarity index 98% rename from src/AIAssistant/Models/Context.cs rename to src/AIAssist/Models/Context.cs index 6145e7d..475aead 100644 --- a/src/AIAssistant/Models/Context.cs +++ b/src/AIAssist/Models/Context.cs @@ -1,6 +1,6 @@ using TreeSitter.Bindings.CustomTypes.TreeParser; -namespace AIAssistant.Models; +namespace AIAssist.Models; public class Context { diff --git a/src/AIAssistant/Models/ContextTreeLevel.cs b/src/AIAssist/Models/ContextTreeLevel.cs similarity index 77% rename from src/AIAssistant/Models/ContextTreeLevel.cs rename to src/AIAssist/Models/ContextTreeLevel.cs index 5cd282c..4b9974d 100644 --- a/src/AIAssistant/Models/ContextTreeLevel.cs +++ b/src/AIAssist/Models/ContextTreeLevel.cs @@ -1,4 +1,4 @@ -namespace AIAssistant.Models; +namespace AIAssist.Models; public enum ContextTreeLevel { diff --git a/src/AIAssistant/Models/DiffResult.cs b/src/AIAssist/Models/DiffResult.cs similarity index 92% rename from src/AIAssistant/Models/DiffResult.cs rename to src/AIAssist/Models/DiffResult.cs index f108117..c2d9ad1 100644 --- a/src/AIAssistant/Models/DiffResult.cs +++ b/src/AIAssist/Models/DiffResult.cs @@ -1,4 +1,4 @@ -namespace AIAssistant.Models; +namespace AIAssist.Models; public class DiffResult { diff --git a/src/AIAssistant/Models/FileBatch.cs b/src/AIAssist/Models/FileBatch.cs similarity index 94% rename from src/AIAssistant/Models/FileBatch.cs rename to src/AIAssist/Models/FileBatch.cs index 719cec5..06dde99 100644 --- a/src/AIAssistant/Models/FileBatch.cs +++ b/src/AIAssist/Models/FileBatch.cs @@ -1,4 +1,4 @@ -namespace AIAssistant.Models; +namespace AIAssist.Models; /// /// Represents a batch of files and their chunks to be processed in a single embedding request. diff --git a/src/AIAssistant/Models/FileChunkGroup.cs b/src/AIAssist/Models/FileChunkGroup.cs similarity index 92% rename from src/AIAssistant/Models/FileChunkGroup.cs rename to src/AIAssist/Models/FileChunkGroup.cs index c980a88..c043e86 100644 --- a/src/AIAssistant/Models/FileChunkGroup.cs +++ b/src/AIAssist/Models/FileChunkGroup.cs @@ -1,6 +1,6 @@ using TreeSitter.Bindings.CustomTypes.TreeParser; -namespace AIAssistant.Models; +namespace AIAssist.Models; /// /// Represents a file and its associated chunks for embedding. diff --git a/src/AIAssistant/Models/Hunk.cs b/src/AIAssist/Models/Hunk.cs similarity index 91% rename from src/AIAssistant/Models/Hunk.cs rename to src/AIAssist/Models/Hunk.cs index fde12db..577d2e6 100644 --- a/src/AIAssistant/Models/Hunk.cs +++ b/src/AIAssist/Models/Hunk.cs @@ -1,4 +1,4 @@ -namespace AIAssistant.Models; +namespace AIAssist.Models; public class Hunk { diff --git a/src/AIAssistant/Models/Options/AppOptions.cs b/src/AIAssist/Models/Options/AppOptions.cs similarity index 93% rename from src/AIAssistant/Models/Options/AppOptions.cs rename to src/AIAssist/Models/Options/AppOptions.cs index 87d19e0..f47fa81 100644 --- a/src/AIAssistant/Models/Options/AppOptions.cs +++ b/src/AIAssist/Models/Options/AppOptions.cs @@ -1,4 +1,4 @@ -namespace AIAssistant.Models.Options; +namespace AIAssist.Models.Options; //The configuration system uses binding and convention-based matching, not JSON deserialization attributes like JsonPropertyName. diff --git a/src/AIAssistant/Models/PromptInformation.cs b/src/AIAssist/Models/PromptInformation.cs similarity index 81% rename from src/AIAssistant/Models/PromptInformation.cs rename to src/AIAssist/Models/PromptInformation.cs index 4f26d15..aa35ca0 100644 --- a/src/AIAssistant/Models/PromptInformation.cs +++ b/src/AIAssist/Models/PromptInformation.cs @@ -1,5 +1,5 @@ using Clients.Models; -namespace AIAssistant.Models; +namespace AIAssist.Models; public record PromptInformation(string EmbeddedResourceName, CommandType CommandType, CodeDiffType? DiffType); diff --git a/src/AIAssistant/Models/Replacement.cs b/src/AIAssist/Models/Replacement.cs similarity index 95% rename from src/AIAssistant/Models/Replacement.cs rename to src/AIAssist/Models/Replacement.cs index 1f12cbb..68a2083 100644 --- a/src/AIAssistant/Models/Replacement.cs +++ b/src/AIAssist/Models/Replacement.cs @@ -1,4 +1,4 @@ -namespace AIAssistant.Models; +namespace AIAssist.Models; public class Replacement(int originalFileStartIndex, int originalFileEndIndex, List? newLines) { diff --git a/src/AIAssistant/Program.cs b/src/AIAssist/Program.cs similarity index 97% rename from src/AIAssistant/Program.cs rename to src/AIAssist/Program.cs index 582862e..e6dbeba 100644 --- a/src/AIAssistant/Program.cs +++ b/src/AIAssist/Program.cs @@ -1,5 +1,5 @@ -using AIAssistant.Commands; -using AIAssistant.Extensions; +using AIAssist.Commands; +using AIAssist.Extensions; using BuildingBlocks.SpectreConsole; using Microsoft.Extensions.Hosting; using Serilog; diff --git a/src/AIAssistant/Prompts/PromptManager.cs b/src/AIAssist/Prompts/PromptManager.cs similarity index 90% rename from src/AIAssistant/Prompts/PromptManager.cs rename to src/AIAssist/Prompts/PromptManager.cs index 49782b2..d195469 100644 --- a/src/AIAssistant/Prompts/PromptManager.cs +++ b/src/AIAssist/Prompts/PromptManager.cs @@ -1,11 +1,11 @@ using System.Reflection; using System.Text; -using AIAssistant.Contracts; -using AIAssistant.Models; +using AIAssist.Contracts; +using AIAssist.Models; using Clients.Models; using Humanizer; -namespace AIAssistant.Prompts; +namespace AIAssist.Prompts; public class PromptManager(IFileService fileService) : IPromptManager { @@ -21,7 +21,7 @@ public string RenderPromptTemplate(string promptTemplateName, object? replacemen { var assembly = Assembly.GetExecutingAssembly(); var templateName = $"{promptTemplateName.ToLowerInvariant()}.template"; - var fullResourceName = $"{nameof(AIAssistant)}.{AIAssistantConstants.PromptsTemplatesNamespace}.{templateName}"; + var fullResourceName = $"{nameof(AIAssist)}.{AIAssistConstants.PromptsTemplatesNamespace}.{templateName}"; // Render the embedded template string processedTemplate = fileService.RenderEmbeddedResource(assembly, fullResourceName, replacements); @@ -106,7 +106,7 @@ public string FilesAddedToChat(IEnumerable fullFileContents) public string AddCodeBlock(string treeSitterCode) { var renderBlock = RenderPromptTemplate( - AIAssistantConstants.Prompts.CodeBlockTemplate, + AIAssistConstants.Prompts.CodeBlockTemplate, new { treeSitterCode = treeSitterCode } ); @@ -116,7 +116,7 @@ public string AddCodeBlock(string treeSitterCode) public string GetEmbeddingInputString(string treeSitterCode) { return RenderPromptTemplate( - AIAssistantConstants.Prompts.CodeEmbeddingTemplate, + AIAssistConstants.Prompts.CodeEmbeddingTemplate, new { treeSitterCode = treeSitterCode } ); } @@ -124,14 +124,14 @@ public string GetEmbeddingInputString(string treeSitterCode) public string CreateLLMContext(IEnumerable codeBlocks) { return RenderPromptTemplate( - AIAssistantConstants.Prompts.CodeContextTemplate, + AIAssistConstants.Prompts.CodeContextTemplate, new { codeContext = string.Join(Environment.NewLine, codeBlocks) } ); } private string AskMoreContextPrompt() { - var renderBlock = RenderPromptTemplate(AIAssistantConstants.Prompts.AskMoreContext, null); + var renderBlock = RenderPromptTemplate(AIAssistConstants.Prompts.AskMoreContext, null); return renderBlock; } diff --git a/src/AIAssistant/Prompts/Templates/ask-more-context.template b/src/AIAssist/Prompts/Templates/ask-more-context.template similarity index 100% rename from src/AIAssistant/Prompts/Templates/ask-more-context.template rename to src/AIAssist/Prompts/Templates/ask-more-context.template diff --git a/src/AIAssistant/Prompts/Templates/code-assist-search-replace-diff.template b/src/AIAssist/Prompts/Templates/code-assist-search-replace-diff.template similarity index 100% rename from src/AIAssistant/Prompts/Templates/code-assist-search-replace-diff.template rename to src/AIAssist/Prompts/Templates/code-assist-search-replace-diff.template diff --git a/src/AIAssistant/Prompts/Templates/code-assistant-code-block-diff.template b/src/AIAssist/Prompts/Templates/code-assistant-code-block-diff.template similarity index 100% rename from src/AIAssistant/Prompts/Templates/code-assistant-code-block-diff.template rename to src/AIAssist/Prompts/Templates/code-assistant-code-block-diff.template diff --git a/src/AIAssistant/Prompts/Templates/code-assistant-unified-diff.template b/src/AIAssist/Prompts/Templates/code-assistant-unified-diff.template similarity index 100% rename from src/AIAssistant/Prompts/Templates/code-assistant-unified-diff.template rename to src/AIAssist/Prompts/Templates/code-assistant-unified-diff.template diff --git a/src/AIAssistant/Prompts/Templates/code-block.template b/src/AIAssist/Prompts/Templates/code-block.template similarity index 100% rename from src/AIAssistant/Prompts/Templates/code-block.template rename to src/AIAssist/Prompts/Templates/code-block.template diff --git a/src/AIAssistant/Prompts/Templates/code-context.template b/src/AIAssist/Prompts/Templates/code-context.template similarity index 100% rename from src/AIAssistant/Prompts/Templates/code-context.template rename to src/AIAssist/Prompts/Templates/code-context.template diff --git a/src/AIAssistant/Prompts/Templates/code-embedding.template b/src/AIAssist/Prompts/Templates/code-embedding.template similarity index 100% rename from src/AIAssistant/Prompts/Templates/code-embedding.template rename to src/AIAssist/Prompts/Templates/code-embedding.template diff --git a/src/AIAssistant/Services/ChatSessionManager.cs b/src/AIAssist/Services/ChatSessionManager.cs similarity index 90% rename from src/AIAssistant/Services/ChatSessionManager.cs rename to src/AIAssist/Services/ChatSessionManager.cs index b40c082..4d865a9 100644 --- a/src/AIAssistant/Services/ChatSessionManager.cs +++ b/src/AIAssist/Services/ChatSessionManager.cs @@ -1,8 +1,7 @@ -using AIAssistant.Chat.Models; -using AIAssistant.Contracts; -using AIAssistant.Models; +using AIAssist.Chat.Models; +using AIAssist.Contracts; -namespace AIAssistant.Services; +namespace AIAssist.Services; public class ChatSessionManager : IChatSessionManager { diff --git a/src/AIAssistant/Services/CodeAssistStrategies/CodeAssistFactory.cs b/src/AIAssist/Services/CodeAssistStrategies/CodeAssistFactory.cs similarity index 72% rename from src/AIAssistant/Services/CodeAssistStrategies/CodeAssistFactory.cs rename to src/AIAssist/Services/CodeAssistStrategies/CodeAssistFactory.cs index 943c017..ea70b01 100644 --- a/src/AIAssistant/Services/CodeAssistStrategies/CodeAssistFactory.cs +++ b/src/AIAssist/Services/CodeAssistStrategies/CodeAssistFactory.cs @@ -1,7 +1,7 @@ -using AIAssistant.Contracts.CodeAssist; +using AIAssist.Contracts.CodeAssist; using Clients.Models; -namespace AIAssistant.Services.CodeAssistStrategies; +namespace AIAssist.Services.CodeAssistStrategies; public class CodeAssistFactory(IDictionary strategies) : ICodeAssistFactory { diff --git a/src/AIAssistant/Services/CodeAssistStrategies/EmbeddingCodeAssist.cs b/src/AIAssist/Services/CodeAssistStrategies/EmbeddingCodeAssist.cs similarity index 95% rename from src/AIAssistant/Services/CodeAssistStrategies/EmbeddingCodeAssist.cs rename to src/AIAssist/Services/CodeAssistStrategies/EmbeddingCodeAssist.cs index 5c5a153..7deb13c 100644 --- a/src/AIAssistant/Services/CodeAssistStrategies/EmbeddingCodeAssist.cs +++ b/src/AIAssist/Services/CodeAssistStrategies/EmbeddingCodeAssist.cs @@ -1,8 +1,8 @@ -using AIAssistant.Chat.Models; -using AIAssistant.Contracts; -using AIAssistant.Contracts.CodeAssist; -using AIAssistant.Models; -using AIAssistant.Models.Options; +using AIAssist.Chat.Models; +using AIAssist.Contracts; +using AIAssist.Contracts.CodeAssist; +using AIAssist.Models; +using AIAssist.Models.Options; using BuildingBlocks.SpectreConsole.Contracts; using BuildingBlocks.Utils; using Humanizer; @@ -10,7 +10,7 @@ using Spectre.Console; using TreeSitter.Bindings.CustomTypes.TreeParser; -namespace AIAssistant.Services.CodeAssistStrategies; +namespace AIAssist.Services.CodeAssistStrategies; public class EmbeddingCodeAssist( IEmbeddingService embeddingService, diff --git a/src/AIAssistant/Services/CodeAssistStrategies/TreeSitterCodeAssistSummary.cs b/src/AIAssist/Services/CodeAssistStrategies/TreeSitterCodeAssistSummary.cs similarity index 94% rename from src/AIAssistant/Services/CodeAssistStrategies/TreeSitterCodeAssistSummary.cs rename to src/AIAssist/Services/CodeAssistStrategies/TreeSitterCodeAssistSummary.cs index 14db845..debe278 100644 --- a/src/AIAssistant/Services/CodeAssistStrategies/TreeSitterCodeAssistSummary.cs +++ b/src/AIAssist/Services/CodeAssistStrategies/TreeSitterCodeAssistSummary.cs @@ -1,8 +1,8 @@ using System.Text; -using AIAssistant.Contracts; -using AIAssistant.Contracts.CodeAssist; +using AIAssist.Contracts; +using AIAssist.Contracts.CodeAssist; -namespace AIAssistant.Services.CodeAssistStrategies; +namespace AIAssist.Services.CodeAssistStrategies; public class TreeSitterCodeAssistSummary( IContextService contextService, diff --git a/src/AIAssistant/Services/CodeAssistantManager.cs b/src/AIAssist/Services/CodeAssistantManager.cs similarity index 91% rename from src/AIAssistant/Services/CodeAssistantManager.cs rename to src/AIAssist/Services/CodeAssistantManager.cs index b953f0a..ee09283 100644 --- a/src/AIAssistant/Services/CodeAssistantManager.cs +++ b/src/AIAssist/Services/CodeAssistantManager.cs @@ -1,10 +1,9 @@ -using System.Collections; using System.Text.RegularExpressions; -using AIAssistant.Contracts.CodeAssist; -using AIAssistant.Contracts.Diff; -using AIAssistant.Models; +using AIAssist.Contracts.CodeAssist; +using AIAssist.Contracts.Diff; +using AIAssist.Models; -namespace AIAssistant.Services; +namespace AIAssist.Services; public class CodeAssistantManager(ICodeAssist codeAssist, ICodeDiffManager diffManager) : ICodeAssistantManager { @@ -18,7 +17,7 @@ public Task LoadCodeFiles(string contextWorkingDirectory, IList? codeFil return codeAssist.QueryChatCompletionAsync(userQuery); } - public Task AddOrUpdateCodeFilesToCache(IList? codeFiles) + public Task AddOrUpdateCodeFiles(IList? codeFiles) { return codeAssist.AddOrUpdateCodeFiles(codeFiles); } diff --git a/src/AIAssistant/Services/CodeFilesTreeGeneratorService.cs b/src/AIAssist/Services/CodeFilesTreeGeneratorService.cs similarity index 98% rename from src/AIAssistant/Services/CodeFilesTreeGeneratorService.cs rename to src/AIAssist/Services/CodeFilesTreeGeneratorService.cs index 50aeb13..ea2e7ee 100644 --- a/src/AIAssistant/Services/CodeFilesTreeGeneratorService.cs +++ b/src/AIAssist/Services/CodeFilesTreeGeneratorService.cs @@ -1,11 +1,11 @@ -using AIAssistant.Contracts; -using AIAssistant.Models.Options; +using AIAssist.Contracts; +using AIAssist.Models.Options; using BuildingBlocks.Utils; using Microsoft.Extensions.Options; using TreeSitter.Bindings.Contracts; using TreeSitter.Bindings.CustomTypes.TreeParser; -namespace AIAssistant.Services; +namespace AIAssist.Services; public class CodeFilesTreeGeneratorService( ITreeSitterCodeCaptureService treeSitterCodeCaptureService, diff --git a/src/AIAssistant/Services/ContextService.cs b/src/AIAssist/Services/ContextService.cs similarity index 99% rename from src/AIAssistant/Services/ContextService.cs rename to src/AIAssist/Services/ContextService.cs index edb11ac..9ee1603 100644 --- a/src/AIAssistant/Services/ContextService.cs +++ b/src/AIAssist/Services/ContextService.cs @@ -1,10 +1,10 @@ -using AIAssistant.Contracts; -using AIAssistant.Models; -using AIAssistant.Models.Options; +using AIAssist.Contracts; +using AIAssist.Models; +using AIAssist.Models.Options; using BuildingBlocks.Utils; using Microsoft.Extensions.Options; -namespace AIAssistant.Services; +namespace AIAssist.Services; public class ContextService( IOptions appOptions, diff --git a/src/AIAssistant/Services/EmbeddingService.cs b/src/AIAssist/Services/EmbeddingService.cs similarity index 92% rename from src/AIAssistant/Services/EmbeddingService.cs rename to src/AIAssist/Services/EmbeddingService.cs index 96cd63d..99a3f65 100644 --- a/src/AIAssistant/Services/EmbeddingService.cs +++ b/src/AIAssist/Services/EmbeddingService.cs @@ -1,12 +1,12 @@ -using AIAssistant.Chat.Models; -using AIAssistant.Contracts; -using AIAssistant.Data; -using AIAssistant.Dtos; -using AIAssistant.Models; +using AIAssist.Chat.Models; +using AIAssist.Contracts; +using AIAssist.Data; +using AIAssist.Dtos; +using AIAssist.Models; using BuildingBlocks.LLM; using TreeSitter.Bindings.CustomTypes.TreeParser; -namespace AIAssistant.Services; +namespace AIAssist.Services; public class EmbeddingService( ILLMClientManager llmClientManager, @@ -23,15 +23,16 @@ ChatSession chatSession int totalTokens = 0; decimal totalCost = 0; - var fileEmbeddingsMap = new Dictionary>>(); + var fileEmbeddingsMap = new Dictionary>>(StringComparer.Ordinal); // Group files and manage batching using the updated tokenizer logic - var fileBatches = await BatchFilesByTokenLimitAsync(codeFilesMap, maxBatchTokens: 8192); + var fileBatches = await BatchFilesByTokenLimitAsync(codeFilesMap, maxBatchTokens: 8192).ConfigureAwait(false); foreach (var batch in fileBatches) { var batchInputs = batch.GetBatchInputs(); - var embeddingResult = await llmClientManager.GetEmbeddingAsync(batchInputs, null); + var embeddingResult = await llmClientManager.GetEmbeddingAsync(batchInputs, null).ConfigureAwait(false); + await Task.Delay(TimeSpan.FromSeconds(1)).ConfigureAwait(false); int resultIndex = 0; foreach (var fileChunkGroup in batch.Files) @@ -84,7 +85,7 @@ ChatSession chatSession ); } - await codeEmbeddingsRepository.AddOrUpdateCodeEmbeddings(codeEmbeddings); + await codeEmbeddingsRepository.AddOrUpdateCodeEmbeddings(codeEmbeddings).ConfigureAwait(false); return new AddEmbeddingsForFilesResult(totalTokens, totalCost); } @@ -92,7 +93,7 @@ ChatSession chatSession public async Task GetRelatedEmbeddings(string userQuery, ChatSession chatSession) { // Generate embedding for user input based on LLM apis - var embeddingsResult = await GenerateEmbeddingForUserInput(userQuery); + var embeddingsResult = await GenerateEmbeddingForUserInput(userQuery).ConfigureAwait(false); // Find relevant code based on the user query var relevantCodes = codeEmbeddingsRepository.Query( @@ -119,7 +120,7 @@ public IEnumerable QueryByFilter( public async Task GenerateEmbeddingForUserInput(string userInput) { - return await llmClientManager.GetEmbeddingAsync(new List { userInput }, null); + return await llmClientManager.GetEmbeddingAsync(new List { userInput }, null).ConfigureAwait(false); } private async Task> BatchFilesByTokenLimitAsync( @@ -134,10 +135,10 @@ int maxBatchTokens { // Convert the full code to an input string and split into chunks var input = promptManager.GetEmbeddingInputString(file.TreeSitterFullCode); - var chunks = await SplitTextIntoChunksAsync(input, maxTokens: 8192); + var chunks = await SplitTextIntoChunksAsync(input, maxTokens: 8192).ConfigureAwait(false); var tokenCountTasks = chunks.Select(chunk => tokenizer.GetTokenCount(chunk)); - var tokenCounts = await Task.WhenAll(tokenCountTasks); + var tokenCounts = await Task.WhenAll(tokenCountTasks).ConfigureAwait(false); // Pair chunks with their token counts var chunkWithTokens = chunks.Zip( @@ -195,7 +196,7 @@ private async Task> SplitTextIntoChunksAsync(string text, int maxTo if (currentChunk.Count % 50 == 0 || currentChunk.Count == words.Length) { var currentText = string.Join(" ", currentChunk); - var currentTokenCount = await tokenizer.GetTokenCount(currentText); + var currentTokenCount = await tokenizer.GetTokenCount(currentText).ConfigureAwait(false); if (currentTokenCount > maxTokens) { @@ -204,7 +205,7 @@ private async Task> SplitTextIntoChunksAsync(string text, int maxTo { currentChunk.RemoveAt(currentChunk.Count - 1); currentText = string.Join(" ", currentChunk); - currentTokenCount = await tokenizer.GetTokenCount(currentText); + currentTokenCount = await tokenizer.GetTokenCount(currentText).ConfigureAwait(false); } // Add the finalized chunk only if it fits the token limit @@ -224,7 +225,7 @@ private async Task> SplitTextIntoChunksAsync(string text, int maxTo if (currentChunk.Count > 0) { var finalText = string.Join(" ", currentChunk); - var finalTokenCount = await tokenizer.GetTokenCount(finalText); + var finalTokenCount = await tokenizer.GetTokenCount(finalText).ConfigureAwait(false); if (finalTokenCount <= maxTokens) { @@ -235,7 +236,7 @@ private async Task> SplitTextIntoChunksAsync(string text, int maxTo return chunks; } - private IList MergeEmbeddings(IList> embeddings) + private static IList MergeEmbeddings(IList> embeddings) { if (embeddings == null || embeddings.Count == 0) throw new ArgumentException("The embeddings list cannot be null or empty."); diff --git a/src/AIAssistant/Services/FileService.cs b/src/AIAssist/Services/FileService.cs similarity index 85% rename from src/AIAssistant/Services/FileService.cs rename to src/AIAssist/Services/FileService.cs index 7a6c3d2..5562550 100644 --- a/src/AIAssistant/Services/FileService.cs +++ b/src/AIAssist/Services/FileService.cs @@ -1,8 +1,8 @@ using System.Reflection; -using AIAssistant.Contracts; +using AIAssist.Contracts; using BuildingBlocks.Utils; -namespace AIAssistant.Services; +namespace AIAssist.Services; public class FileService : IFileService { @@ -25,7 +25,7 @@ public bool IsPathIgnored(string path) if (FilesUtilities.IsDirectory(path)) { // Check if the path doesn't end with a directory separator and add it, to detecting directory by regex matcher - if (!path.EndsWith(Path.DirectorySeparatorChar.ToString())) + if (!path.EndsWith(Path.DirectorySeparatorChar.ToString(), StringComparison.Ordinal)) { // Add the correct separator for the platform path += Path.DirectorySeparatorChar; @@ -51,12 +51,14 @@ public bool IsPathIgnored(string path) private void LoadIgnorePatterns() { var embeddedResourceIgnorePatterns = FilesUtilities.LoadEmbeddedResourceIgnorePatterns( - $"{nameof(AIAssistant)}..aiassistignore", + $"{nameof(AIAssist)}..aiassistignore", Assembly.GetExecutingAssembly() ); var dirIgnorePatterns = FilesUtilities.LoadIgnorePattersCurrentDirectory([".gitignore", ".aiassistignore"]); - var mergeIgnore = embeddedResourceIgnorePatterns.Union(dirIgnorePatterns).Distinct(); + var mergeIgnore = embeddedResourceIgnorePatterns + .Union(dirIgnorePatterns, StringComparer.Ordinal) + .Distinct(StringComparer.Ordinal); _gitignorePatterns.AddRange(mergeIgnore); } } diff --git a/src/AIAssistant/Services/LLMClientManager.cs b/src/AIAssist/Services/LLMClientManager.cs similarity index 97% rename from src/AIAssistant/Services/LLMClientManager.cs rename to src/AIAssist/Services/LLMClientManager.cs index 74c818e..4782d0e 100644 --- a/src/AIAssistant/Services/LLMClientManager.cs +++ b/src/AIAssist/Services/LLMClientManager.cs @@ -1,6 +1,6 @@ using System.Text; -using AIAssistant.Contracts; -using AIAssistant.Dtos; +using AIAssist.Contracts; +using AIAssist.Dtos; using BuildingBlocks.LLM; using Clients.Contracts; using Clients.Dtos; @@ -8,7 +8,7 @@ using Clients.Options; using Microsoft.Extensions.Options; -namespace AIAssistant.Services; +namespace AIAssist.Services; public class LLMClientManager : ILLMClientManager { diff --git a/src/AIAssistant/aiassist-config.json b/src/AIAssist/aiassist-config.json similarity index 100% rename from src/AIAssistant/aiassist-config.json rename to src/AIAssist/aiassist-config.json diff --git a/src/AIAssistant/AIAssistant.sln b/src/AIAssistant/AIAssistant.sln deleted file mode 100644 index 918700e..0000000 --- a/src/AIAssistant/AIAssistant.sln +++ /dev/null @@ -1,42 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.5.002.0 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AIAssistant", "AIAssistant.csproj", "{A3D7EDB7-E711-4A19-8A1B-2C30EC27FEF3}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "bin", "bin", "{8BF6246B-F228-4C8F-8232-E4C20FDD40A9}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Debug", "Debug", "{54EE5F2E-143B-4156-8C60-B51510AC5F0C}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "net8.0", "net8.0", "{89EB6325-C4B8-4EA7-B02E-7E7FA4149086}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Calculator", "bin\Debug\net8.0\Calculator\Calculator.csproj", "{2FA0CC8D-539A-4666-AC12-1DA249DFAF3E}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {A3D7EDB7-E711-4A19-8A1B-2C30EC27FEF3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A3D7EDB7-E711-4A19-8A1B-2C30EC27FEF3}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A3D7EDB7-E711-4A19-8A1B-2C30EC27FEF3}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A3D7EDB7-E711-4A19-8A1B-2C30EC27FEF3}.Release|Any CPU.Build.0 = Release|Any CPU - {2FA0CC8D-539A-4666-AC12-1DA249DFAF3E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {2FA0CC8D-539A-4666-AC12-1DA249DFAF3E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2FA0CC8D-539A-4666-AC12-1DA249DFAF3E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {2FA0CC8D-539A-4666-AC12-1DA249DFAF3E}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(NestedProjects) = preSolution - {54EE5F2E-143B-4156-8C60-B51510AC5F0C} = {8BF6246B-F228-4C8F-8232-E4C20FDD40A9} - {89EB6325-C4B8-4EA7-B02E-7E7FA4149086} = {54EE5F2E-143B-4156-8C60-B51510AC5F0C} - {2FA0CC8D-539A-4666-AC12-1DA249DFAF3E} = {89EB6325-C4B8-4EA7-B02E-7E7FA4149086} - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {97132996-ACD6-49C3-B288-CB310A0DA717} - EndGlobalSection -EndGlobal diff --git a/src/AIAssistant/Commands/PlanCommand.cs b/src/AIAssistant/Commands/PlanCommand.cs deleted file mode 100644 index ff589e6..0000000 --- a/src/AIAssistant/Commands/PlanCommand.cs +++ /dev/null @@ -1,3 +0,0 @@ -namespace AIAssistant.Commands; - -public class PlanCommand { } diff --git a/src/BuildingBlocks/DotEnv/DotEnv.cs b/src/BuildingBlocks/Environments/DotEnv.cs similarity index 94% rename from src/BuildingBlocks/DotEnv/DotEnv.cs rename to src/BuildingBlocks/Environments/DotEnv.cs index 2960bb8..f06e4e5 100644 --- a/src/BuildingBlocks/DotEnv/DotEnv.cs +++ b/src/BuildingBlocks/Environments/DotEnv.cs @@ -1,4 +1,4 @@ -namespace BuildingBlocks.DotEnv; +namespace BuildingBlocks.Environments; public static class DotEnv { diff --git a/src/Clients/CacheModels.cs b/src/Clients/CacheModels.cs index 06437d9..c188f34 100644 --- a/src/Clients/CacheModels.cs +++ b/src/Clients/CacheModels.cs @@ -24,8 +24,11 @@ public CacheModels(IOptions modelOptions, IOptionsnet8.0 enable enable + x64 @@ -16,8 +17,30 @@ All + + git + $(AssemblyName) + AIAssist + AIAssist + Mehdi Hadeli + Context aware AI coding assistant inside terminal to help in code development, code explanation, code refactor and review, bug fix and chat with supporting local and online language models. + ai ollama gpt pgt-4o dotnet csharp azure-ai + $(SolutionDir)nugets + readme.md + aiassist.png + LICENSE + Apache-2.0 + https://github.com/mehdihadeli/AIAssist + https://github.com/mehdihadeli/AIAssist + git + main + true + true + Copyright (c) 2024 Mehdi Hadeli + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/Directory.Packages.props b/src/Directory.Packages.props index c97e07a..52c3e89 100644 --- a/src/Directory.Packages.props +++ b/src/Directory.Packages.props @@ -45,4 +45,7 @@ + + + \ No newline at end of file diff --git a/src/TreeSitter.Bindings/TreeSitter.Bindings.csproj b/src/TreeSitter.Bindings/TreeSitter.Bindings.csproj index 59e53f4..5aa6f2e 100644 --- a/src/TreeSitter.Bindings/TreeSitter.Bindings.csproj +++ b/src/TreeSitter.Bindings/TreeSitter.Bindings.csproj @@ -4,10 +4,7 @@ true - - - - + diff --git a/tests/IntegrationTests/AIAssistant.IntegrationTests/ApplicationFixture.cs b/tests/IntegrationTests/AIAssistant.IntegrationTests/ApplicationFixture.cs index 0bc5850..31d5c29 100644 --- a/tests/IntegrationTests/AIAssistant.IntegrationTests/ApplicationFixture.cs +++ b/tests/IntegrationTests/AIAssistant.IntegrationTests/ApplicationFixture.cs @@ -1,4 +1,4 @@ -using AIAssistant.Extensions; +using AIAssist.Extensions; namespace AIAssistant.IntegrationTests; diff --git a/tests/IntegrationTests/AIAssistant.IntegrationTests/Services/CodeAssistStrategies/EmbeddingCodeAssistStrategyIntegrationTests.cs b/tests/IntegrationTests/AIAssistant.IntegrationTests/Services/CodeAssistStrategies/EmbeddingCodeAssistStrategyIntegrationTests.cs index 2da8f00..2892dc1 100644 --- a/tests/IntegrationTests/AIAssistant.IntegrationTests/Services/CodeAssistStrategies/EmbeddingCodeAssistStrategyIntegrationTests.cs +++ b/tests/IntegrationTests/AIAssistant.IntegrationTests/Services/CodeAssistStrategies/EmbeddingCodeAssistStrategyIntegrationTests.cs @@ -1,5 +1,5 @@ -using AIAssistant.Contracts; -using AIAssistant.Contracts.CodeAssist; +using AIAssist.Contracts; +using AIAssist.Contracts.CodeAssist; using Clients.Models; using FluentAssertions; using Microsoft.Extensions.DependencyInjection; diff --git a/tests/IntegrationTests/AIAssistant.IntegrationTests/Services/CodeAssistantManagerIntegrationTests.cs b/tests/IntegrationTests/AIAssistant.IntegrationTests/Services/CodeAssistantManagerIntegrationTests.cs index 004b1cf..a7fb8d3 100644 --- a/tests/IntegrationTests/AIAssistant.IntegrationTests/Services/CodeAssistantManagerIntegrationTests.cs +++ b/tests/IntegrationTests/AIAssistant.IntegrationTests/Services/CodeAssistantManagerIntegrationTests.cs @@ -1,7 +1,6 @@ using System.Text; -using AIAssistant.Chat.Models; -using AIAssistant.Contracts; -using AIAssistant.Contracts.CodeAssist; +using AIAssist.Contracts; +using AIAssist.Contracts.CodeAssist; using FluentAssertions; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; diff --git a/tests/IntegrationTests/Clients.IntegrationTests/ApplicationFixture.cs b/tests/IntegrationTests/Clients.IntegrationTests/ApplicationFixture.cs index fa44a4a..661c4e5 100644 --- a/tests/IntegrationTests/Clients.IntegrationTests/ApplicationFixture.cs +++ b/tests/IntegrationTests/Clients.IntegrationTests/ApplicationFixture.cs @@ -1,4 +1,4 @@ -using AIAssistant.Extensions; +using AIAssist.Extensions; using Microsoft.Extensions.Hosting; namespace Clients.IntegrationTests; diff --git a/tests/IntegrationTests/Clients.IntegrationTests/Ollama/OllamaClientStrategyIntegrationTests.cs b/tests/IntegrationTests/Clients.IntegrationTests/Ollama/OllamaClientStrategyIntegrationTests.cs index cd681ae..dd518cb 100644 --- a/tests/IntegrationTests/Clients.IntegrationTests/Ollama/OllamaClientStrategyIntegrationTests.cs +++ b/tests/IntegrationTests/Clients.IntegrationTests/Ollama/OllamaClientStrategyIntegrationTests.cs @@ -1,4 +1,3 @@ -using AIAssistant.Chat.Models; using Clients.Contracts; using Clients.Dtos; using Clients.Models; diff --git a/tests/IntegrationTests/Clients.IntegrationTests/OpenAI/OpenAIClientStrategyIntegrationTests.cs b/tests/IntegrationTests/Clients.IntegrationTests/OpenAI/OpenAIClientStrategyIntegrationTests.cs index 23399a1..1ec600a 100644 --- a/tests/IntegrationTests/Clients.IntegrationTests/OpenAI/OpenAIClientStrategyIntegrationTests.cs +++ b/tests/IntegrationTests/Clients.IntegrationTests/OpenAI/OpenAIClientStrategyIntegrationTests.cs @@ -1,4 +1,3 @@ -using AIAssistant.Chat.Models; using Clients.Contracts; using Clients.Dtos; using Clients.Models; diff --git a/tests/UnitTests/AIAssistant.UnitTests/Diff/CodeDiffUpdaterTests.cs b/tests/UnitTests/AIAssistant.UnitTests/Diff/CodeDiffUpdaterTests.cs index e08c7a1..e15aa96 100644 --- a/tests/UnitTests/AIAssistant.UnitTests/Diff/CodeDiffUpdaterTests.cs +++ b/tests/UnitTests/AIAssistant.UnitTests/Diff/CodeDiffUpdaterTests.cs @@ -1,5 +1,5 @@ -using AIAssistant.Contracts.Diff; -using AIAssistant.Diff; +using AIAssist.Contracts.Diff; +using AIAssist.Diff; using BuildingBlocks.SpectreConsole; using FluentAssertions; using Spectre.Console; diff --git a/tests/UnitTests/AIAssistant.UnitTests/Diff/UnifiedCodeDiffParserTests.cs b/tests/UnitTests/AIAssistant.UnitTests/Diff/UnifiedCodeDiffParserTests.cs index 4ee373a..3f3d116 100644 --- a/tests/UnitTests/AIAssistant.UnitTests/Diff/UnifiedCodeDiffParserTests.cs +++ b/tests/UnitTests/AIAssistant.UnitTests/Diff/UnifiedCodeDiffParserTests.cs @@ -1,5 +1,5 @@ -using AIAssistant.Diff; -using AIAssistant.Models; +using AIAssist.Diff; +using AIAssist.Models; using FluentAssertions; namespace AIAssistant.UnitTests.Diff; diff --git a/tests/UnitTests/AIAssistant.UnitTests/Services/CodeLoaderServiceTests.cs b/tests/UnitTests/AIAssistant.UnitTests/Services/CodeLoaderServiceTests.cs index 0e41219..54a4ea2 100644 --- a/tests/UnitTests/AIAssistant.UnitTests/Services/CodeLoaderServiceTests.cs +++ b/tests/UnitTests/AIAssistant.UnitTests/Services/CodeLoaderServiceTests.cs @@ -1,10 +1,9 @@ -using AIAssistant.Models.Options; -using AIAssistant.Services; using FluentAssertions; using Microsoft.Extensions.Options; namespace AIAssistant.UnitTests.Services; + // // public class CodeLoaderServiceTests : IAsyncLifetime // { diff --git a/version.json b/version.json new file mode 100644 index 0000000..33f7ba2 --- /dev/null +++ b/version.json @@ -0,0 +1,18 @@ +{ + "$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json", + "version": "1.0.0-preview", + "gitCommitIdShortAutoMinimum": 7, + "nugetPackageVersion": { + "semVer": 2 + }, + "publicReleaseRefSpec": ["^refs/tags/v\\d+\\.\\d+"], + "release": { + "firstUnstableTag": "preview", + "versionIncrement": "minor" + }, + "cloudBuild": { + "buildNumber": { + "enabled": true + } + } +} \ No newline at end of file