···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+## 1. Project Setup & Core Structure (Commander.js)
66+- [ ] Initialize Node.js project.
77+- [ ] Install `commander` for CLI routing.
88+- [ ] Implement basic CLI command structure (e.g., `tangled --version`, `tangled --help`).
99+- [ ] Set up TypeScript configuration.
1010+- [ ] Configure linting and formatting (ESLint, Prettier).
1111+1212+## 2. Authentication (Auth)
1313+- [ ] Implement `tangled auth login` command.
1414+ - [ ] Explore methods for secure AT Proto session storage (OS keychain consideration across platforms: Windows, macOS, Linux).
1515+ - [ ] Integrate `@atproto/api` for XRPC client and session management.
1616+ - [ ] Investigate web browser authentication flow.
1717+- [ ] Implement `tangled auth logout` command.
1818+1919+## 3. Git SSH Key Management
2020+- [ ] Implement `tangled ssh-key add <public-key-path>` command.
2121+ - [ ] This command should upload the provided public SSH key to the user's tangled.org account via the API, similar to how `gh ssh-key add` works.
2222+ - [ ] The CLI is not responsible for generating SSH keys or managing the local ssh-agent; users are expected to handle these steps externally.
2323+- [ ] Implement `tangled ssh-key verify` command.
2424+ - [ ] This command should execute `ssh -T git@tangled.org`, parse the DID from its output, and then resolve that DID to a Bluesky handle, displaying the result to the user.
2525+- [ ] Ensure all Git operations leverage SSH keys for authentication, as `tangled.org` exclusively supports SSH for Git.
2626+2727+## 4. Context Engine (Git Integration)
2828+- [ ] Integrate `git-url-parse` to resolve Tangled DID/NSID from `.git/config` remote URLs.
2929+- [ ] Develop a "Context Resolver" module to infer repository context (DID) from the current working directory.
3030+- [ ] Implement fallback mechanisms if no git remote is found or DID cannot be resolved (error handling).
3131+- [ ] Integrate `simple-git` for safe local git operations.
3232+- [ ] Implement logic to parse the DID from `ssh -T git@tangled.org` output (will be reused by `tangled ssh-key verify`).
3333+- [ ] Implement functionality to resolve a DID (e.g., `did:plc:b2mcbcamkwyznc5fkplwlxbf`) into a human-readable Bluesky handle (will be reused by `tangled ssh-key verify`).
3434+3535+## 5. Repository Management
3636+- [ ] Implement `tangled repo create <repo-name>` command.
3737+- [ ] Implement `tangled repo view` command (display repo details).
3838+ - [ ] Support `--json` output with field filtering (e.g., `--json name,cloneUrl,description`) using `lodash/pick`).
3939+4040+## 6. Issue Management
4141+- [ ] Implement `tangled issue create "<title>" [--body "<body>" | --body-file <file> | -F -]` command.
4242+- [ ] Implement `tangled issue list [--json "id,title"]` command.
4343+ - [ ] Support `--json` output with field filtering.
4444+4545+## 7. Output & LLM Integration
4646+- [ ] Implement output formatting based on `is-interactive` check.
4747+ - [ ] "Human Mode" (TTY): Use `cli-table3` for pretty tables.
4848+ - [ ] "Machine Mode" (Pipe/`--json`): Plain text or JSON output.
4949+- [ ] Implement `--json` flag for structured output.
5050+- [ ] Implement `--no-input` flag to force CLI to error on unresolved context or missing flags (Fail Fast, Fail Loud principle).
5151+5252+## 8. Testing
5353+- [ ] Set up a testing framework (e.g., Jest, Vitest).
5454+- [ ] Write unit tests for core modules (Auth, Context Resolver, API client).
5555+- [ ] Write integration tests for CLI commands.
5656+5757+## 9. Documentation & Deployment
5858+- [ ] Generate CLI help documentation (`commander` usually handles this).
5959+- [ ] Consider packaging/distribution strategy (npm, standalone binary).
6060+6161+## 10. Outstanding Issues / Future Considerations (from README)
6262+- [ ] Secure cross-platform AT Proto session storage (OS keychain).
6363+- [ ] Git authentication management similar to GitHub CLI (SSH keys, 1Password integration).
6464+- [ ] Define clear precedence order for settings resolution (local config, home folder, CLI flags).
6565+- [ ] Consider adding extensions/plugins (Out of Scope for V1, but keep in mind).