@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.
Files changed (108) hide show
  1. package/README.md +160 -1
  2. package/README.zh-CN.md +65 -1
  3. package/cli.js +5 -10
  4. package/package.json +6 -2
  5. package/src/ProjectOnboarding.tsx +47 -29
  6. package/src/Tool.ts +33 -4
  7. package/src/commands/agents.tsx +3401 -0
  8. package/src/commands/help.tsx +2 -2
  9. package/src/commands/resume.tsx +2 -1
  10. package/src/commands/terminalSetup.ts +4 -4
  11. package/src/commands.ts +3 -0
  12. package/src/components/ApproveApiKey.tsx +1 -1
  13. package/src/components/Config.tsx +10 -6
  14. package/src/components/ConsoleOAuthFlow.tsx +5 -4
  15. package/src/components/CustomSelect/select-option.tsx +28 -2
  16. package/src/components/CustomSelect/select.tsx +14 -5
  17. package/src/components/CustomSelect/theme.ts +45 -0
  18. package/src/components/Help.tsx +4 -4
  19. package/src/components/InvalidConfigDialog.tsx +1 -1
  20. package/src/components/LogSelector.tsx +1 -1
  21. package/src/components/MCPServerApprovalDialog.tsx +1 -1
  22. package/src/components/Message.tsx +2 -0
  23. package/src/components/ModelListManager.tsx +10 -6
  24. package/src/components/ModelSelector.tsx +201 -23
  25. package/src/components/ModelStatusDisplay.tsx +7 -5
  26. package/src/components/PromptInput.tsx +146 -96
  27. package/src/components/SentryErrorBoundary.ts +9 -3
  28. package/src/components/StickerRequestForm.tsx +16 -0
  29. package/src/components/StructuredDiff.tsx +36 -29
  30. package/src/components/TextInput.tsx +13 -0
  31. package/src/components/TodoItem.tsx +47 -0
  32. package/src/components/TrustDialog.tsx +1 -1
  33. package/src/components/messages/AssistantLocalCommandOutputMessage.tsx +5 -1
  34. package/src/components/messages/AssistantToolUseMessage.tsx +14 -4
  35. package/src/components/messages/TaskProgressMessage.tsx +32 -0
  36. package/src/components/messages/TaskToolMessage.tsx +58 -0
  37. package/src/components/permissions/FallbackPermissionRequest.tsx +2 -4
  38. package/src/components/permissions/FileEditPermissionRequest/FileEditPermissionRequest.tsx +1 -1
  39. package/src/components/permissions/FileEditPermissionRequest/FileEditToolDiff.tsx +5 -3
  40. package/src/components/permissions/FileWritePermissionRequest/FileWritePermissionRequest.tsx +1 -1
  41. package/src/components/permissions/FileWritePermissionRequest/FileWriteToolDiff.tsx +5 -3
  42. package/src/components/permissions/FilesystemPermissionRequest/FilesystemPermissionRequest.tsx +2 -4
  43. package/src/components/permissions/PermissionRequest.tsx +3 -5
  44. package/src/constants/macros.ts +2 -0
  45. package/src/constants/modelCapabilities.ts +179 -0
  46. package/src/constants/models.ts +90 -0
  47. package/src/constants/product.ts +1 -1
  48. package/src/context.ts +7 -7
  49. package/src/entrypoints/cli.tsx +23 -3
  50. package/src/entrypoints/mcp.ts +10 -10
  51. package/src/hooks/useCanUseTool.ts +1 -1
  52. package/src/hooks/useTextInput.ts +5 -2
  53. package/src/hooks/useUnifiedCompletion.ts +1405 -0
  54. package/src/messages.ts +1 -0
  55. package/src/query.ts +3 -0
  56. package/src/screens/ConfigureNpmPrefix.tsx +1 -1
  57. package/src/screens/Doctor.tsx +1 -1
  58. package/src/screens/REPL.tsx +11 -12
  59. package/src/services/adapters/base.ts +38 -0
  60. package/src/services/adapters/chatCompletions.ts +90 -0
  61. package/src/services/adapters/responsesAPI.ts +170 -0
  62. package/src/services/claude.ts +198 -62
  63. package/src/services/customCommands.ts +43 -22
  64. package/src/services/gpt5ConnectionTest.ts +340 -0
  65. package/src/services/mcpClient.ts +1 -1
  66. package/src/services/mentionProcessor.ts +273 -0
  67. package/src/services/modelAdapterFactory.ts +69 -0
  68. package/src/services/openai.ts +534 -14
  69. package/src/services/responseStateManager.ts +90 -0
  70. package/src/services/systemReminder.ts +113 -12
  71. package/src/test/testAdapters.ts +96 -0
  72. package/src/tools/AskExpertModelTool/AskExpertModelTool.tsx +120 -56
  73. package/src/tools/BashTool/BashTool.tsx +4 -31
  74. package/src/tools/BashTool/BashToolResultMessage.tsx +1 -1
  75. package/src/tools/BashTool/OutputLine.tsx +1 -0
  76. package/src/tools/FileEditTool/FileEditTool.tsx +4 -5
  77. package/src/tools/FileReadTool/FileReadTool.tsx +43 -10
  78. package/src/tools/MCPTool/MCPTool.tsx +2 -1
  79. package/src/tools/MultiEditTool/MultiEditTool.tsx +2 -2
  80. package/src/tools/NotebookReadTool/NotebookReadTool.tsx +15 -23
  81. package/src/tools/StickerRequestTool/StickerRequestTool.tsx +1 -1
  82. package/src/tools/TaskTool/TaskTool.tsx +170 -86
  83. package/src/tools/TaskTool/prompt.ts +61 -25
  84. package/src/tools/ThinkTool/ThinkTool.tsx +1 -3
  85. package/src/tools/TodoWriteTool/TodoWriteTool.tsx +65 -41
  86. package/src/tools/lsTool/lsTool.tsx +5 -2
  87. package/src/tools.ts +16 -16
  88. package/src/types/conversation.ts +51 -0
  89. package/src/types/logs.ts +58 -0
  90. package/src/types/modelCapabilities.ts +64 -0
  91. package/src/types/notebook.ts +87 -0
  92. package/src/utils/advancedFuzzyMatcher.ts +290 -0
  93. package/src/utils/agentLoader.ts +284 -0
  94. package/src/utils/ask.tsx +1 -0
  95. package/src/utils/commands.ts +1 -1
  96. package/src/utils/commonUnixCommands.ts +161 -0
  97. package/src/utils/config.ts +173 -2
  98. package/src/utils/conversationRecovery.ts +1 -0
  99. package/src/utils/debugLogger.ts +13 -13
  100. package/src/utils/exampleCommands.ts +1 -0
  101. package/src/utils/fuzzyMatcher.ts +328 -0
  102. package/src/utils/messages.tsx +6 -5
  103. package/src/utils/model.ts +120 -42
  104. package/src/utils/responseState.ts +23 -0
  105. package/src/utils/secureFile.ts +559 -0
  106. package/src/utils/terminal.ts +1 -0
  107. package/src/utils/theme.ts +11 -0
  108. 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
- }