@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.
@@ -0,0 +1,417 @@
1
+ import { R as ResolvedConfig } from './loader-_tD59b9E.js';
2
+ export { F as FeatureConfig, K as KrolikConfig, P as PathConfig, a as PrismaConfig, b as RabbitConfig, T as TemplateConfig, c as TrpcConfig, d as defineConfig, g as getConfig, l as loadConfig } from './loader-_tD59b9E.js';
3
+
4
+ /**
5
+ * @module types/commands/base
6
+ * @description Base command types and interfaces
7
+ */
8
+
9
+ /**
10
+ * Output format for command results
11
+ * Default is 'ai' (AI-friendly XML format)
12
+ */
13
+ type OutputFormat = 'ai' | 'json' | 'text' | 'markdown';
14
+ /**
15
+ * Log levels
16
+ */
17
+ type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'silent';
18
+ /**
19
+ * Logger interface for dependency injection
20
+ */
21
+ interface Logger {
22
+ debug(message: string): void;
23
+ info(message: string): void;
24
+ warn(message: string): void;
25
+ error(message: string): void;
26
+ success(message: string): void;
27
+ section(title: string): void;
28
+ box(lines: string[], type?: 'info' | 'success' | 'warning' | 'error'): void;
29
+ }
30
+ /**
31
+ * Base options for all commands
32
+ */
33
+ interface BaseCommandOptions {
34
+ /** Output format (default: 'ai' for AI-friendly XML) */
35
+ format?: OutputFormat;
36
+ /** Enable verbose logging */
37
+ verbose?: boolean;
38
+ /** Dry run mode (no changes) */
39
+ dryRun?: boolean;
40
+ /** Custom config path */
41
+ config?: string;
42
+ /** Project root override */
43
+ projectRoot?: string;
44
+ /** Human-readable text output */
45
+ text?: boolean;
46
+ /** JSON output */
47
+ json?: boolean;
48
+ }
49
+ /**
50
+ * Command context passed to all commands
51
+ */
52
+ interface CommandContext {
53
+ /** Resolved configuration */
54
+ config: ResolvedConfig;
55
+ /** Logger instance */
56
+ logger: Logger;
57
+ /** Command options */
58
+ options: BaseCommandOptions;
59
+ }
60
+ /**
61
+ * Generic command result
62
+ */
63
+ interface CommandResult<T = unknown> {
64
+ /** Whether command succeeded */
65
+ success: boolean;
66
+ /** Result data */
67
+ data?: T;
68
+ /** Error message if failed */
69
+ error?: string;
70
+ /** Duration in milliseconds */
71
+ durationMs?: number;
72
+ }
73
+
74
+ /**
75
+ * @module commands/fix/types
76
+ * @description Unified types for code quality analysis and auto-fixing
77
+ *
78
+ * Consolidates all types from former quality/ into fix/
79
+ */
80
+
81
+ /**
82
+ * Severity levels for quality issues
83
+ */
84
+ type QualitySeverity = 'error' | 'warning' | 'info';
85
+
86
+ /**
87
+ * @module types/commands/review
88
+ * @description Review command result types
89
+ */
90
+
91
+ type ReviewSeverity = QualitySeverity;
92
+ /**
93
+ * Review issue categories
94
+ */
95
+ type ReviewCategory = 'security' | 'performance' | 'style' | 'logic' | 'test' | 'docs';
96
+ /**
97
+ * Single review issue
98
+ */
99
+ interface ReviewIssue {
100
+ file: string;
101
+ line?: number;
102
+ severity: ReviewSeverity;
103
+ category: ReviewCategory;
104
+ message: string;
105
+ suggestion?: string;
106
+ }
107
+ /**
108
+ * File change information
109
+ */
110
+ interface FileChange {
111
+ path: string;
112
+ status: 'added' | 'modified' | 'deleted' | 'renamed';
113
+ additions: number;
114
+ deletions: number;
115
+ binary: boolean;
116
+ }
117
+ /**
118
+ * Review result
119
+ */
120
+ interface ReviewResult {
121
+ title: string;
122
+ description: string;
123
+ baseBranch: string;
124
+ headBranch: string;
125
+ files: FileChange[];
126
+ issues: ReviewIssue[];
127
+ affectedFeatures: string[];
128
+ summary: {
129
+ totalFiles: number;
130
+ additions: number;
131
+ deletions: number;
132
+ riskLevel: 'low' | 'medium' | 'high';
133
+ testsRequired: boolean;
134
+ docsRequired: boolean;
135
+ };
136
+ }
137
+
138
+ /**
139
+ * @module types/commands/routes
140
+ * @description Routes analysis result types
141
+ */
142
+ /**
143
+ * Route procedure definition
144
+ */
145
+ interface RouteProcedure {
146
+ name: string;
147
+ type: 'query' | 'mutation' | 'subscription';
148
+ input?: string;
149
+ output?: string;
150
+ }
151
+ /**
152
+ * Router definition
153
+ */
154
+ interface RouterDefinition {
155
+ name: string;
156
+ file: string;
157
+ procedures: RouteProcedure[];
158
+ }
159
+ /**
160
+ * Routes analysis result
161
+ */
162
+ interface RoutesResult {
163
+ routers: RouterDefinition[];
164
+ totalProcedures: number;
165
+ queries: number;
166
+ mutations: number;
167
+ }
168
+
169
+ /**
170
+ * @module types/commands/schema
171
+ * @description Schema analysis result types
172
+ */
173
+ /**
174
+ * Schema field definition
175
+ */
176
+ interface SchemaField {
177
+ name: string;
178
+ type: string;
179
+ isOptional: boolean;
180
+ isArray: boolean;
181
+ attributes: string[];
182
+ }
183
+ /**
184
+ * Schema relation definition
185
+ */
186
+ interface SchemaRelation {
187
+ name: string;
188
+ type: 'one-to-one' | 'one-to-many' | 'many-to-many';
189
+ target: string;
190
+ }
191
+ /**
192
+ * Schema model definition
193
+ */
194
+ interface SchemaModel {
195
+ name: string;
196
+ fields: SchemaField[];
197
+ relations: SchemaRelation[];
198
+ }
199
+ /**
200
+ * Schema analysis result
201
+ */
202
+ interface SchemaResult {
203
+ models: SchemaModel[];
204
+ enums: Array<{
205
+ name: string;
206
+ values: string[];
207
+ }>;
208
+ modelCount: number;
209
+ enumCount: number;
210
+ }
211
+
212
+ /**
213
+ * @module types/commands/status
214
+ * @description Status command result types
215
+ */
216
+ /**
217
+ * Status command result
218
+ */
219
+ interface StatusResult {
220
+ health: 'good' | 'warning' | 'error';
221
+ branch: {
222
+ name: string;
223
+ isCorrect: boolean;
224
+ };
225
+ git: {
226
+ hasChanges: boolean;
227
+ modified: number;
228
+ untracked: number;
229
+ staged: number;
230
+ ahead?: number;
231
+ behind?: number;
232
+ };
233
+ typecheck: {
234
+ status: 'passed' | 'failed' | 'skipped';
235
+ cached: boolean;
236
+ errors?: string;
237
+ };
238
+ lint: {
239
+ warnings: number;
240
+ errors: number;
241
+ };
242
+ todos: {
243
+ count: number;
244
+ };
245
+ durationMs: number;
246
+ /** Package info (optional, for rich output) */
247
+ package?: {
248
+ name: string;
249
+ version: string;
250
+ depsCount: number;
251
+ devDepsCount: number;
252
+ };
253
+ /** Tech stack (optional, for rich output) */
254
+ techStack?: {
255
+ framework?: string;
256
+ language: 'typescript' | 'javascript';
257
+ ui: string[];
258
+ database: string[];
259
+ api: string[];
260
+ packageManager: string;
261
+ };
262
+ /** Recent commits (optional, for rich output) */
263
+ recentCommits?: Array<{
264
+ hash: string;
265
+ message: string;
266
+ author: string;
267
+ relativeDate: string;
268
+ }>;
269
+ /** File stats (optional, for rich output) */
270
+ fileStats?: {
271
+ sourceFiles: number;
272
+ testFiles: number;
273
+ };
274
+ /** Monorepo workspaces (optional) */
275
+ workspaces?: Array<{
276
+ name: string;
277
+ path: string;
278
+ type: 'app' | 'package' | 'config' | 'unknown';
279
+ }>;
280
+ /** AI rules files for agents to read (IMPORTANT!) */
281
+ aiRules?: Array<{
282
+ path: string;
283
+ relativePath: string;
284
+ scope: 'root' | 'package' | 'app';
285
+ }>;
286
+ /** Current branch context */
287
+ branchContext?: {
288
+ name: string;
289
+ type: 'feature' | 'fix' | 'chore' | 'release' | 'hotfix' | 'main' | 'develop' | 'unknown';
290
+ issueNumber?: number;
291
+ description?: string;
292
+ };
293
+ }
294
+
295
+ /**
296
+ * @module lib/fs
297
+ * @description File system utilities
298
+ */
299
+ /**
300
+ * Options for file finding
301
+ */
302
+ interface FindFilesOptions {
303
+ /** File extensions to include (e.g., ['.ts', '.tsx']) */
304
+ extensions?: string[];
305
+ /** Directories to skip */
306
+ skipDirs?: string[];
307
+ /** Maximum depth to traverse */
308
+ maxDepth?: number;
309
+ }
310
+ /**
311
+ * Read file contents as string
312
+ */
313
+ declare function readFile(filePath: string): string | null;
314
+ /**
315
+ * Write content to file
316
+ */
317
+ declare function writeFile(filePath: string, content: string): boolean;
318
+ /**
319
+ * Find files recursively matching criteria
320
+ */
321
+ declare function findFiles(dir: string, options?: FindFilesOptions): string[];
322
+
323
+ /**
324
+ * @module lib/@git/local
325
+ * @description Git operations for local project repository
326
+ */
327
+ /**
328
+ * Git status information
329
+ */
330
+ interface GitStatus {
331
+ /** Files with modifications */
332
+ modified: string[];
333
+ /** Untracked files */
334
+ untracked: string[];
335
+ /** Staged files */
336
+ staged: string[];
337
+ /** Has any changes */
338
+ hasChanges: boolean;
339
+ }
340
+ /**
341
+ * Check if current directory is a git repository
342
+ */
343
+ declare function isGitRepo(cwd?: string): boolean;
344
+ /**
345
+ * Get current branch name
346
+ */
347
+ declare function getCurrentBranch(cwd?: string): string | null;
348
+ /**
349
+ * Get git status (modified, untracked, staged files)
350
+ */
351
+ declare function getStatus(cwd?: string): GitStatus;
352
+
353
+ /**
354
+ * @module lib/logger
355
+ * @description Colored console logging with multiple output styles
356
+ */
357
+
358
+ /**
359
+ * Logger options
360
+ */
361
+ interface LoggerOptions {
362
+ /** Minimum log level */
363
+ level?: LogLevel;
364
+ /** Use colors */
365
+ colors?: boolean;
366
+ /** Custom write function (for testing) */
367
+ write?: (message: string) => void;
368
+ }
369
+ /**
370
+ * Create a logger instance
371
+ */
372
+ declare function createLogger(options?: LoggerOptions): Logger;
373
+
374
+ /**
375
+ * @module lib/shell
376
+ * @description Shell command execution utilities
377
+ */
378
+ /**
379
+ * Shell execution options
380
+ */
381
+ interface ShellOptions {
382
+ /** Working directory */
383
+ cwd?: string;
384
+ /** Suppress output */
385
+ silent?: boolean;
386
+ /** Timeout in milliseconds */
387
+ timeout?: number;
388
+ /** Environment variables */
389
+ env?: Record<string, string>;
390
+ }
391
+ /**
392
+ * Shell execution result
393
+ */
394
+ interface ShellResult {
395
+ /** Command succeeded */
396
+ success: boolean;
397
+ /** Command output */
398
+ output: string;
399
+ /** Error message if failed */
400
+ error?: string;
401
+ }
402
+ /**
403
+ * Execute a shell command and return trimmed output
404
+ *
405
+ * @throws Error if command fails
406
+ */
407
+ declare function exec(command: string, options?: ShellOptions): string;
408
+ /**
409
+ * Execute a shell command and return result object (never throws)
410
+ */
411
+ declare function tryExec(command: string, options?: ShellOptions): ShellResult;
412
+ /**
413
+ * Execute a shell command and return lines array
414
+ */
415
+ declare function execLines(command: string, options?: ShellOptions): string[];
416
+
417
+ export { type CommandContext, type CommandResult, type Logger, ResolvedConfig, type ReviewResult, type RoutesResult, type SchemaResult, type StatusResult, createLogger, exec, execLines, findFiles, getCurrentBranch, getStatus, isGitRepo, readFile, tryExec, writeFile };
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export { createLogger, defineConfig, exec, execLines, findFiles, getConfig, getCurrentBranch, getStatus, isGitRepo, loadConfig, readFile, tryExec, writeFile } from './chunk-DTDOBWO6.js';
2
+ //# sourceMappingURL=index.js.map
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
@@ -0,0 +1,157 @@
1
+ /**
2
+ * @module types/config
3
+ * @description Configuration type definitions
4
+ */
5
+ /**
6
+ * Path configuration for project directories
7
+ */
8
+ interface PathConfig {
9
+ /** Web application directory (e.g., 'apps/web', 'src') */
10
+ web?: string;
11
+ /** API/backend directory (e.g., 'packages/api', 'server') */
12
+ api?: string;
13
+ /** Database/ORM directory (e.g., 'packages/db', 'prisma') */
14
+ db?: string;
15
+ /** Shared packages directory */
16
+ shared?: string;
17
+ /** Components directory */
18
+ components?: string;
19
+ /** Hooks directory */
20
+ hooks?: string;
21
+ /** Library/utilities directory */
22
+ lib?: string;
23
+ }
24
+ /**
25
+ * Feature flags for project capabilities
26
+ */
27
+ interface FeatureConfig {
28
+ /** Project uses Prisma ORM */
29
+ prisma?: boolean;
30
+ /** Project uses tRPC */
31
+ trpc?: boolean;
32
+ /** Project uses Next.js */
33
+ nextjs?: boolean;
34
+ /** Project uses React */
35
+ react?: boolean;
36
+ /** Project is a monorepo */
37
+ monorepo?: boolean;
38
+ /** Project uses TypeScript */
39
+ typescript?: boolean;
40
+ }
41
+ /**
42
+ * Prisma-specific configuration
43
+ */
44
+ interface PrismaConfig {
45
+ /** Path to Prisma schema directory or file */
46
+ schemaDir?: string;
47
+ /** Path to migrations directory */
48
+ migrationsDir?: string;
49
+ }
50
+ /**
51
+ * tRPC-specific configuration
52
+ */
53
+ interface TrpcConfig {
54
+ /** Path to routers directory */
55
+ routersDir?: string;
56
+ /** Path to main router file */
57
+ appRouter?: string;
58
+ }
59
+ /**
60
+ * Template configuration for code generation
61
+ */
62
+ interface TemplateConfig {
63
+ /** Path to hook template */
64
+ hook?: string;
65
+ /** Path to component template */
66
+ component?: string;
67
+ /** Path to test template */
68
+ test?: string;
69
+ /** Path to schema template */
70
+ schema?: string;
71
+ }
72
+ /**
73
+ * Domain configuration for context filtering
74
+ */
75
+ interface DomainConfig {
76
+ /** Primary keywords that get highest priority in filtering */
77
+ primary: string[];
78
+ /** Secondary keywords for broader matching */
79
+ secondary?: string[];
80
+ /** File patterns related to this domain (glob) */
81
+ files?: string[];
82
+ /** Suggested approach steps */
83
+ approach?: string[];
84
+ /** Context hints for AI */
85
+ hints?: Record<string, string>;
86
+ }
87
+ /**
88
+ * Main project configuration
89
+ */
90
+ interface KrolikConfig {
91
+ /** Project name (for display purposes) */
92
+ name?: string;
93
+ /** Project root directory (auto-detected if not set) */
94
+ projectRoot?: string;
95
+ /** Path configurations */
96
+ paths?: PathConfig;
97
+ /** Feature flags */
98
+ features?: FeatureConfig;
99
+ /** Prisma configuration */
100
+ prisma?: PrismaConfig;
101
+ /** tRPC configuration */
102
+ trpc?: TrpcConfig;
103
+ /** Template paths */
104
+ templates?: TemplateConfig;
105
+ /** Custom domain definitions for context filtering */
106
+ domains?: Record<string, DomainConfig>;
107
+ /** Directories to exclude from analysis */
108
+ exclude?: string[];
109
+ /** Custom extensions to include */
110
+ extensions?: string[];
111
+ }
112
+ /** @deprecated Use KrolikConfig instead */
113
+ type RabbitConfig = KrolikConfig;
114
+ /**
115
+ * Resolved configuration with all defaults applied
116
+ * Note: domains remains optional as it's project-specific configuration
117
+ */
118
+ interface ResolvedConfig extends Omit<Required<KrolikConfig>, 'domains'> {
119
+ paths: Required<PathConfig>;
120
+ features: Required<FeatureConfig>;
121
+ prisma: Required<PrismaConfig>;
122
+ trpc: Required<TrpcConfig>;
123
+ templates: Required<TemplateConfig>;
124
+ domains?: Record<string, DomainConfig>;
125
+ }
126
+
127
+ /**
128
+ * @module config/loader
129
+ * @description Configuration loading and resolution
130
+ */
131
+
132
+ /**
133
+ * Find project root by looking for package.json
134
+ */
135
+ declare function findProjectRoot(startDir?: string): string;
136
+ /**
137
+ * Load and resolve configuration
138
+ */
139
+ declare function loadConfig(options?: {
140
+ configPath?: string;
141
+ projectRoot?: string;
142
+ noCache?: boolean;
143
+ }): Promise<ResolvedConfig>;
144
+ /**
145
+ * Get config synchronously (must have been loaded first)
146
+ */
147
+ declare function getConfig(): ResolvedConfig;
148
+ /**
149
+ * Clear config cache
150
+ */
151
+ declare function clearConfigCache(): void;
152
+ /**
153
+ * Helper to define config with type checking
154
+ */
155
+ declare function defineConfig(config: KrolikConfig): KrolikConfig;
156
+
157
+ export { type FeatureConfig as F, type KrolikConfig as K, type PathConfig as P, type ResolvedConfig as R, type TemplateConfig as T, type PrismaConfig as a, type RabbitConfig as b, type TrpcConfig as c, defineConfig as d, clearConfigCache as e, findProjectRoot as f, getConfig as g, loadConfig as l };
package/package.json ADDED
@@ -0,0 +1,118 @@
1
+ {
2
+ "name": "@anatolykoptev/krolik-cli",
3
+ "version": "0.1.0",
4
+ "description": "KROLIK — fast AI-assisted development toolkit for TypeScript projects",
5
+ "keywords": [
6
+ "cli",
7
+ "ai",
8
+ "developer-tools",
9
+ "typescript",
10
+ "code-review",
11
+ "prisma",
12
+ "trpc",
13
+ "nextjs",
14
+ "krolik"
15
+ ],
16
+ "author": "Anatoly Koptev",
17
+ "license": "MIT",
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "https://github.com/anatolykoptev/krolik-cli.git"
21
+ },
22
+ "homepage": "https://github.com/anatolykoptev/krolik-cli#readme",
23
+ "bugs": {
24
+ "url": "https://github.com/anatolykoptev/krolik-cli/issues"
25
+ },
26
+ "type": "module",
27
+ "exports": {
28
+ ".": {
29
+ "types": "./dist/index.d.ts",
30
+ "import": "./dist/index.js"
31
+ },
32
+ "./config": {
33
+ "types": "./dist/config/index.d.ts",
34
+ "import": "./dist/config/index.js"
35
+ }
36
+ },
37
+ "main": "./dist/index.js",
38
+ "types": "./dist/index.d.ts",
39
+ "bin": {
40
+ "krolik": "./dist/bin/cli.js"
41
+ },
42
+ "files": [
43
+ "dist",
44
+ "templates",
45
+ "README.md",
46
+ "LICENSE"
47
+ ],
48
+ "scripts": {
49
+ "dev": "tsx watch src/bin/cli.ts",
50
+ "build": "pnpm sync-version && tsup",
51
+ "typecheck": "tsc --noEmit",
52
+ "lint": "biome lint .",
53
+ "lint:fix": "biome lint --write .",
54
+ "format": "biome format --write .",
55
+ "check": "biome check .",
56
+ "check:fix": "biome check --write .",
57
+ "test": "vitest",
58
+ "test:run": "vitest run",
59
+ "test:coverage": "vitest run --coverage",
60
+ "sync-version": "tsx scripts/sync-version.ts",
61
+ "changeset": "changeset",
62
+ "changeset:version": "changeset version && pnpm sync-version",
63
+ "changeset:publish": "pnpm build && changeset publish",
64
+ "prepublishOnly": "pnpm build",
65
+ "prepare": "husky"
66
+ },
67
+ "dependencies": {
68
+ "@typescript-eslint/parser": "^8.50.0",
69
+ "better-sqlite3": "^12.5.0",
70
+ "chalk": "^5.4.1",
71
+ "commander": "^13.1.0",
72
+ "cosmiconfig": "^9.0.0",
73
+ "glob": "^13.0.0",
74
+ "jscodeshift": "^17.3.0",
75
+ "ora": "^8.2.0",
76
+ "prettier": "^3.7.4",
77
+ "ts-morph": "^27.0.2",
78
+ "zod": "^3.24.4"
79
+ },
80
+ "devDependencies": {
81
+ "@biomejs/biome": "^2.0.0",
82
+ "@changesets/changelog-github": "^0.5.2",
83
+ "@changesets/cli": "^2.29.8",
84
+ "@swc/core": "^1.15.7",
85
+ "@swc/core-darwin-arm64": "^1.15.7",
86
+ "@types/better-sqlite3": "^7.6.13",
87
+ "@types/node": "^22.15.0",
88
+ "husky": "^9.1.7",
89
+ "lint-staged": "^16.2.7",
90
+ "tsup": "^8.5.0",
91
+ "tsx": "^4.20.0",
92
+ "typescript": "^5.9.3",
93
+ "vitest": "^4.0.0"
94
+ },
95
+ "peerDependencies": {
96
+ "typescript": ">=5.0.0"
97
+ },
98
+ "engines": {
99
+ "node": ">=20.0.0"
100
+ },
101
+ "publishConfig": {
102
+ "registry": "https://npm.pkg.github.com"
103
+ },
104
+ "packageManager": "pnpm@10.0.0",
105
+ "lint-staged": {
106
+ "*.{ts,tsx}": [
107
+ "biome check --write --no-errors-on-unmatched"
108
+ ],
109
+ "*.{json,md,yml,yaml}": [
110
+ "biome format --write --no-errors-on-unmatched"
111
+ ]
112
+ },
113
+ "pnpm": {
114
+ "onlyBuiltDependencies": [
115
+ "better-sqlite3"
116
+ ]
117
+ }
118
+ }