Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
115 commits
Select commit Hold shift + click to select a range
29a528f
Add methodology analysis phase for RLCR loop exit
SihaoLiu Mar 13, 2026
d3ded24
Fix methodology analysis completion: require report and fail closed
SihaoLiu Mar 13, 2026
7282f6e
Fix read validator to allow historical round access during methodolog…
SihaoLiu Mar 13, 2026
50e8bbb
Harden methodology analysis read bypass with path canonicalization an…
SihaoLiu Mar 13, 2026
f34d45f
Enforce read-only project files during methodology analysis phase
SihaoLiu Mar 13, 2026
87687a2
Fix spawned agent bypass and broaden bash restriction coverage
SihaoLiu Mar 13, 2026
9888044
Fix realpath for non-existent files and narrow gh allowlist
SihaoLiu Mar 13, 2026
4c48209
Block project-root reads and interpreters during methodology analysis
SihaoLiu Mar 13, 2026
786ed32
Block shell entry points and fix concurrent session binding in method…
SihaoLiu Mar 13, 2026
f2a12c6
Allow cancel script during methodology analysis, remove gh issue earl…
SihaoLiu Mar 13, 2026
7b91c47
Scope methodology fallback to spawned agents only, add missing git su…
SihaoLiu Mar 13, 2026
3c85332
Remove cross-session methodology fallback, add realpath raw path fall…
SihaoLiu Mar 13, 2026
5c123c2
Expand methodology bash blocklist, require non-empty report, fix moni…
SihaoLiu Mar 13, 2026
03ac7d0
Tighten cancel allowlist, document spawned agent limitation, remove d…
SihaoLiu Mar 13, 2026
5a08329
Remove raw records from read allowlist, document bash read limitation
SihaoLiu Mar 13, 2026
2cba950
Fix stale error messages in read validator methodology analysis block
SihaoLiu Mar 13, 2026
3eed7d6
Add missing template for methodology analysis state file block message
SihaoLiu Mar 13, 2026
0edbe3f
Merge dev: resolve conflicts with yolo/skip-quiz flags
SihaoLiu Mar 13, 2026
13a47fb
Fix cancel allowlist regex and move methodology handler before git-clean
SihaoLiu Mar 13, 2026
9b961a8
Harden RLCR against mainline drift
tastynoob Mar 15, 2026
cfc46d6
Use portable shebang across all shell scripts
Emin017 Mar 17, 2026
4303249
Bump version to 1.14.1 for branch CI validation
Emin017 Mar 17, 2026
4deb1db
Harden template-loader error handling and reduce code duplication
zevorn Mar 18, 2026
0844648
Add native Codex hook support and harden install/test flows
shinezyy Mar 15, 2026
dbb88bc
fixed tests for bitlesson-select-routing
shinezyy Mar 26, 2026
9ed3e1a
bump version of humanize
SihaoLiu Mar 28, 2026
03e159c
Merge PR #49: Use portable shebang across all shell scripts
SihaoLiu Mar 28, 2026
1862329
Merge PR #50: Harden template-loader error handling and reduce duplic…
SihaoLiu Mar 28, 2026
fe1832d
Merge PR #42: Add methodology analysis for RLCR loop exit
SihaoLiu Mar 28, 2026
a8f85e8
Merge PR #48: Harden RLCR against mainline drift
SihaoLiu Mar 28, 2026
611a437
Fix codex_hooks flag probe, managed-hook regex, and legacy compat
SihaoLiu Mar 29, 2026
2a0faf6
Fix BSD sed portability, awk field splitting, and strict parser defaults
SihaoLiu Mar 29, 2026
d122c82
Fix path injection in shim generation, JSON escaping, and legacy trac…
SihaoLiu Mar 29, 2026
9cf2544
Merge branch 'main' into dev
SihaoLiu Mar 29, 2026
febbc00
Fix relative path bypass in methodology analysis read guard
SihaoLiu Mar 29, 2026
17fabf7
Revert version back to 1.16.0 on dev branch
SihaoLiu Mar 29, 2026
2ab5361
Fix relative path bypass in write validator and add Codex flag probes…
SihaoLiu Mar 29, 2026
4326860
Fix mainline verdict parser picking last keyword instead of first
SihaoLiu Mar 29, 2026
016caca
Add ask-gemini skill and tool-filtered monitor subcommands
SihaoLiu Mar 29, 2026
883e3f5
Revert version back to 1.16.0 to match dev branch
SihaoLiu Mar 29, 2026
916fc50
Reject path traversal segments in methodology analysis fallback guards
SihaoLiu Mar 29, 2026
515f90a
Merge pull request #52 from humania-org/ask-gemini
SihaoLiu Mar 29, 2026
95a6b7b
Fix edit validator path fallback and reject whitespace-only completio…
SihaoLiu Mar 29, 2026
bd506f2
Reject ambiguous multi-keyword verdict lines and fix Gemini CLI insta…
SihaoLiu Mar 29, 2026
4561bc4
Shell-quote hook command paths and reject ambiguous verdict lines
SihaoLiu Mar 29, 2026
338b4dd
Remove PR loop feature entirely
SihaoLiu Mar 29, 2026
3374acb
fix minor display bug of monitor script
SihaoLiu Mar 29, 2026
a1f3614
Be more specific about what is a round
SihaoLiu Mar 29, 2026
c045dff
fix: normalize path slashes in PostToolUse hook to prevent session_id…
gyy0592 Apr 4, 2026
707097c
revert: remove version bump, keep only hook fix
gyy0592 Apr 4, 2026
79714b7
Add support for multiple comment formats in refine-plan
Lyken17 Apr 9, 2026
228d6aa
Update README.md
Lyken17 Apr 13, 2026
28813b6
Merge pull request #68 from gyy0592/fix/session-id-double-slash
SihaoLiu Apr 13, 2026
690fb27
fix: use pipe delimiter in find_comment_markers to avoid splitting CM…
SihaoLiu Apr 13, 2026
027bf0b
fix: update test assertions to match renamed comment terminology
SihaoLiu Apr 13, 2026
3bef3ef
Merge pull request #78 from Lyken17/main
SihaoLiu Apr 13, 2026
722eb25
[docs] clarify the place to use monitor script
SihaoLiu Apr 13, 2026
e61b570
Merge branch 'main' into dev
SihaoLiu Apr 14, 2026
7c4356c
fix: correct managed-hook dedup regex and block unresolvable symlinks
SihaoLiu Apr 14, 2026
c4389bb
feat: add integral context to RLCR review prompts (PID complete)
zevorn Apr 14, 2026
50ed1bc
Merge pull request #81 from zevorn/feat/rlcr-integral-context
SihaoLiu Apr 15, 2026
fc8a027
Update repo org URLs from humania-org to PolyArch
SihaoLiu Apr 15, 2026
5c2f07f
Update remaining repo org URLs from humania-org to PolyArch
SihaoLiu Apr 15, 2026
41a02e8
Merge branch 'main' into dev
SihaoLiu Apr 15, 2026
84ebaee
Merge branch 'main' into dev and bump version to 1.16.1
SihaoLiu Apr 15, 2026
67fa1ae
Reset dev version to 1.16.0
SihaoLiu Apr 15, 2026
a9078aa
fix: block tracked humanize loop state from git
xyyy1420 Apr 16, 2026
421ae97
Narrow tracked-humanize guard to .humanize/ to avoid false blocks
SihaoLiu Apr 16, 2026
0f025cb
Merge pull request #86 from xyyy1420/dev
SihaoLiu Apr 16, 2026
9730744
Allow natural stop when background tasks still running
SihaoLiu Apr 16, 2026
3adf8ef
Expand '~' in transcript_path before background-task file check
SihaoLiu Apr 16, 2026
38691dd
Make tilde-path regressions portable and cover the wrapper too
SihaoLiu Apr 16, 2026
6a1d931
Prevent RLCR loop orphaning when session dies mid-background
SihaoLiu Apr 16, 2026
69587a7
Prefer own-session match and clean marker on resume
SihaoLiu Apr 16, 2026
0535919
Recognise SDK task_notification completions and keep recovery marker
SihaoLiu Apr 16, 2026
60e2635
Narrow cross-session adoption and block foreign-session hijack
SihaoLiu Apr 16, 2026
7fb3038
Tighten cross-session guard and marker cleanup
SihaoLiu Apr 16, 2026
7538f74
Silence ambiguous callers and scope transcript scan to this loop
SihaoLiu Apr 16, 2026
9c80698
Normalize loop-start boundary into actual UTC
SihaoLiu Apr 16, 2026
74671f7
Pin rlcr-stop-gate project root at every wrapper testsite
SihaoLiu Apr 16, 2026
39f09c4
Avoid duplicate jq pass in bg-pending short-circuit
SihaoLiu Apr 16, 2026
3711e5f
Extract bg-task helpers into dedicated lib and guard transcript_path …
SihaoLiu Apr 16, 2026
b955a69
Merge pull request #91 from PolyArch/do-not-block-stop-when-backgroun…
SihaoLiu Apr 17, 2026
fdd8670
Add liveness probe to prune orphaned background task IDs
SihaoLiu Apr 17, 2026
850a444
WIP: wrap all path with realpath
SihaoLiu Apr 17, 2026
3dcb4dd
Canonicalize both sides of cancel-authorization path comparison
SihaoLiu Apr 17, 2026
0e2c6a0
Merge pull request #93 from PolyArch/use-realpath4everything
SihaoLiu Apr 17, 2026
b10fbf1
Reject symlink aliases for cancel source and destination
SihaoLiu Apr 17, 2026
cf17140
Use prefix-only canonicalization in read/write path validators
SihaoLiu Apr 17, 2026
98d86c0
Merge pull request #94 from PolyArch/use-realpath4everything
SihaoLiu Apr 17, 2026
68bde28
Tighten cancel-rlcr-loop allowlist regex in methodology phase
SihaoLiu Apr 17, 2026
47ee97d
Reject unresolvable symlinks in methodology write/edit validators
SihaoLiu Apr 17, 2026
a4fbccd
Remove version bump hint from CLAUDE.md
SihaoLiu Apr 17, 2026
22e52bd
Wire test-disable-nested-codex-hooks into run-all-tests
SihaoLiu Apr 17, 2026
0ca864d
Place --disable codex_hooks after the Codex subcommand
SihaoLiu Apr 17, 2026
cd367ee
Reject shell metacharacters in cancel allowlist exception
SihaoLiu Apr 17, 2026
d09a282
Block patch in methodology-phase Bash denylist
SihaoLiu Apr 17, 2026
5990827
Gate methodology completion on a clean git tree
SihaoLiu Apr 17, 2026
3a0cd7c
docs: add gen-idea design spec for directed-swarm idea drafting
shinan6 Apr 20, 2026
84ffc93
docs: add gen-idea implementation plan
shinan6 Apr 20, 2026
e18d013
feat(gen-idea): add draft template for directed-swarm output
shinan6 Apr 20, 2026
e3e38de
feat(gen-idea): add IO validation script with slug resolution
shinan6 Apr 20, 2026
911c5da
docs(plan): align Task 2 script with implemented fixes
shinan6 Apr 20, 2026
7e6442b
fix(gen-idea): harden realpath fallback and document tempfile contract
shinan6 Apr 20, 2026
a49ed09
feat(gen-idea): add slash-command spec for directed-swarm drafting
shinan6 Apr 20, 2026
2269e0a
fix(gen-idea): clarify command spec ambiguities surfaced in review
shinan6 Apr 20, 2026
c6d8d19
feat(gen-idea): document command in README, bump to 1.16.1
shinan6 Apr 20, 2026
1adeca4
feat(gen-idea): emit short-idea warning and clarify SLUG usage
shinan6 Apr 20, 2026
695766a
chore: revert version to 1.16.0
SihaoLiu Apr 20, 2026
ad9fe53
remove superpowers docs from branch
SihaoLiu Apr 20, 2026
0e6a5b3
fix(gen-idea): treat whitespace-containing .md args as inline
SihaoLiu Apr 20, 2026
04116b9
fix(gen-idea): reject unreadable markdown input files
SihaoLiu Apr 20, 2026
3e891f3
fix(gen-idea): emit inline idea body via stdout sentinel
SihaoLiu Apr 21, 2026
179a87c
Merge pull request #99 from shinan6/add-gen-idea-command
SihaoLiu Apr 21, 2026
3c7fa7d
chore: bump default Codex model from gpt-5.4 to gpt-5.5
SihaoLiu Apr 25, 2026
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
2 changes: 1 addition & 1 deletion .claude-plugin/marketplace.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"name": "humanize",
"source": "./",
"description": "Humanize - An iterative development plugin that uses Codex to review Claude's work. Creates a feedback loop where Claude implements plans and Codex independently reviews progress, ensuring quality through continuous refinement.",
"version": "1.15.4"
"version": "1.16.0"
}
]
}
2 changes: 1 addition & 1 deletion .claude-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "humanize",
"description": "Humanize - An iterative development plugin that uses Codex to review Claude's work. Creates a feedback loop where Claude implements plans and Codex independently reviews progress, ensuring quality through continuous refinement.",
"version": "1.15.4",
"version": "1.16.0",
"author": {
"name": "PolyArch"
},
Expand Down
2 changes: 1 addition & 1 deletion .claude/CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ This is a Claude Code plugin that provides iterative development with Codex revi

