@fluentcommerce/ai-skills 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +622 -0
- package/bin/cli.mjs +1973 -0
- package/content/cli/agents/fluent-cli/agent.json +149 -0
- package/content/cli/agents/fluent-cli.md +132 -0
- package/content/cli/skills/fluent-bootstrap/SKILL.md +181 -0
- package/content/cli/skills/fluent-cli-index/SKILL.md +63 -0
- package/content/cli/skills/fluent-cli-mcp-cicd/SKILL.md +77 -0
- package/content/cli/skills/fluent-cli-reference/SKILL.md +1031 -0
- package/content/cli/skills/fluent-cli-retailer/SKILL.md +85 -0
- package/content/cli/skills/fluent-cli-settings/SKILL.md +106 -0
- package/content/cli/skills/fluent-connect/SKILL.md +886 -0
- package/content/cli/skills/fluent-module-deploy/SKILL.md +349 -0
- package/content/cli/skills/fluent-profile/SKILL.md +180 -0
- package/content/cli/skills/fluent-workflow/SKILL.md +310 -0
- package/content/dev/agents/fluent-dev/agent.json +88 -0
- package/content/dev/agents/fluent-dev.md +525 -0
- package/content/dev/reference-modules/catalog.json +4754 -0
- package/content/dev/skills/fluent-build/SKILL.md +192 -0
- package/content/dev/skills/fluent-connection-analysis/SKILL.md +386 -0
- package/content/dev/skills/fluent-custom-code/SKILL.md +895 -0
- package/content/dev/skills/fluent-data-module-scaffold/SKILL.md +714 -0
- package/content/dev/skills/fluent-e2e-test/SKILL.md +394 -0
- package/content/dev/skills/fluent-event-api/SKILL.md +945 -0
- package/content/dev/skills/fluent-feature-explain/SKILL.md +603 -0
- package/content/dev/skills/fluent-feature-plan/PLAN_TEMPLATE.md +695 -0
- package/content/dev/skills/fluent-feature-plan/SKILL.md +227 -0
- package/content/dev/skills/fluent-job-batch/SKILL.md +138 -0
- package/content/dev/skills/fluent-mermaid-validate/SKILL.md +86 -0
- package/content/dev/skills/fluent-module-scaffold/SKILL.md +1928 -0
- package/content/dev/skills/fluent-module-validate/SKILL.md +775 -0
- package/content/dev/skills/fluent-pre-deploy-check/SKILL.md +1108 -0
- package/content/dev/skills/fluent-retailer-config/SKILL.md +1111 -0
- package/content/dev/skills/fluent-rule-scaffold/SKILL.md +385 -0
- package/content/dev/skills/fluent-scope-decompose/SKILL.md +1021 -0
- package/content/dev/skills/fluent-session-audit-export/SKILL.md +632 -0
- package/content/dev/skills/fluent-session-summary/SKILL.md +195 -0
- package/content/dev/skills/fluent-settings/SKILL.md +1058 -0
- package/content/dev/skills/fluent-source-onboard/SKILL.md +632 -0
- package/content/dev/skills/fluent-system-monitoring/SKILL.md +767 -0
- package/content/dev/skills/fluent-test-data/SKILL.md +513 -0
- package/content/dev/skills/fluent-trace/SKILL.md +1143 -0
- package/content/dev/skills/fluent-transition-api/SKILL.md +346 -0
- package/content/dev/skills/fluent-version-manage/SKILL.md +744 -0
- package/content/dev/skills/fluent-workflow-analyzer/SKILL.md +959 -0
- package/content/dev/skills/fluent-workflow-builder/SKILL.md +319 -0
- package/content/dev/skills/fluent-workflow-deploy/SKILL.md +267 -0
- package/content/mcp-extn/agents/fluent-mcp.md +69 -0
- package/content/mcp-extn/skills/fluent-mcp-tools/SKILL.md +461 -0
- package/content/mcp-official/agents/fluent-mcp-core.md +91 -0
- package/content/mcp-official/skills/fluent-mcp-core/SKILL.md +94 -0
- package/content/rfl/agents/fluent-rfl.md +56 -0
- package/content/rfl/skills/fluent-rfl-assess/SKILL.md +172 -0
- package/docs/CAPABILITY_MAP.md +77 -0
- package/docs/CLI_COVERAGE.md +47 -0
- package/docs/DEV_WORKFLOW.md +802 -0
- package/docs/FLOW_RUN.md +142 -0
- package/docs/USE_CASES.md +404 -0
- package/metadata.json +156 -0
- package/package.json +51 -0
|
@@ -0,0 +1,603 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: fluent-feature-explain
|
|
3
|
+
description: Reverse-engineer and explain an existing Fluent Commerce feature. Synthesizes workflow analysis, custom code logic, connection topology, and live runtime evidence into a comprehensive, visually rich Feature Architecture Document saved to accounts/<PROFILE>/analysis/features/. Triggers on "explain feature", "how does this work", "reverse engineer", "feature architecture", "document this flow", "what does this workflow do".
|
|
4
|
+
user-invocable: true
|
|
5
|
+
allowed-tools: Bash, Read, Write, Edit, Glob, Grep
|
|
6
|
+
argument-hint: <feature-name-or-workflow> [--depth shallow|full] [--include-runtime] [--output <path>]
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Feature Explainer
|
|
10
|
+
|
|
11
|
+
Reverse-engineer an existing feature to produce a comprehensive **Feature Architecture Document**. Orchestrates workflow analysis, code analysis, connection mapping, and live runtime evidence to explain *how* a feature is implemented end-to-end — from input trigger to terminal state, across all impacted entities.
|
|
12
|
+
|
|
13
|
+
## Ownership Boundary
|
|
14
|
+
|
|
15
|
+
This skill owns the **synthesis** of analysis artifacts into unified feature documentation.
|
|
16
|
+
|
|
17
|
+
Source analysis skills (called as needed, not duplicated):
|
|
18
|
+
- Workflow structure analysis -> `/fluent-workflow-analyzer`
|
|
19
|
+
- Code logic analysis -> `/fluent-custom-code`
|
|
20
|
+
- Dependency mapping -> `/fluent-connection-analysis`
|
|
21
|
+
- Runtime event forensics -> `/fluent-trace`
|
|
22
|
+
- Settings cross-reference -> `/fluent-settings`
|
|
23
|
+
|
|
24
|
+
MCP tools used directly:
|
|
25
|
+
- `plugin.list` — Rule descriptions, entity types, parameters
|
|
26
|
+
- `workflow.transitions` — Available user actions per status
|
|
27
|
+
- `environment.discover` — Environment context (locations, networks, catalogues)
|
|
28
|
+
- `event.flowInspect` — Runtime event trace (when `--include-runtime` or real entity ref provided)
|
|
29
|
+
- `entity.get` — Entity state and edge traversal
|
|
30
|
+
|
|
31
|
+
## When to Use
|
|
32
|
+
|
|
33
|
+
- "Explain how the Home Delivery order flow works end-to-end"
|
|
34
|
+
- "Reverse engineer the Click & Collect fulfilment feature"
|
|
35
|
+
- "Document the Return Order implementation for the team"
|
|
36
|
+
- "What entities, rules, and settings are involved in order allocation?"
|
|
37
|
+
- "How does ORDER::HD work? Show me diagrams"
|
|
38
|
+
- Onboarding new developers to an existing implementation
|
|
39
|
+
- Pre-change understanding before modifying a complex feature
|
|
40
|
+
- Stakeholder documentation and handover packs
|
|
41
|
+
|
|
42
|
+
## Output Location
|
|
43
|
+
|
|
44
|
+
All generated documents are saved to:
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
accounts/<PROFILE>/analysis/features/<FEATURE_NAME>.md
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Where `<FEATURE_NAME>` is derived from the user's request:
|
|
51
|
+
- Workflow name: `ORDER::HD` -> `ORDER_HD.md`
|
|
52
|
+
- Feature name: `"Home Delivery"` -> `Home_Delivery.md`
|
|
53
|
+
- Custom name via `--output`: saves to the specified path
|
|
54
|
+
|
|
55
|
+
Each document includes a metadata header for traceability:
|
|
56
|
+
|
|
57
|
+
```markdown
|
|
58
|
+
<!-- Feature Architecture Document -->
|
|
59
|
+
<!-- Generated: 2026-02-23T14:30:00Z -->
|
|
60
|
+
<!-- Profile: HMDEV -->
|
|
61
|
+
<!-- Retailer: HM_TEST (ID: 5) -->
|
|
62
|
+
<!-- Workflows: ORDER::HD (v1.50), FULFILMENT::HD_WH (v1.22) -->
|
|
63
|
+
<!-- Depth: full -->
|
|
64
|
+
<!-- Runtime evidence: yes (entity: HD-001) -->
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Execution Protocol
|
|
68
|
+
|
|
69
|
+
### Phase 1: Scope Identification
|
|
70
|
+
|
|
71
|
+
1. **Parse user request** — Extract feature name, workflow names, entity types, or entry points.
|
|
72
|
+
|
|
73
|
+
2. **Discover workflows** — If the user names a feature (not a workflow), map it to candidate workflows:
|
|
74
|
+
- Search workflow JSON filenames in `accounts/<PROFILE>/workflows/<RETAILER>/`
|
|
75
|
+
- If workflows not downloaded, download them first:
|
|
76
|
+
```bash
|
|
77
|
+
fluent workflow download -p <PROFILE> -r <RETAILER_REF> -w all -o accounts/<PROFILE>/workflows/<RETAILER_REF>/
|
|
78
|
+
```
|
|
79
|
+
- Match by entity type, subtype, or keyword in workflow names/rulesets
|
|
80
|
+
|
|
81
|
+
3. **Determine boundaries:**
|
|
82
|
+
- **Primary entity type** (e.g., ORDER)
|
|
83
|
+
- **Related entity types** (e.g., FULFILMENT_CHOICE, FULFILMENT, ARTICLE)
|
|
84
|
+
- **Entry events** (what triggers this feature)
|
|
85
|
+
- **Terminal states** (where the feature ends)
|
|
86
|
+
|
|
87
|
+
4. **Select depth:**
|
|
88
|
+
- `--depth shallow` — Primary workflow only, no cross-entity tracing
|
|
89
|
+
- `--depth full` (default) — All related workflows, cross-entity flows, settings, integrations
|
|
90
|
+
|
|
91
|
+
### Phase 2: Structural Analysis
|
|
92
|
+
|
|
93
|
+
For each workflow in scope, invoke `/fluent-workflow-analyzer` capabilities:
|
|
94
|
+
|
|
95
|
+
**From workflow JSON (static analysis):**
|
|
96
|
+
- Parse all statuses, rulesets, triggers, and rules
|
|
97
|
+
- Classify process flows (CREATE, USER_ACTION, SCHEDULED_EVENT, CROSS_WORKFLOW, INTEGRATION_EVENT, INTERNAL)
|
|
98
|
+
- Build status transition graph
|
|
99
|
+
- Identify event chains from entry to terminal states
|
|
100
|
+
|
|
101
|
+
**From MCP tools (live data):**
|
|
102
|
+
- `plugin.list` — Get rule descriptions, accepted entity types, produced events, parameters for every rule in the workflow
|
|
103
|
+
- `workflow.transitions` — Query available user actions at each status (validates the state machine against deployed workflow)
|
|
104
|
+
|
|
105
|
+
**Produce:**
|
|
106
|
+
- Status state machine per entity type
|
|
107
|
+
- Event chain from trigger to terminal
|
|
108
|
+
- Process flow classification table
|
|
109
|
+
|
|
110
|
+
### Phase 3: Logic Analysis
|
|
111
|
+
|
|
112
|
+
For rules involved in the feature, gather behavior information using a tiered approach based on available evidence:
|
|
113
|
+
|
|
114
|
+
**Tier 1: `plugin.list` MCP tool** (always available):
|
|
115
|
+
- Rule descriptions (what the rule does)
|
|
116
|
+
- Event attributes consumed (what data the rule reads)
|
|
117
|
+
- Parameters (configurable behavior)
|
|
118
|
+
- Accepted entity types
|
|
119
|
+
|
|
120
|
+
**Tier 2: Source code analysis** (when `accounts/<PROFILE>/SOURCE/` exists):
|
|
121
|
+
Invoke `/fluent-custom-code` to analyze Java source:
|
|
122
|
+
- `source-map.json` — Rule class locations, test coverage
|
|
123
|
+
- `workflow-rule-map.json` — Rule-to-workflow mapping with confidence
|
|
124
|
+
- `behavior-map.md` — Human-readable behavior descriptions
|
|
125
|
+
|
|
126
|
+
**Source code validation** (automatically triggered for custom rules):
|
|
127
|
+
- Cross-reference rule props from workflow JSON against what the Java code actually reads
|
|
128
|
+
- Verify that configurable JSON paths (e.g., `sourcingLocationPath`) match fields the code navigates
|
|
129
|
+
- Check test coverage per custom rule — flag untested rules
|
|
130
|
+
- Identify any rules referenced in the workflow but missing from SOURCE (gap)
|
|
131
|
+
|
|
132
|
+
**Tier 2b: JAR decompilation** (when source code is missing for some rules but JARs exist):
|
|
133
|
+
|
|
134
|
+
After completing Tier 2 source analysis, identify any custom rules still unresolved (found in workflow JSON + plugin.list but not in SOURCE Java files). For these rules:
|
|
135
|
+
|
|
136
|
+
**How to find rules without decompiling (discovery vs decompilation are separate):**
|
|
137
|
+
- `plugin.list` gives you the rule's fully qualified key (e.g., `SAGIRISH.order.ForwardEventByFulfilmentChoiceType`) — the namespace prefix (`order`) hints at the module name
|
|
138
|
+
- `jar tf` lists all class file paths inside a JAR by reading the ZIP index — **no decompilation needed** for discovery
|
|
139
|
+
- Only after confirming which JAR contains the class do you extract + decompile it
|
|
140
|
+
|
|
141
|
+
1. **Ensure CFR decompiler is available** — auto-download if missing:
|
|
142
|
+
```bash
|
|
143
|
+
# Check for CFR in workspace tools/ directory
|
|
144
|
+
if [ ! -f tools/cfr.jar ]; then
|
|
145
|
+
mkdir -p tools
|
|
146
|
+
curl -L -o tools/cfr.jar "https://github.com/leibnitz27/cfr/releases/download/0.152/cfr-0.152.jar"
|
|
147
|
+
fi
|
|
148
|
+
# Verify it works
|
|
149
|
+
java -jar tools/cfr.jar --version
|
|
150
|
+
```
|
|
151
|
+
CFR is a single-JAR decompiler (~2MB), no installation needed — just `java -jar`.
|
|
152
|
+
|
|
153
|
+
2. **Search for JARs recursively** under `accounts/<PROFILE>/SOURCE/`:
|
|
154
|
+
```bash
|
|
155
|
+
find accounts/<PROFILE>/SOURCE/ -name "*.jar" -type f
|
|
156
|
+
```
|
|
157
|
+
Look in: reference modules (`referece modules/`, `reference-modules/`), `assets/rules/`, `dist/`, `target/`.
|
|
158
|
+
|
|
159
|
+
3. **Match unresolved rules to JARs** — `jar tf` reads the ZIP directory index (instant, no decompilation). For each JAR, check for matching class names:
|
|
160
|
+
```bash
|
|
161
|
+
jar tf <path-to-jar> | grep -i "<RuleClassName>"
|
|
162
|
+
```
|
|
163
|
+
This tells you exactly which JAR contains which rule, and the full package path.
|
|
164
|
+
|
|
165
|
+
4. **Decompile the matched JAR** with CFR using `--jarfilter` to extract only rule classes:
|
|
166
|
+
```bash
|
|
167
|
+
java -jar tools/cfr.jar "<path-to-jar>" \
|
|
168
|
+
--outputdir "accounts/<PROFILE>/SOURCE/.decompiled/<jar-basename>" \
|
|
169
|
+
--jarfilter "com.fluentcommerce.rule"
|
|
170
|
+
```
|
|
171
|
+
The `--jarfilter` flag restricts decompilation to classes matching the package prefix, keeping output focused on rule logic only. This produces clean, readable Java files organized by package path.
|
|
172
|
+
|
|
173
|
+
5. **Create a `DECOMPILED.md` marker** in the output directory:
|
|
174
|
+
```markdown
|
|
175
|
+
# Decompiled Source
|
|
176
|
+
- **Source JAR:** `<path-to-jar>`
|
|
177
|
+
- **Decompiled on:** <date>
|
|
178
|
+
- **Decompiler:** CFR 0.152
|
|
179
|
+
- **Rule classes:** <count>
|
|
180
|
+
- **Filter:** `com.fluentcommerce.rule.*`
|
|
181
|
+
- **Note:** This is decompiled bytecode, not original source. Variable names may be synthetic.
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
6. **Fallback if Java not available** — extract and disassemble individual classes:
|
|
185
|
+
```bash
|
|
186
|
+
mkdir -p /tmp/jar-decompile && cd /tmp/jar-decompile
|
|
187
|
+
jar xf <path-to-jar> <class-path>
|
|
188
|
+
javap -c -p <extracted-class-file>
|
|
189
|
+
```
|
|
190
|
+
`javap -c -p` provides bytecode disassembly sufficient to determine matching logic, null guards, data flow, and exception handling.
|
|
191
|
+
|
|
192
|
+
7. **Confidence level:**
|
|
193
|
+
- Full decompilation (CFR/Fernflower): mark as **HIGH** — readable Java, prop names visible, logic clear
|
|
194
|
+
- `javap` bytecode: mark as **HIGH** — implementation logic is unambiguous from bytecode
|
|
195
|
+
- Note the JAR version, decompiler version, and source path in the document metadata
|
|
196
|
+
|
|
197
|
+
**If SOURCE directory is missing or empty (no source, no JARs):**
|
|
198
|
+
- Ask the user: "Custom rules were found but no source code or JARs are available under `accounts/<PROFILE>/SOURCE/`. Options: (1) Clone plugin repos to `accounts/<PROFILE>/SOURCE/<repo>/` (2) Place reference module ZIPs/JARs in `accounts/<PROFILE>/SOURCE/` for decompilation (3) Run `/fluent-connect` for full workspace preparation including JAR provision"
|
|
199
|
+
- If user declines or source unavailable, proceed with Tier 1 only and add confidence caveats to the document:
|
|
200
|
+
- Mark affected rules as **MEDIUM confidence** (behavior inferred from plugin.list + runtime only)
|
|
201
|
+
- Add explicit "What we don't know" column for each affected rule
|
|
202
|
+
- Note in Analysis Caveats: "For more accurate analysis of these rules, provide source code or module JARs"
|
|
203
|
+
|
|
204
|
+
**Tier 3: Runtime evidence** (when entities exist — see Phase 5):
|
|
205
|
+
- Validates static analysis against actual execution
|
|
206
|
+
- Confirms which rulesets actually fire vs which are theorized from workflow JSON
|
|
207
|
+
|
|
208
|
+
**Produce:**
|
|
209
|
+
- Per-ruleset explanation: what it does, what triggers it, what it changes, what it emits
|
|
210
|
+
- Decision points and conditional logic
|
|
211
|
+
- Custom vs OOTB rule classification
|
|
212
|
+
- **Confidence level per rule** (see Analysis Confidence Levels below)
|
|
213
|
+
|
|
214
|
+
### Phase 4: Connection & Dependency Analysis
|
|
215
|
+
|
|
216
|
+
Invoke `/fluent-connection-analysis` capabilities:
|
|
217
|
+
|
|
218
|
+
**Map:**
|
|
219
|
+
- Internal connections (rulesets within same workflow)
|
|
220
|
+
- Cross-entity connections (ORDER -> FULFILMENT_CHOICE -> FULFILMENT)
|
|
221
|
+
- Cross-workflow connections (shared events)
|
|
222
|
+
- Integration points (webhooks, external system calls)
|
|
223
|
+
- Settings dependencies (which settings each ruleset reads)
|
|
224
|
+
|
|
225
|
+
**From `/fluent-settings` cross-reference:**
|
|
226
|
+
- List all settings referenced by rules in scope
|
|
227
|
+
- Show current values (or MISSING status)
|
|
228
|
+
- Map setting -> ruleset -> behavior impact
|
|
229
|
+
|
|
230
|
+
### Phase 5: Runtime Evidence (Adaptive)
|
|
231
|
+
|
|
232
|
+
**Auto-discovery:** Before asking the user, automatically search for existing entities of the workflow's entity type via GraphQL. Query for entities with matching type/subtype that have reached a non-initial status (e.g., not just CREATED). If entities are found, use the most recently completed one for runtime evidence.
|
|
233
|
+
|
|
234
|
+
**When runtime exists** (entities found, or `--include-runtime` specified, or user provides entity ref):
|
|
235
|
+
|
|
236
|
+
**IMPORTANT — Staged flowInspect pattern (never call with `compact: false` upfront):**
|
|
237
|
+
|
|
238
|
+
**Step 1: Compact call (always start here, ~2-3k tokens):**
|
|
239
|
+
```
|
|
240
|
+
event.flowInspect({ rootEntityRef: "<REF>", rootEntityType: "<TYPE>" })
|
|
241
|
+
```
|
|
242
|
+
Returns: status flow, anomaly findings, failed webhooks, slowest rulesets, event counts. This is sufficient for the Runtime Evidence section in most cases.
|
|
243
|
+
|
|
244
|
+
**Step 2: Targeted drill-down (only if compact findings indicate issues):**
|
|
245
|
+
- If anomalies found → `event.get` on specific event IDs from the compact diagnostics
|
|
246
|
+
- If webhook failures → compact response already includes failed webhook details
|
|
247
|
+
- If rule timing needed → call `event.flowInspect` with ONLY `includeRuleDetails: true` (keep compact: true)
|
|
248
|
+
- If custom log messages needed → call with ONLY `includeCustomLogs: true` (keep compact: true)
|
|
249
|
+
|
|
250
|
+
**NEVER do this** (wastes ~30k tokens of context):
|
|
251
|
+
```
|
|
252
|
+
event.flowInspect({ ..., compact: false, includeAudit: true, includeRuleDetails: true, ... })
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
**From `entity.get`:**
|
|
256
|
+
- Current entity state with edge traversal
|
|
257
|
+
- Related entities (fulfilments, items, articles)
|
|
258
|
+
- Attribute values at current state
|
|
259
|
+
|
|
260
|
+
This grounds the static analysis in real execution evidence.
|
|
261
|
+
|
|
262
|
+
**When NO runtime exists** (no entities found for this workflow type):
|
|
263
|
+
- Skip the Runtime Evidence section
|
|
264
|
+
- Automatically escalate source code analysis depth (Phase 3 Tier 2) if SOURCE is available
|
|
265
|
+
- Add the "Analysis Confidence" caveat section to the document (see below)
|
|
266
|
+
- Note in the document: "No entities of type {entityType}::{subtype} found in the environment. Runtime evidence unavailable. Deploy and process a test entity for validated analysis."
|
|
267
|
+
|
|
268
|
+
### Phase 6: Synthesis — Feature Architecture Document
|
|
269
|
+
|
|
270
|
+
Combine all findings into the output document with the following sections:
|
|
271
|
+
|
|
272
|
+
---
|
|
273
|
+
|
|
274
|
+
## Document Structure
|
|
275
|
+
|
|
276
|
+
### Section 1: Feature Overview
|
|
277
|
+
|
|
278
|
+
```markdown
|
|
279
|
+
# Feature Architecture: <Feature Name>
|
|
280
|
+
|
|
281
|
+
## Overview
|
|
282
|
+
|
|
283
|
+
**Purpose:** <1-2 sentence description of what the feature does>
|
|
284
|
+
**Primary Entity:** <entity type and subtype> (e.g., ORDER::HD)
|
|
285
|
+
**Related Entities:** <list> (e.g., FULFILMENT_CHOICE, FULFILMENT::HD_WH, ARTICLE)
|
|
286
|
+
**Workflows:** <list with versions>
|
|
287
|
+
**Entry Point:** <triggering event or API call>
|
|
288
|
+
**Terminal States:** <list of end states>
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
### Section 2: Entity Lifecycle — State Machine
|
|
292
|
+
|
|
293
|
+
One `stateDiagram-v2` per entity type showing ALL statuses and transitions:
|
|
294
|
+
|
|
295
|
+
````markdown
|
|
296
|
+
## Entity Lifecycle
|
|
297
|
+
|
|
298
|
+
### ORDER::HD
|
|
299
|
+
|
|
300
|
+
```mermaid
|
|
301
|
+
stateDiagram-v2
|
|
302
|
+
[*] --> CREATED : CreateOrder
|
|
303
|
+
CREATED --> BOOKED : BookOrder
|
|
304
|
+
BOOKED --> FULFILLED : AllFulfilmentsComplete
|
|
305
|
+
FULFILLED --> COMPLETE : CompleteOrder
|
|
306
|
+
CREATED --> CANCELLED : CancelOrder
|
|
307
|
+
BOOKED --> CANCELLED : CancelOrder
|
|
308
|
+
|
|
309
|
+
note right of CREATED : Entry point — order submitted
|
|
310
|
+
note right of BOOKED : Inventory allocated, fulfilments created
|
|
311
|
+
note right of FULFILLED : All items shipped/collected
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
### FULFILMENT::HD_WH
|
|
315
|
+
|
|
316
|
+
```mermaid
|
|
317
|
+
stateDiagram-v2
|
|
318
|
+
[*] --> CREATED : CreateFulfilment
|
|
319
|
+
CREATED --> ASSIGNED : AssignToLocation
|
|
320
|
+
ASSIGNED --> PICKED : ConfirmPick
|
|
321
|
+
PICKED --> PACKED : ConfirmPack
|
|
322
|
+
PACKED --> SHIPPED : ConfirmShipment
|
|
323
|
+
SHIPPED --> DELIVERED : ConfirmDelivery
|
|
324
|
+
SHIPPED --> COMPLETE : CompleteWithoutDelivery
|
|
325
|
+
```
|
|
326
|
+
````
|
|
327
|
+
|
|
328
|
+
### Section 3: Cross-Entity Flow — Sequence Diagram
|
|
329
|
+
|
|
330
|
+
Show the full lifecycle across entity types with event names and key data:
|
|
331
|
+
|
|
332
|
+
````markdown
|
|
333
|
+
## Cross-Entity Flow
|
|
334
|
+
|
|
335
|
+
```mermaid
|
|
336
|
+
sequenceDiagram
|
|
337
|
+
participant EXT as External System
|
|
338
|
+
participant ORD as ORDER
|
|
339
|
+
participant FC as FULFILMENT_CHOICE
|
|
340
|
+
participant FUL as FULFILMENT
|
|
341
|
+
participant LOC as Location / WMS
|
|
342
|
+
|
|
343
|
+
EXT->>ORD: CreateOrder (ref, items, customer)
|
|
344
|
+
ORD->>ORD: CREATED → Validate & Book
|
|
345
|
+
ORD->>FC: SendEvent: CreateFulfilmentChoice
|
|
346
|
+
FC->>FC: CREATED → Evaluate sourcing
|
|
347
|
+
FC->>FUL: SendEvent: CreateFulfilment (locationRef, items)
|
|
348
|
+
FC->>ORD: SendEvent: OrderBooked
|
|
349
|
+
ORD->>ORD: CREATED → BOOKED
|
|
350
|
+
|
|
351
|
+
FUL->>LOC: Webhook: NotifyWarehouse (endpoint, payload)
|
|
352
|
+
LOC-->>FUL: ConfirmPick (pickedItems)
|
|
353
|
+
FUL->>FUL: ASSIGNED → PICKED
|
|
354
|
+
FUL->>FUL: PICKED → PACKED → SHIPPED
|
|
355
|
+
|
|
356
|
+
FUL->>ORD: SendEvent: FulfilmentComplete
|
|
357
|
+
ORD->>ORD: BOOKED → FULFILLED → COMPLETE
|
|
358
|
+
```
|
|
359
|
+
````
|
|
360
|
+
|
|
361
|
+
### Section 4: Event Chain
|
|
362
|
+
|
|
363
|
+
Flowchart showing the event propagation tree:
|
|
364
|
+
|
|
365
|
+
````markdown
|
|
366
|
+
## Event Chain
|
|
367
|
+
|
|
368
|
+
```mermaid
|
|
369
|
+
flowchart TD
|
|
370
|
+
A[CreateOrder] --> B[ORDER: CREATED]
|
|
371
|
+
B --> C{Validate}
|
|
372
|
+
C -->|pass| D[BookOrder]
|
|
373
|
+
C -->|fail| E[ORDER: CANCELLED]
|
|
374
|
+
D --> F[FULFILMENT_CHOICE: CREATED]
|
|
375
|
+
F --> G[FULFILMENT: CREATED]
|
|
376
|
+
G --> H[AssignToLocation]
|
|
377
|
+
H --> I[ConfirmPick]
|
|
378
|
+
I --> J[ConfirmPack]
|
|
379
|
+
J --> K[ConfirmShipment]
|
|
380
|
+
K --> L[FULFILMENT: SHIPPED]
|
|
381
|
+
L --> M[ORDER: FULFILLED]
|
|
382
|
+
M --> N[ORDER: COMPLETE]
|
|
383
|
+
|
|
384
|
+
style E fill:#f99
|
|
385
|
+
style N fill:#9f9
|
|
386
|
+
```
|
|
387
|
+
````
|
|
388
|
+
|
|
389
|
+
### Section 5: Input → Output Data Flow
|
|
390
|
+
|
|
391
|
+
Table mapping what data enters, transforms, and exits at each step:
|
|
392
|
+
|
|
393
|
+
```markdown
|
|
394
|
+
## Input → Output Data Flow
|
|
395
|
+
|
|
396
|
+
| Step | Event / Action | Input Data | Logic / Transformation | Output / Side Effect |
|
|
397
|
+
|------|---------------|------------|----------------------|---------------------|
|
|
398
|
+
| 1 | CreateOrder | items[], customer, deliveryAddress | Validate structure | ORDER entity CREATED |
|
|
399
|
+
| 2 | BookOrder | ORDER attributes | Inventory allocation | FULFILMENT_CHOICE created |
|
|
400
|
+
| 3 | CreateFulfilment | locationRef, items | Assign to warehouse | FULFILMENT entity CREATED |
|
|
401
|
+
| 4 | ConfirmPick | pickedItems[], picker | Verify quantities | FULFILMENT → PICKED |
|
|
402
|
+
| 5 | ConfirmShipment | carrierRef, trackingNum | Link carrier | FULFILMENT → SHIPPED, webhook sent |
|
|
403
|
+
| 6 | FulfilmentComplete | fulfilmentRef | Check all complete | ORDER → FULFILLED |
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
### Section 6: Rules & Logic
|
|
407
|
+
|
|
408
|
+
Per-ruleset explanation with source:
|
|
409
|
+
|
|
410
|
+
```markdown
|
|
411
|
+
## Rules & Logic
|
|
412
|
+
|
|
413
|
+
### Ruleset: BookOrder (ORDER::HD)
|
|
414
|
+
|
|
415
|
+
| Rule | Type | Description | Reads | Produces |
|
|
416
|
+
|------|------|-------------|-------|----------|
|
|
417
|
+
| ValidateOrderAttributes | OOTB | Validates required order attributes | event.attributes | - |
|
|
418
|
+
| CreateFulfilmentChoice | Custom | Creates FC entity with sourcing logic | ORDER items, locations | FULFILMENT_CHOICE entity |
|
|
419
|
+
| SetOrderStatus | OOTB | Sets ORDER status to BOOKED | - | status: BOOKED |
|
|
420
|
+
| SendOrderBookedEvent | OOTB | Emits event for downstream | orderRef | Event: OrderBooked |
|
|
421
|
+
|
|
422
|
+
**Decision Points:**
|
|
423
|
+
- If validation fails → ORDER transitions to CANCELLED (CancelOrder ruleset)
|
|
424
|
+
- If no sourcing location found → ORDER stays BOOKED, manual intervention required
|
|
425
|
+
|
|
426
|
+
**Custom Rule Detail: CreateFulfilmentChoice**
|
|
427
|
+
- Source: `accounts/HMDEV/SOURCE/fc-module-hm-extensions/src/main/java/.../CreateFulfilmentChoiceRule.java`
|
|
428
|
+
- Reads: `order.items`, `order.deliveryAddress`, location capabilities
|
|
429
|
+
- Logic: Evaluates location proximity, stock availability, delivery SLAs
|
|
430
|
+
- Produces: FULFILMENT_CHOICE entity with selected location
|
|
431
|
+
```
|
|
432
|
+
|
|
433
|
+
### Section 7: Settings Dependencies
|
|
434
|
+
|
|
435
|
+
```markdown
|
|
436
|
+
## Settings Dependencies
|
|
437
|
+
|
|
438
|
+
| Setting Key | Context | Current Value | Used By | Purpose |
|
|
439
|
+
|------------|---------|---------------|---------|---------|
|
|
440
|
+
| WEBHOOK_ENDPOINT_ORDER_BOOK | RETAILER | https://api.example.com/orders | BookOrder ruleset | Notify external OMS |
|
|
441
|
+
| INVENTORY_ALLOCATION_STRATEGY | RETAILER | CLOSEST_LOCATION | CreateFulfilmentChoice | Sourcing algorithm |
|
|
442
|
+
| ORDER_VALIDATION_ENABLED | RETAILER | true | ValidateOrder | Feature flag |
|
|
443
|
+
| MAX_FULFILMENT_RETRIES | RETAILER | MISSING | RetryFulfilment | **Gap: setting not created** |
|
|
444
|
+
```
|
|
445
|
+
|
|
446
|
+
### Section 8: Integration Points
|
|
447
|
+
|
|
448
|
+
```markdown
|
|
449
|
+
## Integration Points
|
|
450
|
+
|
|
451
|
+
### Webhooks
|
|
452
|
+
|
|
453
|
+
| Ruleset | Endpoint Setting | HTTP Method | Payload Shape | Direction |
|
|
454
|
+
|---------|-----------------|-------------|---------------|-----------|
|
|
455
|
+
| NotifyWarehouse | WEBHOOK_WMS_FULFILMENT | POST | { fulfilmentRef, items, locationRef } | Outbound |
|
|
456
|
+
| ReceiveShipment | N/A (inbound event) | POST /event | { trackingNumber, carrier } | Inbound |
|
|
457
|
+
|
|
458
|
+
### Scheduled Events
|
|
459
|
+
|
|
460
|
+
| Ruleset | Event Name | Delay | Purpose |
|
|
461
|
+
|---------|-----------|-------|---------|
|
|
462
|
+
| RetryAllocation | RetryFulfilmentAllocation | 30min | Retry failed sourcing |
|
|
463
|
+
| EscalateStuck | EscalateStuckOrder | 24h | Alert ops team |
|
|
464
|
+
```
|
|
465
|
+
|
|
466
|
+
### Section 9: Runtime Evidence (when available)
|
|
467
|
+
|
|
468
|
+
```markdown
|
|
469
|
+
## Runtime Evidence
|
|
470
|
+
|
|
471
|
+
**Entity:** ORDER HD-001
|
|
472
|
+
**Trace period:** 2026-02-23T10:00:00Z to 2026-02-23T10:15:00Z
|
|
473
|
+
|
|
474
|
+
### Execution Timeline
|
|
475
|
+
|
|
476
|
+
| Time | Event | Entity | Status Change | Duration |
|
|
477
|
+
|------|-------|--------|--------------|----------|
|
|
478
|
+
| 10:00:01 | CreateOrder | ORDER | → CREATED | - |
|
|
479
|
+
| 10:00:02 | BookOrder | ORDER | CREATED → BOOKED | 1.2s |
|
|
480
|
+
| 10:00:03 | CreateFC | FC | → CREATED | 0.8s |
|
|
481
|
+
| 10:00:04 | CreateFulfilment | FUL | → CREATED | 0.5s |
|
|
482
|
+
| 10:05:30 | ConfirmPick | FUL | ASSIGNED → PICKED | 0.3s |
|
|
483
|
+
|
|
484
|
+
### Anomalies
|
|
485
|
+
|
|
486
|
+
- No anomalies detected (all events SUCCESS)
|
|
487
|
+
- OR: `RetryAllocation` fired 3 times before success (check inventory levels)
|
|
488
|
+
```
|
|
489
|
+
|
|
490
|
+
### Section 10: Analysis Confidence (always included)
|
|
491
|
+
|
|
492
|
+
This section is **always** included in the document and communicates the depth and reliability of the analysis based on what evidence was available.
|
|
493
|
+
|
|
494
|
+
```markdown
|
|
495
|
+
## Analysis Confidence
|
|
496
|
+
|
|
497
|
+
### Evidence Availability
|
|
498
|
+
|
|
499
|
+
| Source | Available | Impact |
|
|
500
|
+
|--------|-----------|--------|
|
|
501
|
+
| Workflow JSON | Yes | State machine, rulesets, triggers, props — **structural analysis complete** |
|
|
502
|
+
| plugin.list (deployed rules) | Yes | Rule descriptions, parameters, entity types — **rule behavior inferred** |
|
|
503
|
+
| workflow.transitions (live) | Yes | User actions validated against deployed workflow |
|
|
504
|
+
| Source code (Java) | No | Custom rule internals unknown — prop-to-code validation not possible |
|
|
505
|
+
| Runtime evidence | No | No executed entities found — theoretical flow only, not validated |
|
|
506
|
+
|
|
507
|
+
### Confidence Levels
|
|
508
|
+
|
|
509
|
+
| Aspect | Confidence | Reason |
|
|
510
|
+
|--------|------------|--------|
|
|
511
|
+
| State machine (statuses, transitions) | HIGH | Derived from workflow JSON — definitive |
|
|
512
|
+
| Event chain (happy path) | HIGH | Traced through rulesets + triggers — deterministic |
|
|
513
|
+
| Event chain (error/edge paths) | MEDIUM | Inferred from trigger coverage — not runtime-validated |
|
|
514
|
+
| Custom rule behavior | LOW | Only plugin.list description available — actual Java logic not inspected |
|
|
515
|
+
| Webhook payload shapes | LOW | Setting keys identified but payload templates not inspected |
|
|
516
|
+
| Integration timing / performance | N/A | No runtime evidence |
|
|
517
|
+
| Settings values | MEDIUM | Keys identified from rule props — current values need `/fluent-settings` audit |
|
|
518
|
+
|
|
519
|
+
### Recommendations for Higher Confidence
|
|
520
|
+
|
|
521
|
+
1. **Clone plugin source code** to `accounts/<PROFILE>/SOURCE/` and re-run with source analysis:
|
|
522
|
+
- Enables prop-to-code validation for custom rules
|
|
523
|
+
- Reveals actual logic, edge cases, and error handling
|
|
524
|
+
- Shows test coverage per rule
|
|
525
|
+
2. **If source repos unavailable, provide module JARs** in `accounts/<PROFILE>/SOURCE/`:
|
|
526
|
+
- Run `/fluent-custom-code` to decompile JARs into `.decompiled/` (CFR or Fernflower)
|
|
527
|
+
- Decompiled source gives MEDIUM confidence (synthetic variable names, no comments)
|
|
528
|
+
- Still enables cross-referencing workflow props against actual `context.getProp()` calls
|
|
529
|
+
3. **Process a test entity** through the workflow and re-run with `--include-runtime`:
|
|
530
|
+
- Validates which rulesets actually fire
|
|
531
|
+
- Reveals timing, webhook responses, and NO_MATCH events
|
|
532
|
+
- Confirms the theoretical flow matches reality
|
|
533
|
+
3. **Run `/fluent-settings` audit** to verify all referenced settings exist with correct values
|
|
534
|
+
```
|
|
535
|
+
|
|
536
|
+
**Confidence level rules:**
|
|
537
|
+
|
|
538
|
+
| Evidence combination | Custom rule confidence | Flow confidence |
|
|
539
|
+
|---------------------|----------------------|-----------------|
|
|
540
|
+
| Workflow JSON + plugin.list only | LOW | HIGH (structure) / MEDIUM (behavior) |
|
|
541
|
+
| + Decompiled JAR (no original source) | MEDIUM | HIGH |
|
|
542
|
+
| + Original source code | HIGH | HIGH |
|
|
543
|
+
| + Runtime evidence | HIGH (validated) | HIGH (validated) |
|
|
544
|
+
| All three (original source + runtime) | HIGHEST — fully validated | HIGHEST — fully validated |
|
|
545
|
+
|
|
546
|
+
---
|
|
547
|
+
|
|
548
|
+
## Arguments
|
|
549
|
+
|
|
550
|
+
| Argument | Description | Default |
|
|
551
|
+
|----------|-------------|---------|
|
|
552
|
+
| `<feature>` | Feature name, workflow name (e.g., `ORDER::HD`), or entity ref | Required |
|
|
553
|
+
| `--depth shallow` | Primary workflow only, no cross-entity tracing | `full` |
|
|
554
|
+
| `--depth full` | All related workflows, cross-entity flows, settings, integrations | Default |
|
|
555
|
+
| `--include-runtime` | Collect live event trace via `event.flowInspect` | Off unless entity ref provided |
|
|
556
|
+
| `--output <path>` | Custom output path instead of default `accounts/<PROFILE>/analysis/features/` | Auto-generated |
|
|
557
|
+
|
|
558
|
+
## Quality Checklist
|
|
559
|
+
|
|
560
|
+
Before saving the document, verify:
|
|
561
|
+
|
|
562
|
+
- [ ] State diagram shows ALL statuses in the workflow, not just the happy path
|
|
563
|
+
- [ ] Cross-entity sequence diagram includes event names AND key data flowing between entities
|
|
564
|
+
- [ ] Every ruleset in scope has an explanation row in the Rules & Logic table
|
|
565
|
+
- [ ] Settings table shows current values with MISSING flagged for any gaps
|
|
566
|
+
- [ ] Integration points table includes endpoint, HTTP method, and payload shape
|
|
567
|
+
- [ ] Input → Output data flow table covers every step from entry to terminal
|
|
568
|
+
- [ ] Custom rules have source file paths (or "source unavailable" noted)
|
|
569
|
+
- [ ] Terminal states are clearly identified (success AND failure paths)
|
|
570
|
+
- [ ] Mermaid diagrams render correctly — validate against `/fluent-mermaid-validate` rules (no colons in free text, no unicode arrows, quoted special-char labels)
|
|
571
|
+
- [ ] Metadata header includes profile, retailer, workflow versions, generation timestamp
|
|
572
|
+
- [ ] **Analysis Confidence section is present** with evidence availability table and per-aspect confidence levels
|
|
573
|
+
- [ ] **Missing evidence is called out** — if no source code or runtime, recommendations section explains how to get higher confidence
|
|
574
|
+
|
|
575
|
+
## Cross-References
|
|
576
|
+
|
|
577
|
+
- Workflow structure details: `/fluent-workflow-analyzer`
|
|
578
|
+
- Custom code behavior: `/fluent-custom-code`
|
|
579
|
+
- Connection topology: `/fluent-connection-analysis`
|
|
580
|
+
- Runtime debugging: `/fluent-trace`
|
|
581
|
+
- Settings audit: `/fluent-settings`
|
|
582
|
+
- Environment discovery: `/fluent-mcp-tools` → `environment.discover`
|
|
583
|
+
- Rule descriptions: `/fluent-mcp-tools` → `plugin.list`
|
|
584
|
+
- User actions per status: `/fluent-mcp-tools` → `workflow.transitions`
|
|
585
|
+
|
|
586
|
+
## Example Usage
|
|
587
|
+
|
|
588
|
+
```bash
|
|
589
|
+
# Explain a workflow by name
|
|
590
|
+
/fluent-feature-explain ORDER::HD
|
|
591
|
+
|
|
592
|
+
# Explain a named feature (maps to workflows automatically)
|
|
593
|
+
/fluent-feature-explain "Home Delivery"
|
|
594
|
+
|
|
595
|
+
# Shallow analysis — single workflow only
|
|
596
|
+
/fluent-feature-explain FULFILMENT::HD_WH --depth shallow
|
|
597
|
+
|
|
598
|
+
# Include runtime evidence from a real entity
|
|
599
|
+
/fluent-feature-explain ORDER::HD --include-runtime HD-001
|
|
600
|
+
|
|
601
|
+
# Custom output path
|
|
602
|
+
/fluent-feature-explain "Click & Collect" --output ./docs/cc-feature.md
|
|
603
|
+
```
|