Skill Tracer
Skills › gstack › autoplan › tasks-aggregator.md

tasks-aggregator.md

71 lines · autoplan/sections/tasks-aggregator.md at 3f79d81

Open on GitHub

Most marks come from matching words in the file, so treat them as pointers.

1<!-- AUTO-GENERATED from tasks-aggregator.md.tmpl — do not edit directly -->
2<!-- Regenerate: bun run gen:skill-docs -->

<!-- AUTO-GENERATED from tasks-aggregator.md.tmpl — do not edit directly --> <!-- Regenerate: bun run gen:skill-docs -->

Raw lines 1 to 2
3## Implementation Tasks aggregator
4
5Before rendering the Final Approval Gate output block below, aggregate the
6per-phase task lists each review skill wrote.
7
8```bash
9GSTACK_STATE_ROOT=$(~/.claude/skills/gstack/bin/gstack-paths --get GSTACK_STATE_ROOT); : "${GSTACK_STATE_ROOT:?gstack-paths failed; reinstall with ./setup or /gstack-upgrade}"
10BRANCH=$(~/.claude/skills/gstack/bin/gstack-slug --get BRANCH 2>/dev/null)
11SLUG=$(~/.claude/skills/gstack/bin/gstack-slug --get SLUG 2>/dev/null)
12TASKS_DIR="$GSTACK_STATE_ROOT/projects/${SLUG:-unknown}"
13BRANCH=$(git branch --show-current 2>/dev/null || echo unknown)
14# Commit window: last 5 commits on this branch. Drops stale standalone reviews.
15COMMITS_RECENT=$(git log --format=%H -n 5 2>/dev/null | tr '\n' '|' | sed 's/|$//')
17AGGREGATED_TASKS=""
18if command -v jq >/dev/null 2>&1; then
19 # All 4 phases, scoped to this branch + commit window; latest run_id per
20 # phase; exact dedupe by (component, sorted(files), title); P1 > P2 > P3, then phase order.
21 ALL_JSONL=$(mktemp -t autoplan-tasks.XXXXXXXX)
22 for phase in ceo-review design-review eng-review devex-review; do
23 # find, not a glob: zsh nomatch errors when a phase wrote no JSONL. Sorted for stable order.
24 while IFS= read -r f; do
25 [ -f "$f" ] || continue
26 # .commit is bound BEFORE the pipe: a pipe rebinds jq's context, so a bare
27 # .commit after it indexes the array, every line errors, and the aggregate is empty.
28 jq -c --arg branch "$BRANCH" --arg commits "$COMMITS_RECENT" \
29 '.commit as $c | select(.branch == $branch and ($commits | split("|") | index($c) != null))' \
30 "$f" 2>/dev/null >> "$ALL_JSONL" || true
31 done < <(find "$TASKS_DIR" -maxdepth 1 -name "tasks-$phase-*.jsonl" 2>/dev/null | sort)
32 # Latest run_id per phase
33 if [ -s "$ALL_JSONL" ]; then
34 jq -sc --arg phase "$phase" \
35 '[.[] | select(.phase == $phase)] | (max_by(.run_id) // null) as $latest_run | if $latest_run then map(select(.run_id == $latest_run.run_id)) else [] end | .[]' \
36 "$ALL_JSONL" > "$ALL_JSONL.phase" 2>/dev/null || true
37 jq -c --arg phase "$phase" 'select(.phase != $phase)' "$ALL_JSONL" > "$ALL_JSONL.other" 2>/dev/null || true
38 cat "$ALL_JSONL.other" "$ALL_JSONL.phase" > "$ALL_JSONL"
39 rm -f "$ALL_JSONL.phase" "$ALL_JSONL.other"
40 fi
41 done
43 # Exact-match dedupe; non-matches stay separate (the renderer marks possible duplicates).
44 AGGREGATED_TASKS=$(jq -s \
45 'group_by([.component, (.files | sort), .title])
46 | map(
47 # Highest priority per group; tie-break by phase order
48 sort_by({P1:0,P2:1,P3:2}[.priority] // 99, {"ceo-review":0,"design-review":1,"eng-review":2,"devex-review":3}[.phase] // 99) | .[0]
49 )
50 | sort_by({P1:0,P2:1,P3:2}[.priority] // 99, {"ceo-review":0,"design-review":1,"eng-review":2,"devex-review":3}[.phase] // 99)
51 | if length == 0 then "_No actionable tasks emitted from any phase._" else
52 map("- [ ] **\(.id) (\(.priority), human: \(.effort_human) / CC: \(.effort_cc)) — \(.component)** — \(.title)\n - Surfaced by: \(.phase) — \(.source_finding)\n - Files: \(.files | join(", "))") | join("\n")
53 end' "$ALL_JSONL" 2>/dev/null | sed 's/^"//;s/"$//;s/\\n/\n/g')
54 rm -f "$ALL_JSONL"
55else
56 AGGREGATED_TASKS="_jq not installed — install jq to aggregate per-phase task lists. Skipping._"
57fi
58```
60In the Final Approval Gate output template below, render the aggregated markdown
61in the `### Implementation Tasks (aggregated across phases)` section: substitute
62`$AGGREGATED_TASKS` (the bash variable above) at runtime before printing the
63message; it is not a gen-skill-docs placeholder.
65If `$AGGREGATED_TASKS` is empty (no JSONL files found — none of the review
66skills ran in this session), render:
68`_No per-phase task lists found in $TASKS_DIR for branch $BRANCH. Each review
69skill writes its own; if you ran one of them but no list appears here, check
70that jq is installed and the tasks-<phase>-*.jsonl files exist._`

