Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
149 changes: 149 additions & 0 deletions .github/workflows/idea-enhancer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
# ─────────────────────────────────────────────────────────────────────────────
# Idea Enhancer — enriches human-authored Ideas Discussions
#
# When a human opens an Ideas Discussion (or periodically on a schedule), an
# analyst pass reads the idea, researches it, and posts ONE enhancement comment:
# clarifying framing, market/competitive context, a sharper problem statement,
# impact/effort, and concrete acceptance criteria. A hidden marker is appended so
# the same idea is never enhanced twice (idempotent across runs).
#
# This complements feature-ideation.yml (which generates NEW idea Discussions):
# that pipeline never enriches human-added items, which is what this closes.
#
# Pipeline position:
# ★ human opens an Ideas Discussion ──> THIS (enhance comment) ──┐
# feature-ideation (new Ideas) ─────────────────────────────┤
# -> idea-triage (shortlist) -> ★ human adds idea:approved │
# -> initiative-planner -> ★ human adds initiative:auto │
# -> initiative-driver -> dev-lead <───────────────────────────────┘
#
# Org-private automation (like idea-triage.yml / initiative-planner.yml) — NOT a
# thin caller stub. The tooling lives in scripts/idea-enhancer/ and is unit-tested
# (tests/test_idea_enhancer.bats).
# ─────────────────────────────────────────────────────────────────────────────
name: Idea Enhancer

on:
discussion:
types: [created]
schedule:
- cron: '0 7 * * 3' # Wednesday 07:00 UTC — safety net between ideation (Fri) and triage (Mon)
workflow_dispatch:
inputs:
dry_run:
description: 'Log intended enhancement comments to an artifact instead of posting them'
required: false
default: false
type: boolean
model:
description: 'Anthropic model id for the enhancement pass'
required: false
default: 'claude-sonnet-4-6'
type: string

permissions: {}

concurrency:
group: idea-enhancer
cancel-in-progress: false

jobs:
enhance:
runs-on: ubuntu-latest
timeout-minutes: 20
permissions:
contents: read # checkout
discussions: write # read the Ideas backlog + post enhancement comments
id-token: write # claude-code-action OIDC
env:
REPO: ${{ github.repository }}
DRY_RUN: ${{ inputs.dry_run && '1' || '0' }}
# Empty for schedule/dispatch (scan all); the created discussion's number
# for the `discussion` trigger (enhance just that one, immediately).
DISCUSSION_NUMBER: ${{ github.event.discussion.number }}
steps:
- name: Checkout agent repo
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
persist-credentials: false

- name: Set temp paths
run: |
echo "DRY_RUN_LOG=${{ runner.temp }}/dry-run.jsonl" >> "$GITHUB_ENV"
echo "CONTEXT_PATH=${{ runner.temp }}/candidates.json" >> "$GITHUB_ENV"

- name: Gather enhancement candidates
id: gather
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
bash scripts/idea-enhancer/gather-candidates.sh
echo "count=$(jq '.candidates | length' "$CONTEXT_PATH")" >> "$GITHUB_OUTPUT"

