@anatolykoptev/krolik-cli 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,479 @@
1
+ # KROLIK CLI
2
+
3
+ [![CI](https://github.com/anatolykoptev/krolik-cli/actions/workflows/ci.yml/badge.svg)](https://github.com/anatolykoptev/krolik-cli/actions/workflows/ci.yml)
4
+ [![codecov](https://codecov.io/gh/anatolykoptev/krolik-cli/branch/main/graph/badge.svg)](https://codecov.io/gh/anatolykoptev/krolik-cli)
5
+ [![npm version](https://badge.fury.io/js/%40anatolykoptev%2Fkrolik-cli.svg)](https://badge.fury.io/js/%40anatolykoptev%2Fkrolik-cli)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
+
8
+ ```
9
+ (\(\
10
+ (-.-)
11
+ o_(")(")
12
+ ```
13
+
14
+ Fast AI-assisted development toolkit for TypeScript projects.
15
+
16
+ ## Features
17
+
18
+ - **Project Status** — Quick diagnostics (git, types, lint, TODOs)
19
+ - **Code Quality** — Analyze code for SRP, complexity, type-safety, lint issues
20
+ - **Auto-Fix** — Automatically fix code issues (Biome + TypeScript + custom)
21
+ - **Code Review** — AI-assisted review of changes
22
+ - **Schema Analysis** — Prisma schema documentation
23
+ - **Routes Analysis** — tRPC routes documentation
24
+ - **Issue Parser** — GitHub issue parsing for AI context
25
+ - **Context Generator** — Generate AI context for tasks
26
+ - **Code Generation** — Hooks, schemas, tests, barrels, docs
27
+ - **Security Audit** — Check for vulnerabilities
28
+ - **MCP Server** — Claude Code integration
29
+ - **Plugin Setup** — Install Claude Code plugins (claude-mem, etc.)
30
+
31
+ ## Installation
32
+
33
+ ```bash
34
+ # Global install
35
+ npm install -g krolik-cli
36
+
37
+ # Or as a dev dependency
38
+ pnpm add -D krolik-cli
39
+ ```
40
+
41
+ ## Quick Start
42
+
43
+ ```bash
44
+ # Initialize config
45
+ krolik init
46
+
47
+ # Quick project status
48
+ krolik status
49
+
50
+ # Status without slow checks
51
+ krolik status --fast
52
+
53
+ # Review current branch changes
54
+ krolik review
55
+
56
+ # Analyze Prisma schema
57
+ krolik schema --save
58
+
59
+ # Analyze tRPC routes
60
+ krolik routes --save
61
+
62
+ # Parse GitHub issue
63
+ krolik issue 123
64
+
65
+ # Generate code
66
+ krolik codegen hooks
67
+ krolik codegen schemas
68
+ krolik codegen tests
69
+
70
+ # Code quality analysis
71
+ krolik quality
72
+ krolik quality --ai # AI-friendly XML output
73
+
74
+ # Auto-fix issues
75
+ krolik fix # Full pipeline
76
+ krolik fix --dry-run # Preview changes
77
+
78
+ # Security audit
79
+ krolik security
80
+
81
+ # Start MCP server
82
+ krolik mcp
83
+
84
+ # Install Claude Code plugins (claude-mem, etc.)
85
+ krolik setup
86
+ ```
87
+
88
+ ## Configuration
89
+
90
+ Create `krolik.config.ts` or `krolik.yaml` in your project root.
91
+
92
+ ### TypeScript Config
93
+
94
+ ```typescript
95
+ import { defineConfig } from 'krolik-cli';
96
+
97
+ export default defineConfig({
98
+ name: 'my-project',
99
+ paths: {
100
+ web: 'apps/web',
101
+ api: 'packages/api',
102
+ db: 'packages/db',
103
+ },
104
+ features: {
105
+ prisma: true,
106
+ trpc: true,
107
+ nextjs: true,
108
+ },
109
+ prisma: {
110
+ schemaDir: 'packages/db/prisma/schema',
111
+ },
112
+ trpc: {
113
+ routersDir: 'packages/api/src/routers',
114
+ },
115
+ // Custom domains for context generation
116
+ domains: {
117
+ crm: {
118
+ keywords: ['customer', 'lead', 'contact'],
119
+ approach: ['Check CRM module', 'Review customer schema'],
120
+ },
121
+ },
122
+ });
123
+ ```
124
+
125
+ ### YAML Config
126
+
127
+ ```yaml
128
+ # krolik.yaml
129
+ name: my-project
130
+
131
+ paths:
132
+ web: apps/web
133
+ api: packages/api
134
+ db: packages/db
135
+
136
+ features:
137
+ prisma: true
138
+ trpc: true
139
+ nextjs: true
140
+
141
+ prisma:
142
+ schemaDir: packages/db/prisma/schema
143
+
144
+ trpc:
145
+ routersDir: packages/api/src/routers
146
+
147
+ # Custom domains for context generation
148
+ domains:
149
+ crm:
150
+ keywords:
151
+ - customer
152
+ - lead
153
+ - contact
154
+ approach:
155
+ - Check CRM module
156
+ - Review customer schema
157
+ ```
158
+
159
+ ## Auto-Detection
160
+
161
+ Krolik automatically detects:
162
+
163
+ - **Monorepo** — pnpm-workspace.yaml, npm/yarn workspaces
164
+ - **Prisma** — @prisma/client dependency, schema location
165
+ - **tRPC** — @trpc/server dependency, routers location
166
+ - **Next.js** — next dependency
167
+ - **TypeScript** — typescript dependency, tsconfig.json
168
+
169
+ ## Commands Reference
170
+
171
+ ### Global Options
172
+
173
+ ```bash
174
+ krolik [command] [options]
175
+ -V, --version Output version number
176
+ -c, --config <path> Path to config file
177
+ --project-root <path> Project root directory
178
+ --cwd <path> Alias for --project-root
179
+ -t, --text Human-readable text output (default: AI-friendly XML)
180
+ --json Output as JSON
181
+ -v, --verbose Verbose output
182
+ --no-color Disable colored output
183
+ ```
184
+
185
+ ---
186
+
187
+ ### `krolik status`
188
+
189
+ Quick project diagnostics: git, typecheck, lint, TODOs.
190
+
191
+ ```bash
192
+ krolik status # Full diagnostics
193
+ krolik status --fast # Skip slow checks (typecheck, lint)
194
+ krolik status --report # Generate AI-REPORT.md with code quality analysis
195
+ ```
196
+
197
+ ---
198
+
199
+ ### `krolik fix`
200
+
201
+ Auto-fix code quality issues. **Replaces deprecated `quality` command.**
202
+
203
+ ```bash
204
+ # Analysis modes
205
+ krolik fix --analyze-only # Analyze only (no fixes)
206
+ krolik fix --dry-run # Show what would be fixed
207
+ krolik fix --dry-run --diff # Show unified diff preview
208
+
209
+ # Execution
210
+ krolik fix # Apply all safe fixes
211
+ krolik fix --yes # Auto-confirm all fixes
212
+ krolik fix --path <path> # Fix specific directory
213
+ krolik fix --limit <n> # Max fixes to apply
214
+ krolik fix --backup # Create backup before fixing
215
+
216
+ # Fix scope
217
+ krolik fix --trivial # Only trivial (console, debugger)
218
+ krolik fix --safe # Trivial + safe (excludes risky)
219
+ krolik fix --all # Include risky fixers (requires confirmation)
220
+
221
+ # Tool selection
222
+ krolik fix --biome # Run Biome auto-fix (default)
223
+ krolik fix --biome-only # Only Biome, skip custom
224
+ krolik fix --no-biome # Skip Biome
225
+ krolik fix --typecheck # Run TypeScript check (default)
226
+ krolik fix --typecheck-only # Only TypeScript check
227
+ krolik fix --no-typecheck # Skip TypeScript check
228
+
229
+ # Category filtering
230
+ krolik fix --category lint # Only lint issues
231
+ krolik fix --category type-safety # Only type-safety issues
232
+ krolik fix --category complexity # Only complexity issues
233
+
234
+ # Individual fixers
235
+ krolik fix --fix-console # Fix console.log
236
+ krolik fix --fix-debugger # Fix debugger statements
237
+ krolik fix --fix-alert # Fix alert() calls
238
+ krolik fix --fix-ts-ignore # Fix @ts-ignore
239
+ krolik fix --fix-any # Fix `any` types
240
+ krolik fix --fix-complexity # Fix high complexity
241
+ krolik fix --fix-long-functions # Fix long functions
242
+ krolik fix --fix-magic-numbers # Fix magic numbers
243
+ krolik fix --fix-urls # Fix hardcoded URLs
244
+ krolik fix --fix-srp # Fix SRP violations
245
+
246
+ # Disable fixers
247
+ krolik fix --no-console # Skip console fixes
248
+ krolik fix --no-debugger # Skip debugger fixes
249
+ krolik fix --no-any # Skip any type fixes
250
+
251
+ # Reports
252
+ krolik fix --list-fixers # List all available fixers
253
+ # For AI reports use: krolik status --report
254
+ ```
255
+
256
+ **Fix Categories:**
257
+ - `lint` — console, debugger, alert statements
258
+ - `type-safety` — any, @ts-ignore, eval, loose equality
259
+ - `complexity` — high cyclomatic complexity, long functions
260
+ - `hardcoded` — magic numbers, hardcoded URLs
261
+ - `srp` — single responsibility violations
262
+
263
+ ---
264
+
265
+ ### `krolik context`
266
+
267
+ Generate AI-friendly context for tasks.
268
+
269
+ ```bash
270
+ krolik context --feature <name> # Context for feature (e.g., "booking", "crm")
271
+ krolik context --issue <number> # Context from GitHub issue
272
+ krolik context --file <path> # Context for specific file
273
+ krolik context --include-code # Include Zod schemas and code snippets
274
+ krolik context --domain-history # Include git history for domain files
275
+ krolik context --show-deps # Show domain dependencies
276
+ krolik context --full # Enable all enrichment options
277
+ ```
278
+
279
+ ---
280
+
281
+ ### `krolik review`
282
+
283
+ AI-assisted code review.
284
+
285
+ ```bash
286
+ krolik review # Review current branch vs main
287
+ krolik review --staged # Review staged changes only
288
+ krolik review --pr <number> # Review specific PR
289
+ ```
290
+
291
+ ---
292
+
293
+ ### `krolik schema`
294
+
295
+ Analyze Prisma schema.
296
+
297
+ ```bash
298
+ krolik schema # Print to stdout (AI-friendly XML)
299
+ krolik schema --save # Save to SCHEMA.md
300
+ krolik schema --json # JSON output
301
+ ```
302
+
303
+ ---
304
+
305
+ ### `krolik routes`
306
+
307
+ Analyze tRPC routes.
308
+
309
+ ```bash
310
+ krolik routes # Print to stdout (AI-friendly XML)
311
+ krolik routes --save # Save to ROUTES.md
312
+ krolik routes --json # JSON output
313
+ ```
314
+
315
+ ---
316
+
317
+ ### `krolik issue [number]`
318
+
319
+ Parse GitHub issue for AI context.
320
+
321
+ ```bash
322
+ krolik issue 123 # Parse issue by number
323
+ krolik issue --url <url> # Parse issue by URL
324
+ ```
325
+
326
+ ---
327
+
328
+ ### `krolik codegen <target>`
329
+
330
+ Generate code artifacts.
331
+
332
+ ```bash
333
+ krolik codegen hooks # Generate React hooks
334
+ krolik codegen schemas # Generate Zod schemas
335
+ krolik codegen tests # Generate test files
336
+ krolik codegen barrels # Generate index.ts exports
337
+ krolik codegen docs # Generate documentation
338
+
339
+ # Options
340
+ krolik codegen <target> --path <path> # Target path
341
+ krolik codegen <target> --dry-run # Preview without changes
342
+ krolik codegen <target> --force # Overwrite existing files
343
+ ```
344
+
345
+ ---
346
+
347
+ ### `krolik refine`
348
+
349
+ Analyze and reorganize lib/ structure to @namespace pattern.
350
+
351
+ ```bash
352
+ krolik refine # Analyze lib/ structure
353
+ krolik refine --lib-path <path> # Custom lib directory
354
+ krolik refine --dry-run # Preview changes
355
+ krolik refine --apply # Apply migration (move dirs, update imports)
356
+ krolik refine --generate-config # Generate ai-config.ts
357
+ ```
358
+
359
+ ---
360
+
361
+ ### `krolik security`
362
+
363
+ Run security audit.
364
+
365
+ ```bash
366
+ krolik security # Audit dependencies
367
+ krolik security --fix # Attempt to fix vulnerabilities
368
+ ```
369
+
370
+ ---
371
+
372
+ ### `krolik mcp`
373
+
374
+ Start MCP server for Claude Code integration (stdio transport).
375
+
376
+ ```bash
377
+ krolik mcp # Start MCP server
378
+ ```
379
+
380
+ **Setup in Claude Code:**
381
+
382
+ ```bash
383
+ claude mcp add krolik -- npx krolik mcp
384
+ ```
385
+
386
+ Or add to `.claude/settings.json`:
387
+
388
+ ```json
389
+ {
390
+ "mcpServers": {
391
+ "krolik": {
392
+ "command": "npx",
393
+ "args": ["krolik", "mcp"],
394
+ "cwd": "/path/to/your/project"
395
+ }
396
+ }
397
+ }
398
+ ```
399
+
400
+ **Available MCP Tools:**
401
+
402
+ | Tool | Description |
403
+ |------|-------------|
404
+ | `krolik_status` | Project diagnostics (git, typecheck, lint, TODOs) |
405
+ | `krolik_context` | AI context generation for features/issues |
406
+ | `krolik_schema` | Prisma schema analysis |
407
+ | `krolik_routes` | tRPC routes analysis |
408
+ | `krolik_review` | Code review for changes |
409
+ | `krolik_issue` | GitHub issue parsing |
410
+
411
+ ---
412
+
413
+ ### `krolik setup`
414
+
415
+ Install recommended Claude Code plugins.
416
+
417
+ ```bash
418
+ krolik setup # Install all recommended plugins
419
+ krolik setup --list # List available plugins
420
+ krolik setup --mem # Install only claude-mem
421
+ krolik setup --dry-run # Preview without installing
422
+ krolik setup --force # Reinstall even if already installed
423
+ ```
424
+
425
+ **Available Plugins:**
426
+
427
+ | Plugin | Description |
428
+ |--------|-------------|
429
+ | `claude-mem` | Persistent memory for Claude Code sessions — saves context across sessions, semantic search over history |
430
+
431
+ **What `krolik setup` does:**
432
+
433
+ 1. Clones plugin from GitHub
434
+ 2. Installs dependencies (`npm install`)
435
+ 3. Builds the plugin (`npm run build`)
436
+ 4. Registers in Claude Code (`~/.claude/plugins/`)
437
+ 5. Creates data directories
438
+
439
+ **After installation:**
440
+
441
+ - Restart Claude Code to activate plugins
442
+ - Web UI available at http://localhost:37777 (for claude-mem)
443
+ - Context automatically injected at session start
444
+ - Search with natural language: "What did we do yesterday?"
445
+
446
+ ---
447
+
448
+ ### `krolik init`
449
+
450
+ Initialize krolik.config.ts in project root.
451
+
452
+ ```bash
453
+ krolik init # Interactive config setup
454
+ ```
455
+
456
+ ## Environment Variables
457
+
458
+ | Variable | Description | Default |
459
+ |----------|-------------|---------|
460
+ | `KROLIK_CONFIG` | Config file path | Auto-detected |
461
+ | `KROLIK_PROJECT_ROOT` | Project root | Current directory |
462
+ | `KROLIK_LOG_LEVEL` | Log level (debug/info/warn/error) | info |
463
+
464
+ ## Programmatic Usage
465
+
466
+ ```typescript
467
+ import { loadConfig, createLogger, runStatus } from 'krolik-cli';
468
+
469
+ async function main() {
470
+ const config = await loadConfig();
471
+ const logger = createLogger();
472
+
473
+ await runStatus({ config, logger, options: { fast: true } });
474
+ }
475
+ ```
476
+
477
+ ## License
478
+
479
+ MIT