Conversation
f8e9c8f to
c11aa5b
Compare
There was a problem hiding this comment.
Code Review
This pull request introduces a comprehensive command-line interface (zap edit) that allows users to perform configuration edits—such as managing endpoints, device types, clusters, attributes, commands, events, and features—directly from the terminal or via batch scripts. The review feedback highlights a critical bug in cli-operations.js where using e.parentRef instead of e.parentEndpointRef bypasses the safety check when deleting parent endpoints. Additionally, improvements were suggested to allow global options to precede the edit command in the argument parser and to make the package category matching case-insensitive.
| let endpoint = await resolver.resolveEndpoint(ctx, params.endpoint) | ||
| let all = await queryEndpoint.selectAllEndpoints(ctx.db, ctx.sessionId) | ||
|
|
||
| let children = all.filter((e) => e.parentRef === endpoint.id) |
There was a problem hiding this comment.
The endpoint object e returned by selectAllEndpoints has its parent endpoint reference mapped to parentEndpointRef (corresponding to the database column PARENT_ENDPOINT_REF), not parentRef. Using e.parentRef will evaluate to undefined, causing the children check to always be empty and allowing deletion of parent endpoints without --force (which silently orphans children).
Please update this to use e.parentEndpointRef instead.
| let children = all.filter((e) => e.parentRef === endpoint.id) | |
| let children = all.filter((e) => e.parentEndpointRef === endpoint.id) |
| for (let i = 0; i < argv.length; i++) { | ||
| let arg = argv[i] | ||
| if (typeof arg !== 'string') continue | ||
| if (arg.startsWith('-')) return -1 |
There was a problem hiding this comment.
Returning -1 immediately when an argument starting with - is encountered prevents users from placing global options (such as --logToStdout or --stateDirectory) before the edit command.
Consider skipping option flags and their values or using a more flexible detection mechanism to allow global options to precede the edit subcommand.
| let filtered = pkgs.filter( | ||
| (p) => | ||
| p.category === wanted || p.type === dbEnum.packageType.zclXmlStandalone | ||
| ) |
There was a problem hiding this comment.
The category comparison p.category === wanted is case-sensitive. Since users might pass mixed-case category names (e.g., --category Zigbee or --category Matter), it is more robust to perform a case-insensitive comparison and guard against null/undefined categories.
let wantedLower = wanted.toLowerCase()
let filtered = pkgs.filter(
(p) =>
(p.category && p.category.toLowerCase() === wantedLower) ||
p.type === dbEnum.packageType.zclXmlStandalone
)830a5fd to
da463ff
Compare
80d143c to
9b25dff
Compare
dec864f to
23c8cb2
Compare
139bb55 to
dc5bed3
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1725 +/- ##
==========================================
+ Coverage 75.07% 77.12% +2.04%
==========================================
Files 204 219 +15
Lines 23892 26552 +2660
Branches 5469 6243 +774
==========================================
+ Hits 17938 20477 +2539
- Misses 5954 6075 +121 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
311d66e to
aa06ef3
Compare
99d9de1 to
cd4755f
Compare
6daea04 to
54f162f
Compare
491525a to
fac54ab
Compare
Provides a discoverable CLI to create and edit .zap files: endpoints, clusters, attributes, commands, events, and Matter features, with ranked lookup suggestions, multiprotocol support, GUI-aligned guardrails, and generation/check coverage. Shares Zigbee cluster state across endpoints the same way the UI does (via util/shared-cluster-state.js), with protocol rules driven by the data model rather than protocol name checks. Ships zap-cli with bundled edit modules and test generation defaults, short --zcl/--gen names, release smoke coverage, and a QA quick-start. When --studioHttpPort and --ideProjectPath are both given, cluster enable/disable and endpoint create ask Studio to install or remove the matching UC components, matching the GUI path. Includes a SKILL.md so agents use zap-cli (with SDK-provided --zcl) instead of rewriting .zap JSON by hand. Includes architecture docs, layering tests, and the step-by-step edit guide.
Adds what an agent could not work out from the command surface alone: where zap-cli and the .zap files live, that clusters need their UC component installed and the project regenerated afterwards, that batching through apply avoids paying the metadata load per command, and that concurrent jobs need their own state directory. Corrects two things. --strict also applies to edits, where it refuses to save when that edit introduced errors, and --gen is not only for code generation: the cluster-to-component mapping is a gen-templates package extension, so component integration needs it too.
Configuring a cluster is half of what the GUI checkbox does; installing the component that implements it is the other half, and only Studio can write the project file. Two ways of getting that wrong were silent. Asking for Studio integration when nothing is answering saved the edit, installed nothing and looked like success, because failures were reported one 404 per component after the fact. The port is now checked once, up front, against the same endpoint isProjectActive uses, and a request that cannot be served is refused. Without Studio the cluster-to-component mapping is still known locally, since it is a package extension the generation templates carry. It was being thrown away. An enable now names the components it could not install, so a headless caller can hand them to slc instead of discovering later that nothing implements the cluster it configured. Also guards isProjectActive against a missing response, which threw a TypeError rather than returning false when nothing was listening.
The test copied a resource .zap and passed the generation templates that carry the cluster-to-component mapping. A resource names its own templates, and fuzzy package matching prefers those, so the session only used the templates the test asked for when the state database happened to resolve the file's reference to them by file name. It did on a machine that had run the suite before, and did not on a fresh one, which is every build agent. Starting from an empty configuration means the file names the templates the test loaded, so what is under test no longer depends on what the database has already seen.
Omitting them can rewrite Matter .zap packages to Zigbee test templates and leave slc generate without Matter zap-generated output.
Strict package matching stops new rewrites but does not fix a .zap that already points at Zigbee test gen-templates.
So a bare zap-cli edit against an SLC project uses the same SDK packages Studio and generate already inject from apack properties, instead of the bundled test templates that corrupt Matter .zap files on save.
Studio 6's Jetty 12 rejects %2F in a path segment, so encodeURIComponent of a filesystem .slcp never reaches the UC servlets. Match the GUI's %→_ mangling and document the Studio-vs-slc component install routes in the skill.
fac54ab to
31a8f57
Compare
No description provided.