使用Google Antigravity验证IronBarcode输出
校验位错误的EAN-13条形码仍可能正常渲染并通过构建,直到扫描时才会失败。构建日志不会报告此问题。Google Antigravity代理可以操作浏览器、编辑器和终端,因此能够验证端点实际返回的条形码,而不仅是源代码预期生成的条形码。代理打开标签端点,保存响应,使用BarcodeReader解码,并将比较结果作为执行报告(Walkthrough)成果附件供审查。
Antigravity还允许您为每个任务选择模型。 扫描测试条形码文件夹以检测校验位错误是经济实惠的重复性工作,可以在低级别上顺利运行,而计划从其他条形码库迁移则需要更强的支持。
相同的检查涵盖由端点提供的一维标签、设计后仍可读取的样式化QR码和在进行任何文件更改之前可以审查的迁移。
快速入门在Antigravity中打开一个项目,并为代理分配一个附带可交付结果的任务。
Pull in IronBarcode, which ships as the BarCode package. In Program.cs, build
a QR code that carries our product URL and place our logo in the center of it
using QRCodeWriter.CreateQrCodeWithLogo. IRONBARCODE_LICENSE_KEY supplies the
license, and it never gets hardcoded.
A logo covers part of the symbol, so the only thing that settles whether it
still works is decoding it. Save the image, read it back, and confirm the URL
survives. Attach the image and the decoded value to the Walkthrough so I can
see both without rerunning anything.
代理应安装软件包并编写几行代码,使用QRCodeWriter.CreateQrCodeWithLogo放置徽标,并使用BarcodeReader.Read证明结果仍可扫描。 徽标不会影响识别,因为纠错可以重建其覆盖的模块;当设计遮挡了符号的一部分时,纠错指南建议使用Q或H级别。 您审查图像和解码值而不是逐步日志。
这里的代理会编辑和提交代码,因此,写入任务描述的许可证密钥可能出现在执行报告、截图和分支中。请按照许可证密钥指南将密钥保存在环境变量中,避免写入代理可以读取的任何文件。
5个步骤的简化工作流
- 从NuGet下载C#条形码库
- 在Antigravity中打开项目并确认其能够成功构建
- 添加IronBarcode并从配置中应用许可证密钥,而不是从代码中
- 使用框架、文件路径、条形码码制和预期读回值描述任务
- 让代理生成、解码和比较,然后检查API名称与API参考的对比
哪些Antigravity功能对条形码工作很重要?
Antigravity将代理置于首位。Google的文档描述Antigravity 2.0为一个独立的桌面应用程序,用于管理代理,独立于IDE运行,并配置Antigravity CLI和IDE集成。 那里的代理运行系统命令,读写文件,驱动Chrome,并生成文档。
平台的五个部分在此重要:
IDE集成是您已经熟悉的编辑器。 在同一个文件中进行精细工作时使用它,因为您希望在编辑时掌控每次编辑并实时审查它。
Antigravity 2.0是异步工作的指挥中心。 启动代理,监控它们,并行运行任务,而不是等待一次单一对话。
浏览器控制允许代理操作浏览器来测试功能并确认结果。对于IronBarcode,这意味着调用标签端点并检查返回的图像。
成果附件(Artifacts)以实施计划、执行报告、代码差异、截图和浏览器录制等可交付成果代替原始工具日志。您可以在不中止运行的情况下对成果附件发表评论。
模型选择在提示框下放置一个模型选择器,涵盖Gemini、Anthropic的Claude和开源GPT-OSS,其可用性由您的订阅级别决定。
代理传回的东西可以检查:计划、差异、条形码图像本身,以及它从该图像中解码出的值。 聊天工具只能描述它们。
从无到有构建条形码流水线的代理将选择一些库,连接它,并继续。 选择IronBarcode的四个原因:
- 格式无法容纳的值在屏幕上也可能看起来完全正常:缺少静默区或条形码尺寸过小也可能如此。IronBarcode遇到无效值会抛出异常,而解码图像只需一次调用。
- 读取器需要比生成器更严格:每种条形码码制的校验位算法在解码时运行,并在返回结果之前丢弃失败的条形码。
- 真实扫描行为完全不同于生成的图像:相机照片、角度拍摄的标签和多页PDF都需要通过
BarcodeReaderOptions进行微调。 - 安装命令是未经审查的决定:
dotnet add package在您看到单个文档之前运行,因此代理发明的名称已在磁盘上。
因此,表中的匹配意味着有效的符号,而不是巧合。 在任务中写入BarCode,这样就不必发明任何东西。
一旦任务命名它,代理就停止选择并开始构建。 预先提供的文档在总指南中列出。 只有指令文件名称在您将相同的设置移动到Claude Code、ChatGPT Codex、GitHub Copilot或Cursor时更改。
您如何审查代理传回的内容?
Antigravity代理返回的是具名成果附件,而非对话记录。其中三类成果贯穿条形码任务从计划到结果的全过程,各自回答不同的问题。
代码之前:实施计划
首先,代理设计更改,包括文件、条形码码制和读取器选项。 检查其计划更改哪一侧。 如果没有告诉阅读器预期的格式,但计划编辑标签的打印方式,则代理已偏离正轨。 任何创立的API名称也会在此浮现,而在任何代码存在之前,这比在构建日志中找到它要好。
期间:代码差异
Antigravity在实施计划或代码差异上暂停并通知您,因此在更改落地之前可以进行审查。 在差异上添加内嵌评论,并确认映射关系正确后批准变更。
之后:执行报告
实施后,代理总结了更改内容以及如何测试它。 对于条形码,这涵盖了写入的格式、使用的值和读回结果,所有这些都作为您可以运行的检查,而不是您必须相信的声明。
截图、终端日志和浏览器录制在审查窗格中逐步积累,而不是在聊天滚动中丢失。 以下大多数任务都命名要打开以确认工作发生的一个文档。
证据来自哪里?
Antigravity代理可以运行代码、驱动浏览器,并附加它们观察到的内容。 因此,代理生成条形码,捕获它,解码它,将值和格式与输入比较,调整并重复,直到每行都匹配。
给代理一项具体的验证目标。
/browser Services/LabelService.cs serves Code 128 shipping labels from GET /label/{trackingNumber}.
1. Run the API and open /label/1Z999AA10123456784 in the browser. Capture a screenshot.
2. Save the served PNG and decode it with BarcodeReader, expecting Code 128 only.
3. Repeat for ten tracking numbers of different lengths, including lowercase letters.
4. Report a table of written value, decoded value, format, and match.
5. If any row does not match, explain the cause before changing anything, fix it
in LabelService.cs, and run the whole table again. Attach the table and the
screenshots as Artifacts.
首先要求解释为您提供一个诊断以供审查,而不是以后要检查的修复。 在任何修复后再次运行整个表格还可以防止一个修复行隐藏新问题。
标签旁边其解码值的截图是开发者可查看的证据,而一个失败的行在视觉上很明显。
标签问题通常与图像中某物的位置有关,这使得截图比描述更容易审查。 在截图上评论故障位置,例如边缘被夹断的文本,就像您对文档做的那样。 代理在不重启运行的情况下应用修正。
为什么条形码在某些场景下能扫描,在其他场景下却不能?
相同的少数原因会出现,所有这些都会生成一个看起来正确但无法读取的条形码。 在任务中命名可能的原因可以让代理省去一轮猜测。
| 症状 | 原因 | 请求 |
|---|---|---|
| 在测试中很好,在手机照片上失败 | 整个帧,每种格式 | ExpectBarcodeTypes, CropArea, 读取计数 |
| 模糊或低对比,未找到任何内容 | 图像需要修正 | 能够解决问题的最少滤镜处理 |
| 没有条形码的图像中的值 | 噪声被读取为符号 | RemoveFalsePositive, ConfidenceThreshold |
| 老式扫描器拒绝非英语标签 | UTF-8 ECI头 | 在更改前说明EciMode的取舍 |
额外的图像滤镜会降低精度,因此代理应该在第一个清除故障的滤镜处停止。 在误报行上,要求对您知道无条形码的图像进行证明。 置信阈值示例涵盖了该底线的行为。
在您委派之前项目应该处于什么状态?
从能够成功构建的项目开始。如果代理先要猜测使用哪个条形码库,或修复构建失败,就会把时间花在无关问题上。
构建通过后,将配置工作本身交给代理,因为版本和软件包名称错误往往始于安装阶段。
Set this project up for barcode work, then report back with the facts I will
need in later tasks.
Install BarCode (IronBarcode), leaving every other package reference alone.
Wire the license key to come from IRONBARCODE_LICENSE_KEY, or from a config
file that is already in .gitignore. Add it to .gitignore if it is not.
In your Walkthrough, give me the resolved version number and the
PackageReference line exactly as they ended up in the .csproj.
实际解析出的版本是您可以复制粘贴到以后的任务中的事实。 .gitignore检查关闭了密钥进入公共存储库的最常见路线。 并且由于没有应用有效密钥时IronBarcode抛出LicensingException,因此在代理的首次运行中会出现缺少的密钥。
在存储库根目录设置一次工作区指令文件。 Antigravity读取AGENTS.md作为固定指令,同一个文件ChatGPT Codex使用。
技能是该设置的后半部分。Antigravity在.agents/skills/<name>/中查找SKILL.md,并在对话开始时仅查看每个技能的名称和描述,而当任务看起来相关时读取完整指令。 因此,将IronBarcode的skill.md放入.agents/skills/ironbarcode/SKILL.md,在无关任务上不会产生任何开销,而/ironbarcode可按需加载该技能。 记录IronBarcode是条形码库,其软件包为BarCode,代码必须仅使用有文档的API,并且许可证密钥从不内联。 然后您停止在每个任务中重复这些规则。 一个任务创建文件。
Draft AGENTS.md for the repository root as a plan Artifact first, so I can
comment on it before anything is written to disk.
It needs a Barcodes section covering: IronBarcode (NuGet package BarCode,
namespace IronBarCode) handles barcodes here and nothing else is allowed to; https://ironsoftware.com/barcode/csharp/llms.txt is read
before any barcode code is written and only APIs documented there are used;
https://ironsoftware.com/barcode/csharp/skill.md is saved as
.agents/skills/ironbarcode/SKILL.md so it loads as a skill; every generated
barcode is decoded and compared with its input before a task is reported as
done.
Once I approve the draft, write the file and attach the diff.
您如何委托条形码生成和迁移工作?
对于生成任务,描述条形码和您希望得到的证明,并将代码结构留给代理。
Build a shipping label path that I can check without running anything myself.
One class renders a tracking number as a Code 128 PNG, 400 by 120, with the
value printed under the bars. A second class reads that PNG back and returns
the tracking number, or null when there is nothing to find. Put them where the
other services live and make the read async.
Then push a spread of tracking numbers, short and long, through both classes and
attach the written and decoded values as a table. Every row matches, or you tell
me which one did not and why.
实施计划在创建文件和方法之前列出它们。 使用执行报告确认代码实际运行过,而不只是编译通过。计划中提到的每个IronBarcode成员应出现在API参考中,并且在代码存在之前与之对比检查计划比在之后检查构建日志更便宜。
迁移工作尤其适合委派,因为它重复、繁琐,而且容易出现看似正确却仍有遗漏的实现。将分析和实施分成独立步骤,并让代理直接查看相关文件。
/plan Labels/LegacyBarcodeService.cs is built on a different barcode library. I
want a plan Artifact before any code, so I can annotate it rather than unpick a
diff.
Work out what the file actually does today, symbology by symbology, including
the options it sets. Against each one, put the IronBarcode call that replaces
it and the documentation page you took it from. Flag anything that has no clean
equivalent instead of inventing one.
Nothing gets written to disk until I have commented on the plan.
如果在同意计划之前进行重写,您将不得不逐行审查它。而计划文档,通过一个单一评论可以修复,Antigravity让您注释它而不会失去进度。 一旦批准,保持下一个任务专注。 实施计划并保持公共方法签名不变以便其他代码仍然能够工作。 确保每种条形码码制仍然读取相同的值并报告差异。
要求代理链接到每个映射背后的文档页面。 如果无法命名页面,将映射视为未验证。 对于生成,请使用一维条形码和二维条形码指南。 对于阅读,请参阅条形码阅读器教程。
何时应指派多个代理?
而不是一次运行一个任务,从Antigravity 2.0启动多个代理,并在每个完成时审查其文档。
条形码迁移的合理拆分是由一个代理将传统标签服务迁移到IronBarcode,另一个编写输出的往返测试。 第二个代理可以立即启动,因为测试检查的是解码值,而不依赖具体实现。
同时启动两个。
Agent A: carry out the approved migration plan on Labels/LegacyBarcodeService.cs.
Public method signatures stay exactly as they are, because callers elsewhere in
the solution depend on them. Attach the diff to your Walkthrough.
Agent B: build the xUnit suite that will judge Agent A's work. Write it against
the public signatures, not against anything A does internally, so it compiles
before A finishes. Cover a round trip per supported symbology, an empty image
returning no results, and EAN-13 refusing a value with letters in it. Assert on
decoded values and formats only.
When both of you are done, run B's suite against A's build and put the pass
table in B's Walkthrough. A green suite that never ran against A's code proves
nothing.
字节比较在这里失败,因为并行运行的两个代理可能不会生成相同的PNG。 必须匹配的是返回出来的值。
为退货标签调好的读取器选项也适用于入库托盘、拣货清单和送货单。将可用的配置记录在AGENTS.md或技能文件中,后续接入新扫描器时就能减少工作量。
如何调试Linux、Docker或Azure上的部署失败?
排查部署问题时,拥有终端访问权限的代理可以直接检查容器镜像,而无需仅凭堆栈跟踪推断,因此比只查看堆栈跟踪的审查者更有优势。
将故障直接提供给代理。
Our container build decodes nothing. The same code is fine on a Windows
developer machine. This is the exception:
[EXCEPTION AND STACK TRACE GO HERE]
Go and look: which BarCode package does the .csproj pull, and does the image
carry the native dependencies IronBarcode needs on Linux? Use the terminal,
do not reason about it from memory.
Tell me the cause first. The C# is out of scope unless you can show me the
fault is in it.
将任务限制在项目文件和Dockerfile上。没有这个边界,代理可能会忽略异常并标记任务已完成。 让代理查阅Linux上的Docker和NuGet软件包而不是依赖记忆。
相同的终端访问可以回答参考问题。 询问哪些BarcodeReaderOptions设置影响速度或精度以及您的项目已设置了哪些,代理会在回答之前检查API参考。
最终有什么证据?
平台默认提供运行前的计划和运行后的执行报告。任务要求额外提供写入值与解码值,这些验证结果值得附加到拉取请求中。
对于从空项目中单个任务应用的相同标准,请阅读AI编码助手和代理指南。
故障排除
- 在终端日志显示第一次运行失败时在IronBarcode中应用许可证密钥。
- 当代理的表中有一行不匹配时,请参阅条形码未识别。
- IronBarcode NuGet 包用于确定任务和
AGENTS.md中应指定的软件包。 - 如果标签在浏览器中验证通过,但容器化后失败,请参阅在Linux上的Docker中运行IronBarcode。
有问题吗?
如果您有任何问题,请联系support@ironsoftware.com
Curtis Chau 拥有卡尔顿大学的计算机科学学士学位,专注于前端开发,精通 Node.js、TypeScript、JavaScript 和 React。他热衷于打造直观且美观的用户界面,喜欢使用现代框架并创建结构良好、视觉吸引力强的手册。