Spaces:
Sleeping
Sleeping
Commit ·
c8b8965
1
Parent(s): f5632c1
docs: add unified confirm/revise with plan card to editable plan spec
Browse filesPer-message Confirm buttons now auto-fill the corresponding plan card
field when a plan is visible, using field_agents mapping and keyword
detection from gap analysis categories.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
docs/superpowers/specs/2026-04-12-editable-plan-card-design.md
CHANGED
|
@@ -82,6 +82,38 @@ When the user clicks "Ask Agent" on a field:
|
|
| 82 |
|
| 83 |
No new API endpoints — reuses existing `POST /api/chat` with `@mentions` routing.
|
| 84 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 85 |
## Data Model Changes
|
| 86 |
|
| 87 |
### `DesignPlan` (`agents/design_state.py`)
|
|
@@ -148,9 +180,13 @@ field_agents: dict[str, str] = {
|
|
| 148 |
- `askAgentForField(fieldName)` — constructs mention-targeted message, calls `sendMessage()`, switches to chat tab
|
| 149 |
- `savePlanAndContinue()` — merges edited values into `designState`, saves to localStorage, removes plan card, resets phase to exploring
|
| 150 |
- `recalcPlanScore()` — reads current field values from plan card inputs, runs `computeScore()`, updates current score display
|
|
|
|
|
|
|
|
|
|
| 151 |
|
| 152 |
### Modified functions
|
| 153 |
- `approvePlanCard()` — reads edited field values + notes from plan card inputs before sending to API
|
|
|
|
| 154 |
- `computeScore()` — no logic change, just called by `recalcPlanScore()`
|
| 155 |
|
| 156 |
## Testing
|
|
@@ -162,3 +198,8 @@ field_agents: dict[str, str] = {
|
|
| 162 |
- Verify Save & Continue preserves edits in designState and resets phase
|
| 163 |
- Verify Reject discards all edits
|
| 164 |
- Verify Approve sends edited values (not original values)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 82 |
|
| 83 |
No new API endpoints — reuses existing `POST /api/chat` with `@mentions` routing.
|
| 84 |
|
| 85 |
+
### 6. Unified Confirm/Revise with Plan Card
|
| 86 |
+
|
| 87 |
+
Currently there are three disconnected approval mechanisms:
|
| 88 |
+
- **Plan card** — Approve / Reject (whole plan)
|
| 89 |
+
- **Wizard step 7** — Approve & Generate (same as plan card)
|
| 90 |
+
- **Per-message** — Confirm / Revise on every agent response (sends chat message, updates design state indirectly via `extract_decisions()`)
|
| 91 |
+
|
| 92 |
+
The per-message Confirm/Revise buttons must be aware of the plan card.
|
| 93 |
+
|
| 94 |
+
**When a plan card is visible (phase = "planning"):**
|
| 95 |
+
|
| 96 |
+
`confirmRecommendation()` behavior changes:
|
| 97 |
+
1. Sends the confirmation message to chat (same as today — keeps design state updated)
|
| 98 |
+
2. **Auto-fills the corresponding plan card field** — detects which field the agent message relates to using the `field_agents` mapping + keyword matching from `GapAnalysisConfig.category_keywords`
|
| 99 |
+
3. Recalculates the plan card's current score
|
| 100 |
+
|
| 101 |
+
Field detection logic (reuses existing gap analysis categories):
|
| 102 |
+
- Agent is `engineering` + message contains dimension keywords → update `dimensions`
|
| 103 |
+
- Agent is `engineering` + message contains material keywords → update `material`
|
| 104 |
+
- Agent is `design` + message contains feature keywords → update `features`
|
| 105 |
+
- Agent is `cnc` + message contains constraint keywords → update `constraints`
|
| 106 |
+
- Agent is `cnc` + message contains axis/machining keywords → update `axis_recommendation`
|
| 107 |
+
- If no field match is found, skip the auto-fill (just send the chat message as today)
|
| 108 |
+
|
| 109 |
+
Value extraction: parse the confirmed message content for the relevant value (e.g., extract "Al 6061" from "I recommend Al 6061 for its machinability"). Uses simple heuristics — first quoted value, or value after "recommend"/"suggest"/"use".
|
| 110 |
+
|
| 111 |
+
`reviseRecommendation()` — no change. Works as today (pre-fills input with context).
|
| 112 |
+
|
| 113 |
+
**When no plan card is visible (phase = "exploring"):**
|
| 114 |
+
|
| 115 |
+
Confirm/Revise works exactly as it does today — no plan card interaction.
|
| 116 |
+
|
| 117 |
## Data Model Changes
|
| 118 |
|
| 119 |
### `DesignPlan` (`agents/design_state.py`)
|
|
|
|
| 180 |
- `askAgentForField(fieldName)` — constructs mention-targeted message, calls `sendMessage()`, switches to chat tab
|
| 181 |
- `savePlanAndContinue()` — merges edited values into `designState`, saves to localStorage, removes plan card, resets phase to exploring
|
| 182 |
- `recalcPlanScore()` — reads current field values from plan card inputs, runs `computeScore()`, updates current score display
|
| 183 |
+
- `detectPlanField(agentId, content)` — maps an agent message to a plan field using `field_agents` mapping + `category_keywords`. Returns field name or null.
|
| 184 |
+
- `extractFieldValue(fieldName, content)` — parses agent message content to extract a value for the given field (quoted values, values after "recommend"/"suggest"/"use")
|
| 185 |
+
- `updatePlanCardField(fieldName, value)` — programmatically sets a plan card field's value and triggers `recalcPlanScore()`
|
| 186 |
|
| 187 |
### Modified functions
|
| 188 |
- `approvePlanCard()` — reads edited field values + notes from plan card inputs before sending to API
|
| 189 |
+
- `confirmRecommendation()` — when phase is "planning", also calls `detectPlanField()` → `extractFieldValue()` → `updatePlanCardField()` to auto-fill the plan card
|
| 190 |
- `computeScore()` — no logic change, just called by `recalcPlanScore()`
|
| 191 |
|
| 192 |
## Testing
|
|
|
|
| 198 |
- Verify Save & Continue preserves edits in designState and resets phase
|
| 199 |
- Verify Reject discards all edits
|
| 200 |
- Verify Approve sends edited values (not original values)
|
| 201 |
+
- Verify Confirm on agent message auto-fills corresponding plan card field when plan is visible
|
| 202 |
+
- Verify Confirm on agent message works as before when no plan card is visible
|
| 203 |
+
- Verify field detection correctly maps agent + keyword to plan field
|
| 204 |
+
- Verify value extraction handles common patterns (quoted, after "recommend", etc.)
|
| 205 |
+
- Verify plan card score recalculates after Confirm auto-fill
|