Repository navigation
Description
Description
When installing a remote workflow using gh aw add, relative imports pointing to files outside .github/workflows/ appear to be downloaded to an incorrect destination.
As a result, the workflow is installed, but compilation fails with import file not found.
Minimal Reproduction
Source repository structure:
.github/
├── prompts/
│ └── review.md
└── workflows/
└── review.md
The workflow .github/workflows/review.md contains:
---
imports:
- ../prompts/review.md
inlined-imports: true
---In a separate consuming repository, install the remote workflow:
gh aw add example-org/workflow-library/.github/workflows/review.md@mainReplace example-org/workflow-library with an accessible synthetic test repository.
Then compile:
gh aw compile review --strict --approveExpected Behavior
gh aw add should install the workflow and its referenced dependencies while preserving the relative import structure.
The consuming repository should contain:
.github/
├── prompts/
│ └── review.md
└── workflows/
└── review.md
Compilation should succeed.
Actual Behavior
The installed workflow fails compilation:
error: import file not found
- ../prompts/review.md
Source inspection suggests that the import may instead be installed at:
.github/workflows/.github/prompts/review.md
This destination is inferred from the implementation and has not yet been independently verified through a minimal end-to-end reproduction.
Root Cause Analysis
The likely issue is in [pkg/cli/includes.go](https://github.com/github/gh-aw/blob/main/pkg/cli/includes.go), specifically fetchFrontmatterImportsRecursive.
The function correctly resolves the remote import path:
.github/workflows/../prompts/review.md
→ .github/prompts/review.md
However, when the resolved path does not start with the original workflow directory, the implementation appears to retain the full repository-relative path and append it to the local .github/workflows/ destination.
This potentially produces:
.github/workflows/.github/prompts/review.md
instead of:
.github/prompts/review.md
The relevant behavior was observed during source inspection of v1.0.1, v1.2.2, and main.
Proposed Implementation Plan
- Update import destination resolution in
pkg/cli/includes.goso that imports outside the original workflow directory preserve their repository-relative location in the consuming repository. - Ensure all resolved destinations remain within the destination repository, rejecting unsafe path traversal.
- Add regression tests covering:
- Imports within
.github/workflows/shared/. - Relative imports into
.github/prompts/. - Nested and transitive imports.
- Invalid imports attempting to escape the repository.
- Imports within
- Verify that
gh aw addfollowed by strict compilation succeeds in a clean consuming repository.
Acceptance Criteria
- Relative imports outside
.github/workflows/are installed at paths compatible with compiler resolution. - Existing imports within
.github/workflows/continue working. - Transitive dependency fetching continues working.
- Path traversal outside the destination repository is prevented.
- Automated regression tests cover the affected layouts.
Environment
- Reported failure:
gh-aw v1.0.1 - Source inspected:
v1.0.1,v1.2.2, andmain - Platform: GitHub CLI extension (
gh aw add) - Scenario: Remote workflow installation with relative frontmatter imports
Related Issues
- [#23900 – Flexible import path resolution and cross-repo agent imports](Fix: Flexible import path resolution and cross-repo agent imports #23900)
- #44757 –
gh aw adddoes not resolveuses:references in imported files - [#15982 – Nested local path imports in remote workflows should resolve](Nested local path imports in remote workflows should resolve #15982)
- #17620 –
gh aw addof workflow with transitive import from nested directory fails
These related issues are closed, but the installation destination problem described here appears to remain unresolved.
Activity