Skip to content

Commit c241bb5

Browse files
authored
Merge remote-tracking branch 'origin/main' into fix/harness-missing-return
2 parents 0321035 + d84e17d commit c241bb5

29 files changed

+1845
-163
lines changed

.github/aw/github-agentic-workflows.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -214,18 +214,18 @@ The YAML frontmatter supports these fields:
214214
The `custom` engine allows you to define your own GitHub Actions steps instead of using an AI processor. Each step in the `steps` array follows standard GitHub Actions step syntax with `name`, `uses`/`run`, `with`, `env`, etc. This is useful for deterministic workflows that don't require AI processing.
215215

216216
**Environment Variables Available to Custom Engines:**
217-
217+
218218
Custom engine steps have access to the following environment variables:
219-
219+
220220
- **`$GH_AW_PROMPT`**: Path to the generated prompt file (`/tmp/gh-aw/aw-prompts/prompt.txt`) containing the markdown content from the workflow. This file contains the natural language instructions that would normally be sent to an AI processor. Custom engines can read this file to access the workflow's markdown content programmatically.
221221
- **`$GH_AW_SAFE_OUTPUTS`**: Path to the safe outputs file (when safe-outputs are configured). Used for writing structured output that gets processed automatically.
222222
- **`$GH_AW_MAX_TURNS`**: Maximum number of turns/iterations (when max-turns is configured in engine config).
223-
223+
224224
Example of accessing the prompt content:
225225
```bash
226226
# Read the workflow prompt content
227227
cat $GH_AW_PROMPT
228-
228+
229229
# Process the prompt content in a custom step
230230
- name: Process workflow instructions
231231
run: |
@@ -253,7 +253,7 @@ The YAML frontmatter supports these fields:
253253
log-level: debug # Optional: debug, info (default), warn, error
254254
args: ["--custom-arg", "value"] # Optional: additional AWF arguments
255255
```
256-
256+
257257
- **`sandbox:`** - Sandbox configuration for AI engines (string or object)
258258
- String format: `"default"` (no sandbox), `"awf"` (Agent Workflow Firewall), `"srt"` or `"sandbox-runtime"` (Anthropic Sandbox Runtime)
259259
- Object format for full configuration:
@@ -703,7 +703,7 @@ cache:
703703
restore-keys: |
704704
node-modules-
705705
- key: build-cache-${{ github.sha }}
706-
path:
706+
path:
707707
- dist
708708
- .cache
709709
restore-keys:
@@ -963,7 +963,7 @@ All other expressions are dissallowed.
963963
The `needs.activation.outputs.text` value provides automatically sanitized content based on the triggering event:
964964

965965
- **Issues**: `title + "\n\n" + body`
966-
- **Pull Requests**: `title + "\n\n" + body`
966+
- **Pull Requests**: `title + "\n\n" + body`
967967
- **Issue Comments**: `comment.body`
968968
- **PR Review Comments**: `comment.body`
969969
- **PR Reviews**: `review.body`
@@ -1163,7 +1163,7 @@ permissions:
11631163
11641164
safe-outputs:
11651165
create-issue: # Automatic issue creation
1166-
add-comment: # Automatic comment creation
1166+
add-comment: # Automatic comment creation
11671167
create-pull-request: # Automatic PR creation
11681168
```
11691169

@@ -1437,7 +1437,7 @@ The `--start-date` and `--end-date` flags support delta time syntax for relative
14371437

14381438
**Supported Time Units:**
14391439
- **Days**: `-1d`, `-7d`
1440-
- **Weeks**: `-1w`, `-4w`
1440+
- **Weeks**: `-1w`, `-4w`
14411441
- **Months**: `-1mo`, `-6mo`
14421442
- **Hours/Minutes**: `-12h`, `-30m` (for sub-day precision)
14431443
- **Combinations**: `-1mo2w3d`, `-2w5d12h`
@@ -1447,7 +1447,7 @@ The `--start-date` and `--end-date` flags support delta time syntax for relative
14471447
# Get runs from the last week
14481448
gh aw logs --start-date -1w
14491449
1450-
# Get runs up to yesterday
1450+
# Get runs up to yesterday
14511451
gh aw logs --end-date -1d
14521452
14531453
# Get runs from the last month
@@ -1502,7 +1502,7 @@ permissions:
15021502
GitHub Agentic Workflows supports security scanning during compilation with `--actionlint`, `--zizmor`, and `--poutine` flags.
15031503

15041504
**actionlint** - Lints GitHub Actions workflows and validates shell scripts with integrated shellcheck
1505-
**zizmor** - Scans for security vulnerabilities, privilege escalation, and secret exposure
1505+
**zizmor** - Scans for security vulnerabilities, privilege escalation, and secret exposure
15061506
**poutine** - Analyzes supply chain risks and third-party action usage
15071507

15081508
```bash
@@ -1559,7 +1559,7 @@ gh aw mcp list-tools github weekly-research
15591559

