Skip to content

Commit e214c4f

Browse files
tamirdresherCopilot
andcommitted
refactor(Squad.Agents.AI): co-locate sample under src/ and consolidate README
- Moves the sample app from samples/squad-agents-ai-sample/ to src/Squad.Agents.AI/samples/Squad.Agents.AI.Sample/ so it lives alongside the package it demonstrates. - Folds the sample's standalone README into the package README, giving consumers one canonical doc for both the API and the runnable demo. - Adds <Compile Remove="samples/**/*.cs" /> to Squad.Agents.AI.csproj so the library's wildcard glob does not pick up Program.cs in the co-located samples subdirectory. - Updates the .csproj project reference, and CI workflow paths to match the new layout. - Verified end-to-end: dotnet build, dotnet test (43/43 passing), and a sample sanity-check run (clear CLI-not-found error, no stack trace). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent b55d622 commit e214c4f

7 files changed

Lines changed: 86 additions & 119 deletions

File tree

‎.github/workflows/squad-agents-ai-ci.yml‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
paths:
66
- 'src/Squad.Agents.AI/**'
77
- 'test/Squad.Agents.AI.Tests/**'
8-
- 'samples/squad-agents-ai-sample/**'
8+
- 'src/Squad.Agents.AI/samples/Squad.Agents.AI.Sample/**'
99
- '.github/workflows/squad-agents-ai-ci.yml'
1010
- 'Directory.*.props'
1111
- 'Directory.*.json'
@@ -16,7 +16,7 @@ on:
1616
paths:
1717
- 'src/Squad.Agents.AI/**'
1818
- 'test/Squad.Agents.AI.Tests/**'
19-
- 'samples/squad-agents-ai-sample/**'
19+
- 'src/Squad.Agents.AI/samples/Squad.Agents.AI.Sample/**'
2020
- '.github/workflows/squad-agents-ai-ci.yml'
2121
- 'Directory.*.props'
2222
- 'Directory.*.json'
@@ -58,7 +58,7 @@ jobs:
5858
run: dotnet restore test/Squad.Agents.AI.Tests/Squad.Agents.AI.Tests.csproj -p:NuGetAudit=true
5959

6060
- name: Restore sample
61-
run: dotnet restore samples/squad-agents-ai-sample/Squad.Agents.AI.Sample.csproj -p:NuGetAudit=true
61+
run: dotnet restore src/Squad.Agents.AI/samples/Squad.Agents.AI.Sample/Squad.Agents.AI.Sample.csproj -p:NuGetAudit=true
6262

6363
- name: Build package
6464
run: dotnet build src/Squad.Agents.AI/Squad.Agents.AI.csproj --no-restore -c Release
@@ -67,7 +67,7 @@ jobs:
6767
run: dotnet build test/Squad.Agents.AI.Tests/Squad.Agents.AI.Tests.csproj --no-restore -c Release
6868

6969
- name: Build sample
70-
run: dotnet build samples/squad-agents-ai-sample/Squad.Agents.AI.Sample.csproj --no-restore -c Release
70+
run: dotnet build src/Squad.Agents.AI/samples/Squad.Agents.AI.Sample/Squad.Agents.AI.Sample.csproj --no-restore -c Release
7171

7272
- name: Test
7373
run: dotnet test test/Squad.Agents.AI.Tests/Squad.Agents.AI.Tests.csproj --no-build -c Release --logger trx --results-directory TestResults

‎samples/squad-agents-ai-sample/README.md‎

Lines changed: 0 additions & 112 deletions
This file was deleted.

