@agiflowai/aicode-utils 0.4.1 → 0.6.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/dist/index.d.cts CHANGED
@@ -1,23 +1,100 @@
1
- //#region src/types/index.d.ts
1
+ import pino from "pino";
2
+
3
+ //#region src/constants/projectType.d.ts
2
4
  /**
3
- * @agiflowai/aicode-utils - Type Definitions
4
- *
5
- * DESIGN PATTERNS:
6
- * - Interface segregation: Keep interfaces focused and minimal
7
- * - Type composition: Build complex types from simple primitives
8
- * - Generics: Use type parameters for reusable, type-safe abstractions
9
- *
10
- * CODING STANDARDS:
11
- * - Use PascalCase for type/interface names
12
- * - Prefix interfaces with 'I' only for abstract contracts
13
- * - Document complex types with JSDoc comments
14
- * - Export all public types
5
+ * Project type constants
6
+ */
7
+ declare const ProjectType: {
8
+ readonly MONOLITH: "monolith";
9
+ readonly MONOREPO: "monorepo";
10
+ };
11
+ type ProjectType = (typeof ProjectType)[keyof typeof ProjectType];
12
+ /**
13
+ * Config source constants
14
+ */
15
+ declare const ConfigSource: {
16
+ readonly PROJECT_JSON: "project.json";
17
+ readonly TOOLKIT_YAML: "toolkit.yaml";
18
+ };
19
+ type ConfigSource = (typeof ConfigSource)[keyof typeof ConfigSource];
20
+ //#endregion
21
+ //#region src/types/projectConfig.d.ts
22
+ /**
23
+ * Result of project config resolution
24
+ */
25
+ interface ProjectConfigResult {
26
+ type: ProjectType;
27
+ sourceTemplate: string;
28
+ configSource: ConfigSource;
29
+ workspaceRoot?: string;
30
+ }
31
+ /**
32
+ * Nx project.json configuration
33
+ */
34
+ interface NxProjectJson {
35
+ name: string;
36
+ $schema?: string;
37
+ sourceRoot?: string;
38
+ projectType?: 'application' | 'library';
39
+ sourceTemplate?: string;
40
+ targets?: Record<string, unknown>;
41
+ tags?: string[];
42
+ [key: string]: unknown;
43
+ }
44
+ //#endregion
45
+ //#region src/services/ProjectConfigResolver.d.ts
46
+ /**
47
+ * ProjectConfigResolver
15
48
  *
16
- * AVOID:
17
- * - Any type unless absolutely necessary
18
- * - Overly complex type gymnastics
19
- * - Coupling types to implementation details
49
+ * Resolves project configuration from multiple sources with priority:
50
+ * 1. project.json (monorepo - Nx/Lerna/Turborepo)
51
+ * 2. toolkit.yaml at workspace root (monolith)
20
52
  */
53
+ declare class ProjectConfigResolver {
54
+ /**
55
+ * Resolve project configuration with priority fallback
56
+ *
57
+ * Priority order:
58
+ * 1. Check for project.json (monorepo case)
59
+ * 2. Check for toolkit.yaml at workspace root (monolith case)
60
+ * 3. Error with helpful message
61
+ *
62
+ * @param projectPath - Absolute path to the project directory
63
+ * @param explicitTemplate - Optional explicit template override
64
+ * @returns Project configuration result
65
+ * @throws Error if no configuration found
66
+ */
67
+ static resolveProjectConfig(projectPath: string, explicitTemplate?: string): Promise<ProjectConfigResult>;
68
+ /**
69
+ * Get helpful error message when no configuration is found
70
+ */
71
+ private static getHelpfulErrorMessage;
72
+ /**
73
+ * Check if project has configuration (without throwing error)
74
+ *
75
+ * @param projectPath - Absolute path to the project directory
76
+ * @returns true if configuration exists, false otherwise
77
+ * @throws Error if there's a filesystem error (not just missing config)
78
+ */
79
+ static hasConfiguration(projectPath: string): Promise<boolean>;
80
+ /**
81
+ * Create toolkit.yaml for monolith projects
82
+ *
83
+ * @param sourceTemplate - The template identifier
84
+ * @param workspaceRoot - Optional workspace root path (defaults to current directory)
85
+ */
86
+ static createToolkitYaml(sourceTemplate: string, workspaceRoot?: string): Promise<void>;
87
+ /**
88
+ * Create or update project.json for monorepo projects
89
+ *
90
+ * @param projectPath - Absolute path to the project directory
91
+ * @param projectName - Name of the project
92
+ * @param sourceTemplate - The template identifier
93
+ */
94
+ static createProjectJson(projectPath: string, projectName: string, sourceTemplate: string): Promise<void>;
95
+ }
96
+ //#endregion
97
+ //#region src/types/index.d.ts
21
98
  /**
22
99
  * Project configuration from project.json
23
100
  */
@@ -185,6 +262,12 @@ declare class ScaffoldProcessingService {
185
262
  * - Direct coupling to other services (use dependency injection)
186
263
  * - Exposing internal implementation details
187
264
  */
265
+ interface ToolkitConfig {
266
+ version?: string;
267
+ templatesPath?: string;
268
+ projectType?: 'monolith' | 'monorepo';
269
+ sourceTemplate?: string;
270
+ }
188
271
  declare class TemplatesManagerService {
189
272
  private static SCAFFOLD_CONFIG_FILE;
190
273
  private static TEMPLATES_FOLDER;
@@ -237,6 +320,173 @@ declare class TemplatesManagerService {
237
320
  * Get the templates folder name
238
321
  */
239
322
  static getTemplatesFolderName(): string;
323
+ /**
324
+ * Read toolkit.yaml configuration from workspace root
325
+ *
326
+ * @param startPath - The path to start searching from (defaults to process.cwd())
327
+ * @returns The toolkit configuration object or null if not found
328
+ */
329
+ static readToolkitConfig(startPath?: string): Promise<ToolkitConfig | null>;
330
+ /**
331
+ * Read toolkit.yaml configuration from workspace root (sync)
332
+ *
333
+ * @param startPath - The path to start searching from (defaults to process.cwd())
334
+ * @returns The toolkit configuration object or null if not found
335
+ */
336
+ static readToolkitConfigSync(startPath?: string): ToolkitConfig | null;
337
+ /**
338
+ * Write toolkit.yaml configuration to workspace root
339
+ *
340
+ * @param config - The toolkit configuration to write
341
+ * @param startPath - The path to start searching from (defaults to process.cwd())
342
+ */
343
+ static writeToolkitConfig(config: ToolkitConfig, startPath?: string): Promise<void>;
344
+ /**
345
+ * Get the workspace root directory
346
+ *
347
+ * @param startPath - The path to start searching from (defaults to process.cwd())
348
+ * @returns The workspace root directory path
349
+ */
350
+ static getWorkspaceRoot(startPath?: string): Promise<string>;
351
+ /**
352
+ * Get the workspace root directory (sync)
353
+ *
354
+ * @param startPath - The path to start searching from (defaults to process.cwd())
355
+ * @returns The workspace root directory path
356
+ */
357
+ static getWorkspaceRootSync(startPath?: string): string;
240
358
  }
241
359
  //#endregion
242
- export { GeneratorContext, GeneratorFunction, IFileSystemService, IVariableReplacementService, ParsedInclude, ProjectConfig, ProjectFinderService, ScaffoldProcessingService, ScaffoldResult, TemplatesManagerService };
360
+ //#region src/utils/logger.d.ts
361
+ declare const logger: pino.Logger<never, boolean>;
362
+ declare const log: {
363
+ debug: (msg: string, ...args: any[]) => void;
364
+ info: (msg: string, ...args: any[]) => void;
365
+ warn: (msg: string, ...args: any[]) => void;
366
+ error: (msg: string, ...args: any[]) => void;
367
+ };
368
+ //#endregion
369
+ //#region src/utils/print.d.ts
370
+ /**
371
+ * Themed console utilities for consistent CLI output
372
+ */
373
+ declare const print: {
374
+ /**
375
+ * Log info message (cyan)
376
+ */
377
+ info: (message: string) => void;
378
+ /**
379
+ * Log success message (green)
380
+ */
381
+ success: (message: string) => void;
382
+ /**
383
+ * Log warning message (yellow)
384
+ */
385
+ warning: (message: string) => void;
386
+ /**
387
+ * Log error message (red)
388
+ */
389
+ error: (message: string, error?: Error | string) => void;
390
+ /**
391
+ * Log debug message (gray)
392
+ */
393
+ debug: (message: string) => void;
394
+ /**
395
+ * Log section header (bold cyan)
396
+ */
397
+ header: (message: string) => void;
398
+ /**
399
+ * Log item in a list (gray with prefix)
400
+ */
401
+ item: (message: string) => void;
402
+ /**
403
+ * Log indented text (gray)
404
+ */
405
+ indent: (message: string) => void;
406
+ /**
407
+ * Log highlighted text (bold green)
408
+ */
409
+ highlight: (message: string) => void;
410
+ /**
411
+ * Empty line
412
+ */
413
+ newline: () => void;
414
+ };
415
+ /**
416
+ * Emoji icons for consistent visual markers
417
+ */
418
+ declare const icons: {
419
+ rocket: string;
420
+ check: string;
421
+ cross: string;
422
+ warning: string;
423
+ info: string;
424
+ package: string;
425
+ folder: string;
426
+ file: string;
427
+ config: string;
428
+ wrench: string;
429
+ chart: string;
430
+ bulb: string;
431
+ download: string;
432
+ upload: string;
433
+ gear: string;
434
+ clipboard: string;
435
+ skip: string;
436
+ };
437
+ /**
438
+ * Themed message helpers
439
+ */
440
+ declare const messages: {
441
+ /**
442
+ * Display an info message with icon
443
+ */
444
+ info: (message: string) => void;
445
+ /**
446
+ * Display a success message with icon
447
+ */
448
+ success: (message: string) => void;
449
+ /**
450
+ * Display an error message with icon
451
+ */
452
+ error: (message: string, error?: Error | string) => void;
453
+ /**
454
+ * Display a warning message with icon
455
+ */
456
+ warning: (message: string) => void;
457
+ /**
458
+ * Display a hint/tip message with icon
459
+ */
460
+ hint: (message: string) => void;
461
+ /**
462
+ * Display a loading/processing message with icon
463
+ */
464
+ loading: (message: string) => void;
465
+ };
466
+ /**
467
+ * Section formatters
468
+ */
469
+ declare const sections: {
470
+ /**
471
+ * Print a header section
472
+ */
473
+ header: (title: string) => void;
474
+ /**
475
+ * Print a list section with title
476
+ */
477
+ list: (title: string, items: string[]) => void;
478
+ /**
479
+ * Print next steps section
480
+ */
481
+ nextSteps: (steps: string[]) => void;
482
+ /**
483
+ * Print created files section
484
+ */
485
+ createdFiles: (files: string[], maxShow?: number) => void;
486
+ /**
487
+ * Print warnings section
488
+ */
489
+ warnings: (warnings: string[]) => void;
490
+ };
491
+ //#endregion
492
+ export { ConfigSource, GeneratorContext, GeneratorFunction, IFileSystemService, IVariableReplacementService, NxProjectJson, ParsedInclude, ProjectConfig, ProjectConfigResolver, ProjectConfigResult, ProjectFinderService, ProjectType, ScaffoldProcessingService, ScaffoldResult, TemplatesManagerService, ToolkitConfig, icons, log, logger, messages, print, sections };
package/dist/index.d.ts CHANGED
@@ -1,23 +1,100 @@
1
- //#region src/types/index.d.ts
1
+ import pino from "pino";
2
+
3
+ //#region src/constants/projectType.d.ts
2
4
  /**
3
- * @agiflowai/aicode-utils - Type Definitions
4
- *
5
- * DESIGN PATTERNS:
6
- * - Interface segregation: Keep interfaces focused and minimal
7
- * - Type composition: Build complex types from simple primitives
8
- * - Generics: Use type parameters for reusable, type-safe abstractions
9
- *
10
- * CODING STANDARDS:
11
- * - Use PascalCase for type/interface names
12
- * - Prefix interfaces with 'I' only for abstract contracts
13
- * - Document complex types with JSDoc comments
14
- * - Export all public types
5
+ * Project type constants
6
+ */
7
+ declare const ProjectType: {
8
+ readonly MONOLITH: "monolith";
9
+ readonly MONOREPO: "monorepo";
10
+ };
11
+ type ProjectType = (typeof ProjectType)[keyof typeof ProjectType];
12
+ /**
13
+ * Config source constants
14
+ */
15
+ declare const ConfigSource: {
16
+ readonly PROJECT_JSON: "project.json";
17
+ readonly TOOLKIT_YAML: "toolkit.yaml";
18
+ };
19
+ type ConfigSource = (typeof ConfigSource)[keyof typeof ConfigSource];
20
+ //#endregion
21
+ //#region src/types/projectConfig.d.ts
22
+ /**
23
+ * Result of project config resolution
24
+ */
25
+ interface ProjectConfigResult {
26
+ type: ProjectType;
27
+ sourceTemplate: string;
28
+ configSource: ConfigSource;
29
+ workspaceRoot?: string;
30
+ }
31
+ /**
32
+ * Nx project.json configuration
33
+ */
34
+ interface NxProjectJson {
35
+ name: string;
36
+ $schema?: string;
37
+ sourceRoot?: string;
38
+ projectType?: 'application' | 'library';
39
+ sourceTemplate?: string;
40
+ targets?: Record<string, unknown>;
41
+ tags?: string[];
42
+ [key: string]: unknown;
43
+ }
44
+ //#endregion
45
+ //#region src/services/ProjectConfigResolver.d.ts
46
+ /**
47
+ * ProjectConfigResolver
15
48
  *
16
- * AVOID:
17
- * - Any type unless absolutely necessary
18
- * - Overly complex type gymnastics
19
- * - Coupling types to implementation details
49
+ * Resolves project configuration from multiple sources with priority:
50
+ * 1. project.json (monorepo - Nx/Lerna/Turborepo)
51
+ * 2. toolkit.yaml at workspace root (monolith)
20
52
  */
53
+ declare class ProjectConfigResolver {
54
+ /**
55
+ * Resolve project configuration with priority fallback
56
+ *
57
+ * Priority order:
58
+ * 1. Check for project.json (monorepo case)
59
+ * 2. Check for toolkit.yaml at workspace root (monolith case)
60
+ * 3. Error with helpful message
61
+ *
62
+ * @param projectPath - Absolute path to the project directory
63
+ * @param explicitTemplate - Optional explicit template override
64
+ * @returns Project configuration result
65
+ * @throws Error if no configuration found
66
+ */
67
+ static resolveProjectConfig(projectPath: string, explicitTemplate?: string): Promise<ProjectConfigResult>;
68
+ /**
69
+ * Get helpful error message when no configuration is found
70
+ */
71
+ private static getHelpfulErrorMessage;
72
+ /**
73
+ * Check if project has configuration (without throwing error)
74
+ *
75
+ * @param projectPath - Absolute path to the project directory
76
+ * @returns true if configuration exists, false otherwise
77
+ * @throws Error if there's a filesystem error (not just missing config)
78
+ */
79
+ static hasConfiguration(projectPath: string): Promise<boolean>;
80
+ /**
81
+ * Create toolkit.yaml for monolith projects
82
+ *
83
+ * @param sourceTemplate - The template identifier
84
+ * @param workspaceRoot - Optional workspace root path (defaults to current directory)
85
+ */
86
+ static createToolkitYaml(sourceTemplate: string, workspaceRoot?: string): Promise<void>;
87
+ /**
88
+ * Create or update project.json for monorepo projects
89
+ *
90
+ * @param projectPath - Absolute path to the project directory
91
+ * @param projectName - Name of the project
92
+ * @param sourceTemplate - The template identifier
93
+ */
94
+ static createProjectJson(projectPath: string, projectName: string, sourceTemplate: string): Promise<void>;
95
+ }
96
+ //#endregion
97
+ //#region src/types/index.d.ts
21
98
  /**
22
99
  * Project configuration from project.json
23
100
  */
@@ -185,6 +262,12 @@ declare class ScaffoldProcessingService {
185
262
  * - Direct coupling to other services (use dependency injection)
186
263
  * - Exposing internal implementation details
187
264
  */
265
+ interface ToolkitConfig {
266
+ version?: string;
267
+ templatesPath?: string;
268
+ projectType?: 'monolith' | 'monorepo';
269
+ sourceTemplate?: string;
270
+ }
188
271
  declare class TemplatesManagerService {
189
272
  private static SCAFFOLD_CONFIG_FILE;
190
273
  private static TEMPLATES_FOLDER;
@@ -237,6 +320,173 @@ declare class TemplatesManagerService {
237
320
  * Get the templates folder name
238
321
  */
239
322
  static getTemplatesFolderName(): string;
323
+ /**
324
+ * Read toolkit.yaml configuration from workspace root
325
+ *
326
+ * @param startPath - The path to start searching from (defaults to process.cwd())
327
+ * @returns The toolkit configuration object or null if not found
328
+ */
329
+ static readToolkitConfig(startPath?: string): Promise<ToolkitConfig | null>;
330
+ /**
331
+ * Read toolkit.yaml configuration from workspace root (sync)
332
+ *
333
+ * @param startPath - The path to start searching from (defaults to process.cwd())
334
+ * @returns The toolkit configuration object or null if not found
335
+ */
336
+ static readToolkitConfigSync(startPath?: string): ToolkitConfig | null;
337
+ /**
338
+ * Write toolkit.yaml configuration to workspace root
339
+ *
340
+ * @param config - The toolkit configuration to write
341
+ * @param startPath - The path to start searching from (defaults to process.cwd())
342
+ */
343
+ static writeToolkitConfig(config: ToolkitConfig, startPath?: string): Promise<void>;
344
+ /**
345
+ * Get the workspace root directory
346
+ *
347
+ * @param startPath - The path to start searching from (defaults to process.cwd())
348
+ * @returns The workspace root directory path
349
+ */
350
+ static getWorkspaceRoot(startPath?: string): Promise<string>;
351
+ /**
352
+ * Get the workspace root directory (sync)
353
+ *
354
+ * @param startPath - The path to start searching from (defaults to process.cwd())
355
+ * @returns The workspace root directory path
356
+ */
357
+ static getWorkspaceRootSync(startPath?: string): string;
240
358
  }
241
359
  //#endregion
242
- export { GeneratorContext, GeneratorFunction, IFileSystemService, IVariableReplacementService, ParsedInclude, ProjectConfig, ProjectFinderService, ScaffoldProcessingService, ScaffoldResult, TemplatesManagerService };
360
+ //#region src/utils/logger.d.ts
361
+ declare const logger: pino.Logger<never, boolean>;
362
+ declare const log: {
363
+ debug: (msg: string, ...args: any[]) => void;
364
+ info: (msg: string, ...args: any[]) => void;
365
+ warn: (msg: string, ...args: any[]) => void;
366
+ error: (msg: string, ...args: any[]) => void;
367
+ };
368
+ //#endregion
369
+ //#region src/utils/print.d.ts
370
+ /**
371
+ * Themed console utilities for consistent CLI output
372
+ */
373
+ declare const print: {
374
+ /**
375
+ * Log info message (cyan)
376
+ */
377
+ info: (message: string) => void;
378
+ /**
379
+ * Log success message (green)
380
+ */
381
+ success: (message: string) => void;
382
+ /**
383
+ * Log warning message (yellow)
384
+ */
385
+ warning: (message: string) => void;
386
+ /**
387
+ * Log error message (red)
388
+ */
389
+ error: (message: string, error?: Error | string) => void;
390
+ /**
391
+ * Log debug message (gray)
392
+ */
393
+ debug: (message: string) => void;
394
+ /**
395
+ * Log section header (bold cyan)
396
+ */
397
+ header: (message: string) => void;
398
+ /**
399
+ * Log item in a list (gray with prefix)
400
+ */
401
+ item: (message: string) => void;
402
+ /**
403
+ * Log indented text (gray)
404
+ */
405
+ indent: (message: string) => void;
406
+ /**
407
+ * Log highlighted text (bold green)
408
+ */
409
+ highlight: (message: string) => void;
410
+ /**
411
+ * Empty line
412
+ */
413
+ newline: () => void;
414
+ };
415
+ /**
416
+ * Emoji icons for consistent visual markers
417
+ */
418
+ declare const icons: {
419
+ rocket: string;
420
+ check: string;
421
+ cross: string;
422
+ warning: string;
423
+ info: string;
424
+ package: string;
425
+ folder: string;
426
+ file: string;
427
+ config: string;
428
+ wrench: string;
429
+ chart: string;
430
+ bulb: string;
431
+ download: string;
432
+ upload: string;
433
+ gear: string;
434
+ clipboard: string;
435
+ skip: string;
436
+ };
437
+ /**
438
+ * Themed message helpers
439
+ */
440
+ declare const messages: {
441
+ /**
442
+ * Display an info message with icon
443
+ */
444
+ info: (message: string) => void;
445
+ /**
446
+ * Display a success message with icon
447
+ */
448
+ success: (message: string) => void;
449
+ /**
450
+ * Display an error message with icon
451
+ */
452
+ error: (message: string, error?: Error | string) => void;
453
+ /**
454
+ * Display a warning message with icon
455
+ */
456
+ warning: (message: string) => void;
457
+ /**
458
+ * Display a hint/tip message with icon
459
+ */
460
+ hint: (message: string) => void;
461
+ /**
462
+ * Display a loading/processing message with icon
463
+ */
464
+ loading: (message: string) => void;
465
+ };
466
+ /**
467
+ * Section formatters
468
+ */
469
+ declare const sections: {
470
+ /**
471
+ * Print a header section
472
+ */
473
+ header: (title: string) => void;
474
+ /**
475
+ * Print a list section with title
476
+ */
477
+ list: (title: string, items: string[]) => void;
478
+ /**
479
+ * Print next steps section
480
+ */
481
+ nextSteps: (steps: string[]) => void;
482
+ /**
483
+ * Print created files section
484
+ */
485
+ createdFiles: (files: string[], maxShow?: number) => void;
486
+ /**
487
+ * Print warnings section
488
+ */
489
+ warnings: (warnings: string[]) => void;
490
+ };
491
+ //#endregion
492
+ export { ConfigSource, GeneratorContext, GeneratorFunction, IFileSystemService, IVariableReplacementService, NxProjectJson, ParsedInclude, ProjectConfig, ProjectConfigResolver, ProjectConfigResult, ProjectFinderService, ProjectType, ScaffoldProcessingService, ScaffoldResult, TemplatesManagerService, ToolkitConfig, icons, log, logger, messages, print, sections };