Add DriftJudge AI role with verdict parsing
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -42,3 +42,33 @@ Rules:
|
||||
|
||||
User intent: ` + intent
|
||||
}
|
||||
|
||||
// DriftJudge decides whether the current window is on-task for a commitment.
|
||||
// It takes primitives, not domain/evidence types, so ai stays a leaf package.
|
||||
type DriftJudge interface {
|
||||
JudgeDrift(ctx context.Context, commitment, windowClass, windowTitle string) (Verdict, error)
|
||||
}
|
||||
|
||||
// JudgeDrift makes Service satisfy DriftJudge over the same backend as Coach.
|
||||
func (s *Service) JudgeDrift(ctx context.Context, commitment, windowClass, windowTitle string) (Verdict, error) {
|
||||
out, err := s.backend.Run(ctx, buildDriftPrompt(commitment, windowClass, windowTitle))
|
||||
if err != nil {
|
||||
return Verdict{}, err
|
||||
}
|
||||
return parseVerdict(out)
|
||||
}
|
||||
|
||||
func buildDriftPrompt(commitment, class, title string) string {
|
||||
return `You are a focus monitor. The user committed to a task. Decide whether their CURRENT window is on-task or a distraction.
|
||||
|
||||
Respond with ONLY a JSON object, no prose and no code fences, exactly this shape:
|
||||
{"on_task": <true or false>, "reason": "<short explanation, one sentence>"}
|
||||
|
||||
Rules:
|
||||
- on_task: true if the window plausibly serves the commitment, false if it is a distraction.
|
||||
- reason: one short sentence. REQUIRED when on_task is false.
|
||||
|
||||
Commitment: ` + commitment + `
|
||||
Current window class: ` + class + `
|
||||
Current window title: ` + title
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user