@hyperfrontend/project-scope/heuristics/entry-points

entry-points

Entry-point discovery for application source code, combining package.json declarations with conventional file patterns.

discoverEntryPoints reads main, module, browser, bin, and exports fields from package.json, then layers in convention-based candidates (src/index.ts, src/main.ts, src/server.ts, src/cli.ts, etc.). Each candidate is returned with a confidence score, type classification (main, cli, server, library, worker, ...), and the source that produced it (package-json vs convention). Detection is cached for a short TTL; pass { skipCache: true } for fresh results. The patterns themselves are exposed as ENTRY_POINT_PATTERNS for downstream tools that need to extend the heuristic.

API Reference

ƒ Functions

§function

clearEntryPointCache(): void

Clear the entry point discovery cache.
Useful for testing or when the project files have changed.

Example

Clearing the entry point cache

import { clearEntryPointCache } from '@hyperfrontend/project-scope'

// Reset cache before re-analyzing after file changes
clearEntryPointCache()
§function

discoverEntryPoints(projectPath: string, options?: DiscoverEntryPointsOptions): EntryPointInfo[]

Discover entry points in project.
Analyzes package.json fields (main, module, bin, exports), convention-based patterns, and framework-specific entries.
Results are cached for 60 seconds per project path and options to avoid redundant file system operations on repeated calls.

Parameters

NameTypeDescription
§projectPath
string
Project directory path
§options?
DiscoverEntryPointsOptions
Discovery options

Returns

EntryPointInfo[]
Array of discovered entry points sorted by confidence

Example

Discovering project entry points

import { discoverEntryPoints } from '@hyperfrontend/project-scope'

const entryPoints = discoverEntryPoints('./my-app')
for (const entry of entryPoints) {
  console.log(`${entry.path} (${entry.type}) - ${entry.confidence}% confidence`)
}
// Output:
// src/index.ts (main) - 100% confidence
// src/cli.ts (cli) - 85% confidence

Interfaces

§interface

DiscoverEntryPointsOptions

Options for entry point discovery.

Properties

§includeFrameworkEntries?:boolean
Include framework-specific entries (e.g., Next.js pages)
§maxDepth?:number
Maximum depth for file search
§skipCache?:boolean
Skip cache lookup (force fresh detection)
§interface

ExtendedEntryPointInfo

Extended entry point info with source.

Properties

§confidence:number
Detection confidence (0-100)
§path:string
File path
§source:EntryPointSource
How the entry point was discovered
§type:"main" | "app" | "server" | "cli" | "test"
Entry point type

Types

§type

EntryPointSource

Entry point source information. Describes how an entry point was discovered.
type EntryPointSource = PackageJsonEntrySource | ConventionEntrySource | FrameworkEntrySource | ConfigEntrySource
§type

EntryPointType

Supported entry point type enumeration.
type EntryPointType = "main" | "app" | "server" | "cli" | "test"

Variables

§type

ENTRY_POINT_PATTERNS

Common entry point patterns by project type. Used for convention-based entry point discovery.