@shareai-lab/kode 1.0.71 → 1.0.75
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/README.md +160 -1
- package/README.zh-CN.md +65 -1
- package/cli.js +5 -10
- package/package.json +6 -2
- package/src/ProjectOnboarding.tsx +47 -29
- package/src/Tool.ts +33 -4
- package/src/commands/agents.tsx +3401 -0
- package/src/commands/help.tsx +2 -2
- package/src/commands/resume.tsx +2 -1
- package/src/commands/terminalSetup.ts +4 -4
- package/src/commands.ts +3 -0
- package/src/components/ApproveApiKey.tsx +1 -1
- package/src/components/Config.tsx +10 -6
- package/src/components/ConsoleOAuthFlow.tsx +5 -4
- package/src/components/CustomSelect/select-option.tsx +28 -2
- package/src/components/CustomSelect/select.tsx +14 -5
- package/src/components/CustomSelect/theme.ts +45 -0
- package/src/components/Help.tsx +4 -4
- package/src/components/InvalidConfigDialog.tsx +1 -1
- package/src/components/LogSelector.tsx +1 -1
- package/src/components/MCPServerApprovalDialog.tsx +1 -1
- package/src/components/Message.tsx +2 -0
- package/src/components/ModelListManager.tsx +10 -6
- package/src/components/ModelSelector.tsx +201 -23
- package/src/components/ModelStatusDisplay.tsx +7 -5
- package/src/components/PromptInput.tsx +146 -96
- package/src/components/SentryErrorBoundary.ts +9 -3
- package/src/components/StickerRequestForm.tsx +16 -0
- package/src/components/StructuredDiff.tsx +36 -29
- package/src/components/TextInput.tsx +13 -0
- package/src/components/TodoItem.tsx +47 -0
- package/src/components/TrustDialog.tsx +1 -1
- package/src/components/messages/AssistantLocalCommandOutputMessage.tsx +5 -1
- package/src/components/messages/AssistantToolUseMessage.tsx +14 -4
- package/src/components/messages/TaskProgressMessage.tsx +32 -0
- package/src/components/messages/TaskToolMessage.tsx +58 -0
- package/src/components/permissions/FallbackPermissionRequest.tsx +2 -4
- package/src/components/permissions/FileEditPermissionRequest/FileEditPermissionRequest.tsx +1 -1
- package/src/components/permissions/FileEditPermissionRequest/FileEditToolDiff.tsx +5 -3
- package/src/components/permissions/FileWritePermissionRequest/FileWritePermissionRequest.tsx +1 -1
- package/src/components/permissions/FileWritePermissionRequest/FileWriteToolDiff.tsx +5 -3
- package/src/components/permissions/FilesystemPermissionRequest/FilesystemPermissionRequest.tsx +2 -4
- package/src/components/permissions/PermissionRequest.tsx +3 -5
- package/src/constants/macros.ts +2 -0
- package/src/constants/modelCapabilities.ts +179 -0
- package/src/constants/models.ts +90 -0
- package/src/constants/product.ts +1 -1
- package/src/context.ts +7 -7
- package/src/entrypoints/cli.tsx +23 -3
- package/src/entrypoints/mcp.ts +10 -10
- package/src/hooks/useCanUseTool.ts +1 -1
- package/src/hooks/useTextInput.ts +5 -2
- package/src/hooks/useUnifiedCompletion.ts +1405 -0
- package/src/messages.ts +1 -0
- package/src/query.ts +3 -0
- package/src/screens/ConfigureNpmPrefix.tsx +1 -1
- package/src/screens/Doctor.tsx +1 -1
- package/src/screens/REPL.tsx +11 -12
- 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/claude.ts +198 -62
- package/src/services/customCommands.ts +43 -22
- package/src/services/gpt5ConnectionTest.ts +340 -0
- package/src/services/mcpClient.ts +1 -1
- package/src/services/mentionProcessor.ts +273 -0
- package/src/services/modelAdapterFactory.ts +69 -0
- package/src/services/openai.ts +534 -14
- package/src/services/responseStateManager.ts +90 -0
- package/src/services/systemReminder.ts +113 -12
- package/src/test/testAdapters.ts +96 -0
- package/src/tools/AskExpertModelTool/AskExpertModelTool.tsx +120 -56
- package/src/tools/BashTool/BashTool.tsx +4 -31
- package/src/tools/BashTool/BashToolResultMessage.tsx +1 -1
- package/src/tools/BashTool/OutputLine.tsx +1 -0
- package/src/tools/FileEditTool/FileEditTool.tsx +4 -5
- package/src/tools/FileReadTool/FileReadTool.tsx +43 -10
- package/src/tools/MCPTool/MCPTool.tsx +2 -1
- package/src/tools/MultiEditTool/MultiEditTool.tsx +2 -2
- package/src/tools/NotebookReadTool/NotebookReadTool.tsx +15 -23
- package/src/tools/StickerRequestTool/StickerRequestTool.tsx +1 -1
- package/src/tools/TaskTool/TaskTool.tsx +170 -86
- package/src/tools/TaskTool/prompt.ts +61 -25
- package/src/tools/ThinkTool/ThinkTool.tsx +1 -3
- package/src/tools/TodoWriteTool/TodoWriteTool.tsx +65 -41
- package/src/tools/lsTool/lsTool.tsx +5 -2
- package/src/tools.ts +16 -16
- 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/advancedFuzzyMatcher.ts +290 -0
- package/src/utils/agentLoader.ts +284 -0
- package/src/utils/ask.tsx +1 -0
- package/src/utils/commands.ts +1 -1
- package/src/utils/commonUnixCommands.ts +161 -0
- package/src/utils/config.ts +173 -2
- package/src/utils/conversationRecovery.ts +1 -0
- package/src/utils/debugLogger.ts +13 -13
- package/src/utils/exampleCommands.ts +1 -0
- package/src/utils/fuzzyMatcher.ts +328 -0
- package/src/utils/messages.tsx +6 -5
- package/src/utils/model.ts +120 -42
- package/src/utils/responseState.ts +23 -0
- package/src/utils/secureFile.ts +559 -0
- package/src/utils/terminal.ts +1 -0
- package/src/utils/theme.ts +11 -0
- package/src/hooks/useSlashCommandTypeahead.ts +0 -137
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
import { useInput } from 'ink'
|
|
2
|
-
import { useState, useCallback, useEffect } from 'react'
|
|
3
|
-
import { Command, getCommand } from '../commands'
|
|
4
|
-
|
|
5
|
-
type Props = {
|
|
6
|
-
commands: Command[]
|
|
7
|
-
onInputChange: (value: string) => void
|
|
8
|
-
onSubmit: (value: string, isSubmittingSlashCommand?: boolean) => void
|
|
9
|
-
setCursorOffset: (offset: number) => void
|
|
10
|
-
currentInput?: string // Add current input for monitoring
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export function useSlashCommandTypeahead({
|
|
14
|
-
commands,
|
|
15
|
-
onInputChange,
|
|
16
|
-
onSubmit,
|
|
17
|
-
setCursorOffset,
|
|
18
|
-
currentInput,
|
|
19
|
-
}: Props): {
|
|
20
|
-
suggestions: string[]
|
|
21
|
-
selectedSuggestion: number
|
|
22
|
-
updateSuggestions: (value: string) => void
|
|
23
|
-
clearSuggestions: () => void
|
|
24
|
-
} {
|
|
25
|
-
const [suggestions, setSuggestions] = useState<string[]>([])
|
|
26
|
-
const [selectedSuggestion, setSelectedSuggestion] = useState(-1)
|
|
27
|
-
|
|
28
|
-
// Force clear suggestions when input doesn't start with /
|
|
29
|
-
useEffect(() => {
|
|
30
|
-
if (
|
|
31
|
-
currentInput !== undefined &&
|
|
32
|
-
!currentInput.startsWith('/') &&
|
|
33
|
-
suggestions.length > 0
|
|
34
|
-
) {
|
|
35
|
-
setSuggestions([])
|
|
36
|
-
setSelectedSuggestion(-1)
|
|
37
|
-
}
|
|
38
|
-
}, [currentInput, suggestions.length])
|
|
39
|
-
|
|
40
|
-
function updateSuggestions(value: string) {
|
|
41
|
-
if (value.startsWith('/')) {
|
|
42
|
-
const query = value.slice(1).toLowerCase()
|
|
43
|
-
|
|
44
|
-
// Find commands whose name or alias matches the query
|
|
45
|
-
const matchingCommands = commands
|
|
46
|
-
.filter(cmd => !cmd.isHidden)
|
|
47
|
-
.filter(cmd => {
|
|
48
|
-
const names = [cmd.userFacingName()]
|
|
49
|
-
if (cmd.aliases) {
|
|
50
|
-
names.push(...cmd.aliases)
|
|
51
|
-
}
|
|
52
|
-
return names.some(name => name.toLowerCase().startsWith(query))
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
// For each matching command, include its primary name
|
|
56
|
-
const filtered = matchingCommands.map(cmd => cmd.userFacingName())
|
|
57
|
-
setSuggestions(filtered)
|
|
58
|
-
|
|
59
|
-
// Try to preserve the selected suggestion
|
|
60
|
-
const newIndex =
|
|
61
|
-
selectedSuggestion > -1
|
|
62
|
-
? filtered.indexOf(suggestions[selectedSuggestion]!)
|
|
63
|
-
: 0
|
|
64
|
-
if (newIndex > -1) {
|
|
65
|
-
setSelectedSuggestion(newIndex)
|
|
66
|
-
} else {
|
|
67
|
-
setSelectedSuggestion(0)
|
|
68
|
-
}
|
|
69
|
-
} else {
|
|
70
|
-
setSuggestions([])
|
|
71
|
-
setSelectedSuggestion(-1)
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
useInput((_, key) => {
|
|
76
|
-
if (suggestions.length > 0) {
|
|
77
|
-
// Handle suggestion navigation (up/down arrows)
|
|
78
|
-
if (key.downArrow) {
|
|
79
|
-
setSelectedSuggestion(prev =>
|
|
80
|
-
prev >= suggestions.length - 1 ? 0 : prev + 1,
|
|
81
|
-
)
|
|
82
|
-
return true
|
|
83
|
-
} else if (key.upArrow) {
|
|
84
|
-
setSelectedSuggestion(prev =>
|
|
85
|
-
prev <= 0 ? suggestions.length - 1 : prev - 1,
|
|
86
|
-
)
|
|
87
|
-
return true
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
// Handle selection completion via tab or return
|
|
91
|
-
else if (key.tab || (key.return && selectedSuggestion >= 0)) {
|
|
92
|
-
// Ensure a suggestion is selected
|
|
93
|
-
if (selectedSuggestion === -1 && key.tab) {
|
|
94
|
-
setSelectedSuggestion(0)
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
const suggestionIndex = selectedSuggestion >= 0 ? selectedSuggestion : 0
|
|
98
|
-
const suggestion = suggestions[suggestionIndex]
|
|
99
|
-
if (!suggestion) return true
|
|
100
|
-
|
|
101
|
-
const input = '/' + suggestion + ' '
|
|
102
|
-
onInputChange(input)
|
|
103
|
-
// Manually move cursor to end
|
|
104
|
-
setCursorOffset(input.length)
|
|
105
|
-
setSuggestions([])
|
|
106
|
-
setSelectedSuggestion(-1)
|
|
107
|
-
|
|
108
|
-
// If return was pressed and command doesn't take arguments, just run it
|
|
109
|
-
if (key.return) {
|
|
110
|
-
const command = getCommand(suggestion, commands)
|
|
111
|
-
if (
|
|
112
|
-
command.type !== 'prompt' ||
|
|
113
|
-
(command.argNames ?? []).length === 0
|
|
114
|
-
) {
|
|
115
|
-
onSubmit(input, /* isSubmittingSlashCommand */ true)
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
return true
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
// Explicitly return false when not handling the input
|
|
123
|
-
return false
|
|
124
|
-
})
|
|
125
|
-
|
|
126
|
-
const clearSuggestions = useCallback(() => {
|
|
127
|
-
setSuggestions([])
|
|
128
|
-
setSelectedSuggestion(-1)
|
|
129
|
-
}, [])
|
|
130
|
-
|
|
131
|
-
return {
|
|
132
|
-
suggestions,
|
|
133
|
-
selectedSuggestion,
|
|
134
|
-
updateSuggestions,
|
|
135
|
-
clearSuggestions,
|
|
136
|
-
}
|
|
137
|
-
}
|