@ooples/token-optimizer-mcp
Version:
Intelligent context window optimization for Claude Code - store content externally via caching and compression, freeing up your context window for what matters
196 lines • 5.18 kB
TypeScript
/**
* Smart Status Tool - 70% Token Reduction
*
* Achieves token reduction through:
* 1. Status-only output (file paths grouped by status, no content)
* 2. Summary mode (counts only, not file lists)
* 3. Filtered output (only specific statuses or file patterns)
* 4. Git-based caching (reuse status results based on git hash)
* 5. Selective detail (get details only for specific files)
*
* Target: 70% reduction vs full git diff output
*/
import { CacheEngine } from '../../core/cache-engine.js';
import { TokenCounter } from '../../core/token-counter.js';
import { MetricsCollector } from '../../core/metrics.js';
export type FileStatus = 'modified' | 'added' | 'deleted' | 'renamed' | 'copied' | 'untracked' | 'ignored' | 'unmerged';
export interface FileStatusInfo {
path: string;
status: FileStatus;
oldPath?: string;
staged: boolean;
size?: number;
diff?: string;
}
export interface SmartStatusOptions {
cwd?: string;
statuses?: FileStatus[];
filePattern?: string;
staged?: boolean;
unstaged?: boolean;
summaryOnly?: boolean;
includeSize?: boolean;
includeDetail?: boolean;
detailFiles?: string[];
includeUntracked?: boolean;
includeIgnored?: boolean;
limit?: number;
offset?: number;
useCache?: boolean;
ttl?: number;
}
export interface SmartStatusResult {
success: boolean;
repository: {
path: string;
branch?: string;
commit?: string;
clean: boolean;
};
metadata: {
totalFiles: number;
returnedCount: number;
truncated: boolean;
tokensSaved: number;
tokenCount: number;
originalTokenCount: number;
compressionRatio: number;
duration: number;
cacheHit: boolean;
};
summary?: {
modified: number;
added: number;
deleted: number;
renamed: number;
copied: number;
untracked: number;
ignored: number;
unmerged: number;
staged: number;
unstaged: number;
};
files?: FileStatusInfo[];
error?: string;
}
export declare class SmartStatusTool {
private cache;
private tokenCounter;
private metrics;
constructor(cache: CacheEngine, tokenCounter: TokenCounter, metrics: MetricsCollector);
/**
* Get git status with grouped file lists and minimal token output
*/
status(options?: SmartStatusOptions): Promise<SmartStatusResult>;
/**
* Check if directory is a git repository
*/
private isGitRepository;
/**
* Get current git commit hash
*/
private getGitHash;
/**
* Get repository information
*/
private getRepositoryInfo;
/**
* Get git status output
*/
private getGitStatus;
/**
* Parse git status porcelain output
*/
private parseGitStatus;
/**
* Parse git status codes
*/
private parseStatusCodes;
/**
* Apply filters to file list
*/
private applyFilters;
/**
* Calculate summary counts
*/
private calculateSummary;
/**
* Get diff for a specific file
*/
private getFileDiff;
/**
* Get status statistics
*/
getStats(): {
totalCalls: number;
cacheHits: number;
totalTokensSaved: number;
averageReduction: number;
};
}
/**
* Get smart status tool instance
*/
export declare function getSmartStatusTool(cache: CacheEngine, tokenCounter: TokenCounter, metrics: MetricsCollector): SmartStatusTool;
/**
* CLI function - Creates resources and uses factory
*/
export declare function runSmartStatus(options?: SmartStatusOptions): Promise<SmartStatusResult>;
/**
* MCP Tool Definition
*/
export declare const SMART_STATUS_TOOL_DEFINITION: {
name: string;
description: string;
inputSchema: {
type: string;
properties: {
cwd: {
type: string;
description: string;
};
statuses: {
type: string;
items: {
type: string;
enum: string[];
};
description: string;
};
filePattern: {
type: string;
description: string;
};
summaryOnly: {
type: string;
description: string;
default: boolean;
};
includeDetail: {
type: string;
description: string;
default: boolean;
};
detailFiles: {
type: string;
items: {
type: string;
};
description: string;
};
staged: {
type: string;
description: string;
};
unstaged: {
type: string;
description: string;
};
limit: {
type: string;
description: string;
};
};
};
};
//# sourceMappingURL=smart-status.d.ts.map