Phase 1: go-io/go-log → core.Fs{}, core.E(), core.Error/Info/Warn
Phase 2: strings/fmt → core.Contains, core.Sprintf, core.Split etc
Phase 3: embed.FS → core.Mount/core.Embed, core.Extract
Phase 4: cmd/main.go → core.Command(), c.Cli().Run(), no cli package
All packages migrated:
- pkg/lib (Codex): core.Mount, core.Extract, Result returns, AX comments
- pkg/setup (Codex): core.Fs, core.E, fixed missing lib helpers
- pkg/brain (Codex): Core primitives, AX comments
- pkg/monitor (Codex): Core string/logging primitives
- pkg/agentic (Codex): 20 files, Core primitives throughout
- cmd/main.go: pure Core CLI, no fmt/log/filepath/strings/cli
Remaining stdlib: path/filepath (Core doesn't wrap OS paths),
fmt.Sscanf/strings.Map (no Core equivalent).
Co-Authored-By: Virgil <virgil@lethean.io>
51 lines
1.3 KiB
Go
51 lines
1.3 KiB
Go
// SPDX-License-Identifier: EUPL-1.2
|
|
|
|
package agentic
|
|
|
|
import (
|
|
"encoding/json"
|
|
"os"
|
|
"time"
|
|
|
|
core "dappco.re/go/core"
|
|
)
|
|
|
|
// CompletionEvent is emitted when a dispatched agent finishes.
|
|
// Written to ~/.core/workspace/events.jsonl as append-only log.
|
|
//
|
|
// event := agentic.CompletionEvent{Type: "agent_completed", Agent: "codex", Workspace: "go-io-123", Status: "completed"}
|
|
type CompletionEvent struct {
|
|
Type string `json:"type"`
|
|
Agent string `json:"agent"`
|
|
Workspace string `json:"workspace"`
|
|
Status string `json:"status"`
|
|
Timestamp string `json:"timestamp"`
|
|
}
|
|
|
|
// emitCompletionEvent appends a completion event to the events log.
|
|
// The plugin's hook watches this file to notify the orchestrating agent.
|
|
// Status should be the actual terminal state: completed, failed, or blocked.
|
|
func emitCompletionEvent(agent, workspace, status string) {
|
|
eventsFile := core.JoinPath(WorkspaceRoot(), "events.jsonl")
|
|
|
|
event := CompletionEvent{
|
|
Type: "agent_completed",
|
|
Agent: agent,
|
|
Workspace: workspace,
|
|
Status: status,
|
|
Timestamp: time.Now().UTC().Format(time.RFC3339),
|
|
}
|
|
|
|
data, err := json.Marshal(event)
|
|
if err != nil {
|
|
return
|
|
}
|
|
|
|
// Append to events log
|
|
f, err := os.OpenFile(eventsFile, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
|
|
if err != nil {
|
|
return
|
|
}
|
|
defer f.Close()
|
|
f.Write(append(data, '\n'))
|
|
}
|