···11-# TODO.md: Tangled CLI Development Plan
22-33-This document outlines the development tasks for the Tangled CLI, based on the `README.md` and project goals.
44-55-## Project Setup & Core Structure (Commander.js)
66-77-- [x] Initialize Node.js project.
88-- [x] Install `commander` for CLI routing.
99-- [x] Implement basic CLI command structure (e.g., `tangled --version`, `tangled --help`).
1010-- [x] Set up TypeScript configuration.
1111-- [x] Configure linting and formatting (Biome).
1212-- [x] Configure vitest for testing.
1313-1414-## Authentication (Auth)
1515-1616-- [x] Implement `tangled auth login` command.
1717- - [x] Collect user's PDS handle and app password.
1818- - [x] Implement session storage using an OS keychain library (e.g., `keytar`) for secure, cross-platform token management.
1919- - [x] Integrate `@atproto/api` for XRPC client and session management.
2020-- [x] Implement `tangled auth logout` command.
2121-2222-## Git SSH Key Management
2323-2424-- [x] Implement `tangled ssh-key verify` command.
2525- - [x] This command executes `ssh -T git@tangled.org`, parses the DID from its output, and displays it to the user.
2626- - [x] If the user is logged in with the CLI and their DID matches the SSH DID, their handle is also displayed.
2727-2828-## Context Engine (Git Integration)
2929-3030-- [x] Develop a "Context Resolver" module to infer repository context (DID) from the current working directory.
3131- - [x] Start by using the current Git repository context.
3232- - [x] Integrate `git-url-parse` to resolve Tangled DID/NSID from `.git/config` remote URLs. Using `simple-git` if needed.
3333- - [x] If multiple remotes exist, look for one at tangled.org, then prompt the user to select remote if ambiguity remains.
3434- - [x] Fallback to prompting the user to add a remote for their Tangled repository if none are found.
3535- - [x] Avoid creating a config file in V1; rely on Git remotes and CLI flags for context.
3636- - [x] If a config is needed remember that the precedence order should be: CLI flags > local config > home folder config. Users may prefer different settings per repo (such as unique remote names, etc).
3737-3838-## Issue Management
3939-4040-- [x] Implement `tangled issue create "<title>" [--body "<body>" | --body-file <file> | -F -]` command.
4141-- [x] Implement `tangled issue list [--json "id,title"]` command.
4242- - [x] Support `--json` output with field filtering.
4343-- [ ] Migrate this TODO list into Tangled issues once issue creation is implemented. (note defects and address blocking features as needed).
4444- - [ ] Create phases in this todo list, and then use `- [ ]` tasks in the issue descriptions.
4545- - [ ] Remove TODO.md once all tasks are migrated to issues.
4646- - [ ] Update README.md to link to the issue board for contribution guidelines and project status instead of this TODO list.
4747- - [ ] Create CLI_FEEDBACK.md with learnings from using the CLI and complete the issue creation process and close the loop on dogfooding the CLI for this project.
4848-4949-## Pull Request Management
5050-5151-This section outlines the phased implementation for Pull Request (PR) support, following `gh` CLI patterns.
5252-5353-### Phase 1: Creating a Pull Request from a Branch (Author Workflow)
5454-5555-- [ ] Implement `tangled pr create --base <base-branch> --head <head-branch> --title <title> [--body <body> | --body-file <file> | -F -]` command.
5656- - [ ] Generate the `git diff` patch between the `--head` and `--base` branches.
5757- - [ ] Upload the generated patch as a blob using `com.atproto.repo.uploadBlob` (or equivalent).
5858- - [ ] Create a `sh.tangled.repo.pull` record using `com.atproto.repo.createRecord`, including `target` (repo and base branch), `source` (head branch and SHA), `title`, `body`, and the `patchBlob` reference.
5959-- [ ] Implement `tangled pr list [--json <fields>]` command to list pull requests for the current repository.
6060- - [ ] Use `com.atproto.repo.listRecords` with `collection: "sh.tangled.repo.pull"`.
6161-- [ ] Implement `tangled pr view <id> [--json <fields>]` command to display detailed information about a specific pull request.
6262- - [ ] Use `com.atproto.repo.getRecord` for the `sh.tangled.repo.pull` record.
6363- - [ ] Fetch associated comments using `com.atproto.repo.listRecords` with `collection: "sh.tangled.repo.pull.comment"`.
6464- - [ ] Dogfood the CLI by using it to create a pull request for these changes, and then view the created PR to ensure all data is correctly stored and retrieved.
6565-6666-### Phase 2: Working as a Reviewer (Commenting)
6767-6868-- [ ] Implement `tangled pr comment <id> [--body <body> | --body-file <file> | -F -]` command.
6969- - [ ] Create a `sh.tangled.repo.pull.comment` record using `com.atproto.repo.createRecord`, linking it to the pull request's AT-URI.
7070-- [ ] Implement `tangled pr review <id> --comment <comment> [--approve | --request-changes]` command.
7171- - [ ] Create a `sh.tangled.repo.pull.comment` record.
7272- - [ ] Update the `sh.tangled.repo.pull.status` record (if applicable) to reflect approval or requested changes. (Further API research might be needed to map approve/request-changes to status updates).
7373-7474-### Phase 3: Responding to a Review (Author Workflow)
7575-7676-- [ ] This phase primarily involves local Git operations (pushing new commits) and using `tangled pr comment` for clarifications, which are covered by existing or planned commands.
7777-7878-## Repository Management
7979-8080-- [ ] Implement `tangled repo create <repo-name>` command.
8181-- [ ] Implement `tangled repo view` command (display repo details).
8282- - [ ] Support `--json` output with field filtering (e.g., `--json name,cloneUrl,description`) using `lodash/pick`).