Angular Modernizer
    Preparing search index...

    The Kernel - Core infrastructure manager.

    The Kernel is domain-agnostic: it knows nothing about Angular, components or transformations. All domain logic lives in plugins.

    Responsibilities:

    1. Manage the ts-morph Project instance
    2. Load and initialize plugins
    3. Provide file system abstraction
    4. Act as the central registry for plugins

    Example usage:

    const kernel = new Kernel({
    tsConfigPath: './tsconfig.json',
    plugins: [myPlugin],
    });

    await kernel.initialize();

    const project = kernel.getProject();
    const plugin = kernel.getPlugin('my-plugin');
    Index

    Constructors

    Methods

    • Analyze incrementally.

      Only analyzes changed files and their dependents for faster re-analysis.

      Parameters

      Returns Promise<unknown>

      Promise resolving to incremental analysis result

      Error if Kernel is not initialized

      const result = await kernel.analyzeIncremental({
      baseBranch: 'main',
      includeDependents: true,
      parallel: true
      });
      console.info(`Analyzed ${result.analyzedFiles.length} of ${result.changedFiles.length + result.skippedFiles.length} files`);

      The WorkerPool analysis path is deprecated since 1.1 and will be removed in 2.0; the MCP scans run in a scan worker instead.

    • Analyze with parallel execution.

      Executes analysis rules in parallel across source files for improved performance.

      Parameters

      Returns Promise<unknown[]>

      Promise resolving to analysis results

      Error if Kernel is not initialized or parallel execution is not enabled

      const results = await kernel.analyzeParallel({
      plugins: ['plugin-angular', 'plugin-solid'],
      onProgress: (progress) => console.info(`${progress.percentage}% complete`)
      });

      The WorkerPool analysis path is deprecated since 1.1 and will be removed in 2.0; the MCP scans run in a scan worker instead.

    • Get all registered plugins.

      Returns Plugin[]

      Error if Kernel is not initialized

    • Get the build validator instance. Creates one lazily if it doesn't exist.

      Returns BuildValidator

      BuildValidator instance

      Error if Kernel is not initialized

    • Get the cache manager if enabled. Returns undefined if caching is not configured.

      Returns CacheManager | undefined

      Error if Kernel is not initialized

    • Get the parallel executor if enabled. Returns undefined if parallel execution is not configured.

      Returns ParallelExecutor | undefined

      Error if Kernel is not initialized

    • Get the parser orchestrator instance.

      The parser orchestrator automatically selects the best parser strategy based on project characteristics (external decorators, path aliases, etc.) and provides fallback mechanisms for resilient parsing.

      Returns ParserOrchestrator | undefined

      ParserOrchestrator instance

      Error if Kernel is not initialized

    • Get a plugin by name. Returns undefined if the plugin is not registered.

      Parameters

      • name: string

        The unique name of the plugin

      Returns Plugin | undefined

      Error if Kernel is not initialized

    • Get the ts-morph Project instance. This is the primary way plugins interact with the codebase.

      Returns Project

      Error if Kernel is not initialized

    • Get the cached project context.

      Project context is detected during initialization using ProjectCompatibilityValidator. It contains information about custom decorators, path aliases, complex constructors, and Angular version. This context is used by ParserOrchestrator for parser selection.

      Returns ParserProjectContext | undefined

      ProjectContext detected during initialization

      Error if Kernel is not initialized

    • Get the project root directory.

      Returns path.dirname(tsConfigPath) when tsConfigPath is set, or process.cwd() otherwise. Safe to call before initialize() - reads only from this.config which is set in the constructor.

      Returns string

    • Get the resource manager.

      Returns ResourceManager | undefined

      Error if Kernel is not initialized

    • Check if a plugin is registered.

      Parameters

      • name: string

        The unique name of the plugin

      Returns boolean

      Error if Kernel is not initialized

    • Initialize the Kernel and all plugins. This must be called before using the Kernel.

      Returns Promise<void>

      Error if initialization fails or if already initialized

    • Check if the Kernel is initialized.

      Returns boolean

    • Transform a single source file using all applicable transformation rules.

      This method delegates to the TransformationCoordinator to execute transformation rules from all loaded plugins on the specified file.

      Parameters

      • sourceFile: SourceFile

        The source file to transform

      • config: TransformationConfig = {}

        Transformation configuration

      Returns Promise<TransformationResult>

      Promise resolving to transformation result

      Error if Kernel is not initialized or transformation coordinator is not available

      const result = await kernel.transformFile(sourceFile, {
      dryRun: false,
      autoSave: true
      });