Files
雷电芽衣 96489cd051 chore(go): audit providers kirocli kiroide opencode
Move Kiro IDE onto managed_runtime.go and shell_command.go, share
cloneJSONObject across providers, make OpenCode status verify the managed
runtime contract instead of any hook.js, propagate script removal errors,
and build the legacy runtime config through buildManagedRuntimeConfig.

Claude-Session: https://claude.ai/code/session_01Agoc9bRVE9KL7mmWtey9Vq
2026-09-03 02:32:20 -04:00

50 lines
1.2 KiB
Go

package plugins
import (
"path/filepath"
"strings"
)
func kiroIdeRuntimeReferenceForCommand(
command string,
scriptName string,
) (*managedScriptReference, error) {
runtimePath, scriptPath, ok := parseEncodedCommand(command)
if !ok || !filepath.IsAbs(runtimePath) || !isNodeExecutable(runtimePath) {
return nil, nil
}
return resolveManagedScript(scriptPath, scriptName)
}
func currentKiroIdeReference(
hook map[string]any,
nodePath string,
) (*managedScriptReference, error) {
reference, err := managedKiroIdeReference(hook)
if err != nil || reference == nil {
return reference, err
}
action := hook["action"].(map[string]any)
command := action["command"].(string)
expected, err := buildEncodedCommand("Kiro IDE", nodePath, reference.scriptPath)
if err != nil {
return nil, err
}
if command != expected {
return nil, nil
}
return reference, nil
}
// legacyKiroIdeGoReference reads the pre-2.1 `node <script>` form.
func legacyKiroIdeGoReference(
command any,
scriptName string,
) (*managedScriptReference, error) {
text, ok := command.(string)
if !ok || !strings.HasPrefix(text, "node ") {
return nil, nil
}
return resolveManagedScript(strings.TrimPrefix(text, "node "), scriptName)
}