Rebuilt from the standalone f5341ed tree (durable managed-file transactions, Kiro IDE adapter, hook retry with a bounded chain lock, CLI version 2.0.1) with the Open-Source API trims re-applied: no admin events, members, webhooks, deep health, token rotation, or agent integration updates, and the mirror's freeze/unfreeze and registration validation contracts kept. The root quickstart now imports the /v2 path. Claude-Session: https://claude.ai/code/session_01QoUjdc7HGKTsgj5GhG8HvF
129 lines
3.3 KiB
Go
129 lines
3.3 KiB
Go
package plugins
|
|
|
|
import "fmt"
|
|
|
|
// KiroIdePlugin manages Kiro IDE 1.0 workspace hooks.
|
|
type KiroIdePlugin struct {
|
|
rename renameFunc
|
|
}
|
|
|
|
// ManagesGuardRuntime reports that Kiro IDE commits both generated runtimes,
|
|
// runtime metadata, credentials, workspace hooks, and legacy migration in one
|
|
// transaction.
|
|
func (p *KiroIdePlugin) ManagesGuardRuntime() bool {
|
|
return true
|
|
}
|
|
|
|
// PreflightInstall validates every source and runtime identity before writes.
|
|
func (p *KiroIdePlugin) PreflightInstall(config InstallConfig) error {
|
|
sources, err := readKiroIdeSources()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if err := requireAvailableKiroIdeHooks(sources.document.hooks); err != nil {
|
|
return err
|
|
}
|
|
_, _, err = preflightKiroIdeInstallation(config)
|
|
return err
|
|
}
|
|
|
|
func (p *KiroIdePlugin) Install(config InstallConfig) error {
|
|
sources, err := readKiroIdeSources()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if err := requireAvailableKiroIdeHooks(sources.document.hooks); err != nil {
|
|
return err
|
|
}
|
|
paths, nodePath, err := preflightKiroIdeInstallation(config)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
hooks := withoutManagedKiroIdeHooks(sources.document.hooks, "")
|
|
guard, err := buildKiroIdeHook(kiroIdeGuardName, nodePath, paths.guardPath)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
audit, err := buildKiroIdeHook(kiroIdeAuditName, nodePath, paths.auditPath)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
rendered, err := renderKiroIdeDocument(
|
|
sources.document,
|
|
append(hooks, guard, audit),
|
|
)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
prepared, err := prepareKiroIdeInstallation(config, sources, paths, rendered)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if err := commitKiroIdeInstallation(prepared, p.rename); err != nil {
|
|
return err
|
|
}
|
|
fmt.Printf("Kiro IDE workspace hooks: %s\n", sources.paths.configPath)
|
|
fmt.Println("Kiro IDE verification: confirm both Elydora entries in the Agent Hooks panel.")
|
|
return nil
|
|
}
|
|
|
|
func (p *KiroIdePlugin) Uninstall(agentID string) error {
|
|
sources, err := readKiroIdeSources()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
rendered, err := renderKiroIdeDocument(
|
|
sources.document,
|
|
withoutManagedKiroIdeHooks(sources.document.hooks, agentID),
|
|
)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
prepared, err := prepareKiroIdeUninstall(sources, rendered, agentID)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if err := commitKiroIdeUninstall(prepared, p.rename); err != nil {
|
|
return err
|
|
}
|
|
fmt.Println("Uninstalled Elydora hooks from Kiro IDE.")
|
|
return nil
|
|
}
|
|
|
|
func (p *KiroIdePlugin) Status() (PluginStatus, error) {
|
|
sources, err := readKiroIdeSources()
|
|
entry := SupportedAgents[kiroIdeAgentKey]
|
|
status := PluginStatus{
|
|
AgentName: kiroIdeAgentKey,
|
|
DisplayName: entry.Name,
|
|
ConfigPath: sourcesPathOrEmpty(sources),
|
|
}
|
|
if err != nil {
|
|
return status, err
|
|
}
|
|
if err := requireAvailableKiroIdeHooks(sources.document.hooks); err != nil {
|
|
return status, err
|
|
}
|
|
contracts, err := kiroIdeRuntimeContracts(sources.document.hooks)
|
|
if err != nil {
|
|
return status, err
|
|
}
|
|
status.HookConfigured = len(contracts) > 0
|
|
if !status.HookConfigured {
|
|
return status, nil
|
|
}
|
|
status.HookScriptExists, err = kiroIdeRuntimeFilesExist(contracts)
|
|
if err != nil {
|
|
return status, err
|
|
}
|
|
status.Installed = status.HookScriptExists
|
|
return status, nil
|
|
}
|
|
|
|
func sourcesPathOrEmpty(sources *kiroIdeSources) string {
|
|
if sources == nil {
|
|
return ""
|
|
}
|
|
return sources.paths.configPath
|
|
}
|