Implementation Tasks aggregator

Before rendering the Final Approval Gate output block below, aggregate the per-phase task lists each review skill wrote.

GSTACK_STATE_ROOT=$(~/.claude/skills/gstack/bin/gstack-paths --get GSTACK_STATE_ROOT); : "${GSTACK_STATE_ROOT:?gstack-paths failed; reinstall with ./setup or /gstack-upgrade}"
BRANCH=$(~/.claude/skills/gstack/bin/gstack-slug --get BRANCH 2>/dev/null)
SLUG=$(~/.claude/skills/gstack/bin/gstack-slug --get SLUG 2>/dev/null)
TASKS_DIR="$GSTACK_STATE_ROOT/projects/${SLUG:-unknown}"
BRANCH=$(git branch --show-current 2>/dev/null || echo unknown)
# Commit window: last 5 commits on this branch. Drops stale standalone reviews.
COMMITS_RECENT=$(git log --format=%H -n 5 2>/dev/null | tr '\n' '|' | sed 's/|$//')

AGGREGATED_TASKS=""
if command -v jq >/dev/null 2>&1; then
  # All 4 phases, scoped to this branch + commit window; latest run_id per
  # phase; exact dedupe by (component, sorted(files), title); P1 > P2 > P3, then phase order.
  ALL_JSONL=$(mktemp -t autoplan-tasks.XXXXXXXX)
  for phase in ceo-review design-review eng-review devex-review; do
    # find, not a glob: zsh nomatch errors when a phase wrote no JSONL. Sorted for stable order.
    while IFS= read -r f; do
      [ -f "$f" ] || continue
      # .commit is bound BEFORE the pipe: a pipe rebinds jq's context, so a bare
      # .commit after it indexes the array, every line errors, and the aggregate is empty.
      jq -c --arg branch "$BRANCH" --arg commits "$COMMITS_RECENT" \
        '.commit as $c | select(.branch == $branch and ($commits | split("|") | index($c) != null))' \
        "$f" 2>/dev/null >> "$ALL_JSONL" || true
    done < <(find "$TASKS_DIR" -maxdepth 1 -name "tasks-$phase-*.jsonl" 2>/dev/null | sort)
    # Latest run_id per phase
    if [ -s "$ALL_JSONL" ]; then
      jq -sc --arg phase "$phase" \
        '[.[] | select(.phase == $phase)] | (max_by(.run_id) // null) as $latest_run | if $latest_run then map(select(.run_id == $latest_run.run_id)) else [] end | .[]' \
        "$ALL_JSONL" > "$ALL_JSONL.phase" 2>/dev/null || true
      jq -c --arg phase "$phase" 'select(.phase != $phase)' "$ALL_JSONL" > "$ALL_JSONL.other" 2>/dev/null || true
      cat "$ALL_JSONL.other" "$ALL_JSONL.phase" > "$ALL_JSONL"
      rm -f "$ALL_JSONL.phase" "$ALL_JSONL.other"
    fi
  done

  # Exact-match dedupe; non-matches stay separate (the renderer marks possible duplicates).
  AGGREGATED_TASKS=$(jq -s \
    'group_by([.component, (.files | sort), .title])
     | map(
         # Highest priority per group; tie-break by phase order
         sort_by({P1:0,P2:1,P3:2}[.priority] // 99, {"ceo-review":0,"design-review":1,"eng-review":2,"devex-review":3}[.phase] // 99) | .[0]
       )
     | sort_by({P1:0,P2:1,P3:2}[.priority] // 99, {"ceo-review":0,"design-review":1,"eng-review":2,"devex-review":3}[.phase] // 99)
     | if length == 0 then "_No actionable tasks emitted from any phase._" else
         map("- [ ] **\(.id) (\(.priority), human: \(.effort_human) / CC: \(.effort_cc)) — \(.component)** — \(.title)\n  - Surfaced by: \(.phase) — \(.source_finding)\n  - Files: \(.files | join(", "))") | join("\n")
       end' "$ALL_JSONL" 2>/dev/null | sed 's/^"//;s/"$//;s/\\n/\n/g')
  rm -f "$ALL_JSONL"
else
  AGGREGATED_TASKS="_jq not installed — install jq to aggregate per-phase task lists. Skipping._"
fi

In the Final Approval Gate output template below, render the aggregated markdown in the ### Implementation Tasks (aggregated across phases) section: substitute $AGGREGATED_TASKS (the bash variable above) at runtime before printing the message; it is not a gen-skill-docs placeholder.

If $AGGREGATED_TASKS is empty (no JSONL files found — none of the review skills ran in this session), render:

_No per-phase task lists found in $TASKS_DIR for branch $BRANCH. Each review skill writes its own; if you ran one of them but no list appears here, check that jq is installed and the tasks-<phase>-*.jsonl files exist._

Raw lines 3 to 71
Names a skill review :6
Runs code bin/gstack-paths :9
Runs code bin/gstack-slug :10