You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-**`sentiment`** (optional): Indicates the nature of the outcome for visual styling
76
+
-`"positive"`: Renders with green styling (e.g., "Use this option")
77
+
-`"negative"`: Renders with red styling (e.g., "Don't use this option")
78
+
- Omitted: Defaults to red (neutral/warning styling)
79
+
80
+
**Note**: The `sentiment` field is particularly useful for **suitability trees** (where outcomes are binary: suitable vs. unsuitable) as opposed to **selection trees** (where all outcomes are valid options). See [Tree Types](#tree-types) below.
81
+
82
+
## Tree Types
83
+
84
+
Decision trees can serve different purposes, which affects how you structure outcomes:
85
+
86
+
### Selection Trees
87
+
All paths lead to valid recommendations. Users choose between options.
88
+
-**Example**: "Which data type should I use?" → JSON, Hash, or String (all valid)
89
+
-**Outcome styling**: Typically all neutral (no sentiment field needed)
90
+
-**Use case**: Helping users choose among alternatives
91
+
92
+
### Suitability Trees
93
+
Paths lead to binary outcomes: suitable or unsuitable for the use case.
94
+
-**Example**: "Should I use RDI?" → Yes (good fit) or No (various reasons why not)
95
+
-**Outcome styling**: Use `sentiment: "positive"` for suitable outcomes and `sentiment: "negative"` for unsuitable ones
96
+
-**Use case**: Determining if a technology/approach is appropriate
97
+
-**Benefit**: Visual distinction (green vs. red) helps users quickly understand if something is recommended
75
98
76
99
## Multi-line Text
77
100
@@ -112,6 +135,8 @@ scope: documents
112
135
5. **Consistent naming**: Use camelCase for IDs, end question IDs with "Question"
113
136
6. **Match fence and YAML IDs**: The `id` in the code block fence should match the `id` field in the YAML for consistency
114
137
7. **Use meaningful scopes**: Choose scope values that clearly indicate the tree's domain (e.g., `documents`, `collections`, `sequences`)
138
+
8. **Add sentiment for suitability trees**: If your tree determines whether something is suitable (not just choosing between options), use `sentiment: "positive"` and `sentiment: "negative"` to provide visual feedback
139
+
9. **Be consistent with sentiment**: In a suitability tree, ensure all positive outcomes have `sentiment: "positive"` and all negative outcomes have `sentiment: "negative"` for clarity
**Benefit**: Helps future implementers and enables AI agents to understand the format.
142
142
143
+
## 11. Sentiment-Based Styling for Suitability Trees
144
+
145
+
**Discovery**: Not all decision trees are "selection trees" (choose between options). Some are "suitability trees" (determine if something is appropriate).
146
+
147
+
**Problem**: Selection trees and suitability trees have fundamentally different semantics:
148
+
-**Selection trees**: All outcomes are valid recommendations (e.g., "Use JSON" vs. "Use Hash" vs. "Use String")
149
+
-**Suitability trees**: Outcomes are binary (suitable vs. unsuitable) (e.g., "RDI is a good fit" vs. "RDI won't work")
150
+
151
+
**Solution**: Add optional `sentiment` field to outcomes:
152
+
```yaml
153
+
outcome:
154
+
label: "✅ RDI is a good fit for your use case"
155
+
id: goodFit
156
+
sentiment: "positive"# Green styling
157
+
```
158
+
159
+
**Implementation Details**:
160
+
- Extract `sentiment` field during YAML parsing in JavaScript
161
+
- Apply conditional styling in SVG rendering:
162
+
- `sentiment: "positive"` → Green background (`#0fa869`) and border
163
+
- `sentiment: "negative"` → Red background (`#d9534f`) and border
164
+
- No sentiment → Red (default, maintains backward compatibility)
165
+
166
+
**Key Insight**: Explicit metadata is better than heuristics. Don't try to infer sentiment from emoji (✅/❌) or label text. Use explicit fields for reliability and AI agent compatibility.
167
+
168
+
**Backward Compatibility**: Existing trees without sentiment fields continue to work with default red styling. This allows gradual adoption.
0 commit comments