Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/aw/instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ If a rule conflicts, this repository overlay takes precedence.

Add your repository-specific standards here, for example:

- **CRITICAL INVARIANT:** After **any** modification to agentic workflow markdown files (`.github/workflows/*.md`), you **must** run `gh aw compile` (or `gh aw compile --watch` while iterating) before stopping. Treat this as mandatory.
- **CRITICAL INVARIANT:** After **any** modification to agentic workflow markdown files (`.github/workflows/*.md`), you **must** run a one-shot `gh aw compile` before stopping. Agents must not use `--watch`, because watch mode does not terminate automatically.
- Required shared include(s) for new workflows
- Standard frontmatter defaults
- Frontmatter ordering/style conventions
Expand Down
2 changes: 1 addition & 1 deletion .github/aw/maintainer.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ Build the workflow in stages:
5. **Configure triggers and pressure valves.** Add a fuzzy schedule, optional manual or slash-command entrypoint, concurrency, and an open-PR guard.
6. **Configure least privilege and safe outputs.** Derive tools, permissions, network access, allowlists, protected files, and per-run caps from the chosen portfolio.
7. **Write the execution contract.** State the selected-task input, quality bar, stop conditions, contributor etiquette, validation policy, reporting format, and memory update requirement.
8. **Compile and inspect generated Actions.** Run `gh aw compile --watch` while iterating, then compile once more before committing.
8. **Compile and inspect generated Actions.** Agents must run one-shot `gh aw compile` commands and must not use `--watch`, because watch mode does not terminate automatically.
9. **Roll out gradually.** Begin with low cadence and conservative caps. Review early runs before increasing scope or frequency.

Do not transplant Repo Assist's exact weights, labels, stale threshold, open-PR ceiling, or output maxima without measuring the target repository. These are policy choices, not universal defaults.
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/squad-game-planner.lock.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .github/workflows/squad-plan.lock.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pkg/cli/ci.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ func IsRunningInCI() bool {
"CI",
"CONTINUOUS_INTEGRATION",
"GITHUB_ACTIONS",
"COPILOT_AGENT_SESSION_ID",
}

for _, v := range ciVars {
Expand Down
9 changes: 8 additions & 1 deletion pkg/cli/ci_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ func TestIsRunningInCI(t *testing.T) {
},
expected: true,
},
{
name: "running in Copilot coding agent",
envVars: map[string]string{
"COPILOT_AGENT_SESSION_ID": "session-id",
},
expected: true,
},
{
name: "running in CI - multiple env vars set",
envVars: map[string]string{
Expand Down Expand Up @@ -67,7 +74,7 @@ func TestIsRunningInCI(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
// Clear all CI-related env vars first
ciVars := []string{"CI", "CONTINUOUS_INTEGRATION", "GITHUB_ACTIONS"}
ciVars := []string{"CI", "CONTINUOUS_INTEGRATION", "GITHUB_ACTIONS", "COPILOT_AGENT_SESSION_ID"}
for _, v := range ciVars {
t.Setenv(v, "")
}
Expand Down
4 changes: 4 additions & 0 deletions pkg/cli/compile_orchestrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ func CompileWorkflows(ctx context.Context, config CompileConfig) ([]*workflow.Wo
default:
}

if config.Watch && IsRunningInCI() {
return nil, errors.New("watch mode cannot be used in CI or Copilot coding agent environments")
}

if os.Getenv("GH_HOST") == "" { //nolint:osgetenvlibrary
if detectedHost := getHostFromOriginRemote(); detectedHost != "github.com" && detectedHost != "" {
compileOrchestratorLog.Printf("Auto-detected GHES host from git remote: %s", detectedHost)
Expand Down
37 changes: 37 additions & 0 deletions pkg/cli/compile_watch_environment_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//go:build !integration

package cli

import (
"context"
"strings"
"testing"
)

func TestCompileWorkflowsRejectsWatchInAutomatedEnvironments(t *testing.T) {
tests := []struct {
name string
envVar string
envValue string
}{
{name: "CI", envVar: "CI", envValue: "true"},
{name: "Copilot coding agent", envVar: "COPILOT_AGENT_SESSION_ID", envValue: "session-id"},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
for _, envVar := range []string{"CI", "CONTINUOUS_INTEGRATION", "GITHUB_ACTIONS", "COPILOT_AGENT_SESSION_ID"} {
t.Setenv(envVar, "")
}
t.Setenv(tt.envVar, tt.envValue)

_, err := CompileWorkflows(context.Background(), CompileConfig{Watch: true})
if err == nil {
t.Fatal("expected watch mode to be rejected")
}
if !strings.Contains(err.Error(), "watch mode cannot be used in CI or Copilot coding agent environments") {
t.Fatalf("unexpected error: %v", err)
}
})
}
}