fix(windows): Fix az CLI execution and ADO state mapping on Windows#1055
fix(windows): Fix az CLI execution and ADO state mapping on Windows#1055michaeldevenney wants to merge 2 commits into
Conversation
- watch/index.ts: Use shell:true for execFile on Windows so az.cmd is found - azure-devops.ts: Quote WIQL args with spaces under shell:true on Windows - azure-devops.ts: Guard JSON.parse against empty az boards query output - azure-devops.ts: Map GitHub-style 'open'/'closed' states to ADO WIQL equivalents Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
@michaeldevenney Hey Mike! I reviewed this PR - the 4 Windows+ADO fixes look solid (az CLI ENOENT, WIQL arg splitting, empty stdout guard, state mapping). Are you planning to mark this as ready for review soon? Also noting that CI checks haven't run yet - might want to trigger those. Let us know if you need any help getting this across the finish line! |
Hi Tamir, sorry for the delay, got wrapped up with something at work. Yes, this is ready for review. The CI checks appear to be waiting on approval from a maintainer. |
There was a problem hiding this comment.
Pull request overview
This PR fixes several Windows-specific failures when running squad watch against Azure DevOps by improving Azure CLI invocation/argument handling and by mapping GitHub-style state filters (open/closed) to Azure DevOps WIQL state conditions.
Changes:
- Update the CLI
watchcommand to run Azure CLI successfully on Windows by usingshell: trueforazinvocations. - Harden
AzureDevOpsAdapter.listWorkItems()by (a) quoting whitespace-containing args on Windows, (b) treating empty stdout as[], and (c) mappingopen/closedto ADO WIQL equivalents. - Add a changeset bumping
@bradygaster/squad-cliand@bradygaster/squad-sdkas patch releases.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
packages/squad-sdk/src/platform/azure-devops.ts |
Quotes az args on Windows to avoid WIQL splitting; maps open/closed to ADO WIQL; guards empty CLI output before JSON parse. |
packages/squad-cli/src/cli/commands/watch/index.ts |
Uses shared azCmd/azExecOpts for Windows-safe Azure CLI checks and work item updates. |
.changeset/windows-ado-fixes.md |
Patch changeset for CLI + SDK releases. |
azCmd, azExecOpts, storage, and execFileAsync were declared between two import blocks. TypeScript/ESM requires all import statements to precede any executable code. Consolidate the full import block at the top of the file, then declare the module-level constants below. Addresses review feedback on PR bradygaster#1055. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Fixed the import issue — consolidated all |
What
Two packages, four bug fixes — all related to running
squad watchon Windows with an Azure DevOps project.Why
squad-cli / watch command:
On Windows,
azis not a binary — it's a.cmdbatch script. Node.jsexecFilewithout{ shell: true }fails withENOENTbefore any ADO operation can run. The watch command fails on startup with "az CLI not found" on every Windows machine.squad-sdk / AzureDevOpsAdapter:
Three additional bugs were uncovered after fixing the launch issue:
WIQL arg splitting:
AZ_OPTScorrectly setsshell: IS_WINDOWS, butcmd.exere-parses the command line and splits args at spaces. WIQL queries contain spaces and get corrupted. Fix: quote any arg containing whitespace on Windows.Empty stdout crash:
az boards queryreturns empty string (not[]) when no work items match.JSON.parse('')throwsSyntaxError: Unexpected end of JSON input. Fix:output || '[]'before parse.GitHub-style states in ADO: The state option passes
'open'directly into WIQL as[System.State] = 'open'. ADO has noopenstate — work items useActive,New,Resolved, etc. Everysquad watchrun withstate: 'open'returns zero results silently. Fix: map'open'→NOT IN ('Closed','Resolved','Removed','Done')and'closed'→IN ('Closed','Resolved','Done').How
packages/squad-cli/src/cli/commands/watch/index.tsazCmdandazExecOptsconstants (Windows shell guard)execFile/execFileSynccall sites to use these constantspackages/squad-sdk/src/platform/azure-devops.tsaz()method: quote args containing whitespace on Windows before passing toexecFileSynclistWorkItems(): addedoutput || '[]'guard beforeJSON.parselistWorkItems(): added state mapping for GitHub-style'open'/'closed'→ ADO WIQLTesting
On Windows with
platform: 'azure-devops'configured in.squad/config.json:squad watch— should start without "az CLI not found" errorstate: 'open'is used (previously returned zero)Breaking Changes
None. All fixes are additive. macOS/Linux behavior is unchanged.
Relationship to #581
We're aware that #581 (ADO-Driven Squadding PRD) proposes a deeper architectural change — refactoring
watch.tsto route throughPlatformAdapterinstead of calling theghCLI directly. If that work lands, it will supersede thewatch/index.tsportion of this PR.This PR is intentionally tactical: it fixes four concrete bugs that affect every Windows user running
squad watchagainst ADO today, without waiting on the larger platform-agnostic effort. Theazure-devops.tsfixes (SDK layer) remain useful regardless of howwatch.tsis eventually refactored.