Skip to content

Commit 79285a8

Browse files
committed
Merge remote-tracking branch 'origin/feat/memory-doctor'
2 parents f8eaa02 + 1006fae commit 79285a8

File tree

11 files changed

+3432
-9
lines changed

11 files changed

+3432
-9
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,11 @@ htmlcov/
7676

7777
# Planning documents
7878
prd.json
79+
prd.md
7980
mega-plan.json
81+
mega-plan.md
8082
design_doc.json
83+
design_doc.md
8184

8285
# Status and state files
8386
.mega-status.json

commands/hybrid-auto.md

Lines changed: 164 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -675,9 +675,168 @@ Write("prd.json", json.dumps(prd, indent=2))
675675
echo "✓ Flow/TDD configuration written to PRD"
676676
```
677677

678-
## Step 5.5: Display Unified Review
678+
## Step 5.4: Decision Conflict Check (Passive)
679679

680-
**CRITICAL**: Use Bash to display the unified PRD + Design Document review:
680+
After design_doc.json is generated, check new decisions against existing project decisions:
681+
682+
```bash
683+
uv run python "${CLAUDE_PLUGIN_ROOT}/skills/hybrid-ralph/scripts/memory-doctor.py" \
684+
--mode passive \
685+
--new-decisions design_doc.json \
686+
--project-root "$(pwd)"
687+
```
688+
689+
Exit code handling:
690+
- **Exit 0**: No issues found or no existing decisions to compare — proceed silently to Step 5.5
691+
- **Exit 1**: Decision conflicts or duplicates detected — follow the resolution steps below
692+
- **Exit 2** (or script crash/traceback): Infrastructure error (e.g., no LLM provider). Log the warning and proceed to Step 5.5. This check is advisory and must not block PRD generation.
693+
694+
If exit code is 1:
695+
1. Display the diagnosis report to the user
696+
2. Use `AskUserQuestion` to ask the user how to resolve each issue:
697+
- **Deprecate** — Mark the older/conflicting decision as deprecated (recommended for conflicts and superseded)
698+
- **Merge** — Combine duplicate decisions into one (recommended for duplicates)
699+
- **Skip** — Keep both decisions as-is
700+
3. Apply the user's choices using the memory-doctor `--apply` command:
701+
702+
**CRITICAL**: Construct a JSON array of the user's choices and save it to `_doctor_actions.json`. Each entry must include the full diagnosis context with `decision_a` and `decision_b` dicts (including `id` and `_source` fields) as returned by the diagnosis report:
703+
704+
```json
705+
[
706+
{
707+
"action": "deprecate",
708+
"diagnosis": {
709+
"type": "conflict",
710+
"decision_a": {"id": "ADR-F003", "_source": "path/to/design_doc.json"},
711+
"decision_b": {"id": "ADR-F012", "_source": "other/design_doc.json"},
712+
"source_a": "path/to/design_doc.json",
713+
"source_b": "other/design_doc.json"
714+
}
715+
},
716+
{
717+
"action": "merge",
718+
"diagnosis": {
719+
"type": "duplicate",
720+
"decision_a": {"id": "ADR-F005", "_source": "path/to/design_doc.json"},
721+
"decision_b": {"id": "ADR-F009", "_source": "other/design_doc.json"},
722+
"source_a": "path/to/design_doc.json",
723+
"source_b": "other/design_doc.json"
724+
}
725+
}
726+
]
727+
```
728+
729+
Then run the apply command:
730+
```bash
731+
uv run python "${CLAUDE_PLUGIN_ROOT}/skills/hybrid-ralph/scripts/memory-doctor.py" \
732+
--apply _doctor_actions.json \
733+
--project-root "$(pwd)"
734+
```
735+
736+
Clean up the temporary file:
737+
```bash
738+
rm -f _doctor_actions.json
739+
```
740+
741+
Note: Entries where the user chose **Skip** should be omitted from the actions array entirely.
742+
743+
## Step 5.45: Generate Markdown Documents
744+
745+
**CRITICAL**: Generate human-readable Markdown files from the finalized JSON:
746+
747+
```bash
748+
uv run python "${CLAUDE_PLUGIN_ROOT}/skills/hybrid-ralph/scripts/render-plan-docs.py" \
749+
--mode hybrid \
750+
--project-root "$(pwd)"
751+
```
752+
753+
This produces:
754+
- `prd.md` — Human-readable PRD with stories, acceptance criteria, execution batches
755+
- `design_doc.md` — Technical design with components, patterns, and full ADR details
756+
757+
These files are programmatically generated from JSON (not LLM) and stay in sync.
758+
If the script fails, log a warning and continue — the Markdown files are supplementary.
759+
760+
## Step 5.5: Confirm Architectural Decisions
761+
762+
Before the unified review, display a decision summary and confirm with the user. This ensures any modifications during confirmation are reflected in the unified review displayed afterward.
763+
764+
### 5.5.1: Display Decision Summary
765+
766+
Read `design_doc.json` and for each decision with status "accepted" or "proposed", display:
767+
768+
```
769+
============================================================
770+
ARCHITECTURAL DECISIONS — Summary
771+
============================================================
772+
773+
[ADR-F001] Decision Title
774+
Context: <context>
775+
Decision: <decision>
776+
Rationale: <rationale>
777+
Alternatives: <alt1>, <alt2>
778+
779+
[ADR-F002] ...
780+
781+
Total: N decisions
782+
============================================================
783+
```
784+
785+
### 5.5.2: Confirmation Flow
786+
787+
**If `NO_CONFIRM_MODE` is true** (i.e., `--no-confirm` was passed):
788+
- Skip interactive confirmation entirely
789+
- Auto-accept all decisions: set every decision's status to "accepted" in `design_doc.json`
790+
- Log: `"Auto-accepted N architectural decisions (--no-confirm mode)"`
791+
- Proceed to Step 5.6
792+
793+
**Otherwise** (interactive mode — the default):
794+
795+
Use `AskUserQuestion` with these options:
796+
797+
```
798+
Question: "These N architectural decisions will be used as the baseline for future conflict detection. Do you accept them?"
799+
800+
Options:
801+
1. "Accept All (Recommended)" — Accept all decisions as-is
802+
2. "Review Individually" — Review and confirm each decision one by one
803+
3. "Discuss" — Chat about specific decisions before confirming
804+
```
805+
806+
**If user selects "Accept All"**: Set all decision statuses to "accepted" in `design_doc.json`. Proceed to Step 5.6.
807+
808+
**If user selects "Discuss"**: Let the user discuss freely. After the discussion, repeat Step 5.5.2 (re-ask the question).
809+
810+
**If user selects "Review Individually"**: For each decision, use `AskUserQuestion`:
811+
812+
```
813+
Question: "[ADR-F001] <title>
814+
Context: <context>
815+
Decision: <decision>
816+
Rationale: <rationale>"
817+
818+
Options:
819+
1. "Accept" — Accept this decision
820+
2. "Reject" — Remove this decision
821+
3. "Modify" — Edit this decision before accepting
822+
4. "Discuss" — Chat about this decision
823+
```
824+
825+
- **Accept**: Mark status as "accepted"
826+
- **Reject**: Mark status as "rejected"
827+
- **Modify**: Let the user describe changes, update the decision in `design_doc.json`, then re-confirm this specific ADR
828+
- **Discuss**: Let the user chat, then re-ask for this specific ADR
829+
830+
After all decisions are reviewed, re-run Step 5.45 to regenerate the Markdown files:
831+
```bash
832+
uv run python "${CLAUDE_PLUGIN_ROOT}/skills/hybrid-ralph/scripts/render-plan-docs.py" \
833+
--mode hybrid \
834+
--project-root "$(pwd)"
835+
```
836+
837+
## Step 5.6: Display Unified Review
838+
839+
**CRITICAL**: Use Bash to display the unified PRD + Design Document review. This is displayed after ADR confirmation so it reflects any decision modifications made during Step 5.5:
681840

682841
```bash
683842
uv run python "${CLAUDE_PLUGIN_ROOT}/skills/hybrid-ralph/scripts/unified-review.py" --mode hybrid
@@ -700,14 +859,16 @@ If the script is not available, display a manual summary showing:
700859

701860
## Step 6: Confirm Generation Complete and Show Next Steps
702861

703-
After displaying the unified review, confirm and show how to proceed:
862+
After displaying the unified review, show how to proceed:
704863

705864
```
706865
PRD and Design Document generated successfully!
707866
708867
Files created:
709868
- prd.json (product requirements document)
710869
- design_doc.json (technical design document)
870+
- prd.md (human-readable PRD)
871+
- design_doc.md (human-readable technical design)
711872
712873
============================================================
713874
EXECUTION CONFIGURATION

0 commit comments

Comments
 (0)