Skip to content

Commit 40c4e16

Browse files
authored
feat: add flowr serve — interactive D3.js visualization server (1.1.0)
Copied from flowr-viz: FastAPI REST API, D3.js frontend, --edit flag, [viz] extra. 20 BDD examples, 0 ruff errors, 0 pyright errors.
1 parent 3b150b4 commit 40c4e16

170 files changed

Lines changed: 8191 additions & 4475 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.opencode/knowledge/workflow/flowr-spec.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ last-updated: 2026-05-06
1212
- Declare `exits` on every flow as its contract with parent flows; parent `next` keys must match child `exits` exactly.
1313
- Use `conditions` blocks on states to define named condition groups; reference them in transitions with `when`.
1414
- Guarded transitions use `when` with expression strings (`==true`, `>=80%`); `when` accepts a dict, a named ref string, or a list mixing both; conditions are AND-combined with no inheritance.
15-
- Carry runtime metadata in state-level `attrs` (agent, skills, git, input_artifacts, etc.); `attrs` is opaque to the engine and replaces flow-level attrs entirely (no merge).
15+
- Carry runtime metadata in state-level `attrs` (agent, skills, input_artifacts, etc.); `attrs` is opaque to the engine and replaces flow-level attrs entirely (no merge).
1616
- All CLI commands output **JSON by default** (structured, machine-parseable). Use `--text` flag for human-readable plain text.
1717
- `next` command shows **all** transitions with status markers (`"open"` / `"blocked"`) and condition hints for blocked transitions.
18-
- Sessions track workflow progress (flow, state, call stack) as YAML files in `.flowr/sessions/` with atomic writes; `--session` on check/next/transition resolves flow/state automatically.
18+
- Sessions track workflow progress (flow, state, call stack) as YAML files in `.cache/sessions/` with atomic writes; `--session` on check/next/transition resolves flow/state automatically.
1919
- Subflow exit names resolve through the parent flow's transition map (not used directly as state IDs). Enables subflow chaining and recursive entry up to 3 levels.
2020
- Configuration reads `[tool.flowr]` from `pyproject.toml` (flows_dir, sessions_dir, default_flow, default_session); CLI flags override pyproject.toml which overrides defaults.
21-
- Flow name resolution: commands accept short names (e.g., `planning-flow`) resolved from the configured flows directory, or full file paths.
21+
- Flow name resolution: commands accept short names (e.g., `architecture-flow`) resolved from the configured flows directory, or full file paths.
2222
- Immutable loaded flows, closed evidence schema, isolated subflow context, filesystem wins over session on conflict. Extension fields (non-reserved keys) are allowed and not interpreted by the validator.
2323

2424
## Concepts
@@ -31,11 +31,11 @@ last-updated: 2026-05-06
3131

3232
**Conditions and Guards**: States may define `conditions` blocks containing named condition groups. Transitions reference these groups with `when` to create guarded transitions. The `when` field accepts three forms: a dict (inline condition-map), a string (reference to a named group), or a list (mix of named refs and inline dicts). All conditions are AND-combined. A named ref that does not match a group defined on the same state causes a validation error. Condition expressions use operators `==`, `!=`, `>=`, `<=`, `>`, `<`. Numeric extraction is applied to both sides (e.g., `>=80%` vs `75%` compares 80 vs 75). Plain strings without operators are treated as `==` (implicit equality). No inheritance; every condition is explicit on the transition where it applies.
3333

34-
**State Attrs**: State-level `attrs` carry runtime metadata that the flowr engine ignores but agents and skills read. Common keys: `description`, `owner`, `skills`, `git`, `input_artifacts`, `edited_artifacts`, `output_artifacts`. The `git` key (`main` or `feature`) determines the branch for commits. State-level `attrs` replace flow-level attrs entirely (no merge, no deep merge). The `attrs` field is the designated extension point: implementations should place implementation-specific data inside `attrs` rather than as top-level keys.
34+
**State Attrs**: State-level `attrs` carry runtime metadata that the flowr engine ignores but agents and skills read. Common keys: `description`, `owner`, `skills`, `input_artifacts`, `edited_artifacts`, `output_artifacts`. State-level `attrs` replace flow-level attrs entirely (no merge, no deep merge). The `attrs` field is the designated extension point: implementations should place implementation-specific data inside `attrs` rather than as top-level keys.
3535

