Skip to content
Open
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
5 changes: 5 additions & 0 deletions .changeset/hip-bags-laugh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"wtc": patch
---

feature: adds cli cloning and teamwork setup
Comment thread
marlonmarcello marked this conversation as resolved.
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
24.18.0
22 changes: 11 additions & 11 deletions plans/PLAN.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

A terminal UI tool for developers to manage GitHub repos, AWS Amplify projects, and Teamwork tasks.

- **Status:** Phase 6 GitHub Repo Creation (6.1 planned)
- **Status:** Phase 6.4 Local Clone + WTC Project Bootstrap completed
- **Package Manager:** Bun
- **Runtime:** Bun (standalone binary distribution)
- **TUI:** @opentui/solid + solid-js
Expand Down Expand Up @@ -155,25 +155,25 @@ Create branches and draft PRs from Teamwork tasks with timer prompts and useful

GitHub repo creation work is split into detailed subphase plans under [`plans/github/`](github/README.md).

#### Phase 6.1 — [TUI Repo Creation From Template](github/6.1-tui-repo-creation-from-template.md)
#### Phase 6.1 — [TUI Repo Creation From Template](github/6.1-tui-repo-creation-from-template.md)

Create a GitHub repo under the company org from an approved organization template through the TUI. No CLI, branch protection, Teamwork linking, or local clone yet.
Create a GitHub repo under the company org from an approved organization template through the TUI, with template selection, repo name/description/visibility input, repo rules preset selection, and success dialog.

#### Phase 6.2 — [CLI Repo Creation](github/6.2-cli-repo-creation.md)
#### Phase 6.2 — [CLI Repo Creation](github/6.2-cli-repo-creation.md)

Add the CLI equivalent of Phase 6.1.
CLI `wtc repo create` command with `--template`, `--visibility`, `--description`, `--rules-preset`, and `--json` flags. Creates repos under the company org from templates or as blank repos initialized with an MIT license.

#### Phase 6.3 — [Repo Rules](github/6.3-repo-rules.md)
#### Phase 6.3 — [Repo Rules](github/6.3-repo-rules.md)

Add branch protection, PR rules, and repository settings to the creation flow.
Branch protection rulesets, repository settings, vulnerability alerts, and senior-reviewers bypass for newly created repos. Rules preset selection (`standard`/`none`) available in both TUI and CLI. Best-effort post-create setup with warnings for token permission issues.

#### Phase 6.4 — [Teamwork Project Linking](github/6.4-teamwork-project-linking.md)
#### Phase 6.4 — [Local Clone + WTC Project Bootstrap](github/6.4-local-clone-and-wtc-project-bootstrap.md)

Link created GitHub repos into WTC project config and update CLI parity if Phase 6.3 introduces CLI-relevant options.
Clone the newly created repo, write a `.wtc.yaml` into the cloned repo with Teamwork project ID and optional Teamwork references, then commit and push the config so all devs get a ready-to-use WTC project.

#### Phase 6.5 — [Local Clone And Final Features](github/6.5-local-clone-and-final-features.md)
#### Phase 6.5 — [Teamwork Project Linking + Final Polish](github/6.5-teamwork-project-linking-and-final-polish.md)

Add optional local clone and final repo creation workflow conveniences.
Link the created repo into WTC project config from the old working directory. Add any remaining repo creation workflow conveniences and CLI/TUI parity gaps.

### Phase 7 — AWS Amplify Hosting

Expand Down
10 changes: 2 additions & 8 deletions plans/github/6.1-tui-repo-creation-from-template.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
# 6.1 TUI Repo Creation From Template
# 6.1 TUI Repo Creation From Template ✅ Complete

## Goal

Create a new GitHub repository from an approved organization template, or as a blank repository initialized with an MIT license, through the TUI.

This phase is intentionally narrow: TUI first, no CLI, no local clone, no branch protection, and no Teamwork/project linking.
Create a new GitHub repository from an approved organization template, or as a blank repository initialized with an MIT license, through the TUI. Includes rules preset selection (`standard`/`none`), repo settings, and post-create setup warnings.

