Skill Tracer
Skills › Superpowers › subagent-driven-development › task-brief

task-brief

43 lines · skills/subagent-driven-development/scripts/task-brief at 2ce8aa1

1#!/usr/bin/env bash
2# Extract one task's full text from an implementation plan into a file the
3# implementer reads in one call, so the task text never has to be pasted
4# through the controller's context.
5#
6# Usage: task-brief PLAN_FILE TASK_NUMBER [OUTFILE]
7# Default OUTFILE: <repo-root>/.superpowers/sdd/<plan-basename>/task-<N>-brief.md
8# (per plan and per worktree; concurrent runs of the SAME plan in the same
9# working tree share it).
10set -euo pipefail
12if [ $# -lt 2 ] || [ $# -gt 3 ]; then
13 echo "usage: task-brief PLAN_FILE TASK_NUMBER [OUTFILE]" >&2
14 exit 2
15fi
17plan=$1
18n=$2
19[ -f "$plan" ] || { echo "no such plan file: $plan" >&2; exit 2; }
21if [ $# -eq 3 ]; then
22 out=$3
23else
24 # Invoke via bash rather than direct exec: some extractors (Python zipfile)
25 # strip Unix exec bits when unpacking marketplace packages (#2040).
26 dir=$("${BASH:-bash}" "$(cd "$(dirname "$0")" && pwd)/sdd-workspace" "$plan")
27 out="$dir/task-${n}-brief.md"
28fi
30awk -v n="$n" '
31 /^```/ { infence = !infence }
32 !infence && /^#+[ \t]+Task[ \t]+[0-9]+/ {
33 intask = ($0 ~ ("^#+[ \t]+Task[ \t]+" n "([^0-9]|$)"))
34 }
35 intask { print }
36' "$plan" > "$out"
38if [ ! -s "$out" ]; then
39 echo "task ${n} not found in ${plan} (no heading matching 'Task ${n}')" >&2
40 exit 3
41fi
43echo "wrote ${out}: $(wc -l < "$out" | tr -d ' ') lines"