3636
**Subflow Invocation**: A state with a `flow:` field becomes a subflow invocation. The parent's `next` keys must match the child's `exits` exactly. Subflows use a call-stack mechanism: push on entry, pop on exit. Context is isolated: only the current flow is visible. Cross-flow cycles are forbidden.
3737

38-
**Subflow Exit Resolution (v1.0.0)**: Exit names resolve through the parent flow's transition map instead of being used directly as state IDs. This enables subflow chaining (atomic exit + re-enter next subflow) and recursive subflow entry up to 3 levels deep (e.g., main-flow → feature-dev-flow → planning-flow). Stack frames record the correct parent state (subflow wrapper, not pre-transition state).
38+
**Subflow Exit Resolution (v1.0.0)**: Exit names resolve through the parent flow's transition map instead of being used directly as state IDs. This enables subflow chaining (atomic exit + re-enter next subflow) and recursive subflow entry up to 3 levels deep (e.g., define-flow → spec-validation-flow). Stack frames record the correct parent state (subflow wrapper, not pre-transition state).
3939

4040
## Content
4141

@@ -102,18 +102,18 @@ States may define a `conditions` block (sibling of `attrs` and `next`) containin
102102

103103
```yaml
104104
conditions:
105-
invest_passed:
105+
invest-passed:
106106
independent: ==true
107107
negotiable: ==true
108108
valuable: ==true
109109
next:
110110
done:
111111
to: next-state
112-
when: invest_passed
112+
when: invest-passed
113113
partial:
114114
to: review
115115
when:
116-
- invest_passed
116+
- invest-passed
117117
- { override: "==yes" }
118118
```
119119
@@ -137,7 +137,7 @@ Named condition references in `when` clauses must resolve to a key in the same s
137137
- Cross-flow cycles are forbidden (detected via DFS at load time)
138138
- Exit names resolve through parent flow's transition map (not used directly as state IDs)
139139
- Subflow chaining: atomic exit + re-enter next subflow without manual state manipulation
140-
- Recursive entry: supports up to 3-level nesting (mainfeature-dev → planning)
140+
- Recursive entry: supports up to 3-level nesting (define-flowdiscovery-flow, develop-flow → development-flow, etc.)
141141
- Stack frames record the subflow wrapper state (not the pre-transition state)
142142
- `.yaml` extension fallback: flow references without extension are resolved automatically
143143
- `session init` auto-enters subflow when first state has a `flow:` field
@@ -176,7 +176,7 @@ A flow definition MAY contain fields not specified in the specification. Such ex
176176

177177
### Session Model
178178

179-
Sessions persist workflow progress as YAML files in `.flowr/sessions/` with atomic writes (temp-file-then-rename). Each session tracks:
179+
Sessions persist workflow progress as YAML files in `.cache/sessions/` with atomic writes (temp-file-then-rename). Each session tracks:
180180

181181
| Field | Description |
182182
|-------|-------------|
@@ -197,8 +197,8 @@ flowr reads `[tool.flowr]` from `pyproject.toml`. Resolution priority: CLI flags
197197
| Key | Default | Description |
198198
|-----|---------|-------------|
199199
| `flows_dir` | `.flowr/flows` | Directory containing flow YAML files |
200-
| `sessions_dir` | `.flowr/sessions` | Directory for session YAML files |
201-
| `default_flow` | `main-flow` | Flow name used when none specified |
200+
| `sessions_dir` | `.cache/sessions` | Directory for session YAML files |
201+
| `default_flow` | `define-flow` | Flow name used when none specified |
202202
| `default_session` | `default` | Session name used with bare `--session` |
203203

204204
### Design Principles

0 commit comments

Comments
 (0)