## Decisions

Expand Down Expand Up @@ -136,15 +134,11 @@ Command palette:

## Out Of Scope

- CLI commands.
- Branch protection.
- PR/review/status check rules.
- Teamwork/project linking.
- Local clone.
- Manual template entry.
- Personal account repo creation.
- GitHub Enterprise `internal` visibility.
- Template/repo list caching.

## Definition Of Done

Expand Down
38 changes: 12 additions & 26 deletions plans/github/6.2-cli-repo-creation.md
Original file line number Diff line number Diff line change
@@ -1,43 +1,29 @@
# 6.2 CLI Repo Creation
# 6.2 CLI Repo Creation ✅ Complete

## Goal

Add the CLI equivalent of Phase 6.1 repo creation.
CLI `wtc repo create` command that mirrors the full TUI creation flow.

This phase mirrors only the basic TUI workflow: create a repo from an approved owner template or as a blank repo. It does not include branch protection, Teamwork linking, or local clone.

## Scope

- Add a `repo` CLI command group.
- Add `wtc repo create`.
- Use the code-owned company GitHub org constant `wethegit`.
- Reuse API functions from `src/api/github/repos.ts`.
- Keep the command scriptable first.

## Proposed Command
## Actual Command

```bash
wtc repo create <name> --template <template-name> --visibility private --description "Optional description"
wtc repo create <name> --template <template-name> --visibility private --description "Optional description" --rules-preset standard --json
```

Flags:
## Flags

- `--template <template-name>`: optional template repo name under `wethegit`. Omit for a blank repo.
- `--visibility <private|public>`: defaults to `private`.
- `--description <text>`: optional.
- `--json`: print machine-readable output.
- `--rules-preset <standard|none>`: repo rules preset. Defaults to `standard`. `none` skips rulesets.
- `--json`: print machine-readable output with `name`, `fullName`, `url`, `cloneUrl`, `sshUrl`, and `warnings`.

Behavior:
## Behavior

- Uses `createGitHubRepoWithSetup()` from `src/api/github/repos.ts`, matching the TUI flow.
- If `--template` is provided, verifies the requested template exists and has `is_template === true`.
- If `--template` is omitted, creates a blank repo initialized with an MIT license.
- Creates the repo under `wethegit`.
- Prints the created repo URL.

## Deferred

- Interactive TTY prompts.
- Opening the created repo in a browser.
- Branch protection flags.
- Teamwork/project linking flags.
- Clone flags.
- Applies repo settings, vulnerability alerts, and optional rulesets after creation.
- Prints any setup warnings (token permission issues, team lookup failures).
- Prints the created repo URL (or JSON output with `--json`).
69 changes: 36 additions & 33 deletions plans/github/6.3-repo-rules.md
Original file line number Diff line number Diff line change
@@ -1,61 +1,64 @@
# 6.3 Repo Rules
# 6.3 Repo Rules ✅ Complete

## Goal

Add branch protection, PR rules, and repository settings to the repo creation flow after basic creation is stable.
Branch protection rulesets, repository settings, and vulnerability alerts applied to newly created GitHub repos.

## Scope Candidates
## Implemented Scope

- Protect the default branch plus `release/*` and `release-candidate/*`.
- Require pull requests before merging.
- Require approving reviews.
- Set required approving review count.
- Require pull requests before merging with 1 required approving review.
- Dismiss stale approvals when new commits are pushed.
- Block force pushes, with `wethegit/senior-reviewers` allowed to bypass the ruleset.
- Require review thread resolution.
- Block force pushes; `wethegit/senior-reviewers` team can bypass the ruleset.
- Block branch deletion.
- Configure allowed merge strategies.
- Allow merge, squash, and rebase.
- Enable delete branch on merge.
- Enable vulnerability alerts.
- Disable wikis, discussions, and repository projects.
- Initialize blank repos with an MIT license.

## TUI Flow

Repo rules should appear as an optional setup step in the TUI creation flow after visibility selection and before final confirmation.
## Presets

Possible shape:
Two presets selectable during creation:

1. Select template.
2. Enter repo name.
3. Optional description.
4. Select visibility.
5. Select repo rules preset.
6. Confirm creation.
7. Create repo.
8. Apply repository settings, vulnerability alerts, and rules.
9. Show success dialog with warnings if post-create setup is incomplete.
| Preset | Behavior |
| ---------- | --------------------------------------------------------------- |
| `standard` | Applies all rulesets, settings, and vulnerability alerts. |
| `none` | Applies settings and vulnerability alerts only; skips rulesets. |

## API Scope
## API

Likely add or extend `src/api/github/repos.ts` with focused functions such as:
- `createGitHubRepoWithSetup()` in `src/api/github/repos.ts` — single call for create + setup.
- `applyGitHubRepoSetup()` — applies repository settings, vulnerability alerts, and optional rulesets.
- `updateGitHubRepoSettings()` — disables wikis, discussions, and projects; enables delete branch on merge.
- `enableGitHubVulnerabilityAlerts()` — enables Dependabot alerts.
- `applyGitHubRepoRulesetSetup()` — resolves the bypass team ID and creates the ruleset.
- `GITHUB_REPO_RULESET_PRESETS` in `src/api/github/repo-rules.ts` — preset definitions kept separate from Octokit call sites.

- `updateGitHubRepoSettings(input)`
- `applyGitHubRepoSetup(input)`
- GitHub repository rulesets for branch rules.
## TUI Flow

Keep Octokit-specific request details in the GitHub API module, not in TUI components.
The TUI creation flow includes a rules preset step after visibility selection and before confirmation, matching the implemented behavior.

## Deferred
## CLI Parity

- CLI parity until Phase 6.4.1.
- Teamwork/project linking until Phase 6.4.2.
- Local clone until Phase 6.5.
`--rules-preset standard|none` is available on `wtc repo create`.

## Decisions

- Rules are a `standard` preset with a `none` escape hatch in the TUI.
- Rules are a `standard` preset with a `none` escape hatch.
- Required approvals: 1.
- Dismiss stale approvals and require review thread resolution.
- CODEOWNERS reviews and required status checks are disabled for now.
- CODEOWNERS reviews and required status checks are disabled.
- Merge, squash, and rebase are all allowed.
- Only the `senior-reviewers` team bypasses the ruleset.
- Post-create setup failures are returned as warnings (repo creation is not rolled back).

## Token Requirements

The GitHub token needs the following permissions for full setup:

- `Administration: read/write` (repository settings)
- `Dependabot alerts: read/write` (vulnerability alerts)
- `Repository rules: read/write` (rulesets)
- Organization `member: read` (team lookup for bypass actor)
119 changes: 119 additions & 0 deletions plans/github/6.4-local-clone-and-wtc-project-bootstrap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
# 6.4 Local Clone + WTC Project Bootstrap ✅ Complete

## Goal

Optionally bootstrap a newly created GitHub repo as a ready-to-use WTC project by cloning it locally, writing `.wtc.yaml` into the clone, committing the config, and pushing it before repository rules are applied.

If the user skips Teamwork setup, repo creation keeps the existing behavior: create repo, apply repo setup/rules, and show the success dialog.

## Decisions

- Teamwork bootstrap is optional.
- Cloning uses SSH only; there is no HTTPS protocol choice.
- The clone parent directory defaults to the directory where WTC was started.
- Repo rules are applied after clone/bootstrap when Teamwork setup is enabled so the config commit can be pushed before branch protection is active.
- Do not add the GitHub repo URL to `project.links`; the `.wtc.yaml` lives inside the repo, so that link is redundant.
- Bootstrap should auto-discover values from our internal Teamwork project template before asking the user.

## Internal Teamwork Template Names

- General task list: `Internal | Billable Projects | General Tasks`
- Preferred code review task: `Dev | Code Review - Forever`
- Fallback code review task: `Dev | Code Review`

The code review task is expected to be a child task in the General task list.

This phase only needs the internal template path where Code Review is a task in the General task list. A future reusable picker can support IDs that represent either task lists or parent tasks with subtasks, matching the Project tab behavior.