15601560
This command is useful for:
15611561
- **Discovering capabilities**: See what tools are available from each MCP server
1562-
- **Workflow discovery**: Find which workflows use a specific MCP server
1562+
- **Workflow discovery**: Find which workflows use a specific MCP server
15631563
- **Permission debugging**: Check which tools are allowed in your workflow configuration
15641564

15651565
## Compilation Process
@@ -1588,7 +1588,7 @@ Agentic workflows compile to GitHub Actions YAML:
15881588

15891589
1. **Use descriptive workflow names** that clearly indicate purpose
15901590
2. **Set appropriate timeouts** to prevent runaway costs
1591-
3. **Include security notices** for workflows processing user content
1591+
3. **Include security notices** for workflows processing user content
15921592
4. **Use the `imports:` field** in frontmatter for common patterns and security boilerplate
15931593
5. **ALWAYS run `gh aw compile` after every change** to generate the GitHub Actions workflow (or `gh aw compile <workflow-id>` for specific workflows)
15941594
6. **Review generated `.lock.yml`** files before deploying
@@ -1651,4 +1651,4 @@ gh aw logs <workflow-id>
16511651

16521652
### Documentation
16531653

1654-
For complete CLI documentation, see: https://githubnext.github.io/gh-aw/setup/cli/
1654+
For complete CLI documentation, see: https://githubnext.github.io/gh-aw/setup/cli/

.github/copilot-instructions.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# GitHub Copilot SDK — Assistant Instructions
2+
3+
**Quick purpose:** Help contributors and AI coding agents quickly understand this mono-repo and be productive (build, test, add SDK features, add E2E tests). ✅
4+
5+
## Big picture 🔧
6+
7+
- The repo implements language SDKs (Node/TS, Python, Go, .NET) that speak to the **Copilot CLI** via **JSON‑RPC** (see `README.md` and `nodejs/src/client.ts`).
8+
- Typical flow: your App → SDK client → JSON-RPC → Copilot CLI (server mode). The CLI must be installed or you can connect to an external CLI server via the `CLI URL option (language-specific casing)` (Node: `cliUrl`, Go: `CLIUrl`, .NET: `CliUrl`, Python: `cli_url`).
9+
10+
## Most important files to read first 📚
11+
12+
- Top-level: `README.md` (architecture + quick start)
13+
- Language entry points: `nodejs/src/client.ts`, `python/README.md`, `go/README.md`, `dotnet/README.md`
14+
- Test harness & E2E: `test/harness/*`, Python harness wrapper `python/e2e/testharness/proxy.py`
15+
- Schemas & type generation: `nodejs/scripts/generate-session-types.ts`
16+
- Session snapshots used by E2E: `test/snapshots/` (used by the replay proxy)
17+
18+
## Developer workflows (commands you’ll use often) ▶️
19+
20+
- Monorepo helpers: use `just` tasks from repo root:
21+
- Install deps: `just install` (runs npm ci, uv pip install -e, go mod download, dotnet restore)
22+
- Format all: `just format` | Lint all: `just lint` | Test all: `just test`
23+
- Per-language:
24+
- Node: `cd nodejs && npm ci``npm test` (Vitest), `npm run generate:session-types` to regenerate session-event types
25+
- Python: `cd python && uv pip install -e ".[dev]"``uv run pytest` (E2E tests use the test harness)
26+
- Go: `cd go && go test ./...`
27+
- .NET: `cd dotnet && dotnet test test/GitHub.Copilot.SDK.Test.csproj`
28+
29+
## Testing & E2E tips ⚙️
30+
31+
- E2E runs against a local **replaying CAPI proxy** (see `test/harness/server.ts`). Most language E2E harnesses spawn that server automatically (see `python/e2e/testharness/proxy.py`).
32+
- Tests rely on YAML snapshot exchanges under `test/snapshots/` — to add test scenarios, add or edit the appropriate YAML files and update tests.
33+
- The harness prints `Listening: http://...` — tests parse this URL to configure CLI or proxy.
34+
35+
## Project-specific conventions & patterns ✅
36+
37+
- Tools: each SDK has helper APIs to expose functions as tools; prefer the language's `DefineTool`/`@define_tool`/`AIFunctionFactory.Create` patterns (see language READMEs).
38+
- Infinite sessions are enabled by default and persist workspace state to `~/.copilot/session-state/{sessionId}`; compaction events are emitted (`session.compaction_start`, `session.compaction_complete`). See language READMEs for usage.
39+
- Streaming: when `streaming`/`Streaming=true` you receive delta events (`assistant.message_delta`, `assistant.reasoning_delta`) and final events (`assistant.message`, `assistant.reasoning`) — tests expect this behavior.
40+
- Type generation is centralized in `nodejs/scripts/generate-session-types.ts` and requires the `@github/copilot` schema to be present (often via `npm link` or installed package).
41+
42+
## Integration & environment notes ⚠️
43+
44+
- The SDK requires a Copilot CLI installation or an external server reachable via the `CLI URL option (language-specific casing)` (Node: `cliUrl`, Go: `CLIUrl`, .NET: `CliUrl`, Python: `cli_url`) or `COPILOT_CLI_PATH`.
45+
- Some scripts (typegen, formatting) call external tools: `gofmt`, `dotnet format`, `tsx` (available via npm), `quicktype`/`quicktype-core` (used by the Node typegen script), and `prettier` (provided as an npm devDependency). Most of these are available through the repo's package scripts or devDependencies—run `just install` (and `cd nodejs && npm ci`) to install them. Ensure the required tools are available in CI / developer machines.
46+
- Tests may assume `node >= 18`, `python >= 3.9`, platform differences handled (Windows uses `shell=True` for npx in harness).
47+
48+
## Where to add new code or tests 🧭
49+
50+
- SDK code: `nodejs/src`, `python/copilot`, `go`, `dotnet/src`
51+
- Unit tests: `nodejs/test`, `python/*`, `go/*`, `dotnet/test`
52+
- E2E tests: `*/e2e/` folders that use the shared replay proxy and `test/snapshots/`
53+
- Generated types: update schema in `@github/copilot` then run `cd nodejs && npm run generate:session-types` and commit generated files in `src/generated` or language generated location.

