Skip to content

feat(cli): add --remote flag for creating features on remote repos#430

Open
arielshad wants to merge 9 commits intomainfrom
feat/remote-repo-support
Open

feat(cli): add --remote flag for creating features on remote repos#430
arielshad wants to merge 9 commits intomainfrom
feat/remote-repo-support

Conversation

@arielshad
Copy link
Copy Markdown
Contributor

Summary

  • Add shep feat new --remote <url> to clone, register, and create a feature on a remote GitHub repo in a single command — accepts HTTPS, SSH, and owner/repo shorthand formats
  • Create CreateFeatureFromRemoteUseCase composite use case in the application layer to orchestrate import-then-create flow, reusable across CLI/Web/TUI
  • Add "Import from GitHub" trigger in the Web UI feature-create-drawer's repository combobox, reusing the existing GitHubImportDialog for inline import during feature creation
  • Enable the githubImport feature flag by default so the import UI is available out of the box
  • Add server action createFeatureFromRemote for Web UI remote feature creation

What Changed

Application Layer

  • CreateFeatureFromRemoteUseCase — new composite use case that chains ImportGitHubRepositoryUseCaseCreateFeatureUseCase with progress callbacks, deduplication (skips clone if repo already imported), and full error propagation

CLI

  • feat/new.command.ts — added --remote <url> option with mutual exclusivity validation against --repo, clone progress display, and interactive mode support (prompt for description after import)

Web UI

  • feature-create-drawer.tsx — integrated GitHub import trigger into the RepositoryCombobox with auto-select on successful import
  • create-feature-from-remote.ts (server action) — new action wiring remote URL to the composite use case
  • feature-flags.ts — changed githubImport default from false to true

Specs

  • Full specification documents: spec, research, plan, tasks, and feature tracking YAML files for feature 072

Tests (1,043 new lines)

  • Unit tests for CreateFeatureFromRemoteUseCase (orchestration, deduplication, error handling)
  • Unit tests for CLI --remote flag (validation, progress display, interactive mode)
  • Unit tests for Web UI server action and feature-create-drawer import integration
  • Feature flag default value test update

Test plan

  • Unit tests: 4554 tests passing (334 test files)
  • Build: compiles without errors
  • Lint: passes with zero warnings
  • CI pipeline passes all checks
  • E2E: shep feat new --remote owner/repo "description" clones and creates feature
  • E2E: shep feat new --remote with already-imported repo skips clone
  • E2E: Web UI import-from-GitHub trigger in feature creation drawer works end-to-end

🤖 Generated with Claude Code

arielshad and others added 9 commits March 19, 2026 19:12
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
… repo support

12 tasks across 4 phases: application layer composite use case,
CLI --remote flag, Web UI import trigger + server action, and
feature flag default change.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Introduce CreateFeatureFromRemoteUseCase that orchestrates
ImportGitHubRepositoryUseCase and CreateFeatureUseCase for
single-step remote repo feature creation. Includes two-phase
support (createRecord + initializeAndSpawn) for Web UI and
full execute() for CLI. Registered in DI container with
string token alias for web routes. 23 unit tests cover call
ordering, field passthrough, error propagation, deduplication,
and two-phase methods.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…display

Wire the --remote <url> option on feat new to
CreateFeatureFromRemoteUseCase. When provided, the command clones the
GitHub repo (or reuses an existing import), then creates the feature.
A dynamic spinner displays clone progress from gh CLI stderr. Errors
from the import pipeline (auth, URL parse, clone) surface as
actionable CLI messages. All existing flags (--push, --pr, --fast,
--pending, --model, --attach, --parent) compose with --remote.
Commander.js .conflicts('repo') prevents combining --remote and
--repo.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Change githubImport feature flag default from false to true in
TypeSpec model, settings defaults factory, and feature-flags.ts
fallback. Existing users with explicit false setting are unaffected
due to DB-primary resolution.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add Import from GitHub button in RepositoryCombobox that opens the
existing GitHubImportDialog. Create createFeatureFromRemote server
action with two-phase execution. Auto-select newly imported repo
in combobox on successful import. Add Storybook stories and unit
tests for modified components.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Reformat spec.yaml with consistent YAML block scalar style and add
feature.yaml to track implementation progress (12/12 tasks complete,
all phases from analyze through phase-4 completed).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

