feat: handle local directory arguments in compile command#30295
feat: handle local directory arguments in compile command#30295
Conversation
When a directory path or a GitHub URL (tree/blob) is passed as a compile argument, expand it to the constituent .md workflow files instead of failing with a "workflow not found" error. - New compile_args.go: resolveCompileArgs, expandCompileArg, expandURLArg, expandDirectoryArg functions - compile_orchestrator.go: preprocess MarkdownFiles with resolveCompileArgs before starting compilation - compile_args_test.go: unit tests for all expansion paths - main.go: updated help text with directory and URL usage examples Agent-Logs-Url: https://github.com/github/gh-aw/sessions/771b5545-fcc4-40cc-9a3a-4e9979778509 Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/771b5545-fcc4-40cc-9a3a-4e9979778509 Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds preprocessing for gh aw compile arguments so users can pass a local workflows directory or a GitHub tree/blob/raw URL and have it resolved to the underlying workflow Markdown files, avoiding the prior “workflow not found” behavior.
Changes:
- Introduces argument expansion logic to turn directory paths and GitHub folder/file URLs into concrete local
.mdworkflow file paths. - Wires the argument preprocessing into the compile orchestrator so expansion happens before the compilation pipeline runs.
- Adds unit tests for the new expansion behavior and updates CLI help examples.
Show a summary per file
| File | Description |
|---|---|
| pkg/cli/compile_orchestrator.go | Preprocesses MarkdownFiles args via resolveCompileArgs before compilation begins. |
| pkg/cli/compile_args.go | New helpers to expand directory args and GitHub URLs into local workflow .md files. |
| pkg/cli/compile_args_test.go | New unit tests for argument expansion paths (directory, tree URL, blob URL, mixed args). |
| cmd/gh-aw/main.go | Updates compile command help examples to include directory and GitHub folder URL usage. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 4/4 changed files
- Comments generated: 1
| func TestExpandCompileArg_BlobURL(t *testing.T) { | ||
| url := "https://github.com/org/repo/blob/main/.github/workflows/my-workflow.md" | ||
| result, err := expandCompileArg(url, false) | ||
| require.NoError(t, err, "blob URL should not error") | ||
| assert.Equal(t, []string{".github/workflows/my-workflow.md"}, result, | ||
| "blob URL should return the extracted local file path") | ||
| } | ||
|
|
||
| func TestExpandCompileArg_InvalidURL(t *testing.T) { | ||
| // An unparseable URL should be returned as-is (let the resolver handle it) | ||
| url := "https://not-github.com/some/path" | ||
| result, err := expandCompileArg(url, false) | ||
| require.NoError(t, err, "unrecognized URL should not error") | ||
| assert.Equal(t, []string{url}, result, "unrecognized URL should be returned unchanged") | ||
| } |
|
@copilot only support local folder, remove url support |
…only Per feedback, URL expansion is removed. The compile command now only expands local directory paths to their constituent .md workflow files. - compile_args.go: remove expandURLArg and the URL detection branch - compile_args_test.go: replace URL tests with a URL-passthrough test - main.go: remove the GitHub URL example from help text Agent-Logs-Url: https://github.com/github/gh-aw/sessions/d64afd8b-17e9-425a-8385-27a057edc074 Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Done in b9e5e6f. URL support has been removed — the compile command now only expands local directory paths to their constituent Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Summary
Fixes the error when a local folder path is passed as an argument to
gh aw compile. Previously, passing a directory path caused a "workflow not found" error. Now directory arguments are properly expanded to all.mdworkflow files in the referenced directory.Changes
pkg/cli/compile_args.go(new): Preprocessing functions that expand directory paths:resolveCompileArgs– entry point, iterates over all argsexpandCompileArg– expands local directory paths; passes everything else through unchangedexpandDirectoryArg– returns all.mdworkflow files found in a local directorypkg/cli/compile_orchestrator.go: CallsresolveCompileArgsto preprocessMarkdownFilesbefore the compilation pipeline starts.pkg/cli/compile_args_test.go(new): Unit tests covering directory expansion, plain names, file paths, and passthrough of other arguments.cmd/gh-aw/main.go: Updated help text with directory usage example.Behaviour
my-workflow.github/workflows/w.md.github/workflows(dir).mdfiles in that dir