# Humanize Project Rules
- Everything about this project, including but not limited to implementations, comments, tests and documentations should be in English. No Emoji or CJK char is allowed.
- If under `main` branch, every commit MUST include a version bump in `.claude-plugin/plugin.json`, `.claude-plugin/marketplace.json` and `README.md` (the "Current Version" line). If not under `main` branch, please make sure that the current branch's `version` in those three files has a incremental update compared to that of `main` branch. The `version` must be identical in those three files.
- If version bump is required, please bump them in three files: `.claude-plugin/plugin.json`, `.claude-plugin/marketplace.json` and `README.md` (the "Current Version" line).
- Version number must be in format of `X.Y.Z` where X/Y/Z is numeric number. Version MUST NOT include anything other than `X.Y.Z`. For example, a good version is `9.732.42`; Bad version examples (MUST NOT USE): `3.22.7-alpha` (extra "-alpha" string), `9.77.2 (2026-01-07)` (useless date/timestamp).
- The plan template in `commands/gen-plan.md` (Phase 5 Plan Structure section) and `prompt-template/plan/gen-plan-template.md` are intentionally kept in sync. When modifying either file, ensure both are updated to maintain consistency.
- Conversely, changes to `prompt-template/plan/gen-plan-template.md` must also be reflected in the Plan Structure section of `commands/gen-plan.md`.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ temp

