Skip to content

feat(flow): kbagent flow examples + fix drifted flow schema (port get_flow_examples) #397

@padak

Description

@padak

Part of #390.

Summary

Add kbagent flow examples (port of get_flow_examples) and, at the same time, fix the drifted hand-written flow schema by porting the authoritative flow JSON schemas.

MCP source (keboola-mcp-server @ agent-v1.60.0)

  • Examples: src/keboola_mcp_server/tools/flow/tools.py (get_flow_examples) loads static bundled files via importlib.resources:
    • resources/flow_examples/conditional_flow_examples.jsonl — 2 examples (for keboola.flow; string-UUID ids, graph next: [...]).
    • resources/flow_examples/legacy_flow_examples.jsonl — 2 examples (for keboola.orchestrator; integer ids, dependsOn: [...]).
    • Gated: keboola.flow examples require the project conditional_flows feature ('hide-conditional-flows' not in project_features).
  • Schemas (sibling): tools/flow/utils.py FLOW_SCHEMAS → static bundled flow-schema.json / conditional-flow-schema.json.

What kbagent already has

  • Examples: nothing — no bundled files, no fetch path (there is no endpoint; bundling is the only option).
  • Schema is drifted: commands/flow.py _FLOW_SCHEMA is a hand-written triple-quoted string covering only keboola.flow, drifted independently from the MCP server's authoritative JSON schemas, with no orchestrator variant. flow_service.py has no schema/examples methods.
  • Both flow types are already modelled: _FLOW_COMPONENT_CHOICES = ["keboola.orchestrator", "keboola.flow"]; flow new/flow update already take --component-id for both.

Proposed command(s)

kbagent flow examples [--component-id keboola.orchestrator|keboola.flow]

Plus: replace _FLOW_SCHEMA with the bundled authoritative flow-schema.json + conditional-flow-schema.json, so flow schema [--component-id …] serves the correct schema per type.

Implementation sketch

  • Bundle the two .jsonl example files and the two schema JSON files copied from the MCP server into src/keboola_agent_cli/resources/flow_examples/ (+ schemas), loaded via importlib.resources. Add the data files to packaging (pyproject.toml / hatch include).
  • L2 small loader in flow_service.py returning the parsed list / schema per type.
  • L1 flow examples thin command (dual output: JSON list of flow-config dicts; human = numbered JSON blocks). Update flow schema to read the bundled schema per --component-id.

Effort: M

Dominated by bundling static resource files + packaging + tests, not logic.

Acceptance criteria

  • kbagent flow examples --component-id keboola.flow and …keboola.orchestrator each return their examples.
  • flow schema --component-id … serves the authoritative schema for both flow types (orchestrator variant added).
  • --json emits structured dicts.
  • Packaging includes the new data files (verified in a built wheel).
  • Unit test + E2E test.
  • Doc-sync surfaces per Epic: Port keboola-mcp-server agent tools into native kbagent commands #390 checklist.

Risks / open questions

  • Static-bundle drift: copying examples/schemas forks a second copy that can rot — exactly the failure already present in _FLOW_SCHEMA. Mitigate with a sync note/script; treat examples as illustrative. (No API to fetch them.)
  • Feature gate: kbagent has no conditional_flows/project_features plumbing today. Recommendation: ship ungated v1 (examples are static illustrative text; flow new already accepts both types), document that keboola.flow needs the feature. Adding the gate later is optional.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions