Skip to content

feat: add the stacflow SDK and move flow_ui into a pub workspace - #45

Merged
divyanshub024 merged 11 commits into
mainfrom
feat/workspace
Sep 21, 2026
Merged

divyanshub024 merged 11 commits into
mainfrom
feat/workspace

Conversation

@divyanshub024

@divyanshub024 divyanshub024 commented Sep 16, 2026 •

Copy link
Copy Markdown
Member

Summary

Turns the repo into a Dart pub workspace and adds the StacFlow SDK beside flow_ui.

  • packages/flow_ui is the published package, moved as-is. Every file under lib/ is a pure rename; no widget changes.
  • packages/stacflow is the SDK: StacFlowChat, the controller, and StacFlowChatView, the ready-made screen on flow_ui. Gemini, OpenAI and Claude adapters run natively with the developer's own key behind one TurnTransport seam, with streaming, stop, retry, regenerate, edit and resend, image attachments, copy, feedback and a model selector. The key is a private field set on exactly one header and never appears in URLs, logs or errors.
  • Tools: Tool with read, write and destructive permissions, a confirmation card for gated calls, runToolLoop (dispatch, approval, timeouts, abort, continuation segments, a rounds cap), and the tool card in the thread with toolBodyBuilder for custom result bodies. Calls and results replay to the model in later turns on all three providers; Claude thinking blocks and Gemini signatures replay within a turn. Provider call ids ride inside the tc_ ids, so contracts/ is unchanged by tools.
  • contracts/ holds the wire contract (SSE events, error codes) with tool/contracts_gen.dart generating packages/stacflow/lib/src/generated and CI failing on drift.
  • Docs: package READMEs, the stacflow example app against Gemini with a set_theme tool, and CLAUDE.md/AGENTS.md for the workspace conventions.
  • Root pubspec.yaml carries the melos scripts; playground and packages/stacflow depend on flow_ui: ^0.4.0.

Releases stay per package: flow_ui-v* and stacflow-v* tags. stacflow keeps publish_to: none until the 0.1.0 tag; the version bump is a follow-up.

Screenshots

Nothing in flow_ui renders differently; every lib/ file is a pure move. The SDK's view composes existing flow_ui components (thread, composer, tool and confirmation cards).

How this was verified

  • dart run melos run analyze clean in all five members; dart format --set-exit-if-changed . clean.
  • Smoke script (packages/stacflow/tool/smoke.dart) against Claude with TOOLS=true, including TOOL_PERMISSION=destructive and DECLINE=true.
  • The stacflow example app against Gemini on web (chat, stop, retry, the set_theme tool).
  • A banking demo app on Claude, on the iOS simulator: theme switch, a read tool rendering a custom card, a destructive transfer with confirm and decline, and a tool rendering model-generated Stac JSON.
  • Gemini and OpenAI tool calling compile and share the runner but have not been exercised live since the tool work landed.

