opencode-autopilot
Advanced tools
| import type { Task } from "./backlog.js"; | ||
| export interface ValidationIssue { | ||
| field: string; | ||
| question: string; | ||
| } | ||
| export declare function validateTask(task: Partial<Task>): ValidationIssue[]; | ||
| export declare function formatValidationQuestions(task: Partial<Task>, issues: ValidationIssue[]): string; |
| export function validateTask(task) { | ||
| const issues = []; | ||
| if (!task.title || task.title.length < 10) { | ||
| issues.push({ | ||
| field: "title", | ||
| question: "What specifically needs to be done? The title should describe the deliverable, not just the area.", | ||
| }); | ||
| } | ||
| if (!task.description || task.description.length < 50) { | ||
| issues.push({ | ||
| field: "description", | ||
| question: "What is the expected behavior after this task is done? Include: what changes, where, and how to verify it works.", | ||
| }); | ||
| } | ||
| const desc = (task.description || "").toLowerCase(); | ||
| // Vague descriptions | ||
| const vaguePatterns = [ | ||
| { pattern: /\bfix\b.*\bbug\b/i, without: /\b(when|if|because|error|crash|fails?)\b/i }, | ||
| { pattern: /\bimprove\b/i, without: /\b(by|from|to|currently|should)\b/i }, | ||
| { pattern: /\brefactor\b/i, without: /\b(extract|split|merge|move|rename|into|from)\b/i }, | ||
| { pattern: /\bupdate\b/i, without: /\b(from|to|version|because|add|remove)\b/i }, | ||
| { pattern: /\bclean\s?up\b/i, without: /\b(remove|delete|extract|replace)\b/i }, | ||
| ]; | ||
| for (const { pattern, without } of vaguePatterns) { | ||
| if (pattern.test(desc) && !without.test(desc)) { | ||
| issues.push({ | ||
| field: "description", | ||
| question: `"${task.title}" is vague. What is the current behavior vs expected behavior? What concrete change should be made?`, | ||
| }); | ||
| break; | ||
| } | ||
| } | ||
| // Missing scope for implementation tasks | ||
| const isImplementation = /\b(add|create|build|implement|write)\b/i.test(desc); | ||
| if (isImplementation && !task.scope?.files?.length && !task.scope?.directories?.length) { | ||
| issues.push({ | ||
| field: "scope.files", | ||
| question: "Which files or directories should be modified? Defining file scope prevents the agent from touching unrelated code.", | ||
| }); | ||
| } | ||
| // Missing acceptance criteria | ||
| if (!task.scope?.acceptanceCriteria?.length) { | ||
| issues.push({ | ||
| field: "scope.acceptanceCriteria", | ||
| question: "How do you verify this task is done? List 1-3 concrete acceptance criteria (e.g., 'API returns 429 after 100 requests', 'existing tests pass').", | ||
| }); | ||
| } | ||
| // Overly broad scope | ||
| if (task.scope?.directories?.length && task.scope.directories.some((d) => d === "." || d === "src" || d === "/")) { | ||
| issues.push({ | ||
| field: "scope.directories", | ||
| question: 'The scope includes the entire project. Which specific subdirectory does this task affect? (e.g., "src/api/routes" not "src")', | ||
| }); | ||
| } | ||
| return issues; | ||
| } | ||
| export function formatValidationQuestions(task, issues) { | ||
| if (issues.length === 0) | ||
| return ""; | ||
| const lines = [ | ||
| `### Clarification needed for: "${task.title || "Untitled task"}"`, | ||
| "", | ||
| "Before adding this to the backlog, please clarify:", | ||
| "", | ||
| ]; | ||
| for (let i = 0; i < issues.length; i++) { | ||
| lines.push(`${i + 1}. ${issues[i].question}`); | ||
| } | ||
| return lines.join("\n"); | ||
| } |
+1
-0
@@ -6,1 +6,2 @@ import type { Plugin } from "@opencode-ai/plugin"; | ||
| export { loadMetrics, saveMetrics, recordMetric, getDispatchedToday, formatStats, type MetricEvent, type Metrics, } from "./metrics.js"; | ||
| export { validateTask, formatValidationQuestions, type ValidationIssue, } from "./validate.js"; |
+1
-0
@@ -318,1 +318,2 @@ import { mkdirSync, existsSync } from "fs"; | ||
| export { loadMetrics, saveMetrics, recordMetric, getDispatchedToday, formatStats, } from "./metrics.js"; | ||
| export { validateTask, formatValidationQuestions, } from "./validate.js"; |
+1
-1
| { | ||
| "name": "opencode-autopilot", | ||
| "version": "0.2.0", | ||
| "version": "0.3.0", | ||
| "description": "Autonomous task orchestration for OpenCode — centralized backlog, auto-dispatch, session lifecycle, telemetry", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
30168
13.57%13
18.18%636
14.18%