Files
Elydora-Open-Source/sdks/go/cmd/elydora/plugins/cline.go
T
雷电芽衣 bc6983a62e chore(oss): audit the server package and resync the SDK mirrors
Split the 657-line operation service into eor, submit, and verify
modules, add the AGENT_REVOKED and KEY_RETIRED codes the Backend already
emits, and condense every multi-line comment. Mirror Node, Python, and
Go at 2.1.0 with the deep-health 503, non-idempotent retry, rotation
grace, and path-encoding fixes. Document which routes and response
fields the self-hosted server does not provide.

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

109 lines
2.4 KiB
Go

package plugins
import "fmt"
// ClinePlugin manages Cline's native global file hooks.
type ClinePlugin struct {
rename renameFunc
}
// ManagesGuardRuntime reports that the guard is committed with the audit runtime.
func (p *ClinePlugin) ManagesGuardRuntime() bool {
return true
}
// PreflightInstall validates hook ownership and runtime identity before writes.
func (p *ClinePlugin) PreflightInstall(config InstallConfig) error {
paths, guard, audit, err := readClineHookPair()
if err != nil {
return err
}
if err := requireAvailableClineHook(guard); err != nil {
return err
}
if err := requireAvailableClineHook(audit); err != nil {
return err
}
_, err = preflightClineInstallation(config, paths)
return err
}
func (p *ClinePlugin) Install(config InstallConfig) error {
paths, guard, audit, err := readClineHookPair()
if err != nil {
return err
}
if err := requireAvailableClineHook(guard); err != nil {
return err
}
if err := requireAvailableClineHook(audit); err != nil {
return err
}
runtimePaths, err := preflightClineInstallation(config, paths)
if err != nil {
return err
}
changes, err := prepareClineInstallationChanges(
config,
runtimePaths,
guard,
audit,
)
if err != nil {
return err
}
if err := writeClineChanges(
changes,
"Install Cline hooks",
p.rename,
runtimePaths,
); err != nil {
return err
}
fmt.Println("Cline: user-level PreToolUse and PostToolUse hooks installed.")
return nil
}
func (p *ClinePlugin) Uninstall(agentID string) error {
paths, guard, audit, err := readClineHookPair()
if err != nil {
return err
}
changes, err := prepareClineUninstallChanges(
[]clineHookFile{guard, audit},
agentID,
)
if err != nil {
return err
}
return writeClineHookChanges(
changes,
"Uninstall Cline hooks",
p.rename,
paths,
)
}
func (p *ClinePlugin) Status() (PluginStatus, error) {
paths, guard, audit, err := readClineHookPair()
status := PluginStatus{
AgentName: clineAgentKey,
DisplayName: "Cline",
ConfigPath: paths.hooksDirectory,
}
if err != nil {
return status, err
}
contract, err := clineContractForFiles(guard, audit)
if err != nil || contract == nil {
return status, err
}
status.HookConfigured = true
status.HookScriptExists, err = clineRuntimeFilesExist(contract)
if err != nil {
return status, err
}
status.Installed = status.HookScriptExists
return status, nil
}