Checklist

  • dart run melos run analyze is clean
  • dart run melos run format applied
  • Exercised in the playground (no new flow_ui component; the playground builds and runs from its new workspace position)
  • Any new entry under dependencies: in packages/flow_ui/pubspec.yaml is flutter.dev-published, forces no configuration on hosts that never use the feature, and is argued in this PR (none added)
  • Nothing model-facing in flow_ui; prompts, schemas and provider calls live only in packages/stacflow, enforced by the CI grep
  • New public API is exported from packages/flow_ui/lib/flow_ui.dart and documented in docs/ and the README table (no new flow_ui API; stacflow's API is exported from lib/stacflow.dart and documented in its README; the docs site pages come later)
  • packages/flow_ui/CHANGELOG.md updated for user-facing changes, with breaking changes called out (no flow_ui changes in this PR; the stacflow CHANGELOG carries 0.1.0)
  • PR title follows conventional commits (feat:, fix:, refactor:, docs:, chore:)

Note

High Risk
Large monorepo and release-process change plus a new SDK that handles API keys, provider HTTP, streaming, and client tool execution—areas that are security- and behavior-sensitive even though flow_ui widgets are largely unchanged.

Overview
Restructures the repository into a Dart pub workspace (root pubspec.yaml + melos for analyze/format/test) and moves the published UI library to packages/flow_ui at 0.4.0, with per-package .pubignore, a slim root README, and docs/playground paths updated accordingly.

Adds packages/stacflow, the StacFlow SDK: StacFlowChat / StacFlowChatView on flow_ui, Gemini/OpenAI/Claude providers, streaming turn transport, client tools (permissions, confirmations, tool loop), plus a runnable example app and contracts/ wire specs (SSE events and error codes) aligned with hand-maintained transport types.

CI and release shift to workspace-wide checks, a boundaries job (flow_ui must not depend on stacflow), app matrix builds for flow_ui example, stacflow example, and playground, and per-package release tags (flow_ui-v*, stacflow-v*) driving pana, pub publish, and docs deploy. Example apps switch API keys to --dart-define / gitignored env files instead of committed stubs where applicable.

Reviewed by Cursor Bugbot for commit e15020f. Bugbot is set up for automated code reviews on this repo. Configure here.

flow_ui moves unchanged to packages/flow_ui; the repo root becomes the
pub workspace with melos scripts, and stacflow lives beside it as
packages/stacflow so the two version in lockstep. The SDK re-exports
flow_ui and adds Gemini, OpenAI and Claude adapters behind one transport
seam, a client-side tool loop with read, write and destructive
permissions, and the wire contract under contracts/ with its codegen.
Provider call ids ride inside the tc_ tool-call ids, so tools land
without a contract change.

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread packages/stacflow/lib/src/providers/openai_provider.dart
Comment thread docs/src/content/docs/stacflow/getting-started.mdx Outdated
Comment thread docs/src/content/docs/stacflow/getting-started.mdx Outdated

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread packages/stacflow/lib/src/providers/openai_provider.dart
…he local-mode launch

The first release is stacflow without a gateway, so the contract folder
becomes the SDK's own spec: the REST spec, the cloud-only error codes,
the ui_payload event, the A2UI stub, the contracts lock and the mirror
script into stacflow-cloud go. The stacflow docs-site pages come back
with the site work later; the README carries the platform entries a
host needs in the meantime.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit edfe1d3. Configure here.

Comment thread packages/stacflow/lib/src/providers/turn_runner.dart Outdated
…odegen

The generator was 594 lines producing 456, against a schema this package is
the only consumer of. contracts/ stays as the specification; sse_events.dart
and error_codes.dart move next to the rest of the transport layer and are
maintained by hand, which also puts them under very_good_analysis for the
first time.
@StacDev StacDev deleted a comment from coderabbitai Bot Sep 21, 2026
withSupportedImages had no label to pass: wire_history.dart knew the
attachment's name but WireImagePart did not carry it, so a HEIC on Claude or
a GIF on Gemini reached the model as "Attachment file" instead of its name.
@StacDev StacDev deleted a comment from coderabbitai Bot Sep 21, 2026
…shable

Five review findings on this branch. finish() closed the controller without
marking the emitter done, so stopping a turn mid-request threw twice. retry()
spliced a failed turn out of the middle, leaving a history that ended with an
assistant turn. editAndResend truncated the thread before discovering it had
nothing to send. The pana gate never stubbed the example's gitignored key
file, unlike ci.yml. And the examples' `resolution: workspace` shipped inside
the published archives, where no workspace root exists to resolve it.
@StacDev StacDev deleted a comment from coderabbitai Bot Sep 21, 2026
@divyanshub024
divyanshub024 merged commit 95ff229 into main Sep 21, 2026
9 checks passed
@divyanshub024
divyanshub024 deleted the feat/workspace branch September 21, 2026 18:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant