Skip to content
Closed
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: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ jobs:
python-version: ${{ matrix.python-version }}
- run: pip install -e ".[dev]"
- run: pytest -v
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

docker-test:
runs-on: ubuntu-latest
Expand Down
12 changes: 10 additions & 2 deletions src/skills.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@ def save_skill_file(skill_name: str, raw_content: str) -> Path:
# ---------------------------------------------------------------------------


def _github_headers() -> dict:
"""Return auth headers if GITHUB_TOKEN is set, else empty dict."""
import os

token = os.environ.get("GITHUB_TOKEN")
return {"Authorization": f"Bearer {token}"} if token else {}


def list_skills_in_repo(repo: str, branch: str = DEFAULT_BRANCH) -> List[str]:
"""Return names of all skills available in a GitHub repo.

Expand All @@ -76,7 +84,7 @@ def list_skills_in_repo(repo: str, branch: str = DEFAULT_BRANCH) -> List[str]:
"""
url = _GITHUB_TREE_API.format(repo=repo, branch=branch)
try:
resp = httpx.get(url, follow_redirects=True, timeout=15)
resp = httpx.get(url, follow_redirects=False, timeout=15, headers=_github_headers())
if resp.status_code != 200:
return []
tree = resp.json().get("tree", [])
Expand Down Expand Up @@ -104,7 +112,7 @@ def fetch_skill_from_repo(
"""
url = _GITHUB_RAW.format(repo=repo, branch=branch, skill=skill_name)
try:
resp = httpx.get(url, follow_redirects=True, timeout=15)
resp = httpx.get(url, follow_redirects=False, timeout=15, headers=_github_headers())
if resp.status_code != 200:
return None
except httpx.HTTPError:
Expand Down
7 changes: 3 additions & 4 deletions tests/test_docker_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -1090,15 +1090,14 @@ def test_install_all_then_sync_dry_run(self, runner, cli, tmp_path, monkeypatch)
(tmp_path / ".cursor").mkdir()
(tmp_path / ".cursor" / "mcp.json").write_text("{}")

r_install = runner.invoke(
cli, ["install", self.TEST_REPO, "--all", "-t", "cursor", "-y"]
)
r_install = runner.invoke(cli, ["install", self.TEST_REPO, "--all", "-t", "cursor", "-y"])
assert r_install.exit_code == 0, r_install.output

skills_dir = tmp_path / ".apc" / "skills"
installed_count = len(list(skills_dir.iterdir())) if skills_dir.exists() else 0
assert installed_count > 5, (
f"Expected >5 skills installed, got {installed_count}. Install output:\n{r_install.output}"
f"Expected >5 skills installed, got {installed_count}.\n"
f"Install output:\n{r_install.output}"
)

r_sync = runner.invoke(cli, ["sync", "--tools", "cursor", "--dry-run"])
Expand Down