diff --git a/executor.lua b/executor.lua index 10c6b28..76927e2 100644 --- a/executor.lua +++ b/executor.lua @@ -166,4 +166,25 @@ function M.extract_delegate_lines(text) return out end +-- Phase 10 / #89: extract `TASK: ` lines from a cloud +-- preplanner's response. Wire contract for the planning/executor +-- split: cloud emits a list of imperative TASKs once per :norris +-- launch, local model executes each. +-- +-- More permissive than extract_cmd_lines: tolerates leading +-- whitespace (cloud models often indent) AND leading whitespace +-- after the colon, AND strips trailing whitespace. Strict only on +-- the literal "TASK:" prefix. +-- +-- Returns an array of strings (already trimmed); empty TASKs and +-- non-TASK lines are dropped silently. +function M.extract_task_lines(text) + local out = {} + for line in (text or ""):gmatch("[^\n]+") do + local task = line:match("^%s*TASK:%s*(.-)%s*$") + if task and task:match("%S") then out[#out + 1] = task end + end + return out +end + return M