UNPKG

@nanocollective/nanocoder

Version:

A local-first CLI coding agent that brings the power of agentic coding tools like Claude Code and Gemini CLI to local models or controlled APIs like OpenRouter

182 lines 4.45 kB
/** * Git Utilities * * Shared utilities for git operations including command execution, * status parsing, and availability checks. */ /** * File change status from git */ export type FileChangeStatus = 'added' | 'modified' | 'deleted' | 'renamed' | 'copied'; /** * Represents a single file change */ export interface FileChange { path: string; status: FileChangeStatus; oldPath?: string; additions: number; deletions: number; isBinary: boolean; } /** * Commit information */ export interface CommitInfo { hash: string; shortHash: string; author: string; email: string; date: string; relativeDate: string; subject: string; body: string; filesChanged?: number; } /** * Branch information */ export interface BranchInfo { name: string; current: boolean; upstream?: string; ahead: number; behind: number; lastCommit?: string; } /** * Stash entry */ export interface StashEntry { index: number; message: string; branch: string; date: string; } /** * Check if git is available on the system (synchronous) */ export declare function isGitAvailable(): boolean; /** * Check if the current directory is inside a git repository (synchronous) */ export declare function isInsideGitRepo(): boolean; /** * Check if gh CLI is available on the system (synchronous) */ export declare function isGhAvailable(): boolean; /** * Execute a git command and return the output */ export declare function execGit(args: string[]): Promise<string>; /** * Execute a gh CLI command and return the output */ export declare function execGh(args: string[]): Promise<string>; /** * Check if there are uncommitted changes (staged or unstaged) */ export declare function hasUncommittedChanges(): Promise<boolean>; /** * Check if there are staged changes */ export declare function hasStagedChanges(): Promise<boolean>; /** * Check if a rebase is in progress */ export declare function isRebaseInProgress(): Promise<boolean>; /** * Check if a merge is in progress */ export declare function isMergeInProgress(): Promise<boolean>; /** * Get the current branch name */ export declare function getCurrentBranch(): Promise<string>; /** * Get the default branch (main or master) */ export declare function getDefaultBranch(): Promise<string>; /** * Check if a branch exists */ export declare function branchExists(name: string): Promise<boolean>; /** * Get the upstream branch for the current branch */ export declare function getUpstreamBranch(): Promise<string | null>; /** * Get ahead/behind counts relative to upstream */ export declare function getAheadBehind(): Promise<{ ahead: number; behind: number; }>; /** * Get list of local branches */ export declare function getLocalBranches(): Promise<BranchInfo[]>; /** * Get list of remote branches */ export declare function getRemoteBranches(): Promise<string[]>; /** * Get unpushed commits (commits ahead of upstream) */ export declare function getUnpushedCommits(): Promise<CommitInfo[]>; /** * Check if the last commit has been pushed */ export declare function isLastCommitPushed(): Promise<boolean>; /** * Get commits with various filters */ export declare function getCommits(options: { count?: number; range?: string; file?: string; author?: string; since?: string; grep?: string; }): Promise<CommitInfo[]>; /** * Parse git status --porcelain output */ export declare function parseGitStatus(statusOutput: string): { staged: FileChange[]; unstaged: FileChange[]; untracked: string[]; conflicts: string[]; }; /** * Get diff stats for files (additions/deletions) */ export declare function getDiffStats(staged?: boolean): Promise<Map<string, { additions: number; deletions: number; }>>; /** * Get list of stashes */ export declare function getStashList(): Promise<StashEntry[]>; /** * Get stash count */ export declare function getStashCount(): Promise<number>; /** * Check if a remote exists */ export declare function remoteExists(name: string): Promise<boolean>; /** * Truncate diff output if too long */ export declare function truncateDiff(diff: string, maxLines?: number): { content: string; truncated: boolean; totalLines: number; }; /** * Format file status character for display */ export declare function formatStatusChar(status: FileChangeStatus): string; //# sourceMappingURL=utils.d.ts.map