-
Notifications
You must be signed in to change notification settings - Fork 0
feature(github): repo clone with config setup #74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
marlonmarcello
wants to merge
6
commits into
main
Choose a base branch
from
feature/github/repo-clone-config-setup
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
83ead76
chore: docs and plan reconcilliation
marlonmarcello d5a8d18
feature: refactor preflight for repo creation and adds local clonning
marlonmarcello 24e5381
fix: repo creation doesnt wait for completion
marlonmarcello 66f20c0
fix: CLI flag for boolean
marlonmarcello ea95087
chore: changeset
marlonmarcello 184c51c
chore: better logs
marlonmarcello File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "wtc": patch | ||
| --- | ||
|
|
||
| feature: adds cli cloning and teamwork setup | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 24.18.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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`). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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
119
plans/github/6.4-local-clone-and-wtc-project-bootstrap.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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. |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.