trajectoryToolManifestDiff function

({List<String> added, List<String> modified, List<String> removed}) trajectoryToolManifestDiff(
  1. TrajectoryToolManifestBlob? before,
  2. TrajectoryToolManifestBlob? after
)

The tool-set diff between two manifest versions (F2): names only — renderers pull descriptions/schemas from the blobs.

Implementation

({List<String> added, List<String> removed, List<String> modified})
trajectoryToolManifestDiff(
  TrajectoryToolManifestBlob? before,
  TrajectoryToolManifestBlob? after,
) {
  if (before == null || after == null) {
    return (added: const [], removed: const [], modified: const []);
  }
  final beforeByName = {for (final tool in before.tools) tool.name: tool};
  final afterByName = {for (final tool in after.tools) tool.name: tool};
  return (
    added: [
      for (final tool in after.tools)
        if (!beforeByName.containsKey(tool.name)) tool.name,
    ],
    removed: [
      for (final tool in before.tools)
        if (!afterByName.containsKey(tool.name)) tool.name,
    ],
    modified: [
      for (final tool in after.tools)
        if (beforeByName[tool.name] != null &&
            beforeByName[tool.name]!.schemaJson != tool.schemaJson)
          tool.name,
    ],
  );
}