Add declarative Flow CLI support

Currently, declarative flows can be loaded by the runtime, but the CLI
still treats them as an experimental definition file instead of a
first-class Flow project shape.

With this PR, `crewai create flow --declarative` scaffolds a YAML-backed
Flow project, and `crewai run`, `crewai flow kickoff`, and `crewai flow
plot` can run against the configured definition.

This also lets crew actions reference reusable crew definition files or
folders and override their inputs from the Flow definition, so
declarative flows can compose existing declarative crews without
inlining everything.
This commit is contained in:
Vinicius Brasil
2026-06-22 16:13:12 -07:00
parent 0391febc6c
commit 9e220b1617
20 changed files with 1226 additions and 348 deletions

View File

@@ -0,0 +1,31 @@
from __future__ import annotations
from pathlib import Path
from crewai_cli.create_flow import create_flow
def test_create_flow_declarative_scaffold(monkeypatch, tmp_path: Path):
monkeypatch.chdir(tmp_path)
create_flow("Research Flow", declarative=True)
project_root = tmp_path / "research_flow"
assert (project_root / "flow.yaml").is_file()
assert (project_root / "crews").is_dir()
assert (project_root / "tools").is_dir()
assert (project_root / "knowledge").is_dir()
assert (project_root / "skills").is_dir()
assert not (project_root / "src").exists()
pyproject = (project_root / "pyproject.toml").read_text(encoding="utf-8")
assert 'type = "flow"' in pyproject
assert 'definition = "flow.yaml"' in pyproject
assert (
'only-include = ["flow.yaml", "crews", "tools", "knowledge", "skills"]'
in pyproject
)
flow_definition = (project_root / "flow.yaml").read_text(encoding="utf-8")
assert "schema: crewai.flow/v1" in flow_definition
assert "name: ResearchFlow" in flow_definition