or run

npx @tessl/cli init
Log in

Version

Files

tile.json

task.mdevals/scenario-2/

Git-Based Package Selector

A command-line tool that selects workspace packages based on Git changes between commits or branches, similar to how pnpm filters packages when using Git diff filtering.

Capabilities

Parse Git diff filtering expressions

  • Parses filter expression [origin/main] to select packages changed since the origin/main branch @test
  • Parses filter expression [HEAD~2] to select packages changed in the last 2 commits @test
  • Parses filter expression [abc123] to select packages changed since commit abc123 @test

Identify changed packages from Git diff

  • Given a workspace with packages A, B, C and changes only in package A, selecting with [HEAD~1] returns only package A @test
  • Given a workspace where files in packages A and B have changed, selecting with [main] returns both packages A and B @test
  • Given a workspace where no packages have changed, selecting with [HEAD~1] returns an empty list @test

Handle edge cases

  • When the specified Git reference does not exist, throws an error with a clear message @test
  • When run outside a Git repository, throws an error indicating Git is required @test

Implementation

@generates

API

/**
 * Represents a workspace package with its location
 */
export interface WorkspacePackage {
  name: string;
  path: string;
}

/**
 * Parses a Git filter expression like [origin/main] or [HEAD~2]
 * and returns the Git reference to compare against.
 *
 * @param filterExpression - The filter expression in format [gitref]
 * @returns The Git reference (e.g., "origin/main", "HEAD~2")
 * @throws Error if the expression format is invalid
 */
export function parseGitFilter(filterExpression: string): string;

/**
 * Gets the list of files that changed between the current state
 * and the specified Git reference.
 *
 * @param gitRef - The Git reference to compare against
 * @returns Array of file paths that have changed
 * @throws Error if Git reference doesn't exist or not in a Git repository
 */
export function getChangedFiles(gitRef: string): Promise<string[]>;

/**
 * Selects workspace packages that have changes based on Git diff.
 *
 * @param packages - Array of workspace packages to filter
 * @param gitRef - The Git reference to compare against
 * @returns Array of packages that contain changed files
 * @throws Error if Git reference doesn't exist or not in a Git repository
 */
export function selectChangedPackages(
  packages: WorkspacePackage[],
  gitRef: string
): Promise<WorkspacePackage[]>;

Dependencies { .dependencies }

pnpm { .dependency }

Provides the Git integration for filtering functionality that this tool is based on.

@satisfied-by