Skip to content

feat(gen-idea): directed-swarm idea drafting command (1.16.1) - #99

Merged
SihaoLiu merged 15 commits into
PolyArch:devfrom
shinan6:add-gen-idea-command
Apr 21, 2026
Merged

feat(gen-idea): directed-swarm idea drafting command (1.16.1)#99
SihaoLiu merged 15 commits into
PolyArch:devfrom
shinan6:add-gen-idea-command

Conversation

@shinan6

@shinan6 shinan6 commented Apr 20, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds /humanize:gen-idea: takes a loose idea (inline text or .md file) and produces a repo-grounded draft suitable as input to /humanize:gen-plan.
  • Applies the directed-diversity pattern from Anthropic's Automated W2S Researcher note: a lead picks N orthogonal directions, N parallel Explore subagents develop each with objective repo evidence, the lead synthesizes one primary + N-1 alternatives.
  • First pass is deliberately lightweight: no Codex, no relevance check, no config-loader integration, no auto-chain to gen-plan, no test harness. Each carve-out is listed in the design spec's "Out of Scope" section.
  • Version bumped 1.16.01.16.1 across plugin.json, marketplace.json, and the README header.

What ships

  • commands/gen-idea.md — slash-command spec (five phases: parse → validate → direction generation → parallel exploration → synthesize + write).
  • prompt-template/idea/gen-idea-template.md — output draft skeleton with nine placeholders.
  • scripts/validate-gen-idea-io.sh — bash IO validation + slug + default-path resolution. Exit codes parallel validate-gen-plan-io.sh. Includes short-idea warning, macOS realpath fallback, and a deliberate no-trap tempfile contract documented inline.
  • README.md — new Quick Start step (step 1) above gen-plan; version header to 1.16.1.
  • docs/superpowers/specs/2026-04-20-gen-idea-design.md + docs/superpowers/plans/2026-04-20-gen-idea.md — design + implementation plan used to drive this change.

Command signature

/humanize:gen-idea <idea-text-or-path> [--n 6] [--output <path>]

Positional arg auto-detects inline text vs existing .md file. --n is [2, 10], default 6. --output defaults to .humanize/ideas/<slug>-<YYYYMMDD-HHMMSS>.md and refuses to overwrite.

Test plan

  • Shell syntax clean (bash -n scripts/validate-gen-idea-io.sh).
  • JSON validity preserved for plugin.json and marketplace.json.
  • All ten Task 2 smoke-test exit codes match plan expectations (happy paths inline + file; MISSING_IDEA, N_OUT_OF_RANGE, INVALID_N, INPUT_NOT_FOUND, INPUT_NOT_MD, INPUT_EMPTY, OUTPUT_EXISTS, OUTPUT_DIR_NOT_FOUND).
  • Two-stage review per task: spec compliance + code quality, with loops closing Critical/Important findings (macOS realpath fallback, BSD mktemp template, Alt-N numbering scheme, sentinel rendering, Hard-Constraint carve-out, short-idea warning).
  • Integration sanity: script stdout keys, command parser, template placeholders, and exit-code table are contract-aligned across all three artifacts.
  • End-to-end live run against a real repo idea (add a /humanize:list-loops command that shows all active RLCR and PR loops with state and elapsed time, --n 4): draft produced at .humanize/ideas/...md with one primary direction plus three alternatives, every alt carrying concrete repo line-range evidence; idea preserved verbatim; the exploratory, no concrete precedent sentinel correctly surfaced where appropriate.
  • CI test suite (tests/run-all-tests.sh) — requires bash 4+; validated locally on macOS bash 3.2 only via shell-syntax + JSON + version checks. CI will run the full suite on Linux.
  • Live install verification: reviewer installs the branch, invokes /humanize:gen-idea "...", and confirms the five-phase flow renders a valid draft that passes through /humanize:gen-plan --input <draft> without human edits.

