chore(go): audit providers kimi grok qwen letta
Move Kimi, Grok, and Qwen onto managed_runtime.go and shell_command.go; share the encoded and shell command builders and the quoted Windows legacy parser with Droid; split managed_changes.go; dedupe Letta's hook entry filtering and stop swallowing settings read errors. Claude-Session: https://claude.ai/code/session_01Agoc9bRVE9KL7mmWtey9Vq
This commit is contained in:
1 parent
1ede03d989
commit
34ff4c1ea8
34 files changed
+421
-1876
No files matched your search
@@ -196,3 +196,57 @@ func parseEncodedWindowsCommand(command string) (string, string, bool) {
|
||||
}
|
||||
return parsePowerShellSource(source)
|
||||
}
|
||||
|
||||
func buildEncodedCommand(product, runtimePath, scriptPath string) (string, error) {
|
||||
if !filepath.IsAbs(runtimePath) || !filepath.IsAbs(scriptPath) {
|
||||
return "", fmt.Errorf("%s hook commands require absolute runtime and script paths", product)
|
||||
}
|
||||
if runtime.GOOS == "windows" {
|
||||
return encodedWindowsCommand(runtimePath, scriptPath), nil
|
||||
}
|
||||
return posixSource(runtimePath, scriptPath), nil
|
||||
}
|
||||
|
||||
func parseEncodedCommand(command string) (string, string, bool) {
|
||||
if runtimePath, scriptPath, ok := parsePOSIXCommand(command); ok {
|
||||
return runtimePath, scriptPath, true
|
||||
}
|
||||
return parseEncodedWindowsCommand(command)
|
||||
}
|
||||
|
||||
func buildShellCommand(runtimePath, scriptPath string) string {
|
||||
if runtime.GOOS == "windows" {
|
||||
return powerShellSource(runtimePath, scriptPath)
|
||||
}
|
||||
return posixSource(runtimePath, scriptPath)
|
||||
}
|
||||
|
||||
func parseShellCommand(command string) (string, string, bool) {
|
||||
if runtime.GOOS == "windows" {
|
||||
return parsePowerShellSource(command)
|
||||
}
|
||||
return parsePOSIXCommand(command)
|
||||
}
|
||||
|
||||
// parseQuotedWindowsCommand reads the pre-2.1 `"node" "script"` form.
|
||||
func parseQuotedWindowsCommand(command string) (string, string, bool) {
|
||||
runtimePath, next, ok := readQuotedWindowsArgument(command, 0)
|
||||
if !ok || next >= len(command) || command[next] != ' ' {
|
||||
return "", "", false
|
||||
}
|
||||
scriptPath, end, ok := readQuotedWindowsArgument(command, next+1)
|
||||
return runtimePath, scriptPath, ok && end == len(command)
|
||||
}
|
||||
|
||||
func readQuotedWindowsArgument(command string, start int) (string, int, bool) {
|
||||
if start >= len(command) || command[start] != '"' {
|
||||
return "", start, false
|
||||
}
|
||||
end := strings.IndexByte(command[start+1:], '"')
|
||||
if end < 0 {
|
||||
return "", start, false
|
||||
}
|
||||
end += start + 1
|
||||
value := command[start+1 : end]
|
||||
return value, end + 1, value != "" && !strings.ContainsAny(value, "\r\n")
|
||||
}
|
||||
Reference in new issue
Block a user