@shareai-lab/kode 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +426 -0
- package/README.zh-CN.md +326 -0
- package/cli.js +79 -0
- package/package.json +119 -0
- package/scripts/postinstall.js +18 -0
- package/src/ProjectOnboarding.tsx +198 -0
- package/src/Tool.ts +82 -0
- package/src/commands/agents.tsx +3410 -0
- package/src/commands/approvedTools.ts +53 -0
- package/src/commands/bug.tsx +20 -0
- package/src/commands/clear.ts +43 -0
- package/src/commands/compact.ts +120 -0
- package/src/commands/config.tsx +19 -0
- package/src/commands/cost.ts +18 -0
- package/src/commands/ctx_viz.ts +209 -0
- package/src/commands/doctor.ts +24 -0
- package/src/commands/help.tsx +19 -0
- package/src/commands/init.ts +37 -0
- package/src/commands/listen.ts +42 -0
- package/src/commands/login.tsx +51 -0
- package/src/commands/logout.tsx +40 -0
- package/src/commands/mcp.ts +41 -0
- package/src/commands/model.tsx +40 -0
- package/src/commands/modelstatus.tsx +20 -0
- package/src/commands/onboarding.tsx +34 -0
- package/src/commands/pr_comments.ts +59 -0
- package/src/commands/refreshCommands.ts +54 -0
- package/src/commands/release-notes.ts +34 -0
- package/src/commands/resume.tsx +31 -0
- package/src/commands/review.ts +49 -0
- package/src/commands/terminalSetup.ts +221 -0
- package/src/commands.ts +139 -0
- package/src/components/ApproveApiKey.tsx +93 -0
- package/src/components/AsciiLogo.tsx +13 -0
- package/src/components/AutoUpdater.tsx +148 -0
- package/src/components/Bug.tsx +367 -0
- package/src/components/Config.tsx +293 -0
- package/src/components/ConsoleOAuthFlow.tsx +327 -0
- package/src/components/Cost.tsx +23 -0
- package/src/components/CostThresholdDialog.tsx +46 -0
- package/src/components/CustomSelect/option-map.ts +42 -0
- package/src/components/CustomSelect/select-option.tsx +78 -0
- package/src/components/CustomSelect/select.tsx +152 -0
- package/src/components/CustomSelect/theme.ts +45 -0
- package/src/components/CustomSelect/use-select-state.ts +414 -0
- package/src/components/CustomSelect/use-select.ts +35 -0
- package/src/components/FallbackToolUseRejectedMessage.tsx +15 -0
- package/src/components/FileEditToolUpdatedMessage.tsx +66 -0
- package/src/components/Help.tsx +215 -0
- package/src/components/HighlightedCode.tsx +33 -0
- package/src/components/InvalidConfigDialog.tsx +113 -0
- package/src/components/Link.tsx +32 -0
- package/src/components/LogSelector.tsx +86 -0
- package/src/components/Logo.tsx +170 -0
- package/src/components/MCPServerApprovalDialog.tsx +100 -0
- package/src/components/MCPServerDialogCopy.tsx +25 -0
- package/src/components/MCPServerMultiselectDialog.tsx +109 -0
- package/src/components/Message.tsx +221 -0
- package/src/components/MessageResponse.tsx +15 -0
- package/src/components/MessageSelector.tsx +211 -0
- package/src/components/ModeIndicator.tsx +88 -0
- package/src/components/ModelConfig.tsx +301 -0
- package/src/components/ModelListManager.tsx +227 -0
- package/src/components/ModelSelector.tsx +3387 -0
- package/src/components/ModelStatusDisplay.tsx +230 -0
- package/src/components/Onboarding.tsx +274 -0
- package/src/components/PressEnterToContinue.tsx +11 -0
- package/src/components/PromptInput.tsx +760 -0
- package/src/components/SentryErrorBoundary.ts +39 -0
- package/src/components/Spinner.tsx +129 -0
- package/src/components/StickerRequestForm.tsx +16 -0
- package/src/components/StructuredDiff.tsx +191 -0
- package/src/components/TextInput.tsx +259 -0
- package/src/components/TodoItem.tsx +47 -0
- package/src/components/TokenWarning.tsx +31 -0
- package/src/components/ToolUseLoader.tsx +40 -0
- package/src/components/TrustDialog.tsx +106 -0
- package/src/components/binary-feedback/BinaryFeedback.tsx +63 -0
- package/src/components/binary-feedback/BinaryFeedbackOption.tsx +111 -0
- package/src/components/binary-feedback/BinaryFeedbackView.tsx +172 -0
- package/src/components/binary-feedback/utils.ts +220 -0
- package/src/components/messages/AssistantBashOutputMessage.tsx +22 -0
- package/src/components/messages/AssistantLocalCommandOutputMessage.tsx +49 -0
- package/src/components/messages/AssistantRedactedThinkingMessage.tsx +19 -0
- package/src/components/messages/AssistantTextMessage.tsx +144 -0
- package/src/components/messages/AssistantThinkingMessage.tsx +40 -0
- package/src/components/messages/AssistantToolUseMessage.tsx +133 -0
- package/src/components/messages/TaskProgressMessage.tsx +32 -0
- package/src/components/messages/TaskToolMessage.tsx +58 -0
- package/src/components/messages/UserBashInputMessage.tsx +28 -0
- package/src/components/messages/UserCommandMessage.tsx +30 -0
- package/src/components/messages/UserKodingInputMessage.tsx +28 -0
- package/src/components/messages/UserPromptMessage.tsx +35 -0
- package/src/components/messages/UserTextMessage.tsx +39 -0
- package/src/components/messages/UserToolResultMessage/UserToolCanceledMessage.tsx +12 -0
- package/src/components/messages/UserToolResultMessage/UserToolErrorMessage.tsx +36 -0
- package/src/components/messages/UserToolResultMessage/UserToolRejectMessage.tsx +31 -0
- package/src/components/messages/UserToolResultMessage/UserToolResultMessage.tsx +57 -0
- package/src/components/messages/UserToolResultMessage/UserToolSuccessMessage.tsx +35 -0
- package/src/components/messages/UserToolResultMessage/utils.tsx +56 -0
- package/src/components/permissions/BashPermissionRequest/BashPermissionRequest.tsx +121 -0
- package/src/components/permissions/FallbackPermissionRequest.tsx +153 -0
- package/src/components/permissions/FileEditPermissionRequest/FileEditPermissionRequest.tsx +182 -0
- package/src/components/permissions/FileEditPermissionRequest/FileEditToolDiff.tsx +77 -0
- package/src/components/permissions/FileWritePermissionRequest/FileWritePermissionRequest.tsx +164 -0
- package/src/components/permissions/FileWritePermissionRequest/FileWriteToolDiff.tsx +83 -0
- package/src/components/permissions/FilesystemPermissionRequest/FilesystemPermissionRequest.tsx +240 -0
- package/src/components/permissions/PermissionRequest.tsx +101 -0
- package/src/components/permissions/PermissionRequestTitle.tsx +69 -0
- package/src/components/permissions/hooks.ts +44 -0
- package/src/components/permissions/toolUseOptions.ts +59 -0
- package/src/components/permissions/utils.ts +23 -0
- package/src/constants/betas.ts +5 -0
- package/src/constants/claude-asterisk-ascii-art.tsx +238 -0
- package/src/constants/figures.ts +4 -0
- package/src/constants/keys.ts +3 -0
- package/src/constants/macros.ts +8 -0
- package/src/constants/modelCapabilities.ts +179 -0
- package/src/constants/models.ts +1025 -0
- package/src/constants/oauth.ts +18 -0
- package/src/constants/product.ts +17 -0
- package/src/constants/prompts.ts +168 -0
- package/src/constants/releaseNotes.ts +7 -0
- package/src/context/PermissionContext.tsx +149 -0
- package/src/context.ts +278 -0
- package/src/cost-tracker.ts +84 -0
- package/src/entrypoints/cli.tsx +1542 -0
- package/src/entrypoints/mcp.ts +176 -0
- package/src/history.ts +25 -0
- package/src/hooks/useApiKeyVerification.ts +59 -0
- package/src/hooks/useArrowKeyHistory.ts +55 -0
- package/src/hooks/useCanUseTool.ts +138 -0
- package/src/hooks/useCancelRequest.ts +39 -0
- package/src/hooks/useDoublePress.ts +42 -0
- package/src/hooks/useExitOnCtrlCD.ts +31 -0
- package/src/hooks/useInterval.ts +25 -0
- package/src/hooks/useLogMessages.ts +16 -0
- package/src/hooks/useLogStartupTime.ts +12 -0
- package/src/hooks/useNotifyAfterTimeout.ts +65 -0
- package/src/hooks/usePermissionRequestLogging.ts +44 -0
- package/src/hooks/useTerminalSize.ts +49 -0
- package/src/hooks/useTextInput.ts +318 -0
- package/src/hooks/useUnifiedCompletion.ts +1405 -0
- package/src/messages.ts +38 -0
- package/src/permissions.ts +268 -0
- package/src/query.ts +715 -0
- package/src/screens/ConfigureNpmPrefix.tsx +197 -0
- package/src/screens/Doctor.tsx +219 -0
- package/src/screens/LogList.tsx +68 -0
- package/src/screens/REPL.tsx +809 -0
- package/src/screens/ResumeConversation.tsx +68 -0
- package/src/services/adapters/base.ts +38 -0
- package/src/services/adapters/chatCompletions.ts +90 -0
- package/src/services/adapters/responsesAPI.ts +170 -0
- package/src/services/browserMocks.ts +66 -0
- package/src/services/claude.ts +2197 -0
- package/src/services/customCommands.ts +704 -0
- package/src/services/fileFreshness.ts +377 -0
- package/src/services/gpt5ConnectionTest.ts +340 -0
- package/src/services/mcpClient.ts +564 -0
- package/src/services/mcpServerApproval.tsx +50 -0
- package/src/services/mentionProcessor.ts +273 -0
- package/src/services/modelAdapterFactory.ts +69 -0
- package/src/services/notifier.ts +40 -0
- package/src/services/oauth.ts +357 -0
- package/src/services/openai.ts +1338 -0
- package/src/services/responseStateManager.ts +90 -0
- package/src/services/sentry.ts +3 -0
- package/src/services/statsig.ts +172 -0
- package/src/services/statsigStorage.ts +86 -0
- package/src/services/systemReminder.ts +507 -0
- package/src/services/vcr.ts +161 -0
- package/src/test/testAdapters.ts +96 -0
- package/src/tools/ArchitectTool/ArchitectTool.tsx +122 -0
- package/src/tools/ArchitectTool/prompt.ts +15 -0
- package/src/tools/AskExpertModelTool/AskExpertModelTool.tsx +569 -0
- package/src/tools/BashTool/BashTool.tsx +243 -0
- package/src/tools/BashTool/BashToolResultMessage.tsx +38 -0
- package/src/tools/BashTool/OutputLine.tsx +49 -0
- package/src/tools/BashTool/prompt.ts +174 -0
- package/src/tools/BashTool/utils.ts +56 -0
- package/src/tools/FileEditTool/FileEditTool.tsx +315 -0
- package/src/tools/FileEditTool/prompt.ts +51 -0
- package/src/tools/FileEditTool/utils.ts +58 -0
- package/src/tools/FileReadTool/FileReadTool.tsx +404 -0
- package/src/tools/FileReadTool/prompt.ts +7 -0
- package/src/tools/FileWriteTool/FileWriteTool.tsx +297 -0
- package/src/tools/FileWriteTool/prompt.ts +10 -0
- package/src/tools/GlobTool/GlobTool.tsx +119 -0
- package/src/tools/GlobTool/prompt.ts +8 -0
- package/src/tools/GrepTool/GrepTool.tsx +147 -0
- package/src/tools/GrepTool/prompt.ts +11 -0
- package/src/tools/MCPTool/MCPTool.tsx +107 -0
- package/src/tools/MCPTool/prompt.ts +3 -0
- package/src/tools/MemoryReadTool/MemoryReadTool.tsx +127 -0
- package/src/tools/MemoryReadTool/prompt.ts +3 -0
- package/src/tools/MemoryWriteTool/MemoryWriteTool.tsx +89 -0
- package/src/tools/MemoryWriteTool/prompt.ts +3 -0
- package/src/tools/MultiEditTool/MultiEditTool.tsx +366 -0
- package/src/tools/MultiEditTool/prompt.ts +45 -0
- package/src/tools/NotebookEditTool/NotebookEditTool.tsx +298 -0
- package/src/tools/NotebookEditTool/prompt.ts +3 -0
- package/src/tools/NotebookReadTool/NotebookReadTool.tsx +258 -0
- package/src/tools/NotebookReadTool/prompt.ts +3 -0
- package/src/tools/StickerRequestTool/StickerRequestTool.tsx +93 -0
- package/src/tools/StickerRequestTool/prompt.ts +19 -0
- package/src/tools/TaskTool/TaskTool.tsx +466 -0
- package/src/tools/TaskTool/constants.ts +1 -0
- package/src/tools/TaskTool/prompt.ts +92 -0
- package/src/tools/ThinkTool/ThinkTool.tsx +54 -0
- package/src/tools/ThinkTool/prompt.ts +12 -0
- package/src/tools/TodoWriteTool/TodoWriteTool.tsx +313 -0
- package/src/tools/TodoWriteTool/prompt.ts +63 -0
- package/src/tools/URLFetcherTool/URLFetcherTool.tsx +178 -0
- package/src/tools/URLFetcherTool/cache.ts +55 -0
- package/src/tools/URLFetcherTool/htmlToMarkdown.ts +55 -0
- package/src/tools/URLFetcherTool/prompt.ts +17 -0
- package/src/tools/WebSearchTool/WebSearchTool.tsx +103 -0
- package/src/tools/WebSearchTool/prompt.ts +13 -0
- package/src/tools/WebSearchTool/searchProviders.ts +66 -0
- package/src/tools/lsTool/lsTool.tsx +272 -0
- package/src/tools/lsTool/prompt.ts +2 -0
- package/src/tools.ts +67 -0
- package/src/types/PermissionMode.ts +120 -0
- package/src/types/RequestContext.ts +72 -0
- package/src/types/conversation.ts +51 -0
- package/src/types/logs.ts +58 -0
- package/src/types/modelCapabilities.ts +64 -0
- package/src/types/notebook.ts +87 -0
- package/src/utils/Cursor.ts +436 -0
- package/src/utils/PersistentShell.ts +552 -0
- package/src/utils/advancedFuzzyMatcher.ts +290 -0
- package/src/utils/agentLoader.ts +278 -0
- package/src/utils/agentStorage.ts +97 -0
- package/src/utils/array.ts +3 -0
- package/src/utils/ask.tsx +99 -0
- package/src/utils/auth.ts +13 -0
- package/src/utils/autoCompactCore.ts +223 -0
- package/src/utils/autoUpdater.ts +458 -0
- package/src/utils/betas.ts +20 -0
- package/src/utils/browser.ts +14 -0
- package/src/utils/cleanup.ts +72 -0
- package/src/utils/commands.ts +261 -0
- package/src/utils/commonUnixCommands.ts +161 -0
- package/src/utils/config.ts +945 -0
- package/src/utils/conversationRecovery.ts +55 -0
- package/src/utils/debugLogger.ts +1235 -0
- package/src/utils/diff.ts +42 -0
- package/src/utils/env.ts +57 -0
- package/src/utils/errors.ts +21 -0
- package/src/utils/exampleCommands.ts +109 -0
- package/src/utils/execFileNoThrow.ts +51 -0
- package/src/utils/expertChatStorage.ts +136 -0
- package/src/utils/file.ts +405 -0
- package/src/utils/fileRecoveryCore.ts +71 -0
- package/src/utils/format.tsx +44 -0
- package/src/utils/fuzzyMatcher.ts +328 -0
- package/src/utils/generators.ts +62 -0
- package/src/utils/git.ts +92 -0
- package/src/utils/globalLogger.ts +77 -0
- package/src/utils/http.ts +10 -0
- package/src/utils/imagePaste.ts +38 -0
- package/src/utils/json.ts +13 -0
- package/src/utils/log.ts +382 -0
- package/src/utils/markdown.ts +213 -0
- package/src/utils/messageContextManager.ts +289 -0
- package/src/utils/messages.tsx +939 -0
- package/src/utils/model.ts +914 -0
- package/src/utils/permissions/filesystem.ts +127 -0
- package/src/utils/responseState.ts +23 -0
- package/src/utils/ripgrep.ts +167 -0
- package/src/utils/secureFile.ts +564 -0
- package/src/utils/sessionState.ts +49 -0
- package/src/utils/state.ts +25 -0
- package/src/utils/style.ts +29 -0
- package/src/utils/terminal.ts +50 -0
- package/src/utils/theme.ts +127 -0
- package/src/utils/thinking.ts +144 -0
- package/src/utils/todoStorage.ts +431 -0
- package/src/utils/tokens.ts +43 -0
- package/src/utils/toolExecutionController.ts +163 -0
- package/src/utils/unaryLogging.ts +26 -0
- package/src/utils/user.ts +37 -0
- package/src/utils/validate.ts +165 -0
- package/yoga.wasm +0 -0
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { Text, Box } from 'ink'
|
|
3
|
+
import { getModelManager } from '../utils/model'
|
|
4
|
+
import { getGlobalConfig } from '../utils/config'
|
|
5
|
+
import { useExitOnCtrlCD } from '../hooks/useExitOnCtrlCD'
|
|
6
|
+
import { getTheme } from '../utils/theme'
|
|
7
|
+
|
|
8
|
+
type Props = {
|
|
9
|
+
onClose: () => void
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function ModelStatusDisplay({ onClose }: Props): React.ReactNode {
|
|
13
|
+
const theme = getTheme()
|
|
14
|
+
const exitState = useExitOnCtrlCD(onClose)
|
|
15
|
+
|
|
16
|
+
try {
|
|
17
|
+
const modelManager = getModelManager()
|
|
18
|
+
const config = getGlobalConfig()
|
|
19
|
+
|
|
20
|
+
// 显示所有模型指针的当前状态
|
|
21
|
+
const pointers = ['main', 'task', 'reasoning', 'quick'] as const
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<Box
|
|
25
|
+
flexDirection="column"
|
|
26
|
+
borderStyle="round"
|
|
27
|
+
borderColor={theme.secondaryBorder}
|
|
28
|
+
paddingX={2}
|
|
29
|
+
paddingY={1}
|
|
30
|
+
>
|
|
31
|
+
<Text bold>
|
|
32
|
+
📊 Current Model Status{' '}
|
|
33
|
+
{exitState.pending
|
|
34
|
+
? `(press ${exitState.keyName} again to exit)`
|
|
35
|
+
: ''}
|
|
36
|
+
</Text>
|
|
37
|
+
<Text> </Text>
|
|
38
|
+
|
|
39
|
+
{pointers.map(pointer => {
|
|
40
|
+
try {
|
|
41
|
+
const model = modelManager.getModel(pointer)
|
|
42
|
+
if (model && model.name && model.provider) {
|
|
43
|
+
return (
|
|
44
|
+
<Box key={pointer} flexDirection="column" marginBottom={1}>
|
|
45
|
+
<Text>
|
|
46
|
+
🎯{' '}
|
|
47
|
+
<Text bold color={theme.kode}>
|
|
48
|
+
{pointer.toUpperCase()}
|
|
49
|
+
</Text>{' '}
|
|
50
|
+
→ {model.name}
|
|
51
|
+
</Text>
|
|
52
|
+
<Text color={theme.secondaryText}>
|
|
53
|
+
{' '}
|
|
54
|
+
Provider: {model.provider}
|
|
55
|
+
</Text>
|
|
56
|
+
<Text color={theme.secondaryText}>
|
|
57
|
+
{' '}
|
|
58
|
+
Model: {model.modelName || 'unknown'}
|
|
59
|
+
</Text>
|
|
60
|
+
<Text color={theme.secondaryText}>
|
|
61
|
+
{' '}
|
|
62
|
+
Context:{' '}
|
|
63
|
+
{model.contextLength
|
|
64
|
+
? Math.round(model.contextLength / 1000)
|
|
65
|
+
: 'unknown'}
|
|
66
|
+
k tokens
|
|
67
|
+
</Text>
|
|
68
|
+
<Text color={theme.secondaryText}>
|
|
69
|
+
{' '}
|
|
70
|
+
Active: {model.isActive ? '✅' : '❌'}
|
|
71
|
+
</Text>
|
|
72
|
+
</Box>
|
|
73
|
+
)
|
|
74
|
+
} else {
|
|
75
|
+
return (
|
|
76
|
+
<Box key={pointer} flexDirection="column" marginBottom={1}>
|
|
77
|
+
<Text>
|
|
78
|
+
🎯{' '}
|
|
79
|
+
<Text bold color={theme.kode}>
|
|
80
|
+
{pointer.toUpperCase()}
|
|
81
|
+
</Text>{' '}
|
|
82
|
+
→ <Text color={theme.error}>❌ Not configured</Text>
|
|
83
|
+
</Text>
|
|
84
|
+
</Box>
|
|
85
|
+
)
|
|
86
|
+
}
|
|
87
|
+
} catch (pointerError) {
|
|
88
|
+
return (
|
|
89
|
+
<Box key={pointer} flexDirection="column" marginBottom={1}>
|
|
90
|
+
<Text>
|
|
91
|
+
🎯{' '}
|
|
92
|
+
<Text bold color={theme.kode}>
|
|
93
|
+
{pointer.toUpperCase()}
|
|
94
|
+
</Text>{' '}
|
|
95
|
+
→{' '}
|
|
96
|
+
<Text color={theme.error}>
|
|
97
|
+
❌ Error: {String(pointerError)}
|
|
98
|
+
</Text>
|
|
99
|
+
</Text>
|
|
100
|
+
</Box>
|
|
101
|
+
)
|
|
102
|
+
}
|
|
103
|
+
})}
|
|
104
|
+
|
|
105
|
+
<Text> </Text>
|
|
106
|
+
<Text bold>📚 Available Models:</Text>
|
|
107
|
+
|
|
108
|
+
{(() => {
|
|
109
|
+
try {
|
|
110
|
+
const availableModels = modelManager.getAvailableModels() || []
|
|
111
|
+
|
|
112
|
+
if (availableModels.length === 0) {
|
|
113
|
+
return (
|
|
114
|
+
<Text color={theme.secondaryText}> No models configured</Text>
|
|
115
|
+
)
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return availableModels.map((model, index) => {
|
|
119
|
+
try {
|
|
120
|
+
const isInUse = pointers.some(p => {
|
|
121
|
+
try {
|
|
122
|
+
return (
|
|
123
|
+
modelManager.getModel(p)?.modelName === model.modelName
|
|
124
|
+
)
|
|
125
|
+
} catch {
|
|
126
|
+
return false
|
|
127
|
+
}
|
|
128
|
+
})
|
|
129
|
+
|
|
130
|
+
return (
|
|
131
|
+
<Box key={index} flexDirection="column" marginBottom={1}>
|
|
132
|
+
<Text>
|
|
133
|
+
{' '}
|
|
134
|
+
{isInUse ? '🔄' : '💤'} {model.name || 'Unnamed'}{' '}
|
|
135
|
+
<Text color={theme.secondaryText}>
|
|
136
|
+
({model.provider || 'unknown'})
|
|
137
|
+
</Text>
|
|
138
|
+
</Text>
|
|
139
|
+
<Text color={theme.secondaryText}>
|
|
140
|
+
{' '}
|
|
141
|
+
Model: {model.modelName || 'unknown'}
|
|
142
|
+
</Text>
|
|
143
|
+
<Text color={theme.secondaryText}>
|
|
144
|
+
{' '}
|
|
145
|
+
Context:{' '}
|
|
146
|
+
{model.contextLength
|
|
147
|
+
? Math.round(model.contextLength / 1000)
|
|
148
|
+
: 'unknown'}
|
|
149
|
+
k tokens
|
|
150
|
+
</Text>
|
|
151
|
+
{model.lastUsed && (
|
|
152
|
+
<Text color={theme.secondaryText}>
|
|
153
|
+
{' '}
|
|
154
|
+
Last used: {new Date(model.lastUsed).toLocaleString()}
|
|
155
|
+
</Text>
|
|
156
|
+
)}
|
|
157
|
+
</Box>
|
|
158
|
+
)
|
|
159
|
+
} catch (modelError) {
|
|
160
|
+
return (
|
|
161
|
+
<Box key={index} flexDirection="column" marginBottom={1}>
|
|
162
|
+
<Text color={theme.error}>
|
|
163
|
+
{' '}
|
|
164
|
+
❌ Model error: {String(modelError)}
|
|
165
|
+
</Text>
|
|
166
|
+
</Box>
|
|
167
|
+
)
|
|
168
|
+
}
|
|
169
|
+
})
|
|
170
|
+
} catch (availableModelsError) {
|
|
171
|
+
return (
|
|
172
|
+
<Text color={theme.error}>
|
|
173
|
+
❌ Error loading available models:{' '}
|
|
174
|
+
{String(availableModelsError)}
|
|
175
|
+
</Text>
|
|
176
|
+
)
|
|
177
|
+
}
|
|
178
|
+
})()}
|
|
179
|
+
|
|
180
|
+
<Text> </Text>
|
|
181
|
+
<Text bold>🔧 Debug Info:</Text>
|
|
182
|
+
<Text color={theme.secondaryText}>
|
|
183
|
+
{' '}
|
|
184
|
+
ModelProfiles: {config.modelProfiles?.length || 0} configured
|
|
185
|
+
</Text>
|
|
186
|
+
<Text color={theme.secondaryText}>
|
|
187
|
+
{' '}
|
|
188
|
+
DefaultModelId: {(config as any).defaultModelId || 'not set'}
|
|
189
|
+
</Text>
|
|
190
|
+
{config.modelPointers && (
|
|
191
|
+
<>
|
|
192
|
+
<Text color={theme.secondaryText}>
|
|
193
|
+
{' '}
|
|
194
|
+
ModelPointers configured:{' '}
|
|
195
|
+
{Object.keys(config.modelPointers).length > 0 ? 'Yes' : 'No'}
|
|
196
|
+
</Text>
|
|
197
|
+
{Object.entries(config.modelPointers).map(([pointer, modelId]) => (
|
|
198
|
+
<React.Fragment key={pointer}>
|
|
199
|
+
<Text color={theme.secondaryText}>
|
|
200
|
+
{' '}
|
|
201
|
+
{pointer}: {modelId || 'not set'}
|
|
202
|
+
</Text>
|
|
203
|
+
</React.Fragment>
|
|
204
|
+
))}
|
|
205
|
+
</>
|
|
206
|
+
)}
|
|
207
|
+
</Box>
|
|
208
|
+
)
|
|
209
|
+
} catch (error) {
|
|
210
|
+
return (
|
|
211
|
+
<Box
|
|
212
|
+
flexDirection="column"
|
|
213
|
+
borderStyle="round"
|
|
214
|
+
borderColor={theme.error}
|
|
215
|
+
paddingX={2}
|
|
216
|
+
paddingY={1}
|
|
217
|
+
>
|
|
218
|
+
<Text bold>
|
|
219
|
+
📊 Model Status Error{' '}
|
|
220
|
+
{exitState.pending
|
|
221
|
+
? `(press ${exitState.keyName} again to exit)`
|
|
222
|
+
: ''}
|
|
223
|
+
</Text>
|
|
224
|
+
<Text color={theme.error}>
|
|
225
|
+
❌ Error reading model status: {String(error)}
|
|
226
|
+
</Text>
|
|
227
|
+
</Box>
|
|
228
|
+
)
|
|
229
|
+
}
|
|
230
|
+
}
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
import React, { useState } from 'react'
|
|
2
|
+
import { PRODUCT_NAME } from '../constants/product'
|
|
3
|
+
import { Box, Newline, Text, useInput } from 'ink'
|
|
4
|
+
import {
|
|
5
|
+
getGlobalConfig,
|
|
6
|
+
saveGlobalConfig,
|
|
7
|
+
DEFAULT_GLOBAL_CONFIG,
|
|
8
|
+
ProviderType,
|
|
9
|
+
} from '../utils/config.js'
|
|
10
|
+
import { OrderedList } from '@inkjs/ui'
|
|
11
|
+
import { useExitOnCtrlCD } from '../hooks/useExitOnCtrlCD'
|
|
12
|
+
import { MIN_LOGO_WIDTH } from './Logo'
|
|
13
|
+
import { Select } from './CustomSelect/select'
|
|
14
|
+
import { StructuredDiff } from './StructuredDiff'
|
|
15
|
+
import { getTheme, type ThemeNames } from '../utils/theme'
|
|
16
|
+
import { clearTerminal } from '../utils/terminal'
|
|
17
|
+
import { PressEnterToContinue } from './PressEnterToContinue'
|
|
18
|
+
import { ModelSelector } from './ModelSelector'
|
|
19
|
+
type StepId = 'theme' | 'usage' | 'providers' | 'model'
|
|
20
|
+
|
|
21
|
+
interface OnboardingStep {
|
|
22
|
+
id: StepId
|
|
23
|
+
component: React.ReactNode
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
type Props = {
|
|
27
|
+
onDone(): void
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function Onboarding({ onDone }: Props): React.ReactNode {
|
|
31
|
+
const [currentStepIndex, setCurrentStepIndex] = useState(0)
|
|
32
|
+
const [showModelSelector, setShowModelSelector] = useState(false)
|
|
33
|
+
const config = getGlobalConfig()
|
|
34
|
+
|
|
35
|
+
const [selectedTheme, setSelectedTheme] = useState(
|
|
36
|
+
DEFAULT_GLOBAL_CONFIG.theme,
|
|
37
|
+
)
|
|
38
|
+
const theme = getTheme()
|
|
39
|
+
function goToNextStep() {
|
|
40
|
+
if (currentStepIndex < steps.length - 1) {
|
|
41
|
+
const nextIndex = currentStepIndex + 1
|
|
42
|
+
setCurrentStepIndex(nextIndex)
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function handleThemeSelection(newTheme: string) {
|
|
47
|
+
saveGlobalConfig({
|
|
48
|
+
...config,
|
|
49
|
+
theme: newTheme as ThemeNames,
|
|
50
|
+
})
|
|
51
|
+
goToNextStep()
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function handleThemePreview(newTheme: string) {
|
|
55
|
+
setSelectedTheme(newTheme as ThemeNames)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function handleProviderSelectionDone() {
|
|
59
|
+
// After model selection is done, go to the next step
|
|
60
|
+
goToNextStep()
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function handleModelSelectionDone() {
|
|
64
|
+
// After final model selection is done, complete onboarding
|
|
65
|
+
onDone()
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const exitState = useExitOnCtrlCD(() => process.exit(0))
|
|
69
|
+
|
|
70
|
+
useInput(async (_, key) => {
|
|
71
|
+
const currentStep = steps[currentStepIndex]
|
|
72
|
+
if (
|
|
73
|
+
key.return &&
|
|
74
|
+
currentStep &&
|
|
75
|
+
['usage', 'providers', 'model'].includes(currentStep.id)
|
|
76
|
+
) {
|
|
77
|
+
if (currentStep.id === 'model') {
|
|
78
|
+
// Navigate to ModelSelector component
|
|
79
|
+
setShowModelSelector(true)
|
|
80
|
+
} else if (currentStepIndex === steps.length - 1) {
|
|
81
|
+
onDone()
|
|
82
|
+
} else {
|
|
83
|
+
// HACK: for some reason there's now a jump here otherwise :(
|
|
84
|
+
await clearTerminal()
|
|
85
|
+
goToNextStep()
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
// Define all onboarding steps
|
|
91
|
+
const themeStep = (
|
|
92
|
+
<Box flexDirection="column" gap={1} paddingLeft={1}>
|
|
93
|
+
<Text>Let's get started.</Text>
|
|
94
|
+
<Box flexDirection="column">
|
|
95
|
+
<Text bold>Choose the option that looks best when you select it:</Text>
|
|
96
|
+
<Text dimColor>To change this later, run /config</Text>
|
|
97
|
+
</Box>
|
|
98
|
+
<Select
|
|
99
|
+
options={[
|
|
100
|
+
{ label: 'Light text', value: 'dark' },
|
|
101
|
+
{ label: 'Dark text', value: 'light' },
|
|
102
|
+
{
|
|
103
|
+
label: 'Light text (colorblind-friendly)',
|
|
104
|
+
value: 'dark-daltonized',
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
label: 'Dark text (colorblind-friendly)',
|
|
108
|
+
value: 'light-daltonized',
|
|
109
|
+
},
|
|
110
|
+
]}
|
|
111
|
+
onFocus={handleThemePreview}
|
|
112
|
+
onChange={handleThemeSelection}
|
|
113
|
+
/>
|
|
114
|
+
<Box flexDirection="column">
|
|
115
|
+
<Box
|
|
116
|
+
paddingLeft={1}
|
|
117
|
+
marginRight={1}
|
|
118
|
+
borderStyle="round"
|
|
119
|
+
borderColor="gray"
|
|
120
|
+
flexDirection="column"
|
|
121
|
+
>
|
|
122
|
+
<StructuredDiff
|
|
123
|
+
patch={{
|
|
124
|
+
oldStart: 1,
|
|
125
|
+
newStart: 1,
|
|
126
|
+
oldLines: 3,
|
|
127
|
+
newLines: 3,
|
|
128
|
+
lines: [
|
|
129
|
+
'function greet() {',
|
|
130
|
+
'- console.log("Hello, World!");',
|
|
131
|
+
'+ console.log("Hello, anon!");',
|
|
132
|
+
'}',
|
|
133
|
+
],
|
|
134
|
+
}}
|
|
135
|
+
dim={false}
|
|
136
|
+
width={40}
|
|
137
|
+
overrideTheme={selectedTheme}
|
|
138
|
+
/>
|
|
139
|
+
</Box>
|
|
140
|
+
</Box>
|
|
141
|
+
</Box>
|
|
142
|
+
)
|
|
143
|
+
|
|
144
|
+
const providersStep = (
|
|
145
|
+
<Box flexDirection="column" gap={1} paddingLeft={1}>
|
|
146
|
+
<Box flexDirection="column" width={70}>
|
|
147
|
+
<Text color={theme.secondaryText}>
|
|
148
|
+
Next, let's select your preferred AI provider and model.
|
|
149
|
+
</Text>
|
|
150
|
+
</Box>
|
|
151
|
+
<ModelSelector
|
|
152
|
+
onDone={handleProviderSelectionDone}
|
|
153
|
+
skipModelType={true}
|
|
154
|
+
isOnboarding={true}
|
|
155
|
+
/>
|
|
156
|
+
</Box>
|
|
157
|
+
)
|
|
158
|
+
|
|
159
|
+
const usageStep = (
|
|
160
|
+
<Box flexDirection="column" gap={1} paddingLeft={1}>
|
|
161
|
+
<Text bold>Using {PRODUCT_NAME} effectively:</Text>
|
|
162
|
+
<Box flexDirection="column" width={70}>
|
|
163
|
+
<OrderedList children={[]}>
|
|
164
|
+
<OrderedList.Item children={[]}>
|
|
165
|
+
<Text>
|
|
166
|
+
Start in your project directory
|
|
167
|
+
<Newline />
|
|
168
|
+
<Text color={theme.secondaryText}>
|
|
169
|
+
Files are automatically added to context when needed.
|
|
170
|
+
</Text>
|
|
171
|
+
<Newline />
|
|
172
|
+
</Text>
|
|
173
|
+
</OrderedList.Item>
|
|
174
|
+
<OrderedList.Item children={[]}>
|
|
175
|
+
<Text>
|
|
176
|
+
Use {PRODUCT_NAME} as a development partner
|
|
177
|
+
<Newline />
|
|
178
|
+
<Text color={theme.secondaryText}>
|
|
179
|
+
Get help with file analysis, editing, bash commands,
|
|
180
|
+
<Newline />
|
|
181
|
+
and git history.
|
|
182
|
+
<Newline />
|
|
183
|
+
</Text>
|
|
184
|
+
</Text>
|
|
185
|
+
</OrderedList.Item>
|
|
186
|
+
<OrderedList.Item children={[]}>
|
|
187
|
+
<Text>
|
|
188
|
+
Provide clear context
|
|
189
|
+
<Newline />
|
|
190
|
+
<Text color={theme.secondaryText}>
|
|
191
|
+
Be as specific as you would with another engineer. <Newline />
|
|
192
|
+
The better the context, the better the results. <Newline />
|
|
193
|
+
</Text>
|
|
194
|
+
</Text>
|
|
195
|
+
</OrderedList.Item>
|
|
196
|
+
</OrderedList>
|
|
197
|
+
</Box>
|
|
198
|
+
<PressEnterToContinue />
|
|
199
|
+
</Box>
|
|
200
|
+
)
|
|
201
|
+
|
|
202
|
+
const modelStep = (
|
|
203
|
+
<Box flexDirection="column" gap={1} paddingLeft={1}>
|
|
204
|
+
<Text bold>Configure your models:</Text>
|
|
205
|
+
<Box flexDirection="column" width={70}>
|
|
206
|
+
<Text>
|
|
207
|
+
You can customize which models {PRODUCT_NAME} uses for different
|
|
208
|
+
tasks.
|
|
209
|
+
<Newline />
|
|
210
|
+
<Text color={theme.secondaryText}>
|
|
211
|
+
Let's set up your preferred models for large and small tasks.
|
|
212
|
+
</Text>
|
|
213
|
+
</Text>
|
|
214
|
+
<Box marginTop={1}>
|
|
215
|
+
<Text>
|
|
216
|
+
Press <Text color={theme.suggestion}>Enter</Text> to continue to the
|
|
217
|
+
model selection screen.
|
|
218
|
+
</Text>
|
|
219
|
+
</Box>
|
|
220
|
+
</Box>
|
|
221
|
+
<PressEnterToContinue />
|
|
222
|
+
</Box>
|
|
223
|
+
)
|
|
224
|
+
|
|
225
|
+
const steps: OnboardingStep[] = []
|
|
226
|
+
steps.push({ id: 'theme', component: themeStep })
|
|
227
|
+
steps.push({ id: 'usage', component: usageStep })
|
|
228
|
+
|
|
229
|
+
steps.push({ id: 'model', component: modelStep })
|
|
230
|
+
|
|
231
|
+
// If we're showing the model selector screen, render it directly
|
|
232
|
+
if (showModelSelector) {
|
|
233
|
+
return (
|
|
234
|
+
<ModelSelector
|
|
235
|
+
onDone={handleModelSelectionDone}
|
|
236
|
+
skipModelType={true}
|
|
237
|
+
isOnboarding={true}
|
|
238
|
+
/>
|
|
239
|
+
)
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
return (
|
|
243
|
+
<Box flexDirection="column" gap={1}>
|
|
244
|
+
<>
|
|
245
|
+
<Box flexDirection="column" gap={1}>
|
|
246
|
+
<Text bold>
|
|
247
|
+
{PRODUCT_NAME}{' '}
|
|
248
|
+
{exitState.pending
|
|
249
|
+
? `(press ${exitState.keyName} again to exit)`
|
|
250
|
+
: ''}
|
|
251
|
+
</Text>
|
|
252
|
+
{steps[currentStepIndex]?.component}
|
|
253
|
+
</Box>
|
|
254
|
+
</>
|
|
255
|
+
</Box>
|
|
256
|
+
)
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
export function WelcomeBox(): React.ReactNode {
|
|
260
|
+
const theme = getTheme()
|
|
261
|
+
return (
|
|
262
|
+
<Box
|
|
263
|
+
borderColor={theme.kode}
|
|
264
|
+
borderStyle="round"
|
|
265
|
+
paddingX={1}
|
|
266
|
+
width={MIN_LOGO_WIDTH}
|
|
267
|
+
>
|
|
268
|
+
<Text>
|
|
269
|
+
<Text color={theme.kode}>✻</Text> Welcome to{' '}
|
|
270
|
+
<Text bold>{PRODUCT_NAME}</Text> research preview!
|
|
271
|
+
</Text>
|
|
272
|
+
</Box>
|
|
273
|
+
)
|
|
274
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as React from 'react'
|
|
2
|
+
import { getTheme } from '../utils/theme'
|
|
3
|
+
import { Text } from 'ink'
|
|
4
|
+
|
|
5
|
+
export function PressEnterToContinue(): React.ReactNode {
|
|
6
|
+
return (
|
|
7
|
+
<Text color={getTheme().permission}>
|
|
8
|
+
Press <Text bold>Enter</Text> to continue…
|
|
9
|
+
</Text>
|
|
10
|
+
)
|
|
11
|
+
}
|