@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,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared AST-grep utilities for all tools that use @ast-grep/napi.
|
|
3
|
+
* Single source of truth for language mapping, parsing, and error normalization.
|
|
4
|
+
*
|
|
5
|
+
* @plan PLAN-20260211-ASTGREP.P03
|
|
6
|
+
*/
|
|
7
|
+
import { parse, Lang, findInFiles, registerDynamicLanguage, } from '@ast-grep/napi';
|
|
8
|
+
import python from '@ast-grep/lang-python';
|
|
9
|
+
import go from '@ast-grep/lang-go';
|
|
10
|
+
import rust from '@ast-grep/lang-rust';
|
|
11
|
+
import java from '@ast-grep/lang-java';
|
|
12
|
+
import cpp from '@ast-grep/lang-cpp';
|
|
13
|
+
import c from '@ast-grep/lang-c';
|
|
14
|
+
import json from '@ast-grep/lang-json';
|
|
15
|
+
import ruby from '@ast-grep/lang-ruby';
|
|
16
|
+
import * as path from 'node:path';
|
|
17
|
+
let dynamicLanguagesRegistered = false;
|
|
18
|
+
function ensureDynamicLanguages() {
|
|
19
|
+
if (dynamicLanguagesRegistered)
|
|
20
|
+
return;
|
|
21
|
+
registerDynamicLanguage({
|
|
22
|
+
python,
|
|
23
|
+
go,
|
|
24
|
+
rust,
|
|
25
|
+
java,
|
|
26
|
+
cpp,
|
|
27
|
+
c,
|
|
28
|
+
json,
|
|
29
|
+
ruby,
|
|
30
|
+
}); // eslint-disable-line @typescript-eslint/no-explicit-any -- Required for ast-grep dynamic language registration (third-party API limitation)
|
|
31
|
+
dynamicLanguagesRegistered = true;
|
|
32
|
+
}
|
|
33
|
+
// Register on module load
|
|
34
|
+
ensureDynamicLanguages();
|
|
35
|
+
/**
|
|
36
|
+
* File extension to ast-grep language mapping.
|
|
37
|
+
* Single source of truth across all AST tools.
|
|
38
|
+
*/
|
|
39
|
+
export const LANGUAGE_MAP = {
|
|
40
|
+
ts: Lang.TypeScript,
|
|
41
|
+
js: Lang.JavaScript,
|
|
42
|
+
tsx: Lang.Tsx,
|
|
43
|
+
jsx: Lang.Tsx,
|
|
44
|
+
py: 'python',
|
|
45
|
+
rb: 'ruby',
|
|
46
|
+
go: 'go',
|
|
47
|
+
rs: 'rust',
|
|
48
|
+
java: 'java',
|
|
49
|
+
cpp: 'cpp',
|
|
50
|
+
c: 'c',
|
|
51
|
+
html: Lang.Html,
|
|
52
|
+
css: Lang.Css,
|
|
53
|
+
json: 'json',
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Reverse mapping from full language names to Lang/string values.
|
|
57
|
+
*/
|
|
58
|
+
const LANGUAGE_NAME_MAP = {
|
|
59
|
+
typescript: Lang.TypeScript,
|
|
60
|
+
javascript: Lang.JavaScript,
|
|
61
|
+
tsx: Lang.Tsx,
|
|
62
|
+
jsx: Lang.Tsx,
|
|
63
|
+
python: 'python',
|
|
64
|
+
ruby: 'ruby',
|
|
65
|
+
go: 'go',
|
|
66
|
+
rust: 'rust',
|
|
67
|
+
java: 'java',
|
|
68
|
+
cpp: 'cpp',
|
|
69
|
+
c: 'c',
|
|
70
|
+
html: Lang.Html,
|
|
71
|
+
css: Lang.Css,
|
|
72
|
+
json: 'json',
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* File extensions that belong to the JavaScript/TypeScript language family.
|
|
76
|
+
*/
|
|
77
|
+
export const JAVASCRIPT_FAMILY_EXTENSIONS = [
|
|
78
|
+
'ts',
|
|
79
|
+
'js',
|
|
80
|
+
'tsx',
|
|
81
|
+
'jsx',
|
|
82
|
+
];
|
|
83
|
+
/**
|
|
84
|
+
* Resolve a file extension or language name to an ast-grep language.
|
|
85
|
+
* Accepts both extensions ('ts', 'py') and full names ('typescript', 'python').
|
|
86
|
+
* Returns undefined for unrecognized inputs.
|
|
87
|
+
*/
|
|
88
|
+
export function getAstLanguage(extOrName) {
|
|
89
|
+
// Try extension first
|
|
90
|
+
if (extOrName in LANGUAGE_MAP) {
|
|
91
|
+
return LANGUAGE_MAP[extOrName];
|
|
92
|
+
}
|
|
93
|
+
// Try full name (case-insensitive)
|
|
94
|
+
const lower = extOrName.toLowerCase();
|
|
95
|
+
if (lower in LANGUAGE_NAME_MAP) {
|
|
96
|
+
return LANGUAGE_NAME_MAP[lower];
|
|
97
|
+
}
|
|
98
|
+
return undefined;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Detect the ast-grep language from a file path's extension.
|
|
102
|
+
* Returns undefined if the extension is not recognized.
|
|
103
|
+
*/
|
|
104
|
+
export function resolveLanguageFromPath(filePath) {
|
|
105
|
+
const ext = path.extname(filePath).slice(1); // remove the dot
|
|
106
|
+
if (!ext)
|
|
107
|
+
return undefined;
|
|
108
|
+
return LANGUAGE_MAP[ext];
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Check if @ast-grep/napi is available and usable.
|
|
112
|
+
*/
|
|
113
|
+
export function isAstGrepAvailable() {
|
|
114
|
+
try {
|
|
115
|
+
// If we got this far, the import succeeded
|
|
116
|
+
return typeof parse === 'function' && typeof findInFiles === 'function';
|
|
117
|
+
}
|
|
118
|
+
catch {
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Parse source code with error normalization.
|
|
124
|
+
* Returns { root } on success or { error } on failure.
|
|
125
|
+
* Does not throw.
|
|
126
|
+
*/
|
|
127
|
+
export function parseSource(language, content) {
|
|
128
|
+
try {
|
|
129
|
+
ensureDynamicLanguages();
|
|
130
|
+
const result = parse(language, content);
|
|
131
|
+
return { root: result };
|
|
132
|
+
}
|
|
133
|
+
catch (err) {
|
|
134
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
135
|
+
return { error: `Failed to parse source: ${message}` };
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
// Re-export ast-grep APIs for convenience
|
|
139
|
+
export { parse, Lang, findInFiles } from '@ast-grep/napi';
|
|
140
|
+
//# sourceMappingURL=ast-grep-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ast-grep-utils.js","sourceRoot":"","sources":["../../../src/utils/ast-grep-utils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,KAAK,EACL,IAAI,EACJ,WAAW,EACX,uBAAuB,GACxB,MAAM,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IAAI,OAAO,WAAW,KAAK,UAAU,CAAC;IAC1E,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,WAAW,CACzB,QAAuB,EACvB,OAAe;IAEf,IAAI,CAAC;QACH,sBAAsB,EAAE,CAAC;QACzB,MAAM,MAAM,GAAG,KAAK,CAAC,QAAgB,EAAE,OAAO,CAAC,CAAC;QAChD,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IAC1B,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,OAAO,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACjE,OAAO,EAAE,KAAK,EAAE,2BAA2B,OAAO,EAAE,EAAE,CAAC;IACzD,CAAC;AACH,CAAC;AAED,0CAA0C;AAC1C,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
export declare const debugLogger: {
|
|
7
|
+
error: (..._args: unknown[]) => void;
|
|
8
|
+
warn: (..._args: unknown[]) => void;
|
|
9
|
+
debug: (..._args: unknown[]) => void;
|
|
10
|
+
log: (..._args: unknown[]) => void;
|
|
11
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
export const debugLogger = {
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
8
|
+
error: (..._args) => { },
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
10
|
+
warn: (..._args) => { },
|
|
11
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
12
|
+
debug: (..._args) => { },
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
14
|
+
log: (..._args) => { },
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=debugLogger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debugLogger.js","sourceRoot":"","sources":["../../../src/utils/debugLogger.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,6DAA6D;IAC7D,KAAK,EAAE,CAAC,GAAG,KAAgB,EAAQ,EAAE,GAAE,CAAC;IACxC,6DAA6D;IAC7D,IAAI,EAAE,CAAC,GAAG,KAAgB,EAAQ,EAAE,GAAE,CAAC;IACvC,6DAA6D;IAC7D,KAAK,EAAE,CAAC,GAAG,KAAgB,EAAQ,EAAE,GAAE,CAAC;IACxC,6DAA6D;IAC7D,GAAG,EAAE,CAAC,GAAG,KAAgB,EAAQ,EAAE,GAAE,CAAC;CACvC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @plan:PLAN-20260608-ISSUE1585.P11
|
|
3
|
+
* @requirement:REQ-PKG-BOUNDARY
|
|
4
|
+
*/
|
|
5
|
+
import type { StructuredPatchOptionsNonabortable, CreatePatchOptionsNonabortable } from 'diff';
|
|
6
|
+
export interface DiffStat {
|
|
7
|
+
ai_removed_lines: number;
|
|
8
|
+
ai_added_lines: number;
|
|
9
|
+
user_added_lines: number;
|
|
10
|
+
user_removed_lines: number;
|
|
11
|
+
}
|
|
12
|
+
export declare const DEFAULT_DIFF_OPTIONS: StructuredPatchOptionsNonabortable;
|
|
13
|
+
export declare const DEFAULT_CREATE_PATCH_OPTIONS: CreatePatchOptionsNonabortable;
|
|
14
|
+
export declare function getDiffStat(fileName: string, oldStr: string, aiStr: string, userStr: string): DiffStat;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @plan:PLAN-20260608-ISSUE1585.P11
|
|
3
|
+
* @requirement:REQ-PKG-BOUNDARY
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @license
|
|
7
|
+
* Copyright 2025 Google LLC
|
|
8
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
9
|
+
*/
|
|
10
|
+
import * as Diff from 'diff';
|
|
11
|
+
export const DEFAULT_DIFF_OPTIONS = {
|
|
12
|
+
context: 3,
|
|
13
|
+
ignoreWhitespace: true,
|
|
14
|
+
};
|
|
15
|
+
export const DEFAULT_CREATE_PATCH_OPTIONS = {
|
|
16
|
+
context: 3,
|
|
17
|
+
ignoreWhitespace: true,
|
|
18
|
+
};
|
|
19
|
+
export function getDiffStat(fileName, oldStr, aiStr, userStr) {
|
|
20
|
+
const countLines = (patch) => {
|
|
21
|
+
let added = 0;
|
|
22
|
+
let removed = 0;
|
|
23
|
+
patch.hunks.forEach((hunk) => {
|
|
24
|
+
hunk.lines.forEach((line) => {
|
|
25
|
+
if (line.startsWith('+')) {
|
|
26
|
+
added++;
|
|
27
|
+
}
|
|
28
|
+
else if (line.startsWith('-')) {
|
|
29
|
+
removed++;
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
return { added, removed };
|
|
34
|
+
};
|
|
35
|
+
const patch = Diff.structuredPatch(fileName, fileName, oldStr, aiStr, 'Current', 'Proposed', DEFAULT_DIFF_OPTIONS);
|
|
36
|
+
const { added: aiAddedLines, removed: aiRemovedLines } = countLines(patch);
|
|
37
|
+
const userPatch = Diff.structuredPatch(fileName, fileName, aiStr, userStr, 'Proposed', 'User', DEFAULT_DIFF_OPTIONS);
|
|
38
|
+
const { added: userAddedLines, removed: userRemovedLines } = countLines(userPatch);
|
|
39
|
+
return {
|
|
40
|
+
ai_added_lines: aiAddedLines,
|
|
41
|
+
ai_removed_lines: aiRemovedLines,
|
|
42
|
+
user_added_lines: userAddedLines,
|
|
43
|
+
user_removed_lines: userRemovedLines,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=diffOptions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diffOptions.js","sourceRoot":"","sources":["../../../src/utils/diffOptions.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AAEH,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAe7B,MAAM,CAAC,MAAM,oBAAoB,GAAuC;IACtE,OAAO,EAAE,CAAC;IACV,gBAAgB,EAAE,IAAI;CACvB,CAAC;AAEF,MAAM,CAAC,MAAM,4BAA4B,GAAmC;IAC1E,OAAO,EAAE,CAAC;IACV,gBAAgB,EAAE,IAAI;CACvB,CAAC;AAEF,MAAM,UAAU,WAAW,CACzB,QAAgB,EAChB,MAAc,EACd,KAAa,EACb,OAAe;IAEf,MAAM,UAAU,GAAG,CAAC,KAAsB,EAAE,EAAE;QAC5C,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,IAAI,OAAO,GAAG,CAAC,CAAC;QAChB,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAyB,EAAE,EAAE;YAChD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAY,EAAE,EAAE;gBAClC,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;oBACzB,KAAK,EAAE,CAAC;gBACV,CAAC;qBAAM,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;oBAChC,OAAO,EAAE,CAAC;gBACZ,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QACH,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;IAC5B,CAAC,CAAC;IAEF,MAAM,KAAK,GAAG,IAAI,CAAC,eAAe,CAChC,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,KAAK,EACL,SAAS,EACT,UAAU,EACV,oBAAoB,CACrB,CAAC;IACF,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,cAAc,EAAE,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;IAE3E,MAAM,SAAS,GAAG,IAAI,CAAC,eAAe,CACpC,QAAQ,EACR,QAAQ,EACR,KAAK,EACL,OAAO,EACP,UAAU,EACV,MAAM,EACN,oBAAoB,CACrB,CAAC;IACF,MAAM,EAAE,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,gBAAgB,EAAE,GACxD,UAAU,CAAC,SAAS,CAAC,CAAC;IAExB,OAAO;QACL,cAAc,EAAE,YAAY;QAC5B,gBAAgB,EAAE,cAAc;QAChC,gBAAgB,EAAE,cAAc;QAChC,kBAAkB,EAAE,gBAAgB;KACrC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
declare const GUI_EDITORS: readonly ["vscode", "vscodium", "windsurf", "cursor", "zed", "antigravity"];
|
|
7
|
+
declare const TERMINAL_EDITORS: readonly ["vim", "neovim", "emacs", "hx"];
|
|
8
|
+
declare const EDITORS: readonly ["vscode", "vscodium", "windsurf", "cursor", "zed", "antigravity", "vim", "neovim", "emacs", "hx"];
|
|
9
|
+
export declare const DEFAULT_GUI_EDITOR: GuiEditorType;
|
|
10
|
+
export type GuiEditorType = (typeof GUI_EDITORS)[number];
|
|
11
|
+
export type TerminalEditorType = (typeof TERMINAL_EDITORS)[number];
|
|
12
|
+
export type EditorType = (typeof EDITORS)[number];
|
|
13
|
+
export declare function isGuiEditor(editor: EditorType): editor is GuiEditorType;
|
|
14
|
+
export declare function isTerminalEditor(editor: EditorType): editor is TerminalEditorType;
|
|
15
|
+
export declare const EDITOR_DISPLAY_NAMES: Record<EditorType, string>;
|
|
16
|
+
export declare function getEditorDisplayName(editor: EditorType): string;
|
|
17
|
+
interface DiffCommand {
|
|
18
|
+
command: string;
|
|
19
|
+
args: string[];
|
|
20
|
+
}
|
|
21
|
+
export declare function checkHasEditorType(editor: EditorType): boolean;
|
|
22
|
+
export declare function getEditorCommand(editor: EditorType): string;
|
|
23
|
+
export declare function allowEditorTypeInSandbox(editor: EditorType): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Check if the editor is valid and can be used.
|
|
26
|
+
* Returns false if preferred editor is not set / invalid / not available / not allowed in sandbox.
|
|
27
|
+
*/
|
|
28
|
+
export declare function isEditorAvailable(editor: string | undefined): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Get the diff command for a specific editor.
|
|
31
|
+
*/
|
|
32
|
+
export declare function getDiffCommand(oldPath: string, newPath: string, editor: EditorType): DiffCommand | null;
|
|
33
|
+
/**
|
|
34
|
+
* Opens a diff tool to compare two files.
|
|
35
|
+
* Terminal-based editors by default blocks parent process until the editor exits.
|
|
36
|
+
* GUI-based editors require args such as "--wait" to block parent process.
|
|
37
|
+
*/
|
|
38
|
+
export declare function openDiff(oldPath: string, newPath: string, editor: EditorType, onEditorClose?: () => void): Promise<void>;
|
|
39
|
+
export {};
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { execSync, spawn, spawnSync } from 'node:child_process';
|
|
7
|
+
const debugLogger = {
|
|
8
|
+
error: (..._args) => { },
|
|
9
|
+
};
|
|
10
|
+
const GUI_EDITORS = [
|
|
11
|
+
'vscode',
|
|
12
|
+
'vscodium',
|
|
13
|
+
'windsurf',
|
|
14
|
+
'cursor',
|
|
15
|
+
'zed',
|
|
16
|
+
'antigravity',
|
|
17
|
+
];
|
|
18
|
+
const TERMINAL_EDITORS = ['vim', 'neovim', 'emacs', 'hx'];
|
|
19
|
+
const EDITORS = [...GUI_EDITORS, ...TERMINAL_EDITORS];
|
|
20
|
+
const GUI_EDITORS_SET = new Set(GUI_EDITORS);
|
|
21
|
+
const TERMINAL_EDITORS_SET = new Set(TERMINAL_EDITORS);
|
|
22
|
+
const EDITORS_SET = new Set(EDITORS);
|
|
23
|
+
export const DEFAULT_GUI_EDITOR = 'vscode';
|
|
24
|
+
export function isGuiEditor(editor) {
|
|
25
|
+
return GUI_EDITORS_SET.has(editor);
|
|
26
|
+
}
|
|
27
|
+
export function isTerminalEditor(editor) {
|
|
28
|
+
return TERMINAL_EDITORS_SET.has(editor);
|
|
29
|
+
}
|
|
30
|
+
export const EDITOR_DISPLAY_NAMES = {
|
|
31
|
+
vscode: 'VS Code',
|
|
32
|
+
vscodium: 'VSCodium',
|
|
33
|
+
windsurf: 'Windsurf',
|
|
34
|
+
cursor: 'Cursor',
|
|
35
|
+
vim: 'Vim',
|
|
36
|
+
neovim: 'Neovim',
|
|
37
|
+
zed: 'Zed',
|
|
38
|
+
emacs: 'Emacs',
|
|
39
|
+
antigravity: 'Antigravity',
|
|
40
|
+
hx: 'Helix',
|
|
41
|
+
};
|
|
42
|
+
export function getEditorDisplayName(editor) {
|
|
43
|
+
return EDITOR_DISPLAY_NAMES[editor] || editor;
|
|
44
|
+
}
|
|
45
|
+
function isValidEditorType(editor) {
|
|
46
|
+
return EDITORS_SET.has(editor);
|
|
47
|
+
}
|
|
48
|
+
function commandExists(cmd) {
|
|
49
|
+
try {
|
|
50
|
+
// eslint-disable-next-line sonarjs/os-command -- Project intentionally invokes platform tooling at this trusted boundary; arguments remain explicit and behavior is preserved.
|
|
51
|
+
execSync(process.platform === 'win32' ? `where.exe ${cmd}` : `command -v ${cmd}`, { stdio: 'ignore' });
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Editor command configurations for different platforms.
|
|
60
|
+
* Each editor can have multiple possible command names, listed in order of preference.
|
|
61
|
+
*/
|
|
62
|
+
const editorCommands = {
|
|
63
|
+
vscode: { win32: ['code.cmd'], default: ['code'] },
|
|
64
|
+
vscodium: { win32: ['codium.cmd'], default: ['codium'] },
|
|
65
|
+
windsurf: { win32: ['windsurf'], default: ['windsurf'] },
|
|
66
|
+
cursor: { win32: ['cursor'], default: ['cursor'] },
|
|
67
|
+
vim: { win32: ['vim'], default: ['vim'] },
|
|
68
|
+
neovim: { win32: ['nvim'], default: ['nvim'] },
|
|
69
|
+
zed: { win32: ['zed'], default: ['zed', 'zeditor'] },
|
|
70
|
+
emacs: { win32: ['emacs.exe'], default: ['emacs'] },
|
|
71
|
+
antigravity: { win32: ['agy.cmd'], default: ['agy'] },
|
|
72
|
+
hx: { win32: ['hx'], default: ['hx'] },
|
|
73
|
+
};
|
|
74
|
+
export function checkHasEditorType(editor) {
|
|
75
|
+
const commandConfig = editorCommands[editor];
|
|
76
|
+
const commands = process.platform === 'win32' ? commandConfig.win32 : commandConfig.default;
|
|
77
|
+
return commands.some((cmd) => commandExists(cmd));
|
|
78
|
+
}
|
|
79
|
+
export function getEditorCommand(editor) {
|
|
80
|
+
const commandConfig = editorCommands[editor];
|
|
81
|
+
const commands = process.platform === 'win32' ? commandConfig.win32 : commandConfig.default;
|
|
82
|
+
return (
|
|
83
|
+
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- intentional falsy coalescing: commandExists returns boolean, falsy means command not found
|
|
84
|
+
commands.slice(0, -1).find((cmd) => commandExists(cmd)) ||
|
|
85
|
+
commands[commands.length - 1]);
|
|
86
|
+
}
|
|
87
|
+
export function allowEditorTypeInSandbox(editor) {
|
|
88
|
+
const notUsingSandbox = !process.env['SANDBOX'];
|
|
89
|
+
if (isGuiEditor(editor)) {
|
|
90
|
+
return notUsingSandbox;
|
|
91
|
+
}
|
|
92
|
+
// For terminal-based editors like vim and emacs, allow in sandbox.
|
|
93
|
+
return true;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Check if the editor is valid and can be used.
|
|
97
|
+
* Returns false if preferred editor is not set / invalid / not available / not allowed in sandbox.
|
|
98
|
+
*/
|
|
99
|
+
export function isEditorAvailable(editor) {
|
|
100
|
+
if (editor && isValidEditorType(editor)) {
|
|
101
|
+
return checkHasEditorType(editor) && allowEditorTypeInSandbox(editor);
|
|
102
|
+
}
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Get the diff command for a specific editor.
|
|
107
|
+
*/
|
|
108
|
+
export function getDiffCommand(oldPath, newPath, editor) {
|
|
109
|
+
if (!isValidEditorType(editor)) {
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
const command = getEditorCommand(editor);
|
|
113
|
+
switch (editor) {
|
|
114
|
+
case 'vscode':
|
|
115
|
+
case 'vscodium':
|
|
116
|
+
case 'windsurf':
|
|
117
|
+
case 'cursor':
|
|
118
|
+
case 'zed':
|
|
119
|
+
case 'antigravity':
|
|
120
|
+
return { command, args: ['--wait', '--diff', oldPath, newPath] };
|
|
121
|
+
case 'vim':
|
|
122
|
+
case 'neovim':
|
|
123
|
+
return {
|
|
124
|
+
command,
|
|
125
|
+
args: [
|
|
126
|
+
'-d',
|
|
127
|
+
// skip viminfo file to avoid E138 errors
|
|
128
|
+
'-i',
|
|
129
|
+
'NONE',
|
|
130
|
+
// make the left window read-only and the right window editable
|
|
131
|
+
'-c',
|
|
132
|
+
'wincmd h | set readonly | wincmd l',
|
|
133
|
+
// set up colors for diffs
|
|
134
|
+
'-c',
|
|
135
|
+
'highlight DiffAdd cterm=bold ctermbg=22 guibg=#005f00 | highlight DiffChange cterm=bold ctermbg=24 guibg=#005f87 | highlight DiffText ctermbg=21 guibg=#0000af | highlight DiffDelete ctermbg=52 guibg=#5f0000',
|
|
136
|
+
// Show helpful messages
|
|
137
|
+
'-c',
|
|
138
|
+
'set showtabline=2 | set tabline=[Instructions]\\ :wqa(save\\ &\\ quit)\\ \\|\\ i/esc(toggle\\ edit\\ mode)',
|
|
139
|
+
'-c',
|
|
140
|
+
'wincmd h | setlocal statusline=OLD\\ FILE',
|
|
141
|
+
'-c',
|
|
142
|
+
'wincmd l | setlocal statusline=%#StatusBold#NEW\\ FILE\\ :wqa(save\\ &\\ quit)\\ \\|\\ i/esc(toggle\\ edit\\ mode)',
|
|
143
|
+
// Auto close all windows when one is closed
|
|
144
|
+
'-c',
|
|
145
|
+
'autocmd BufWritePost * wqa',
|
|
146
|
+
oldPath,
|
|
147
|
+
newPath,
|
|
148
|
+
],
|
|
149
|
+
};
|
|
150
|
+
case 'emacs':
|
|
151
|
+
return {
|
|
152
|
+
command: 'emacs',
|
|
153
|
+
args: ['--eval', `(ediff "${oldPath}" "${newPath}")`],
|
|
154
|
+
};
|
|
155
|
+
case 'hx':
|
|
156
|
+
return {
|
|
157
|
+
command: 'hx',
|
|
158
|
+
args: ['--vsplit', '--', oldPath, newPath],
|
|
159
|
+
};
|
|
160
|
+
default:
|
|
161
|
+
return null;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Opens a diff tool to compare two files.
|
|
166
|
+
* Terminal-based editors by default blocks parent process until the editor exits.
|
|
167
|
+
* GUI-based editors require args such as "--wait" to block parent process.
|
|
168
|
+
*/
|
|
169
|
+
export async function openDiff(oldPath, newPath, editor, onEditorClose) {
|
|
170
|
+
const diffCommand = getDiffCommand(oldPath, newPath, editor);
|
|
171
|
+
if (!diffCommand) {
|
|
172
|
+
debugLogger.error('No diff tool available. Install a supported editor.');
|
|
173
|
+
return undefined;
|
|
174
|
+
}
|
|
175
|
+
if (isTerminalEditor(editor)) {
|
|
176
|
+
try {
|
|
177
|
+
const result = spawnSync(diffCommand.command, diffCommand.args, {
|
|
178
|
+
stdio: 'inherit',
|
|
179
|
+
});
|
|
180
|
+
if (result.error) {
|
|
181
|
+
throw result.error;
|
|
182
|
+
}
|
|
183
|
+
if (result.status !== 0) {
|
|
184
|
+
throw new Error(`${editor} exited with code ${result.status}`);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
finally {
|
|
188
|
+
onEditorClose?.();
|
|
189
|
+
}
|
|
190
|
+
return undefined;
|
|
191
|
+
}
|
|
192
|
+
await new Promise((resolve, reject) => {
|
|
193
|
+
const childProcess = spawn(diffCommand.command, diffCommand.args, {
|
|
194
|
+
stdio: 'inherit',
|
|
195
|
+
shell: process.platform === 'win32',
|
|
196
|
+
});
|
|
197
|
+
childProcess.on('close', (code) => {
|
|
198
|
+
onEditorClose?.();
|
|
199
|
+
if (code === 0) {
|
|
200
|
+
resolve();
|
|
201
|
+
}
|
|
202
|
+
else {
|
|
203
|
+
reject(new Error(`${editor} exited with code ${code}`));
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
childProcess.on('error', (error) => {
|
|
207
|
+
reject(error);
|
|
208
|
+
});
|
|
209
|
+
});
|
|
210
|
+
return undefined;
|
|
211
|
+
}
|
|
212
|
+
//# sourceMappingURL=editor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editor.js","sourceRoot":"","sources":["../../../src/utils/editor.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEhE,MAAM,WAAW,GAAG;IAClB,KAAK,EAAE,CAAC,GAAG,KAAgB,EAAE,EAAE,GAAE,CAAC;CACnC,CAAC;AAEF,MAAM,WAAW,GAAG;IAClB,QAAQ;IACR,UAAU;IACV,UAAU;IACV,QAAQ;IACR,KAAK;IACL,aAAa;CACL,CAAC;AACX,MAAM,gBAAgB,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,CAAU,CAAC;AACnE,MAAM,OAAO,GAAG,CAAC,GAAG,WAAW,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C;iBAAM,CAAC;gBACN,MAAM,CAAC,IAAI,KAAK,CAAC,GAAG,MAAM,qBAAqB,IAAI,EAAE,CAAC,CAAC,CAAC;YAC1D,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;YACjC,MAAM,CAAC,KAAK,CAAC,CAAC;QAChB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IACH,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Vybestack LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Ensures that the parent directories for a file path exist, creating them if necessary.
|
|
8
|
+
* @param filePath - The absolute path to the file
|
|
9
|
+
*/
|
|
10
|
+
export declare function ensureParentDirectoriesExist(filePath: string): Promise<void>;
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
/**
|
|
9
|
+
* Ensures that the parent directories for a file path exist, creating them if necessary.
|
|
10
|
+
* @param filePath - The absolute path to the file
|
|
11
|
+
*/
|
|
12
|
+
export async function ensureParentDirectoriesExist(filePath) {
|
|
13
|
+
const dirName = path.dirname(filePath);
|
|
14
|
+
await fsPromises.mkdir(dirName, { recursive: true });
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=ensure-dirs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ensure-dirs.js","sourceRoot":"","sources":["../../../src/utils/ensure-dirs.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,IAAI,UAAU,EAAE,MAAM,IAAI,CAAC;AAC5C,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,4BAA4B,CAChD,QAAgB;IAEhB,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACvC,MAAM,UAAU,CAAC,KAAK,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;AACvD,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
export declare function isNodeError(error: unknown): error is NodeJS.ErrnoException;
|
|
7
|
+
export declare function getErrorMessage(error: unknown): string;
|
|
8
|
+
export declare class FatalError extends Error {
|
|
9
|
+
readonly exitCode: number;
|
|
10
|
+
constructor(message: string, exitCode: number);
|
|
11
|
+
}
|
|
12
|
+
export declare class FatalAuthenticationError extends FatalError {
|
|
13
|
+
constructor(message: string);
|
|
14
|
+
}
|
|
15
|
+
export declare class FatalInputError extends FatalError {
|
|
16
|
+
constructor(message: string);
|
|
17
|
+
}
|
|
18
|
+
export declare class FatalSandboxError extends FatalError {
|
|
19
|
+
constructor(message: string);
|
|
20
|
+
}
|
|
21
|
+
export declare class FatalConfigError extends FatalError {
|
|
22
|
+
constructor(message: string);
|
|
23
|
+
}
|
|
24
|
+
export declare class FatalTurnLimitedError extends FatalError {
|
|
25
|
+
constructor(message: string);
|
|
26
|
+
}
|
|
27
|
+
export declare class FatalToolExecutionError extends FatalError {
|
|
28
|
+
constructor(message: string);
|
|
29
|
+
}
|
|
30
|
+
export declare class FatalCancellationError extends FatalError {
|
|
31
|
+
constructor(message: string);
|
|
32
|
+
}
|
|
33
|
+
export declare class ForbiddenError extends Error {
|
|
34
|
+
}
|
|
35
|
+
export declare class UnauthorizedError extends Error {
|
|
36
|
+
}
|
|
37
|
+
export declare class BadRequestError extends Error {
|
|
38
|
+
}
|
|
39
|
+
export declare class NotYetImplemented extends Error {
|
|
40
|
+
constructor(message?: string);
|
|
41
|
+
}
|
|
42
|
+
export declare function toFriendlyError(error: unknown): unknown;
|
|
43
|
+
/**
|
|
44
|
+
* Checks if an error is a 401 authentication error.
|
|
45
|
+
* Uses structured error properties from MCP SDK errors first.
|
|
46
|
+
*
|
|
47
|
+
* @plan PLAN-20250219-GMERGE021.R3.P03
|
|
48
|
+
* @requirement REQ-GMERGE021-R3-002
|
|
49
|
+
*/
|
|
50
|
+
export declare function isAuthenticationError(error: unknown): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Checks if an error is a 404 Not Found error with proper detection.
|
|
53
|
+
* Uses typed error checking first, falls back to anchored pattern matching.
|
|
54
|
+
* Avoids false positives from strings like "port 40404" or "code 4040".
|
|
55
|
+
*
|
|
56
|
+
* @param error - The error to check
|
|
57
|
+
* @returns True if the error is a 404 error
|
|
58
|
+
*/
|
|
59
|
+
export declare function is404Error(error: unknown): boolean;
|