‎src/Squad.Agents.AI/README.md‎

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,79 @@ Parsed URI query keys: `teamRoot`, `cliPath`, `cwd`, `cliArgs` (semicolon-separa
182182
- `.nuspec` metadata with authors, tags, repository, and readme pointer
183183
- `LICENSE` copied from the repository root
184184

185+
## Sample
186+
187+
A runnable console application is included at
188+
`src/Squad.Agents.AI/samples/Squad.Agents.AI.Sample/`. It demonstrates the four
189+
core integration patterns in one place: basic DI, keyed DI with multiple agents,
190+
the `ConfigureCopilotClient` BYOK delegate, and streaming via `RunStreamingAsync`.
191+
192+
### Prerequisites
193+
194+
| Prerequisite | Notes |
195+
|---|---|
196+
| [.NET 10 SDK](https://dotnet.microsoft.com/download/dotnet/10.0) | `dotnet --version` should print `10.x.x` |
197+
| GitHub Copilot CLI on `PATH` | Install from [github.com/github/copilot-cli](https://github.com/github/copilot-cli); verify with `copilot --version` |
198+
| Squad CLI installed | Follow the install guide in the [Squad repository README](https://github.com/tamirdresher/squad#readme) |
199+
| Initialized Squad team root | Run `squad init` in a directory; this becomes your team root |
200+
| GitHub Copilot authentication | Run `gh auth login` or `copilot auth login` once before running the sample |
201+
202+
Set the team root path before running:
203+
204+
```bash
205+
# Linux / macOS
206+
export SQUAD_TEAM_ROOT=/path/to/your/team-root
207+
208+
# Windows PowerShell
209+
$env:SQUAD_TEAM_ROOT = "C:\path\to\your\team-root"
210+
```
211+
212+
### Run
213+
214+
Run all four flows in sequence:
215+
216+
```bash
217+
dotnet run --project src/Squad.Agents.AI/samples/Squad.Agents.AI.Sample/
218+
```
219+
220+
Run a single flow (1–4):
221+
222+
```bash
223+
dotnet run --project src/Squad.Agents.AI/samples/Squad.Agents.AI.Sample/ -- --flow=1
224+
dotnet run --project src/Squad.Agents.AI/samples/Squad.Agents.AI.Sample/ -- --flow=2
225+
dotnet run --project src/Squad.Agents.AI/samples/Squad.Agents.AI.Sample/ -- --flow=3
226+
dotnet run --project src/Squad.Agents.AI/samples/Squad.Agents.AI.Sample/ -- --flow=4
227+
```
228+
229+
### Flow walkthrough
230+
231+
**Flow 1 — Basic DI registration** — `AddSquadAgent` registers `SquadAgent` and the
232+
base `AIAgent` interface. Resolves the agent from DI, creates a session, calls
233+
`RunAsync`, and prints `AgentResponse.Text`.
234+
235+
**Flow 2 — Keyed DI (multiple agents)** — `AddKeyedSquadAgent` registers two agents
236+
under keys `"alpha"` and `"beta"`. Resolution uses
237+
`GetRequiredKeyedService<SquadAgent>("alpha")`.
238+
239+
**Flow 3 — BYOK / `ConfigureCopilotClient` delegate** — the delegate receives
240+
`CopilotClientOptions` after Squad has applied its defaults. Inject a custom token
241+
or environment variable. The routing gate prevents accidental redirection of
242+
`Cwd`, `CliPath`, or `CliArgs` — configure those on `SquadAgentOptions` directly.
243+
244+
**Flow 4 — Streaming** — `RunStreamingAsync` returns
245+
`IAsyncEnumerable<AgentResponseUpdate>`. Each `update.Text` fragment is written to
246+
`Console.Write` without a newline for live token-by-token output.
247+
248+
### Troubleshooting
249+
250+
| Error | Cause | Fix |
251+
|---|---|---|
252+
| `GitHub Copilot CLI was not found on PATH` | `copilot` binary is missing or not on `PATH` | Install from [github.com/github/copilot-cli](https://github.com/github/copilot-cli); verify with `copilot --version` |
253+
| `Authentication failed` / `401` | Copilot CLI is not signed in | Run `gh auth login` or `copilot auth login` |
254+
| `SquadFolderPath does not exist` | `SQUAD_TEAM_ROOT` points to a non-existent path | Set `SQUAD_TEAM_ROOT` to an initialized Squad team directory |
255+
| `The system cannot find the file specified` (Win32Exception) | Copilot CLI not found | Same as first row above |
256+
| Build error: `Package Squad.Agents.AI not found` | Sample uses a project reference; ensure you run from the repo root | Run `dotnet build` from the repository root or pass `--project src/Squad.Agents.AI/samples/Squad.Agents.AI.Sample/` |
257+
185258
## See also
186259

187260
- Root repo: <https://github.com/bradygaster/squad>

‎src/Squad.Agents.AI/Squad.Agents.AI.csproj‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
<GenerateDocumentationFile>true</GenerateDocumentationFile>
1919
<Version>0.1.0-preview</Version>
2020
</PropertyGroup>
21+
<ItemGroup>
22+
<Compile Remove="samples/**/*.cs" />
23+
</ItemGroup>
2124
<ItemGroup>
2225
<PackageReference Include="Microsoft.Agents.AI.GitHub.Copilot" Version="1.7.0-preview.260526.1" />
2326
<PackageReference Include="Microsoft.Extensions.AI" Version="10.6.0" />

samples/squad-agents-ai-sample/Program.cs renamed to src/Squad.Agents.AI/samples/Squad.Agents.AI.Sample/Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
// Flow 3 — BYOK / ConfigureCopilotClient delegate
88
// Flow 4 — Streaming via RunStreamingAsync
99
//
10-
// Run: dotnet run --project samples/squad-agents-ai-sample/
11-
// Run one flow: dotnet run --project samples/squad-agents-ai-sample/ -- --flow=1
10+
// Run: dotnet run --project src/Squad.Agents.AI/samples/Squad.Agents.AI.Sample/
11+
// Run one flow: dotnet run --project src/Squad.Agents.AI/samples/Squad.Agents.AI.Sample/ -- --flow=1
1212
// ============================================================
1313

1414
using Microsoft.Agents.AI;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Squad.Agents.AI Sample
2+
3+
For docs see [../../README.md#sample](../../README.md#sample).

samples/squad-agents-ai-sample/Squad.Agents.AI.Sample.csproj renamed to src/Squad.Agents.AI/samples/Squad.Agents.AI.Sample/Squad.Agents.AI.Sample.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
1111
</PropertyGroup>
1212
<ItemGroup>
13-
<ProjectReference Include="..\..\src\Squad.Agents.AI\Squad.Agents.AI.csproj" />
13+
<ProjectReference Include="..\..\Squad.Agents.AI.csproj" />
1414
</ItemGroup>
1515
<ItemGroup>
1616
<PackageReference Include="Microsoft.Extensions.Hosting" Version="10.0.0" />

0 commit comments

Comments
 (0)