@machina.ai/cell-cli-core 1.0.21-rc4 → 1.4.0-rc1
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/dist/index.d.ts +6 -2
- package/dist/index.js +6 -2
- package/dist/index.js.map +1 -1
- package/dist/package.json +25 -11
- package/dist/src/code_assist/codeAssist.d.ts +6 -3
- package/dist/src/code_assist/codeAssist.js +12 -0
- package/dist/src/code_assist/codeAssist.js.map +1 -1
- package/dist/src/code_assist/converter.d.ts +3 -1
- package/dist/src/code_assist/converter.js +37 -5
- package/dist/src/code_assist/converter.js.map +1 -1
- package/dist/src/code_assist/converter.test.js +83 -0
- package/dist/src/code_assist/converter.test.js.map +1 -1
- package/dist/src/code_assist/oauth2.d.ts +2 -1
- package/dist/src/code_assist/oauth2.js +85 -49
- package/dist/src/code_assist/oauth2.js.map +1 -1
- package/dist/src/code_assist/oauth2.test.js +317 -15
- package/dist/src/code_assist/oauth2.test.js.map +1 -1
- package/dist/src/code_assist/server.d.ts +5 -5
- package/dist/src/code_assist/server.js +1 -1
- package/dist/src/code_assist/server.js.map +1 -1
- package/dist/src/code_assist/setup.d.ts +1 -1
- package/dist/src/code_assist/setup.js +1 -1
- package/dist/src/code_assist/setup.js.map +1 -1
- package/dist/src/code_assist/setup.test.js.map +1 -1
- package/dist/src/config/config.d.ts +53 -15
- package/dist/src/config/config.js +127 -47
- package/dist/src/config/config.js.map +1 -1
- package/dist/src/config/config.test.js +151 -6
- package/dist/src/config/config.test.js.map +1 -1
- package/dist/src/config/models.d.ts +1 -0
- package/dist/src/config/models.js +2 -0
- package/dist/src/config/models.js.map +1 -1
- package/dist/src/config/storage.d.ts +32 -0
- package/dist/src/config/storage.js +90 -0
- package/dist/src/config/storage.js.map +1 -0
- package/dist/src/config/storage.test.js +43 -0
- package/dist/src/config/storage.test.js.map +1 -0
- package/dist/src/core/client.d.ts +21 -11
- package/dist/src/core/client.js +83 -26
- package/dist/src/core/client.js.map +1 -1
- package/dist/src/core/client.test.js +398 -88
- package/dist/src/core/client.test.js.map +1 -1
- package/dist/src/core/contentGenerator.d.ts +6 -6
- package/dist/src/core/contentGenerator.js +4 -3
- package/dist/src/core/contentGenerator.js.map +1 -1
- package/dist/src/core/contentGenerator.test.js.map +1 -1
- package/dist/src/core/coreToolScheduler.d.ts +14 -5
- package/dist/src/core/coreToolScheduler.js +120 -49
- package/dist/src/core/coreToolScheduler.js.map +1 -1
- package/dist/src/core/coreToolScheduler.test.js +383 -72
- package/dist/src/core/coreToolScheduler.test.js.map +1 -1
- package/dist/src/core/geminiChat.d.ts +48 -15
- package/dist/src/core/geminiChat.js +327 -154
- package/dist/src/core/geminiChat.js.map +1 -1
- package/dist/src/core/geminiChat.test.js +1041 -257
- package/dist/src/core/geminiChat.test.js.map +1 -1
- package/dist/src/core/geminiRequest.js +1 -0
- package/dist/src/core/geminiRequest.js.map +1 -1
- package/dist/src/core/logger.d.ts +4 -2
- package/dist/src/core/logger.js +4 -3
- package/dist/src/core/logger.js.map +1 -1
- package/dist/src/core/logger.test.js +19 -18
- package/dist/src/core/logger.test.js.map +1 -1
- package/dist/src/core/loggingContentGenerator.d.ts +3 -3
- package/dist/src/core/loggingContentGenerator.js +11 -9
- package/dist/src/core/loggingContentGenerator.js.map +1 -1
- package/dist/src/core/nonInteractiveToolExecutor.d.ts +3 -5
- package/dist/src/core/nonInteractiveToolExecutor.js +15 -123
- package/dist/src/core/nonInteractiveToolExecutor.js.map +1 -1
- package/dist/src/core/nonInteractiveToolExecutor.test.js +116 -90
- package/dist/src/core/nonInteractiveToolExecutor.test.js.map +1 -1
- package/dist/src/core/prompts.js +8 -7
- package/dist/src/core/prompts.js.map +1 -1
- package/dist/src/core/prompts.test.js +21 -21
- package/dist/src/core/prompts.test.js.map +1 -1
- package/dist/src/core/subagent.d.ts +24 -18
- package/dist/src/core/subagent.js +126 -89
- package/dist/src/core/subagent.js.map +1 -1
- package/dist/src/core/subagent.test.js +51 -35
- package/dist/src/core/subagent.test.js.map +1 -1
- package/dist/src/core/turn.d.ts +33 -8
- package/dist/src/core/turn.js +59 -14
- package/dist/src/core/turn.js.map +1 -1
- package/dist/src/core/turn.test.js +349 -90
- package/dist/src/core/turn.test.js.map +1 -1
- package/dist/src/generated/git-commit.d.ts +2 -2
- package/dist/src/generated/git-commit.js +2 -2
- package/dist/src/generated/git-commit.js.map +1 -1
- package/dist/src/ide/constants.d.ts +1 -1
- package/dist/src/ide/constants.js +1 -1
- package/dist/src/ide/constants.js.map +1 -1
- package/dist/src/ide/detect-ide.d.ts +8 -3
- package/dist/src/ide/detect-ide.js +29 -11
- package/dist/src/ide/detect-ide.js.map +1 -1
- package/dist/src/ide/detect-ide.test.js +96 -52
- package/dist/src/ide/detect-ide.test.js.map +1 -1
- package/dist/src/ide/ide-client.d.ts +18 -9
- package/dist/src/ide/ide-client.js +151 -33
- package/dist/src/ide/ide-client.js.map +1 -1
- package/dist/src/ide/ide-client.test.js +147 -25
- package/dist/src/ide/ide-client.test.js.map +1 -1
- package/dist/src/ide/ide-installer.d.ts +1 -1
- package/dist/src/ide/ide-installer.js +31 -22
- package/dist/src/ide/ide-installer.js.map +1 -1
- package/dist/src/ide/ide-installer.test.js +82 -22
- package/dist/src/ide/ide-installer.test.js.map +1 -1
- package/dist/src/ide/ideContext.d.ts +12 -0
- package/dist/src/ide/ideContext.js +1 -0
- package/dist/src/ide/ideContext.js.map +1 -1
- package/dist/src/ide/process-utils.d.ts +13 -6
- package/dist/src/ide/process-utils.js +142 -35
- package/dist/src/ide/process-utils.js.map +1 -1
- package/dist/src/ide/process-utils.test.js +158 -0
- package/dist/src/ide/process-utils.test.js.map +1 -0
- package/dist/src/index.d.ts +12 -2
- package/dist/src/index.js +11 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/mcp/google-auth-provider.d.ts +3 -3
- package/dist/src/mcp/google-auth-provider.test.js.map +1 -1
- package/dist/src/mcp/oauth-provider.d.ts +13 -13
- package/dist/src/mcp/oauth-provider.js +32 -31
- package/dist/src/mcp/oauth-provider.js.map +1 -1
- package/dist/src/mcp/oauth-provider.test.js +75 -36
- package/dist/src/mcp/oauth-provider.test.js.map +1 -1
- package/dist/src/mcp/oauth-token-storage.d.ts +9 -31
- package/dist/src/mcp/oauth-token-storage.js +10 -13
- package/dist/src/mcp/oauth-token-storage.js.map +1 -1
- package/dist/src/mcp/oauth-token-storage.test.js +30 -27
- package/dist/src/mcp/oauth-token-storage.test.js.map +1 -1
- package/dist/src/mcp/oauth-utils.d.ts +9 -1
- package/dist/src/mcp/oauth-utils.js +41 -27
- package/dist/src/mcp/oauth-utils.js.map +1 -1
- package/dist/src/mcp/oauth-utils.test.js +41 -1
- package/dist/src/mcp/oauth-utils.test.js.map +1 -1
- package/dist/src/mcp/token-storage/base-token-storage.d.ts +19 -0
- package/dist/src/mcp/token-storage/base-token-storage.js +36 -0
- package/dist/src/mcp/token-storage/base-token-storage.js.map +1 -0
- package/dist/src/mcp/token-storage/base-token-storage.test.d.ts +6 -0
- package/dist/src/mcp/token-storage/base-token-storage.test.js +160 -0
- package/dist/src/mcp/token-storage/base-token-storage.test.js.map +1 -0
- package/dist/src/mcp/token-storage/file-token-storage.d.ts +24 -0
- package/dist/src/mcp/token-storage/file-token-storage.js +144 -0
- package/dist/src/mcp/token-storage/file-token-storage.js.map +1 -0
- package/dist/src/mcp/token-storage/file-token-storage.test.d.ts +6 -0
- package/dist/src/mcp/token-storage/file-token-storage.test.js +235 -0
- package/dist/src/mcp/token-storage/file-token-storage.test.js.map +1 -0
- package/dist/src/mcp/token-storage/hybrid-token-storage.d.ts +23 -0
- package/dist/src/mcp/token-storage/hybrid-token-storage.js +78 -0
- package/dist/src/mcp/token-storage/hybrid-token-storage.js.map +1 -0
- package/dist/src/mcp/token-storage/hybrid-token-storage.test.d.ts +6 -0
- package/dist/src/mcp/token-storage/hybrid-token-storage.test.js +193 -0
- package/dist/src/mcp/token-storage/hybrid-token-storage.test.js.map +1 -0
- package/dist/src/mcp/token-storage/keychain-token-storage.d.ts +31 -0
- package/dist/src/mcp/token-storage/keychain-token-storage.js +190 -0
- package/dist/src/mcp/token-storage/keychain-token-storage.js.map +1 -0
- package/dist/src/mcp/token-storage/keychain-token-storage.test.d.ts +6 -0
- package/dist/src/mcp/token-storage/keychain-token-storage.test.js +254 -0
- package/dist/src/mcp/token-storage/keychain-token-storage.test.js.map +1 -0
- package/dist/src/mcp/token-storage/types.d.ts +38 -0
- package/dist/src/mcp/token-storage/types.js +11 -0
- package/dist/src/mcp/token-storage/types.js.map +1 -0
- package/dist/src/prompts/mcp-prompts.d.ts +2 -2
- package/dist/src/prompts/prompt-registry.d.ts +1 -1
- package/dist/src/services/chatRecordingService.d.ts +6 -13
- package/dist/src/services/chatRecordingService.js +31 -19
- package/dist/src/services/chatRecordingService.js.map +1 -1
- package/dist/src/services/chatRecordingService.test.js +64 -25
- package/dist/src/services/chatRecordingService.test.js.map +1 -1
- package/dist/src/services/fileDiscoveryService.js +1 -1
- package/dist/src/services/fileDiscoveryService.js.map +1 -1
- package/dist/src/services/fileDiscoveryService.test.js +3 -3
- package/dist/src/services/fileDiscoveryService.test.js.map +1 -1
- package/dist/src/services/fileSystemService.js +1 -1
- package/dist/src/services/fileSystemService.js.map +1 -1
- package/dist/src/services/fileSystemService.test.js +1 -1
- package/dist/src/services/fileSystemService.test.js.map +1 -1
- package/dist/src/services/gitService.d.ts +3 -1
- package/dist/src/services/gitService.js +21 -12
- package/dist/src/services/gitService.js.map +1 -1
- package/dist/src/services/gitService.test.js +22 -19
- package/dist/src/services/gitService.test.js.map +1 -1
- package/dist/src/services/loopDetectionService.d.ts +3 -2
- package/dist/src/services/loopDetectionService.js +28 -4
- package/dist/src/services/loopDetectionService.js.map +1 -1
- package/dist/src/services/loopDetectionService.test.js +23 -1
- package/dist/src/services/loopDetectionService.test.js.map +1 -1
- package/dist/src/services/shellExecutionService.d.ts +8 -10
- package/dist/src/services/shellExecutionService.js +292 -135
- package/dist/src/services/shellExecutionService.js.map +1 -1
- package/dist/src/services/shellExecutionService.test.js +277 -42
- package/dist/src/services/shellExecutionService.test.js.map +1 -1
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.d.ts +18 -4
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.js +171 -11
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.js.map +1 -1
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.js +103 -11
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.js.map +1 -1
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.d.ts +31 -1
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.js +75 -0
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.js.map +1 -1
- package/dist/src/telemetry/constants.d.ts +9 -0
- package/dist/src/telemetry/constants.js +9 -0
- package/dist/src/telemetry/constants.js.map +1 -1
- package/dist/src/telemetry/file-exporters.d.ts +5 -4
- package/dist/src/telemetry/file-exporters.js +1 -1
- package/dist/src/telemetry/file-exporters.js.map +1 -1
- package/dist/src/telemetry/index.d.ts +5 -2
- package/dist/src/telemetry/index.js +3 -2
- package/dist/src/telemetry/index.js.map +1 -1
- package/dist/src/telemetry/loggers.d.ts +8 -2
- package/dist/src/telemetry/loggers.js +130 -2
- package/dist/src/telemetry/loggers.js.map +1 -1
- package/dist/src/telemetry/loggers.test.circular.js.map +1 -1
- package/dist/src/telemetry/loggers.test.js +105 -9
- package/dist/src/telemetry/loggers.test.js.map +1 -1
- package/dist/src/telemetry/metrics.d.ts +15 -4
- package/dist/src/telemetry/metrics.js +46 -8
- package/dist/src/telemetry/metrics.js.map +1 -1
- package/dist/src/telemetry/metrics.test.js +5 -25
- package/dist/src/telemetry/metrics.test.js.map +1 -1
- package/dist/src/telemetry/sdk.d.ts +1 -1
- package/dist/src/telemetry/sdk.js +3 -3
- package/dist/src/telemetry/sdk.js.map +1 -1
- package/dist/src/telemetry/telemetry-utils.d.ts +6 -0
- package/dist/src/telemetry/telemetry-utils.js +14 -0
- package/dist/src/telemetry/telemetry-utils.js.map +1 -0
- package/dist/src/telemetry/telemetry-utils.test.d.ts +6 -0
- package/dist/src/telemetry/telemetry-utils.test.js +40 -0
- package/dist/src/telemetry/telemetry-utils.test.js.map +1 -0
- package/dist/src/telemetry/types.d.ts +61 -6
- package/dist/src/telemetry/types.js +105 -4
- package/dist/src/telemetry/types.js.map +1 -1
- package/dist/src/telemetry/uiTelemetry.d.ts +2 -2
- package/dist/src/telemetry/uiTelemetry.js +5 -5
- package/dist/src/telemetry/uiTelemetry.js.map +1 -1
- package/dist/src/telemetry/uiTelemetry.test.js +20 -16
- package/dist/src/telemetry/uiTelemetry.test.js.map +1 -1
- package/dist/src/test-utils/config.d.ts +2 -1
- package/dist/src/test-utils/config.js.map +1 -1
- package/dist/src/test-utils/index.d.ts +6 -0
- package/dist/src/test-utils/index.js +7 -0
- package/dist/src/test-utils/index.js.map +1 -0
- package/dist/src/test-utils/mock-tool.d.ts +41 -0
- package/dist/src/test-utils/mock-tool.js +51 -0
- package/dist/src/test-utils/mock-tool.js.map +1 -0
- package/dist/src/test-utils/mockWorkspaceContext.d.ts +1 -1
- package/dist/src/test-utils/tools.d.ts +3 -2
- package/dist/src/test-utils/tools.js.map +1 -1
- package/dist/src/tools/diffOptions.d.ts +1 -1
- package/dist/src/tools/diffOptions.js +21 -13
- package/dist/src/tools/diffOptions.js.map +1 -1
- package/dist/src/tools/diffOptions.test.js +58 -22
- package/dist/src/tools/diffOptions.test.js.map +1 -1
- package/dist/src/tools/edit.d.ts +6 -5
- package/dist/src/tools/edit.js +47 -36
- package/dist/src/tools/edit.js.map +1 -1
- package/dist/src/tools/edit.test.js +77 -12
- package/dist/src/tools/edit.test.js.map +1 -1
- package/dist/src/tools/glob.d.ts +3 -2
- package/dist/src/tools/glob.js +17 -6
- package/dist/src/tools/glob.js.map +1 -1
- package/dist/src/tools/glob.test.js +29 -4
- package/dist/src/tools/glob.test.js.map +1 -1
- package/dist/src/tools/grep.d.ts +3 -2
- package/dist/src/tools/grep.js +35 -15
- package/dist/src/tools/grep.js.map +1 -1
- package/dist/src/tools/grep.test.js +26 -3
- package/dist/src/tools/grep.test.js.map +1 -1
- package/dist/src/tools/ls.d.ts +3 -2
- package/dist/src/tools/ls.js +12 -7
- package/dist/src/tools/ls.js.map +1 -1
- package/dist/src/tools/ls.test.js +7 -2
- package/dist/src/tools/ls.test.js.map +1 -1
- package/dist/src/tools/mcp-client-manager.d.ts +8 -6
- package/dist/src/tools/mcp-client-manager.js +30 -5
- package/dist/src/tools/mcp-client-manager.js.map +1 -1
- package/dist/src/tools/mcp-client-manager.test.js +20 -1
- package/dist/src/tools/mcp-client-manager.test.js.map +1 -1
- package/dist/src/tools/mcp-client.d.ts +18 -11
- package/dist/src/tools/mcp-client.js +67 -57
- package/dist/src/tools/mcp-client.js.map +1 -1
- package/dist/src/tools/mcp-client.test.js +29 -4
- package/dist/src/tools/mcp-client.test.js.map +1 -1
- package/dist/src/tools/mcp-tool.d.ts +6 -4
- package/dist/src/tools/mcp-tool.js +21 -11
- package/dist/src/tools/mcp-tool.js.map +1 -1
- package/dist/src/tools/mcp-tool.test.js +49 -12
- package/dist/src/tools/mcp-tool.test.js.map +1 -1
- package/dist/src/tools/memoryTool.d.ts +4 -3
- package/dist/src/tools/memoryTool.js +15 -38
- package/dist/src/tools/memoryTool.js.map +1 -1
- package/dist/src/tools/memoryTool.test.js +24 -12
- package/dist/src/tools/memoryTool.test.js.map +1 -1
- package/dist/src/tools/modifiable-tool.d.ts +2 -2
- package/dist/src/tools/modifiable-tool.js +3 -3
- package/dist/src/tools/modifiable-tool.js.map +1 -1
- package/dist/src/tools/modifiable-tool.test.js +4 -4
- package/dist/src/tools/modifiable-tool.test.js.map +1 -1
- package/dist/src/tools/read-file.d.ts +3 -2
- package/dist/src/tools/read-file.js +12 -34
- package/dist/src/tools/read-file.js.map +1 -1
- package/dist/src/tools/read-file.test.js +9 -6
- package/dist/src/tools/read-file.test.js.map +1 -1
- package/dist/src/tools/read-many-files.d.ts +3 -2
- package/dist/src/tools/read-many-files.js +35 -58
- package/dist/src/tools/read-many-files.js.map +1 -1
- package/dist/src/tools/read-many-files.test.js +64 -11
- package/dist/src/tools/read-many-files.test.js.map +1 -1
- package/dist/src/tools/ripGrep.d.ts +47 -0
- package/dist/src/tools/ripGrep.js +368 -0
- package/dist/src/tools/ripGrep.js.map +1 -0
- package/dist/src/tools/ripGrep.test.d.ts +6 -0
- package/dist/src/tools/ripGrep.test.js +874 -0
- package/dist/src/tools/ripGrep.test.js.map +1 -0
- package/dist/src/tools/shell.d.ts +3 -2
- package/dist/src/tools/shell.js +30 -25
- package/dist/src/tools/shell.js.map +1 -1
- package/dist/src/tools/shell.test.js +34 -25
- package/dist/src/tools/shell.test.js.map +1 -1
- package/dist/src/tools/smart-edit.d.ts +73 -0
- package/dist/src/tools/smart-edit.js +607 -0
- package/dist/src/tools/smart-edit.js.map +1 -0
- package/dist/src/tools/smart-edit.test.d.ts +6 -0
- package/dist/src/tools/smart-edit.test.js +405 -0
- package/dist/src/tools/smart-edit.test.js.map +1 -0
- package/dist/src/tools/tool-error.d.ts +17 -1
- package/dist/src/tools/tool-error.js +26 -0
- package/dist/src/tools/tool-error.js.map +1 -1
- package/dist/src/tools/tool-registry.d.ts +10 -4
- package/dist/src/tools/tool-registry.js +19 -7
- package/dist/src/tools/tool-registry.js.map +1 -1
- package/dist/src/tools/tool-registry.test.js +86 -3
- package/dist/src/tools/tool-registry.test.js.map +1 -1
- package/dist/src/tools/tools.d.ts +15 -9
- package/dist/src/tools/tools.js +12 -0
- package/dist/src/tools/tools.js.map +1 -1
- package/dist/src/tools/tools.test.js +1 -2
- package/dist/src/tools/tools.test.js.map +1 -1
- package/dist/src/tools/web-fetch.d.ts +3 -2
- package/dist/src/tools/web-fetch.js +14 -10
- package/dist/src/tools/web-fetch.js.map +1 -1
- package/dist/src/tools/web-fetch.test.js +55 -16
- package/dist/src/tools/web-fetch.test.js.map +1 -1
- package/dist/src/tools/web-search.d.ts +4 -3
- package/dist/src/tools/web-search.js +31 -8
- package/dist/src/tools/web-search.js.map +1 -1
- package/dist/src/tools/web-search.test.js +69 -1
- package/dist/src/tools/web-search.test.js.map +1 -1
- package/dist/src/tools/write-file.d.ts +4 -3
- package/dist/src/tools/write-file.js +14 -14
- package/dist/src/tools/write-file.js.map +1 -1
- package/dist/src/tools/write-file.test.js +14 -14
- package/dist/src/tools/write-file.test.js.map +1 -1
- package/dist/src/utils/bfsFileSearch.d.ts +2 -2
- package/dist/src/utils/bfsFileSearch.js +2 -2
- package/dist/src/utils/bfsFileSearch.js.map +1 -1
- package/dist/src/utils/bfsFileSearch.test.js +3 -3
- package/dist/src/utils/bfsFileSearch.test.js.map +1 -1
- package/dist/src/utils/editCorrector.d.ts +2 -2
- package/dist/src/utils/editCorrector.js +1 -1
- package/dist/src/utils/editCorrector.js.map +1 -1
- package/dist/src/utils/editCorrector.test.js +3 -3
- package/dist/src/utils/editCorrector.test.js.map +1 -1
- package/dist/src/utils/editor.js +2 -2
- package/dist/src/utils/editor.js.map +1 -1
- package/dist/src/utils/editor.test.js +2 -2
- package/dist/src/utils/editor.test.js.map +1 -1
- package/dist/src/utils/environmentContext.d.ts +2 -2
- package/dist/src/utils/environmentContext.js +1 -1
- package/dist/src/utils/environmentContext.js.map +1 -1
- package/dist/src/utils/environmentContext.test.js +1 -1
- package/dist/src/utils/environmentContext.test.js.map +1 -1
- package/dist/src/utils/errorReporting.d.ts +1 -1
- package/dist/src/utils/errors.d.ts +19 -0
- package/dist/src/utils/errors.js +32 -0
- package/dist/src/utils/errors.js.map +1 -1
- package/dist/src/utils/fetch.js +1 -1
- package/dist/src/utils/fetch.js.map +1 -1
- package/dist/src/utils/fileUtils.d.ts +23 -12
- package/dist/src/utils/fileUtils.js +160 -79
- package/dist/src/utils/fileUtils.js.map +1 -1
- package/dist/src/utils/fileUtils.test.js +314 -21
- package/dist/src/utils/fileUtils.test.js.map +1 -1
- package/dist/src/utils/filesearch/crawler.d.ts +1 -1
- package/dist/src/utils/filesearch/crawler.test.js +2 -2
- package/dist/src/utils/filesearch/crawler.test.js.map +1 -1
- package/dist/src/utils/filesearch/fileSearch.d.ts +1 -0
- package/dist/src/utils/filesearch/fileSearch.js +14 -9
- package/dist/src/utils/filesearch/fileSearch.js.map +1 -1
- package/dist/src/utils/filesearch/fileSearch.test.js +90 -0
- package/dist/src/utils/filesearch/fileSearch.test.js.map +1 -1
- package/dist/src/utils/generateContentResponseUtilities.d.ts +1 -2
- package/dist/src/utils/generateContentResponseUtilities.js +1 -13
- package/dist/src/utils/generateContentResponseUtilities.js.map +1 -1
- package/dist/src/utils/generateContentResponseUtilities.test.js +2 -40
- package/dist/src/utils/generateContentResponseUtilities.test.js.map +1 -1
- package/dist/src/utils/getFolderStructure.d.ts +2 -2
- package/dist/src/utils/getFolderStructure.js +2 -2
- package/dist/src/utils/getFolderStructure.js.map +1 -1
- package/dist/src/utils/getFolderStructure.test.js +13 -13
- package/dist/src/utils/getFolderStructure.test.js.map +1 -1
- package/dist/src/utils/getPty.d.ts +19 -0
- package/dist/src/utils/getPty.js +23 -0
- package/dist/src/utils/getPty.js.map +1 -0
- package/dist/src/utils/gitIgnoreParser.d.ts +1 -0
- package/dist/src/utils/gitIgnoreParser.js +104 -13
- package/dist/src/utils/gitIgnoreParser.js.map +1 -1
- package/dist/src/utils/gitIgnoreParser.test.js +69 -3
- package/dist/src/utils/gitIgnoreParser.test.js.map +1 -1
- package/dist/src/utils/gitUtils.js +2 -2
- package/dist/src/utils/gitUtils.js.map +1 -1
- package/dist/src/utils/ide-trust.d.ts +10 -0
- package/dist/src/utils/ide-trust.js +14 -0
- package/dist/src/utils/ide-trust.js.map +1 -0
- package/dist/src/utils/ignorePatterns.d.ts +103 -0
- package/dist/src/utils/ignorePatterns.js +220 -0
- package/dist/src/utils/ignorePatterns.js.map +1 -0
- package/dist/src/utils/ignorePatterns.test.d.ts +6 -0
- package/dist/src/utils/ignorePatterns.test.js +250 -0
- package/dist/src/utils/ignorePatterns.test.js.map +1 -0
- package/dist/src/utils/installationManager.d.ts +16 -0
- package/dist/src/utils/installationManager.js +50 -0
- package/dist/src/utils/installationManager.js.map +1 -0
- package/dist/src/utils/installationManager.test.d.ts +6 -0
- package/dist/src/utils/installationManager.test.js +83 -0
- package/dist/src/utils/installationManager.test.js.map +1 -0
- package/dist/src/utils/language-detection.d.ts +6 -0
- package/dist/src/utils/language-detection.js +101 -0
- package/dist/src/utils/language-detection.js.map +1 -0
- package/dist/src/utils/llm-edit-fixer.d.ts +25 -0
- package/dist/src/utils/llm-edit-fixer.js +112 -0
- package/dist/src/utils/llm-edit-fixer.js.map +1 -0
- package/dist/src/utils/memoryDiscovery.d.ts +7 -6
- package/dist/src/utils/memoryDiscovery.js +68 -33
- package/dist/src/utils/memoryDiscovery.js.map +1 -1
- package/dist/src/utils/memoryDiscovery.test.js +76 -20
- package/dist/src/utils/memoryDiscovery.test.js.map +1 -1
- package/dist/src/utils/memoryImportProcessor.js +2 -2
- package/dist/src/utils/memoryImportProcessor.js.map +1 -1
- package/dist/src/utils/memoryImportProcessor.test.js +2 -141
- package/dist/src/utils/memoryImportProcessor.test.js.map +1 -1
- package/dist/src/utils/messageInspectors.d.ts +1 -1
- package/dist/src/utils/nextSpeakerChecker.d.ts +2 -2
- package/dist/src/utils/nextSpeakerChecker.test.js +33 -0
- package/dist/src/utils/nextSpeakerChecker.test.js.map +1 -1
- package/dist/src/utils/partUtils.d.ts +22 -1
- package/dist/src/utils/partUtils.js +68 -0
- package/dist/src/utils/partUtils.js.map +1 -1
- package/dist/src/utils/partUtils.test.js +112 -1
- package/dist/src/utils/partUtils.test.js.map +1 -1
- package/dist/src/utils/pathReader.d.ts +17 -0
- package/dist/src/utils/pathReader.js +92 -0
- package/dist/src/utils/pathReader.js.map +1 -0
- package/dist/src/utils/pathReader.test.d.ts +6 -0
- package/dist/src/utils/pathReader.test.js +363 -0
- package/dist/src/utils/pathReader.test.js.map +1 -0
- package/dist/src/utils/paths.d.ts +1 -18
- package/dist/src/utils/paths.js +3 -29
- package/dist/src/utils/paths.js.map +1 -1
- package/dist/src/utils/quotaErrorDetection.d.ts +1 -1
- package/dist/src/utils/retry.test.js +4 -1
- package/dist/src/utils/retry.test.js.map +1 -1
- package/dist/src/utils/schemaValidator.js +4 -0
- package/dist/src/utils/schemaValidator.js.map +1 -1
- package/dist/src/utils/session.js +1 -1
- package/dist/src/utils/session.js.map +1 -1
- package/dist/src/utils/shell-utils.d.ts +1 -1
- package/dist/src/utils/shell-utils.js +23 -29
- package/dist/src/utils/shell-utils.js.map +1 -1
- package/dist/src/utils/shell-utils.test.js +7 -0
- package/dist/src/utils/shell-utils.test.js.map +1 -1
- package/dist/src/utils/summarizer.d.ts +2 -2
- package/dist/src/utils/summarizer.test.js.map +1 -1
- package/dist/src/utils/systemEncoding.js +2 -2
- package/dist/src/utils/systemEncoding.js.map +1 -1
- package/dist/src/utils/systemEncoding.test.js +2 -2
- package/dist/src/utils/systemEncoding.test.js.map +1 -1
- package/dist/src/utils/tool-utils.d.ts +19 -0
- package/dist/src/utils/tool-utils.js +58 -0
- package/dist/src/utils/tool-utils.js.map +1 -0
- package/dist/src/utils/tool-utils.test.d.ts +6 -0
- package/dist/src/utils/tool-utils.test.js +61 -0
- package/dist/src/utils/tool-utils.test.js.map +1 -0
- package/dist/src/utils/userAccountManager.d.ts +20 -0
- package/dist/src/utils/userAccountManager.js +114 -0
- package/dist/src/utils/userAccountManager.js.map +1 -0
- package/dist/src/utils/userAccountManager.test.d.ts +6 -0
- package/dist/src/utils/{user_account.test.js → userAccountManager.test.js} +33 -30
- package/dist/src/utils/userAccountManager.test.js.map +1 -0
- package/dist/src/utils/workspaceContext.js +13 -7
- package/dist/src/utils/workspaceContext.js.map +1 -1
- package/dist/src/utils/workspaceContext.test.js +41 -16
- package/dist/src/utils/workspaceContext.test.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +27 -13
- package/dist/src/utils/user_account.d.ts +0 -9
- package/dist/src/utils/user_account.js +0 -109
- package/dist/src/utils/user_account.js.map +0 -1
- package/dist/src/utils/user_account.test.js.map +0 -1
- package/dist/src/utils/user_id.d.ts +0 -11
- package/dist/src/utils/user_id.js +0 -49
- package/dist/src/utils/user_id.js.map +0 -1
- package/dist/src/utils/user_id.test.js +0 -21
- package/dist/src/utils/user_id.test.js.map +0 -1
- /package/dist/src/{utils/user_account.test.d.ts → config/storage.test.d.ts} +0 -0
- /package/dist/src/{utils/user_id.test.d.ts → ide/process-utils.test.d.ts} +0 -0
|
@@ -3,20 +3,23 @@
|
|
|
3
3
|
* Copyright 2025 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
-
import * as child_process from 'child_process';
|
|
7
|
-
import * as process from 'process';
|
|
8
|
-
import * as path from 'path';
|
|
9
|
-
import * as fs from 'fs';
|
|
10
|
-
import * as os from 'os';
|
|
11
|
-
import { DetectedIde } from './detect-ide.js';
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
|
|
6
|
+
import * as child_process from 'node:child_process';
|
|
7
|
+
import * as process from 'node:process';
|
|
8
|
+
import * as path from 'node:path';
|
|
9
|
+
import * as fs from 'node:fs';
|
|
10
|
+
import * as os from 'node:os';
|
|
11
|
+
import { DetectedIde, getIdeInfo } from './detect-ide.js';
|
|
12
|
+
import { CELL_CLI_COMPANION_EXTENSION_NAME } from './constants.js';
|
|
13
|
+
function getVsCodeCommand(platform = process.platform) {
|
|
14
|
+
return platform === 'win32' ? 'code.cmd' : 'code';
|
|
15
|
+
}
|
|
16
|
+
async function findVsCodeCommand(platform = process.platform) {
|
|
15
17
|
// 1. Check PATH first.
|
|
18
|
+
const vscodeCommand = getVsCodeCommand(platform);
|
|
16
19
|
try {
|
|
17
|
-
if (
|
|
20
|
+
if (platform === 'win32') {
|
|
18
21
|
const result = child_process
|
|
19
|
-
.execSync(`where.exe ${
|
|
22
|
+
.execSync(`where.exe ${vscodeCommand}`)
|
|
20
23
|
.toString()
|
|
21
24
|
.trim();
|
|
22
25
|
// `where.exe` can return multiple paths. Return the first one.
|
|
@@ -26,10 +29,10 @@ async function findVsCodeCommand() {
|
|
|
26
29
|
}
|
|
27
30
|
}
|
|
28
31
|
else {
|
|
29
|
-
child_process.execSync(`command -v ${
|
|
32
|
+
child_process.execSync(`command -v ${vscodeCommand}`, {
|
|
30
33
|
stdio: 'ignore',
|
|
31
34
|
});
|
|
32
|
-
return
|
|
35
|
+
return vscodeCommand;
|
|
33
36
|
}
|
|
34
37
|
}
|
|
35
38
|
catch {
|
|
@@ -37,7 +40,6 @@ async function findVsCodeCommand() {
|
|
|
37
40
|
}
|
|
38
41
|
// 2. Check common installation locations.
|
|
39
42
|
const locations = [];
|
|
40
|
-
const platform = process.platform;
|
|
41
43
|
const homeDir = os.homedir();
|
|
42
44
|
if (platform === 'darwin') {
|
|
43
45
|
// macOS
|
|
@@ -49,7 +51,7 @@ async function findVsCodeCommand() {
|
|
|
49
51
|
}
|
|
50
52
|
else if (platform === 'win32') {
|
|
51
53
|
// Windows
|
|
52
|
-
locations.push(path.join(process.env['ProgramFiles'] || 'C:\\
|
|
54
|
+
locations.push(path.join(process.env['ProgramFiles'] || 'C:\\Program Files', 'Microsoft VS Code', 'bin', 'code.cmd'), path.join(homeDir, 'AppData', 'Local', 'Programs', 'Microsoft VS Code', 'bin', 'code.cmd'));
|
|
53
55
|
}
|
|
54
56
|
for (const location of locations) {
|
|
55
57
|
if (fs.existsSync(location)) {
|
|
@@ -59,16 +61,22 @@ async function findVsCodeCommand() {
|
|
|
59
61
|
return null;
|
|
60
62
|
}
|
|
61
63
|
class VsCodeInstaller {
|
|
64
|
+
ide;
|
|
65
|
+
platform;
|
|
62
66
|
vsCodeCommand;
|
|
63
|
-
|
|
64
|
-
|
|
67
|
+
ideInfo;
|
|
68
|
+
constructor(ide, platform = process.platform) {
|
|
69
|
+
this.ide = ide;
|
|
70
|
+
this.platform = platform;
|
|
71
|
+
this.vsCodeCommand = findVsCodeCommand(platform);
|
|
72
|
+
this.ideInfo = getIdeInfo(ide);
|
|
65
73
|
}
|
|
66
74
|
async install() {
|
|
67
75
|
const commandPath = await this.vsCodeCommand;
|
|
68
76
|
if (!commandPath) {
|
|
69
77
|
return {
|
|
70
78
|
success: false,
|
|
71
|
-
message:
|
|
79
|
+
message: `${this.ideInfo.displayName} CLI not found. Please ensure 'code' is in your system's PATH. For help, see https://code.visualstudio.com/docs/configure/command-line#_code-is-not-recognized-as-an-internal-or-external-command. You can also install the '${CELL_CLI_COMPANION_EXTENSION_NAME}' extension manually from the VS Code marketplace.`,
|
|
72
80
|
};
|
|
73
81
|
}
|
|
74
82
|
const command = `"${commandPath}" --install-extension nova-solutions.cell-cli-vscode-ide-companion --force`;
|
|
@@ -76,21 +84,22 @@ class VsCodeInstaller {
|
|
|
76
84
|
child_process.execSync(command, { stdio: 'pipe' });
|
|
77
85
|
return {
|
|
78
86
|
success: true,
|
|
79
|
-
message:
|
|
87
|
+
message: `${this.ideInfo.displayName} companion extension was installed successfully.`,
|
|
80
88
|
};
|
|
81
89
|
}
|
|
82
90
|
catch (_error) {
|
|
83
91
|
return {
|
|
84
92
|
success: false,
|
|
85
|
-
message: `Failed to install
|
|
93
|
+
message: `Failed to install ${this.ideInfo.displayName} companion extension. Please try installing '${CELL_CLI_COMPANION_EXTENSION_NAME}' manually from the ${this.ideInfo.displayName} extension marketplace.`,
|
|
86
94
|
};
|
|
87
95
|
}
|
|
88
96
|
}
|
|
89
97
|
}
|
|
90
|
-
export function getIdeInstaller(ide) {
|
|
98
|
+
export function getIdeInstaller(ide, platform = process.platform) {
|
|
91
99
|
switch (ide) {
|
|
92
100
|
case DetectedIde.VSCode:
|
|
93
|
-
|
|
101
|
+
case DetectedIde.FirebaseStudio:
|
|
102
|
+
return new VsCodeInstaller(ide, platform);
|
|
94
103
|
default:
|
|
95
104
|
return null;
|
|
96
105
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ide-installer.js","sourceRoot":"","sources":["../../../src/ide/ide-installer.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,aAAa,MAAM,
|
|
1
|
+
{"version":3,"file":"ide-installer.js","sourceRoot":"","sources":["../../../src/ide/ide-installer.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AACxC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,WAAW,EAAE,UAAU,EAAgB,MAAM,iBAAiB,CAAC;AACxE,OAAO,EAAE,iCAAiC,EAAE,MAAM,gBAAgB,CAAC;AAEnE,SAAS,gBAAgB,CAAC,WAA4B,OAAO,CAAC,QAAQ;IACpE,OAAO,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC;AACpD,CAAC;AAWD,KAAK,UAAU,iBAAiB,CAC9B,WAA4B,OAAO,CAAC,QAAQ;IAE5C,uBAAuB;IACvB,MAAM,aAAa,GAAG,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IACjD,IAAI,CAAC;QACH,IAAI,QAAQ,KAAK,OAAO,EAAE,CAAC;YACzB,MAAM,MAAM,GAAG,aAAa;iBACzB,QAAQ,CAAC,aAAa,aAAa,EAAE,CAAC;iBACtC,QAAQ,EAAE;iBACV,IAAI,EAAE,CAAC;YACV,+DAA+D;YAC/D,MAAM,SAAS,GAAG,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;YAC3C,IAAI,SAAS,EAAE,CAAC;gBACd,OAAO,SAAS,CAAC;YACnB,CAAC;QACH,CAAC;aAAM,CAAC;YACN,aAAa,CAAC,QAAQ,CAAC,cAAc,aAAa,EAA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,IAAI,CAAC;IAChB,CAAC;AACH,CAAC"}
|
|
@@ -5,47 +5,107 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { vi, describe, it, expect, beforeEach, afterEach } from 'vitest';
|
|
7
7
|
import { getIdeInstaller } from './ide-installer.js';
|
|
8
|
-
import * as child_process from 'child_process';
|
|
9
|
-
import * as fs from 'fs';
|
|
10
|
-
import * as os from 'os';
|
|
8
|
+
import * as child_process from 'node:child_process';
|
|
9
|
+
import * as fs from 'node:fs';
|
|
10
|
+
import * as os from 'node:os';
|
|
11
|
+
import * as path from 'node:path';
|
|
11
12
|
import { DetectedIde } from './detect-ide.js';
|
|
12
13
|
vi.mock('child_process');
|
|
13
14
|
vi.mock('fs');
|
|
14
15
|
vi.mock('os');
|
|
15
16
|
describe('ide-installer', () => {
|
|
17
|
+
const HOME_DIR = '/home/user';
|
|
16
18
|
beforeEach(() => {
|
|
17
|
-
vi.spyOn(os, 'homedir').mockReturnValue(
|
|
19
|
+
vi.spyOn(os, 'homedir').mockReturnValue(HOME_DIR);
|
|
18
20
|
});
|
|
19
21
|
afterEach(() => {
|
|
20
22
|
vi.restoreAllMocks();
|
|
21
23
|
});
|
|
22
24
|
describe('getIdeInstaller', () => {
|
|
23
|
-
it('
|
|
24
|
-
const installer = getIdeInstaller(
|
|
25
|
+
it.each([{ ide: DetectedIde.VSCode }, { ide: DetectedIde.FirebaseStudio }])('returns a VsCodeInstaller for "$ide"', ({ ide }) => {
|
|
26
|
+
const installer = getIdeInstaller(ide);
|
|
25
27
|
expect(installer).not.toBeNull();
|
|
26
|
-
|
|
27
|
-
expect(installer).toBeInstanceOf(Object);
|
|
28
|
+
expect(installer?.install).toEqual(expect.any(Function));
|
|
28
29
|
});
|
|
29
30
|
});
|
|
30
31
|
describe('VsCodeInstaller', () => {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
installer = getIdeInstaller(
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
});
|
|
32
|
+
function setup({ ide = DetectedIde.VSCode, existsResult = false, execSync = () => '', platform = 'linux', } = {}) {
|
|
33
|
+
vi.spyOn(child_process, 'execSync').mockImplementation(execSync);
|
|
34
|
+
vi.spyOn(fs, 'existsSync').mockReturnValue(existsResult);
|
|
35
|
+
const installer = getIdeInstaller(ide, platform);
|
|
36
|
+
return { installer };
|
|
37
|
+
}
|
|
38
38
|
describe('install', () => {
|
|
39
|
-
it(
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
it.each([
|
|
40
|
+
{
|
|
41
|
+
platform: 'win32',
|
|
42
|
+
expectedLookupPaths: [
|
|
43
|
+
path.join('C:\\Program Files', 'Microsoft VS Code/bin/code.cmd'),
|
|
44
|
+
path.join(HOME_DIR, '/AppData/Local/Programs/Microsoft VS Code/bin/code.cmd'),
|
|
45
|
+
],
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
platform: 'darwin',
|
|
49
|
+
expectedLookupPaths: [
|
|
50
|
+
'/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code',
|
|
51
|
+
path.join(HOME_DIR, 'Library/Application Support/Code/bin/code'),
|
|
52
|
+
],
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
platform: 'linux',
|
|
56
|
+
expectedLookupPaths: ['/usr/share/code/bin/code'],
|
|
57
|
+
},
|
|
58
|
+
])('identifies the path to code cli on platform: $platform', async ({ platform, expectedLookupPaths }) => {
|
|
59
|
+
const { installer } = setup({
|
|
60
|
+
platform,
|
|
61
|
+
execSync: () => {
|
|
62
|
+
throw new Error('Command not found'); // `code` is not in PATH
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
await installer.install();
|
|
66
|
+
for (const [idx, path] of expectedLookupPaths.entries()) {
|
|
67
|
+
expect(fs.existsSync).toHaveBeenNthCalledWith(idx + 1, path);
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
it('installs the extension using code cli', async () => {
|
|
71
|
+
const { installer } = setup({
|
|
72
|
+
platform: 'linux',
|
|
73
|
+
});
|
|
74
|
+
await installer.install();
|
|
75
|
+
expect(child_process.execSync).toHaveBeenCalledWith('"code" --install-extension nova-solutions.cell-cli-vscode-ide-companion --force', { stdio: 'pipe' });
|
|
76
|
+
});
|
|
77
|
+
it.each([
|
|
78
|
+
{
|
|
79
|
+
ide: DetectedIde.VSCode,
|
|
80
|
+
expectedMessage: 'VS Code companion extension was installed successfully',
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
ide: DetectedIde.FirebaseStudio,
|
|
84
|
+
expectedMessage: 'Firebase Studio companion extension was installed successfully',
|
|
85
|
+
},
|
|
86
|
+
])('returns that the cli was installed successfully', async ({ ide, expectedMessage }) => {
|
|
87
|
+
const { installer } = setup({ ide });
|
|
88
|
+
const result = await installer.install();
|
|
89
|
+
expect(result.success).toBe(true);
|
|
90
|
+
expect(result.message).toContain(expectedMessage);
|
|
91
|
+
});
|
|
92
|
+
it.each([
|
|
93
|
+
{ ide: DetectedIde.VSCode, expectedErr: 'VS Code CLI not found' },
|
|
94
|
+
{
|
|
95
|
+
ide: DetectedIde.FirebaseStudio,
|
|
96
|
+
expectedErr: 'Firebase Studio CLI not found',
|
|
97
|
+
},
|
|
98
|
+
])('should return a failure message if $ide is not installed', async ({ ide, expectedErr }) => {
|
|
99
|
+
const { installer } = setup({
|
|
100
|
+
ide,
|
|
101
|
+
execSync: () => {
|
|
102
|
+
throw new Error('Command not found');
|
|
103
|
+
},
|
|
104
|
+
existsResult: false,
|
|
42
105
|
});
|
|
43
|
-
vi.spyOn(fs, 'existsSync').mockReturnValue(false);
|
|
44
|
-
// Re-create the installer so it re-runs findVsCodeCommand
|
|
45
|
-
installer = getIdeInstaller(DetectedIde.VSCode);
|
|
46
106
|
const result = await installer.install();
|
|
47
107
|
expect(result.success).toBe(false);
|
|
48
|
-
expect(result.message).toContain(
|
|
108
|
+
expect(result.message).toContain(expectedErr);
|
|
49
109
|
});
|
|
50
110
|
});
|
|
51
111
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ide-installer.test.js","sourceRoot":"","sources":["../../../src/ide/ide-installer.test.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACzE,OAAO,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"ide-installer.test.js","sourceRoot":"","sources":["../../../src/ide/ide-installer.test.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACzE,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,EAAE,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;AACzB,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACd,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAEd,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;IAC7B,MAAM,QAAQ,GAAG,YAAY,CAAC;IAE9B,UAAU,CAAC,GAAG,EAAE;QACd,EAAE,CAAC,KAAK,CAAC,EAAE,EAAE,SAAS,CAAC,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;IACpD,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,GAAG,EAAE;QACb,EAAE,CAAC,eAAe,EAAE,CAAC;IACvB,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,iBAAiB,EAAE,GA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CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -78,6 +78,7 @@ export declare const IdeContextSchema: z.ZodObject<{
|
|
|
78
78
|
isActive?: boolean | undefined;
|
|
79
79
|
selectedText?: string | undefined;
|
|
80
80
|
}>, "many">>;
|
|
81
|
+
isTrusted: z.ZodOptional<z.ZodBoolean>;
|
|
81
82
|
}, "strip", z.ZodTypeAny, {
|
|
82
83
|
openFiles?: {
|
|
83
84
|
path: string;
|
|
@@ -89,6 +90,7 @@ export declare const IdeContextSchema: z.ZodObject<{
|
|
|
89
90
|
isActive?: boolean | undefined;
|
|
90
91
|
selectedText?: string | undefined;
|
|
91
92
|
}[] | undefined;
|
|
93
|
+
isTrusted?: boolean | undefined;
|
|
92
94
|
}, {
|
|
93
95
|
openFiles?: {
|
|
94
96
|
path: string;
|
|
@@ -100,6 +102,7 @@ export declare const IdeContextSchema: z.ZodObject<{
|
|
|
100
102
|
isActive?: boolean | undefined;
|
|
101
103
|
selectedText?: string | undefined;
|
|
102
104
|
}[] | undefined;
|
|
105
|
+
isTrusted?: boolean | undefined;
|
|
103
106
|
}>>;
|
|
104
107
|
}, "strip", z.ZodTypeAny, {
|
|
105
108
|
workspaceState?: {
|
|
@@ -113,6 +116,7 @@ export declare const IdeContextSchema: z.ZodObject<{
|
|
|
113
116
|
isActive?: boolean | undefined;
|
|
114
117
|
selectedText?: string | undefined;
|
|
115
118
|
}[] | undefined;
|
|
119
|
+
isTrusted?: boolean | undefined;
|
|
116
120
|
} | undefined;
|
|
117
121
|
}, {
|
|
118
122
|
workspaceState?: {
|
|
@@ -126,6 +130,7 @@ export declare const IdeContextSchema: z.ZodObject<{
|
|
|
126
130
|
isActive?: boolean | undefined;
|
|
127
131
|
selectedText?: string | undefined;
|
|
128
132
|
}[] | undefined;
|
|
133
|
+
isTrusted?: boolean | undefined;
|
|
129
134
|
} | undefined;
|
|
130
135
|
}>;
|
|
131
136
|
export type IdeContext = z.infer<typeof IdeContextSchema>;
|
|
@@ -171,6 +176,7 @@ export declare const IdeContextNotificationSchema: z.ZodObject<{
|
|
|
171
176
|
isActive?: boolean | undefined;
|
|
172
177
|
selectedText?: string | undefined;
|
|
173
178
|
}>, "many">>;
|
|
179
|
+
isTrusted: z.ZodOptional<z.ZodBoolean>;
|
|
174
180
|
}, "strip", z.ZodTypeAny, {
|
|
175
181
|
openFiles?: {
|
|
176
182
|
path: string;
|
|
@@ -182,6 +188,7 @@ export declare const IdeContextNotificationSchema: z.ZodObject<{
|
|
|
182
188
|
isActive?: boolean | undefined;
|
|
183
189
|
selectedText?: string | undefined;
|
|
184
190
|
}[] | undefined;
|
|
191
|
+
isTrusted?: boolean | undefined;
|
|
185
192
|
}, {
|
|
186
193
|
openFiles?: {
|
|
187
194
|
path: string;
|
|
@@ -193,6 +200,7 @@ export declare const IdeContextNotificationSchema: z.ZodObject<{
|
|
|
193
200
|
isActive?: boolean | undefined;
|
|
194
201
|
selectedText?: string | undefined;
|
|
195
202
|
}[] | undefined;
|
|
203
|
+
isTrusted?: boolean | undefined;
|
|
196
204
|
}>>;
|
|
197
205
|
}, "strip", z.ZodTypeAny, {
|
|
198
206
|
workspaceState?: {
|
|
@@ -206,6 +214,7 @@ export declare const IdeContextNotificationSchema: z.ZodObject<{
|
|
|
206
214
|
isActive?: boolean | undefined;
|
|
207
215
|
selectedText?: string | undefined;
|
|
208
216
|
}[] | undefined;
|
|
217
|
+
isTrusted?: boolean | undefined;
|
|
209
218
|
} | undefined;
|
|
210
219
|
}, {
|
|
211
220
|
workspaceState?: {
|
|
@@ -219,6 +228,7 @@ export declare const IdeContextNotificationSchema: z.ZodObject<{
|
|
|
219
228
|
isActive?: boolean | undefined;
|
|
220
229
|
selectedText?: string | undefined;
|
|
221
230
|
}[] | undefined;
|
|
231
|
+
isTrusted?: boolean | undefined;
|
|
222
232
|
} | undefined;
|
|
223
233
|
}>;
|
|
224
234
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -234,6 +244,7 @@ export declare const IdeContextNotificationSchema: z.ZodObject<{
|
|
|
234
244
|
isActive?: boolean | undefined;
|
|
235
245
|
selectedText?: string | undefined;
|
|
236
246
|
}[] | undefined;
|
|
247
|
+
isTrusted?: boolean | undefined;
|
|
237
248
|
} | undefined;
|
|
238
249
|
};
|
|
239
250
|
jsonrpc: "2.0";
|
|
@@ -251,6 +262,7 @@ export declare const IdeContextNotificationSchema: z.ZodObject<{
|
|
|
251
262
|
isActive?: boolean | undefined;
|
|
252
263
|
selectedText?: string | undefined;
|
|
253
264
|
}[] | undefined;
|
|
265
|
+
isTrusted?: boolean | undefined;
|
|
254
266
|
} | undefined;
|
|
255
267
|
};
|
|
256
268
|
jsonrpc: "2.0";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ideContext.js","sourceRoot":"","sources":["../../../src/ide/ideContext.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,CAAC;IACjC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;IACrB,QAAQ,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IAChC,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACnC,MAAM,EAAE,CAAC;SACN,MAAM,CAAC;QACN,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;QAChB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;KACtB,CAAC;SACD,QAAQ,EAAE;CACd,CAAC,CAAC;AAGH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;IACvC,cAAc,EAAE,CAAC;SACd,MAAM,CAAC;QACN,SAAS,EAAE,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,QAAQ,EA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IACJ,CAAC;IAED,OAAO;QACL,aAAa;QACb,aAAa;QACb,qBAAqB;QACrB,eAAe;KAChB,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,qBAAqB,EAAE,CAAC"}
|
|
@@ -4,11 +4,18 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
/**
|
|
7
|
-
* Traverses up the process tree
|
|
8
|
-
* This is useful for identifying the main application process that spawned the current script,
|
|
9
|
-
* such as the main VS Code window process.
|
|
7
|
+
* Traverses up the process tree to find the process ID and command of the IDE.
|
|
10
8
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
9
|
+
* This function uses different strategies depending on the operating system
|
|
10
|
+
* to identify the main application process (e.g., the main VS Code window
|
|
11
|
+
* process).
|
|
12
|
+
*
|
|
13
|
+
* If the IDE process cannot be reliably identified, it will return the
|
|
14
|
+
* top-level ancestor process ID and command as a fallback.
|
|
15
|
+
*
|
|
16
|
+
* @returns A promise that resolves to the PID and command of the IDE process.
|
|
13
17
|
*/
|
|
14
|
-
export declare function
|
|
18
|
+
export declare function getIdeProcessInfo(): Promise<{
|
|
19
|
+
pid: number;
|
|
20
|
+
command: string;
|
|
21
|
+
}>;
|
|
@@ -3,55 +3,162 @@
|
|
|
3
3
|
* Copyright 2025 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
-
import { exec } from 'child_process';
|
|
7
|
-
import { promisify } from 'util';
|
|
8
|
-
import os from 'os';
|
|
6
|
+
import { exec } from 'node:child_process';
|
|
7
|
+
import { promisify } from 'node:util';
|
|
8
|
+
import os from 'node:os';
|
|
9
|
+
import path from 'node:path';
|
|
9
10
|
const execAsync = promisify(exec);
|
|
11
|
+
const MAX_TRAVERSAL_DEPTH = 32;
|
|
10
12
|
/**
|
|
11
|
-
*
|
|
12
|
-
* This is useful for identifying the main application process that spawned the current script,
|
|
13
|
-
* such as the main VS Code window process.
|
|
13
|
+
* Fetches the parent process ID, name, and command for a given process ID.
|
|
14
14
|
*
|
|
15
|
-
* @
|
|
16
|
-
* @
|
|
15
|
+
* @param pid The process ID to inspect.
|
|
16
|
+
* @returns A promise that resolves to the parent's PID, name, and command.
|
|
17
17
|
*/
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
async function getProcessInfo(pid) {
|
|
19
|
+
try {
|
|
20
|
+
const platform = os.platform();
|
|
21
|
+
if (platform === 'win32') {
|
|
22
|
+
const powershellCommand = [
|
|
23
|
+
'$p = Get-CimInstance Win32_Process',
|
|
24
|
+
`-Filter 'ProcessId=${pid}'`,
|
|
25
|
+
'-ErrorAction SilentlyContinue;',
|
|
26
|
+
'if ($p) {',
|
|
27
|
+
'@{Name=$p.Name;ParentProcessId=$p.ParentProcessId;CommandLine=$p.CommandLine}',
|
|
28
|
+
'| ConvertTo-Json',
|
|
29
|
+
'}',
|
|
30
|
+
].join(' ');
|
|
31
|
+
const { stdout } = await execAsync(`powershell "${powershellCommand}"`);
|
|
32
|
+
const output = stdout.trim();
|
|
33
|
+
if (!output)
|
|
34
|
+
return { parentPid: 0, name: '', command: '' };
|
|
35
|
+
const { Name = '', ParentProcessId = 0, CommandLine = '', } = JSON.parse(output);
|
|
36
|
+
return { parentPid: ParentProcessId, name: Name, command: CommandLine };
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
const command = `ps -o ppid=,command= -p ${pid}`;
|
|
40
|
+
const { stdout } = await execAsync(command);
|
|
41
|
+
const trimmedStdout = stdout.trim();
|
|
42
|
+
const ppidString = trimmedStdout.split(/\s+/)[0];
|
|
43
|
+
const parentPid = parseInt(ppidString, 10);
|
|
44
|
+
const fullCommand = trimmedStdout.substring(ppidString.length).trim();
|
|
45
|
+
const processName = path.basename(fullCommand.split(' ')[0]);
|
|
46
|
+
return {
|
|
47
|
+
parentPid: isNaN(parentPid) ? 1 : parentPid,
|
|
48
|
+
name: processName,
|
|
49
|
+
command: fullCommand,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
catch (_e) {
|
|
54
|
+
console.debug(`Failed to get process info for pid ${pid}:`, _e);
|
|
55
|
+
return { parentPid: 0, name: '', command: '' };
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Finds the IDE process info on Unix-like systems.
|
|
60
|
+
*
|
|
61
|
+
* The strategy is to find the shell process that spawned the CLI, and then
|
|
62
|
+
* find that shell's parent process (the IDE). To get the true IDE process,
|
|
63
|
+
* we traverse one level higher to get the grandparent.
|
|
64
|
+
*
|
|
65
|
+
* @returns A promise that resolves to the PID and command of the IDE process.
|
|
66
|
+
*/
|
|
67
|
+
async function getIdeProcessInfoForUnix() {
|
|
68
|
+
const shells = ['zsh', 'bash', 'sh', 'tcsh', 'csh', 'ksh', 'fish', 'dash'];
|
|
20
69
|
let currentPid = process.pid;
|
|
21
|
-
// Loop upwards through the process tree, with a depth limit to prevent infinite loops.
|
|
22
|
-
const MAX_TRAVERSAL_DEPTH = 32;
|
|
23
70
|
for (let i = 0; i < MAX_TRAVERSAL_DEPTH; i++) {
|
|
24
|
-
let parentPid;
|
|
25
71
|
try {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
72
|
+
const { parentPid, name } = await getProcessInfo(currentPid);
|
|
73
|
+
const isShell = shells.some((shell) => name === shell);
|
|
74
|
+
if (isShell) {
|
|
75
|
+
// The direct parent of the shell is often a utility process (e.g. VS
|
|
76
|
+
// Code's `ptyhost` process). To get the true IDE process, we need to
|
|
77
|
+
// traverse one level higher to get the grandparent.
|
|
78
|
+
let idePid = parentPid;
|
|
79
|
+
try {
|
|
80
|
+
const { parentPid: grandParentPid } = await getProcessInfo(parentPid);
|
|
81
|
+
if (grandParentPid > 1) {
|
|
82
|
+
idePid = grandParentPid;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
catch {
|
|
86
|
+
// Ignore if getting grandparent fails, we'll just use the parent pid.
|
|
87
|
+
}
|
|
88
|
+
const { command } = await getProcessInfo(idePid);
|
|
89
|
+
return { pid: idePid, command };
|
|
32
90
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const command = `ps -o ppid= -p ${currentPid}`;
|
|
36
|
-
const { stdout } = await execAsync(command);
|
|
37
|
-
const ppid = parseInt(stdout.trim(), 10);
|
|
38
|
-
parentPid = isNaN(ppid) ? 1 : ppid; // Top of the tree is 1
|
|
91
|
+
if (parentPid <= 1) {
|
|
92
|
+
break; // Reached the root
|
|
39
93
|
}
|
|
94
|
+
currentPid = parentPid;
|
|
40
95
|
}
|
|
41
|
-
catch
|
|
42
|
-
//
|
|
43
|
-
// We'll break the loop and return the last valid PID we found.
|
|
96
|
+
catch {
|
|
97
|
+
// Process in chain died
|
|
44
98
|
break;
|
|
45
99
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
100
|
+
}
|
|
101
|
+
const { command } = await getProcessInfo(currentPid);
|
|
102
|
+
return { pid: currentPid, command };
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Finds the IDE process info on Windows.
|
|
106
|
+
*
|
|
107
|
+
* The strategy is to find the great-grandchild of the root process.
|
|
108
|
+
*
|
|
109
|
+
* @returns A promise that resolves to the PID and command of the IDE process.
|
|
110
|
+
*/
|
|
111
|
+
async function getIdeProcessInfoForWindows() {
|
|
112
|
+
let currentPid = process.pid;
|
|
113
|
+
let previousPid = process.pid;
|
|
114
|
+
for (let i = 0; i < MAX_TRAVERSAL_DEPTH; i++) {
|
|
115
|
+
try {
|
|
116
|
+
const { parentPid } = await getProcessInfo(currentPid);
|
|
117
|
+
if (parentPid > 0) {
|
|
118
|
+
try {
|
|
119
|
+
const { parentPid: grandParentPid } = await getProcessInfo(parentPid);
|
|
120
|
+
if (grandParentPid === 0) {
|
|
121
|
+
// We've found the grandchild of the root (`currentPid`). The IDE
|
|
122
|
+
// process is its child, which we've stored in `previousPid`.
|
|
123
|
+
const { command } = await getProcessInfo(previousPid);
|
|
124
|
+
return { pid: previousPid, command };
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
catch {
|
|
128
|
+
// getting grandparent failed, proceed
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
if (parentPid <= 0) {
|
|
132
|
+
break; // Reached the root
|
|
133
|
+
}
|
|
134
|
+
previousPid = currentPid;
|
|
135
|
+
currentPid = parentPid;
|
|
136
|
+
}
|
|
137
|
+
catch {
|
|
138
|
+
// Process in chain died
|
|
50
139
|
break;
|
|
51
140
|
}
|
|
52
|
-
// Move one level up the tree for the next iteration.
|
|
53
|
-
currentPid = parentPid;
|
|
54
141
|
}
|
|
55
|
-
|
|
142
|
+
const { command } = await getProcessInfo(currentPid);
|
|
143
|
+
return { pid: currentPid, command };
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Traverses up the process tree to find the process ID and command of the IDE.
|
|
147
|
+
*
|
|
148
|
+
* This function uses different strategies depending on the operating system
|
|
149
|
+
* to identify the main application process (e.g., the main VS Code window
|
|
150
|
+
* process).
|
|
151
|
+
*
|
|
152
|
+
* If the IDE process cannot be reliably identified, it will return the
|
|
153
|
+
* top-level ancestor process ID and command as a fallback.
|
|
154
|
+
*
|
|
155
|
+
* @returns A promise that resolves to the PID and command of the IDE process.
|
|
156
|
+
*/
|
|
157
|
+
export async function getIdeProcessInfo() {
|
|
158
|
+
const platform = os.platform();
|
|
159
|
+
if (platform === 'win32') {
|
|
160
|
+
return getIdeProcessInfoForWindows();
|
|
161
|
+
}
|
|
162
|
+
return getIdeProcessInfoForUnix();
|
|
56
163
|
}
|
|
57
164
|
//# sourceMappingURL=process-utils.js.map
|