Files
Elydora-Go-SDK/cmd/elydora/plugins/kiroide_status.go
T
雷电芽衣 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

62 lines
1.8 KiB
Go

package plugins
import (
"path/filepath"
"runtime"
)
func kiroIdeExpectedScripts(agentID string, _ map[string]any) ([]byte, []byte) {
return []byte(generateGuardScript(kiroIdeAgentKey, agentID, "", false, "")),
[]byte(buildHookScriptWithOutput(kiroIdeAgentKey, agentID, "", false, true))
}
func kiroIdeRuntimeFileMode(snapshot *managedFileSnapshot, expected uint32) bool {
if runtime.GOOS == "windows" {
return true
}
return uint32(snapshot.mode.Perm()) == expected
}
// kiroIdeRuntimeModesMatch requires the private modes the installer writes.
func kiroIdeRuntimeModesMatch(contract managedRuntimeContract) (bool, error) {
agentDirectory := filepath.Dir(contract.guardPath)
for _, item := range []struct {
path, label string
limit int64
mode uint32
}{
{filepath.Join(agentDirectory, "config.json"), "Elydora runtime config", maxRuntimeConfigBytes, 0600},
{filepath.Join(agentDirectory, "private.key"), "Elydora private key", maxProtectedSecretBytes, 0600},
{contract.guardPath, "Elydora guard runtime", maxManagedSourceBytes, 0700},
{contract.auditPath, "Elydora audit runtime", maxManagedSourceBytes, 0700},
} {
snapshot, err := readManagedFile(item.path, item.label, item.limit)
if err != nil || snapshot == nil {
return false, err
}
if !kiroIdeRuntimeFileMode(snapshot, item.mode) {
return false, nil
}
}
return true, nil
}
func kiroIdeRuntimeFilesExist(contracts []managedRuntimeContract) (bool, error) {
for _, contract := range contracts {
exists, err := managedRuntimeContractExists(
contract, kiroIdeAgentKey, "Kiro IDE", kiroIdeExpectedScripts,
)
if err != nil {
return false, err
}
if !exists {
continue
}
modes, err := kiroIdeRuntimeModesMatch(contract)
if err != nil || modes {
return modes, err
}
}
return false, nil
}