## Bootstrap Config

Generated `.wtc.yaml` in the cloned repo:

```yaml
version: 1

project:
links: []

teamwork:
projectId: 12345
reviewTaskId: 67890
pinnedTaskLists:
- name: "General Tasks"
id: 1699936
```

The Teamwork project ID is the only required Teamwork value for bootstrap. If General Tasks or Code Review cannot be discovered, or the user skips them, WTC still writes the config with `pinnedTaskLists: []` and/or an empty `reviewTaskId`.

## Discovery Flow

1. Resolve Teamwork project ID.
- Prefer explicit CLI/TUI input.
- Otherwise use nearest current `.wtc.yaml` `teamwork.projectId`.
- If still missing in TUI, ask user.
- If still missing in CLI, fail before creating the repo.
2. Search for the General task list in that Teamwork project using `searchTerm`, then exact-match the returned task-list name.
3. If the General task list is found, search for the code review task using `searchTerm=Dev | Code Review`, `projectIds`, and `tasklistIds`, then exact-match returned task names in priority order: `Dev | Code Review - Forever`, then `Dev | Code Review`.
4. If both are found, skip the remaining Teamwork questions.
5. If the General task list is not found, ask for General task-list ID or URL and allow skipping only that field.
6. After a General task list is known, try again to find the code review task inside it.
7. If the code review task is still not found, ask for code review task ID or URL and allow skipping only that field.

## TUI Flow

Existing repo creation steps remain unchanged until repo rules are selected.

1. Ask: `Would you like to setup Teamwork linking now?`
2. If no:
- Continue to final confirmation without bootstrap.
3. If yes:
- Resolve or ask for Teamwork project ID.
- Auto-discover General task list and code review task.
- Ask only for values that could not be discovered; General Tasks and Code Review can be skipped independently.
- Ask for clone parent directory, defaulting to process start directory.
- Validate the clone target does not exist.
4. Show final confirmation with repo and Teamwork setup details.
5. If confirmed:
- Create the GitHub repo.
- Clone with `repo.sshUrl`.
- Write `.wtc.yaml` in the cloned repo.
- Commit `chore: add WTC project config`.
- Push the config commit.
- Apply repo settings/rules.
- Show success with any bootstrap/setup warnings.

## CLI Flow

Existing default remains unchanged unless Teamwork setup is requested.

Potential flags on `wtc repo create`:

- `--setup-teamwork`: enable clone + `.wtc.yaml` bootstrap.
- `--clone-dir <path>`: clone parent directory; defaults to process start directory.
- `--teamwork-project-id <id>`: optional override for current config value.
- `--general-tasks <taskListId|taskListUrl|-1>`: optional override for auto-discovery. `-1` explicitly skips the pinned General Tasks list.
- `--review-task <taskId|taskUrl|-1>`: optional override for auto-discovery. `-1` explicitly skips the Code Review task.

When `--setup-teamwork` is present, CLI should fail before repo creation only if it cannot resolve the required Teamwork project ID or clone target. General Tasks and Code Review are optional config values; if discovery does not find them, CLI proceeds and writes empty values.

## API Scope

- Add task-list reference parsing next to the existing task reference parser.
- Add targeted Teamwork task-list and task discovery using `searchTerm` and exact-match filtering.
- Add Git helpers for clone, commit, and push config.
- Add a repo creation workflow that can delay repo setup/rules until after optional bootstrap.

## Error Handling

- If repo creation fails, stop normally.
- If bootstrap fails after repo creation, still attempt repo setup/rules and return warnings.
- If repo setup/rules fail, return warnings as current 6.3 behavior does.
- Do not leave errors only in logs; TUI/CLI must show user-facing warnings.

## Verification

- `bun run check`
- `bun run lint`
- Manual TUI happy path with internal Teamwork template project.
- Manual CLI happy path with `--setup-teamwork`.
- Manual skip path to confirm existing repo creation still works unchanged.
42 changes: 0 additions & 42 deletions plans/github/6.4-teamwork-project-linking.md

This file was deleted.

Loading
Loading