|
| 1 | +# @yavydev/cli |
| 2 | + |
| 3 | +CLI for searching, managing, and configuring AI-ready documentation on Yavy. |
| 4 | + |
| 5 | +## Commands |
| 6 | + |
| 7 | +```bash |
| 8 | +npm install # Install dependencies |
| 9 | +npm run build # Build with tsup |
| 10 | +npm run dev # Build in watch mode |
| 11 | +npm run check # Run all checks (typecheck + lint + format + test) |
| 12 | +npm run typecheck # TypeScript strict type checking |
| 13 | +npm run lint # ESLint with typescript-eslint |
| 14 | +npm run lint:fix # ESLint auto-fix |
| 15 | +npm run test # Run tests (vitest) |
| 16 | +npm run format:check # Check formatting (prettier) |
| 17 | +npm run format # Fix formatting |
| 18 | +``` |
| 19 | + |
| 20 | +## Architecture |
| 21 | + |
| 22 | +The CLI is built on Commander.js with a modular command structure. Each command is a factory function returning a `Command` instance, registered in the entry point. |
| 23 | + |
| 24 | +- **Commands** - one directory or file per command group. Each exports a factory. |
| 25 | +- **API Client** - token-based HTTP client with retry logic and exponential backoff. |
| 26 | +- **Auth** - OAuth2 PKCE flow with local callback server; credentials stored in `~/.yavy/`. |
| 27 | +- **Prompts** - interactive flows using @clack/prompts for multi-select and @inquirer/prompts for input/select. |
| 28 | + |
| 29 | +See [docs/architecture.md](docs/architecture.md) for details. |
| 30 | + |
| 31 | +## Key Design Decisions |
| 32 | + |
| 33 | +- `@/` path aliases throughout (configured in tsconfig, tsup, vitest). |
| 34 | +- Strict TypeScript: `strict`, `noUncheckedIndexedAccess`, `noUnusedLocals`, `noUnusedParameters`, `noFallthroughCasesInSwitch`. |
| 35 | +- ESLint with typescript-eslint: `consistent-type-imports`, `no-floating-promises`, `no-explicit-any`. |
| 36 | +- Commands set `process.exitCode` instead of calling `process.exit()` directly - keeps code testable. |
| 37 | +- Two auth patterns coexist: OAuth (login flow) and token-based (API token via env or config file). |
| 38 | +- Interactive mode activates when required CLI flags are missing; flags always take precedence. |
| 39 | + |
| 40 | +## After Changing Commands |
| 41 | + |
| 42 | +- Register new commands in the entry point. |
| 43 | +- Add the command to README.md under the Commands section. |
| 44 | +- If adding a new command group, create a directory under `src/commands/`. |
| 45 | + |
| 46 | +## After Changing the API Client |
| 47 | + |
| 48 | +- Update tests that mock fetch globally. |
| 49 | +- If adding new response types, define them alongside existing API interfaces in the client module. |
| 50 | + |
| 51 | +## Documentation |
| 52 | + |
| 53 | +- [Architecture](docs/architecture.md) - layers, data flow, design decisions |
| 54 | +- [README](README.md) - install, quick start, command reference |
0 commit comments