@shareai-lab/kode 1.0.71 → 1.0.73
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 +142 -1
- package/README.zh-CN.md +47 -1
- package/package.json +5 -1
- 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 +117 -87
- package/src/components/SentryErrorBoundary.ts +3 -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 +11 -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 +1404 -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 +15 -9
- 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 +521 -12
- 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 +11 -10
- 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/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
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Common Unix Commands Database
|
|
3
|
+
*
|
|
4
|
+
* A curated list of 500+ most frequently used Unix/Linux commands
|
|
5
|
+
* for developers and system administrators.
|
|
6
|
+
*
|
|
7
|
+
* Categories:
|
|
8
|
+
* - File & Directory Operations
|
|
9
|
+
* - Text Processing
|
|
10
|
+
* - Process Management
|
|
11
|
+
* - Network Tools
|
|
12
|
+
* - Development Tools
|
|
13
|
+
* - System Administration
|
|
14
|
+
* - Package Management
|
|
15
|
+
* - Version Control
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
export const COMMON_UNIX_COMMANDS = [
|
|
19
|
+
// File & Directory Operations (50+)
|
|
20
|
+
'ls', 'cd', 'pwd', 'mkdir', 'rmdir', 'rm', 'cp', 'mv', 'touch', 'cat',
|
|
21
|
+
'less', 'more', 'head', 'tail', 'file', 'stat', 'ln', 'readlink', 'basename', 'dirname',
|
|
22
|
+
'find', 'locate', 'which', 'whereis', 'type', 'tree', 'du', 'df', 'mount', 'umount',
|
|
23
|
+
'chmod', 'chown', 'chgrp', 'umask', 'setfacl', 'getfacl', 'lsattr', 'chattr', 'realpath', 'mktemp',
|
|
24
|
+
'rsync', 'scp', 'sftp', 'ftp', 'wget', 'curl', 'tar', 'gzip', 'gunzip', 'zip',
|
|
25
|
+
'unzip', 'bzip2', 'bunzip2', 'xz', 'unxz', '7z', 'rar', 'unrar', 'zcat', 'zless',
|
|
26
|
+
|
|
27
|
+
// Text Processing (50+)
|
|
28
|
+
'grep', 'egrep', 'fgrep', 'rg', 'ag', 'ack', 'sed', 'awk', 'cut', 'paste',
|
|
29
|
+
'sort', 'uniq', 'wc', 'tr', 'col', 'column', 'expand', 'unexpand', 'fold', 'fmt',
|
|
30
|
+
'pr', 'nl', 'od', 'hexdump', 'xxd', 'strings', 'split', 'csplit', 'join', 'comm',
|
|
31
|
+
'diff', 'sdiff', 'vimdiff', 'patch', 'diffstat', 'cmp', 'md5sum', 'sha1sum', 'sha256sum', 'sha512sum',
|
|
32
|
+
'base64', 'uuencode', 'uudecode', 'rev', 'tac', 'shuf', 'jq', 'yq', 'xmllint', 'tidy',
|
|
33
|
+
|
|
34
|
+
// Process Management (40+)
|
|
35
|
+
'ps', 'top', 'htop', 'atop', 'iotop', 'iftop', 'nethogs', 'pgrep', 'pkill', 'kill',
|
|
36
|
+
'killall', 'jobs', 'bg', 'fg', 'nohup', 'disown', 'nice', 'renice', 'ionice', 'taskset',
|
|
37
|
+
'pstree', 'fuser', 'lsof', 'strace', 'ltrace', 'ptrace', 'gdb', 'valgrind', 'time', 'timeout',
|
|
38
|
+
'watch', 'screen', 'tmux', 'byobu', 'dtach', 'nmon', 'dstat', 'vmstat', 'iostat', 'mpstat',
|
|
39
|
+
|
|
40
|
+
// Network Tools (50+)
|
|
41
|
+
'ping', 'ping6', 'traceroute', 'tracepath', 'mtr', 'netstat', 'ss', 'ip', 'ifconfig', 'route',
|
|
42
|
+
'arp', 'hostname', 'hostnamectl', 'nslookup', 'dig', 'host', 'whois', 'nc', 'netcat', 'ncat',
|
|
43
|
+
'socat', 'telnet', 'ssh', 'ssh-keygen', 'ssh-copy-id', 'ssh-add', 'ssh-agent', 'sshd', 'tcpdump', 'wireshark',
|
|
44
|
+
'tshark', 'nmap', 'masscan', 'zmap', 'iptables', 'ip6tables', 'firewall-cmd', 'ufw', 'fail2ban', 'nginx',
|
|
45
|
+
'apache2', 'httpd', 'curl', 'wget', 'aria2', 'axel', 'links', 'lynx', 'w3m', 'elinks',
|
|
46
|
+
|
|
47
|
+
// Development Tools - Languages (60+)
|
|
48
|
+
'gcc', 'g++', 'clang', 'clang++', 'make', 'cmake', 'autoconf', 'automake', 'libtool', 'pkg-config',
|
|
49
|
+
'python3', 'pip', 'pip3', 'pipenv', 'poetry', 'virtualenv', 'pyenv',
|
|
50
|
+
'node', 'npm', 'uv', 'npx', 'yarn', 'pnpm', 'nvm', 'volta', 'deno', 'bun', 'tsx',
|
|
51
|
+
'ruby', 'gem', 'bundle', 'bundler', 'rake', 'rbenv', 'rvm', 'irb', 'pry', 'rails',
|
|
52
|
+
'java', 'javac', 'jar', 'javadoc', 'maven', 'mvn', 'gradle', 'ant', 'kotlin', 'kotlinc',
|
|
53
|
+
'go', 'gofmt', 'golint', 'govet', 'godoc', 'rust', 'rustc', 'cargo', 'rustup', 'rustfmt',
|
|
54
|
+
|
|
55
|
+
// Development Tools - Utilities (40+)
|
|
56
|
+
'git', 'svn', 'hg', 'bzr', 'cvs', 'fossil', 'tig', 'gitk', 'git-flow', 'hub',
|
|
57
|
+
'gh', 'glab', 'docker', 'docker-compose', 'podman', 'kubectl', 'helm', 'minikube', 'kind', 'k3s',
|
|
58
|
+
'vagrant', 'terraform', 'ansible', 'puppet', 'chef', 'salt', 'packer', 'consul', 'vault', 'nomad',
|
|
59
|
+
'vim', 'vi', 'nvim', 'emacs', 'nano', 'pico', 'ed', 'code', 'subl', 'atom',
|
|
60
|
+
|
|
61
|
+
// Database & Data Tools (30+)
|
|
62
|
+
'mysql', 'mysqldump', 'mysqladmin', 'psql', 'pg_dump', 'pg_restore', 'sqlite3', 'redis-cli', 'mongo', 'mongodump',
|
|
63
|
+
'mongorestore', 'cqlsh', 'influx', 'clickhouse-client', 'mariadb', 'cockroach', 'etcdctl', 'consul', 'vault', 'nomad',
|
|
64
|
+
'jq', 'yq', 'xmlstarlet', 'csvkit', 'miller', 'awk', 'sed', 'perl', 'lua', 'tcl',
|
|
65
|
+
|
|
66
|
+
// System Administration (50+)
|
|
67
|
+
'sudo', 'su', 'passwd', 'useradd', 'userdel', 'usermod', 'groupadd', 'groupdel', 'groupmod', 'id',
|
|
68
|
+
'who', 'w', 'last', 'lastlog', 'finger', 'chfn', 'chsh', 'login', 'logout', 'exit',
|
|
69
|
+
'systemctl', 'service', 'journalctl', 'systemd-analyze', 'init', 'telinit', 'runlevel', 'shutdown', 'reboot', 'halt',
|
|
70
|
+
'poweroff', 'uptime', 'uname', 'hostname', 'hostnamectl', 'timedatectl', 'localectl', 'loginctl', 'machinectl', 'bootctl',
|
|
71
|
+
'cron', 'crontab', 'at', 'batch', 'anacron', 'systemd-run', 'systemd-timer', 'logrotate', 'logger', 'dmesg',
|
|
72
|
+
|
|
73
|
+
// Package Management (30+)
|
|
74
|
+
'apt', 'apt-get', 'apt-cache', 'dpkg', 'dpkg-reconfigure', 'aptitude', 'snap', 'flatpak', 'appimage', 'alien',
|
|
75
|
+
'yum', 'dnf', 'rpm', 'zypper', 'pacman', 'yaourt', 'yay', 'makepkg', 'abs', 'aur',
|
|
76
|
+
'brew', 'port', 'pkg', 'emerge', 'portage', 'nix', 'guix', 'conda', 'mamba', 'micromamba',
|
|
77
|
+
|
|
78
|
+
// Monitoring & Performance (30+)
|
|
79
|
+
'top', 'htop', 'atop', 'btop', 'gtop', 'gotop', 'bashtop', 'bpytop', 'glances', 'nmon',
|
|
80
|
+
'sar', 'iostat', 'mpstat', 'vmstat', 'pidstat', 'free', 'uptime', 'tload', 'slabtop', 'powertop',
|
|
81
|
+
'iotop', 'iftop', 'nethogs', 'bmon', 'nload', 'speedtest', 'speedtest-cli', 'fast', 'mtr', 'smokeping',
|
|
82
|
+
|
|
83
|
+
// Security Tools (30+)
|
|
84
|
+
'gpg', 'gpg2', 'openssl', 'ssh-keygen', 'ssh-keyscan', 'ssl-cert', 'certbot', 'acme.sh', 'mkcert', 'step',
|
|
85
|
+
'pass', 'keepassxc-cli', 'bitwarden', '1password', 'hashcat', 'john', 'hydra', 'ncrack', 'medusa', 'aircrack-ng',
|
|
86
|
+
'chkrootkit', 'rkhunter', 'clamav', 'clamscan', 'freshclam', 'aide', 'tripwire', 'samhain', 'ossec', 'wazuh',
|
|
87
|
+
|
|
88
|
+
// Shell & Scripting (30+)
|
|
89
|
+
'bash', 'sh', 'zsh', 'fish', 'ksh', 'tcsh', 'csh', 'dash', 'ash', 'elvish',
|
|
90
|
+
'export', 'alias', 'unalias', 'history', 'fc', 'source', 'eval', 'exec', 'command', 'builtin',
|
|
91
|
+
'set', 'unset', 'env', 'printenv', 'echo', 'printf', 'read', 'test', 'expr', 'let',
|
|
92
|
+
|
|
93
|
+
// Archive & Compression (20+)
|
|
94
|
+
'tar', 'gzip', 'gunzip', 'bzip2', 'bunzip2', 'xz', 'unxz', 'lzma', 'unlzma', 'compress',
|
|
95
|
+
'uncompress', 'zip', 'unzip', '7z', '7za', 'rar', 'unrar', 'ar', 'cpio', 'pax',
|
|
96
|
+
|
|
97
|
+
// Media Tools (20+)
|
|
98
|
+
'ffmpeg', 'ffplay', 'ffprobe', 'sox', 'play', 'rec', 'mpg123', 'mpg321', 'ogg123', 'flac',
|
|
99
|
+
'lame', 'oggenc', 'opusenc', 'convert', 'mogrify', 'identify', 'display', 'import', 'animate', 'montage',
|
|
100
|
+
|
|
101
|
+
// Math & Calculation (15+)
|
|
102
|
+
'bc', 'dc', 'calc', 'qalc', 'units', 'factor', 'primes', 'seq', 'shuf', 'random',
|
|
103
|
+
'octave', 'maxima', 'sage', 'r', 'julia',
|
|
104
|
+
|
|
105
|
+
// Documentation & Help (15+)
|
|
106
|
+
'man', 'info', 'help', 'apropos', 'whatis', 'whereis', 'which', 'type', 'command', 'hash',
|
|
107
|
+
'tldr', 'cheat', 'howdoi', 'stackoverflow', 'explainshell',
|
|
108
|
+
|
|
109
|
+
// Miscellaneous Utilities (30+)
|
|
110
|
+
'date', 'cal', 'ncal', 'timedatectl', 'zdump', 'tzselect', 'hwclock', 'ntpdate', 'chrony', 'timeshift',
|
|
111
|
+
'yes', 'true', 'false', 'sleep', 'usleep', 'seq', 'jot', 'shuf', 'tee', 'xargs',
|
|
112
|
+
'parallel', 'rush', 'dsh', 'pssh', 'clusterssh', 'terminator', 'tilix', 'alacritty', 'kitty', 'wezterm',
|
|
113
|
+
] as const
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Get common commands that exist on the current system
|
|
117
|
+
* @param systemCommands Array of commands available on the system
|
|
118
|
+
* @returns Deduplicated intersection of common commands and system commands
|
|
119
|
+
*/
|
|
120
|
+
export function getCommonSystemCommands(systemCommands: string[]): string[] {
|
|
121
|
+
const systemSet = new Set(systemCommands.map(cmd => cmd.toLowerCase()))
|
|
122
|
+
const commonIntersection = COMMON_UNIX_COMMANDS.filter(cmd => systemSet.has(cmd.toLowerCase()))
|
|
123
|
+
// Remove duplicates using Set
|
|
124
|
+
return Array.from(new Set(commonIntersection))
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Get a priority score for a command based on its position in the common list
|
|
129
|
+
* Earlier commands get higher priority (more commonly used)
|
|
130
|
+
*/
|
|
131
|
+
export function getCommandPriority(command: string): number {
|
|
132
|
+
const index = COMMON_UNIX_COMMANDS.indexOf(command.toLowerCase() as any)
|
|
133
|
+
if (index === -1) return 0
|
|
134
|
+
|
|
135
|
+
// Convert index to priority score (earlier = higher score)
|
|
136
|
+
const maxScore = 100
|
|
137
|
+
const score = maxScore - (index / COMMON_UNIX_COMMANDS.length) * maxScore
|
|
138
|
+
return Math.round(score)
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Get essential fallback commands for when PATH is empty or unavailable
|
|
143
|
+
* These are the most basic commands that should always be available
|
|
144
|
+
*/
|
|
145
|
+
export function getEssentialCommands(): string[] {
|
|
146
|
+
return [
|
|
147
|
+
'ls', 'cd', 'pwd', 'cat', 'grep', 'find', 'which', 'man', 'cp', 'mv', 'rm', 'mkdir',
|
|
148
|
+
'touch', 'chmod', 'ps', 'top', 'kill', 'git', 'node', 'npm', 'python3',
|
|
149
|
+
'curl', 'wget', 'docker', 'vim', 'nano', 'echo', 'export', 'env', 'sudo'
|
|
150
|
+
]
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Get minimal fallback commands for error scenarios
|
|
155
|
+
* These are absolute minimum commands for basic functionality
|
|
156
|
+
*/
|
|
157
|
+
export function getMinimalFallbackCommands(): string[] {
|
|
158
|
+
return [
|
|
159
|
+
'ls', 'cd', 'pwd', 'cat', 'grep', 'find', 'git', 'node', 'npm', 'python3', 'vim', 'nano'
|
|
160
|
+
]
|
|
161
|
+
}
|
package/src/utils/config.ts
CHANGED
|
@@ -115,12 +115,16 @@ export type ModelProfile = {
|
|
|
115
115
|
modelName: string // Primary key - actual model identifier
|
|
116
116
|
baseURL?: string // Custom endpoint
|
|
117
117
|
apiKey: string
|
|
118
|
-
maxTokens: number // Output token limit
|
|
118
|
+
maxTokens: number // Output token limit (for GPT-5, this maps to max_completion_tokens)
|
|
119
119
|
contextLength: number // Context window size
|
|
120
|
-
reasoningEffort?: 'low' | 'medium' | 'high'
|
|
120
|
+
reasoningEffort?: 'low' | 'medium' | 'high' | 'minimal' | 'medium'
|
|
121
121
|
isActive: boolean // Whether profile is enabled
|
|
122
122
|
createdAt: number // Creation timestamp
|
|
123
123
|
lastUsed?: number // Last usage timestamp
|
|
124
|
+
// 🔥 GPT-5 specific metadata
|
|
125
|
+
isGPT5?: boolean // Auto-detected GPT-5 model flag
|
|
126
|
+
validationStatus?: 'valid' | 'needs_repair' | 'auto_repaired' // Configuration status
|
|
127
|
+
lastValidation?: number // Last validation timestamp
|
|
124
128
|
}
|
|
125
129
|
|
|
126
130
|
export type ModelPointerType = 'main' | 'task' | 'reasoning' | 'quick'
|
|
@@ -769,3 +773,170 @@ export function setModelPointer(
|
|
|
769
773
|
reloadModelManager()
|
|
770
774
|
})
|
|
771
775
|
}
|
|
776
|
+
|
|
777
|
+
// 🔥 GPT-5 Configuration Validation and Auto-Repair Functions
|
|
778
|
+
|
|
779
|
+
/**
|
|
780
|
+
* Check if a model name represents a GPT-5 model
|
|
781
|
+
*/
|
|
782
|
+
export function isGPT5ModelName(modelName: string): boolean {
|
|
783
|
+
if (!modelName || typeof modelName !== 'string') return false
|
|
784
|
+
const lowerName = modelName.toLowerCase()
|
|
785
|
+
return lowerName.startsWith('gpt-5') || lowerName.includes('gpt-5')
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
/**
|
|
789
|
+
* Validate and auto-repair GPT-5 model configuration
|
|
790
|
+
*/
|
|
791
|
+
export function validateAndRepairGPT5Profile(profile: ModelProfile): ModelProfile {
|
|
792
|
+
const isGPT5 = isGPT5ModelName(profile.modelName)
|
|
793
|
+
const now = Date.now()
|
|
794
|
+
|
|
795
|
+
// Create a working copy
|
|
796
|
+
const repairedProfile: ModelProfile = { ...profile }
|
|
797
|
+
let wasRepaired = false
|
|
798
|
+
|
|
799
|
+
// 🔧 Set GPT-5 detection flag
|
|
800
|
+
if (isGPT5 !== profile.isGPT5) {
|
|
801
|
+
repairedProfile.isGPT5 = isGPT5
|
|
802
|
+
wasRepaired = true
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
if (isGPT5) {
|
|
806
|
+
// 🔧 GPT-5 Parameter Validation and Repair
|
|
807
|
+
|
|
808
|
+
// 1. Reasoning effort validation
|
|
809
|
+
const validReasoningEfforts = ['minimal', 'low', 'medium', 'high']
|
|
810
|
+
if (!profile.reasoningEffort || !validReasoningEfforts.includes(profile.reasoningEffort)) {
|
|
811
|
+
repairedProfile.reasoningEffort = 'medium' // Default for coding tasks
|
|
812
|
+
wasRepaired = true
|
|
813
|
+
console.log(`🔧 GPT-5 Config: Set reasoning effort to 'medium' for ${profile.modelName}`)
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
// 2. Context length validation (GPT-5 models typically have 128k context)
|
|
817
|
+
if (profile.contextLength < 128000) {
|
|
818
|
+
repairedProfile.contextLength = 128000
|
|
819
|
+
wasRepaired = true
|
|
820
|
+
console.log(`🔧 GPT-5 Config: Updated context length to 128k for ${profile.modelName}`)
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
// 3. Output tokens validation (reasonable defaults for GPT-5)
|
|
824
|
+
if (profile.maxTokens < 4000) {
|
|
825
|
+
repairedProfile.maxTokens = 8192 // Good default for coding tasks
|
|
826
|
+
wasRepaired = true
|
|
827
|
+
console.log(`🔧 GPT-5 Config: Updated max tokens to 8192 for ${profile.modelName}`)
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
// 4. Provider validation
|
|
831
|
+
if (profile.provider !== 'openai' && profile.provider !== 'custom-openai' && profile.provider !== 'azure') {
|
|
832
|
+
console.warn(`⚠️ GPT-5 Config: Unexpected provider '${profile.provider}' for GPT-5 model ${profile.modelName}. Consider using 'openai' or 'custom-openai'.`)
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
// 5. Base URL validation for official models
|
|
836
|
+
if (profile.modelName.includes('gpt-5') && !profile.baseURL) {
|
|
837
|
+
repairedProfile.baseURL = 'https://api.openai.com/v1'
|
|
838
|
+
wasRepaired = true
|
|
839
|
+
console.log(`🔧 GPT-5 Config: Set default base URL for ${profile.modelName}`)
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
// Update validation metadata
|
|
844
|
+
repairedProfile.validationStatus = wasRepaired ? 'auto_repaired' : 'valid'
|
|
845
|
+
repairedProfile.lastValidation = now
|
|
846
|
+
|
|
847
|
+
if (wasRepaired) {
|
|
848
|
+
console.log(`✅ GPT-5 Config: Auto-repaired configuration for ${profile.modelName}`)
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
return repairedProfile
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
/**
|
|
855
|
+
* Validate and repair all GPT-5 profiles in the global configuration
|
|
856
|
+
*/
|
|
857
|
+
export function validateAndRepairAllGPT5Profiles(): { repaired: number; total: number } {
|
|
858
|
+
const config = getGlobalConfig()
|
|
859
|
+
if (!config.modelProfiles) {
|
|
860
|
+
return { repaired: 0, total: 0 }
|
|
861
|
+
}
|
|
862
|
+
|
|
863
|
+
let repairCount = 0
|
|
864
|
+
const repairedProfiles = config.modelProfiles.map(profile => {
|
|
865
|
+
const repairedProfile = validateAndRepairGPT5Profile(profile)
|
|
866
|
+
if (repairedProfile.validationStatus === 'auto_repaired') {
|
|
867
|
+
repairCount++
|
|
868
|
+
}
|
|
869
|
+
return repairedProfile
|
|
870
|
+
})
|
|
871
|
+
|
|
872
|
+
// Save the repaired configuration
|
|
873
|
+
if (repairCount > 0) {
|
|
874
|
+
const updatedConfig = {
|
|
875
|
+
...config,
|
|
876
|
+
modelProfiles: repairedProfiles,
|
|
877
|
+
}
|
|
878
|
+
saveGlobalConfig(updatedConfig)
|
|
879
|
+
console.log(`🔧 GPT-5 Config: Auto-repaired ${repairCount} model profiles`)
|
|
880
|
+
}
|
|
881
|
+
|
|
882
|
+
return { repaired: repairCount, total: config.modelProfiles.length }
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
/**
|
|
886
|
+
* Get GPT-5 configuration recommendations for a specific model
|
|
887
|
+
*/
|
|
888
|
+
export function getGPT5ConfigRecommendations(modelName: string): Partial<ModelProfile> {
|
|
889
|
+
if (!isGPT5ModelName(modelName)) {
|
|
890
|
+
return {}
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
const recommendations: Partial<ModelProfile> = {
|
|
894
|
+
contextLength: 128000, // GPT-5 standard context length
|
|
895
|
+
maxTokens: 8192, // Good default for coding tasks
|
|
896
|
+
reasoningEffort: 'medium', // Balanced for most coding tasks
|
|
897
|
+
isGPT5: true,
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
// Model-specific optimizations
|
|
901
|
+
if (modelName.includes('gpt-5-mini')) {
|
|
902
|
+
recommendations.maxTokens = 4096 // Smaller default for mini
|
|
903
|
+
recommendations.reasoningEffort = 'low' // Faster for simple tasks
|
|
904
|
+
} else if (modelName.includes('gpt-5-nano')) {
|
|
905
|
+
recommendations.maxTokens = 2048 // Even smaller for nano
|
|
906
|
+
recommendations.reasoningEffort = 'minimal' // Fastest option
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
return recommendations
|
|
910
|
+
}
|
|
911
|
+
|
|
912
|
+
/**
|
|
913
|
+
* Create a properly configured GPT-5 model profile
|
|
914
|
+
*/
|
|
915
|
+
export function createGPT5ModelProfile(
|
|
916
|
+
name: string,
|
|
917
|
+
modelName: string,
|
|
918
|
+
apiKey: string,
|
|
919
|
+
baseURL?: string,
|
|
920
|
+
provider: ProviderType = 'openai'
|
|
921
|
+
): ModelProfile {
|
|
922
|
+
const recommendations = getGPT5ConfigRecommendations(modelName)
|
|
923
|
+
|
|
924
|
+
const profile: ModelProfile = {
|
|
925
|
+
name,
|
|
926
|
+
provider,
|
|
927
|
+
modelName,
|
|
928
|
+
baseURL: baseURL || 'https://api.openai.com/v1',
|
|
929
|
+
apiKey,
|
|
930
|
+
maxTokens: recommendations.maxTokens || 8192,
|
|
931
|
+
contextLength: recommendations.contextLength || 128000,
|
|
932
|
+
reasoningEffort: recommendations.reasoningEffort || 'medium',
|
|
933
|
+
isActive: true,
|
|
934
|
+
createdAt: Date.now(),
|
|
935
|
+
isGPT5: true,
|
|
936
|
+
validationStatus: 'valid',
|
|
937
|
+
lastValidation: Date.now(),
|
|
938
|
+
}
|
|
939
|
+
|
|
940
|
+
console.log(`✅ Created GPT-5 model profile: ${name} (${modelName})`)
|
|
941
|
+
return profile
|
|
942
|
+
}
|
package/src/utils/debugLogger.ts
CHANGED
|
@@ -7,6 +7,19 @@ import { PRODUCT_COMMAND } from '../constants/product'
|
|
|
7
7
|
import { SESSION_ID } from './log'
|
|
8
8
|
import type { Message } from '../types/conversation'
|
|
9
9
|
|
|
10
|
+
// 调试日志级别
|
|
11
|
+
export enum LogLevel {
|
|
12
|
+
TRACE = 'TRACE',
|
|
13
|
+
DEBUG = 'DEBUG',
|
|
14
|
+
INFO = 'INFO',
|
|
15
|
+
WARN = 'WARN',
|
|
16
|
+
ERROR = 'ERROR',
|
|
17
|
+
FLOW = 'FLOW',
|
|
18
|
+
API = 'API',
|
|
19
|
+
STATE = 'STATE',
|
|
20
|
+
REMINDER = 'REMINDER', // 新增:系统提醒事件
|
|
21
|
+
}
|
|
22
|
+
|
|
10
23
|
// 调试模式检测
|
|
11
24
|
const isDebugMode = () =>
|
|
12
25
|
process.argv.includes('--debug') || process.argv.includes('--debug-verbose')
|
|
@@ -69,19 +82,6 @@ function ensureDebugDir() {
|
|
|
69
82
|
}
|
|
70
83
|
}
|
|
71
84
|
|
|
72
|
-
// 调试日志级别
|
|
73
|
-
export enum LogLevel {
|
|
74
|
-
TRACE = 'TRACE',
|
|
75
|
-
DEBUG = 'DEBUG',
|
|
76
|
-
INFO = 'INFO',
|
|
77
|
-
WARN = 'WARN',
|
|
78
|
-
ERROR = 'ERROR',
|
|
79
|
-
FLOW = 'FLOW',
|
|
80
|
-
API = 'API',
|
|
81
|
-
STATE = 'STATE',
|
|
82
|
-
REMINDER = 'REMINDER', // 新增:系统提醒事件
|
|
83
|
-
}
|
|
84
|
-
|
|
85
85
|
// 日志条目接口
|
|
86
86
|
interface LogEntry {
|
|
87
87
|
timestamp: string
|