Out of scope (tracked in the design spec for future passes)

  • Codex pass over the synthesized draft.
  • --chain-to-gen-plan flag for auto-handoff.
  • --directions override for user-pinned angles.
  • Config-loader integration for alternative-language draft variants.
  • Upstream relevance check mirroring gen-plan Phase 2.

🤖 Generated with Claude Code

shinan6 and others added 10 commits April 20, 2026 12:30
Introduces a design document for a new /humanize:gen-idea command that
sits one step before gen-plan in the Humanize workflow. The command
applies the directed-diversity insight from Anthropic's Automated W2S
Researcher note: a lead picks N orthogonal directions and delegates one
direction per Explore subagent, then synthesizes a repo-grounded draft
suitable as gen-plan input.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Five-task plan covering the draft template, IO validation script,
command spec, README/version bumps, and an end-to-end smoke check.
Targets dev for the 1.16.1 release.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Skeleton populated by the command's Phase 4 synthesis step. Placeholders
<TITLE>, <ORIGINAL_IDEA>, <PRIMARY_*>, <ALTERNATIVES>, <SYNTHESIS_NOTES>
are filled deterministically by the command body.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Detects inline vs .md file input, writes inline text to a tempfile so
downstream phases always consume a file, derives a URL-safe slug, and
resolves the default output path under .humanize/ideas/. Exit codes
parallel validate-gen-plan-io.sh.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Two corrections required to pass macOS smoke tests:
- Path heuristic now treats slashes as path-indicating only when no
  whitespace is present, so inline ideas like "add undo/redo" are not
  misread as paths.
- mktemp template drops the .md suffix (BSD mktemp does not support
  a suffix after the X template).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Code-quality review surfaced three items on the IO validation script:
- Guard `realpath $IDEA_INPUT` with a fallback so older macOS does not
  trip `set -e` on the file-input branch.
- Comment explaining the caller owns tempfile cleanup (no trap) so a
  future maintainer does not silently break the caller.
- Comment clarifying the path-vs-inline heuristic and its limitation
  (a non-existent path with spaces falls through to inline mode).

The plan's literal script copy is updated to match.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Five-phase command: parse, validate via scripts/validate-gen-idea-io.sh,
generate N orthogonal directions grounded in repo context, fan out N
parallel Explore subagents in a single Task-tool message, synthesize
one primary plus N-1 alternatives into the new template, write the
draft. No Codex, no tests, no config-loader integration in this pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Five documentation patches to commands/gen-idea.md (and the mirrored
copy in the plan doc):
- State that degraded runs renumber surviving alternatives Alt-1..Alt-K
  sequentially rather than preserving source-index gaps.
- Specify the rendering of the `exploratory, no concrete precedent`
  sentinel as a single bullet when it is the sole evidence.
- Note that the Hard Constraint permits the validation script's
  prerequisite `.humanize/ideas/` directory creation.
- Bold the Sequential Execution Constraint label for style parity with
  gen-plan.md.
- Pin the Phase 2 context paths (README.md, CLAUDE.md, .claude/CLAUDE.md)
  to the project root via `git rev-parse --show-toplevel`.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Add a Quick Start entry for /humanize:gen-idea above the existing
gen-plan step and sync version across plugin.json, marketplace.json,
and the README header.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Address final-review findings:
- Implement the spec's warn-and-continue behavior for inline ideas
  shorter than 10 characters by emitting a `WARNING: short idea ...`
  line on stdout before VALIDATION_SUCCESS. The command spec documents
  this as a non-error informational line that should be surfaced to
  the user but does not block Phase 2.
- Note in Phase 1 that SLUG is informational; it is already baked into
  OUTPUT_FILE by the script and does not need to be consumed directly
  by later phases.
- Mirror both edits into the plan doc copies.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1adeca421e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread scripts/validate-gen-idea-io.sh Outdated
Comment on lines +96 to +97
if [[ "$IDEA_INPUT" == *.md ]]; then
looks_like_path=true

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Treat non-existent .md text as inline input

