|
58 | 58 | ├── main-tunnel.ts # Tunnel bootstrap: auth commands + WebSocket tunnel |
59 | 59 | ├── app.module.ts # Root module with forStdio()/forHttp()/forTunnel() factories |
60 | 60 | ├── bootstrap.ts # Shared logger setup (pino → NestJS LoggerService) |
61 | | -├── cli.ts # Commander CLI with subcommands: default (server), --tunnel, --login, --logout |
| 61 | +├── cli.ts # Commander entrypoint: option parsing, subcommand dispatch |
| 62 | +├── cli/cli-output.ts # User-facing print helpers (cli.success/error/info/box) — separate from cli.ts so non-CLI code can use it without pulling in Commander |
62 | 63 | ├── app-config.service.ts # IAnkiConfig implementation (reads from validated AppConfig) |
63 | 64 | ├── config/ # Zod-validated config system (schema, factory, APP_CONFIG token) |
| 65 | +├── services/ngrok.service.ts # Optional ngrok subprocess for HTTP-mode public tunneling |
| 66 | +├── http/guards/ # HTTP-only guards (Origin allowlist) |
64 | 67 | ├── tunnel/ # Tunnel mode: WebSocket client, OAuth device flow, credentials |
65 | 68 | │ ├── tunnel.client.ts # WebSocket client for tunnel server |
66 | 69 | │ ├── tunnel-mcp.service.ts # Bridges MCP ↔ tunnel via InMemoryTransport |
| 70 | +│ ├── in-memory.transport.ts # MCP transport that connects to TunnelClient in-process |
| 71 | +│ ├── tunnel.protocol.ts # WS message type definitions (request/response/ping/error) |
67 | 72 | │ ├── device-flow.service.ts # OAuth device flow authentication |
68 | 73 | │ ├── credentials.service.ts # Persistent credential storage |
69 | 74 | │ └── commands/ # CLI command handlers (login, logout, tunnel) |
@@ -138,7 +143,7 @@ These are upstream behaviors that shape tool design — surface them in tool des |
138 | 143 |
|
139 | 144 | 1. **CLI Output** (user-facing, clean, no timestamps): |
140 | 145 | ```typescript |
141 | | - import { cli } from '@/cli'; |
| 146 | + import { cli } from '@/cli/cli-output'; |
142 | 147 |
|
143 | 148 | cli.success('Connected to Anki'); // ✓ Connected to Anki |
144 | 149 | cli.error('Connection failed'); // ✗ Connection failed |
@@ -211,6 +216,8 @@ See `src/mcp/primitives/essential/tools/sync.tool.ts` for minimal example. |
211 | 216 | Three distinct tiers — pick the right one for the change: |
212 | 217 |
|
213 | 218 | - **Unit** — `src/**/__tests__/*.spec.ts`, colocated with source. Mock `AnkiConnectClient`. Fast, run on every push. |
| 219 | + - Tool-level tests live next to each tool (e.g. `src/mcp/primitives/essential/tools/__tests__/`). |
| 220 | + - App-level wiring tests live in `src/__tests__/` (`app-config.service.spec.ts`, `cli.spec.ts`, `main-http.spec.ts`) — bootstrap, CLI parsing, config validation. |
214 | 221 | - **Workflows** — `test/workflows/*.spec.ts` (e.g., `note-management.spec.ts`, `review-session.spec.ts`). Multi-tool scenarios still against a mocked client. Use for cross-tool invariants. |
215 | 222 | - **E2E** — `test/e2e/*.e2e-spec.ts`. Hits a real Anki + AnkiConnect running in Docker. Covers both STDIO and HTTP transports. |
216 | 223 |
|
|
0 commit comments