@vybestack/llxprt-code-tools 0.10.0-nightly.260613.1adad3b34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/README.md +294 -0
- package/dist/.last_build +0 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/src/__tests__/fixtures/filesystem-tool-fixtures.d.ts +29 -0
- package/dist/src/__tests__/fixtures/filesystem-tool-fixtures.js +30 -0
- package/dist/src/__tests__/fixtures/filesystem-tool-fixtures.js.map +1 -0
- package/dist/src/__tests__/fixtures/key-storage-fixtures.d.ts +39 -0
- package/dist/src/__tests__/fixtures/key-storage-fixtures.js +53 -0
- package/dist/src/__tests__/fixtures/key-storage-fixtures.js.map +1 -0
- package/dist/src/__tests__/fixtures/provider-formatting-fixtures.d.ts +140 -0
- package/dist/src/__tests__/fixtures/provider-formatting-fixtures.js +157 -0
- package/dist/src/__tests__/fixtures/provider-formatting-fixtures.js.map +1 -0
- package/dist/src/__tests__/red-test-helpers.d.ts +14 -0
- package/dist/src/__tests__/red-test-helpers.js +18 -0
- package/dist/src/__tests__/red-test-helpers.js.map +1 -0
- package/dist/src/formatters/IToolFormatter.d.ts +84 -0
- package/dist/src/formatters/IToolFormatter.js +6 -0
- package/dist/src/formatters/IToolFormatter.js.map +1 -0
- package/dist/src/formatters/ToolFormatter.d.ts +94 -0
- package/dist/src/formatters/ToolFormatter.js +379 -0
- package/dist/src/formatters/ToolFormatter.js.map +1 -0
- package/dist/src/formatters/ToolIdStrategy.d.ts +79 -0
- package/dist/src/formatters/ToolIdStrategy.js +173 -0
- package/dist/src/formatters/ToolIdStrategy.js.map +1 -0
- package/dist/src/formatters/doubleEscapeUtils.d.ts +46 -0
- package/dist/src/formatters/doubleEscapeUtils.js +223 -0
- package/dist/src/formatters/doubleEscapeUtils.js.map +1 -0
- package/dist/src/formatters/index.d.ts +21 -0
- package/dist/src/formatters/index.js +12 -0
- package/dist/src/formatters/index.js.map +1 -0
- package/dist/src/formatters/toolIdNormalization.d.ts +28 -0
- package/dist/src/formatters/toolIdNormalization.js +97 -0
- package/dist/src/formatters/toolIdNormalization.js.map +1 -0
- package/dist/src/formatters/toolNameUtils.d.ts +43 -0
- package/dist/src/formatters/toolNameUtils.js +143 -0
- package/dist/src/formatters/toolNameUtils.js.map +1 -0
- package/dist/src/index.d.ts +88 -0
- package/dist/src/index.js +68 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/interfaces/IAsyncTaskService.d.ts +57 -0
- package/dist/src/interfaces/IAsyncTaskService.js +6 -0
- package/dist/src/interfaces/IAsyncTaskService.js.map +1 -0
- package/dist/src/interfaces/IIdeService.d.ts +62 -0
- package/dist/src/interfaces/IIdeService.js +6 -0
- package/dist/src/interfaces/IIdeService.js.map +1 -0
- package/dist/src/interfaces/ILspService.d.ts +54 -0
- package/dist/src/interfaces/ILspService.js +6 -0
- package/dist/src/interfaces/ILspService.js.map +1 -0
- package/dist/src/interfaces/IMcpToolService.d.ts +47 -0
- package/dist/src/interfaces/IMcpToolService.js +6 -0
- package/dist/src/interfaces/IMcpToolService.js.map +1 -0
- package/dist/src/interfaces/IPromptRegistryService.d.ts +51 -0
- package/dist/src/interfaces/IPromptRegistryService.js +6 -0
- package/dist/src/interfaces/IPromptRegistryService.js.map +1 -0
- package/dist/src/interfaces/ISettingsService.d.ts +50 -0
- package/dist/src/interfaces/ISettingsService.js +6 -0
- package/dist/src/interfaces/ISettingsService.js.map +1 -0
- package/dist/src/interfaces/IShellExecutionService.d.ts +55 -0
- package/dist/src/interfaces/IShellExecutionService.js +6 -0
- package/dist/src/interfaces/IShellExecutionService.js.map +1 -0
- package/dist/src/interfaces/IShellToolHost.d.ts +176 -0
- package/dist/src/interfaces/IShellToolHost.js +6 -0
- package/dist/src/interfaces/IShellToolHost.js.map +1 -0
- package/dist/src/interfaces/ISkillService.d.ts +69 -0
- package/dist/src/interfaces/ISkillService.js +6 -0
- package/dist/src/interfaces/ISkillService.js.map +1 -0
- package/dist/src/interfaces/IStorageService.d.ts +42 -0
- package/dist/src/interfaces/IStorageService.js +6 -0
- package/dist/src/interfaces/IStorageService.js.map +1 -0
- package/dist/src/interfaces/ISubagentService.d.ts +112 -0
- package/dist/src/interfaces/ISubagentService.js +6 -0
- package/dist/src/interfaces/ISubagentService.js.map +1 -0
- package/dist/src/interfaces/ITaskToolHost.d.ts +185 -0
- package/dist/src/interfaces/ITaskToolHost.js +6 -0
- package/dist/src/interfaces/ITaskToolHost.js.map +1 -0
- package/dist/src/interfaces/ITodoService.d.ts +79 -0
- package/dist/src/interfaces/ITodoService.js +6 -0
- package/dist/src/interfaces/ITodoService.js.map +1 -0
- package/dist/src/interfaces/IToolHost.d.ts +91 -0
- package/dist/src/interfaces/IToolHost.js +6 -0
- package/dist/src/interfaces/IToolHost.js.map +1 -0
- package/dist/src/interfaces/IToolKeyStorage.d.ts +62 -0
- package/dist/src/interfaces/IToolKeyStorage.js +6 -0
- package/dist/src/interfaces/IToolKeyStorage.js.map +1 -0
- package/dist/src/interfaces/IToolMessageBus.d.ts +63 -0
- package/dist/src/interfaces/IToolMessageBus.js +6 -0
- package/dist/src/interfaces/IToolMessageBus.js.map +1 -0
- package/dist/src/interfaces/IToolRegistryHost.d.ts +43 -0
- package/dist/src/interfaces/IToolRegistryHost.js +6 -0
- package/dist/src/interfaces/IToolRegistryHost.js.map +1 -0
- package/dist/src/interfaces/IWebSearchService.d.ts +16 -0
- package/dist/src/interfaces/IWebSearchService.js +7 -0
- package/dist/src/interfaces/IWebSearchService.js.map +1 -0
- package/dist/src/interfaces/index.d.ts +33 -0
- package/dist/src/interfaces/index.js +6 -0
- package/dist/src/interfaces/index.js.map +1 -0
- package/dist/src/tools/activate-skill.d.ts +26 -0
- package/dist/src/tools/activate-skill.js +121 -0
- package/dist/src/tools/activate-skill.js.map +1 -0
- package/dist/src/tools/apply-patch.d.ts +65 -0
- package/dist/src/tools/apply-patch.js +528 -0
- package/dist/src/tools/apply-patch.js.map +1 -0
- package/dist/src/tools/ast-edit/ast-config.d.ts +67 -0
- package/dist/src/tools/ast-edit/ast-config.js +72 -0
- package/dist/src/tools/ast-edit/ast-config.js.map +1 -0
- package/dist/src/tools/ast-edit/ast-edit-invocation.d.ts +40 -0
- package/dist/src/tools/ast-edit/ast-edit-invocation.js +410 -0
- package/dist/src/tools/ast-edit/ast-edit-invocation.js.map +1 -0
- package/dist/src/tools/ast-edit/ast-query-extractor.d.ts +21 -0
- package/dist/src/tools/ast-edit/ast-query-extractor.js +178 -0
- package/dist/src/tools/ast-edit/ast-query-extractor.js.map +1 -0
- package/dist/src/tools/ast-edit/ast-read-file-invocation.d.ts +26 -0
- package/dist/src/tools/ast-edit/ast-read-file-invocation.js +149 -0
- package/dist/src/tools/ast-edit/ast-read-file-invocation.js.map +1 -0
- package/dist/src/tools/ast-edit/constants.d.ts +30 -0
- package/dist/src/tools/ast-edit/constants.js +36 -0
- package/dist/src/tools/ast-edit/constants.js.map +1 -0
- package/dist/src/tools/ast-edit/context-collector.d.ts +25 -0
- package/dist/src/tools/ast-edit/context-collector.js +115 -0
- package/dist/src/tools/ast-edit/context-collector.js.map +1 -0
- package/dist/src/tools/ast-edit/context-optimizer.d.ts +29 -0
- package/dist/src/tools/ast-edit/context-optimizer.js +86 -0
- package/dist/src/tools/ast-edit/context-optimizer.js.map +1 -0
- package/dist/src/tools/ast-edit/cross-file-analyzer.d.ts +41 -0
- package/dist/src/tools/ast-edit/cross-file-analyzer.js +294 -0
- package/dist/src/tools/ast-edit/cross-file-analyzer.js.map +1 -0
- package/dist/src/tools/ast-edit/edit-calculator.d.ts +71 -0
- package/dist/src/tools/ast-edit/edit-calculator.js +249 -0
- package/dist/src/tools/ast-edit/edit-calculator.js.map +1 -0
- package/dist/src/tools/ast-edit/edit-helpers.d.ts +22 -0
- package/dist/src/tools/ast-edit/edit-helpers.js +36 -0
- package/dist/src/tools/ast-edit/edit-helpers.js.map +1 -0
- package/dist/src/tools/ast-edit/language-analysis.d.ts +19 -0
- package/dist/src/tools/ast-edit/language-analysis.js +123 -0
- package/dist/src/tools/ast-edit/language-analysis.js.map +1 -0
- package/dist/src/tools/ast-edit/local-context-analyzer.d.ts +84 -0
- package/dist/src/tools/ast-edit/local-context-analyzer.js +267 -0
- package/dist/src/tools/ast-edit/local-context-analyzer.js.map +1 -0
- package/dist/src/tools/ast-edit/repository-context-provider.d.ts +22 -0
- package/dist/src/tools/ast-edit/repository-context-provider.js +139 -0
- package/dist/src/tools/ast-edit/repository-context-provider.js.map +1 -0
- package/dist/src/tools/ast-edit/types.d.ts +155 -0
- package/dist/src/tools/ast-edit/types.js +7 -0
- package/dist/src/tools/ast-edit/types.js.map +1 -0
- package/dist/src/tools/ast-edit/workspace-context-provider.d.ts +22 -0
- package/dist/src/tools/ast-edit/workspace-context-provider.js +39 -0
- package/dist/src/tools/ast-edit/workspace-context-provider.js.map +1 -0
- package/dist/src/tools/ast-edit.d.ts +43 -0
- package/dist/src/tools/ast-edit.js +183 -0
- package/dist/src/tools/ast-edit.js.map +1 -0
- package/dist/src/tools/ast-grep.d.ts +22 -0
- package/dist/src/tools/ast-grep.js +291 -0
- package/dist/src/tools/ast-grep.js.map +1 -0
- package/dist/src/tools/check-async-tasks.d.ts +46 -0
- package/dist/src/tools/check-async-tasks.js +241 -0
- package/dist/src/tools/check-async-tasks.js.map +1 -0
- package/dist/src/tools/codesearch.d.ts +25 -0
- package/dist/src/tools/codesearch.js +153 -0
- package/dist/src/tools/codesearch.js.map +1 -0
- package/dist/src/tools/delete_line_range.d.ts +41 -0
- package/dist/src/tools/delete_line_range.js +238 -0
- package/dist/src/tools/delete_line_range.js.map +1 -0
- package/dist/src/tools/direct-web-fetch.d.ts +22 -0
- package/dist/src/tools/direct-web-fetch.js +215 -0
- package/dist/src/tools/direct-web-fetch.js.map +1 -0
- package/dist/src/tools/edit-utils.d.ts +53 -0
- package/dist/src/tools/edit-utils.js +250 -0
- package/dist/src/tools/edit-utils.js.map +1 -0
- package/dist/src/tools/edit.d.ts +70 -0
- package/dist/src/tools/edit.js +816 -0
- package/dist/src/tools/edit.js.map +1 -0
- package/dist/src/tools/exa-web-search.d.ts +27 -0
- package/dist/src/tools/exa-web-search.js +153 -0
- package/dist/src/tools/exa-web-search.js.map +1 -0
- package/dist/src/tools/glob.d.ts +55 -0
- package/dist/src/tools/glob.js +284 -0
- package/dist/src/tools/glob.js.map +1 -0
- package/dist/src/tools/google-web-fetch.d.ts +34 -0
- package/dist/src/tools/google-web-fetch.js +417 -0
- package/dist/src/tools/google-web-fetch.js.map +1 -0
- package/dist/src/tools/google-web-search-invocation.d.ts +53 -0
- package/dist/src/tools/google-web-search-invocation.js +180 -0
- package/dist/src/tools/google-web-search-invocation.js.map +1 -0
- package/dist/src/tools/google-web-search.d.ts +16 -0
- package/dist/src/tools/google-web-search.js +34 -0
- package/dist/src/tools/google-web-search.js.map +1 -0
- package/dist/src/tools/grep.d.ts +56 -0
- package/dist/src/tools/grep.js +883 -0
- package/dist/src/tools/grep.js.map +1 -0
- package/dist/src/tools/insert_at_line.d.ts +41 -0
- package/dist/src/tools/insert_at_line.js +287 -0
- package/dist/src/tools/insert_at_line.js.map +1 -0
- package/dist/src/tools/list-subagents.d.ts +31 -0
- package/dist/src/tools/list-subagents.js +122 -0
- package/dist/src/tools/list-subagents.js.map +1 -0
- package/dist/src/tools/ls.d.ts +71 -0
- package/dist/src/tools/ls.js +238 -0
- package/dist/src/tools/ls.js.map +1 -0
- package/dist/src/tools/memoryTool.d.ts +66 -0
- package/dist/src/tools/memoryTool.js +435 -0
- package/dist/src/tools/memoryTool.js.map +1 -0
- package/dist/src/tools/modifiable-tool.d.ts +37 -0
- package/dist/src/tools/modifiable-tool.js +120 -0
- package/dist/src/tools/modifiable-tool.js.map +1 -0
- package/dist/src/tools/read-file.d.ts +49 -0
- package/dist/src/tools/read-file.js +279 -0
- package/dist/src/tools/read-file.js.map +1 -0
- package/dist/src/tools/read-many-files.d.ts +60 -0
- package/dist/src/tools/read-many-files.js +529 -0
- package/dist/src/tools/read-many-files.js.map +1 -0
- package/dist/src/tools/read_line_range.d.ts +47 -0
- package/dist/src/tools/read_line_range.js +248 -0
- package/dist/src/tools/read_line_range.js.map +1 -0
- package/dist/src/tools/ripGrep.d.ts +41 -0
- package/dist/src/tools/ripGrep.js +395 -0
- package/dist/src/tools/ripGrep.js.map +1 -0
- package/dist/src/tools/shell.d.ts +60 -0
- package/dist/src/tools/shell.js +735 -0
- package/dist/src/tools/shell.js.map +1 -0
- package/dist/src/tools/structural-analysis.d.ts +27 -0
- package/dist/src/tools/structural-analysis.js +1089 -0
- package/dist/src/tools/structural-analysis.js.map +1 -0
- package/dist/src/tools/stubs.d.ts +10 -0
- package/dist/src/tools/stubs.js +6 -0
- package/dist/src/tools/stubs.js.map +1 -0
- package/dist/src/tools/task.d.ts +41 -0
- package/dist/src/tools/task.js +195 -0
- package/dist/src/tools/task.js.map +1 -0
- package/dist/src/tools/todo-events.d.ts +22 -0
- package/dist/src/tools/todo-events.js +24 -0
- package/dist/src/tools/todo-events.js.map +1 -0
- package/dist/src/tools/todo-pause.d.ts +29 -0
- package/dist/src/tools/todo-pause.js +172 -0
- package/dist/src/tools/todo-pause.js.map +1 -0
- package/dist/src/tools/todo-read.d.ts +18 -0
- package/dist/src/tools/todo-read.js +98 -0
- package/dist/src/tools/todo-read.js.map +1 -0
- package/dist/src/tools/todo-store.d.ts +35 -0
- package/dist/src/tools/todo-store.js +124 -0
- package/dist/src/tools/todo-store.js.map +1 -0
- package/dist/src/tools/todo-write.d.ts +29 -0
- package/dist/src/tools/todo-write.js +366 -0
- package/dist/src/tools/todo-write.js.map +1 -0
- package/dist/src/tools/tool-registry.d.ts +156 -0
- package/dist/src/tools/tool-registry.js +623 -0
- package/dist/src/tools/tool-registry.js.map +1 -0
- package/dist/src/tools/tools.d.ts +403 -0
- package/dist/src/tools/tools.js +519 -0
- package/dist/src/tools/tools.js.map +1 -0
- package/dist/src/tools/write-file.d.ts +45 -0
- package/dist/src/tools/write-file.js +320 -0
- package/dist/src/tools/write-file.js.map +1 -0
- package/dist/src/types/index.d.ts +17 -0
- package/dist/src/types/index.js +9 -0
- package/dist/src/types/index.js.map +1 -0
- package/dist/src/types/provider-content-types.d.ts +56 -0
- package/dist/src/types/provider-content-types.js +6 -0
- package/dist/src/types/provider-content-types.js.map +1 -0
- package/dist/src/types/todo-schemas.d.ts +263 -0
- package/dist/src/types/todo-schemas.js +32 -0
- package/dist/src/types/todo-schemas.js.map +1 -0
- package/dist/src/types/tool-confirmation-types.d.ts +34 -0
- package/dist/src/types/tool-confirmation-types.js +29 -0
- package/dist/src/types/tool-confirmation-types.js.map +1 -0
- package/dist/src/types/tool-context.d.ts +31 -0
- package/dist/src/types/tool-context.js +6 -0
- package/dist/src/types/tool-context.js.map +1 -0
- package/dist/src/types/tool-error.d.ts +69 -0
- package/dist/src/types/tool-error.js +94 -0
- package/dist/src/types/tool-error.js.map +1 -0
- package/dist/src/types/tool-names.d.ts +57 -0
- package/dist/src/types/tool-names.js +64 -0
- package/dist/src/types/tool-names.js.map +1 -0
- package/dist/src/utils/EmojiFilter.d.ts +134 -0
- package/dist/src/utils/EmojiFilter.js +370 -0
- package/dist/src/utils/EmojiFilter.js.map +1 -0
- package/dist/src/utils/ast-grep-utils.d.ts +42 -0
- package/dist/src/utils/ast-grep-utils.js +140 -0
- package/dist/src/utils/ast-grep-utils.js.map +1 -0
- package/dist/src/utils/debugLogger.d.ts +11 -0
- package/dist/src/utils/debugLogger.js +16 -0
- package/dist/src/utils/debugLogger.js.map +1 -0
- package/dist/src/utils/diffOptions.d.ts +14 -0
- package/dist/src/utils/diffOptions.js +46 -0
- package/dist/src/utils/diffOptions.js.map +1 -0
- package/dist/src/utils/editor.d.ts +39 -0
- package/dist/src/utils/editor.js +212 -0
- package/dist/src/utils/editor.js.map +1 -0
- package/dist/src/utils/ensure-dirs.d.ts +10 -0
- package/dist/src/utils/ensure-dirs.js +16 -0
- package/dist/src/utils/ensure-dirs.js.map +1 -0
- package/dist/src/utils/errors.d.ts +59 -0
- package/dist/src/utils/errors.js +178 -0
- package/dist/src/utils/errors.js.map +1 -0
- package/dist/src/utils/fetch.d.ts +11 -0
- package/dist/src/utils/fetch.js +74 -0
- package/dist/src/utils/fetch.js.map +1 -0
- package/dist/src/utils/fileUtils.d.ts +32 -0
- package/dist/src/utils/fileUtils.js +363 -0
- package/dist/src/utils/fileUtils.js.map +1 -0
- package/dist/src/utils/fuzzy-replacer.d.ts +61 -0
- package/dist/src/utils/fuzzy-replacer.js +492 -0
- package/dist/src/utils/fuzzy-replacer.js.map +1 -0
- package/dist/src/utils/gitLineChanges.d.ts +12 -0
- package/dist/src/utils/gitLineChanges.js +171 -0
- package/dist/src/utils/gitLineChanges.js.map +1 -0
- package/dist/src/utils/gitUtils.d.ts +6 -0
- package/dist/src/utils/gitUtils.js +31 -0
- package/dist/src/utils/gitUtils.js.map +1 -0
- package/dist/src/utils/lsp-diagnostics-helper.d.ts +27 -0
- package/dist/src/utils/lsp-diagnostics-helper.js +62 -0
- package/dist/src/utils/lsp-diagnostics-helper.js.map +1 -0
- package/dist/src/utils/mediaUtils.d.ts +38 -0
- package/dist/src/utils/mediaUtils.js +22 -0
- package/dist/src/utils/mediaUtils.js.map +1 -0
- package/dist/src/utils/pathValidation.d.ts +7 -0
- package/dist/src/utils/pathValidation.js +39 -0
- package/dist/src/utils/pathValidation.js.map +1 -0
- package/dist/src/utils/paths.d.ts +7 -0
- package/dist/src/utils/paths.js +158 -0
- package/dist/src/utils/paths.js.map +1 -0
- package/dist/src/utils/resolveTextSearchTarget.d.ts +17 -0
- package/dist/src/utils/resolveTextSearchTarget.js +45 -0
- package/dist/src/utils/resolveTextSearchTarget.js.map +1 -0
- package/dist/src/utils/retry.d.ts +17 -0
- package/dist/src/utils/retry.js +185 -0
- package/dist/src/utils/retry.js.map +1 -0
- package/dist/src/utils/ripgrepPathResolver.d.ts +23 -0
- package/dist/src/utils/ripgrepPathResolver.js +179 -0
- package/dist/src/utils/ripgrepPathResolver.js.map +1 -0
- package/dist/src/utils/safeJsonStringify.d.ts +9 -0
- package/dist/src/utils/safeJsonStringify.js +21 -0
- package/dist/src/utils/safeJsonStringify.js.map +1 -0
- package/dist/src/utils/schemaValidator.d.ts +13 -0
- package/dist/src/utils/schemaValidator.js +275 -0
- package/dist/src/utils/schemaValidator.js.map +1 -0
- package/dist/src/utils/terminalSerializer.d.ts +33 -0
- package/dist/src/utils/terminalSerializer.js +6 -0
- package/dist/src/utils/terminalSerializer.js.map +1 -0
- package/dist/src/utils/todoContextTracker.d.ts +12 -0
- package/dist/src/utils/todoContextTracker.js +28 -0
- package/dist/src/utils/todoContextTracker.js.map +1 -0
- package/dist/src/utils/todoFormatter.d.ts +24 -0
- package/dist/src/utils/todoFormatter.js +157 -0
- package/dist/src/utils/todoFormatter.js.map +1 -0
- package/dist/src/utils/todoReminderService.d.ts +22 -0
- package/dist/src/utils/todoReminderService.js +43 -0
- package/dist/src/utils/todoReminderService.js.map +1 -0
- package/dist/src/utils/tool-key-storage-facade.d.ts +32 -0
- package/dist/src/utils/tool-key-storage-facade.js +56 -0
- package/dist/src/utils/tool-key-storage-facade.js.map +1 -0
- package/dist/src/utils/tool-key-storage-types.d.ts +56 -0
- package/dist/src/utils/tool-key-storage-types.js +56 -0
- package/dist/src/utils/tool-key-storage-types.js.map +1 -0
- package/dist/src/utils/toolOutputLimiter.d.ts +29 -0
- package/dist/src/utils/toolOutputLimiter.js +107 -0
- package/dist/src/utils/toolOutputLimiter.js.map +1 -0
- package/dist/src/utils/unicodeUtils.d.ts +55 -0
- package/dist/src/utils/unicodeUtils.js +129 -0
- package/dist/src/utils/unicodeUtils.js.map +1 -0
- package/package.json +75 -0
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Vybestack LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*
|
|
6
|
+
* Local context analysis functions for AST parsing and code snippet collection.
|
|
7
|
+
*/
|
|
8
|
+
import { ASTConfig } from './ast-config.js';
|
|
9
|
+
import { KEYWORDS, COMMENT_PREFIXES } from './constants.js';
|
|
10
|
+
import { ContextOptimizer } from './context-optimizer.js';
|
|
11
|
+
/**
|
|
12
|
+
* Parse AST from content using basic line-by-line analysis.
|
|
13
|
+
* @param content - Source code content
|
|
14
|
+
* @param language - Programming language
|
|
15
|
+
* @returns Array of AST nodes
|
|
16
|
+
*/
|
|
17
|
+
export async function parseAST(content, language) {
|
|
18
|
+
if (language === 'unknown') {
|
|
19
|
+
return [];
|
|
20
|
+
}
|
|
21
|
+
// Use existing validateASTSyntax logic for basic parsing
|
|
22
|
+
return extractASTNodes(content, language);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Extract AST nodes from content by analyzing significant lines.
|
|
26
|
+
* @param content - Source code content
|
|
27
|
+
* @param language - Programming language
|
|
28
|
+
* @returns Array of AST nodes
|
|
29
|
+
*/
|
|
30
|
+
export function extractASTNodes(content, language) {
|
|
31
|
+
// Simplified AST node extraction
|
|
32
|
+
const nodes = [];
|
|
33
|
+
const lines = content.split('\n');
|
|
34
|
+
lines.forEach((line, index) => {
|
|
35
|
+
if (isSignificantLine(line, language)) {
|
|
36
|
+
nodes.push({
|
|
37
|
+
type: inferNodeType(line, language),
|
|
38
|
+
text: line.trim(),
|
|
39
|
+
startPosition: { line: index + 1, column: 0 },
|
|
40
|
+
endPosition: { line: index + 1, column: line.length },
|
|
41
|
+
children: [],
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
return nodes;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Collect code snippets from content, filtering out comments and short lines.
|
|
49
|
+
* @param content - Source code content
|
|
50
|
+
* @returns Array of code snippets sorted by relevance
|
|
51
|
+
*/
|
|
52
|
+
export function collectSnippets(content) {
|
|
53
|
+
const snippets = [];
|
|
54
|
+
const lines = content.split('\n');
|
|
55
|
+
lines.forEach((line, index) => {
|
|
56
|
+
const trimmed = line.trim();
|
|
57
|
+
const isComment = COMMENT_PREFIXES.some((prefix) => trimmed.startsWith(prefix));
|
|
58
|
+
if (trimmed.length > 10 && !isComment) {
|
|
59
|
+
snippets.push({
|
|
60
|
+
text: trimmed,
|
|
61
|
+
relevance: calculateRelevance(trimmed),
|
|
62
|
+
line: index + 1,
|
|
63
|
+
source: 'local',
|
|
64
|
+
priority: 3,
|
|
65
|
+
charLength: trimmed.length,
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
return snippets
|
|
70
|
+
.sort((a, b) => b.relevance - a.relevance)
|
|
71
|
+
.slice(0, ASTConfig.MAX_SNIPPETS);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Build language-specific context by extracting functions, classes, and variables.
|
|
75
|
+
* @param content - Source code content
|
|
76
|
+
* @param language - Programming language
|
|
77
|
+
* @returns Language context with extracted elements
|
|
78
|
+
*/
|
|
79
|
+
export function buildLanguageContext(content, language) {
|
|
80
|
+
return {
|
|
81
|
+
functions: extractFunctions(content, language),
|
|
82
|
+
classes: extractClasses(content, language),
|
|
83
|
+
variables: extractVariables(content, language),
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Check if a line is significant (non-comment, non-empty).
|
|
88
|
+
* @param line - Source code line
|
|
89
|
+
* @param _language - Programming language (unused but kept for signature compatibility)
|
|
90
|
+
* @returns True if the line is significant
|
|
91
|
+
*/
|
|
92
|
+
export function isSignificantLine(line, _language) {
|
|
93
|
+
const trimmed = line.trim();
|
|
94
|
+
const isComment =
|
|
95
|
+
// eslint-disable-next-line sonarjs/expression-complexity -- Existing structure is intentionally preserved; refactoring this boundary is outside the lint slice.
|
|
96
|
+
trimmed.startsWith('//') ||
|
|
97
|
+
trimmed.startsWith('#') ||
|
|
98
|
+
trimmed.startsWith('*') ||
|
|
99
|
+
trimmed.startsWith('/*') ||
|
|
100
|
+
trimmed.startsWith('*/');
|
|
101
|
+
return trimmed.length > 0 && !isComment;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Infer the AST node type from a line of code.
|
|
105
|
+
* @param line - Source code line
|
|
106
|
+
* @param _language - Programming language (unused but kept for signature compatibility)
|
|
107
|
+
* @returns Node type (function, class, control, return, statement)
|
|
108
|
+
*/
|
|
109
|
+
export function inferNodeType(line, _language) {
|
|
110
|
+
const trimmed = line.trim();
|
|
111
|
+
if (trimmed.includes(KEYWORDS.FUNCTION) || trimmed.includes(KEYWORDS.DEF))
|
|
112
|
+
return 'function';
|
|
113
|
+
if (trimmed.includes(KEYWORDS.CLASS))
|
|
114
|
+
return 'class';
|
|
115
|
+
if (trimmed.includes(KEYWORDS.IF) ||
|
|
116
|
+
trimmed.includes(KEYWORDS.FOR) ||
|
|
117
|
+
trimmed.includes(KEYWORDS.WHILE))
|
|
118
|
+
return 'control';
|
|
119
|
+
if (trimmed.includes(KEYWORDS.RETURN))
|
|
120
|
+
return 'return';
|
|
121
|
+
return 'statement';
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Calculate the relevance score of a code line.
|
|
125
|
+
* @param line - Source code line
|
|
126
|
+
* @returns Relevance score
|
|
127
|
+
*/
|
|
128
|
+
export function calculateRelevance(line) {
|
|
129
|
+
let relevance = 1;
|
|
130
|
+
if (line.includes(KEYWORDS.FUNCTION) || line.includes(KEYWORDS.DEF))
|
|
131
|
+
relevance += 3;
|
|
132
|
+
if (line.includes(KEYWORDS.CLASS))
|
|
133
|
+
relevance += 2;
|
|
134
|
+
if (line.includes(KEYWORDS.RETURN))
|
|
135
|
+
relevance += 1;
|
|
136
|
+
if (line.length > 50)
|
|
137
|
+
relevance += 1;
|
|
138
|
+
return relevance;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Extract function declarations from content using regex.
|
|
142
|
+
* @param content - Source code content
|
|
143
|
+
* @param _language - Programming language
|
|
144
|
+
* @returns Array of function information
|
|
145
|
+
*/
|
|
146
|
+
export function extractFunctions(content, _language) {
|
|
147
|
+
const functions = [];
|
|
148
|
+
const lines = content.split('\n');
|
|
149
|
+
lines.forEach((line, index) => {
|
|
150
|
+
const trimmed = line.trim();
|
|
151
|
+
if (_language === 'typescript' || _language === 'javascript') {
|
|
152
|
+
const match = trimmed.match(
|
|
153
|
+
// eslint-disable-next-line sonarjs/regular-expr -- Static regex reviewed for lint hardening; behavior preserved.
|
|
154
|
+
/function\s+(\w+)\s*\(([^)]*)\)(?::\s*(\w+))?/);
|
|
155
|
+
if (match) {
|
|
156
|
+
functions.push({
|
|
157
|
+
name: match[1],
|
|
158
|
+
parameters: match[2]
|
|
159
|
+
.split(',')
|
|
160
|
+
.map((p) => p.trim())
|
|
161
|
+
.filter((p) => p),
|
|
162
|
+
returnType: match[3] || 'unknown',
|
|
163
|
+
line: index + 1,
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
else if (_language === 'python') {
|
|
168
|
+
const match = trimmed.match(
|
|
169
|
+
// eslint-disable-next-line sonarjs/regular-expr -- Static regex reviewed for lint hardening; behavior preserved.
|
|
170
|
+
/def\s+(\w+)\s*\(([^)]*)\)\s*(?:->\s*(\w+))?/);
|
|
171
|
+
if (match) {
|
|
172
|
+
functions.push({
|
|
173
|
+
name: match[1],
|
|
174
|
+
parameters: match[2]
|
|
175
|
+
.split(',')
|
|
176
|
+
.map((p) => p.trim())
|
|
177
|
+
.filter((p) => p),
|
|
178
|
+
returnType: match[3] || 'unknown',
|
|
179
|
+
line: index + 1,
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
return functions;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Extract class declarations from content using regex.
|
|
188
|
+
* @param content - Source code content
|
|
189
|
+
* @param _language - Programming language
|
|
190
|
+
* @returns Array of class information
|
|
191
|
+
*/
|
|
192
|
+
export function extractClasses(content, _language) {
|
|
193
|
+
const classes = [];
|
|
194
|
+
const lines = content.split('\n');
|
|
195
|
+
lines.forEach((line, index) => {
|
|
196
|
+
const trimmed = line.trim();
|
|
197
|
+
if (trimmed.includes(KEYWORDS.CLASS)) {
|
|
198
|
+
// eslint-disable-next-line sonarjs/regular-expr -- Static regex reviewed for lint hardening; behavior preserved.
|
|
199
|
+
const match = trimmed.match(/class\s+(\w+)/);
|
|
200
|
+
if (match) {
|
|
201
|
+
classes.push({
|
|
202
|
+
name: match[1],
|
|
203
|
+
methods: [], // Simplified implementation
|
|
204
|
+
properties: [], // Simplified implementation
|
|
205
|
+
line: index + 1,
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
return classes;
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Extract variable declarations from content using regex.
|
|
214
|
+
* @param content - Source code content
|
|
215
|
+
* @param _language - Programming language
|
|
216
|
+
* @returns Array of variable information
|
|
217
|
+
*/
|
|
218
|
+
export function extractVariables(content, _language) {
|
|
219
|
+
const variables = [];
|
|
220
|
+
const lines = content.split('\n');
|
|
221
|
+
lines.forEach((line, index) => {
|
|
222
|
+
const trimmed = line.trim();
|
|
223
|
+
if (_language === 'typescript' || _language === 'javascript') {
|
|
224
|
+
// eslint-disable-next-line sonarjs/regular-expr -- Static regex reviewed for lint hardening; behavior preserved.
|
|
225
|
+
const match = trimmed.match(/(?:const|let|var)\s+(\w+)\s*:\s*(\w+)/);
|
|
226
|
+
if (match) {
|
|
227
|
+
variables.push({
|
|
228
|
+
name: match[1],
|
|
229
|
+
type: match[2],
|
|
230
|
+
line: index + 1,
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
return variables;
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Optimize context collection by gathering declaration and local snippets.
|
|
239
|
+
* @param declarations - Array of declarations
|
|
240
|
+
* @param content - Source code content
|
|
241
|
+
* @param _workspaceRoot - Workspace root path (unused but kept for signature compatibility)
|
|
242
|
+
* @returns Optimized array of code snippets
|
|
243
|
+
*/
|
|
244
|
+
export function optimizeContextCollection(declarations, content, _workspaceRoot) {
|
|
245
|
+
const allSnippets = [];
|
|
246
|
+
// Collect declaration snippets (highest priority)
|
|
247
|
+
for (const decl of declarations) {
|
|
248
|
+
allSnippets.push({
|
|
249
|
+
text: `${decl.type}: ${decl.name}`,
|
|
250
|
+
relevance: 5,
|
|
251
|
+
line: decl.line,
|
|
252
|
+
source: 'declaration',
|
|
253
|
+
priority: 1,
|
|
254
|
+
charLength: decl.name.length + decl.type.length + 2,
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
// Collect local snippets
|
|
258
|
+
const localSnippets = collectSnippets(content);
|
|
259
|
+
allSnippets.push(...localSnippets.map((snippet) => ({
|
|
260
|
+
...snippet,
|
|
261
|
+
source: 'local',
|
|
262
|
+
priority: 2,
|
|
263
|
+
charLength: snippet.text.length,
|
|
264
|
+
})));
|
|
265
|
+
return ContextOptimizer.optimizeSnippets(allSnippets);
|
|
266
|
+
}
|
|
267
|
+
//# sourceMappingURL=local-context-analyzer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local-context-analyzer.js","sourceRoot":"","sources":["../../../../src/tools/ast-edit/local-context-analyzer.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAWH,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAC5B,OAAe,EACf,QAAgB;IAEhB,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC3B,OAAO,EAAE,CAAC;IACZ,CAAC;IAED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E,CAAC,CAAC;QACjC,GAAG,OAAO;QACV,MAAM,EAAE,OAAgB;QACxB,QAAQ,EAAE,CAAC;QACX,UAAU,EAAE,OAAO,CAAC,IAAI,CAAC,MAAM;KAChC,CAAC,CAAC,CACJ,CAAC;IAEF,OAAO,gBAAgB,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC;AACxD,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Vybestack LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import type { RepositoryContext } from './types.js';
|
|
7
|
+
/**
|
|
8
|
+
* RepositoryContextProvider handles git operations to collect repository context.
|
|
9
|
+
*/
|
|
10
|
+
export declare class RepositoryContextProvider {
|
|
11
|
+
collectRepositoryContext(rootPath: string): Promise<RepositoryContext | null>;
|
|
12
|
+
/**
|
|
13
|
+
* Get the "Working Set" of files:
|
|
14
|
+
* 1. Unstaged changes (git diff --name-only)
|
|
15
|
+
* 2. Staged changes (git diff --name-only --cached)
|
|
16
|
+
* 3. Recent commits (git log -n <limit> --name-only)
|
|
17
|
+
*/
|
|
18
|
+
getWorkingSetFiles(workspaceRoot: string, limit?: number): Promise<string[]>;
|
|
19
|
+
private getGitRemoteUrl;
|
|
20
|
+
private getCurrentCommit;
|
|
21
|
+
private getCurrentBranch;
|
|
22
|
+
}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Vybestack LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { promises as fsPromises } from 'fs';
|
|
7
|
+
import * as path from 'path';
|
|
8
|
+
import { spawnSync } from 'child_process';
|
|
9
|
+
const GIT_TIMEOUT_MS = 3000;
|
|
10
|
+
const GIT_MAX_BUFFER = 1024 * 1024;
|
|
11
|
+
/**
|
|
12
|
+
* RepositoryContextProvider handles git operations to collect repository context.
|
|
13
|
+
*/
|
|
14
|
+
export class RepositoryContextProvider {
|
|
15
|
+
async collectRepositoryContext(rootPath) {
|
|
16
|
+
try {
|
|
17
|
+
const gitUrl = await this.getGitRemoteUrl(rootPath);
|
|
18
|
+
const commitSha = await this.getCurrentCommit(rootPath);
|
|
19
|
+
const branch = await this.getCurrentBranch(rootPath);
|
|
20
|
+
if (!gitUrl && !commitSha) {
|
|
21
|
+
return null; // Not a git repo or failed to get info
|
|
22
|
+
}
|
|
23
|
+
return {
|
|
24
|
+
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- intentional falsy coalescing: git command output fallback
|
|
25
|
+
gitUrl: gitUrl || 'unknown',
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- intentional falsy coalescing: git command output fallback
|
|
27
|
+
commitSha: commitSha || 'unknown',
|
|
28
|
+
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- intentional falsy coalescing: git command output fallback
|
|
29
|
+
branch: branch || 'unknown',
|
|
30
|
+
rootPath,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
// Git info unavailable; not a git repo.
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Get the "Working Set" of files:
|
|
40
|
+
* 1. Unstaged changes (git diff --name-only)
|
|
41
|
+
* 2. Staged changes (git diff --name-only --cached)
|
|
42
|
+
* 3. Recent commits (git log -n <limit> --name-only)
|
|
43
|
+
*/
|
|
44
|
+
async getWorkingSetFiles(workspaceRoot, limit = 5) {
|
|
45
|
+
const files = new Set();
|
|
46
|
+
try {
|
|
47
|
+
const execGit = (args) => {
|
|
48
|
+
// eslint-disable-next-line sonarjs/no-os-command-from-path -- Project intentionally invokes platform tooling at this trusted boundary; arguments remain explicit and behavior is preserved.
|
|
49
|
+
const result = spawnSync('git', ['-C', workspaceRoot, ...args], {
|
|
50
|
+
encoding: 'utf-8',
|
|
51
|
+
stdio: 'pipe',
|
|
52
|
+
timeout: GIT_TIMEOUT_MS,
|
|
53
|
+
maxBuffer: GIT_MAX_BUFFER,
|
|
54
|
+
});
|
|
55
|
+
return result.status === 0 ? result.stdout.trim() : '';
|
|
56
|
+
};
|
|
57
|
+
// 1. Unstaged changes
|
|
58
|
+
execGit(['diff', '--name-only', '-z'])
|
|
59
|
+
.split('\0')
|
|
60
|
+
.forEach((f) => f && files.add(f));
|
|
61
|
+
// 2. Staged changes
|
|
62
|
+
execGit(['diff', '--name-only', '--cached', '-z'])
|
|
63
|
+
.split('\0')
|
|
64
|
+
.forEach((f) => f && files.add(f));
|
|
65
|
+
// 3. Recent commits
|
|
66
|
+
// Note: -z works with --name-only in log but we need to ensure format doesn't break it.
|
|
67
|
+
// Safest is to rely on diffs for working set, but strictly following plan:
|
|
68
|
+
execGit(['log', `-n${limit}`, '--name-only', '--format=', '-z'])
|
|
69
|
+
.split('\0')
|
|
70
|
+
.forEach((f) => f && files.add(f));
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
// Git command failed; return what we have.
|
|
74
|
+
}
|
|
75
|
+
// Filter existing files and convert to absolute paths
|
|
76
|
+
const validFiles = [];
|
|
77
|
+
for (const file of files) {
|
|
78
|
+
if (!file.trim())
|
|
79
|
+
continue;
|
|
80
|
+
const absPath = path.resolve(workspaceRoot, file);
|
|
81
|
+
try {
|
|
82
|
+
await fsPromises.access(absPath);
|
|
83
|
+
validFiles.push(absPath);
|
|
84
|
+
}
|
|
85
|
+
catch {
|
|
86
|
+
// File might be deleted
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return validFiles;
|
|
90
|
+
}
|
|
91
|
+
async getGitRemoteUrl(repoPath) {
|
|
92
|
+
try {
|
|
93
|
+
const result = spawnSync(
|
|
94
|
+
// eslint-disable-next-line sonarjs/no-os-command-from-path -- Project intentionally invokes platform tooling at this trusted boundary; arguments remain explicit and behavior is preserved.
|
|
95
|
+
'git', ['-C', repoPath, 'remote', 'get-url', 'origin'], {
|
|
96
|
+
encoding: 'utf-8',
|
|
97
|
+
stdio: 'pipe',
|
|
98
|
+
timeout: GIT_TIMEOUT_MS,
|
|
99
|
+
maxBuffer: GIT_MAX_BUFFER,
|
|
100
|
+
});
|
|
101
|
+
return result.status === 0 ? result.stdout.trim() : null;
|
|
102
|
+
}
|
|
103
|
+
catch {
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
async getCurrentCommit(repoPath) {
|
|
108
|
+
try {
|
|
109
|
+
// eslint-disable-next-line sonarjs/no-os-command-from-path -- Project intentionally invokes platform tooling at this trusted boundary; arguments remain explicit and behavior is preserved.
|
|
110
|
+
const result = spawnSync('git', ['-C', repoPath, 'rev-parse', 'HEAD'], {
|
|
111
|
+
encoding: 'utf-8',
|
|
112
|
+
stdio: 'pipe',
|
|
113
|
+
timeout: GIT_TIMEOUT_MS,
|
|
114
|
+
maxBuffer: GIT_MAX_BUFFER,
|
|
115
|
+
});
|
|
116
|
+
return result.status === 0 ? result.stdout.trim() : null;
|
|
117
|
+
}
|
|
118
|
+
catch {
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
async getCurrentBranch(repoPath) {
|
|
123
|
+
try {
|
|
124
|
+
const result = spawnSync(
|
|
125
|
+
// eslint-disable-next-line sonarjs/no-os-command-from-path -- Project intentionally invokes platform tooling at this trusted boundary; arguments remain explicit and behavior is preserved.
|
|
126
|
+
'git', ['-C', repoPath, 'branch', '--show-current'], {
|
|
127
|
+
encoding: 'utf-8',
|
|
128
|
+
stdio: 'pipe',
|
|
129
|
+
timeout: GIT_TIMEOUT_MS,
|
|
130
|
+
maxBuffer: GIT_MAX_BUFFER,
|
|
131
|
+
});
|
|
132
|
+
return result.status === 0 ? result.stdout.trim() : null;
|
|
133
|
+
}
|
|
134
|
+
catch {
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
//# sourceMappingURL=repository-context-provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repository-context-provider.js","sourceRoot":"","sources":["../../../../src/tools/ast-edit/repository-context-provider.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,IAAI,UAAU,EAAE,MAAM,IAAI,CAAC;AAC5C,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAG1C,MAAM,cAAc,GAAG,IAAI,CAAC;AAC5B,MAAM,cAAc,GAAG,IAAI,GAAG,IAAI,CAAC;AAEnC;;GAEG;AACH,MAAM,OAAO,yBAAyB;IACpC,KAAK,CAAC,wBAAwB,CAC5B,QAAgB;QAEhB,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;YACpD,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;YACxD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;YAErD,IAAI,CAAC,MAAM,IAAI,CAAC,SAAS,EAAE,CAAC;gBAC1B,OAAO,IAAI,CAAC,CAAC,uCAAuC;YACtD,CAAC;YAED,OAAO;gBACL,qIAAqI;gBACrI,MAAM,EAAE,MAAM,IAAI,SAAS;gBAC3B,qIAAqI;gBACrI,SAAS,EAAE,SAAS,IAAI,SAAS;gBACjC,qIAAqI;gBACrI,MAAM,EAAE,MAAM,IAAI,SAAS;gBAC3B,QAAQ;aACT,CAAC;QACJ,CAAC;QAAC,MAAM,CAAC;YACP,wCAAwC;YACxC,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,kBAAkB,CACtB,aAAqB,EACrB,QAAgB,CAAC;Q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AQ,EAAE,OAAO;gBACjB,KAAK,EAAE,MAAM;gBACb,OAAO,EAAE,cAAc;gBACvB,SAAS,EAAE,cAAc;aAC1B,CAAC,CAAC;YACH,OAAO,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;QAC3D,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IAEO,KAAK,CAAC,gBAAgB,CAAC,QAAgB;QAC7C,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,SAAS;YACtB,4LAA4L;YAC5L,KAAK,EACL,CAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,gBAAgB,CAAC,EAC5C;gBACE,QAAQ,EAAE,OAAO;gBACjB,KAAK,EAAE,MAAM;gBACb,OAAO,EAAE,cAAc;gBACvB,SAAS,EAAE,cAAc;aAC1B,CACF,CAAC;YACF,OAAO,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;QAC3D,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Vybestack LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
export interface ASTContext {
|
|
7
|
+
filePath: string;
|
|
8
|
+
language: string;
|
|
9
|
+
fileSize: number;
|
|
10
|
+
astNodes: ASTNode[];
|
|
11
|
+
declarations: Declaration[];
|
|
12
|
+
imports: Import[];
|
|
13
|
+
relevantSnippets: CodeSnippet[];
|
|
14
|
+
languageContext: {
|
|
15
|
+
functions: FunctionInfo[];
|
|
16
|
+
classes: ClassInfo[];
|
|
17
|
+
variables: VariableInfo[];
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export interface ASTNode {
|
|
21
|
+
type: string;
|
|
22
|
+
text: string;
|
|
23
|
+
startPosition: Position;
|
|
24
|
+
endPosition: Position;
|
|
25
|
+
children: ASTNode[];
|
|
26
|
+
}
|
|
27
|
+
export interface Declaration {
|
|
28
|
+
name: string;
|
|
29
|
+
type: 'function' | 'class' | 'variable' | 'import';
|
|
30
|
+
line: number;
|
|
31
|
+
column: number;
|
|
32
|
+
signature?: string;
|
|
33
|
+
}
|
|
34
|
+
export interface CodeSnippet {
|
|
35
|
+
text: string;
|
|
36
|
+
relevance: number;
|
|
37
|
+
line: number;
|
|
38
|
+
source: 'declaration' | 'changed_file' | 'recent_file' | 'search' | 'local';
|
|
39
|
+
priority: number;
|
|
40
|
+
charLength: number;
|
|
41
|
+
}
|
|
42
|
+
export interface Import {
|
|
43
|
+
module: string;
|
|
44
|
+
items: string[];
|
|
45
|
+
line: number;
|
|
46
|
+
}
|
|
47
|
+
export interface FunctionInfo {
|
|
48
|
+
name: string;
|
|
49
|
+
parameters: string[];
|
|
50
|
+
returnType: string;
|
|
51
|
+
line: number;
|
|
52
|
+
}
|
|
53
|
+
export interface ClassInfo {
|
|
54
|
+
name: string;
|
|
55
|
+
methods: string[];
|
|
56
|
+
properties: string[];
|
|
57
|
+
line: number;
|
|
58
|
+
}
|
|
59
|
+
export interface VariableInfo {
|
|
60
|
+
name: string;
|
|
61
|
+
type: string;
|
|
62
|
+
line: number;
|
|
63
|
+
}
|
|
64
|
+
export interface Position {
|
|
65
|
+
line: number;
|
|
66
|
+
column: number;
|
|
67
|
+
}
|
|
68
|
+
export interface SgNode {
|
|
69
|
+
range(): {
|
|
70
|
+
start: Position;
|
|
71
|
+
end: Position;
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
export interface RepositoryContext {
|
|
75
|
+
gitUrl: string;
|
|
76
|
+
commitSha: string;
|
|
77
|
+
branch: string;
|
|
78
|
+
rootPath: string;
|
|
79
|
+
}
|
|
80
|
+
export interface SymbolReference {
|
|
81
|
+
type: 'definition' | 'reference' | 'import';
|
|
82
|
+
filePath: string;
|
|
83
|
+
line: number;
|
|
84
|
+
column: number;
|
|
85
|
+
sourceModule?: string;
|
|
86
|
+
}
|
|
87
|
+
export interface FileContext {
|
|
88
|
+
filePath: string;
|
|
89
|
+
declarations: EnhancedDeclaration[];
|
|
90
|
+
summary: string;
|
|
91
|
+
}
|
|
92
|
+
export interface CrossFileContext {
|
|
93
|
+
files: FileContext[];
|
|
94
|
+
}
|
|
95
|
+
export interface ConnectedFile {
|
|
96
|
+
filePath: string;
|
|
97
|
+
declarations: EnhancedDeclaration[];
|
|
98
|
+
}
|
|
99
|
+
export interface EnhancedDeclaration extends Declaration {
|
|
100
|
+
range: {
|
|
101
|
+
start: Position;
|
|
102
|
+
end: Position;
|
|
103
|
+
};
|
|
104
|
+
documentation?: string;
|
|
105
|
+
visibility?: 'public' | 'private' | 'protected';
|
|
106
|
+
signature?: string;
|
|
107
|
+
}
|
|
108
|
+
export interface EnhancedASTContext extends ASTContext {
|
|
109
|
+
declarations: EnhancedDeclaration[];
|
|
110
|
+
repositoryContext?: RepositoryContext;
|
|
111
|
+
relatedFiles?: string[];
|
|
112
|
+
relatedSymbols?: SymbolReference[];
|
|
113
|
+
crossFileContext?: CrossFileContext;
|
|
114
|
+
connectedFiles?: ConnectedFile[];
|
|
115
|
+
}
|
|
116
|
+
export interface ASTEditToolParams {
|
|
117
|
+
/**
|
|
118
|
+
* The absolute path to the file to modify
|
|
119
|
+
*/
|
|
120
|
+
file_path: string;
|
|
121
|
+
/**
|
|
122
|
+
* The text to replace
|
|
123
|
+
*/
|
|
124
|
+
old_string: string;
|
|
125
|
+
/**
|
|
126
|
+
* The text to replace it with
|
|
127
|
+
*/
|
|
128
|
+
new_string: string;
|
|
129
|
+
/**
|
|
130
|
+
* Force execution after preview. Default is false.
|
|
131
|
+
* IMPORTANT: This tool ALWAYS operates in two steps:
|
|
132
|
+
* 1. First call: Preview changes (force: false or omitted)
|
|
133
|
+
* 2. Second call: Apply changes (force: true)
|
|
134
|
+
*/
|
|
135
|
+
force?: boolean;
|
|
136
|
+
/**
|
|
137
|
+
* Timestamp (ms) of the file when last read.
|
|
138
|
+
* If provided, the tool will verify the file hasn't been modified since this time.
|
|
139
|
+
*/
|
|
140
|
+
last_modified?: number;
|
|
141
|
+
}
|
|
142
|
+
export interface ASTReadFileToolParams {
|
|
143
|
+
/**
|
|
144
|
+
* The absolute path to the file to read
|
|
145
|
+
*/
|
|
146
|
+
file_path: string;
|
|
147
|
+
/**
|
|
148
|
+
* The line number to start reading from (optional)
|
|
149
|
+
*/
|
|
150
|
+
offset?: number;
|
|
151
|
+
/**
|
|
152
|
+
* The number of lines to read (optional)
|
|
153
|
+
*/
|
|
154
|
+
limit?: number;
|
|
155
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/tools/ast-edit/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Vybestack LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*
|
|
6
|
+
* Workspace context provider for enriching context with working-set files.
|
|
7
|
+
*/
|
|
8
|
+
import type { ConnectedFile } from './types.js';
|
|
9
|
+
import type { ASTQueryExtractor } from './ast-query-extractor.js';
|
|
10
|
+
import type { RepositoryContextProvider } from './repository-context-provider.js';
|
|
11
|
+
/**
|
|
12
|
+
* Enrich context with declarations from working-set files.
|
|
13
|
+
* Gets the current working set from git (unstaged/staged/recent commits),
|
|
14
|
+
* reads each file, and extracts declarations for a skeleton view.
|
|
15
|
+
*
|
|
16
|
+
* @param targetFilePath - The file currently being edited
|
|
17
|
+
* @param workspaceRoot - The workspace root directory
|
|
18
|
+
* @param repoProvider - Repository context provider for git operations
|
|
19
|
+
* @param astExtractor - AST query extractor for declaration extraction
|
|
20
|
+
* @returns Array of connected files with their declarations
|
|
21
|
+
*/
|
|
22
|
+
export declare function enrichWithWorkingSetContext(targetFilePath: string, workspaceRoot: string, repoProvider: RepositoryContextProvider, astExtractor: ASTQueryExtractor): Promise<ConnectedFile[]>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Vybestack LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*
|
|
6
|
+
* Workspace context provider for enriching context with working-set files.
|
|
7
|
+
*/
|
|
8
|
+
import { promises as fsPromises } from 'fs';
|
|
9
|
+
/**
|
|
10
|
+
* Enrich context with declarations from working-set files.
|
|
11
|
+
* Gets the current working set from git (unstaged/staged/recent commits),
|
|
12
|
+
* reads each file, and extracts declarations for a skeleton view.
|
|
13
|
+
*
|
|
14
|
+
* @param targetFilePath - The file currently being edited
|
|
15
|
+
* @param workspaceRoot - The workspace root directory
|
|
16
|
+
* @param repoProvider - Repository context provider for git operations
|
|
17
|
+
* @param astExtractor - AST query extractor for declaration extraction
|
|
18
|
+
* @returns Array of connected files with their declarations
|
|
19
|
+
*/
|
|
20
|
+
export async function enrichWithWorkingSetContext(targetFilePath, workspaceRoot, repoProvider, astExtractor) {
|
|
21
|
+
const connectedFiles = [];
|
|
22
|
+
// Phase 2: Working Set Context (Git-based)
|
|
23
|
+
// Replace BM25 search with working set file declarations
|
|
24
|
+
const workingSetFiles = await repoProvider.getWorkingSetFiles(workspaceRoot);
|
|
25
|
+
// Filter out current file
|
|
26
|
+
const otherFiles = workingSetFiles.filter((f) => f !== targetFilePath);
|
|
27
|
+
const settled = await Promise.allSettled(otherFiles.map(async (filePath) => {
|
|
28
|
+
const fileContent = await fsPromises.readFile(filePath, 'utf-8');
|
|
29
|
+
const declarations = await astExtractor.extractDeclarations(filePath, fileContent);
|
|
30
|
+
return { filePath, declarations };
|
|
31
|
+
}));
|
|
32
|
+
for (const item of settled) {
|
|
33
|
+
if (item.status === 'fulfilled') {
|
|
34
|
+
connectedFiles.push(item.value);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return connectedFiles;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=workspace-context-provider.js.map
|