# Local Claude client settings
/.claude/settings.json
/.claude/scheduled_tasks.lock

# Humanize state directories (runtime-generated, project-local)
.humanize/
.claude-flow/
.swarm/

# Python cache
__pycache__/
Expand Down
29 changes: 22 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Humanize

**Current Version: 1.15.4**
**Current Version: 1.16.0**

> Derived from the [GAAC (GitHub-as-a-Context)](https://github.com/SihaoLiu/gaac) project.

Expand All @@ -25,6 +25,7 @@ A Claude Code plugin that provides iterative development with independent AI rev

The loop has two phases: **Implementation** (Claude works, Codex reviews summaries) and **Code Review** (Codex checks code quality with severity markers). Issues feed back into implementation until resolved.


## Install

```bash
Expand All @@ -40,25 +41,39 @@ Requires [codex CLI](https://github.com/openai/codex) for review. See the full [

## Quick Start

1. **Generate a plan** from your draft:
1. **Generate an idea draft** from a loose thought (optional — skip if you already have a draft):
```bash
/humanize:gen-idea "add undo/redo to the editor"
```
Output goes to `.humanize/ideas/<slug>-<timestamp>.md` by default. Pass a `.md` path to expand existing rough notes. `--n` controls how many parallel directions explore the idea (default 6).

2. **Generate a plan** from your draft:
```bash
/humanize:gen-plan --input draft.md --output docs/plan.md
```

2. **Refine an annotated plan** before implementation when reviewers add `CMT:` ... `ENDCMT` comments:
3. **Refine an annotated plan** before implementation when reviewers add comments (`CMT:` ... `ENDCMT`, `<cmt>` ... `</cmt>`, or `<comment>` ... `</comment>`):
```bash
/humanize:refine-plan --input docs/plan.md
```

3. **Run the loop**:
4. **Run the loop**:
```bash
/humanize:start-rlcr-loop docs/plan.md
```

4. **Monitor progress**:
5. **Consult Gemini** for deep web research (requires Gemini CLI):
```bash
/humanize:ask-gemini What are the latest best practices for X?
```

6. **Monitor progress (in another terminal, not inside Claude Code)**:
```bash
source <path/to/humanize>/scripts/humanize.sh
humanize monitor rlcr
source <path/to/humanize>/scripts/humanize.sh # Or just add it into your .bashec or .zshrc
humanize monitor rlcr # RLCR loop
humanize monitor skill # All skill invocations (codex + gemini)
humanize monitor codex # Codex invocations only
humanize monitor gemini # Gemini invocations only
```

## Monitor Dashboard
Expand Down
25 changes: 0 additions & 25 deletions commands/cancel-pr-loop.md

This file was deleted.

3 changes: 2 additions & 1 deletion commands/cancel-rlcr-loop.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ To cancel the active loop:
2. Check the first line of output:
- **NO_LOOP** or **NO_ACTIVE_LOOP**: Say "No active RLCR loop found."
- **CANCELLED**: Report the cancellation message from the output
- **CANCELLED_METHODOLOGY_ANALYSIS**: Report the cancellation message from the output
- **CANCELLED_FINALIZE**: Report the cancellation message from the output
- **FINALIZE_NEEDS_CONFIRM**: The loop is in Finalize Phase. Continue to step 3

Expand All @@ -33,6 +34,6 @@ To cancel the active loop:
- **If user chooses "No, let it finish"**:
- Report: "Understood. The Finalize Phase will continue. Once complete, the loop will end normally."

**Key principle**: The script handles all cancellation logic. A loop is active if `state.md` (normal loop) or `finalize-state.md` (Finalize Phase) exists in the newest loop directory.
**Key principle**: The script handles all cancellation logic. A loop is active if `state.md` (normal loop), `methodology-analysis-state.md` (Methodology Analysis Phase), or `finalize-state.md` (Finalize Phase) exists in the newest loop directory.

The loop directory with summaries, review results, and state information will be preserved for reference.
209 changes: 209 additions & 0 deletions commands/gen-idea.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,209 @@
---
description: "Generate a repo-grounded idea draft via directed-swarm exploration"
argument-hint: "<idea-text-or-path> [--n <int>] [--output <path>]"
allowed-tools:
- "Bash(${CLAUDE_PLUGIN_ROOT}/scripts/validate-gen-idea-io.sh:*)"
- "Read"
- "Glob"
- "Grep"
- "Task"
- "Write"
---

# Generate Idea Draft from Loose Input

Read and execute below with ultrathink.

## Hard Constraint: Draft-Only Output

This command MUST NOT implement features, modify source code, or create commits while producing the draft. Permitted writes are limited to the single output draft file produced in Phase 4; prerequisite directory creation for the default `.humanize/ideas/` path by the validation script is permitted as part of that write. All exploration subagents run read-only.

This command transforms a loose idea into a repo-grounded draft suitable as input to `/humanize:gen-plan`. It applies directed-diversity exploration: a lead picks N orthogonal directions, N parallel `Explore` subagents develop each, the lead synthesizes a draft with one primary direction plus N-1 alternatives. Each direction carries objective evidence from the repo.

## Workflow Overview

> **Sequential Execution Constraint**: All phases MUST execute strictly in order. Each phase fully completes before the next.

1. Parse Input
2. IO Validation
3. Direction Generation
4. Parallel Exploration
5. Synthesis and Write

---

## Phase 0: Parse Input

Extract from `$ARGUMENTS`:
- First positional: inline idea text or path to a `.md` file (required).
- `--n <int>`: number of directions. Default 6.
- `--output <path>`: target draft path. Default resolved by the validation script.

Do not interpret or rewrite the idea text here. Pass `$ARGUMENTS` through to Phase 1 unchanged.

---

## Phase 1: IO Validation

Run:
```bash
"${CLAUDE_PLUGIN_ROOT}/scripts/validate-gen-idea-io.sh" $ARGUMENTS
```

Handle exit codes:
- `0`: Parse stdout to extract `INPUT_MODE`, `OUTPUT_FILE`, `SLUG`, `TEMPLATE_FILE`, `N` (each appears on its own `KEY: value` line). When `INPUT_MODE` is `file`, stdout additionally contains an `IDEA_BODY_FILE: <path>` line; extract that too. Continue to Phase 2. (`SLUG` is informational — the script has already incorporated it into `OUTPUT_FILE`, so later phases do not need to use `SLUG` directly.)
- `1`: Report "Missing or empty idea input" and stop.
- `2`: Report "Input looks like a file path but is missing, not readable, or not `.md`" and stop.
- `3`: Report "Output directory does not exist — please create it or choose a different path" and stop.
- `4`: Report "Output file already exists — choose a different path" and stop.
- `5`: Report "No write permission to output directory" and stop.
- `6`: Report "Invalid arguments" with the stdout usage text and stop.
- `7`: Report "Template file missing — plugin configuration error" and stop.

Before `VALIDATION_SUCCESS`, stdout may contain one or more lines starting with `WARNING:` (for example, `WARNING: short idea (<N> chars); proceeding` when an inline idea is under 10 characters). Surface these warnings to the user in your final report but continue Phase 2 normally. `WARNING:` lines are informational, not errors.

Obtain the idea body into memory as `IDEA_BODY`, based on `INPUT_MODE`:
- `inline`: stdout contains a sentinel block at the end of the success output; extract all text between the `=== IDEA_BODY_BEGIN ===` and `=== IDEA_BODY_END ===` lines (exclusive). The script emits a trailing newline after the last body line.
- `file`: read the full contents of `IDEA_BODY_FILE` using the `Read` tool.

Preserve byte-identical content in memory for later phases. No on-disk tempfile is created in inline mode — the stdout sentinel block is the authoritative source.

---

## Phase 2: Direction Generation

Generate exactly `N` orthogonal directions for exploring the idea.

### Context to Gather

Before generating directions, read (paths relative to the project root, which is `$(git rev-parse --show-toplevel)`):
- `README.md` at the project root.
- `CLAUDE.md` at the project root (if it exists).
- `.claude/CLAUDE.md` (if it exists).
- Top-level directory listing via `Glob` with pattern `*` (one level, no recursion).

This context grounds the directions in the actual repo rather than generic brainstorming.

### Generation Rules

Produce exactly `N` direction entries. Each entry has:
- `name`: a 2-5 word short label.
- `rationale`: a single sentence explaining why this angle is distinct from the other directions.

Hard constraint: **orthogonality**. Two near-duplicate directions defeat the directed-diversity premise. Before returning:
- If two directions feel like dupes, replace one with a genuinely different angle.
- If a direction collapses to "just do X better" with no angle distinction, replace it.
- Do not emit directions that merely restate the idea in different words.

### Retry and Degradation

- If the first pass returns fewer than `N` entries, regenerate once with an explicit "you MUST produce `N` orthogonal directions" instruction.
- If the second pass still returns fewer than `N` but at least 2, proceed with the reduced count and emit a warning to the user: `Warning: direction generation returned <count> of <N> requested directions; proceeding with reduced count.`
- If fewer than 2 directions are produced, stop with error: `direction generation degraded; retry.`

Store the final direction list as `DIRECTIONS` (ordered; index 0..len-1).

---

## Phase 3: Parallel Exploration

Dispatch all directions in a **single Task-tool message** containing one Task invocation per direction. This is the W2S parallel-swarm step.

### Subagent Invocation

For each direction in `DIRECTIONS`, launch one `Explore` subagent. Each invocation prompt MUST include:

1. A verbatim copy of the idea body (`IDEA_BODY`) captured in Phase 1.
2. The assigned direction (name + rationale).
3. The following instruction block (reproduce verbatim in the subagent prompt):

> Explore this direction within the current repo. Gather OBJECTIVE EVIDENCE:
> - Specific repo paths with existing patterns worth extending.
> - Prior art or precedent in the codebase or adjacent tooling.
> - Measurable considerations (approximate complexity, LOC surface, performance implications) where discoverable from reading the code.
>
> Read-only. Do not write any files.
>
> If no concrete evidence exists for this direction, report the literal string `exploratory, no concrete precedent` once in OBJECTIVE_EVIDENCE and stop exploring further. Fabrication of references is forbidden.
>
> Return a structured proposal with exactly these fields:
> - `APPROACH_SUMMARY`: concrete design description (what to build, core mechanism, affected components).
> - `OBJECTIVE_EVIDENCE`: bullet list of repo paths, prior art, or the `exploratory, no concrete precedent` sentinel.
> - `KNOWN_RISKS`: short bullet list.
> - `CONFIDENCE`: one of `high`, `medium`, `low`.

### Collection and Degradation

Collect all subagent responses. For each response:
- Parse the four required fields. If a field is missing, mark that proposal as degraded and drop it.
- If fewer than 2 proposals survive, stop with error: `exploration phase degraded; retry.`
- Otherwise continue with the surviving proposals.

Associate each surviving proposal with its originating direction (so Phase 4 can label it with the original direction name). When numbering alternatives in Phase 4 after any drops, renumber survivors sequentially as Alt-1..Alt-K (where K is the count of surviving non-primary directions). Do not preserve gaps from dropped proposals.

---

## Phase 4: Synthesis and Write

### Step 4.1: Pick the Primary Direction

Review all surviving proposals. Choose the strongest as the primary based on:
1. Evidence density — more concrete repo references outranks fewer.
2. Fit with existing repo patterns — extending patterns outranks introducing unfamiliar paradigms.
3. Implementation surface area — prefer smaller surface where quality is otherwise comparable.
4. Declared `CONFIDENCE` — `high` > `medium` > `low` as tiebreaker.

Record the chosen direction as `PRIMARY`; the remaining surviving directions become the Alt-1..Alt-K list (where K is the number of non-primary survivors, K ≤ N-1), numbered sequentially in their original direction order with no gaps for any dropped proposals.

### Step 4.2: Infer Title

Generate a 4-10 word Title Case title that captures the primary direction, not the original input phrasing verbatim. Example: idea `add undo/redo` with primary direction `command-pattern history` yields title `Command-Pattern Undo Stack For The Editor`.

### Step 4.3: Populate the Template

Read the template file located at `TEMPLATE_FILE` (from Phase 1 stdout).

Produce the finalized draft content in memory by replacing placeholders:
- `<TITLE>` — the inferred title.
- `<ORIGINAL_IDEA>` — byte-identical value of `IDEA_BODY` captured in Phase 1. Preserve line breaks, trailing newline, and all formatting. Do NOT paraphrase or re-indent.
- `<PRIMARY_NAME>` — primary direction's short name.
- `<PRIMARY_RATIONALE>` — primary direction's rationale (from Phase 2).
- `<PRIMARY_APPROACH_SUMMARY>` — primary proposal's `APPROACH_SUMMARY`.
- `<PRIMARY_OBJECTIVE_EVIDENCE>` — primary proposal's `OBJECTIVE_EVIDENCE`, rendered as a bullet list. If the subagent returned only the literal sentinel `exploratory, no concrete precedent`, render it as a single bullet: `- exploratory, no concrete precedent`.
- `<PRIMARY_KNOWN_RISKS>` — primary proposal's `KNOWN_RISKS`, rendered as a bullet list.
- `<ALTERNATIVES>` — for each non-primary survivor at its Alt index `i` (1-based, sequential per Step 4.1), emit:

```markdown
### Alt-<i>: <name>
- Gist: <one-paragraph summary derived from APPROACH_SUMMARY>
- Objective Evidence:
- <bullet from OBJECTIVE_EVIDENCE>
- ...
- Why not primary: <one sentence stating the tradeoff vs PRIMARY>
```

Separate consecutive Alt entries with a single blank line.

- `<SYNTHESIS_NOTES>` — one paragraph describing which elements from the alternatives could fold into the primary if the user chose a different direction. This is the lead's own synthesis note, not a subagent output.

### Step 4.4: Write the Draft File

Write the finalized content to `OUTPUT_FILE` using the `Write` tool. Single write; no progressive edits.

### Step 4.5: Report

Report to the user:
- Path written (`OUTPUT_FILE`).
- Primary direction name.
- Requested `N` and the actual direction count (note if reduced due to degradation).
- Next-step hint: `To turn this draft into a plan, run: /humanize:gen-plan --input <OUTPUT_FILE> --output <plan-path>`.

---

## Error Handling

- Phase 1 validation errors stop the command with a clear message. No partial output.
- Phase 2 degradation follows the retry-once + ≥2 minimum rule stated above.
- Phase 3 degradation follows the drop-and-continue + ≥2 minimum rule stated above.
- Never fabricate repo references or prior art. The `exploratory, no concrete precedent` sentinel from subagents is preserved verbatim in the draft.
- If any phase stops with an error, do not write a partial `OUTPUT_FILE`.
Loading
Loading