.github/workflows/issue-triage.lock.yml

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/sdk-consistency-review.lock.yml

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/getting-started.md

Lines changed: 109 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -786,6 +786,113 @@ python weather_assistant.py
786786

787787
</details>
788788

789+
<details>
790+
<summary><strong>Go</strong></summary>
791+
792+
Create `weather-assistant.go`:
793+
794+
```go
795+
package main
796+
797+
import (
798+
"bufio"
799+
"fmt"
800+
"log"
801+
"math/rand"
802+
"os"
803+
"strings"
804+
805+
copilot "github.com/github/copilot-sdk/go"
806+
)
807+
808+
type WeatherParams struct {
809+
City string `json:"city" jsonschema:"The city name"`
810+
}
811+
812+
type WeatherResult struct {
813+
City string `json:"city"`
814+
Temperature string `json:"temperature"`
815+
Condition string `json:"condition"`
816+
}
817+
818+
func main() {
819+
getWeather := copilot.DefineTool(
820+
"get_weather",
821+
"Get the current weather for a city",
822+
func(params WeatherParams, inv copilot.ToolInvocation) (WeatherResult, error) {
823+
conditions := []string{"sunny", "cloudy", "rainy", "partly cloudy"}
824+
temp := rand.Intn(30) + 50
825+
condition := conditions[rand.Intn(len(conditions))]
826+
return WeatherResult{
827+
City: params.City,
828+
Temperature: fmt.Sprintf("%d°F", temp),
829+
Condition: condition,
830+
}, nil
831+
},
832+
)
833+
834+
client := copilot.NewClient(nil)
835+
if err := client.Start(); err != nil {
836+
log.Fatal(err)
837+
}
838+
defer client.Stop()
839+
840+
session, err := client.CreateSession(&copilot.SessionConfig{
841+
Model: "gpt-4.1",
842+
Streaming: true,
843+
Tools: []copilot.Tool{getWeather},
844+
})
845+
if err != nil {
846+
log.Fatal(err)
847+
}
848+
849+
session.On(func(event copilot.SessionEvent) {
850+
if event.Type == "assistant.message_delta" {
851+
if event.Data.DeltaContent != nil {
852+
fmt.Print(*event.Data.DeltaContent)
853+
}
854+
}
855+
if event.Type == "session.idle" {
856+
fmt.Println()
857+
}
858+
})
859+
860+
fmt.Println("🌤️ Weather Assistant (type 'exit' to quit)")
861+
fmt.Println(" Try: 'What's the weather in Paris?' or 'Compare weather in NYC and LA'\n")
862+
863+
scanner := bufio.NewScanner(os.Stdin)
864+
for {
865+
fmt.Print("You: ")
866+
if !scanner.Scan() {
867+
break
868+
}
869+
input := scanner.Text()
870+
if strings.ToLower(input) == "exit" {
871+
break
872+
}
873+
874+
fmt.Print("Assistant: ")
875+
_, err = session.SendAndWait(copilot.MessageOptions{Prompt: input}, 0)
876+
if err != nil {
877+
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
878+
break
879+
}
880+
fmt.Println()
881+
}
882+
if err := scanner.Err(); err != nil {
883+
fmt.Fprintf(os.Stderr, "Input error: %v\n", err)
884+
}
885+
}
886+
```
887+
888+
Run with:
889+
890+
```bash
891+
go run weather-assistant.go
892+
```
893+
894+
</details>
895+
789896
<details>
790897
<summary><strong>.NET</strong></summary>
791898

@@ -954,10 +1061,10 @@ By default, the SDK automatically manages the Copilot CLI process lifecycle, sta
9541061

9551062
### Running the CLI in Server Mode
9561063

957-
Start the CLI in server mode using the `--server` flag and optionally specify a port:
1064+
Start the CLI in server mode using the `--headless` flag and optionally specify a port:
9581065

9591066
```bash
960-
copilot --server --port 4321
1067+
copilot --headless --port 4321
9611068
```
9621069

9631070
If you don't specify a port, the CLI will choose a random available port.

0 commit comments

Comments
 (0)