Skip to content

feat: import/export Squad configuration to/from GitHub repos - #1131

Merged
bradygaster merged 2 commits into
devfrom
bradygaster/squad-1128-import-export-repo
May 18, 2026
Merged

bradygaster merged 2 commits into
devfrom
bradygaster/squad-1128-import-export-repo

Conversation

@bradygaster

Copy link
Copy Markdown
Collaborator

Summary

Adds the ability to export Squad configuration directly to a GitHub repository and import it from one, using the GitHub Contents API via the gh CLI. This enables sharing Squad configurations across teams and machines via a central repo.

New Usage

# Export to a GitHub repo
squad export --repo owner/repo
squad export --repo owner/repo --branch main

# Import from a GitHub repo
squad import --repo owner/repo
squad import --repo owner/repo --branch dev --force

Implementation

  • packages/squad-sdk/src/sharing/repo-sync.ts — Core logic with injectable RepoSyncOperations interface for testability:

    • exportToRepo() — Serializes bundle and pushes via GitHub Contents API (handles SHA for updates)
    • importFromRepo() — Fetches bundle from repo
    • parseRepoString() — Parses owner/repo format (also handles GitHub URLs)
    • validateRepoPath() — Prevents path traversal attacks
    • Uses spawn with stdin for payload to avoid command-line length limits
  • packages/squad-cli/src/cli/commands/export.ts — Added --repo support, refactored manifest building into reusable buildManifest() function

  • packages/squad-cli/src/cli/commands/import.ts — Added --repo support, refactored apply logic into reusable applyManifest() function

  • packages/squad-cli/src/cli-entry.ts — Parses --repo and --branch flags for both commands

  • test/repo-sync.test.ts — 16 tests covering parsing, validation, export, and import with mock operations

Related Issues

Notes

⚠️ Needs squad member review before merging (🟡 medium feature per team capabilities).

Add the ability to export Squad configuration directly to a GitHub
repository and import it from one, using the GitHub Contents API
via the gh CLI.

New flags:
- squad export --repo owner/repo [--branch branch]
- squad import --repo owner/repo [--branch branch] [--force]

Implementation:
- New SDK module: sharing/repo-sync.ts with injectable operations
  interface for testability
- Updated CLI export/import commands to handle --repo flag
- Updated cli-entry.ts to parse --repo and --branch arguments
- Full test coverage with mock operations

Closes #1128

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds GitHub repository-backed import/export support for Squad configuration via the gh CLI and exposes the repo-sync helpers through the SDK.

Changes:

  • Adds SDK repo-sync primitives for parsing repo specs and reading/writing bundle JSON through the GitHub Contents API.
  • Adds --repo/--branch CLI wiring for squad export and squad import.
  • Adds repo-sync unit tests and a changeset for CLI/SDK minor releases.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/squad-sdk/src/sharing/repo-sync.ts Adds GitHub Contents API import/export operations and repo/path validation helpers.
packages/squad-sdk/src/sharing/index.ts Re-exports the new repo-sync SDK module.
packages/squad-cli/src/cli/commands/export.ts Adds repo export path and refactors manifest construction.
packages/squad-cli/src/cli/commands/import.ts Adds repo import path and refactors manifest application.
packages/squad-cli/src/cli-entry.ts Parses --repo and --branch for import/export commands.
test/repo-sync.test.ts Adds unit tests for repo parsing, path validation, and repo sync operations.
.changeset/repo-import-export.md Records minor release notes for CLI and SDK packages.

…l protection

1. Export now includes team.md, decisions.md, and routing.md in the
   manifest to avoid blank-file issues (#1122).

2. Import manifest schema updated with team_md, decisions_md, routing_md
   fields. Older bundles without these fields get empty defaults.

3. Path traversal protection: agent names and skill-derived names are
   validated as safe slugs, and resolved paths are checked to stay under
   their expected parent directories before any writes.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@bradygaster
bradygaster merged commit 04a433c into dev May 18, 2026
6 checks passed
@bradygaster
bradygaster deleted the bradygaster/squad-1128-import-export-repo branch August 8, 2026 08:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: Import/Export Squad configuration directly to/from a repository

3 participants