Any argument ending in .md is forced into looks_like_path=true, so inline ideas such as "rename README.md" fail with INPUT_NOT_FOUND when no file exists. This blocks valid prompts that merely mention a markdown filename and contradicts the command’s advertised auto-detection behavior of using file mode only when an existing .md path is provided.

Useful? React with 👍 / 👎.

looks_like_path=true
fi

if [[ -f "$IDEA_INPUT" ]]; then

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reject unreadable markdown input files

The file-input branch validates existence, extension, and non-empty content but never checks readability, so an unreadable .md can pass validation and then fail later when the command reads IDEA_BODY_FILE. That bypasses the documented exit-code path for “missing/not readable” input and produces a less actionable runtime failure for users.

Useful? React with 👍 / 👎.

An argument ending in .md was unconditionally classified as a path, so
inline ideas that mention a markdown filename (for example
"rename README.md") failed validation with INPUT_NOT_FOUND instead of
being accepted as inline text.

Gate the .md heuristic on the same "no whitespace" rule the "/" branch
already applied. Ideas with any whitespace fall through to inline mode,
while clean strings like "./idea.md" or "path/to/idea.md" still surface
a helpful INPUT_NOT_FOUND error when the file is absent.
The file-input branch validated existence, .md extension, and non-empty
content but never checked readability. An unreadable regular .md file
passed validation and then triggered a less actionable runtime failure
when the command itself tried to read IDEA_BODY_FILE.

Insert an -r readability check between the extension and emptiness
checks. Emit VALIDATION_ERROR: INPUT_NOT_READABLE with exit 2, aligning
with the advertised exit-code path ("missing, not readable, or not .md")
in the command spec.
@SihaoLiu

Copy link
Copy Markdown
Contributor

@codex review this PR as entirety

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 04116b90ce

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread scripts/validate-gen-idea-io.sh Outdated
Comment on lines +129 to +133
# Deliberately no `trap ... EXIT` to remove TMPFILE: the caller consumes
# IDEA_BODY_FILE after this script exits, so a naive trap would delete
# the file the caller needs. On error paths the tempfile is leaked in
# $TMPDIR; the OS sweeps $TMPDIR on reboot and the cost is negligible.
TMPFILE="$(mktemp "${TMPDIR:-/tmp}/gen-idea-inline-XXXXXX")"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Remove leaked inline idea tempfiles

Inline mode writes every idea into a new mktemp file and explicitly avoids deleting it, so each /humanize:gen-idea run leaves another file in /tmp containing user-provided idea text. On long-lived developer machines or CI workers this creates unbounded tempfile growth and retains potentially sensitive ideas beyond command completion; this should be cleaned up via an explicit caller-side delete contract (or equivalent success/failure cleanup path).

Useful? React with 👍 / 👎.

Inline mode created a per-run mktemp file under TMPDIR and deliberately
left it in place so the caller could read it after the script exited.
On long-lived developer machines or CI workers this produced unbounded
tempfile growth and retained user-provided idea text on disk beyond
command completion.

Eliminate the tempfile entirely. The script now emits the inline idea
body on stdout between the literal sentinel lines "=== IDEA_BODY_BEGIN
==="  and "=== IDEA_BODY_END ===". The caller extracts the body from
that block when INPUT_MODE is inline, and still reads IDEA_BODY_FILE
from disk in file mode. IDEA_BODY_FILE is now only emitted in file
mode; stdout contract for inline mode gains the sentinel block but
drops the on-disk handoff.

Update commands/gen-idea.md to document the new mode-aware body
retrieval and to reference the in-memory IDEA_BODY value in the Phase 3
subagent prompt and Phase 4 template placeholder.
@SihaoLiu

Copy link
Copy Markdown
Contributor

@codex review this PR as entirety

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@SihaoLiu
SihaoLiu merged commit 179a87c into PolyArch:dev Apr 21, 2026
4 checks passed
@SihaoLiu SihaoLiu mentioned this pull request Apr 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants