搜索插件、代码仓与 APP 分类

插件详情v1.2.0

fluttersdk_wind_diagnostics_contracts

Wind UI 小部件状态契约,用于 Flutter 调试工具和 AI 代理(MCP)。零依赖的抽象接口,由 fluttersdk_wind 实现,在 fluttersdk_dusk 中使用。

AndroidiOSLinuxmacOSWebWindows
近 30 天下载
17.9万
喜欢数
1
Pub 分数
150

安装插件

flutter pub add fluttersdk_wind_diagnostics_contracts

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

一个无依赖的抽象接口,用于在 Flutter 中定义 Wind UI 小部件状态契约,旨在支持调试工具和 AI 代理(MCP)。该实现位于 fluttersdk_wind 中,并由 fluttersdk_dusk 使用,可在不同平台上实现一致的诊断功能。该包提供了一种标准化的方法,用于在开发和调试过程中检查和分析小部件状态,促进工具与代理之间的互操作性。它具有平台无关性,支持 Android、iOS、Linux、macOS、Web 和 Windows。

适合场景

  • 调试 widget 状态问题
  • 启用AI驱动的代码辅助
  • 与开发工具集成
  • 在测试期间分析UI行为
  • 支持自动化诊断
  • 促进跨平台调试

主要特点

  • 零依赖设计
  • 小部件状态的抽象接口
  • 平台无关的实现
  • 专为AI代理(MCP)设计
  • 专为调试工具集成而构建
  • 一致的契约定义

适合对象

  • 使用高级调试工具的Flutter开发者
  • 构建AI辅助开发功能的团队
  • 工具和 IDE 插件开发者
  • 跨平台 UI 测试器
  • 调试框架贡献者

使用建议

  • 需要与 fluttersdk_wind 和 fluttersdk_dusk 集成
  • 不打算在应用逻辑中直接使用
  • 依赖外部工具链生态系统
  • 限于诊断和分析工作流
  • 孤立状态下无运行时功能

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

Wind Diagnostics Contracts Logo

Wind Diagnostics Contracts

Wind UI widget state contracts for Flutter debug-tooling and AI agents (MCP).
Zero-dep abstract resolver interface plus process-global registry. The plugin_platform_interface pattern, applied to UI framework and debug tooling decoupling. ~80 LoC, frozen v1 contract.

pub package CI License: MIT pub points GitHub stars

Documentation · pub.dev · Issues


Use cases

This package is the integration seam for any tool that needs runtime Wind UI state without pulling Wind into its compile graph:

  • LLM-agent E2E testing for Flutter: MCP servers and AI assistants (Claude Code, Cursor, Copilot) that drive a Flutter app need structured widget state (className, breakpoint, brightness, platform, states, colors) per Element, not screenshots. This package is the typed contract those tools read.
  • DevTools extensions: build a custom Wind inspector tab in Dart DevTools without a hard fluttersdk_wind dependency that drags the rendering surface into the extension bundle.
  • E2E drivers (fluttersdk_dusk, patrol_mcp, marionette_mcp, custom): emit a wind: block in snapshot YAML / JSON without importing Wind. Tests stop breaking when a className is renamed because the contract surfaces semantic state, not selectors.
  • Tailwind-on-Flutter authors: any styling library that follows Wind's className convention can implement this contract to expose its state to the same debug-tooling ecosystem.

Why this package exists

Wind UI (pub.dev) exposes runtime widget state (className, breakpoint, brightness, platform, states, bgColor, textColor) that debug-tooling packages such as fluttersdk_dusk (pub.dev) embed in their snapshot YAML so LLM agents can reason about the rendered tree.

Shipping that handoff through fluttersdk_wind's own surface would force every debug-tool to compile-time depend on Wind, dragging the full rendering surface and bumping debug-tool builds on every Wind release. Shipping it the other way (Wind depending on each debug tool) is even worse.

This package breaks the loop. Both sides depend on the abstract contract here; neither side imports the other.

                    fluttersdk_wind_diagnostics_contracts
                              |
              +---------------+---------------+
              |                               |
       fluttersdk_wind                  fluttersdk_dusk
       (registers a resolver)         (reads the resolver
                                       at snapshot time)

The pattern mirrors Flutter's *_platform_interface convention. plugin_platform_interface (the canonical precedent) sits at 4.97M downloads on pub.dev for exactly this reason.


Install

flutter pub add fluttersdk_wind_diagnostics_contracts

