@iaforged/context-code 2.1.6 → 2.1.7
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/src/Task.js +1 -1
- package/dist/src/commands/add-dir/add-dir.js +1 -1
- package/dist/src/commands/add-dir/validation.js +1 -1
- package/dist/src/constants/oauth.js +1 -1
- package/dist/src/context/mailbox.js +1 -1
- package/dist/src/context/voice.js +1 -1
- package/dist/src/hooks/useTerminalSize.js +1 -1
- package/dist/src/ink/Ansi.js +1 -1
- package/dist/src/ink/clearTerminal.js +1 -1
- package/dist/src/ink/colorize.js +1 -1
- package/dist/src/ink/components/App.js +1 -1
- package/dist/src/ink/components/Button.js +1 -1
- package/dist/src/ink/components/ClockContext.js +1 -1
- package/dist/src/ink/components/CursorDeclarationContext.js +1 -1
- package/dist/src/ink/components/Link.js +1 -1
- package/dist/src/ink/components/StdinContext.js +1 -1
- package/dist/src/ink/components/TerminalFocusContext.js +1 -1
- package/dist/src/ink/dom.js +1 -1
- package/dist/src/ink/events/keyboard-event.js +1 -1
- package/dist/src/ink/hit-test.js +1 -1
- package/dist/src/ink/hooks/use-animation-frame.js +1 -1
- package/dist/src/ink/hooks/use-app.js +1 -1
- package/dist/src/ink/hooks/use-input.js +1 -1
- package/dist/src/ink/hooks/use-interval.js +1 -1
- package/dist/src/ink/hooks/use-selection.js +1 -1
- package/dist/src/ink/hooks/use-tab-status.js +1 -1
- package/dist/src/ink/hooks/use-terminal-focus.js +1 -1
- package/dist/src/ink/hooks/use-terminal-title.js +1 -1
- package/dist/src/ink/hooks/use-terminal-viewport.js +1 -1
- package/dist/src/ink/ink.js +1 -1
- package/dist/src/ink/layout/yoga.js +1 -1
- package/dist/src/ink/line-width-cache.js +1 -1
- package/dist/src/ink/log-update.js +1 -1
- package/dist/src/ink/measure-text.js +1 -1
- package/dist/src/ink/output.js +1 -1
- package/dist/src/ink/parse-keypress.js +1 -1
- package/dist/src/ink/reconciler.js +1 -1
- package/dist/src/ink/render-border.js +1 -1
- package/dist/src/ink/render-node-to-output.js +1 -1
- package/dist/src/ink/render-to-screen.js +1 -1
- package/dist/src/ink/renderer.js +1 -1
- package/dist/src/ink/root.js +1 -1
- package/dist/src/ink/screen.js +1 -1
- package/dist/src/ink/searchHighlight.js +1 -1
- package/dist/src/ink/selection.js +1 -1
- package/dist/src/ink/squash-text-nodes.js +1 -1
- package/dist/src/ink/stringWidth.js +1 -1
- package/dist/src/ink/tabstops.js +1 -1
- package/dist/src/ink/terminal.js +1 -1
- package/dist/src/ink/termio/osc.js +1 -1
- package/dist/src/ink/termio/parser.js +1 -1
- package/dist/src/ink/termio/tokenize.js +1 -1
- package/dist/src/ink/useTerminalNotification.js +1 -1
- package/dist/src/ink/warn.js +1 -1
- package/dist/src/ink/widest-line.js +1 -1
- package/dist/src/ink/wrap-text.js +1 -1
- package/dist/src/ink/wrapAnsi.js +1 -1
- package/dist/src/native-ts/yoga-layout/index.js +1 -1
- package/dist/src/schemas/hooks.js +1 -1
- package/dist/src/services/SessionMemory/sessionMemoryUtils.js +1 -1
- package/dist/src/services/api/client.js +1 -1
- package/dist/src/services/api/dumpPrompts.js +1 -1
- package/dist/src/services/api/errorUtils.js +1 -1
- package/dist/src/services/api/promptCacheBreakDetection.js +1 -1
- package/dist/src/services/api/withRetry.js +1 -1
- package/dist/src/services/autoDream/consolidationLock.js +1 -1
- package/dist/src/services/mcp/elicitationHandler.js +1 -1
- package/dist/src/services/mcp/mcpStringUtils.js +1 -1
- package/dist/src/services/mcp/oauthPort.js +1 -1
- package/dist/src/services/mcp/vscodeSdkMcp.js +1 -1
- package/dist/src/services/oauth/client.js +1 -1
- package/dist/src/services/oauth/getOauthProfile.js +1 -1
- package/dist/src/services/objetivo/types.js +1 -1
- package/dist/src/services/rateLimitMocking.js +1 -1
- package/dist/src/services/remoteManagedSettings/syncCacheState.js +1 -1
- package/dist/src/skills/bundledSkills.js +1 -1
- package/dist/src/tasks/DreamTask/DreamTask.js +1 -1
- package/dist/src/tools/AgentTool/agentMemory.js +1 -1
- package/dist/src/tools/AgentTool/forkSubagent.js +1 -1
- package/dist/src/tools/BashTool/BashToolResultMessage.js +1 -1
- package/dist/src/tools/BashTool/UI.js +1 -1
- package/dist/src/tools/BashTool/sedEditParser.js +1 -1
- package/dist/src/tools/BashTool/utils.js +1 -1
- package/dist/src/tools/FileReadTool/imageProcessor.js +1 -1
- package/dist/src/tools/FileReadTool/prompt.js +1 -1
- package/dist/src/tools/ListMcpResourcesTool/ListMcpResourcesTool.js +1 -1
- package/dist/src/tools/ListMcpResourcesTool/UI.js +1 -1
- package/dist/src/tools/MCPTool/MCPTool.js +1 -1
- package/dist/src/tools/MCPTool/UI.js +1 -1
- package/dist/src/tools/McpAuthTool/McpAuthTool.js +1 -1
- package/dist/src/tools/NotebookEditTool/prompt.js +1 -1
- package/dist/src/tools/PowerShellTool/PowerShellTool.js +1 -1
- package/dist/src/tools/PowerShellTool/UI.js +1 -1
- package/dist/src/tools/PowerShellTool/gitSafety.js +1 -1
- package/dist/src/tools/PowerShellTool/modeValidation.js +1 -1
- package/dist/src/tools/PowerShellTool/pathValidation.js +1 -1
- package/dist/src/tools/PowerShellTool/powershellPermissions.js +1 -1
- package/dist/src/tools/PowerShellTool/powershellSecurity.js +1 -1
- package/dist/src/tools/PowerShellTool/prompt.js +1 -1
- package/dist/src/tools/PowerShellTool/readOnlyValidation.js +1 -1
- package/dist/src/tools/REPLTool/constants.js +1 -1
- package/dist/src/tools/REPLTool/primitiveTools.js +1 -1
- package/dist/src/tools/ReadMcpResourceTool/ReadMcpResourceTool.js +1 -1
- package/dist/src/tools/ReadMcpResourceTool/UI.js +1 -1
- package/dist/src/tools/ScheduleCronTool/prompt.js +1 -1
- package/dist/src/tools/SkillTool/prompt.js +1 -1
- package/dist/src/tools/TodoWriteTool/TodoWriteTool.js +1 -1
- package/dist/src/tools/ToolSearchTool/prompt.js +1 -1
- package/dist/src/tools/WebSearchTool/prompt.js +1 -1
- package/dist/src/tools/shared/gitOperationTracking.js +1 -1
- package/dist/src/types/permissions.js +1 -1
- package/dist/src/utils/Cursor.js +1 -1
- package/dist/src/utils/QueryGuard.js +1 -1
- package/dist/src/utils/Shell.js +1 -1
- package/dist/src/utils/ShellCommand.js +1 -1
- package/dist/src/utils/activityManager.js +1 -1
- package/dist/src/utils/advisor.js +1 -1
- package/dist/src/utils/appleTerminalBackup.js +1 -1
- package/dist/src/utils/argumentSubstitution.js +1 -1
- package/dist/src/utils/authFileDescriptor.js +1 -1
- package/dist/src/utils/autoUpdater.js +1 -1
- package/dist/src/utils/background/remote/preconditions.js +1 -1
- package/dist/src/utils/background/remote/remoteSession.js +1 -1
- package/dist/src/utils/bash/ShellSnapshot.js +1 -1
- package/dist/src/utils/bash/ast.js +1 -1
- package/dist/src/utils/bash/bashParser.js +1 -1
- package/dist/src/utils/bash/bashPipeCommand.js +1 -1
- package/dist/src/utils/bash/parser.js +1 -1
- package/dist/src/utils/bash/shellQuote.js +1 -1
- package/dist/src/utils/bash/shellQuoting.js +1 -1
- package/dist/src/utils/billing.js +1 -1
- package/dist/src/utils/caCerts.js +1 -1
- package/dist/src/utils/claudeInChrome/common.js +1 -1
- package/dist/src/utils/claudeInChrome/setupPortable.js +1 -1
- package/dist/src/utils/claudemd.js +1 -1
- package/dist/src/utils/collapseBackgroundBashNotifications.js +1 -1
- package/dist/src/utils/collapseReadSearch.js +1 -1
- package/dist/src/utils/completionCache.js +1 -1
- package/dist/src/utils/computerUse/common.js +1 -1
- package/dist/src/utils/concurrentSessions.js +1 -1
- package/dist/src/utils/context.js +1 -1
- package/dist/src/utils/cron.js +1 -1
- package/dist/src/utils/cronTasks.js +1 -1
- package/dist/src/utils/cwd.js +1 -1
- package/dist/src/utils/debug.js +1 -1
- package/dist/src/utils/debugFilter.js +1 -1
- package/dist/src/utils/detectRepository.js +1 -1
- package/dist/src/utils/diagLogs.js +1 -1
- package/dist/src/utils/diff.js +1 -1
- package/dist/src/utils/directMemberMessage.js +1 -1
- package/dist/src/utils/doctorDiagnostic.js +1 -1
- package/dist/src/utils/dxt/helpers.js +1 -1
- package/dist/src/utils/dxt/zip.js +1 -1
- package/dist/src/utils/earlyInput.js +1 -1
- package/dist/src/utils/editor.js +1 -1
- package/dist/src/utils/effort.js +1 -1
- package/dist/src/utils/embeddedTools.js +1 -1
- package/dist/src/utils/envDynamic.js +1 -1
- package/dist/src/utils/envUtils.js +1 -1
- package/dist/src/utils/execFileNoThrowPortable.js +1 -1
- package/dist/src/utils/execSyncWrapper.js +1 -1
- package/dist/src/utils/exportRenderer.js +1 -1
- package/dist/src/utils/extraUsage.js +1 -1
- package/dist/src/utils/fastMode.js +1 -1
- package/dist/src/utils/fileOperationAnalytics.js +1 -1
- package/dist/src/utils/fileRead.js +1 -1
- package/dist/src/utils/findExecutable.js +1 -1
- package/dist/src/utils/format.js +1 -1
- package/dist/src/utils/frontmatterParser.js +1 -1
- package/dist/src/utils/fsOperations.js +1 -1
- package/dist/src/utils/fullscreen.js +1 -1
- package/dist/src/utils/genericProcessUtils.js +1 -1
- package/dist/src/utils/getWorktreePaths.js +1 -1
- package/dist/src/utils/git/gitConfigParser.js +1 -1
- package/dist/src/utils/git/gitFilesystem.js +1 -1
- package/dist/src/utils/git/gitignore.js +1 -1
- package/dist/src/utils/gitDiff.js +1 -1
- package/dist/src/utils/gitSettings.js +1 -1
- package/dist/src/utils/glob.js +1 -1
- package/dist/src/utils/gracefulShutdown.js +1 -1
- package/dist/src/utils/groupToolUses.js +1 -1
- package/dist/src/utils/handlePromptSubmit.js +1 -1
- package/dist/src/utils/hash.js +1 -1
- package/dist/src/utils/hooks/fileChangedWatcher.js +1 -1
- package/dist/src/utils/hooks/hooksSettings.js +1 -1
- package/dist/src/utils/hooks/registerSkillHooks.js +1 -1
- package/dist/src/utils/hooks/sessionHooks.js +1 -1
- package/dist/src/utils/http.js +1 -1
- package/dist/src/utils/hyperlink.js +1 -1
- package/dist/src/utils/ide.js +1 -1
- package/dist/src/utils/idePathConversion.js +1 -1
- package/dist/src/utils/imagePaste.js +1 -1
- package/dist/src/utils/imageResizer.js +1 -1
- package/dist/src/utils/imageStore.js +1 -1
- package/dist/src/utils/inProcessTeammateHelpers.js +1 -1
- package/dist/src/utils/ink.js +1 -1
- package/dist/src/utils/jetbrains.js +1 -1
- package/dist/src/utils/json.js +1 -1
- package/dist/src/utils/listSessionsImpl.js +1 -1
- package/dist/src/utils/localInstaller.js +1 -1
- package/dist/src/utils/lockfile.js +1 -1
- package/dist/src/utils/logoV2Utils.js +1 -1
- package/dist/src/utils/markdown.js +1 -1
- package/dist/src/utils/mcp/dateTimeParser.js +1 -1
- package/dist/src/utils/mcpOutputStorage.js +1 -1
- package/dist/src/utils/mcpValidation.js +1 -1
- package/dist/src/utils/memoize.js +1 -1
- package/dist/src/utils/memory/types.js +1 -1
- package/dist/src/utils/memoryFileDetection.js +1 -1
- package/dist/src/utils/messageQueueManager.js +1 -1
- package/dist/src/utils/messages/mappers.js +1 -1
- package/dist/src/utils/messages/systemInit.js +1 -1
- package/dist/src/utils/model/antModels.js +1 -1
- package/dist/src/utils/model/check1mAccess.js +1 -1
- package/dist/src/utils/model/contextWindowUpgradeCheck.js +1 -1
- package/dist/src/utils/model/model.js +1 -1
- package/dist/src/utils/model/modelAllowlist.js +1 -1
- package/dist/src/utils/model/modelCapabilities.js +1 -1
- package/dist/src/utils/model/modelOptions.js +1 -1
- package/dist/src/utils/model/modelStrings.js +1 -1
- package/dist/src/utils/model/providerModels.js +1 -1
- package/dist/src/utils/model/providerProfiles.js +1 -1
- package/dist/src/utils/model/providerProfilesDb.js +1 -1
- package/dist/src/utils/model/providerSwitch.js +1 -1
- package/dist/src/utils/model/providers.js +1 -1
- package/dist/src/utils/modelCost.js +1 -1
- package/dist/src/utils/modifiers.js +1 -1
- package/dist/src/utils/mtls.js +1 -1
- package/dist/src/utils/nativeInstaller/download.js +1 -1
- package/dist/src/utils/nativeInstaller/installer.js +1 -1
- package/dist/src/utils/nativeInstaller/packageManagers.js +1 -1
- package/dist/src/utils/nativeInstaller/pidLock.js +1 -1
- package/dist/src/utils/notebook.js +1 -1
- package/dist/src/utils/pasteStore.js +1 -1
- package/dist/src/utils/path.js +1 -1
- package/dist/src/utils/permissions/PermissionMode.js +1 -1
- package/dist/src/utils/permissions/PermissionPromptToolResultSchema.js +1 -1
- package/dist/src/utils/permissions/PermissionUpdate.js +1 -1
- package/dist/src/utils/permissions/PermissionUpdateSchema.js +1 -1
- package/dist/src/utils/permissions/autoModeState.js +1 -1
- package/dist/src/utils/permissions/bypassPermissionsKillswitch.js +1 -1
- package/dist/src/utils/permissions/filesystem.js +1 -1
- package/dist/src/utils/permissions/getNextPermissionMode.js +1 -1
- package/dist/src/utils/permissions/pathValidation.js +1 -1
- package/dist/src/utils/permissions/permissionRuleParser.js +1 -1
- package/dist/src/utils/permissions/permissionsDb.js +1 -1
- package/dist/src/utils/permissions/permissionsLoader.js +1 -1
- package/dist/src/utils/permissions/shellRuleMatching.js +1 -1
- package/dist/src/utils/planModeV2.js +1 -1
- package/dist/src/utils/plans.js +1 -1
- package/dist/src/utils/platform.js +1 -1
- package/dist/src/utils/plugins/addDirPluginSettings.js +1 -1
- package/dist/src/utils/plugins/cacheUtils.js +1 -1
- package/dist/src/utils/plugins/dependencyResolver.js +1 -1
- package/dist/src/utils/plugins/fetchTelemetry.js +1 -1
- package/dist/src/utils/plugins/gitAvailability.js +1 -1
- package/dist/src/utils/plugins/hintRecommendation.js +1 -1
- package/dist/src/utils/plugins/installedPluginsManager.js +1 -1
- package/dist/src/utils/plugins/loadPluginAgents.js +1 -1
- package/dist/src/utils/plugins/loadPluginCommands.js +1 -1
- package/dist/src/utils/plugins/loadPluginHooks.js +1 -1
- package/dist/src/utils/plugins/loadPluginOutputStyles.js +1 -1
- package/dist/src/utils/plugins/lspPluginIntegration.js +1 -1
- package/dist/src/utils/plugins/lspRecommendation.js +1 -1
- package/dist/src/utils/plugins/managedPlugins.js +1 -1
- package/dist/src/utils/plugins/marketplaceHelpers.js +1 -1
- package/dist/src/utils/plugins/marketplaceManager.js +1 -1
- package/dist/src/utils/plugins/mcpPluginIntegration.js +1 -1
- package/dist/src/utils/plugins/mcpbHandler.js +1 -1
- package/dist/src/utils/plugins/officialMarketplaceGcs.js +1 -1
- package/dist/src/utils/plugins/officialMarketplaceStartupCheck.js +1 -1
- package/dist/src/utils/plugins/orphanedPluginFilter.js +1 -1
- package/dist/src/utils/plugins/performStartupChecks.js +1 -1
- package/dist/src/utils/plugins/pluginAutoupdate.js +1 -1
- package/dist/src/utils/plugins/pluginBlocklist.js +1 -1
- package/dist/src/utils/plugins/pluginDirectories.js +1 -1
- package/dist/src/utils/plugins/pluginFlagging.js +1 -1
- package/dist/src/utils/plugins/pluginInstallationHelpers.js +1 -1
- package/dist/src/utils/plugins/pluginLoader.js +1 -1
- package/dist/src/utils/plugins/pluginOptionsStorage.js +1 -1
- package/dist/src/utils/plugins/pluginPolicy.js +1 -1
- package/dist/src/utils/plugins/pluginStartupCheck.js +1 -1
- package/dist/src/utils/plugins/pluginVersioning.js +1 -1
- package/dist/src/utils/plugins/reconciler.js +1 -1
- package/dist/src/utils/plugins/refresh.js +1 -1
- package/dist/src/utils/plugins/schemas.js +1 -1
- package/dist/src/utils/plugins/walkPluginMarkdown.js +1 -1
- package/dist/src/utils/plugins/zipCache.js +1 -1
- package/dist/src/utils/powershell/parser.js +1 -1
- package/dist/src/utils/processUserInput/processBashCommand.js +1 -1
- package/dist/src/utils/processUserInput/processSlashCommand.js +1 -1
- package/dist/src/utils/processUserInput/processTextPrompt.js +1 -1
- package/dist/src/utils/processUserInput/processUserInput.js +1 -1
- package/dist/src/utils/profilerBase.js +1 -1
- package/dist/src/utils/promptCategory.js +1 -1
- package/dist/src/utils/promptEditor.js +1 -1
- package/dist/src/utils/promptShellExecution.js +1 -1
- package/dist/src/utils/proxy.js +1 -1
- package/dist/src/utils/queryHelpers.js +1 -1
- package/dist/src/utils/queryProfiler.js +1 -1
- package/dist/src/utils/queueProcessor.js +1 -1
- package/dist/src/utils/readFileInRange.js +1 -1
- package/dist/src/utils/releaseNotes.js +1 -1
- package/dist/src/utils/renderOptions.js +1 -1
- package/dist/src/utils/ripgrep.js +1 -1
- package/dist/src/utils/sandbox/sandbox-adapter.js +1 -1
- package/dist/src/utils/sdkEventQueue.js +1 -1
- package/dist/src/utils/secureStorage/index.js +1 -1
- package/dist/src/utils/secureStorage/macOsKeychainHelpers.js +1 -1
- package/dist/src/utils/secureStorage/macOsKeychainStorage.js +1 -1
- package/dist/src/utils/secureStorage/plainTextStorage.js +1 -1
- package/dist/src/utils/secureStorage/sqliteStorage.js +1 -1
- package/dist/src/utils/sessionEnvironment.js +1 -1
- package/dist/src/utils/sessionIngressAuth.js +1 -1
- package/dist/src/utils/sessionRestore.js +1 -1
- package/dist/src/utils/sessionStart.js +1 -1
- package/dist/src/utils/sessionTitle.js +1 -1
- package/dist/src/utils/settings/managedPath.js +1 -1
- package/dist/src/utils/settings/mdm/rawRead.js +1 -1
- package/dist/src/utils/settings/mdm/settings.js +1 -1
- package/dist/src/utils/settings/permissionValidation.js +1 -1
- package/dist/src/utils/settings/pluginOnlyPolicy.js +1 -1
- package/dist/src/utils/settings/schemaOutput.js +1 -1
- package/dist/src/utils/settings/settings.js +1 -1
- package/dist/src/utils/settings/types.js +1 -1
- package/dist/src/utils/settings/validateEditTool.js +1 -1
- package/dist/src/utils/settings/validation.js +1 -1
- package/dist/src/utils/shell/bashProvider.js +1 -1
- package/dist/src/utils/shell/powershellDetection.js +1 -1
- package/dist/src/utils/shell/powershellProvider.js +1 -1
- package/dist/src/utils/shell/readOnlyCommandValidation.js +1 -1
- package/dist/src/utils/shell/resolveDefaultShell.js +1 -1
- package/dist/src/utils/shell/shellToolUtils.js +1 -1
- package/dist/src/utils/shell/specPrefix.js +1 -1
- package/dist/src/utils/shellConfig.js +1 -1
- package/dist/src/utils/sideQuestion.js +1 -1
- package/dist/src/utils/skills/skillChangeDetector.js +1 -1
- package/dist/src/utils/slashCommandParsing.js +1 -1
- package/dist/src/utils/sliceAnsi.js +1 -1
- package/dist/src/utils/slowOperations.js +1 -1
- package/dist/src/utils/standaloneAgent.js +1 -1
- package/dist/src/utils/startupProfiler.js +1 -1
- package/dist/src/utils/staticRender.js +1 -1
- package/dist/src/utils/status.js +1 -1
- package/dist/src/utils/statusNoticeDefinitions.js +1 -1
- package/dist/src/utils/suggestions/commandSuggestions.js +1 -1
- package/dist/src/utils/suggestions/directoryCompletion.js +1 -1
- package/dist/src/utils/suggestions/shellHistoryCompletion.js +1 -1
- package/dist/src/utils/suggestions/skillUsageTracking.js +1 -1
- package/dist/src/utils/suggestions/slackChannelSuggestions.js +1 -1
- package/dist/src/utils/swarm/backends/detection.js +1 -1
- package/dist/src/utils/swarm/permissionSync.js +1 -1
- package/dist/src/utils/swarm/reconnection.js +1 -1
- package/dist/src/utils/swarm/spawnUtils.js +91 -1
- package/dist/src/utils/swarm/teammateInit.js +1 -1
- package/dist/src/utils/systemDirectories.js +1 -1
- package/dist/src/utils/systemPrompt.js +1 -1
- package/dist/src/utils/systemTheme.js +1 -1
- package/dist/src/utils/task/TaskOutput.js +1 -1
- package/dist/src/utils/task/diskOutput.js +1 -1
- package/dist/src/utils/tasks.js +1 -1
- package/dist/src/utils/teamDiscovery.js +1 -1
- package/dist/src/utils/teamMemoryOps.js +1 -1
- package/dist/src/utils/teammateMailbox.js +1 -1
- package/dist/src/utils/telemetry/betaSessionTracing.js +1 -1
- package/dist/src/utils/telemetry/bigqueryExporter.js +1 -1
- package/dist/src/utils/telemetry/events.js +1 -1
- package/dist/src/utils/telemetry/instrumentation.js +1 -1
- package/dist/src/utils/telemetry/logger.js +1 -1
- package/dist/src/utils/telemetry/perfettoTracing.js +1 -1
- package/dist/src/utils/telemetry/pluginTelemetry.js +1 -1
- package/dist/src/utils/telemetry/sessionTracing.js +1 -1
- package/dist/src/utils/telemetryAttributes.js +1 -1
- package/dist/src/utils/teleport/api.js +1 -1
- package/dist/src/utils/teleport/environments.js +1 -1
- package/dist/src/utils/teleport/gitBundle.js +1 -1
- package/dist/src/utils/teleport.js +1 -1
- package/dist/src/utils/tempfile.js +1 -1
- package/dist/src/utils/terminal.js +1 -1
- package/dist/src/utils/terminalPanel.js +1 -1
- package/dist/src/utils/textHighlighting.js +1 -1
- package/dist/src/utils/theme.js +1 -1
- package/dist/src/utils/themes/bootstrap.js +1 -1
- package/dist/src/utils/themes/loader.js +1 -1
- package/dist/src/utils/thinking.js +1 -1
- package/dist/src/utils/tmuxSocket.js +1 -1
- package/dist/src/utils/tokens.js +1 -1
- package/dist/src/utils/toolPool.js +1 -1
- package/dist/src/utils/toolResultStorage.js +1 -1
- package/dist/src/utils/transcriptSearch.js +1 -1
- package/dist/src/utils/truncate.js +1 -1
- package/dist/src/utils/ultraplan/keyword.js +1 -1
- package/dist/src/utils/unaryLogging.js +1 -1
- package/dist/src/utils/undercover.js +1 -1
- package/dist/src/utils/user.js +1 -1
- package/dist/src/utils/userPromptKeywords.js +1 -1
- package/dist/src/utils/which.js +1 -1
- package/dist/src/utils/windowsPaths.js +1 -1
- package/dist/src/utils/worktree.js +1 -1
- package/dist/src/utils/zodToJsonSchema.js +1 -1
- package/dist/src/vim/operators.js +1 -1
- package/dist/src/vim/textObjects.js +1 -1
- package/dist/src/vim/transitions.js +1 -1
- package/dist/src/voice/voiceModeEnabled.js +1 -1
- package/dist/src/webapp/auth.js +1 -1
- package/dist/src/webapp/tunnel.js +1 -1
- package/dist/src/whatsapp/bridge.js +1 -1
- package/dist/src/whatsapp/mirror.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createHash as t}from"crypto";import{logEvent as e}from"
|
|
1
|
+
import{createHash as t}from"crypto";import{logEvent as e}from"src/services/analytics/index.js";export function logFileOperation(o){const n={operation:o.operation,tool:o.tool,filePathHash:(a=o.filePath,t("sha256").update(a).digest("hex").slice(0,16))};var a,i;void 0!==o.content&&o.content.length<=102400&&(n.contentHash=(i=o.content,t("sha256").update(i).digest("hex"))),void 0!==o.type&&(n.type=o.type),e("tengu_file_operation",n)}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{logForDebugging as e}from"./debug.js";import{getFsImplementation as n,safeResolvePath as t}from"./fsOperations.js";export function detectEncodingForResolvedPath(e){const{buffer:t,bytesRead:r}=n().readSync(e,{length:4096});return 0===r?"utf8":r>=2&&255===t[0]&&254===t[1]?"utf16le":(r>=3&&239===t[0]&&187===t[1]&&t[2],"utf8")}export function detectLineEndingsForString(e){let n=0,t=0;for(let r=0;r<e.length;r++)"\n"===e[r]&&(r>0&&"\r"===e[r-1]?n++:t++);return n>t?"CRLF":"LF"}export function readFileSyncWithMetadata(r){const o=n(),{resolvedPath:i,isSymlink:
|
|
1
|
+
import{logForDebugging as e}from"./debug.js";import{getFsImplementation as n,safeResolvePath as t}from"./fsOperations.js";export function detectEncodingForResolvedPath(e){const{buffer:t,bytesRead:r}=n().readSync(e,{length:4096});return 0===r?"utf8":r>=2&&255===t[0]&&254===t[1]?"utf16le":(r>=3&&239===t[0]&&187===t[1]&&t[2],"utf8")}export function detectLineEndingsForString(e){let n=0,t=0;for(let r=0;r<e.length;r++)"\n"===e[r]&&(r>0&&"\r"===e[r-1]?n++:t++);return n>t?"CRLF":"LF"}export function readFileSyncWithMetadata(r){const o=n(),{resolvedPath:i,isSymlink:a}=t(o,r);a&&e(`Reading through symlink: ${r} -> ${i}`);const c=detectEncodingForResolvedPath(i),d=o.readFileSync(i,{encoding:c}),s=detectLineEndingsForString(d.slice(0,4096));return{content:d.replaceAll("\r\n","\n"),encoding:c,lineEndings:s}}export function readFileSync(e){return readFileSyncWithMetadata(e).content}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{whichSync as
|
|
1
|
+
import{whichSync as c}from"./which.js";export function findExecutable(r,i){return{cmd:c(r)??r,args:i}}
|
package/dist/src/utils/format.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getRelativeTimeFormat as t,getTimeZone as e}from"./intl.js";export function formatFileSize(t){const e=t/1024;if(e<1)return`${t} bytes`;if(e<1024)return`${e.toFixed(1).replace(/\.0$/,"")}KB`;const o=e/1024;
|
|
1
|
+
import{getRelativeTimeFormat as t,getTimeZone as e}from"./intl.js";export function formatFileSize(t){const e=t/1024;if(e<1)return`${t} bytes`;if(e<1024)return`${e.toFixed(1).replace(/\.0$/,"")}KB`;const o=e/1024;return o<1024?`${o.toFixed(1).replace(/\.0$/,"")}MB`:`${(o/1024).toFixed(1).replace(/\.0$/,"")}GB`}export function formatSecondsShort(t){return`${(t/1e3).toFixed(1)}s`}export function formatDuration(t,e){if(t<6e4)return 0===t?"0s":t<1?`${(t/1e3).toFixed(1)}s`:`${Math.floor(t/1e3).toString()}s`;let o=Math.floor(t/864e5),r=Math.floor(t%864e5/36e5),n=Math.floor(t%36e5/6e4),i=Math.round(t%6e4/1e3);60===i&&(i=0,n++),60===n&&(n=0,r++),24===r&&(r=0,o++);const a=e?.hideTrailingZeros;return e?.mostSignificantOnly?o>0?`${o}d`:r>0?`${r}h`:n>0?`${n}m`:`${i}s`:o>0?a&&0===r&&0===n?`${o}d`:a&&0===n?`${o}d ${r}h`:`${o}d ${r}h ${n}m`:r>0?a&&0===n&&0===i?`${r}h`:a&&0===i?`${r}h ${n}m`:`${r}h ${n}m ${i}s`:n>0?a&&0===i?`${n}m`:`${n}m ${i}s`:`${i}s`}let o=null,r=null;export function formatNumber(t){return(e=t>=1e3,e?(o||(o=new Intl.NumberFormat("en-US",{notation:"compact",maximumFractionDigits:1,minimumFractionDigits:1})),o):(r||(r=new Intl.NumberFormat("en-US",{notation:"compact",maximumFractionDigits:1,minimumFractionDigits:0})),r)).format(t).toLowerCase();var e}export function formatTokens(t){return formatNumber(t).replace(".0","")}export function formatRelativeTime(e,o={}){const{style:r="narrow",numeric:n="always",now:i=new Date}=o,a=e.getTime()-i.getTime(),s=Math.trunc(a/1e3),m=[{unit:"year",seconds:31536e3,shortUnit:"y"},{unit:"month",seconds:2592e3,shortUnit:"mo"},{unit:"week",seconds:604800,shortUnit:"w"},{unit:"day",seconds:86400,shortUnit:"d"},{unit:"hour",seconds:3600,shortUnit:"h"},{unit:"minute",seconds:60,shortUnit:"m"},{unit:"second",seconds:1,shortUnit:"s"}];for(const{unit:e,seconds:o,shortUnit:i}of m)if(Math.abs(s)>=o){const a=Math.trunc(s/o);return"narrow"===r?s<0?`${Math.abs(a)}${i} ago`:`in ${a}${i}`:t("long",n).format(a,e)}return"narrow"===r?s<=0?"0s ago":"in 0s":t(r,n).format(0,"second")}export function formatRelativeTimeAgo(t,e={}){const{now:o=new Date,...r}=e;return formatRelativeTime(t,t>o?{...r,now:o}:{...r,numeric:"always",now:o})}export function formatLogMetadata(t){const e=void 0!==t.fileSize?formatFileSize(t.fileSize):`${t.messageCount} messages`,o=[formatRelativeTimeAgo(t.modified,{style:"short"}),...t.gitBranch?[t.gitBranch]:[],e];return t.tag&&o.push(`#${t.tag}`),t.agentSetting&&o.push(`@${t.agentSetting}`),t.prNumber&&o.push(t.prRepository?`${t.prRepository}#${t.prNumber}`:`#${t.prNumber}`),o.join(" · ")}export function formatResetTime(t,o=!1,r=!0){if(!t)return;const n=new Date(1e3*t),i=new Date,a=n.getMinutes();if((n.getTime()-i.getTime())/36e5>24){const t={month:"short",day:"numeric",hour:r?"numeric":void 0,minute:r&&0!==a?"2-digit":void 0,hour12:!!r||void 0};return n.getFullYear()!==i.getFullYear()&&(t.year="numeric"),n.toLocaleString("es",t).replace(/ ([AP]M)/i,(t,e)=>e.toLowerCase())+(o?` (${e()})`:"")}return n.toLocaleTimeString("es",{hour:"numeric",minute:0===a?void 0:"2-digit",hour12:!0}).replace(/ ([AP]M)/i,(t,e)=>e.toLowerCase())+(o?` (${e()})`:"")}export function formatResetText(t,e=!1,o=!0){const r=new Date(t);return`${formatResetTime(Math.floor(r.getTime()/1e3),e,o)}`}export{truncate,truncatePathMiddle,truncateStartToWidth,truncateToWidth,truncateToWidthNoEllipsis,wrapText}from"./truncate.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{logForDebugging as t}from"./debug.js";import{parseYaml as n}from"./yaml.js";const r=/[{}[\]*&#!|>%@`]|: /;export const FRONTMATTER_REGEX=/^---\s*\n([\s\S]*?)---\s*\n?/;export function parseFrontmatter(e,o){const s=e.match(FRONTMATTER_REGEX);if(!s)return{frontmatter:{},content:e};const i=s[1]||"",a=e.slice(s[0].length);let c={};try{const t=n(i);t&&"object"==typeof t&&!Array.isArray(t)&&(c=t)}catch{try{const t=function(t){const n=t.split("\n"),e=[];for(const t of n){const n=t.match(/^([a-zA-Z_-]+):\s+(.+)$/);if(n){const[,o,s]=n;if(!o||!s){e.push(t);continue}if(s.startsWith('"')&&s.endsWith('"')||s.startsWith("'")&&s.endsWith("'")){e.push(t);continue}if(r.test(s)){const t=s.replace(/\\/g,"\\\\").replace(/"/g,'\\"');e.push(`${o}: "${t}"`);continue}}e.push(t)}return e.join("\n")}(i),e=n(t);e&&"object"==typeof e&&!Array.isArray(e)&&(c=e)}catch(n){t(`Failed to parse YAML frontmatter${o?` in ${o}`:""}: ${n instanceof Error?n.message:n}`,{level:"warn"})}}return{frontmatter:c,content:a}}export function splitPathInFrontmatter(t){if(Array.isArray(t))return t.flatMap(splitPathInFrontmatter);if("string"!=typeof t)return[];const n=[];let r="",e=0;for(let o=0;o<t.length;o++){const s=t[o];if("{"===s)e++,r+=s;else if("}"===s)e--,r+=s;else if(","===s&&0===e){const t=r.trim();t&&n.push(t),r=""}else r+=s}const o=r.trim();return o&&n.push(o),n.filter(t=>t.length>0).flatMap(t=>expandBraces(t))}function expandBraces(t){const n=t.match(/^([^{]*)\{([^}]+)\}(.*)$/);if(!n)return[t];const r=n[1]||"",e=n[2]||"",o=n[3]||"",s=e.split(",").map(t=>t.trim()),i=[];for(const t of s){const n=expandBraces(r+t+o);i.push(...n)}return i}export function parsePositiveIntFromFrontmatter(t){if(null==t)return;const n="number"==typeof t?t:parseInt(String(t),10);return Number.isInteger(n)&&n>0?n:void 0}export function coerceDescriptionToString(n,r,e){
|
|
1
|
+
import{logForDebugging as t}from"./debug.js";import{parseYaml as n}from"./yaml.js";const r=/[{}[\]*&#!|>%@`]|: /;export const FRONTMATTER_REGEX=/^---\s*\n([\s\S]*?)---\s*\n?/;export function parseFrontmatter(e,o){const s=e.match(FRONTMATTER_REGEX);if(!s)return{frontmatter:{},content:e};const i=s[1]||"",a=e.slice(s[0].length);let c={};try{const t=n(i);t&&"object"==typeof t&&!Array.isArray(t)&&(c=t)}catch{try{const t=function(t){const n=t.split("\n"),e=[];for(const t of n){const n=t.match(/^([a-zA-Z_-]+):\s+(.+)$/);if(n){const[,o,s]=n;if(!o||!s){e.push(t);continue}if(s.startsWith('"')&&s.endsWith('"')||s.startsWith("'")&&s.endsWith("'")){e.push(t);continue}if(r.test(s)){const t=s.replace(/\\/g,"\\\\").replace(/"/g,'\\"');e.push(`${o}: "${t}"`);continue}}e.push(t)}return e.join("\n")}(i),e=n(t);e&&"object"==typeof e&&!Array.isArray(e)&&(c=e)}catch(n){t(`Failed to parse YAML frontmatter${o?` in ${o}`:""}: ${n instanceof Error?n.message:n}`,{level:"warn"})}}return{frontmatter:c,content:a}}export function splitPathInFrontmatter(t){if(Array.isArray(t))return t.flatMap(splitPathInFrontmatter);if("string"!=typeof t)return[];const n=[];let r="",e=0;for(let o=0;o<t.length;o++){const s=t[o];if("{"===s)e++,r+=s;else if("}"===s)e--,r+=s;else if(","===s&&0===e){const t=r.trim();t&&n.push(t),r=""}else r+=s}const o=r.trim();return o&&n.push(o),n.filter(t=>t.length>0).flatMap(t=>expandBraces(t))}function expandBraces(t){const n=t.match(/^([^{]*)\{([^}]+)\}(.*)$/);if(!n)return[t];const r=n[1]||"",e=n[2]||"",o=n[3]||"",s=e.split(",").map(t=>t.trim()),i=[];for(const t of s){const n=expandBraces(r+t+o);i.push(...n)}return i}export function parsePositiveIntFromFrontmatter(t){if(null==t)return;const n="number"==typeof t?t:parseInt(String(t),10);return Number.isInteger(n)&&n>0?n:void 0}export function coerceDescriptionToString(n,r,e){return null==n?null:"string"==typeof n?n.trim()||null:"number"==typeof n||"boolean"==typeof n?String(n):(t(`Description invalid for ${e?`${e}:${r}`:r??"unknown"} - omitting`,{level:"warn"}),null)}export function parseBooleanFrontmatter(t){return!0===t||"true"===t}const e=["bash","powershell"];export function parseShellFrontmatter(n,r){if(null==n)return;const o=String(n).trim().toLowerCase();return""!==o?e.includes(o)?o:void t(`Frontmatter 'shell: ${n}' in ${r} is not recognized. Valid values: ${e.join(", ")}. Falling back to bash.`,{level:"warn"}):void 0}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var r=this&&this.__addDisposableResource||function(r,t
|
|
1
|
+
var r=this&&this.__addDisposableResource||function(r,e,t){if(null!=e){if("object"!=typeof e&&"function"!=typeof e)throw new TypeError("Object expected.");var n,s;if(t){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");n=e[Symbol.asyncDispose]}if(void 0===n){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");n=e[Symbol.dispose],t&&(s=n)}if("function"!=typeof n)throw new TypeError("Object not disposable.");s&&(n=function(){try{s.call(this)}catch(r){return Promise.reject(r)}}),r.stack.push({value:e,dispose:n,async:t})}else t&&r.stack.push({async:!0});return e},e=this&&this.__disposeResources||function(r){return function(e){function fail(t){e.error=e.hasError?new r(t,e.error,"An error was suppressed during disposal."):t,e.hasError=!0}var t,n=0;return function next(){for(;t=e.stack.pop();)try{if(!t.async&&1===n)return n=0,e.stack.push(t),Promise.resolve().then(next);if(t.dispose){var r=t.dispose.call(t.value);if(t.async)return n|=2,Promise.resolve(r).then(next,function(r){return fail(r),next()})}else n|=1}catch(r){fail(r)}if(1===n)return e.hasError?Promise.reject(e.error):Promise.resolve();if(e.hasError)throw e.error}()}}("function"==typeof SuppressedError?SuppressedError:function(r,e,t){var n=new Error(t);return n.name="SuppressedError",n.error=r,n.suppressed=e,n});import*as t from"fs";import{mkdir as n,open as s,readdir as a,readFile as o,rename as i,rmdir as c,rm as l,stat as y,unlink as f}from"fs/promises";import{homedir as d}from"os";import*as h from"path";import{getErrnoCode as S}from"./errors.js";import{slowLogging as u}from"./slowOperations.js";export function safeResolvePath(r,e){if(e.startsWith("//")||e.startsWith("\\\\"))return{resolvedPath:e,isSymlink:!1,isCanonical:!1};try{const t=r.lstatSync(e);if(t.isFIFO()||t.isSocket()||t.isCharacterDevice()||t.isBlockDevice())return{resolvedPath:e,isSymlink:!1,isCanonical:!1};const n=r.realpathSync(e);return{resolvedPath:n,isSymlink:n!==e,isCanonical:!0}}catch(r){return{resolvedPath:e,isSymlink:!1,isCanonical:!1}}}export function isDuplicatePath(r,e,t){const{resolvedPath:n}=safeResolvePath(r,e);return!!t.has(n)||(t.add(n),!1)}export function resolveDeepestExistingAncestorSync(r,e){let t=e;const n=[];for(;t!==h.dirname(t);){let e;try{e=r.lstatSync(t)}catch{n.unshift(h.basename(t)),t=h.dirname(t);continue}if(e.isSymbolicLink())try{const e=r.realpathSync(t);return 0===n.length?e:h.join(e,...n)}catch{const e=r.readlinkSync(t),s=h.isAbsolute(e)?e:h.resolve(h.dirname(t),e);return 0===n.length?s:h.join(s,...n)}try{const e=r.realpathSync(t);if(e!==t)return 0===n.length?e:h.join(e,...n)}catch{}return}}export function getPathsForPermissionCheck(r){let e=r;"~"===e?e=d().normalize("NFC"):e.startsWith("~/")&&(e=h.join(d().normalize("NFC"),e.slice(2)));const t=new Set,n=getFsImplementation();if(t.add(e),e.startsWith("//")||e.startsWith("\\\\"))return Array.from(t);try{let r=e;const s=new Set,a=40;for(let o=0;o<a&&!s.has(r);o++){if(s.add(r),!n.existsSync(r)){if(r===e){const r=resolveDeepestExistingAncestorSync(n,e);void 0!==r&&t.add(r)}break}const a=n.lstatSync(r);if(a.isFIFO()||a.isSocket()||a.isCharacterDevice()||a.isBlockDevice())break;if(!a.isSymbolicLink())break;const o=n.readlinkSync(r),i=h.isAbsolute(o)?o:h.resolve(h.dirname(r),o);t.add(i),r=i}}catch{}const{resolvedPath:s,isSymlink:a}=safeResolvePath(n,e);return a&&s!==e&&t.add(s),Array.from(t)}export const NodeFsOperations={cwd:()=>process.cwd(),existsSync(n){const s={stack:[],error:void 0,hasError:!1};try{return r(s,u`fs.existsSync(${n})`,!1),t.existsSync(n)}catch(r){s.error=r,s.hasError=!0}finally{e(s)}},stat:async r=>y(r),readdir:async r=>a(r,{withFileTypes:!0}),unlink:async r=>f(r),rmdir:async r=>c(r),rm:async(r,e)=>l(r,e),async mkdir(r,e){try{await n(r,{recursive:!0,...e})}catch(r){if("EEXIST"!==S(r))throw r}},readFile:async(r,e)=>o(r,{encoding:e.encoding}),rename:async(r,e)=>i(r,e),statSync(n){const s={stack:[],error:void 0,hasError:!1};try{return r(s,u`fs.statSync(${n})`,!1),t.statSync(n)}catch(r){s.error=r,s.hasError=!0}finally{e(s)}},lstatSync(n){const s={stack:[],error:void 0,hasError:!1};try{return r(s,u`fs.lstatSync(${n})`,!1),t.lstatSync(n)}catch(r){s.error=r,s.hasError=!0}finally{e(s)}},readFileSync(n,s){const a={stack:[],error:void 0,hasError:!1};try{return r(a,u`fs.readFileSync(${n})`,!1),t.readFileSync(n,{encoding:s.encoding})}catch(r){a.error=r,a.hasError=!0}finally{e(a)}},readFileBytesSync(n){const s={stack:[],error:void 0,hasError:!1};try{return r(s,u`fs.readFileBytesSync(${n})`,!1),t.readFileSync(n)}catch(r){s.error=r,s.hasError=!0}finally{e(s)}},readSync(n,s){const a={stack:[],error:void 0,hasError:!1};try{let e;r(a,u`fs.readSync(${n}, ${s.length} bytes)`,!1);try{e=t.openSync(n,"r");const r=Buffer.alloc(s.length);return{buffer:r,bytesRead:t.readSync(e,r,0,s.length,0)}}finally{e&&t.closeSync(e)}}catch(r){a.error=r,a.hasError=!0}finally{e(a)}},appendFileSync(n,s,a){const o={stack:[],error:void 0,hasError:!1};try{if(r(o,u`fs.appendFileSync(${n}, ${s.length} chars)`,!1),void 0!==a?.mode)try{const r=t.openSync(n,"ax",a.mode);try{t.appendFileSync(r,s)}finally{t.closeSync(r)}return}catch(r){if("EEXIST"!==S(r))throw r}t.appendFileSync(n,s)}catch(r){o.error=r,o.hasError=!0}finally{e(o)}},copyFileSync(n,s){const a={stack:[],error:void 0,hasError:!1};try{r(a,u`fs.copyFileSync(${n} → ${s})`,!1),t.copyFileSync(n,s)}catch(r){a.error=r,a.hasError=!0}finally{e(a)}},unlinkSync(n){const s={stack:[],error:void 0,hasError:!1};try{r(s,u`fs.unlinkSync(${n})`,!1),t.unlinkSync(n)}catch(r){s.error=r,s.hasError=!0}finally{e(s)}},renameSync(n,s){const a={stack:[],error:void 0,hasError:!1};try{r(a,u`fs.renameSync(${n} → ${s})`,!1),t.renameSync(n,s)}catch(r){a.error=r,a.hasError=!0}finally{e(a)}},linkSync(n,s){const a={stack:[],error:void 0,hasError:!1};try{r(a,u`fs.linkSync(${n} → ${s})`,!1),t.linkSync(n,s)}catch(r){a.error=r,a.hasError=!0}finally{e(a)}},symlinkSync(n,s,a){const o={stack:[],error:void 0,hasError:!1};try{r(o,u`fs.symlinkSync(${n} → ${s})`,!1),t.symlinkSync(n,s,a)}catch(r){o.error=r,o.hasError=!0}finally{e(o)}},readlinkSync(n){const s={stack:[],error:void 0,hasError:!1};try{return r(s,u`fs.readlinkSync(${n})`,!1),t.readlinkSync(n)}catch(r){s.error=r,s.hasError=!0}finally{e(s)}},realpathSync(n){const s={stack:[],error:void 0,hasError:!1};try{return r(s,u`fs.realpathSync(${n})`,!1),t.realpathSync(n).normalize("NFC")}catch(r){s.error=r,s.hasError=!0}finally{e(s)}},mkdirSync(n,s){const a={stack:[],error:void 0,hasError:!1};try{r(a,u`fs.mkdirSync(${n})`,!1);const e={recursive:!0};void 0!==s?.mode&&(e.mode=s.mode);try{t.mkdirSync(n,e)}catch(r){if("EEXIST"!==S(r))throw r}}catch(r){a.error=r,a.hasError=!0}finally{e(a)}},readdirSync(n){const s={stack:[],error:void 0,hasError:!1};try{return r(s,u`fs.readdirSync(${n})`,!1),t.readdirSync(n,{withFileTypes:!0})}catch(r){s.error=r,s.hasError=!0}finally{e(s)}},readdirStringSync(n){const s={stack:[],error:void 0,hasError:!1};try{return r(s,u`fs.readdirStringSync(${n})`,!1),t.readdirSync(n)}catch(r){s.error=r,s.hasError=!0}finally{e(s)}},isDirEmptySync(t){const n={stack:[],error:void 0,hasError:!1};try{return r(n,u`fs.isDirEmptySync(${t})`,!1),0===this.readdirSync(t).length}catch(r){n.error=r,n.hasError=!0}finally{e(n)}},rmdirSync(n){const s={stack:[],error:void 0,hasError:!1};try{r(s,u`fs.rmdirSync(${n})`,!1),t.rmdirSync(n)}catch(r){s.error=r,s.hasError=!0}finally{e(s)}},rmSync(n,s){const a={stack:[],error:void 0,hasError:!1};try{r(a,u`fs.rmSync(${n})`,!1),t.rmSync(n,s)}catch(r){a.error=r,a.hasError=!0}finally{e(a)}},createWriteStream:r=>t.createWriteStream(r),async readFileBytes(r,e){if(void 0===e)return o(r);const t=await s(r,"r");try{const{size:r}=await t.stat(),n=Math.min(r,e),s=Buffer.allocUnsafe(n);let a=0;for(;a<n;){const{bytesRead:r}=await t.read(s,a,n-a,a);if(0===r)break;a+=r}return a<n?s.subarray(0,a):s}finally{await t.close()}}};let p=NodeFsOperations;export function setFsImplementation(r){p=r}export function getFsImplementation(){return p}export function setOriginalFsImplementation(){p=NodeFsOperations}export async function readFileRange(t,n,a){const o={stack:[],error:void 0,hasError:!1};try{const e=r(o,await s(t,"r"),!0),i=(await e.stat()).size;if(i<=n)return null;const c=Math.min(i-n,a),l=Buffer.allocUnsafe(c);let y=0;for(;y<c;){const{bytesRead:r}=await e.read(l,y,c-y,n+y);if(0===r)break;y+=r}return{content:l.toString("utf8",0,y),bytesRead:y,bytesTotal:i}}catch(r){o.error=r,o.hasError=!0}finally{const r=e(o);r&&await r}}export async function tailFile(t,n){const a={stack:[],error:void 0,hasError:!1};try{const e=r(a,await s(t,"r"),!0),o=(await e.stat()).size;if(0===o)return{content:"",bytesRead:0,bytesTotal:0};const i=Math.max(0,o-n),c=o-i,l=Buffer.allocUnsafe(c);let y=0;for(;y<c;){const{bytesRead:r}=await e.read(l,y,c-y,i+y);if(0===r)break;y+=r}return{content:l.toString("utf8",0,y),bytesRead:y,bytesTotal:o}}catch(r){a.error=r,a.hasError=!0}finally{const r=e(a);r&&await r}}export async function*readLinesReverse(r){const e=await s(r,"r");try{let r=(await e.stat()).size,t=Buffer.alloc(0);const n=Buffer.alloc(4096);for(;r>0;){const s=Math.min(4096,r);r-=s,await e.read(n,0,s,r);const a=Buffer.concat([n.subarray(0,s),t]),o=a.indexOf(10);if(-1===o){t=a;continue}t=Buffer.from(a.subarray(0,o));const i=a.toString("utf8",o+1).split("\n");for(let r=i.length-1;r>=0;r--){const e=i[r];e&&(yield e)}}t.length>0&&(yield t.toString("utf8"))}finally{await e.close()}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{spawnSync as e}from"child_process";import{getIsInteractive as t}from"../bootstrap/state.js";import{logForDebugging as r}from"./debug.js";import{isEnvDefinedFalsy as o,isEnvTruthy as
|
|
1
|
+
import{spawnSync as e}from"child_process";import{getIsInteractive as t}from"../bootstrap/state.js";import{logForDebugging as r}from"./debug.js";import{isEnvDefinedFalsy as o,isEnvTruthy as s}from"./envUtils.js";import{execFileNoThrow as n}from"./execFileNoThrow.js";let i,u=!1,c=!1;export function isTmuxControlMode(){return void 0===i&&function(){if(i=function(){if(!process.env.TMUX)return!1;if("iTerm.app"!==process.env.TERM_PROGRAM)return!1;const e=process.env.TERM??"";return!e.startsWith("screen")&&!e.startsWith("tmux")}(),i)return;if(!process.env.TMUX)return;if(process.env.TERM_PROGRAM)return;let t;try{t=e("tmux",["display-message","-p","#{client_control_mode}"],{encoding:"utf8",timeout:2e3})}catch{return}0===t.status&&(i="1"===t.stdout.trim())}(),i??!1}export function _resetTmuxControlModeProbeForTesting(){i=void 0,u=!1}export function isFullscreenEnvEnabled(){return!(o(process.env.CONTEXT_CODE_NO_FLICKER)||o(process.env.CLAUDE_CODE_NO_FLICKER)||!s(process.env.CONTEXT_CODE_NO_FLICKER)&&!s(process.env.CLAUDE_CODE_NO_FLICKER)&&(isTmuxControlMode()?(u||(u=!0,r("fullscreen disabled: tmux -CC (iTerm2 integration mode) detected · set CLAUDE_CODE_NO_FLICKER=1 to override")),1):"ant"!==process.env.USER_TYPE))}export function isMouseTrackingEnabled(){return!s(process.env.CONTEXT_CODE_DISABLE_MOUSE)&&!s(process.env.CLAUDE_CODE_DISABLE_MOUSE)}export function isMouseClicksDisabled(){return s(process.env.CONTEXT_CODE_DISABLE_MOUSE_CLICKS)||s(process.env.CLAUDE_CODE_DISABLE_MOUSE_CLICKS)}export function isFullscreenActive(){return t()&&isFullscreenEnvEnabled()}export async function maybeGetTmuxMouseHint(){if(!process.env.TMUX)return null;if(!isFullscreenActive()||isTmuxControlMode())return null;if(c)return null;c=!0;const{stdout:e,code:t}=await n("tmux",["show","-Av","mouse"],{useCwd:!1,timeout:2e3});return 0!==t||"on"===e.trim()?null:"tmux detected · scroll with PgUp/PgDn · or add 'set -g mouse on' to ~/.tmux.conf for wheel scroll"}export function _resetForTesting(){u=!1,c=!1}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{execFileNoThrowWithCwd as
|
|
1
|
+
import{execFileNoThrowWithCwd as e,execSyncWithDefaults_DEPRECATED as r}from"./execFileNoThrow.js";export function isProcessRunning(e){if(e<=1)return!1;try{return process.kill(e,0),!0}catch{return!1}}export async function getAncestorPidsAsync(r,t=10){if("win32"===process.platform){const n=`\n $pid = ${String(r)}\n $ancestors = @()\n for ($i = 0; $i -lt ${t}; $i++) {\n $proc = Get-CimInstance Win32_Process -Filter "ProcessId=$pid" -ErrorAction SilentlyContinue\n if (-not $proc -or -not $proc.ParentProcessId -or $proc.ParentProcessId -eq 0) { break }\n $pid = $proc.ParentProcessId\n $ancestors += $pid\n }\n $ancestors -join ','\n `.trim(),o=await e("powershell.exe",["-NoProfile","-Command",n],{timeout:3e3});return 0===o.code&&o.stdout?.trim()?o.stdout.trim().split(",").filter(Boolean).map(e=>parseInt(e,10)).filter(e=>!isNaN(e)):[]}const n=`pid=${String(r)}; for i in $(seq 1 ${t}); do ppid=$(ps -o ppid= -p $pid 2>/dev/null | tr -d ' '); if [ -z "$ppid" ] || [ "$ppid" = "0" ] || [ "$ppid" = "1" ]; then break; fi; echo $ppid; pid=$ppid; done`,o=await e("sh",["-c",n],{timeout:3e3});return 0===o.code&&o.stdout?.trim()?o.stdout.trim().split("\n").filter(Boolean).map(e=>parseInt(e,10)).filter(e=>!isNaN(e)):[]}export function getProcessCommand(e){try{const t=String(e),n="win32"===process.platform?`powershell.exe -NoProfile -Command "(Get-CimInstance Win32_Process -Filter \\"ProcessId=${t}\\").CommandLine"`:`ps -o command= -p ${t}`,o=r(n,{timeout:1e3});return o?o.trim():null}catch{return null}}export async function getAncestorCommandsAsync(r,t=10){if("win32"===process.platform){const n=`\n $currentPid = ${String(r)}\n $commands = @()\n for ($i = 0; $i -lt ${t}; $i++) {\n $proc = Get-CimInstance Win32_Process -Filter "ProcessId=$currentPid" -ErrorAction SilentlyContinue\n if (-not $proc) { break }\n if ($proc.CommandLine) { $commands += $proc.CommandLine }\n if (-not $proc.ParentProcessId -or $proc.ParentProcessId -eq 0) { break }\n $currentPid = $proc.ParentProcessId\n }\n $commands -join [char]0\n `.trim(),o=await e("powershell.exe",["-NoProfile","-Command",n],{timeout:3e3});return 0===o.code&&o.stdout?.trim()?o.stdout.split("\0").filter(Boolean):[]}const n=`currentpid=${String(r)}; for i in $(seq 1 ${t}); do cmd=$(ps -o command= -p $currentpid 2>/dev/null); if [ -n "$cmd" ]; then printf '%s\\0' "$cmd"; fi; ppid=$(ps -o ppid= -p $currentpid 2>/dev/null | tr -d ' '); if [ -z "$ppid" ] || [ "$ppid" = "0" ] || [ "$ppid" = "1" ]; then break; fi; currentpid=$ppid; done`,o=await e("sh",["-c",n],{timeout:3e3});return 0===o.code&&o.stdout?.trim()?o.stdout.split("\0").filter(Boolean):[]}export function getChildPids(e){try{const t=String(e),n="win32"===process.platform?`powershell.exe -NoProfile -Command "(Get-CimInstance Win32_Process -Filter \\"ParentProcessId=${t}\\").ProcessId"`:`pgrep -P ${t}`,o=r(n,{timeout:1e3});return o?o.trim().split("\n").filter(Boolean).map(e=>parseInt(e,10)).filter(e=>!isNaN(e)):[]}catch{return[]}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{sep as t}from"path";import{logEvent as e}from"../services/analytics/index.js";import{execFileNoThrowWithCwd as r}from"./execFileNoThrow.js";import{gitExe as o}from"./git.js";export async function getWorktreePaths(s){const i=Date.now(),{stdout:n,code:
|
|
1
|
+
import{sep as t}from"path";import{logEvent as e}from"../services/analytics/index.js";import{execFileNoThrowWithCwd as r}from"./execFileNoThrow.js";import{gitExe as o}from"./git.js";export async function getWorktreePaths(s){const i=Date.now(),{stdout:n,code:a}=await r(o(),["worktree","list","--porcelain"],{cwd:s,preserveOutputOnError:!1}),c=Date.now()-i;if(0!==a)return e("tengu_worktree_detection",{duration_ms:c,worktree_count:0,success:!1}),[];const l=n.split("\n").filter(t=>t.startsWith("worktree ")).map(t=>t.slice(9).normalize("NFC"));e("tengu_worktree_detection",{duration_ms:c,worktree_count:l.length,success:!0});const u=l.find(e=>s===e||s.startsWith(e+t)),m=l.filter(t=>t!==u).sort((t,e)=>t.localeCompare(e));return u?[u,...m]:m}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{readFile as e}from"fs/promises";import{join as t}from"path";export async function parseGitConfigValue(n,r,o,i){try{return parseConfigString(await e(t(n,"config"),"utf-8"),r,o,i)}catch{return null}}export function parseConfigString(e,t,n,r){const o=e.split("\n"),i=t.toLowerCase(),l=r.toLowerCase();let f=!1;for(const e of o){const t=e.trim();if(0===t.length||"#"===t[0]||";"===t[0])continue;if("["===t[0]){f=matchesSectionHeader(t,i,n);continue}if(!f)continue;const r=parseKeyValue(t);if(r&&r.key.toLowerCase()===l)return r.value}return null}function parseKeyValue(e){let t=0;for(;t<e.length&&isKeyChar(e[t]);)t++;if(0===t)return null;const n=e.slice(0,t);for(;t<e.length&&(" "===e[t]||"\t"===e[t]);)t++;if(t>=e.length||"="!==e[t])return null;for(t++;t<e.length&&(" "===e[t]||"\t"===e[t]);)t++;const r=function(e,t){let n="",r=!1,o=t;for(;o<e.length;){const t=e[o];if(!r&&("#"===t||";"===t))break;if('"'!==t){if("\\"===t&&o+1<e.length){const t=e[o+1];if(r){switch(t){case"n":n+="\n";break;case"t":n+="\t";break;case"b":n+="\b";break;case'"':n+='"';break;case"\\":n+="\\";break;default:n+=t}o+=2;continue}if("\\"===t){n+="\\",o+=2;continue}}n+=t,o++}else r=!r,o++}r||(n=function(e){let t=e.length;for(;t>0&&(" "===e[t-1]||"\t"===e[t-1]);)t--;return e.slice(0,t)}(n))
|
|
1
|
+
import{readFile as e}from"fs/promises";import{join as t}from"path";export async function parseGitConfigValue(n,r,o,i){try{return parseConfigString(await e(t(n,"config"),"utf-8"),r,o,i)}catch{return null}}export function parseConfigString(e,t,n,r){const o=e.split("\n"),i=t.toLowerCase(),l=r.toLowerCase();let f=!1;for(const e of o){const t=e.trim();if(0===t.length||"#"===t[0]||";"===t[0])continue;if("["===t[0]){f=matchesSectionHeader(t,i,n);continue}if(!f)continue;const r=parseKeyValue(t);if(r&&r.key.toLowerCase()===l)return r.value}return null}function parseKeyValue(e){let t=0;for(;t<e.length&&isKeyChar(e[t]);)t++;if(0===t)return null;const n=e.slice(0,t);for(;t<e.length&&(" "===e[t]||"\t"===e[t]);)t++;if(t>=e.length||"="!==e[t])return null;for(t++;t<e.length&&(" "===e[t]||"\t"===e[t]);)t++;const r=function(e,t){let n="",r=!1,o=t;for(;o<e.length;){const t=e[o];if(!r&&("#"===t||";"===t))break;if('"'!==t){if("\\"===t&&o+1<e.length){const t=e[o+1];if(r){switch(t){case"n":n+="\n";break;case"t":n+="\t";break;case"b":n+="\b";break;case'"':n+='"';break;case"\\":n+="\\";break;default:n+=t}o+=2;continue}if("\\"===t){n+="\\",o+=2;continue}}n+=t,o++}else r=!r,o++}return r||(n=function(e){let t=e.length;for(;t>0&&(" "===e[t-1]||"\t"===e[t-1]);)t--;return e.slice(0,t)}(n)),n}(e,t);return{key:n,value:r}}function matchesSectionHeader(e,t,n){let r=1;for(;r<e.length&&"]"!==e[r]&&" "!==e[r]&&"\t"!==e[r]&&'"'!==e[r];)r++;if(e.slice(1,r).toLowerCase()!==t)return!1;if(null===n)return r<e.length&&"]"===e[r];for(;r<e.length&&(" "===e[r]||"\t"===e[r]);)r++;if(r>=e.length||'"'!==e[r])return!1;r++;let o="";for(;r<e.length&&'"'!==e[r];){if("\\"===e[r]&&r+1<e.length){const t=e[r+1];if("\\"===t||'"'===t){o+=t,r+=2;continue}o+=t,r+=2;continue}o+=e[r],r++}return!(r>=e.length||'"'!==e[r]||(r++,r>=e.length||"]"!==e[r]||o!==n))}function isKeyChar(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"||e>="0"&&e<="9"||"-"===e}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{unwatchFile as t,watchFile as e}from"fs";import{readdir as r,readFile as i,stat as a}from"fs/promises";import{join as n,resolve as s}from"path";import{waitForScrollIdle as o}from"../../bootstrap/state.js";import{registerCleanup as c}from"../cleanupRegistry.js";import{getCwd as h}from"../cwd.js";import{findGitRoot as
|
|
1
|
+
import{unwatchFile as t,watchFile as e}from"fs";import{readdir as r,readFile as i,stat as a}from"fs/promises";import{join as n,resolve as s}from"path";import{waitForScrollIdle as o}from"../../bootstrap/state.js";import{registerCleanup as c}from"../cleanupRegistry.js";import{getCwd as h}from"../cwd.js";import{findGitRoot as l}from"../git.js";import{parseGitConfigValue as u}from"./gitConfigParser.js";const f=new Map;export function clearResolveGitDirCache(){f.clear()}export async function resolveGitDir(t){const e=s(t??h()),r=f.get(e);if(void 0!==r)return r;const o=l(e);if(!o)return f.set(e,null),null;const c=n(o,".git");try{if((await a(c)).isFile()){const t=(await i(c,"utf-8")).trim();if(t.startsWith("gitdir:")){const r=t.slice(7).trim(),i=s(o,r);return f.set(e,i),i}}return f.set(e,c),c}catch{return f.set(e,null),null}}export function isSafeRefName(t){return!(!t||t.startsWith("-")||t.startsWith("/")||t.includes("..")||t.split("/").some(t=>"."===t||""===t)||!/^[a-zA-Z0-9/._+@-]+$/.test(t))}export function isValidGitSha(t){return/^[0-9a-f]{40}$/.test(t)||/^[0-9a-f]{64}$/.test(t)}export async function readGitHead(t){try{const e=(await i(n(t,"HEAD"),"utf-8")).trim();if(e.startsWith("ref:")){const r=e.slice(4).trim();if(r.startsWith("refs/heads/")){const t=r.slice(11);return isSafeRefName(t)?{type:"branch",name:t}:null}if(!isSafeRefName(r))return null;const i=await resolveRef(t,r);return i?{type:"detached",sha:i}:{type:"detached",sha:""}}return isValidGitSha(e)?{type:"detached",sha:e}:null}catch{return null}}export async function resolveRef(t,e){const r=await resolveRefInDir(t,e);if(r)return r;const i=await getCommonDir(t);return i&&i!==t?resolveRefInDir(i,e):null}async function resolveRefInDir(t,e){try{const r=(await i(n(t,e),"utf-8")).trim();if(r.startsWith("ref:")){const e=r.slice(4).trim();return isSafeRefName(e)?resolveRef(t,e):null}return isValidGitSha(r)?r:null}catch{}try{const r=await i(n(t,"packed-refs"),"utf-8");for(const t of r.split("\n")){if(t.startsWith("#")||t.startsWith("^"))continue;const r=t.indexOf(" ");if(-1!==r&&t.slice(r+1)===e){const e=t.slice(0,r);return isValidGitSha(e)?e:null}}}catch{}return null}export async function getCommonDir(t){try{const e=(await i(n(t,"commondir"),"utf-8")).trim();return s(t,e)}catch{return null}}export async function readRawSymref(t,e,r){try{const a=(await i(n(t,e),"utf-8")).trim();if(a.startsWith("ref:")){const t=a.slice(4).trim();if(t.startsWith(r)){const e=t.slice(r.length);return isSafeRefName(e)?e:null}}}catch{}return null}const m="test"===process.env.NODE_ENV?10:1e3,d=new class{gitDir=null;commonDir=null;initialized=!1;initPromise=null;watchedPaths=[];branchRefPath=null;cache=new Map;async ensureStarted(){if(!this.initialized)return this.initPromise||(this.initPromise=this.start()),this.initPromise}async start(){this.gitDir=await resolveGitDir(),this.initialized=!0,this.gitDir&&(this.commonDir=await getCommonDir(this.gitDir),this.watchPath(n(this.gitDir,"HEAD"),()=>{this.onHeadChanged()}),this.watchPath(n(this.commonDir??this.gitDir,"config"),()=>{this.invalidate()}),await this.watchCurrentBranchRef(),c(async()=>{this.stopWatching()}))}watchPath(t,r){this.watchedPaths.push(t),e(t,{interval:m},r)}async watchCurrentBranchRef(){if(!this.gitDir)return;const e=await readGitHead(this.gitDir),r=this.commonDir??this.gitDir,i="branch"===e?.type?n(r,"refs","heads",e.name):null;i!==this.branchRefPath&&(this.branchRefPath&&(t(this.branchRefPath),this.watchedPaths=this.watchedPaths.filter(t=>t!==this.branchRefPath)),this.branchRefPath=i,i&&this.watchPath(i,()=>{this.invalidate()}))}async onHeadChanged(){this.invalidate(),await o(),await this.watchCurrentBranchRef()}invalidate(){for(const t of this.cache.values())t.dirty=!0}stopWatching(){for(const e of this.watchedPaths)t(e);this.watchedPaths=[],this.branchRefPath=null}async get(t,e){await this.ensureStarted();const r=this.cache.get(t);if(r&&!r.dirty)return r.value;r&&(r.dirty=!1);const i=await e(),a=this.cache.get(t);return a&&!a.dirty&&(a.value=i),a||this.cache.set(t,{value:i,dirty:!1,compute:e}),i}reset(){this.stopWatching(),this.cache.clear(),this.initialized=!1,this.initPromise=null,this.gitDir=null,this.commonDir=null}};async function computeBranch(){const t=await resolveGitDir();if(!t)return"HEAD";const e=await readGitHead(t);return e&&"branch"===e.type?e.name:"HEAD"}async function computeHead(){const t=await resolveGitDir();if(!t)return"";const e=await readGitHead(t);return e?"branch"===e.type?await resolveRef(t,`refs/heads/${e.name}`)??"":e.sha:""}async function computeRemoteUrl(){const t=await resolveGitDir();if(!t)return null;const e=await u(t,"remote","origin","url");if(e)return e;const r=await getCommonDir(t);return r&&r!==t?u(r,"remote","origin","url"):null}async function computeDefaultBranch(){const t=await resolveGitDir();if(!t)return"main";const e=await getCommonDir(t)??t,r=await readRawSymref(e,"refs/remotes/origin/HEAD","refs/remotes/origin/");if(r)return r;for(const t of["main","master"])if(await resolveRef(e,`refs/remotes/origin/${t}`))return t;return"main"}export function getCachedBranch(){return d.get("branch",computeBranch)}export function getCachedHead(){return d.get("head",computeHead)}export function getCachedRemoteUrl(){return d.get("remoteUrl",computeRemoteUrl)}export function getCachedDefaultBranch(){return d.get("defaultBranch",computeDefaultBranch)}export function resetGitFileWatcher(){d.reset()}export async function getHeadForDir(t){const e=await resolveGitDir(t);if(!e)return null;const r=await readGitHead(e);return r?"branch"===r.type?resolveRef(e,`refs/heads/${r.name}`):r.sha:null}export async function readWorktreeHeadSha(t){let e;try{const r=(await i(n(t,".git"),"utf-8")).trim();if(!r.startsWith("gitdir:"))return null;e=s(t,r.slice(7).trim())}catch{return null}const r=await readGitHead(e);return r?"branch"===r.type?resolveRef(e,`refs/heads/${r.name}`):r.sha:null}export async function getRemoteUrlForDir(t){const e=await resolveGitDir(t);if(!e)return null;const r=await u(e,"remote","origin","url");if(r)return r;const i=await getCommonDir(e);return i&&i!==e?u(i,"remote","origin","url"):null}export async function isShallowClone(){const t=await resolveGitDir();if(!t)return!1;const e=await getCommonDir(t)??t;try{return await a(n(e,"shallow")),!0}catch{return!1}}export async function getWorktreeCountFromFs(){try{const t=await resolveGitDir();if(!t)return 0;const e=await getCommonDir(t)??t;return(await r(n(e,"worktrees"))).length+1}catch{return 1}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{appendFile as
|
|
1
|
+
import{appendFile as r,mkdir as t,readFile as i,writeFile as o}from"fs/promises";import{homedir as e}from"os";import{dirname as a,join as n}from"path";import{getCwd as s}from"../cwd.js";import{getErrnoCode as c}from"../errors.js";import{execFileNoThrowWithCwd as m}from"../execFileNoThrow.js";import{dirIsInGitRepo as f}from"../git.js";import{logError as d}from"../log.js";export async function isPathGitignored(r,t){const{code:i}=await m("git",["check-ignore",r],{preserveOutputOnError:!1,cwd:t});return 0===i}export function getGlobalGitignorePath(){return n(e(),".config","git","ignore")}export async function addFileGlobRuleToGitignore(e,n=s()){try{if(!await f(n))return;const s=`**/${e}`,m=e.endsWith("/")?`${e}sample-file.txt`:e;if(await isPathGitignored(m,n))return;const d=getGlobalGitignorePath(),p=a(d);await t(p,{recursive:!0});try{if((await i(d,{encoding:"utf-8"})).includes(s))return;await r(d,`\n${s}\n`)}catch(r){if("ENOENT"!==c(r))throw r;await o(d,`${s}\n`,"utf-8")}}catch(r){d(r)}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{access as t,readFile as e}from"fs/promises";import{dirname as
|
|
1
|
+
import{access as t,readFile as e}from"fs/promises";import{dirname as s,join as n,relative as i,sep as o}from"path";import{getCwd as r}from"./cwd.js";import{getCachedRepository as a}from"./detectRepository.js";import{execFileNoThrow as l,execFileNoThrowWithCwd as c}from"./execFileNoThrow.js";import{isFileWithinReadSizeLimit as f}from"./file.js";import{findGitRoot as u,getDefaultBranch as p,getGitDir as d,getIsGit as h,gitExe as m}from"./git.js";const w=5e3,E=1e6;export async function fetchGitDiff(){if(!await h())return null;if(await isInTransientGitState())return null;const{stdout:t,code:e}=await l(m(),["--no-optional-locks","diff","HEAD","--shortstat"],{timeout:w,preserveOutputOnError:!1});if(0===e){const e=parseShortstat(t);if(e&&e.filesCount>500)return{stats:e,perFileStats:new Map,hunks:new Map}}const{stdout:s,code:n}=await l(m(),["--no-optional-locks","diff","HEAD","--numstat"],{timeout:w,preserveOutputOnError:!1});if(0!==n)return null;const{stats:i,perFileStats:o}=parseGitNumstat(s),r=50-o.size;if(r>0){const t=await async function(t){const{stdout:e,code:s}=await l(m(),["--no-optional-locks","ls-files","--others","--exclude-standard"],{timeout:w,preserveOutputOnError:!1});if(0!==s||!e.trim())return null;const n=e.trim().split("\n").filter(Boolean);if(0===n.length)return null;const i=new Map;for(const e of n.slice(0,t))i.set(e,{added:0,removed:0,isBinary:!1,isUntracked:!0});return i}(r);if(t){i.filesCount+=t.size;for(const[e,s]of t)o.set(e,s)}}return{stats:i,perFileStats:o,hunks:new Map}}export async function fetchGitDiffHunks(){if(!await h())return new Map;if(await isInTransientGitState())return new Map;const{stdout:t,code:e}=await l(m(),["--no-optional-locks","diff","HEAD"],{timeout:w,preserveOutputOnError:!1});return 0!==e?new Map:parseGitDiff(t)}export function parseGitNumstat(t){const e=t.trim().split("\n").filter(Boolean);let s=0,n=0,i=0;const o=new Map;for(const t of e){const e=t.split("\t");if(e.length<3)continue;i++;const r=e[0],a=e[1],l=e.slice(2).join("\t"),c="-"===r||"-"===a,f=c?0:parseInt(r??"0",10)||0,u=c?0:parseInt(a??"0",10)||0;s+=f,n+=u,o.size<50&&o.set(l,{added:f,removed:u,isBinary:c})}return{stats:{filesCount:i,linesAdded:s,linesRemoved:n},perFileStats:o}}export function parseGitDiff(t){const e=new Map;if(!t.trim())return e;const s=t.split(/^diff --git /m).filter(Boolean);for(const t of s){if(e.size>=50)break;if(t.length>E)continue;const s=t.split("\n"),n=s[0]?.match(/^a\/(.+?) b\/(.+)$/);if(!n)continue;const i=n[2]??n[1]??"",o=[];let r=null,a=0;for(let t=1;t<s.length;t++){const e=s[t]??"",n=e.match(/^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/);if(n)r&&o.push(r),r={oldStart:parseInt(n[1]??"0",10),oldLines:parseInt(n[2]??"1",10),newStart:parseInt(n[3]??"0",10),newLines:parseInt(n[4]??"1",10),lines:[]};else if(!(e.startsWith("index ")||e.startsWith("---")||e.startsWith("+++")||e.startsWith("new file")||e.startsWith("deleted file")||e.startsWith("old mode")||e.startsWith("new mode")||e.startsWith("Binary files"))&&r&&(e.startsWith("+")||e.startsWith("-")||e.startsWith(" ")||""===e)){if(a>=400)continue;r.lines.push(""+e),a++}}r&&o.push(r),o.length>0&&e.set(i,o)}return e}async function isInTransientGitState(){const e=await d(r());return!!e&&(await Promise.all(["MERGE_HEAD","REBASE_HEAD","CHERRY_PICK_HEAD","REVERT_HEAD"].map(s=>t(n(e,s)).then(()=>!0).catch(()=>!1)))).some(Boolean)}export function parseShortstat(t){const e=t.match(/(\d+)\s+files?\s+changed(?:,\s+(\d+)\s+insertions?\(\+\))?(?:,\s+(\d+)\s+deletions?\(-\))?/);return e?{filesCount:parseInt(e[1]??"0",10),linesAdded:parseInt(e[2]??"0",10),linesRemoved:parseInt(e[3]??"0",10)}:null}const D=3e3;export async function fetchSingleFileGitDiff(t){const n=u(s(t));if(!n)return null;const r=i(n,t).split(o).join("/"),l=a(),{code:d}=await c(m(),["--no-optional-locks","ls-files","--error-unmatch",r],{cwd:n,timeout:D});if(0===d){const t=await async function(t){const e=process.env.CONTEXT_CODE_BASE_REF||process.env.CLAUDE_CODE_BASE_REF||await p(),{stdout:s,code:n}=await c(m(),["--no-optional-locks","merge-base","HEAD",e],{cwd:t,timeout:D});return 0===n&&s.trim()?s.trim():"HEAD"}(n),{stdout:e,code:s}=await c(m(),["--no-optional-locks","diff",t,"--",r],{cwd:n,timeout:D});return 0!==s?null:e?{...parseRawDiffToToolUseDiff(r,e,"modified"),repository:l}:null}const h=await async function(t,s){try{if(!f(s,E))return null;const n=(await e(s,"utf-8")).split("\n");n.length>0&&""===n.at(-1)&&n.pop();const i=n.length,o=n.map(t=>`+${t}`).join("\n");return{filename:t,status:"added",additions:i,deletions:0,changes:i,patch:`@@ -0,0 +1,${i} @@\n${o}`}}catch{return null}}(r,t);return h?{...h,repository:l}:null}function parseRawDiffToToolUseDiff(t,e,s){const n=e.split("\n"),i=[];let o=!1,r=0,a=0;for(const t of n)t.startsWith("@@")&&(o=!0),o&&(i.push(t),t.startsWith("+")&&!t.startsWith("+++")?r++:t.startsWith("-")&&!t.startsWith("---")&&a++);return{filename:t,status:s,additions:r,deletions:a,changes:r+a,patch:i.join("\n")}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isEnvDefinedFalsy as s,isEnvTruthy as t}from"./envUtils.js";import{getInitialSettings as n}from"./settings/settings.js";export function shouldIncludeGitInstructions(){const
|
|
1
|
+
import{isEnvDefinedFalsy as s,isEnvTruthy as t}from"./envUtils.js";import{getInitialSettings as n}from"./settings/settings.js";export function shouldIncludeGitInstructions(){const i=process.env.CONTEXT_CODE_DISABLE_GIT_INSTRUCTIONS??process.env.CLAUDE_CODE_DISABLE_GIT_INSTRUCTIONS;return!t(i)&&(!!s(i)||(n().includeGitInstructions??!0))}
|
package/dist/src/utils/glob.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{basename as e,dirname as t,isAbsolute as
|
|
1
|
+
import{basename as e,dirname as t,isAbsolute as s,join as r,sep as o}from"path";import{isEnvTruthy as i}from"./envUtils.js";import{getFileReadIgnorePatterns as a,normalizePatternsToPath as n}from"./permissions/filesystem.js";import{getPlatform as l}from"./platform.js";import{getGlobExclusionsForPluginCache as c}from"./plugins/orphanedPluginFilter.js";import{ripGrep as f}from"./ripgrep.js";export function extractGlobBaseDirectory(s){const r=s.match(/[*?[{]/);if(!r||void 0===r.index)return{baseDir:t(s),relativePattern:e(s)};const i=s.slice(0,r.index),a=Math.max(i.lastIndexOf("/"),i.lastIndexOf(o));if(-1===a)return{baseDir:"",relativePattern:s};let n=i.slice(0,a);const c=s.slice(a+1);return""===n&&0===a&&(n="/"),"windows"===l()&&/^[A-Za-z]:$/.test(n)&&(n+=o),{baseDir:n,relativePattern:c}}export async function glob(e,t,{limit:o,offset:l},p,m){let u=t,D=e;if(s(e)){const{baseDir:t,relativePattern:s}=extractGlobBaseDirectory(e);t&&(u=t,D=s)}const O=n(a(m),u),d=["--files","--glob",D,"--sort=modified",...i(process.env.CONTEXT_CODE_GLOB_NO_IGNORE||process.env.CLAUDE_CODE_GLOB_NO_IGNORE||"true")?["--no-ignore"]:[],...i(process.env.CONTEXT_CODE_GLOB_HIDDEN||process.env.CLAUDE_CODE_GLOB_HIDDEN||"true")?["--hidden"]:[]];for(const e of O)d.push("--glob",`!${e}`);for(const e of await c(u))d.push("--glob",e);const g=(await f(d,u,p)).map(e=>s(e)?e:r(u,e)),E=g.length>l+o;return{files:g.slice(l,l+o),truncated:E}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"chalk";import{writeSync as
|
|
1
|
+
import e from"chalk";import{writeSync as s}from"fs";import t from"lodash-es/memoize.js";import{onExit as r}from"signal-exit";import{getIsInteractive as o,getIsScrollDraining as n,getLastMainRequestId as i,getSessionId as a,isSessionPersistenceDisabled as c}from"../bootstrap/state.js";import u from"../ink/instances.js";import{DISABLE_KITTY_KEYBOARD as l,DISABLE_MODIFY_OTHER_KEYS as p}from"../ink/termio/csi.js";import{DBP as m,DFE as d,DISABLE_MOUSE_TRACKING as g,EXIT_ALT_SCREEN as f,SHOW_CURSOR as E}from"../ink/termio/dec.js";import{CLEAR_ITERM2_PROGRESS as h,CLEAR_TAB_STATUS as _,CLEAR_TERMINAL_TITLE as S,supportsTabStatus as T,wrapForMultiplexer as I}from"../ink/termio/osc.js";import{shutdownDatadog as w}from"../services/analytics/datadog.js";import{shutdown1PEventLogging as x}from"../services/analytics/firstPartyEventLogger.js";import{logEvent as R}from"../services/analytics/index.js";import{runCleanupFunctions as v}from"./cleanupRegistry.js";import{logForDebugging as y}from"./debug.js";import{logForDiagnosticsNoPII as L}from"./diagLogs.js";import{isEnvTruthy as j}from"./envUtils.js";import{getCurrentSessionTitle as A,sessionIdExists as D}from"./sessionStorage.js";import{sleep as M}from"./sleep.js";import{profileReport as C}from"./startupProfiler.js";function cleanupTerminalModes(){if(process.stdout.isTTY)try{s(1,g);const e=u.get(process.stdout);if(e?.isAltScreenActive)try{e.unmount()}catch{s(1,f)}e?.drainStdin(),e?.detachForShutdown(),s(1,p),s(1,l),s(1,d),s(1,m),s(1,E),s(1,h),T()&&s(1,I(_)),j(process.env.CONTEXT_CODE_DISABLE_TERMINAL_TITLE)||j(process.env.CLAUDE_CODE_DISABLE_TERMINAL_TITLE)||("win32"===process.platform?process.title="":s(1,S))}catch{}}let P=!1;function printResumeHint(){if(!P&&process.stdout.isTTY&&o()&&!c())try{const t=a();if(!D(t))return;const r=A(t);let o;o=r?`"${r.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`:t,s(1,e.dim(`\nReanuda esta sesion con:\ncontext --resume ${o}\n`)),P=!0}catch{}}function forceExit(e){void 0!==N&&(clearTimeout(N),N=void 0);try{u.get(process.stdout)?.drainStdin()}catch{}try{process.exit(e)}catch(e){if("test"===process.env.NODE_ENV)throw e;process.kill(process.pid,"SIGKILL")}if("test"!==process.env.NODE_ENV)throw new Error("unreachable")}export const setupGracefulShutdown=t(()=>{r(()=>{}),process.on("SIGINT",()=>{process.argv.includes("-p")||process.argv.includes("--print")||(G&&(cleanupTerminalModes(),forceExit(130)),L("info","shutdown_signal",{signal:"SIGINT"}),gracefulShutdown(0))}),process.on("SIGTERM",()=>{L("info","shutdown_signal",{signal:"SIGTERM"}),gracefulShutdown(143)}),"win32"!==process.platform&&(process.on("SIGHUP",()=>{L("info","shutdown_signal",{signal:"SIGHUP"}),gracefulShutdown(129)}),process.stdin.isTTY&&(k=setInterval(()=>{n()||process.stdout.writable&&process.stdin.readable||(clearInterval(k),L("info","shutdown_signal",{signal:"orphan_detected"}),gracefulShutdown(129))},3e4),k.unref())),process.on("uncaughtException",e=>{L("error","uncaught_exception",{error_name:e.name,error_message:e.message.slice(0,2e3)}),R("tengu_uncaught_exception",{error_name:e.name})}),process.on("unhandledRejection",e=>{const s=e instanceof Error?e.name:"string"==typeof e?"string":"unknown",t=e instanceof Error?{error_name:e.name,error_message:e.message.slice(0,2e3),error_stack:e.stack?.slice(0,4e3)}:{error_message:String(e).slice(0,2e3)};L("error","unhandled_rejection",t),R("tengu_unhandled_rejection",{error_name:s})})});export function gracefulShutdownSync(e=0,s="other",t){process.exitCode=e,O=gracefulShutdown(e,s,t).catch(s=>{y(`Graceful shutdown failed: ${s}`,{level:"error"}),cleanupTerminalModes(),printResumeHint(),forceExit(e)}).catch(()=>{})}let N,k,O,G=!1;export function isShuttingDown(){return G}export function resetShutdownState(){G=!1,P=!1,void 0!==N&&(clearTimeout(N),N=void 0),O=void 0}export function getPendingShutdownForTesting(){return O}export async function gracefulShutdown(e=0,t="other",r){if(G)return;G=!0;const{executeSessionEndHooks:o,getSessionEndHookTimeoutMs:n}=await import("./hooks.js"),a=n();let c;N=setTimeout(e=>{cleanupTerminalModes(),printResumeHint(),forceExit(e)},Math.max(5e3,a+3500),e),N.unref(),process.exitCode=e,cleanupTerminalModes(),printResumeHint();try{const e=(async()=>{try{await v()}catch{}})();await Promise.race([e,new Promise((e,s)=>{c=setTimeout(e=>e(new CleanupTimeoutError),2e3,s)})]),clearTimeout(c)}catch{clearTimeout(c)}try{await o(t,{...r,signal:AbortSignal.timeout(a),timeoutMs:a})}catch{}try{C()}catch{}const u=i();u&&R("tengu_cache_eviction_hint",{scope:"session_end",last_request_id:u});try{await Promise.race([Promise.all([x(),w()]),M(500)])}catch{}if(r?.finalMessage)try{s(2,r.finalMessage+"\n")}catch{}forceExit(e)}class CleanupTimeoutError extends Error{constructor(){super("Cleanup timeout")}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=new WeakMap;function getToolUseInfo(e){if("assistant"===e.type&&"tool_use"===e.message.content[0]?.type){const o=e.message.content[0];return{messageId:e.message.id,toolUseId:o.id,toolName:o.name}}return null}export function applyGrouping(o,t,s=!1){if(s)return{messages:o};const n=function(o){let t=e.get(o);return t||(t=new Set(o.filter(e=>e.renderGroupedToolUse).map(e=>e.name)),e.set(o,t)),t}(t),a=new Map;for(const e of o){const o=getToolUseInfo(e);if(o&&n.has(o.toolName)){const t=`${o.messageId}:${o.toolName}`,s=a.get(t)??[];s.push(e),a.set(t,s)}}const f=new Map,u=new Set;for(const[e,o]of a)if(o.length>=2){f.set(e,o);for(const e of o){const o=getToolUseInfo(e);o&&u.add(o.toolUseId)}}const c=new Map;for(const e of o)if("user"===e.type)for(const o of e.message.content)"tool_result"===o.type&&u.has(o.tool_use_id)&&c.set(o.tool_use_id,e);const l=[],r=new Set;for(const e of o){const o=getToolUseInfo(e);if(o){const e=`${o.messageId}:${o.toolName}`,t=f.get(e);if(t){if(!r.has(e)){r.add(e);const s=t[0],n=[];for(const e of t){const o=e.message.content[0].id,t=c.get(o);t&&n.push(t)}const a={type:"grouped_tool_use",toolName:o.toolName,messages:t,results:n,displayMessage:s,uuid:`grouped-${s.uuid}`,timestamp:s.timestamp,messageId:o.messageId};l.push(a)}continue}}if("user"===e.type){const o=e.message.content.filter(e=>"tool_result"===e.type);if(o.length>0
|
|
1
|
+
const e=new WeakMap;function getToolUseInfo(e){if("assistant"===e.type&&"tool_use"===e.message.content[0]?.type){const o=e.message.content[0];return{messageId:e.message.id,toolUseId:o.id,toolName:o.name}}return null}export function applyGrouping(o,t,s=!1){if(s)return{messages:o};const n=function(o){let t=e.get(o);return t||(t=new Set(o.filter(e=>e.renderGroupedToolUse).map(e=>e.name)),e.set(o,t)),t}(t),a=new Map;for(const e of o){const o=getToolUseInfo(e);if(o&&n.has(o.toolName)){const t=`${o.messageId}:${o.toolName}`,s=a.get(t)??[];s.push(e),a.set(t,s)}}const f=new Map,u=new Set;for(const[e,o]of a)if(o.length>=2){f.set(e,o);for(const e of o){const o=getToolUseInfo(e);o&&u.add(o.toolUseId)}}const c=new Map;for(const e of o)if("user"===e.type)for(const o of e.message.content)"tool_result"===o.type&&u.has(o.tool_use_id)&&c.set(o.tool_use_id,e);const l=[],r=new Set;for(const e of o){const o=getToolUseInfo(e);if(o){const e=`${o.messageId}:${o.toolName}`,t=f.get(e);if(t){if(!r.has(e)){r.add(e);const s=t[0],n=[];for(const e of t){const o=e.message.content[0].id,t=c.get(o);t&&n.push(t)}const a={type:"grouped_tool_use",toolName:o.toolName,messages:t,results:n,displayMessage:s,uuid:`grouped-${s.uuid}`,timestamp:s.timestamp,messageId:o.messageId};l.push(a)}continue}}if("user"===e.type){const o=e.message.content.filter(e=>"tool_result"===e.type);if(o.length>0&&o.every(e=>u.has(e.tool_use_id)))continue}l.push(e)}return{messages:l}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{logEvent as e}from"
|
|
1
|
+
import{logEvent as e}from"src/services/analytics/index.js";import{getCommandName as t,isCommandEnabled as o}from"../commands.js";import{selectableUserMessagesFilter as s}from"../components/MessageSelector.js";import{expandPastedTextRefs as r,parseReferences as n}from"../history.js";import{isValidImagePaste as i}from"../types/textInputTypes.js";import{createAbortController as a}from"./abortController.js";import{logForDebugging as u}from"./debug.js";import{fileHistoryEnabled as m,fileHistoryMakeSnapshot as l}from"./fileHistory.js";import{gracefulShutdownSync as d}from"./gracefulShutdown.js";import{enqueue as p}from"./messageQueueManager.js";import{resolveSkillModelOverride as c}from"./model/model.js";import{processUserInput as f}from"./processUserInput/processUserInput.js";import{queryCheckpoint as g,startQueryProfile as y}from"./queryProfiler.js";import{runWithWorkload as x}from"./workloadContext.js";export async function handlePromptSubmit(s){const{helpers:m,queryGuard:l,isExternalLoading:c=!1,commands:f,onInputChange:g,setPastedContents:x,setToolJSX:h,getToolUseContext:C,messages:S,mainLoopModel:I,ideSelection:v,setUserInputOnProcessing:T,setAbortController:b,onQuery:q,setAppState:j,onBeforeQuery:M,canUseTool:_,queuedCommands:U,uuid:k,skipSlashCommands:P,onJumpToMessage:w}=s,{setCursorOffset:J,clearBuffer:A,resetHistory:H}=m;if(U?.length)return y(),void await executeUserInput({queuedCommands:U,messages:S,mainLoopModel:I,ideSelection:v,querySource:s.querySource,commands:f,queryGuard:l,setToolJSX:h,getToolUseContext:C,setUserInputOnProcessing:T,setAbortController:b,onQuery:q,setAppState:j,onBeforeQuery:M,resetHistory:H,canUseTool:_,onInputChange:g,onJumpToMessage:s.onJumpToMessage});const O=s.input??"",Q=s.mode??"prompt",E=s.pastedContents??{},L=new Set(n(O).map(e=>e.id)),X=Object.fromEntries(Object.entries(E).filter(([,e])=>"image"!==e.type||L.has(e.id))),B=Object.values(X).some(i);if(""===O.trim())return;if(!P&&["exit","quit",":q",":q!",":wq",":wq!"].includes(O.trim())){return void(f.find(e=>"exit"===e.name)?handlePromptSubmit({...s,input:"/exit"}):d(0))}const N=r(O,X),G=n(O).filter(e=>"text"===X[e.id]?.type),R=G.length,V=G.reduce((e,t)=>e+(X[t.id]?.content.length??0),0);if(e("tengu_paste_text",{pastedTextCount:R,pastedTextBytes:V}),!P&&N.trim().startsWith("/")){const r=N.trim(),n=r.indexOf(" "),i=-1===n?r.slice(1):r.slice(1,n),u=-1===n?"":r.slice(n+1).trim(),m=f.find(e=>e.immediate&&o(e)&&(e.name===i||e.aliases?.includes(i)||t(e)===i));if(m&&"local-jsx"===m.type&&(l.isActive||c)){e("tengu_immediate_command_executed",{commandName:m.name}),g(""),J(0),x({}),A();const t=C(S,[],a(),I);let o=!1;const onDone=(e,t)=>{o=!0,h({jsx:null,shouldHidePromptInput:!1,clearLocalJSX:!0}),e&&"skip"!==t?.display&&s.addNotification&&s.addNotification({key:`immediate-${m.name}`,text:e,priority:"immediate"}),t?.nextInput&&(t.submitNextInput?p({value:t.nextInput,mode:"prompt"}):g(t.nextInput)),t?.jumpToMessageId&&s.onJumpToMessage?.(t.jumpToMessageId)},r=await m.load(),n=await r.call(onDone,t,u);return void(n&&!o&&h({jsx:n,shouldHidePromptInput:!1,isLocalJSXCommand:!0,isImmediate:!0}))}}if(l.isActive||c){if("prompt"!==Q&&"bash"!==Q)return;return s.hasInterruptibleToolInProgress&&(u(`[interrupt] Aborting current turn: streamMode=${s.streamMode}`),e("tengu_cancel",{source:"interrupt_on_submit",streamMode:s.streamMode}),s.abortController?.abort("interrupt")),p({value:N.trim(),preExpansionValue:O.trim(),mode:Q,pastedContents:B?X:void 0,skipSlashCommands:P,uuid:k}),g(""),J(0),x({}),H(),void A()}y();const W={value:N,preExpansionValue:O,mode:Q,pastedContents:B?X:void 0,skipSlashCommands:P,uuid:k};await executeUserInput({queuedCommands:[W],messages:S,mainLoopModel:I,ideSelection:v,querySource:s.querySource,commands:f,queryGuard:l,setToolJSX:h,getToolUseContext:C,setUserInputOnProcessing:T,setAbortController:b,onQuery:q,setAppState:j,onBeforeQuery:M,resetHistory:H,canUseTool:_,onInputChange:g,onJumpToMessage:s.onJumpToMessage})}async function executeUserInput(e){const{messages:t,mainLoopModel:o,ideSelection:r,querySource:n,queryGuard:i,setToolJSX:u,getToolUseContext:d,setUserInputOnProcessing:y,setAbortController:h,onQuery:C,setAppState:S,onBeforeQuery:I,resetHistory:v,canUseTool:T,queuedCommands:b,onJumpToMessage:q}=e,j=a();function makeContext(){return d(t,[],j,o)}h(j);try{i.reserve(),g("query_process_user_input_start");const a=[];let d,M,_,U,k,P,w=!1;const J=b??[],A=J[0]?.workload,H=void 0!==A&&J.every(e=>e.workload===A)?A:void 0;await x(H,async()=>{for(let e=0;e<J.length;e++){const o=J[e],s=0===e,i=await f({input:o.value,preExpansionInput:o.preExpansionValue,mode:o.mode,setToolJSX:u,context:makeContext(),pastedContents:s?o.pastedContents:void 0,messages:t,setUserInputOnProcessing:s?y:void 0,isAlreadyProcessing:!s,querySource:n,canUseTool:T,uuid:o.uuid,ideSelection:s?r:void 0,skipSlashCommands:o.skipSlashCommands,bridgeOrigin:o.bridgeOrigin,isMeta:o.isMeta,skipAttachments:!s}),m=o.origin??("task-notification"===o.mode?{kind:"task-notification"}:void 0);if(m)for(const e of i.messages)"user"===e.type&&(e.origin=m);a.push(...i.messages),s&&(w=i.shouldQuery,d=i.allowedTools,M=i.model,_=i.effort,U=i.nextInput,k=i.submitNextInput,P=i.jumpToMessageId)}if(g("query_process_user_input_end"),m()&&(g("query_file_history_snapshot_start"),a.filter(s).forEach(e=>{l(e=>{S(t=>({...t,fileHistory:e(t.fileHistory)}))},e.uuid)}),g("query_file_history_snapshot_end")),a.length){v(),u({jsx:null,shouldHidePromptInput:!1,clearLocalJSX:!0});const e=J[0],t=e?.mode??"prompt",s=e&&"string"==typeof e.value?e.value:void 0,r="prompt"===t;await C(a,j,w,d??[],M?c(M,o):o,r?I:void 0,s,_)}else i.cancelReservation(),u({jsx:null,shouldHidePromptInput:!1,clearLocalJSX:!0}),v(),h(null);U&&(k?p({value:U,mode:"prompt"}):e.onInputChange(U)),P&&q?.(P)})}finally{i.cancelReservation(),y(void 0)}}
|
package/dist/src/utils/hash.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createRequire as t}from"module";const e=t(import.meta.url);export function djb2Hash(t){let e=0;for(let n=0;n<t.length;n++)e=(e<<5)-e+t.charCodeAt(n)|0;return e}export function hashContent(t){
|
|
1
|
+
import{createRequire as t}from"module";const e=t(import.meta.url);export function djb2Hash(t){let e=0;for(let n=0;n<t.length;n++)e=(e<<5)-e+t.charCodeAt(n)|0;return e}export function hashContent(t){return"undefined"!=typeof Bun?Bun.hash(t).toString():e("crypto").createHash("sha256").update(t).digest("hex")}export function hashPair(t,n){return"undefined"!=typeof Bun?Bun.hash(n,Bun.hash(t)).toString():e("crypto").createHash("sha256").update(t).update("\0").update(n).digest("hex")}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import t from"chokidar";import{isAbsolute as e,join as n}from"path";import{registerCleanup as o}from"../cleanupRegistry.js";import{logForDebugging as s}from"../debug.js";import{errorMessage as
|
|
1
|
+
import t from"chokidar";import{isAbsolute as e,join as n}from"path";import{registerCleanup as o}from"../cleanupRegistry.js";import{logForDebugging as s}from"../debug.js";import{errorMessage as a}from"../errors.js";import{executeCwdChangedHooks as r,executeFileChangedHooks as i}from"../hooks.js";import{clearCwdEnvFiles as h}from"../sessionEnvironment.js";import{getHooksConfigFromSnapshot as l}from"./hooksConfigSnapshot.js";let c,g=null,u=[],d=[],f=!1,p=!1,m=null;export function setEnvHookNotifier(t){m=t}export function initializeFileChangedWatcher(t){if(f)return;f=!0,c=t;const e=l();p=(e?.CwdChanged?.length??0)>0||(e?.FileChanged?.length??0)>0,p&&o(async()=>dispose());const n=resolveWatchPaths(e);0!==n.length&&startWatching(n)}function resolveWatchPaths(t){const o=(t??l())?.FileChanged??[],s=[];for(const t of o)if(t.matcher)for(const o of t.matcher.split("|").map(t=>t.trim()))o&&s.push(e(o)?o:n(c,o));return[...new Set([...s,...u])]}function startWatching(e){s(`FileChanged: watching ${e.length} paths`),g=t.watch(e,{persistent:!0,ignoreInitial:!0,awaitWriteFinish:{stabilityThreshold:500,pollInterval:200},ignorePermissionErrors:!0}),g.on("change",t=>handleFileEvent(t,"change")),g.on("add",t=>handleFileEvent(t,"add")),g.on("unlink",t=>handleFileEvent(t,"unlink"))}function handleFileEvent(t,e){s(`FileChanged: ${e} ${t}`),i(t,e).then(({results:t,watchPaths:e,systemMessages:n})=>{e.length>0&&updateWatchPaths(e);for(const t of n)m?.(t,!1);for(const e of t)!e.succeeded&&e.output&&m?.(e.output,!0)}).catch(t=>{const e=a(t);s(`FileChanged hook failed: ${e}`,{level:"error"}),m?.(e,!0)})}export function updateWatchPaths(t){if(!f)return;const e=t.slice().sort();e.length===d.length&&e.every((t,e)=>t===d[e])||(u=t,d=e,restartWatching())}function restartWatching(){g&&(g.close(),g=null);const t=resolveWatchPaths();t.length>0&&startWatching(t)}export async function onCwdChangedForHooks(t,e){if(t===e)return;const n=l();if(!((n?.CwdChanged?.length??0)>0||(n?.FileChanged?.length??0)>0))return;c=e,await h();const o=await r(t,e).catch(t=>{const e=a(t);return s(`CwdChanged hook failed: ${e}`,{level:"error"}),m?.(e,!0),{results:[],watchPaths:[],systemMessages:[]}});u=o.watchPaths,d=o.watchPaths.slice().sort();for(const t of o.systemMessages)m?.(t,!1);for(const t of o.results)!t.succeeded&&t.output&&m?.(t.output,!0);f&&restartWatching()}function dispose(){g&&(g.close(),g=null),u=[],d=[],f=!1,p=!1,m=null}export function resetFileChangedWatcherForTesting(){dispose()}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{resolve as t}from"path";import{getSessionId as e}from"../../bootstrap/state.js";import{SOURCES as o}from"../settings/constants.js";import{getSettingsFilePathForSource as s,getSettingsForSource as
|
|
1
|
+
import{resolve as t}from"path";import{getSessionId as e}from"../../bootstrap/state.js";import{SOURCES as o}from"../settings/constants.js";import{getSettingsFilePathForSource as s,getSettingsForSource as r}from"../settings/settings.js";import{DEFAULT_HOOK_SHELL as n}from"../shell/shellProvider.js";import{getSessionHooks as i}from"./sessionHooks.js";export function isHookEqual(t,e){if(t.type!==e.type)return!1;const sameIf=(t,e)=>(t.if??"")===(e.if??"");switch(t.type){case"command":return"command"===e.type&&t.command===e.command&&(t.shell??n)===(e.shell??n)&&sameIf(t,e);case"prompt":return"prompt"===e.type&&t.prompt===e.prompt&&sameIf(t,e);case"agent":return"agent"===e.type&&t.prompt===e.prompt&&sameIf(t,e);case"http":return"http"===e.type&&t.url===e.url&&sameIf(t,e);case"function":return!1}}export function getHookDisplayText(t){if("statusMessage"in t&&t.statusMessage)return t.statusMessage;switch(t.type){case"command":return t.command;case"prompt":case"agent":return t.prompt;case"http":return t.url;case"callback":return"callback";case"function":return"function"}}export function getAllHooks(o){const n=[],c=r("policySettings");if(!0!==c?.allowManagedHooksOnly){const e=["userSettings","projectSettings","localSettings"],o=new Set;for(const i of e){const e=s(i);if(e){const s=t(e);if(o.has(s))continue;o.add(s)}const c=r(i);if(c?.hooks)for(const[t,e]of Object.entries(c.hooks))for(const o of e)for(const e of o.hooks)n.push({event:t,config:e,matcher:o.matcher,source:i})}}const a=e(),u=i(o,a);for(const[t,e]of u.entries())for(const o of e)for(const e of o.hooks)n.push({event:t,config:e,matcher:o.matcher,source:"sessionHook"});return n}export function getHooksForEvent(t,e){return getAllHooks(t).filter(t=>t.event===e)}export function hookSourceDescriptionDisplayString(t){switch(t){case"userSettings":return"User settings (~/.context/settings.json)";case"projectSettings":return"Project settings (.claude/settings.json)";case"localSettings":return"Local settings (.claude/settings.local.json)";case"pluginHook":return"Plugin hooks (~/.context/plugins/*/hooks/hooks.json)";case"sessionHook":return"Session hooks (in-memory, temporary)";case"builtinHook":return"Built-in hooks (registered internally by Context Code)";default:return t}}export function hookSourceHeaderDisplayString(t){switch(t){case"userSettings":return"User Settings";case"projectSettings":return"Project Settings";case"localSettings":return"Local Settings";case"pluginHook":return"Plugin Hooks";case"sessionHook":return"Session Hooks";case"builtinHook":return"Built-in Hooks";default:return t}}export function hookSourceInlineDisplayString(t){switch(t){case"userSettings":return"User";case"projectSettings":return"Project";case"localSettings":return"Local";case"pluginHook":return"Plugin";case"sessionHook":return"Session";case"builtinHook":return"Built-in";default:return t}}export function sortMatchersByPriority(t,e,s){const r=o.reduce((t,e,o)=>(t[e]=o,t),{});return[...t].sort((t,o)=>{const n=e[s]?.[t]||[],i=e[s]?.[o]||[],c=Array.from(new Set(n.map(t=>t.source))),a=Array.from(new Set(i.map(t=>t.source))),getSourcePriority=t=>"pluginHook"===t||"builtinHook"===t?999:r[t],u=Math.min(...c.map(getSourcePriority)),l=Math.min(...a.map(getSourcePriority));return u!==l?u-l:t.localeCompare(o)})}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{HOOK_EVENTS as o}from"
|
|
1
|
+
import{HOOK_EVENTS as o}from"src/entrypoints/agentSdkTypes.js";import{logForDebugging as s}from"../debug.js";import{addSessionHook as e,removeSessionHook as r}from"./sessionHooks.js";export function registerSkillHooks(n,t,i,f,k){let m=0;for(const c of o){const o=i[c];if(o)for(const i of o)for(const o of i.hooks){const g=o.once?()=>{s(`Removing one-shot hook for event ${c} in skill '${f}'`),r(n,t,c,o)}:void 0;e(n,t,c,i.matcher||"",o,g,k),m++}}m>0&&s(`Registered ${m} hooks from skill '${f}'`)}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{HOOK_EVENTS as o}from"
|
|
1
|
+
import{HOOK_EVENTS as o}from"src/entrypoints/agentSdkTypes.js";import{logForDebugging as s}from"../debug.js";import{isHookEqual as e}from"./hooksSettings.js";export function addSessionHook(o,s,e,t,n,r,i){addHookToSession(o,s,e,t,n,r,i)}export function addFunctionHook(o,s,e,t,n,r,i){const k=i?.id||`function-hook-${Date.now()}-${Math.random()}`;return addHookToSession(o,s,e,t,{type:"function",id:k,timeout:i?.timeout||5e3,callback:n,errorMessage:r}),k}export function removeFunctionHook(o,e,t,n){o(o=>{const s=o.sessionHooks.get(e);if(!s)return o;const r=(s.hooks[t]||[]).map(o=>{const s=o.hooks.filter(o=>"function"!==o.hook.type||o.hook.id!==n);return s.length>0?{...o,hooks:s}:null}).filter(o=>null!==o),i=r.length>0?{...s.hooks,[t]:r}:Object.fromEntries(Object.entries(s.hooks).filter(([o])=>o!==t));return o.sessionHooks.set(e,{hooks:i}),o}),s(`Removed function hook ${n} for event ${t} in session ${e}`)}function addHookToSession(o,e,t,n,r,i,k){o(o=>{const s=o.sessionHooks.get(e)??{hooks:{}},c=s.hooks[t]||[],h=c.findIndex(o=>o.matcher===n&&o.skillRoot===k);let f;if(h>=0){f=[...c];const o=f[h];f[h]={matcher:o.matcher,skillRoot:o.skillRoot,hooks:[...o.hooks,{hook:r,onHookSuccess:i}]}}else f=[...c,{matcher:n,skillRoot:k,hooks:[{hook:r,onHookSuccess:i}]}];const l={...s.hooks,[t]:f};return o.sessionHooks.set(e,{hooks:l}),o}),s(`Added session hook for event ${t} in session ${e}`)}export function removeSessionHook(o,t,n,r){o(o=>{const s=o.sessionHooks.get(t);if(!s)return o;const i=(s.hooks[n]||[]).map(o=>{const s=o.hooks.filter(o=>!e(o.hook,r));return s.length>0?{...o,hooks:s}:null}).filter(o=>null!==o),k=i.length>0?{...s.hooks,[n]:i}:{...s.hooks};return 0===i.length&&delete k[n],o.sessionHooks.set(t,{...s,hooks:k}),o}),s(`Removed session hook for event ${n} in session ${t}`)}function convertToHookMatchers(o){return o.map(o=>({matcher:o.matcher,skillRoot:o.skillRoot,hooks:o.hooks.map(o=>o.hook).filter(o=>"function"!==o.type)}))}export function getSessionHooks(s,e,t){const n=s.sessionHooks.get(e);if(!n)return new Map;const r=new Map;if(t){const o=n.hooks[t];return o&&r.set(t,convertToHookMatchers(o)),r}for(const s of o){const o=n.hooks[s];o&&r.set(s,convertToHookMatchers(o))}return r}export function getSessionFunctionHooks(s,e,t){const n=s.sessionHooks.get(e);if(!n)return new Map;const r=new Map,extractFunctionHooks=o=>o.map(o=>({matcher:o.matcher,hooks:o.hooks.map(o=>o.hook).filter(o=>"function"===o.type)})).filter(o=>o.hooks.length>0);if(t){const o=n.hooks[t];if(o){const s=extractFunctionHooks(o);s.length>0&&r.set(t,s)}return r}for(const s of o){const o=n.hooks[s];if(o){const e=extractFunctionHooks(o);e.length>0&&r.set(s,e)}}return r}export function getSessionHookCallback(o,s,t,n,r){const i=o.sessionHooks.get(s);if(!i)return;const k=i.hooks[t];if(k)for(const o of k)if(o.matcher===n||""===n){const s=o.hooks.find(o=>e(o.hook,r));if(s)return s}}export function clearSessionHooks(o,e){o(o=>(o.sessionHooks.delete(e),o)),s(`Cleared all session hooks for session ${e}`)}
|
package/dist/src/utils/http.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{MACRO as e}from"../recovery/bunBundleShim.js";import t from"axios";import{OAUTH_BETA_HEADER as
|
|
1
|
+
import{MACRO as e}from"../recovery/bunBundleShim.js";import t from"axios";import{OAUTH_BETA_HEADER as r}from"../constants/oauth.js";import{getAnthropicApiKey as o,getClaudeAIOAuthTokens as s,handleOAuth401Error as n,isClaudeAISubscriber as a}from"./auth.js";import{getContextCodeUserAgent as c}from"./userAgent.js";import{getWorkload as A}from"./workloadContext.js";export function getUserAgent(){const t=process.env.CLAUDE_AGENT_SDK_VERSION?`, agent-sdk/${process.env.CLAUDE_AGENT_SDK_VERSION}`:"",r=process.env.CLAUDE_AGENT_SDK_CLIENT_APP?`, client-app/${process.env.CLAUDE_AGENT_SDK_CLIENT_APP}`:"",o=A(),s=o?`, workload/${o}`:"";return`claude-cli/${e.VERSION} (${process.env.USER_TYPE}, ${process.env.CLAUDE_CODE_ENTRYPOINT??"cli"}${t}${r}${s})`}export function getMCPUserAgent(){const t=[];process.env.CLAUDE_CODE_ENTRYPOINT&&t.push(process.env.CLAUDE_CODE_ENTRYPOINT),process.env.CLAUDE_AGENT_SDK_VERSION&&t.push(`agent-sdk/${process.env.CLAUDE_AGENT_SDK_VERSION}`),process.env.CLAUDE_AGENT_SDK_CLIENT_APP&&t.push(`client-app/${process.env.CLAUDE_AGENT_SDK_CLIENT_APP}`);const r=t.length>0?` (${t.join(", ")})`:"";return`claude-code/${e.VERSION}${r}`}export function getWebFetchUserAgent(){return`Context-User (${c()}; +https://support.contextcompany.com/)`}export function getAuthHeaders(){if(a()){const e=s();return e?.accessToken?{headers:{Authorization:`Bearer ${e.accessToken}`,"anthropic-beta":r}}:{headers:{},error:"No OAuth token available"}}const e=o();return e?{headers:{"x-api-key":e}}:{headers:{},error:"No API key available"}}export async function withOAuth401Retry(e,r){try{return await e()}catch(o){if(!t.isAxiosError(o))throw o;const a=o.response?.status;if(!(401===a||r?.also403Revoked&&403===a&&"string"==typeof o.response?.data&&o.response.data.includes("OAuth token has been revoked")))throw o;const c=s()?.accessToken;if(!c)throw o;return await n(c),await e()}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import r from"chalk";import{supportsHyperlinks as
|
|
1
|
+
import r from"chalk";import{supportsHyperlinks as p}from"../ink/supports-hyperlinks.js";export const OSC8_START="]8;;";export const OSC8_END="";export function createHyperlink(t,o,s){if(!(s?.supportsHyperlinks??p()))return t;const e=o??t;return`]8;;${t}${r.blue(e)}]8;;`}
|
package/dist/src/utils/ide.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{MACRO as e}from"../recovery/bunBundleShim.js";import{createRequire as o}from"module";const t=o(import.meta.url);import r from"axios";import{execa as n}from"execa";import s from"lodash-es/capitalize.js";import i from"lodash-es/memoize.js";import{createConnection as a}from"net";import*as c from"os";import{basename as d,join as l,sep as p,resolve as u}from"path";import{logEvent as f}from"../services/analytics/index.js";import{getIsScrollDraining as m,getOriginalCwd as w}from"../bootstrap/state.js";import{callIdeRpc as y}from"../services/mcp/client.js";import{getGlobalConfig as h,saveGlobalConfig as I}from"./config.js";import{env as x}from"./env.js";import{getClaudeConfigHomeDir as E,isEnvTruthy as C}from"./envUtils.js";import{execFileNoThrow as g,execFileNoThrowWithCwd as S,execSyncWithDefaults_DEPRECATED as K}from"./execFileNoThrow.js";import{getFsImplementation as D}from"./fsOperations.js";import{getAncestorPidsAsync as b}from"./genericProcessUtils.js";import{isJetBrainsPluginInstalledCached as v}from"./jetbrains.js";import{logError as L}from"./log.js";import{getPlatform as T}from"./platform.js";import{lt as _}from"./semver.js";const ideOnboardingDialog=()=>t("../components/IdeOnboardingDialog.js");import{createAbortController as N}from"./abortController.js";import{logForDebugging as j}from"./debug.js";import{envDynamic as W}from"./envDynamic.js";import{errorMessage as k,isFsInaccessible as A}from"./errors.js";import{checkWSLDistroMatch as O,WindowsToWSLConverter as P}from"./idePathConversion.js";import{sleep as R}from"./sleep.js";import{jsonParse as V}from"./slowOperations.js";function isProcessRunning(e){try{return process.kill(e,0),!0}catch{return!1}}const M={cursor:{ideKind:"vscode",displayName:"Cursor",processKeywordsMac:["Cursor Helper","Cursor.app"],processKeywordsWindows:["cursor.exe"],processKeywordsLinux:["cursor"]},windsurf:{ideKind:"vscode",displayName:"Windsurf",processKeywordsMac:["Windsurf Helper","Windsurf.app"],processKeywordsWindows:["windsurf.exe"],processKeywordsLinux:["windsurf"]},vscode:{ideKind:"vscode",displayName:"VS Code",processKeywordsMac:["Visual Studio Code","Code Helper"],processKeywordsWindows:["code.exe"],processKeywordsLinux:["code"]},intellij:{ideKind:"jetbrains",displayName:"IntelliJ IDEA",processKeywordsMac:["IntelliJ IDEA"],processKeywordsWindows:["idea64.exe"],processKeywordsLinux:["idea","intellij"]},pycharm:{ideKind:"jetbrains",displayName:"PyCharm",processKeywordsMac:["PyCharm"],processKeywordsWindows:["pycharm64.exe"],processKeywordsLinux:["pycharm"]},webstorm:{ideKind:"jetbrains",displayName:"WebStorm",processKeywordsMac:["WebStorm"],processKeywordsWindows:["webstorm64.exe"],processKeywordsLinux:["webstorm"]},phpstorm:{ideKind:"jetbrains",displayName:"PhpStorm",processKeywordsMac:["PhpStorm"],processKeywordsWindows:["phpstorm64.exe"],processKeywordsLinux:["phpstorm"]},rubymine:{ideKind:"jetbrains",displayName:"RubyMine",processKeywordsMac:["RubyMine"],processKeywordsWindows:["rubymine64.exe"],processKeywordsLinux:["rubymine"]},clion:{ideKind:"jetbrains",displayName:"CLion",processKeywordsMac:["CLion"],processKeywordsWindows:["clion64.exe"],processKeywordsLinux:["clion"]},goland:{ideKind:"jetbrains",displayName:"GoLand",processKeywordsMac:["GoLand"],processKeywordsWindows:["goland64.exe"],processKeywordsLinux:["goland"]},rider:{ideKind:"jetbrains",displayName:"Rider",processKeywordsMac:["Rider"],processKeywordsWindows:["rider64.exe"],processKeywordsLinux:["rider"]},datagrip:{ideKind:"jetbrains",displayName:"DataGrip",processKeywordsMac:["DataGrip"],processKeywordsWindows:["datagrip64.exe"],processKeywordsLinux:["datagrip"]},appcode:{ideKind:"jetbrains",displayName:"AppCode",processKeywordsMac:["AppCode"],processKeywordsWindows:["appcode.exe"],processKeywordsLinux:["appcode"]},dataspell:{ideKind:"jetbrains",displayName:"DataSpell",processKeywordsMac:["DataSpell"],processKeywordsWindows:["dataspell64.exe"],processKeywordsLinux:["dataspell"]},aqua:{ideKind:"jetbrains",displayName:"Aqua",processKeywordsMac:[],processKeywordsWindows:["aqua64.exe"],processKeywordsLinux:[]},gateway:{ideKind:"jetbrains",displayName:"Gateway",processKeywordsMac:[],processKeywordsWindows:["gateway64.exe"],processKeywordsLinux:[]},fleet:{ideKind:"jetbrains",displayName:"Fleet",processKeywordsMac:[],processKeywordsWindows:["fleet.exe"],processKeywordsLinux:[]},androidstudio:{ideKind:"jetbrains",displayName:"Android Studio",processKeywordsMac:["Android Studio"],processKeywordsWindows:["studio64.exe"],processKeywordsLinux:["android-studio"]}};export function isVSCodeIde(e){if(!e)return!1;const o=M[e];return o&&"vscode"===o.ideKind}export function isJetBrainsIde(e){if(!e)return!1;const o=M[e];return o&&"jetbrains"===o.ideKind}export const isSupportedVSCodeTerminal=i(()=>isVSCodeIde(x.terminal));export const isSupportedJetBrainsTerminal=i(()=>isJetBrainsIde(W.terminal));export const isSupportedTerminal=i(()=>isSupportedVSCodeTerminal()||isSupportedJetBrainsTerminal()||Boolean(process.env.FORCE_CODE_TERMINAL));export function getTerminalIdeType(){return isSupportedTerminal()?x.terminal:null}export async function getSortedIdeLockfiles(){try{const e=await getIdeLockfilesPaths();return(await Promise.all(e.map(async e=>{try{const o=(await D().readdir(e)).filter(e=>e.name.endsWith(".lock"));return(await Promise.all(o.map(async o=>{const t=l(e,o.name);try{return{path:t,mtime:(await D().stat(t)).mtime}}catch{return null}}))).filter(e=>null!==e)}catch(e){return A(e)||L(e),[]}}))).flat().sort((e,o)=>o.mtime.getTime()-e.mtime.getTime()).map(e=>e.path)}catch(e){return L(e),[]}}async function readIdeLockfile(e){try{const o=await D().readFile(e,{encoding:"utf-8"});let t,r,n,s=[],i=!1,a=!1;try{const e=V(o);e.workspaceFolders&&(s=e.workspaceFolders),t=e.pid,r=e.ideName,i="ws"===e.transport,a=!0===e.runningInWindows,n=e.authToken}catch(e){s=o.split("\n").map(e=>e.trim())}const c=e.split(p).pop();if(!c)return null;const d=c.replace(".lock","");return{workspaceFolders:s,port:parseInt(d),pid:t,ideName:r,useWebSocket:i,runningInWindows:a,authToken:n}}catch(e){return L(e),null}}async function checkIdeConnection(e,o,t=500){try{return new Promise(r=>{const n=a({host:e,port:o,timeout:t});n.on("connect",()=>{n.destroy(),r(!0)}),n.on("error",()=>{r(!1)}),n.on("timeout",()=>{n.destroy(),r(!1)})})}catch(e){return!1}}const $=i(async()=>{if(process.env.USERPROFILE)return process.env.USERPROFILE;const{stdout:e,code:o}=await g("powershell.exe",["-NoProfile","-NonInteractive","-Command","$env:USERPROFILE"]);if(0===o&&e.trim())return e.trim();j("Unable to get Windows USERPROFILE via PowerShell - IDE detection may be incomplete")});export async function getIdeLockfilesPaths(){const e=[l(E(),"ide")];if("wsl"!==T())return e;const o=await $();if(o){const t=new P(process.env.WSL_DISTRO_NAME).toLocalPath(o);e.push(u(t,".claude","ide"))}try{const o="/mnt/c/Users",t=await D().readdir(o);for(const r of t)(r.isDirectory()||r.isSymbolicLink())&&"Public"!==r.name&&"Default"!==r.name&&"Default User"!==r.name&&"All Users"!==r.name&&e.push(l(o,r.name,".claude","ide"))}catch(e){A(e)?j(`WSL IDE lockfile path detection failed (${e.code}): ${k(e)}`):L(e)}return e}export async function cleanupStaleIdeLockfiles(){try{const e=await getSortedIdeLockfiles();for(const o of e){const e=await readIdeLockfile(o);if(!e){try{await D().unlink(o)}catch(e){L(e)}continue}const t=await H(e.runningInWindows,e.port);let r=!1;if(e.pid){if(!isProcessRunning(e.pid))if("wsl"!==T())r=!0;else{await checkIdeConnection(t,e.port)||(r=!0)}}else{await checkIdeConnection(t,e.port)||(r=!0)}if(r)try{await D().unlink(o)}catch(e){L(e)}}}catch(e){L(e)}}export async function maybeInstallIDEExtension(e){try{const o=await async function(e){if(isVSCodeIde(e)){const o=await getVSCodeIDECommand(e);if(o){if("ant"===process.env.USER_TYPE)return await async function(e){const o=l(c.homedir(),".npmrc");let t=null;const n=D();try{const e=(await n.readFile(o,{encoding:"utf8"})).split("\n");for(const o of e){const e=o.match(/\/\/artifactory\.infra\.ant\.dev\/artifactory\/api\/npm\/npm-all\/:_authToken=(.+)/);if(e&&e[1]){t=e[1].trim();break}}}catch(e){throw L(e),new Error(`Failed to read npm authentication: ${e}`)}if(!t)throw new Error("No artifactory auth token found in ~/.npmrc");const s="https://artifactory.infra.ant.dev/artifactory/armorcode-claude-code-internal/claude-vscode-releases/stable";try{const o=(await r.get(s,{headers:{Authorization:`Bearer ${t}`}})).data.trim();if(!o)throw new Error("No version found in artifactory response");const i=`https://artifactory.infra.ant.dev/artifactory/armorcode-claude-code-internal/claude-vscode-releases/${o}/claude-code.vsix`,a=l(c.tmpdir(),`claude-code-${o}-${Date.now()}.vsix`);try{const n=await r.get(i,{headers:{Authorization:`Bearer ${t}`},responseType:"stream"}),s=D().createWriteStream(a);await new Promise((e,o)=>{n.data.pipe(s),s.on("finish",e),s.on("error",o)}),await R(500);const c=await S(e,["--force","--install-extension",a],{env:getInstallationEnv()});if(0!==c.code)throw new Error(`${c.code}: ${c.error} ${c.stderr}`);return o}finally{try{await n.unlink(a)}catch{}}}catch(e){if(r.isAxiosError(e))throw new Error(`Failed to fetch extension version from artifactory: ${e.message}`);throw e}}(o);let e=await async function(e){const{stdout:o}=await g(e,["--list-extensions","--show-versions"],{env:getInstallationEnv()}),t=o?.split("\n")||[];for(const e of t){const[o,t]=e.split("@");if("anthropic.claude-code"===o&&t)return t}return null}(o);if(!e||_(e,getClaudeCodeVersion())){await R(500);const t=await S(o,["--force","--install-extension","anthropic.claude-code"],{env:getInstallationEnv()});if(0!==t.code)throw new Error(`${t.code}: ${t.error} ${t.stderr}`);e=getClaudeCodeVersion()}return e}}return null}(e);f("tengu_ext_installed",{});return h().diffTool||I(e=>({...e,diffTool:"auto"})),{installed:!0,error:null,installedVersion:o,ideType:e}}catch(o){f("tengu_ext_install_error",{});const t=o instanceof Error?o.message:String(o);return L(o),{installed:!1,error:t,installedVersion:null,ideType:e}}}let F=null;export async function findAvailableIDE(){F&&F.abort(),F=N();const e=F.signal;await cleanupStaleIdeLockfiles();const o=Date.now();for(;Date.now()-o<3e4&&!e.aborted;){if(m()){await R(1e3,e);continue}const o=await detectIDEs(!1);if(e.aborted)return null;if(1===o.length)return o[0];await R(1e3,e)}return null}export async function detectIDEs(e){const o=[];try{const t=process.env.CONTEXT_CODE_SSE_PORT??process.env.CLAUDE_CODE_SSE_PORT,r=t?parseInt(t):null,n=w().normalize("NFC"),s=await getSortedIdeLockfiles(),i=await Promise.all(s.map(readIdeLockfile)),a=function(){let e=null;return()=>(e||(e=b(process.ppid,10).then(e=>new Set(e))),e)}(),c="wsl"!==T()&&isSupportedTerminal();for(const t of i){if(!t)continue;let s=!1;if(s=!(!C(process.env.CONTEXT_CODE_IDE_SKIP_VALID_CHECK)&&!C(process.env.CLAUDE_CODE_IDE_SKIP_VALID_CHECK))||(t.port===r||t.workspaceFolders.some(e=>{if(!e)return!1;let o=e;if("wsl"===T()&&t.runningInWindows&&process.env.WSL_DISTRO_NAME){if(!O(e,process.env.WSL_DISTRO_NAME))return!1;const t=u(o).normalize("NFC");if(n===t||n.startsWith(t+p))return!0;o=new P(process.env.WSL_DISTRO_NAME).toLocalPath(e)}const r=u(o).normalize("NFC");if("windows"===T()){const e=n.replace(/^[a-zA-Z]:/,e=>e.toUpperCase()),o=r.replace(/^[a-zA-Z]:/,e=>e.toUpperCase());return e===o||e.startsWith(o+p)}return n===r||n.startsWith(r+p)})),!s&&!e)continue;if(c){if(!(null!==r&&t.port===r)){if(!t.pid||!isProcessRunning(t.pid))continue;if(process.ppid!==t.pid){if(!(await a()).has(t.pid))continue}}}const i=t.ideName??(isSupportedTerminal()?toIDEDisplayName(W.terminal):"IDE"),d=await H(t.runningInWindows,t.port);let l;l=t.useWebSocket?`ws://${d}:${t.port}`:`http://${d}:${t.port}/sse`,o.push({url:l,name:i,workspaceFolders:t.workspaceFolders,port:t.port,isValid:s,authToken:t.authToken,ideRunningInWindows:t.runningInWindows})}if(!e&&r){const e=o.filter(e=>e.isValid&&e.port===r);if(1===e.length)return e}}catch(e){L(e)}return o}export async function maybeNotifyIDEConnected(e){await e.notification({method:"ide_connected",params:{pid:process.pid}})}export function hasAccessToIDEExtensionDiffFeature(e){return e.some(e=>"connected"===e.type&&"ide"===e.name)}const U="ant"===process.env.USER_TYPE?"anthropic.claude-code-internal":"anthropic.claude-code";export async function isIDEExtensionInstalled(e){if(isVSCodeIde(e)){const o=await getVSCodeIDECommand(e);if(o)try{const e=await S(o,["--list-extensions"],{env:getInstallationEnv()});if(e.stdout?.includes(U))return!0}catch{}}else if(isJetBrainsIde(e))return await v(e);return!1}function getInstallationEnv(){if("linux"===T())return{...process.env,DISPLAY:""}}function getClaudeCodeVersion(){return e.VERSION}async function getVSCodeIDECommand(e){const o=function(){try{if("macos"!==T())return null;let e=process.ppid;for(let o=0;o<10&&e&&0!==e&&1!==e;o++){const o=K(`ps -o command= -p ${e}`)?.trim();if(o){const e={"Visual Studio Code.app":"code","Cursor.app":"cursor","Windsurf.app":"windsurf","Visual Studio Code - Insiders.app":"code","VSCodium.app":"codium"},t="/Contents/MacOS/Electron";for(const[r,n]of Object.entries(e)){const e=o.indexOf(r+t);if(-1!==e){const t=e+r.length;return o.substring(0,t)+"/Contents/Resources/app/bin/"+n}}}const t=K(`ps -o ppid= -p ${e}`)?.trim();if(!t)break;e=parseInt(t.trim())}return null}catch{return null}}();if(o)try{return await D().stat(o),o}catch{}const t="windows"===T()?".cmd":"";let r=null;switch(e){case"vscode":r="code"+t;break;case"cursor":r="cursor"+t;break;case"windsurf":r="windsurf"+t}if(r&&"windows"===T()){const e=await async function(e){const o=process.env.LOCALAPPDATA,t=process.env.ProgramFiles,r=D(),n=[];e.includes("code")?(o&&n.push(l(o,"Programs","Microsoft VS Code","bin","code.cmd")),t&&n.push(l(t,"Microsoft VS Code","bin","code.cmd"))):e.includes("cursor")?o&&n.push(l(o,"Programs","Cursor","bin","cursor.cmd")):e.includes("windsurf")&&o&&n.push(l(o,"Programs","Windsurf","bin","windsurf.cmd"));for(const e of n)try{return await r.stat(e),e}catch{}return null}(r);if(e)return e}return r}export async function isCursorInstalled(){return 0===(await g("cursor",["--version"])).code}export async function isWindsurfInstalled(){return 0===(await g("windsurf",["--version"])).code}export async function isVSCodeInstalled(){const e=await g("code",["--help"]);return 0===e.code&&Boolean(e.stdout?.includes("Visual Studio Code"))}let B=null;export async function detectRunningIDEs(){const e=await async function(){const e=[];try{const o=T();if("macos"===o){const o=(await n('ps aux | grep -E "Visual Studio Code|Code Helper|Cursor Helper|Windsurf Helper|IntelliJ IDEA|PyCharm|WebStorm|PhpStorm|RubyMine|CLion|GoLand|Rider|DataGrip|AppCode|DataSpell|Aqua|Gateway|Fleet|Android Studio" | grep -v grep',{shell:!0,reject:!1})).stdout??"";for(const[t,r]of Object.entries(M))for(const n of r.processKeywordsMac)if(o.includes(n)){e.push(t);break}}else if("windows"===o){const o=((await n('tasklist | findstr /I "Code.exe Cursor.exe Windsurf.exe idea64.exe pycharm64.exe webstorm64.exe phpstorm64.exe rubymine64.exe clion64.exe goland64.exe rider64.exe datagrip64.exe appcode.exe dataspell64.exe aqua64.exe gateway64.exe fleet.exe studio64.exe"',{shell:!0,reject:!1})).stdout??"").toLowerCase();for(const[t,r]of Object.entries(M))for(const n of r.processKeywordsWindows)if(o.includes(n.toLowerCase())){e.push(t);break}}else if("linux"===o){const o=((await n('ps aux | grep -E "code|cursor|windsurf|idea|pycharm|webstorm|phpstorm|rubymine|clion|goland|rider|datagrip|dataspell|aqua|gateway|fleet|android-studio" | grep -v grep',{shell:!0,reject:!1})).stdout??"").toLowerCase();for(const[t,r]of Object.entries(M))for(const n of r.processKeywordsLinux)if(o.includes(n)){if("vscode"!==t){e.push(t);break}if(!o.includes("cursor")&&!o.includes("appcode")){e.push(t);break}}}}catch(e){L(e)}return e}();return B=e,e}export async function detectRunningIDEsCached(){return null===B?detectRunningIDEs():B}export function resetDetectRunningIDEs(){B=null}export function getConnectedIdeName(e){return getIdeClientName(e.find(e=>"connected"===e.type&&"ide"===e.name))}export function getIdeClientName(e){const o=e?.config;return"sse-ide"===o?.type||"ws-ide"===o?.type?o.ideName:isSupportedTerminal()?toIDEDisplayName(W.terminal):null}const z={code:"VS Code",cursor:"Cursor",windsurf:"Windsurf",antigravity:"Antigravity",vi:"Vim",vim:"Vim",nano:"nano",notepad:"Notepad","start /wait notepad":"Notepad",emacs:"Emacs",subl:"Sublime Text",atom:"Atom"};export function toIDEDisplayName(e){if(!e)return"IDE";const o=M[e];if(o)return o.displayName;const t=z[e.toLowerCase().trim()];if(t)return t;const r=e.split(" ")[0],n=r?d(r).toLowerCase():null;if(n){const e=z[n];return e||s(n)}return s(e)}export{y as callIdeRpc};export function getConnectedIdeClient(e){if(!e)return;const o=e.find(e=>"connected"===e.type&&"ide"===e.name);return"connected"===o?.type?o:void 0}export async function closeOpenDiffs(e){try{await y("closeAllDiffTabs",{},e)}catch(e){}}export async function initializeIdeIntegration(e,o,t,r){findAvailableIDE().then(e);const n=h().autoInstallIdeExtension??!0;if(!C(process.env.CONTEXT_CODE_IDE_SKIP_AUTO_INSTALL)&&!C(process.env.CLAUDE_CODE_IDE_SKIP_AUTO_INSTALL)&&n){const n=o??getTerminalIdeType();n&&(isVSCodeIde(n)?isIDEExtensionInstalled(n).then(async o=>{maybeInstallIDEExtension(n).catch(e=>({installed:!1,error:e.message||"Installation failed",installedVersion:null,ideType:n})).then(n=>{r(n),n?.installed&&findAvailableIDE().then(e),o||!0!==n?.installed||ideOnboardingDialog().hasIdeOnboardingDialogBeenShown()||t()})}):isJetBrainsIde(n)&&isIDEExtensionInstalled(n).then(async e=>{e&&!ideOnboardingDialog().hasIdeOnboardingDialogBeenShown()&&t()}))}}const H=i(async(e,o)=>{const t=process.env.CONTEXT_CODE_IDE_HOST_OVERRIDE??process.env.CLAUDE_CODE_IDE_HOST_OVERRIDE;if(t)return t;if("wsl"!==T()||!e)return"127.0.0.1";try{const e=await n("ip route show | grep -i default",{shell:!0,reject:!1});if(0===e.exitCode&&e.stdout){const t=e.stdout.match(/default via (\d+\.\d+\.\d+\.\d+)/);if(t){const e=t[1];if(await checkIdeConnection(e,o))return e}}}catch(e){}return"127.0.0.1"},(e,o)=>`${e}:${o}`);
|
|
1
|
+
import{MACRO as e}from"../recovery/bunBundleShim.js";import{createRequire as o}from"module";const r=o(import.meta.url);import t from"axios";import{execa as s}from"execa";import n from"lodash-es/capitalize.js";import i from"lodash-es/memoize.js";import{createConnection as a}from"net";import*as c from"os";import{basename as d,join as l,sep as p,resolve as u}from"path";import{logEvent as f}from"src/services/analytics/index.js";import{getIsScrollDraining as m,getOriginalCwd as w}from"../bootstrap/state.js";import{callIdeRpc as y}from"../services/mcp/client.js";import{getGlobalConfig as h,saveGlobalConfig as I}from"./config.js";import{env as x}from"./env.js";import{getClaudeConfigHomeDir as g,isEnvTruthy as C}from"./envUtils.js";import{execFileNoThrow as E,execFileNoThrowWithCwd as S,execSyncWithDefaults_DEPRECATED as D}from"./execFileNoThrow.js";import{getFsImplementation as b}from"./fsOperations.js";import{getAncestorPidsAsync as K}from"./genericProcessUtils.js";import{isJetBrainsPluginInstalledCached as v}from"./jetbrains.js";import{logError as L}from"./log.js";import{getPlatform as T}from"./platform.js";import{lt as W}from"./semver.js";const ideOnboardingDialog=()=>r("src/components/IdeOnboardingDialog.js");import{createAbortController as N}from"./abortController.js";import{logForDebugging as _}from"./debug.js";import{envDynamic as j}from"./envDynamic.js";import{errorMessage as A,isFsInaccessible as P}from"./errors.js";import{checkWSLDistroMatch as k,WindowsToWSLConverter as O}from"./idePathConversion.js";import{sleep as R}from"./sleep.js";import{jsonParse as V}from"./slowOperations.js";function isProcessRunning(e){try{return process.kill(e,0),!0}catch{return!1}}const M={cursor:{ideKind:"vscode",displayName:"Cursor",processKeywordsMac:["Cursor Helper","Cursor.app"],processKeywordsWindows:["cursor.exe"],processKeywordsLinux:["cursor"]},windsurf:{ideKind:"vscode",displayName:"Windsurf",processKeywordsMac:["Windsurf Helper","Windsurf.app"],processKeywordsWindows:["windsurf.exe"],processKeywordsLinux:["windsurf"]},vscode:{ideKind:"vscode",displayName:"VS Code",processKeywordsMac:["Visual Studio Code","Code Helper"],processKeywordsWindows:["code.exe"],processKeywordsLinux:["code"]},intellij:{ideKind:"jetbrains",displayName:"IntelliJ IDEA",processKeywordsMac:["IntelliJ IDEA"],processKeywordsWindows:["idea64.exe"],processKeywordsLinux:["idea","intellij"]},pycharm:{ideKind:"jetbrains",displayName:"PyCharm",processKeywordsMac:["PyCharm"],processKeywordsWindows:["pycharm64.exe"],processKeywordsLinux:["pycharm"]},webstorm:{ideKind:"jetbrains",displayName:"WebStorm",processKeywordsMac:["WebStorm"],processKeywordsWindows:["webstorm64.exe"],processKeywordsLinux:["webstorm"]},phpstorm:{ideKind:"jetbrains",displayName:"PhpStorm",processKeywordsMac:["PhpStorm"],processKeywordsWindows:["phpstorm64.exe"],processKeywordsLinux:["phpstorm"]},rubymine:{ideKind:"jetbrains",displayName:"RubyMine",processKeywordsMac:["RubyMine"],processKeywordsWindows:["rubymine64.exe"],processKeywordsLinux:["rubymine"]},clion:{ideKind:"jetbrains",displayName:"CLion",processKeywordsMac:["CLion"],processKeywordsWindows:["clion64.exe"],processKeywordsLinux:["clion"]},goland:{ideKind:"jetbrains",displayName:"GoLand",processKeywordsMac:["GoLand"],processKeywordsWindows:["goland64.exe"],processKeywordsLinux:["goland"]},rider:{ideKind:"jetbrains",displayName:"Rider",processKeywordsMac:["Rider"],processKeywordsWindows:["rider64.exe"],processKeywordsLinux:["rider"]},datagrip:{ideKind:"jetbrains",displayName:"DataGrip",processKeywordsMac:["DataGrip"],processKeywordsWindows:["datagrip64.exe"],processKeywordsLinux:["datagrip"]},appcode:{ideKind:"jetbrains",displayName:"AppCode",processKeywordsMac:["AppCode"],processKeywordsWindows:["appcode.exe"],processKeywordsLinux:["appcode"]},dataspell:{ideKind:"jetbrains",displayName:"DataSpell",processKeywordsMac:["DataSpell"],processKeywordsWindows:["dataspell64.exe"],processKeywordsLinux:["dataspell"]},aqua:{ideKind:"jetbrains",displayName:"Aqua",processKeywordsMac:[],processKeywordsWindows:["aqua64.exe"],processKeywordsLinux:[]},gateway:{ideKind:"jetbrains",displayName:"Gateway",processKeywordsMac:[],processKeywordsWindows:["gateway64.exe"],processKeywordsLinux:[]},fleet:{ideKind:"jetbrains",displayName:"Fleet",processKeywordsMac:[],processKeywordsWindows:["fleet.exe"],processKeywordsLinux:[]},androidstudio:{ideKind:"jetbrains",displayName:"Android Studio",processKeywordsMac:["Android Studio"],processKeywordsWindows:["studio64.exe"],processKeywordsLinux:["android-studio"]}};export function isVSCodeIde(e){if(!e)return!1;const o=M[e];return o&&"vscode"===o.ideKind}export function isJetBrainsIde(e){if(!e)return!1;const o=M[e];return o&&"jetbrains"===o.ideKind}export const isSupportedVSCodeTerminal=i(()=>isVSCodeIde(x.terminal));export const isSupportedJetBrainsTerminal=i(()=>isJetBrainsIde(j.terminal));export const isSupportedTerminal=i(()=>isSupportedVSCodeTerminal()||isSupportedJetBrainsTerminal()||Boolean(process.env.FORCE_CODE_TERMINAL));export function getTerminalIdeType(){return isSupportedTerminal()?x.terminal:null}export async function getSortedIdeLockfiles(){try{const e=await getIdeLockfilesPaths();return(await Promise.all(e.map(async e=>{try{const o=(await b().readdir(e)).filter(e=>e.name.endsWith(".lock"));return(await Promise.all(o.map(async o=>{const r=l(e,o.name);try{return{path:r,mtime:(await b().stat(r)).mtime}}catch{return null}}))).filter(e=>null!==e)}catch(e){return P(e)||L(e),[]}}))).flat().sort((e,o)=>o.mtime.getTime()-e.mtime.getTime()).map(e=>e.path)}catch(e){return L(e),[]}}async function readIdeLockfile(e){try{const o=await b().readFile(e,{encoding:"utf-8"});let r,t,s,n=[],i=!1,a=!1;try{const e=V(o);e.workspaceFolders&&(n=e.workspaceFolders),r=e.pid,t=e.ideName,i="ws"===e.transport,a=!0===e.runningInWindows,s=e.authToken}catch(e){n=o.split("\n").map(e=>e.trim())}const c=e.split(p).pop();if(!c)return null;const d=c.replace(".lock","");return{workspaceFolders:n,port:parseInt(d),pid:r,ideName:t,useWebSocket:i,runningInWindows:a,authToken:s}}catch(e){return L(e),null}}async function checkIdeConnection(e,o,r=500){try{return new Promise(t=>{const s=a({host:e,port:o,timeout:r});s.on("connect",()=>{s.destroy(),t(!0)}),s.on("error",()=>{t(!1)}),s.on("timeout",()=>{s.destroy(),t(!1)})})}catch(e){return!1}}const F=i(async()=>{if(process.env.USERPROFILE)return process.env.USERPROFILE;const{stdout:e,code:o}=await E("powershell.exe",["-NoProfile","-NonInteractive","-Command","$env:USERPROFILE"]);if(0===o&&e.trim())return e.trim();_("Unable to get Windows USERPROFILE via PowerShell - IDE detection may be incomplete")});export async function getIdeLockfilesPaths(){const e=[l(g(),"ide")];if("wsl"!==T())return e;const o=await F();if(o){const r=new O(process.env.WSL_DISTRO_NAME).toLocalPath(o);e.push(u(r,".claude","ide"))}try{const o="/mnt/c/Users",r=await b().readdir(o);for(const t of r)(t.isDirectory()||t.isSymbolicLink())&&"Public"!==t.name&&"Default"!==t.name&&"Default User"!==t.name&&"All Users"!==t.name&&e.push(l(o,t.name,".claude","ide"))}catch(e){P(e)?_(`WSL IDE lockfile path detection failed (${e.code}): ${A(e)}`):L(e)}return e}export async function cleanupStaleIdeLockfiles(){try{const e=await getSortedIdeLockfiles();for(const o of e){const e=await readIdeLockfile(o);if(!e){try{await b().unlink(o)}catch(e){L(e)}continue}const r=await z(e.runningInWindows,e.port);let t=!1;if(e.pid?isProcessRunning(e.pid)||("wsl"!==T()?t=!0:await checkIdeConnection(r,e.port)||(t=!0)):await checkIdeConnection(r,e.port)||(t=!0),t)try{await b().unlink(o)}catch(e){L(e)}}}catch(e){L(e)}}export async function maybeInstallIDEExtension(e){try{const o=await async function(e){if(isVSCodeIde(e)){const o=await getVSCodeIDECommand(e);if(o){if("ant"===process.env.USER_TYPE)return await async function(e){const o=l(c.homedir(),".npmrc");let r=null;const s=b();try{const e=(await s.readFile(o,{encoding:"utf8"})).split("\n");for(const o of e){const e=o.match(/\/\/artifactory\.infra\.ant\.dev\/artifactory\/api\/npm\/npm-all\/:_authToken=(.+)/);if(e&&e[1]){r=e[1].trim();break}}}catch(e){throw L(e),new Error(`Failed to read npm authentication: ${e}`)}if(!r)throw new Error("No artifactory auth token found in ~/.npmrc");try{const o=(await t.get("https://artifactory.infra.ant.dev/artifactory/armorcode-claude-code-internal/claude-vscode-releases/stable",{headers:{Authorization:`Bearer ${r}`}})).data.trim();if(!o)throw new Error("No version found in artifactory response");const n=`https://artifactory.infra.ant.dev/artifactory/armorcode-claude-code-internal/claude-vscode-releases/${o}/claude-code.vsix`,i=l(c.tmpdir(),`claude-code-${o}-${Date.now()}.vsix`);try{const s=await t.get(n,{headers:{Authorization:`Bearer ${r}`},responseType:"stream"}),a=b().createWriteStream(i);await new Promise((e,o)=>{s.data.pipe(a),a.on("finish",e),a.on("error",o)}),await R(500);const c=await S(e,["--force","--install-extension",i],{env:getInstallationEnv()});if(0!==c.code)throw new Error(`${c.code}: ${c.error} ${c.stderr}`);return o}finally{try{await s.unlink(i)}catch{}}}catch(e){if(t.isAxiosError(e))throw new Error(`Failed to fetch extension version from artifactory: ${e.message}`);throw e}}(o);let e=await async function(e){const{stdout:o}=await E(e,["--list-extensions","--show-versions"],{env:getInstallationEnv()}),r=o?.split("\n")||[];for(const e of r){const[o,r]=e.split("@");if("anthropic.claude-code"===o&&r)return r}return null}(o);if(!e||W(e,getClaudeCodeVersion())){await R(500);const r=await S(o,["--force","--install-extension","anthropic.claude-code"],{env:getInstallationEnv()});if(0!==r.code)throw new Error(`${r.code}: ${r.error} ${r.stderr}`);e=getClaudeCodeVersion()}return e}}return null}(e);return f("tengu_ext_installed",{}),h().diffTool||I(e=>({...e,diffTool:"auto"})),{installed:!0,error:null,installedVersion:o,ideType:e}}catch(o){f("tengu_ext_install_error",{});const r=o instanceof Error?o.message:String(o);return L(o),{installed:!1,error:r,installedVersion:null,ideType:e}}}let $=null;export async function findAvailableIDE(){$&&$.abort(),$=N();const e=$.signal;await cleanupStaleIdeLockfiles();const o=Date.now();for(;Date.now()-o<3e4&&!e.aborted;){if(m()){await R(1e3,e);continue}const o=await detectIDEs(!1);if(e.aborted)return null;if(1===o.length)return o[0];await R(1e3,e)}return null}export async function detectIDEs(e){const o=[];try{const r=process.env.CONTEXT_CODE_SSE_PORT??process.env.CLAUDE_CODE_SSE_PORT,t=r?parseInt(r):null,s=w().normalize("NFC"),n=await getSortedIdeLockfiles(),i=await Promise.all(n.map(readIdeLockfile)),a=function(){let e=null;return()=>(e||(e=K(process.ppid,10).then(e=>new Set(e))),e)}(),c="wsl"!==T()&&isSupportedTerminal();for(const r of i){if(!r)continue;let n=!1;if(n=!(!C(process.env.CONTEXT_CODE_IDE_SKIP_VALID_CHECK)&&!C(process.env.CLAUDE_CODE_IDE_SKIP_VALID_CHECK))||r.port===t||r.workspaceFolders.some(e=>{if(!e)return!1;let o=e;if("wsl"===T()&&r.runningInWindows&&process.env.WSL_DISTRO_NAME){if(!k(e,process.env.WSL_DISTRO_NAME))return!1;const r=u(o).normalize("NFC");if(s===r||s.startsWith(r+p))return!0;o=new O(process.env.WSL_DISTRO_NAME).toLocalPath(e)}const t=u(o).normalize("NFC");if("windows"===T()){const e=s.replace(/^[a-zA-Z]:/,e=>e.toUpperCase()),o=t.replace(/^[a-zA-Z]:/,e=>e.toUpperCase());return e===o||e.startsWith(o+p)}return s===t||s.startsWith(t+p)}),!n&&!e)continue;if(c&&(null===t||r.port!==t)){if(!r.pid||!isProcessRunning(r.pid))continue;if(process.ppid!==r.pid&&!(await a()).has(r.pid))continue}const i=r.ideName??(isSupportedTerminal()?toIDEDisplayName(j.terminal):"IDE"),d=await z(r.runningInWindows,r.port);let l;l=r.useWebSocket?`ws://${d}:${r.port}`:`http://${d}:${r.port}/sse`,o.push({url:l,name:i,workspaceFolders:r.workspaceFolders,port:r.port,isValid:n,authToken:r.authToken,ideRunningInWindows:r.runningInWindows})}if(!e&&t){const e=o.filter(e=>e.isValid&&e.port===t);if(1===e.length)return e}}catch(e){L(e)}return o}export async function maybeNotifyIDEConnected(e){await e.notification({method:"ide_connected",params:{pid:process.pid}})}export function hasAccessToIDEExtensionDiffFeature(e){return e.some(e=>"connected"===e.type&&"ide"===e.name)}const U="ant"===process.env.USER_TYPE?"anthropic.claude-code-internal":"anthropic.claude-code";export async function isIDEExtensionInstalled(e){if(isVSCodeIde(e)){const o=await getVSCodeIDECommand(e);if(o)try{const e=await S(o,["--list-extensions"],{env:getInstallationEnv()});if(e.stdout?.includes(U))return!0}catch{}}else if(isJetBrainsIde(e))return await v(e);return!1}function getInstallationEnv(){if("linux"===T())return{...process.env,DISPLAY:""}}function getClaudeCodeVersion(){return e.VERSION}async function getVSCodeIDECommand(e){const o=function(){try{if("macos"!==T())return null;let e=process.ppid;for(let o=0;o<10&&e&&0!==e&&1!==e;o++){const o=D(`ps -o command= -p ${e}`)?.trim();if(o){const e={"Visual Studio Code.app":"code","Cursor.app":"cursor","Windsurf.app":"windsurf","Visual Studio Code - Insiders.app":"code","VSCodium.app":"codium"},r="/Contents/MacOS/Electron";for(const[t,s]of Object.entries(e)){const e=o.indexOf(t+r);if(-1!==e){const r=e+t.length;return o.substring(0,r)+"/Contents/Resources/app/bin/"+s}}}const r=D(`ps -o ppid= -p ${e}`)?.trim();if(!r)break;e=parseInt(r.trim())}return null}catch{return null}}();if(o)try{return await b().stat(o),o}catch{}const r="windows"===T()?".cmd":"";let t=null;switch(e){case"vscode":t="code"+r;break;case"cursor":t="cursor"+r;break;case"windsurf":t="windsurf"+r}if(t&&"windows"===T()){const e=await async function(e){const o=process.env.LOCALAPPDATA,r=process.env.ProgramFiles,t=b(),s=[];e.includes("code")?(o&&s.push(l(o,"Programs","Microsoft VS Code","bin","code.cmd")),r&&s.push(l(r,"Microsoft VS Code","bin","code.cmd"))):e.includes("cursor")?o&&s.push(l(o,"Programs","Cursor","bin","cursor.cmd")):e.includes("windsurf")&&o&&s.push(l(o,"Programs","Windsurf","bin","windsurf.cmd"));for(const e of s)try{return await t.stat(e),e}catch{}return null}(t);if(e)return e}return t}export async function isCursorInstalled(){return 0===(await E("cursor",["--version"])).code}export async function isWindsurfInstalled(){return 0===(await E("windsurf",["--version"])).code}export async function isVSCodeInstalled(){const e=await E("code",["--help"]);return 0===e.code&&Boolean(e.stdout?.includes("Visual Studio Code"))}let B=null;export async function detectRunningIDEs(){const e=await async function(){const e=[];try{const o=T();if("macos"===o){const o=(await s('ps aux | grep -E "Visual Studio Code|Code Helper|Cursor Helper|Windsurf Helper|IntelliJ IDEA|PyCharm|WebStorm|PhpStorm|RubyMine|CLion|GoLand|Rider|DataGrip|AppCode|DataSpell|Aqua|Gateway|Fleet|Android Studio" | grep -v grep',{shell:!0,reject:!1})).stdout??"";for(const[r,t]of Object.entries(M))for(const s of t.processKeywordsMac)if(o.includes(s)){e.push(r);break}}else if("windows"===o){const o=((await s('tasklist | findstr /I "Code.exe Cursor.exe Windsurf.exe idea64.exe pycharm64.exe webstorm64.exe phpstorm64.exe rubymine64.exe clion64.exe goland64.exe rider64.exe datagrip64.exe appcode.exe dataspell64.exe aqua64.exe gateway64.exe fleet.exe studio64.exe"',{shell:!0,reject:!1})).stdout??"").toLowerCase();for(const[r,t]of Object.entries(M))for(const s of t.processKeywordsWindows)if(o.includes(s.toLowerCase())){e.push(r);break}}else if("linux"===o){const o=((await s('ps aux | grep -E "code|cursor|windsurf|idea|pycharm|webstorm|phpstorm|rubymine|clion|goland|rider|datagrip|dataspell|aqua|gateway|fleet|android-studio" | grep -v grep',{shell:!0,reject:!1})).stdout??"").toLowerCase();for(const[r,t]of Object.entries(M))for(const s of t.processKeywordsLinux)if(o.includes(s)){if("vscode"!==r){e.push(r);break}if(!o.includes("cursor")&&!o.includes("appcode")){e.push(r);break}}}}catch(e){L(e)}return e}();return B=e,e}export async function detectRunningIDEsCached(){return null===B?detectRunningIDEs():B}export function resetDetectRunningIDEs(){B=null}export function getConnectedIdeName(e){return getIdeClientName(e.find(e=>"connected"===e.type&&"ide"===e.name))}export function getIdeClientName(e){const o=e?.config;return"sse-ide"===o?.type||"ws-ide"===o?.type?o.ideName:isSupportedTerminal()?toIDEDisplayName(j.terminal):null}const H={code:"VS Code",cursor:"Cursor",windsurf:"Windsurf",antigravity:"Antigravity",vi:"Vim",vim:"Vim",nano:"nano",notepad:"Notepad","start /wait notepad":"Notepad",emacs:"Emacs",subl:"Sublime Text",atom:"Atom"};export function toIDEDisplayName(e){if(!e)return"IDE";const o=M[e];if(o)return o.displayName;const r=H[e.toLowerCase().trim()];if(r)return r;const t=e.split(" ")[0],s=t?d(t).toLowerCase():null;if(s){return H[s]||n(s)}return n(e)}export{y as callIdeRpc};export function getConnectedIdeClient(e){if(!e)return;const o=e.find(e=>"connected"===e.type&&"ide"===e.name);return"connected"===o?.type?o:void 0}export async function closeOpenDiffs(e){try{await y("closeAllDiffTabs",{},e)}catch(e){}}export async function initializeIdeIntegration(e,o,r,t){findAvailableIDE().then(e);const s=h().autoInstallIdeExtension??!0;if(!C(process.env.CONTEXT_CODE_IDE_SKIP_AUTO_INSTALL)&&!C(process.env.CLAUDE_CODE_IDE_SKIP_AUTO_INSTALL)&&s){const s=o??getTerminalIdeType();s&&(isVSCodeIde(s)?isIDEExtensionInstalled(s).then(async o=>{maybeInstallIDEExtension(s).catch(e=>({installed:!1,error:e.message||"Installation failed",installedVersion:null,ideType:s})).then(s=>{t(s),s?.installed&&findAvailableIDE().then(e),o||!0!==s?.installed||ideOnboardingDialog().hasIdeOnboardingDialogBeenShown()||r()})}):isJetBrainsIde(s)&&isIDEExtensionInstalled(s).then(async e=>{e&&!ideOnboardingDialog().hasIdeOnboardingDialogBeenShown()&&r()}))}}const z=i(async(e,o)=>{const r=process.env.CONTEXT_CODE_IDE_HOST_OVERRIDE??process.env.CLAUDE_CODE_IDE_HOST_OVERRIDE;if(r)return r;if("wsl"!==T()||!e)return"127.0.0.1";try{const e=await s("ip route show | grep -i default",{shell:!0,reject:!1});if(0===e.exitCode&&e.stdout){const r=e.stdout.match(/default via (\d+\.\d+\.\d+\.\d+)/);if(r){const e=r[1];if(await checkIdeConnection(e,o))return e}}}catch(e){}return"127.0.0.1"},(e,o)=>`${e}:${o}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{execFileSync as t}from"child_process";export class WindowsToWSLConverter{wslDistroName;constructor(t){this.wslDistroName=t}toLocalPath(r){if(!r)return r;if(this.wslDistroName){const t=r.match(/^\\\\wsl(?:\.localhost|\$)\\([^\\]+)(.*)$/);if(t&&t[1]!==this.wslDistroName)return r}try{return t("wslpath",["-u",r],{encoding:"utf8",stdio:["pipe","pipe","ignore"]}).trim()}catch{return r.replace(/\\/g,"/").replace(/^([A-Z]):/i,(t,r)=>`/mnt/${r.toLowerCase()}`)}}toIDEPath(r){if(!r)return r;try{return t("wslpath",["-w",r],{encoding:"utf8",stdio:["pipe","pipe","ignore"]}).trim()}catch{return r}}}export function checkWSLDistroMatch(t,r){const
|
|
1
|
+
import{execFileSync as t}from"child_process";export class WindowsToWSLConverter{wslDistroName;constructor(t){this.wslDistroName=t}toLocalPath(r){if(!r)return r;if(this.wslDistroName){const t=r.match(/^\\\\wsl(?:\.localhost|\$)\\([^\\]+)(.*)$/);if(t&&t[1]!==this.wslDistroName)return r}try{return t("wslpath",["-u",r],{encoding:"utf8",stdio:["pipe","pipe","ignore"]}).trim()}catch{return r.replace(/\\/g,"/").replace(/^([A-Z]):/i,(t,r)=>`/mnt/${r.toLowerCase()}`)}}toIDEPath(r){if(!r)return r;try{return t("wslpath",["-w",r],{encoding:"utf8",stdio:["pipe","pipe","ignore"]}).trim()}catch{return r}}}export function checkWSLDistroMatch(t,r){const e=t.match(/^\\\\wsl(?:\.localhost|\$)\\([^\\]+)(.*)$/);return!e||e[1]===r}
|