- name: Enhance each candidate idea
if: ${{ steps.gather.outputs.count != '0' }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: anthropics/claude-code-action@787c5a0ce96a9a6cfb050ea0c8f4c05f2447c251 # v1.0.133
with:
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
github_token: ${{ secrets.GITHUB_TOKEN }}
claude_args: |
--model ${{ inputs.model || 'claude-sonnet-4-6' }}
--allowedTools Bash,Read,Glob,Grep
prompt: |
You are the **idea-enhancer analyst** for the ${{ github.repository }} repo.
Your job: for each candidate Idea Discussion, post exactly ONE comment that
makes the idea more actionable. You do NOT approve, label, or promote
anything — that stays with a human and the triage/planner pipeline.

## Input

The candidate set is at `$CONTEXT_PATH` (JSON): `repo`, the idempotency
`marker`, and `candidates[]` (each with number, title, url, author,
timestamps, comment count, labels, and an excerpt of the idea body). Read it:

```bash
cat "$CONTEXT_PATH" | jq .
```

Every candidate is an open, human-authored Ideas Discussion that has not
yet been enhanced. If `candidates` is empty, do nothing and stop.

Use Read/Grep/Glob on the checkout (`AGENTS.md`, `docs/`, `scripts/`,
`.github/workflows/`) and the feature-ideator profile
(`agents/feature-ideator.md`) to ground each enhancement in what this repo
actually does. Favor ideas that leverage existing infrastructure.

## For each candidate

Draft a concise enhancement comment (GitHub Markdown) to a temp file, then
post it. Structure the comment as:
- **Sharpened problem & goal** — restate the idea crisply; note any
ambiguity worth the author clarifying.
- **Context** — relevant prior art in this repo, related initiatives, or
market/competitive signal (cite sources if you researched the web).
- **Impact / Effort** — HIGH/MEDIUM/LOW and S/M/L/XL, with one line of why.
- **Suggested acceptance criteria** — 2–5 specific, testable bullets.
- Keep it constructive and brief; you are augmenting a human's idea, not
replacing it.

Then post it (the script appends the idempotency marker for you; honors
`$DRY_RUN`):

```bash
REPO="${{ github.repository }}" DISCUSSION_NUMBER="<number>" \
BODY_PATH="<your-draft-file>" \
bash scripts/idea-enhancer/post-enhancement.sh
```

Process every candidate. Finish with a 2–3 line summary of how many ideas
you enhanced.

- name: Upload dry-run enhancement log
if: ${{ env.DRY_RUN == '1' }}
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: idea-enhancer-dry-run
path: ${{ runner.temp }}/dry-run.jsonl
if-no-files-found: warn
1 change: 1 addition & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ jobs:
tests/test_gitleaks_config.bats \
tests/test_initiative_planner.bats \
tests/test_idea_triage.bats \
tests/test_idea_enhancer.bats \
tests/test_oversized_pr.bats \
tests/test_apply_repo_settings.bats

Expand Down
16 changes: 16 additions & 0 deletions docs/initiatives/idea-to-initiative-pipeline.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,22 @@ Both are **org-private automation** (like `initiative-driver.yml`), not thin
caller stubs. Tooling and the vendored BMAD personas live in this repo and are
unit-tested.

### `idea-enhancer.yml` — enrich human-authored ideas
- Trigger: a Discussion is **created** (enhance that one immediately), a weekly
**schedule** (safety-net sweep of the backlog), or manual `workflow_dispatch`
(`dry_run` logs intended comments to an artifact).
- Closes the gap where `feature-ideation` only ever generates *new* idea
Discussions and never enriches the ones a human adds. For each open,
human-authored, not-yet-enhanced **Ideas** Discussion it posts **one** comment
(sharpened problem/goal, repo + market context, impact/effort, suggested
acceptance criteria). Bot-authored ideas are skipped — they are already
AI-generated.
- Idempotent: each enhancement comment carries a hidden marker
(`<!-- idea-enhancer:enhanced -->`); a discussion that already has one is never
re-enhanced. It never approves, labels, or promotes — that stays with triage
and the human gates.
- Tooling: `scripts/idea-enhancer/{gather-candidates,post-enhancement}.sh`.

### `idea-triage.yml` — weekly ripeness shortlist
- Scans every open **Ideas** Discussion, scores each **Ripe / Soon / Not yet**
on evidence, prerequisites, alignment, coverage, and freshness.
Expand Down
118 changes: 118 additions & 0 deletions scripts/idea-enhancer/gather-candidates.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
#!/usr/bin/env bash
# gather-candidates.sh — find open "Ideas" Discussions that are worth an
# automated enhancement pass: human-authored, not closed, and not yet enhanced
# (i.e. no prior comment carrying the idempotency marker).
#
# Emits $CONTEXT_PATH (JSON): { repo, marker, candidates: [ {number, title, url,
# author, createdAt, updatedAt, comments, labels, excerpt}, ... ] }. The enhancer
# agent reads it and posts one enhancement comment per candidate.
#
# Bot-authored ideas are skipped: those come from the feature-ideation run and
# are already AI-generated, so the human-added items are the ones that benefit.
#
# Env:
# REPO owner/repo (required)
# CONTEXT_PATH output JSON path (required)
# DISCUSSION_NUMBER restrict to a single discussion (optional; used by the
# `discussion: created` trigger so a new human idea is
# enhanced immediately)
# ENHANCER_MARKER idempotency marker (default below; must match post-enhancement.sh)
# GH_TOKEN token for gh
set -euo pipefail

REPO="${REPO:?REPO required}"
Comment thread
don-petry marked this conversation as resolved.
Resolved
if [[ "$REPO" != */* ]]; then
echo "::error::REPO must be in 'owner/repo' format" >&2
exit 1
fi
CONTEXT_PATH="${CONTEXT_PATH:?CONTEXT_PATH required}"
MARKER="${ENHANCER_MARKER:-<!-- idea-enhancer:enhanced -->}"
ONLY="${DISCUSSION_NUMBER:-}"

owner="${REPO%/*}"
name="${REPO#*/}"

all="[]"

if [[ -n "$ONLY" ]]; then
page="$(gh api graphql \
-f query='
query($owner:String!,$name:String!,$number:Int!){
repository(owner:$owner,name:$name){
discussion(number:$number){
number title url createdAt updatedAt closed
category{ name }
author{ login __typename }
labels(first:20){ nodes{ name } }
comments(first:100){ totalCount nodes{ body author{ login } } }
bodyText
}
}
}' \
-F owner="$owner" -F name="$name" -F number="$ONLY")"

all="$(printf '%s' "$page" | jq --arg marker "$MARKER" '
[.data.repository.discussion
| select(. != null)
| select(.category.name == "Ideas")
| select(.closed == false)
| select((.author.__typename // "User") != "Bot")
| select(((.author.login) // "") | endswith("[bot]") | not)
| select([.comments.nodes[]? | select((.body // "") | contains($marker))] | length == 0)
| {number, title, url,
author: ((.author.login) // "unknown"),
createdAt, updatedAt,
comments: .comments.totalCount,
labels: [.labels.nodes[].name],
excerpt: (.bodyText[0:600])}]')"
else
cursor=""
has_next="true"

while [[ "$has_next" = "true" ]]; do
extra_args=()
[[ -n "$cursor" ]] && extra_args+=(-F after="$cursor")

page="$(gh api graphql \
-f query='
query($owner:String!,$name:String!,$after:String){
repository(owner:$owner,name:$name){
discussions(first:50, after:$after, orderBy:{field:UPDATED_AT, direction:DESC}){
pageInfo{ hasNextPage endCursor }
nodes{
number title url createdAt updatedAt closed
category{ name }
author{ login __typename }
labels(first:20){ nodes{ name } }
comments(first:100){ totalCount nodes{ body author{ login } } }
bodyText
}
}
}
}' \
-F owner="$owner" -F name="$name" "${extra_args[@]}")"

nodes="$(printf '%s' "$page" | jq --arg marker "$MARKER" '
[.data.repository.discussions.nodes[]
| select(.category.name == "Ideas")
| select(.closed == false)
| select((.author.__typename // "User") != "Bot")
| select(((.author.login) // "") | endswith("[bot]") | not)
| select([.comments.nodes[]? | select((.body // "") | contains($marker))] | length == 0)
| {number, title, url,
author: ((.author.login) // "unknown"),
createdAt, updatedAt,
comments: .comments.totalCount,
labels: [.labels.nodes[].name],
excerpt: (.bodyText[0:600])}]')"
all="$(jq -n --argjson a "$all" --argjson b "$nodes" '$a + $b')"

has_next="$(printf '%s' "$page" | jq -r '.data.repository.discussions.pageInfo.hasNextPage')"
cursor="$(printf '%s' "$page" | jq -r '.data.repository.discussions.pageInfo.endCursor // ""')"
done
fi
Comment thread
don-petry marked this conversation as resolved.
Resolved

jq -n --arg repo "$REPO" --arg marker "$MARKER" --argjson candidates "$all" \
'{repo: $repo, marker: $marker, candidates: $candidates}' >"$CONTEXT_PATH"

echo "context written to ${CONTEXT_PATH} (candidates=$(printf '%s' "$all" | jq 'length'))"
68 changes: 68 additions & 0 deletions scripts/idea-enhancer/post-enhancement.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#!/usr/bin/env bash
# post-enhancement.sh — post a single enhancement comment to an Ideas Discussion.
# Appends an idempotency marker so a later gather-candidates pass skips the idea
# (one enhancement per idea, re-run safe). Honors DRY_RUN.
#
# Env:
# REPO owner/repo (required)
# DISCUSSION_NUMBER discussion to comment on (required)
# BODY_PATH file holding the enhancement markdown (required)
# ENHANCER_MARKER idempotency marker (default below; must match gather-candidates.sh)
# DRY_RUN / DRY_RUN_LOG "1" => log the intended comment instead of posting
# GH_TOKEN token for gh
set -euo pipefail

REPO="${REPO:?REPO required}"
Comment thread
don-petry marked this conversation as resolved.
Resolved
if [[ "$REPO" != */* ]]; then
echo "::error::REPO must be in 'owner/repo' format" >&2
exit 1
fi
DISCUSSION_NUMBER="${DISCUSSION_NUMBER:?DISCUSSION_NUMBER required}"
BODY_PATH="${BODY_PATH:?BODY_PATH required}"
MARKER="${ENHANCER_MARKER:-<!-- idea-enhancer:enhanced -->}"

[[ -s "$BODY_PATH" ]] || { echo "::error::enhancement body '$BODY_PATH' missing or empty" >&2; exit 1; }

owner="${REPO%/*}"
name="${REPO#*/}"

# Final comment = the drafted enhancement + the marker on its own line.
body="$(printf '%s\n\n%s\n' "$(cat "$BODY_PATH")" "$MARKER")"

_is_dry_run() { [[ "${DRY_RUN:-0}" = "1" ]]; }

if _is_dry_run; then
jq -nc --arg op post_enhancement --argjson number "$DISCUSSION_NUMBER" \
--arg body "$body" '{op:$op, number:$number, body_len:($body|length)}' \
>>"${DRY_RUN_LOG:-./dry-run.jsonl}"
echo "[dry-run] would comment on discussion #${DISCUSSION_NUMBER}"
exit 0
fi

# Resolve the discussion's node id, then add the comment via GraphQL.
discussion_id="$(gh api graphql \
-f query='
query($owner:String!,$name:String!,$number:Int!){
repository(owner:$owner,name:$name){
discussion(number:$number){ id }
}
}' \
-F owner="$owner" -F name="$name" -F number="$DISCUSSION_NUMBER" \
--jq '.data.repository.discussion.id')"

if [[ -z "$discussion_id" || "$discussion_id" = "null" ]]; then
echo "::error::could not resolve discussion #${DISCUSSION_NUMBER} in ${REPO}" >&2
exit 1
fi

gh api graphql \
-f query='
mutation($discussionId:ID!,$body:String!){
addDiscussionComment(input:{discussionId:$discussionId, body:$body}){
comment{ url }
}
}' \
-F discussionId="$discussion_id" -F body="$body" \
--jq '.data.addDiscussionComment.comment.url'

echo "enhanced discussion #${DISCUSSION_NUMBER}"
Loading
Loading