Most consumers never add this dep by hand. fluttersdk_wind declares it as a direct production dependency, so any app that already depends on Wind picks it up transitively. Add it explicitly when you are authoring a debug-tooling package that reads Wind state without depending on Wind itself.


Usage

Registering a resolver (in fluttersdk_wind)

Wind installs its concrete resolver at app boot, gated by kDebugMode so release builds tree-shake the entire registration site:

import 'package:flutter/foundation.dart' show kDebugMode;
import 'package:fluttersdk_wind/fluttersdk_wind.dart';

void main() {
  if (kDebugMode) {
    Wind.installDebugResolver();
  }
  runApp(const MyApp());
}

Wind.installDebugResolver() is a one-liner inside fluttersdk_wind that does:

import 'package:fluttersdk_wind_diagnostics_contracts/fluttersdk_wind_diagnostics_contracts.dart';

WindDebugRegistry.register(const WindDebugResolverImpl());
Reading the resolver (in a debug-tooling package)

The consumer looks up the currently-installed resolver and calls resolve(element) per Element it wants to inspect. The resolver returns const {} for non-Wind widgets, so the walk is safe for any element:

import 'package:fluttersdk_wind_diagnostics_contracts/fluttersdk_wind_diagnostics_contracts.dart';

void emitWindBlock(StringBuffer buffer, Element element) {
  final WindDebugResolver? resolver = WindDebugRegistry.current;
  if (resolver == null) return; // wind not in this app, or release build.

  final Map<String, Object?> data = resolver.resolve(element);
  if (data.isEmpty) return; // not a Wind widget.

  buffer.writeln('wind:');
  data.forEach((key, value) {
    buffer.writeln('  $key: $value');
  });
}

The returned map's key set is documented as the v1 frozen contract (see CHANGELOG.md for the full key list).

Reading aggregate performance counters

WindDebugResolver answers per-Element questions, so it has nowhere to put a number that belongs to no single element: a cache hit rate, a build count. WindPerfResolver is a second, independent contract for exactly those, with its own registry slot. Registering one never touches the other.

final WindPerfResolver? perf = WindDebugRegistry.currentPerf;
if (perf == null) return; // wind not in this app, or the resolver was never installed.

final Map<String, Object?> stats = perf.stats();
// cacheHits, cacheMisses, cacheBypasses, cacheSize, wDivBuilds, wTextBuilds; all int.

Wind installs it with Wind.installPerfResolver(), separately from installDebugResolver(), because the two answer different questions and a host may want one without the other. Counting itself stays off until wind's own flag is set, so installing the resolver costs nothing. That method ships in the fluttersdk_wind release that pairs with this contract; a reader on an earlier wind will not find it yet.

The null is worth passing through rather than flattening to zeros: it is what lets a consumer tell "no resolver was ever registered" from "the counters really are zero".

Test seams

WindDebugRegistry exposes four @visibleForTesting helpers so debug-tool tests can register fake resolvers without going through Wind. resetForTesting() clears BOTH slots; registerForTesting and registerPerfForTesting install a fake into one each:

import 'package:flutter_test/flutter_test.dart';
import 'package:fluttersdk_wind_diagnostics_contracts/fluttersdk_wind_diagnostics_contracts.dart';

class _FakeResolver implements WindDebugResolver {
  @override
  Map<String, Object?> resolve(Element element) {
    return const <String, Object?>{
      'className': 'flex p-4',
      'breakpoint': 'lg',
      'brightness': 'light',
      'platform': 'web',
      'states': <String>['hover'],
    };
  }
}

void main() {
  setUp(() => WindDebugRegistry.resetForTesting());

  testWidgets('observe emits wind block from registry', (tester) async {
    WindDebugRegistry.registerForTesting(_FakeResolver());
    // ... rest of the test ...
  });
}

Versioning

This package follows Semantic Versioning 2.0.0. Two return-map key sets are the load-bearing contract, WindDebugResolver.resolve's and WindPerfResolver.stats's, and the same rule governs both: additive changes (new keys in the returned map) are non-breaking; renaming or removing existing keys requires a major bump. Adding a METHOD to either contract is breaking, since it breaks every implementer including the test fakes, which is why the perf counters got a second contract rather than a second method on the first.


License

MIT. See LICENSE.

所属分类

依赖

依赖清单 1 项

源码仓库

使用此插件的项目

所在榜单