Dev Release Published

Artifact Version Install
npm 1.135.0-pr430.5b0b699 npm install -g @shepai/cli@1.135.0-pr430.5b0b699

Published from commit 4193a09 | View CI

arielshad added a commit that referenced this pull request Apr 6, 2026
)

## Summary

Adds three related capabilities for working with remote GitHub
repositories, unifying the work from PRs #409, #430, and #434 into a
single feature on current main:

- **`shep repo init-remote [name]`** — creates a GitHub repository from
a local one with no remote (via `gh repo create --source=.
--remote=origin --push`)
- **`shep feat new --remote <url>`** — clones (or auto-forks) a GitHub
repo then creates a feature on it, conflicts with `--repo`
- **Web UI** — shows a "Fork" badge on forked repositories in the repo
picker; `githubImport` feature flag now defaults to `true`

## Key changes

### Domain
- `Repository` entity gains `isFork?: boolean` and `upstreamUrl?:
string` (TypeSpec + generated output)
- Migration `055-add-repository-fork-fields` adds `is_fork` and
`upstream_url` columns + `idx_repositories_upstream_url` index
(idempotent)

### Auto-fork detection
- `IGitHubRepositoryService` gains `getAuthenticatedUser()`,
`checkPushAccess()`, `forkRepository()` + `GitHubForkError`
- `ImportGitHubRepositoryUseCase` now checks push access before cloning.
When the user lacks write permission, it forks via `gh repo fork`,
clones the fork, sets `upstream` remote, and persists fork metadata
- `IRepositoryRepository.findByUpstreamUrl()` for fork deduplication

### Init remote
- `IGitPrService` gains `createGitHubRepo()`, `addRemote()` +
`REMOTE_ALREADY_EXISTS`, `REPO_CREATE_FAILED` error codes
- New `InitRemoteRepositoryUseCase` guards against existing remotes and
delegates to `gh repo create`

### Feature creation from remote
- New `CreateFeatureFromRemoteUseCase` — composite that chains import →
create feature
- Two-phase API: `execute()` for CLI, `createRecord()` +
`initializeAndSpawn()` for Web (fast optimistic UI)

### i18n
- New translation keys for `repo.initRemote.*` and
`feat.new.{remoteOption,remoteConflict,forkedInfo}` added to all 8
locales

## Test plan

- [x] `pnpm typecheck` — zero errors
- [x] `pnpm lint:fix` — clean
- [x] `pnpm test:unit` — **388 files, 5585 tests passing** (includes 44
new tests)
- [x] `pnpm test:int` — **50 files, 595 tests passing** (migration 055
runs cleanly)
- [x] `pnpm build` — clean CLI build
- [x] `pnpm build:storybook` — clean storybook build with new
`WithForkBadges` story
- [ ] Manual: `shep repo init-remote my-test-repo` on a fresh local repo
- [ ] Manual: `shep feat new --remote
https://github.com/someone/public-repo "test feature"` (triggers
auto-fork path)
- [ ] Manual: Web UI — import a repo you don't have push access to,
verify "Fork" badge appears

## Notes

- Complementary to existing `IGitForkService` (PR #525, merged) which
handles fork-and-PR **within** worktrees. The new fork methods on
`IGitHubRepositoryService` handle auto-fork at **import time** — these
are different code paths and do not conflict.
- Migration 055 uses the umzug `MigrationParams` signature with
idempotent column/index checks, consistent with migration 054.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
blackpc pushed a commit that referenced this pull request Apr 6, 2026
# [1.175.0](v1.174.0...v1.175.0) (2026-04-06)

### Features

* **domain:** add unified remote repository support with auto-fork ([#531](#531)) ([64b8dfe](64b8dfe)), closes [#409](#409) [#430](#430) [#434](#434) [#525](#525)
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.

1 participant