diff --git a/README.md b/README.md index 7287319a0..79f136de6 100644 --- a/README.md +++ b/README.md @@ -264,6 +264,21 @@ When using `--stdin`, the specified files are effectively added to the include p > [!NOTE] > When using `--stdin`, file paths can be relative or absolute, and Repomix will automatically handle path resolution and deduplication. +To include git logs in the output: + +```bash +# Include git logs with default count (50 commits) +repomix --include-logs + +# Include git logs with specific commit count +repomix --include-logs --include-logs-count 10 + +# Combine with diffs for comprehensive git context +repomix --include-logs --include-diffs +``` + +The git logs include commit dates, messages, and file paths for each commit, providing valuable context for AI analysis of code evolution and development patterns. + To compress the output: ```bash @@ -537,6 +552,8 @@ Instruction - `--include-empty-directories`: Include empty directories in the output - `--no-git-sort-by-changes`: Disable sorting files by git change count (enabled by default) - `--include-diffs`: Include git diffs in the output (includes both work tree and staged changes separately) +- `--include-logs`: Include git logs in the output (includes commit history with dates, messages, and file paths) +- `--include-logs-count `: Number of git log commits to include (default: 50) #### File Selection Options - `--include `: List of include patterns (comma-separated) @@ -932,6 +949,8 @@ Here's an explanation of the configuration options: | `output.git.sortByChanges` | Whether to sort files by git change count (files with more changes appear at the bottom) | `true` | | `output.git.sortByChangesMaxCommits` | Maximum number of commits to analyze for git changes | `100` | | `output.git.includeDiffs` | Whether to include git diffs in the output (includes both work tree and staged changes separately) | `false` | +| `output.git.includeLogs` | Whether to include git logs in the output (includes commit history with dates, messages, and file paths) | `false` | +| `output.git.includeLogsCount` | Number of git log commits to include | `50` | | `include` | Patterns of files to include (using [glob patterns](https://github.com/mrmlnc/fast-glob?tab=readme-ov-file#pattern-syntax)) | `[]` | | `ignore.useGitignore` | Whether to use patterns from the project's `.gitignore` file | `true` | | `ignore.useDefaultPatterns` | Whether to use default ignore patterns | `true` | @@ -972,7 +991,9 @@ Example configuration: "git": { "sortByChanges": true, "sortByChangesMaxCommits": 100, - "includeDiffs": false + "includeDiffs": false, + "includeLogs": false, + "includeLogsCount": 50 } }, "include": ["**/*"], diff --git a/repomix.config.json b/repomix.config.json index 1b3cd499e..61147eb44 100644 --- a/repomix.config.json +++ b/repomix.config.json @@ -23,7 +23,9 @@ "git": { "sortByChanges": true, "sortByChangesMaxCommits": 100, - "includeDiffs": true + "includeDiffs": true, + "includeLogs": true, + "includeLogsCount": 50 } }, "include": [], diff --git a/src/cli/actions/defaultAction.ts b/src/cli/actions/defaultAction.ts index 91afe9637..d75ff90a0 100644 --- a/src/cli/actions/defaultAction.ts +++ b/src/cli/actions/defaultAction.ts @@ -289,6 +289,20 @@ export const buildCliConfig = (options: CliOptions): RepomixConfigCli => { }; } + // Configure git logs inclusion and count - consolidating related git log options + if (options.includeLogs || options.includeLogsCount !== undefined) { + const gitLogConfig = { + ...cliConfig.output?.git, + ...(options.includeLogs && { includeLogs: true }), + ...(options.includeLogsCount !== undefined && { includeLogsCount: options.includeLogsCount }), + }; + + cliConfig.output = { + ...cliConfig.output, + git: gitLogConfig, + }; + } + if (options.tokenCountTree !== undefined) { cliConfig.output = { ...cliConfig.output, diff --git a/src/cli/cliReport.ts b/src/cli/cliReport.ts index 47e1b174e..c308e8f73 100644 --- a/src/cli/cliReport.ts +++ b/src/cli/cliReport.ts @@ -27,7 +27,13 @@ export const reportResults = (cwd: string, packResult: PackResult, config: Repom logger.log(''); } - reportSecurityCheck(cwd, packResult.suspiciousFilesResults, packResult.suspiciousGitDiffResults, config); + reportSecurityCheck( + cwd, + packResult.suspiciousFilesResults, + packResult.suspiciousGitDiffResults, + packResult.suspiciousGitLogResults, + config, + ); logger.log(''); reportSummary(packResult, config); @@ -75,6 +81,7 @@ export const reportSecurityCheck = ( rootDir: string, suspiciousFilesResults: SuspiciousFileResult[], suspiciousGitDiffResults: SuspiciousFileResult[], + suspiciousGitLogResults: SuspiciousFileResult[], config: RepomixConfigMerged, ) => { if (!config.security.enableSecurityCheck) { @@ -100,19 +107,26 @@ export const reportSecurityCheck = ( logger.log(pc.yellow('Please review these files for potential sensitive information.')); } - // Report results for git diffs - if (suspiciousGitDiffResults.length > 0) { - logger.log(''); - logger.log(pc.yellow(`${suspiciousGitDiffResults.length} security issue(s) found in Git diffs:`)); - suspiciousGitDiffResults.forEach((suspiciousResult, index) => { - logger.log(`${pc.white(`${index + 1}.`)} ${pc.white(suspiciousResult.filePath)}`); - const issueCount = suspiciousResult.messages.length; - const issueText = issueCount === 1 ? 'security issue' : 'security issues'; - logger.log(pc.dim(` - ${issueCount} ${issueText} detected`)); - }); - logger.log(pc.yellow('\nNote: Git diffs with security issues are still included in the output.')); - logger.log(pc.yellow('Please review the diffs before sharing the output.')); + // Report git-related security issues + reportSuspiciousGitContent('Git diffs', suspiciousGitDiffResults); + reportSuspiciousGitContent('Git logs', suspiciousGitLogResults); +}; + +const reportSuspiciousGitContent = (title: string, results: SuspiciousFileResult[]) => { + if (results.length === 0) { + return; } + + logger.log(''); + logger.log(pc.yellow(`${results.length} security issue(s) found in ${title}:`)); + results.forEach((suspiciousResult, index) => { + logger.log(`${pc.white(`${index + 1}.`)} ${pc.white(suspiciousResult.filePath)}`); + const issueCount = suspiciousResult.messages.length; + const issueText = issueCount === 1 ? 'security issue' : 'security issues'; + logger.log(pc.dim(` - ${issueCount} ${issueText} detected`)); + }); + logger.log(pc.yellow(`\nNote: ${title} with security issues are still included in the output.`)); + logger.log(pc.yellow(`Please review the ${title.toLowerCase()} before sharing the output.`)); }; export const reportTopFiles = ( diff --git a/src/cli/cliRun.ts b/src/cli/cliRun.ts index c99285603..8c94b2326 100644 --- a/src/cli/cliRun.ts +++ b/src/cli/cliRun.ts @@ -96,6 +96,11 @@ export const run = async () => { '--include-diffs', 'include git diffs in the output (includes both work tree and staged changes separately)', ) + .option( + '--include-logs', + 'include git logs in the output (includes commit history with dates, messages, and file paths)', + ) + .option('--include-logs-count ', 'number of git log commits to include (default: 50)', Number.parseInt) // File Selection Options .optionsGroup('File Selection Options') .option('--include ', 'list of include patterns (comma-separated)') diff --git a/src/cli/types.ts b/src/cli/types.ts index 52841a77c..dcc38207e 100644 --- a/src/cli/types.ts +++ b/src/cli/types.ts @@ -24,6 +24,8 @@ export interface CliOptions extends OptionValues { includeEmptyDirectories?: boolean; gitSortByChanges?: boolean; includeDiffs?: boolean; + includeLogs?: boolean; + includeLogsCount?: number; // Filter Options include?: string; diff --git a/src/config/configSchema.ts b/src/config/configSchema.ts index 9d2ea6ce1..e6bdb3359 100644 --- a/src/config/configSchema.ts +++ b/src/config/configSchema.ts @@ -44,6 +44,8 @@ export const repomixConfigBaseSchema = z.object({ sortByChanges: z.boolean().optional(), sortByChangesMaxCommits: z.number().optional(), includeDiffs: z.boolean().optional(), + includeLogs: z.boolean().optional(), + includeLogsCount: z.number().optional(), }) .optional(), }) @@ -103,6 +105,8 @@ export const repomixConfigDefaultSchema = z.object({ sortByChanges: z.boolean().default(true), sortByChangesMaxCommits: z.number().int().min(1).default(100), includeDiffs: z.boolean().default(false), + includeLogs: z.boolean().default(false), + includeLogsCount: z.number().int().min(1).default(50), }) .default({}), }) diff --git a/src/core/git/gitCommand.ts b/src/core/git/gitCommand.ts index 8ef581058..e136c4768 100644 --- a/src/core/git/gitCommand.ts +++ b/src/core/git/gitCommand.ts @@ -150,6 +150,33 @@ export const execGitShallowClone = async ( await fs.rm(path.join(directory, '.git'), { recursive: true, force: true }); }; +export const execGitLog = async ( + directory: string, + maxCommits: number, + gitSeparator: string, + deps = { + execFileAsync, + }, +): Promise => { + try { + const result = await deps.execFileAsync('git', [ + '-C', + directory, + 'log', + `--pretty=format:${gitSeparator}%ad|%s`, + '--date=iso', + '--name-only', + '-n', + maxCommits.toString(), + ]); + + return result.stdout || ''; + } catch (error) { + logger.trace('Failed to execute git log:', (error as Error).message); + throw error; + } +}; + /** * Validates a Git URL for security and format * @throws {RepomixError} If the URL is invalid or contains potentially dangerous parameters diff --git a/src/core/git/gitLogHandle.ts b/src/core/git/gitLogHandle.ts new file mode 100644 index 000000000..b719d4149 --- /dev/null +++ b/src/core/git/gitLogHandle.ts @@ -0,0 +1,114 @@ +import type { RepomixConfigMerged } from '../../config/configSchema.js'; +import { RepomixError } from '../../shared/errorHandle.js'; +import { logger } from '../../shared/logger.js'; +import { execGitLog } from './gitCommand.js'; +import { isGitRepository } from './gitRepositoryHandle.js'; + +// Null character used as record separator in git log output for robust parsing +// This ensures commits are split correctly even when commit messages contain newlines +export const GIT_LOG_RECORD_SEPARATOR = '\x00'; + +// Git format string for null character separator +// Git expects %x00 format in pretty format strings +export const GIT_LOG_FORMAT_SEPARATOR = '%x00'; + +export interface GitLogCommit { + date: string; + message: string; + files: string[]; +} + +export interface GitLogResult { + logContent: string; + commits: GitLogCommit[]; +} + +const parseGitLog = (rawLogOutput: string, recordSeparator = GIT_LOG_RECORD_SEPARATOR): GitLogCommit[] => { + if (!rawLogOutput.trim()) { + return []; + } + + const commits: GitLogCommit[] = []; + // Split by record separator used in git log output + // This is more robust than splitting by double newlines, as commit messages may contain newlines + const logEntries = rawLogOutput.split(recordSeparator).filter(Boolean); + + for (const entry of logEntries) { + // Split on both \n and \r\n to handle different line ending formats across platforms + const lines = entry.split(/\r?\n/).filter((line) => line.trim() !== ''); + if (lines.length === 0) continue; + + // First line contains date and message separated by | + const firstLine = lines[0]; + const separatorIndex = firstLine.indexOf('|'); + if (separatorIndex === -1) continue; + + const date = firstLine.substring(0, separatorIndex); + const message = firstLine.substring(separatorIndex + 1); + + // Remaining lines are file paths + const files = lines.slice(1).filter((line) => line.trim() !== ''); + + commits.push({ + date, + message, + files, + }); + } + + return commits; +}; + +export const getGitLog = async ( + directory: string, + maxCommits: number, + deps = { + execGitLog, + isGitRepository, + }, +): Promise => { + if (!(await deps.isGitRepository(directory))) { + logger.trace(`Directory ${directory} is not a git repository`); + return ''; + } + + try { + return await deps.execGitLog(directory, maxCommits, GIT_LOG_FORMAT_SEPARATOR); + } catch (error) { + logger.trace('Failed to get git log:', (error as Error).message); + throw error; + } +}; + +export const getGitLogs = async ( + rootDirs: string[], + config: RepomixConfigMerged, + deps = { + getGitLog, + }, +): Promise => { + // Get git logs if enabled + let gitLogResult: GitLogResult | undefined; + + if (config.output.git?.includeLogs) { + try { + // Use the first directory as the git repository root + // Usually this would be the root of the project + const gitRoot = rootDirs[0] || config.cwd; + const maxCommits = config.output.git?.includeLogsCount || 50; + const logContent = await deps.getGitLog(gitRoot, maxCommits); + + // Parse the raw log content into structured commits + const commits = parseGitLog(logContent); + + gitLogResult = { + logContent, + commits, + }; + } catch (error) { + throw new RepomixError(`Failed to get git logs: ${(error as Error).message}`, { cause: error }); + } + } + + return gitLogResult; +}; diff --git a/src/core/metrics/calculateGitLogMetrics.ts b/src/core/metrics/calculateGitLogMetrics.ts new file mode 100644 index 000000000..6eebdaff1 --- /dev/null +++ b/src/core/metrics/calculateGitLogMetrics.ts @@ -0,0 +1,60 @@ +import type { RepomixConfigMerged } from '../../config/configSchema.js'; +import { logger } from '../../shared/logger.js'; +import { initTaskRunner } from '../../shared/processConcurrency.js'; +import type { GitLogResult } from '../git/gitLogHandle.js'; +import type { GitLogMetricsTask } from './workers/gitLogMetricsWorker.js'; + +/** + * Calculate token count for git logs if included + */ +export const calculateGitLogMetrics = async ( + config: RepomixConfigMerged, + gitLogResult: GitLogResult | undefined, + deps = { + initTaskRunner, + }, +): Promise<{ gitLogTokenCount: number }> => { + // Return zero token count if git logs are disabled or no result + if (!config.output.git?.includeLogs || !gitLogResult) { + return { + gitLogTokenCount: 0, + }; + } + + // Return zero token count if no git log content + if (!gitLogResult.logContent) { + return { + gitLogTokenCount: 0, + }; + } + + const taskRunner = deps.initTaskRunner( + 1, // Single task for git log calculation + new URL('./workers/gitLogMetricsWorker.js', import.meta.url).href, + ); + + try { + const startTime = process.hrtime.bigint(); + logger.trace('Starting git log token calculation using worker'); + + const result = await taskRunner.run({ + content: gitLogResult.logContent, + encoding: config.tokenCount.encoding, + }); + + const endTime = process.hrtime.bigint(); + const duration = Number(endTime - startTime) / 1e6; + logger.trace(`Git log token calculation completed in ${duration.toFixed(2)}ms`); + + return { + gitLogTokenCount: result, + }; + } catch (error) { + logger.error('Failed to calculate git log metrics:', error); + return { + gitLogTokenCount: 0, + }; + } finally { + await taskRunner.cleanup(); + } +}; diff --git a/src/core/metrics/calculateMetrics.ts b/src/core/metrics/calculateMetrics.ts index bb05be5bb..362289035 100644 --- a/src/core/metrics/calculateMetrics.ts +++ b/src/core/metrics/calculateMetrics.ts @@ -2,7 +2,9 @@ import type { RepomixConfigMerged } from '../../config/configSchema.js'; import type { RepomixProgressCallback } from '../../shared/types.js'; import type { ProcessedFile } from '../file/fileTypes.js'; import type { GitDiffResult } from '../git/gitDiffHandle.js'; +import type { GitLogResult } from '../git/gitLogHandle.js'; import { calculateGitDiffMetrics } from './calculateGitDiffMetrics.js'; +import { calculateGitLogMetrics } from './calculateGitLogMetrics.js'; import { calculateOutputMetrics } from './calculateOutputMetrics.js'; import { calculateSelectiveFileMetrics } from './calculateSelectiveFileMetrics.js'; @@ -13,6 +15,7 @@ export interface CalculateMetricsResult { fileCharCounts: Record; fileTokenCounts: Record; gitDiffTokenCount: number; + gitLogTokenCount: number; } export const calculateMetrics = async ( @@ -21,10 +24,12 @@ export const calculateMetrics = async ( progressCallback: RepomixProgressCallback, config: RepomixConfigMerged, gitDiffResult: GitDiffResult | undefined, + gitLogResult: GitLogResult | undefined, deps = { calculateSelectiveFileMetrics, calculateOutputMetrics, calculateGitDiffMetrics, + calculateGitLogMetrics, }, ): Promise => { progressCallback('Calculating metrics...'); @@ -44,7 +49,7 @@ export const calculateMetrics = async ( .slice(0, Math.min(processedFiles.length, Math.max(topFilesLength * 10, topFilesLength))) .map((file) => file.path); - const [selectiveFileMetrics, totalTokens, gitDiffTokenCount] = await Promise.all([ + const [selectiveFileMetrics, totalTokens, gitDiffTokenCount, gitLogTokenCount] = await Promise.all([ deps.calculateSelectiveFileMetrics( processedFiles, metricsTargetPaths, @@ -53,6 +58,7 @@ export const calculateMetrics = async ( ), deps.calculateOutputMetrics(output, config.tokenCount.encoding, config.output.filePath), deps.calculateGitDiffMetrics(config, gitDiffResult), + deps.calculateGitLogMetrics(config, gitLogResult), ]); const totalFiles = processedFiles.length; @@ -77,5 +83,6 @@ export const calculateMetrics = async ( fileCharCounts, fileTokenCounts, gitDiffTokenCount: gitDiffTokenCount, + gitLogTokenCount: gitLogTokenCount.gitLogTokenCount, }; }; diff --git a/src/core/metrics/workers/gitLogMetricsWorker.ts b/src/core/metrics/workers/gitLogMetricsWorker.ts new file mode 100644 index 000000000..338b9b8ee --- /dev/null +++ b/src/core/metrics/workers/gitLogMetricsWorker.ts @@ -0,0 +1,37 @@ +import type { TiktokenEncoding } from 'tiktoken'; +import { logger, setLogLevelByWorkerData } from '../../../shared/logger.js'; +import { freeTokenCounters, getTokenCounter } from '../tokenCounterFactory.js'; + +// Initialize logger configuration from workerData at module load time +// This must be called before any logging operations in the worker +setLogLevelByWorkerData(); + +export interface GitLogMetricsTask { + content: string; + encoding: TiktokenEncoding; +} + +export default async ({ content, encoding }: GitLogMetricsTask): Promise => { + const processStartAt = process.hrtime.bigint(); + + try { + if (!content) { + return 0; + } + + const tokenCounter = getTokenCounter(encoding); + const tokenCount = tokenCounter.countTokens(content); + + const processEndAt = process.hrtime.bigint(); + const processDuration = Number(processEndAt - processStartAt) / 1e6; + logger.trace(`Git log token count calculated in ${processDuration.toFixed(2)}ms`); + + return tokenCount; + } catch (error) { + logger.error('Error calculating git log token count:', error); + return 0; + } finally { + // Clean up token counters to free memory + freeTokenCounters(); + } +}; diff --git a/src/core/output/outputGenerate.ts b/src/core/output/outputGenerate.ts index 38fd35f11..cee2bfe3a 100644 --- a/src/core/output/outputGenerate.ts +++ b/src/core/output/outputGenerate.ts @@ -8,6 +8,7 @@ import { type FileSearchResult, searchFiles } from '../file/fileSearch.js'; import { generateTreeString } from '../file/fileTreeGenerate.js'; import type { ProcessedFile } from '../file/fileTypes.js'; import type { GitDiffResult } from '../git/gitDiffHandle.js'; +import type { GitLogResult } from '../git/gitLogHandle.js'; import type { OutputGeneratorContext, RenderContext } from './outputGeneratorTypes.js'; import { sortOutputFiles } from './outputSort.js'; import { @@ -50,6 +51,9 @@ const createRenderContext = (outputGeneratorContext: OutputGeneratorContext): Re gitDiffEnabled: outputGeneratorContext.config.output.git?.includeDiffs, gitDiffWorkTree: outputGeneratorContext.gitDiffResult?.workTreeDiffContent, gitDiffStaged: outputGeneratorContext.gitDiffResult?.stagedDiffContent, + gitLogEnabled: outputGeneratorContext.config.output.git?.includeLogs, + gitLogContent: outputGeneratorContext.gitLogResult?.logContent, + gitLogCommits: outputGeneratorContext.gitLogResult?.commits, }; }; @@ -86,6 +90,15 @@ const generateParsableXmlOutput = async (renderContext: RenderContext): Promise< git_diff_staged: renderContext.gitDiffStaged, } : undefined, + git_logs: renderContext.gitLogEnabled + ? { + git_log_commit: renderContext.gitLogCommits?.map((commit) => ({ + date: commit.date, + message: commit.message, + files: commit.files.map((file) => ({ '#text': file })), + })), + } + : undefined, instruction: renderContext.instruction ? renderContext.instruction : undefined, }, }; @@ -156,6 +169,7 @@ export const generateOutput = async ( processedFiles: ProcessedFile[], allFilePaths: string[], gitDiffResult: GitDiffResult | undefined = undefined, + gitLogResult: GitLogResult | undefined = undefined, deps = { buildOutputGeneratorContext, generateHandlebarOutput, @@ -172,6 +186,7 @@ export const generateOutput = async ( allFilePaths, sortedProcessedFiles, gitDiffResult, + gitLogResult, ); const renderContext = createRenderContext(outputGeneratorContext); @@ -192,6 +207,7 @@ export const buildOutputGeneratorContext = async ( allFilePaths: string[], processedFiles: ProcessedFile[], gitDiffResult: GitDiffResult | undefined = undefined, + gitLogResult: GitLogResult | undefined = undefined, ): Promise => { let repositoryInstruction = ''; @@ -229,5 +245,6 @@ export const buildOutputGeneratorContext = async ( config, instruction: repositoryInstruction, gitDiffResult, + gitLogResult, }; }; diff --git a/src/core/output/outputGeneratorTypes.ts b/src/core/output/outputGeneratorTypes.ts index 3207145f3..ffa2c565f 100644 --- a/src/core/output/outputGeneratorTypes.ts +++ b/src/core/output/outputGeneratorTypes.ts @@ -1,6 +1,7 @@ import type { RepomixConfigMerged } from '../../config/configSchema.js'; import type { ProcessedFile } from '../file/fileTypes.js'; import type { GitDiffResult } from '../git/gitDiffHandle.js'; +import type { GitLogCommit, GitLogResult } from '../git/gitLogHandle.js'; export interface OutputGeneratorContext { generationDate: string; @@ -9,6 +10,7 @@ export interface OutputGeneratorContext { config: RepomixConfigMerged; instruction: string; gitDiffResult: GitDiffResult | undefined; + gitLogResult: GitLogResult | undefined; } export interface RenderContext { @@ -29,4 +31,7 @@ export interface RenderContext { readonly gitDiffEnabled: boolean; readonly gitDiffWorkTree: string | undefined; readonly gitDiffStaged: string | undefined; + readonly gitLogEnabled: boolean; + readonly gitLogContent: string | undefined; + readonly gitLogCommits: GitLogCommit[] | undefined; } diff --git a/src/core/output/outputStyleDecorate.ts b/src/core/output/outputStyleDecorate.ts index 70d5c38a9..3b1b7cde5 100644 --- a/src/core/output/outputStyleDecorate.ts +++ b/src/core/output/outputStyleDecorate.ts @@ -184,5 +184,11 @@ export const generateSummaryNotes = (config: RepomixConfigMerged): string => { notes.push('- Git diffs from the worktree and staged changes are included'); } + // Git logs notes + if (config.output.git?.includeLogs) { + const logCount = config.output.git?.includeLogsCount || 50; + notes.push(`- Git logs (${logCount} commits) are included to show development patterns`); + } + return notes.join('\n'); }; diff --git a/src/core/output/outputStyles/markdownStyle.ts b/src/core/output/outputStyles/markdownStyle.ts index 27a361c73..ef436aafc 100644 --- a/src/core/output/outputStyles/markdownStyle.ts +++ b/src/core/output/outputStyles/markdownStyle.ts @@ -61,6 +61,21 @@ export const getMarkdownTemplate = () => { {{/if}} +{{#if gitLogEnabled}} +# Git Logs + +{{#each gitLogCommits}} +## Commit: {{{this.date}}} +**Message:** {{{this.message}}} + +**Files:** +{{#each this.files}} +- {{{this}}} +{{/each}} + +{{/each}} +{{/if}} + {{#if instruction}} # Instruction {{{instruction}}} diff --git a/src/core/output/outputStyles/plainStyle.ts b/src/core/output/outputStyles/plainStyle.ts index 7c6bea924..9d3dbf924 100644 --- a/src/core/output/outputStyles/plainStyle.ts +++ b/src/core/output/outputStyles/plainStyle.ts @@ -77,6 +77,24 @@ ${PLAIN_SEPARATOR} {{/if}} +{{#if gitLogEnabled}} +${PLAIN_LONG_SEPARATOR} +Git Logs +${PLAIN_LONG_SEPARATOR} +{{#each gitLogCommits}} +${PLAIN_SEPARATOR} +Date: {{{this.date}}} +Message: {{{this.message}}} +Files: +{{#each this.files}} + - {{{this}}} +{{/each}} +${PLAIN_SEPARATOR} + +{{/each}} + +{{/if}} + {{#if instruction}} ${PLAIN_LONG_SEPARATOR} Instruction diff --git a/src/core/output/outputStyles/xmlStyle.ts b/src/core/output/outputStyles/xmlStyle.ts index 4ae22d174..101aed015 100644 --- a/src/core/output/outputStyles/xmlStyle.ts +++ b/src/core/output/outputStyles/xmlStyle.ts @@ -64,6 +64,22 @@ This section contains the contents of the repository's files. {{/if}} +{{#if gitLogEnabled}} + +{{#each gitLogCommits}} + +{{{this.date}}} +{{{this.message}}} + +{{#each this.files}} +{{{this}}} +{{/each}} + + +{{/each}} + +{{/if}} + {{#if instruction}} {{{instruction}}} diff --git a/src/core/packager.ts b/src/core/packager.ts index 950bab017..037c99ba3 100644 --- a/src/core/packager.ts +++ b/src/core/packager.ts @@ -8,6 +8,7 @@ import { processFiles } from './file/fileProcess.js'; import { searchFiles } from './file/fileSearch.js'; import type { ProcessedFile, RawFile } from './file/fileTypes.js'; import { GitDiffResult, getGitDiffs } from './git/gitDiffHandle.js'; +import { GitLogResult, getGitLogs } from './git/gitLogHandle.js'; import { calculateMetrics } from './metrics/calculateMetrics.js'; import { generateOutput } from './output/outputGenerate.js'; import { copyToClipboardIfEnabled } from './packager/copyToClipboardIfEnabled.js'; @@ -22,8 +23,10 @@ export interface PackResult { fileCharCounts: Record; fileTokenCounts: Record; gitDiffTokenCount: number; + gitLogTokenCount: number; suspiciousFilesResults: SuspiciousFileResult[]; suspiciousGitDiffResults: SuspiciousFileResult[]; + suspiciousGitLogResults: SuspiciousFileResult[]; processedFiles: ProcessedFile[]; safeFilePaths: string[]; } @@ -39,6 +42,7 @@ const defaultDeps = { calculateMetrics, sortPaths, getGitDiffs, + getGitLogs, }; export const pack = async ( @@ -93,11 +97,15 @@ export const pack = async ( progressCallback('Getting git diffs...'); const gitDiffResult = await deps.getGitDiffs(rootDirs, config); + // Get git logs if enabled - run this before security check + progressCallback('Getting git logs...'); + const gitLogResult = await deps.getGitLogs(rootDirs, config); + // Run security check and get filtered safe files - const { safeFilePaths, safeRawFiles, suspiciousFilesResults, suspiciousGitDiffResults } = await withMemoryLogging( - 'Security Check', - () => deps.validateFileSafety(rawFiles, progressCallback, config, gitDiffResult), - ); + const { safeFilePaths, safeRawFiles, suspiciousFilesResults, suspiciousGitDiffResults, suspiciousGitLogResults } = + await withMemoryLogging('Security Check', () => + deps.validateFileSafety(rawFiles, progressCallback, config, gitDiffResult, gitLogResult), + ); // Process files (remove comments, etc.) progressCallback('Processing files...'); @@ -107,7 +115,7 @@ export const pack = async ( progressCallback('Generating output...'); const output = await withMemoryLogging('Generate Output', () => - deps.generateOutput(rootDirs, config, processedFiles, safeFilePaths, gitDiffResult), + deps.generateOutput(rootDirs, config, processedFiles, safeFilePaths, gitDiffResult, gitLogResult), ); progressCallback('Writing output file...'); @@ -116,7 +124,7 @@ export const pack = async ( await deps.copyToClipboardIfEnabled(output, progressCallback, config); const metrics = await withMemoryLogging('Calculate Metrics', () => - deps.calculateMetrics(processedFiles, output, progressCallback, config, gitDiffResult), + deps.calculateMetrics(processedFiles, output, progressCallback, config, gitDiffResult, gitLogResult), ); // Create a result object that includes metrics and security results @@ -124,6 +132,7 @@ export const pack = async ( ...metrics, suspiciousFilesResults, suspiciousGitDiffResults, + suspiciousGitLogResults, processedFiles, safeFilePaths, }; diff --git a/src/core/security/securityCheck.ts b/src/core/security/securityCheck.ts index 767b99514..9e572ee25 100644 --- a/src/core/security/securityCheck.ts +++ b/src/core/security/securityCheck.ts @@ -4,6 +4,7 @@ import { initTaskRunner } from '../../shared/processConcurrency.js'; import type { RepomixProgressCallback } from '../../shared/types.js'; import type { RawFile } from '../file/fileTypes.js'; import type { GitDiffResult } from '../git/gitDiffHandle.js'; +import type { GitLogResult } from '../git/gitLogHandle.js'; import type { SecurityCheckTask, SecurityCheckType } from './workers/securityCheckWorker.js'; export interface SuspiciousFileResult { @@ -16,11 +17,13 @@ export const runSecurityCheck = async ( rawFiles: RawFile[], progressCallback: RepomixProgressCallback = () => {}, gitDiffResult?: GitDiffResult, + gitLogResult?: GitLogResult, deps = { initTaskRunner, }, ): Promise => { const gitDiffTasks: SecurityCheckTask[] = []; + const gitLogTasks: SecurityCheckTask[] = []; // Add Git diff content for security checking if available if (gitDiffResult) { @@ -41,8 +44,19 @@ export const runSecurityCheck = async ( } } + // Add Git log content for security checking if available + if (gitLogResult) { + if (gitLogResult.logContent) { + gitLogTasks.push({ + filePath: 'Git log history', + content: gitLogResult.logContent, + type: 'gitLog', + }); + } + } + const taskRunner = deps.initTaskRunner( - rawFiles.length + gitDiffTasks.length, + rawFiles.length + gitDiffTasks.length + gitLogTasks.length, new URL('./workers/securityCheckWorker.js', import.meta.url).href, ); const fileTasks = rawFiles.map( @@ -54,8 +68,8 @@ export const runSecurityCheck = async ( }) satisfies SecurityCheckTask, ); - // Combine file tasks and Git diff tasks - const tasks = [...fileTasks, ...gitDiffTasks]; + // Combine file tasks, Git diff tasks, and Git log tasks + const tasks = [...fileTasks, ...gitDiffTasks, ...gitLogTasks]; try { logger.trace(`Starting security check for ${tasks.length} files/content`); diff --git a/src/core/security/validateFileSafety.ts b/src/core/security/validateFileSafety.ts index f9d4791ff..7be5ba8be 100644 --- a/src/core/security/validateFileSafety.ts +++ b/src/core/security/validateFileSafety.ts @@ -3,6 +3,7 @@ import { logger } from '../../shared/logger.js'; import type { RepomixProgressCallback } from '../../shared/types.js'; import type { ProcessedFile, RawFile } from '../file/fileTypes.js'; import type { GitDiffResult } from '../git/gitDiffHandle.js'; +import type { GitLogResult } from '../git/gitLogHandle.js'; import { filterOutUntrustedFiles } from './filterOutUntrustedFiles.js'; import { type SuspiciousFileResult, runSecurityCheck } from './securityCheck.js'; @@ -14,6 +15,7 @@ export const validateFileSafety = async ( progressCallback: RepomixProgressCallback, config: RepomixConfigMerged, gitDiffResult?: GitDiffResult, + gitLogResult?: GitLogResult, deps = { runSecurityCheck, filterOutUntrustedFiles, @@ -21,23 +23,19 @@ export const validateFileSafety = async ( ) => { let suspiciousFilesResults: SuspiciousFileResult[] = []; let suspiciousGitDiffResults: SuspiciousFileResult[] = []; + let suspiciousGitLogResults: SuspiciousFileResult[] = []; if (config.security.enableSecurityCheck) { progressCallback('Running security check...'); - const allResults = await deps.runSecurityCheck(rawFiles, progressCallback, gitDiffResult); + const allResults = await deps.runSecurityCheck(rawFiles, progressCallback, gitDiffResult, gitLogResult); - // Separate Git diff results from regular file results + // Separate Git diff and Git log results from regular file results suspiciousFilesResults = allResults.filter((result) => result.type === 'file'); suspiciousGitDiffResults = allResults.filter((result) => result.type === 'gitDiff'); + suspiciousGitLogResults = allResults.filter((result) => result.type === 'gitLog'); - if (suspiciousGitDiffResults.length > 0) { - logger.warn('Security issues found in Git diffs, but they will still be included in the output'); - for (const result of suspiciousGitDiffResults) { - const issueCount = result.messages.length; - const issueText = issueCount === 1 ? 'issue' : 'issues'; - logger.warn(` - ${result.filePath}: ${issueCount} ${issueText} detected`); - } - } + logSuspiciousContentWarning('Git diffs', suspiciousGitDiffResults); + logSuspiciousContentWarning('Git logs', suspiciousGitLogResults); } const safeRawFiles = deps.filterOutUntrustedFiles(rawFiles, suspiciousFilesResults); @@ -49,5 +47,19 @@ export const validateFileSafety = async ( safeFilePaths, suspiciousFilesResults, suspiciousGitDiffResults, + suspiciousGitLogResults, }; }; + +const logSuspiciousContentWarning = (contentType: string, results: SuspiciousFileResult[]) => { + if (results.length === 0) { + return; + } + + logger.warn(`Security issues found in ${contentType}, but they will still be included in the output`); + for (const result of results) { + const issueCount = result.messages.length; + const issueText = issueCount === 1 ? 'issue' : 'issues'; + logger.warn(` - ${result.filePath}: ${issueCount} ${issueText} detected`); + } +}; diff --git a/src/core/security/workers/securityCheckWorker.ts b/src/core/security/workers/securityCheckWorker.ts index 2140c6ee5..2cd33244f 100644 --- a/src/core/security/workers/securityCheckWorker.ts +++ b/src/core/security/workers/securityCheckWorker.ts @@ -7,8 +7,8 @@ import { logger, setLogLevelByWorkerData } from '../../../shared/logger.js'; // This must be called before any logging operations in the worker setLogLevelByWorkerData(); -// Security check type to distinguish between regular files and git diffs -export type SecurityCheckType = 'file' | 'gitDiff'; +// Security check type to distinguish between regular files, git diffs, and git logs +export type SecurityCheckType = 'file' | 'gitDiff' | 'gitLog'; export interface SecurityCheckTask { filePath: string; diff --git a/tests/cli/actions/defaultAction.test.ts b/tests/cli/actions/defaultAction.test.ts index 5818398ae..bdfe76ec0 100644 --- a/tests/cli/actions/defaultAction.test.ts +++ b/tests/cli/actions/defaultAction.test.ts @@ -102,9 +102,11 @@ describe('defaultAction', () => { fileTokenCounts: {}, suspiciousFilesResults: [], suspiciousGitDiffResults: [], + suspiciousGitLogResults: [], processedFiles: [], safeFilePaths: [], gitDiffTokenCount: 0, + gitLogTokenCount: 0, }); }); @@ -654,10 +656,12 @@ describe('defaultAction', () => { totalChars: 2500, totalCharacters: 2500, gitDiffTokenCount: 0, + gitLogTokenCount: 0, processedFiles: [], safeFilePaths: [], suspiciousFilesResults: [], suspiciousGitDiffResults: [], + suspiciousGitLogResults: [], fileCharCounts: {}, fileTokenCounts: {}, outputFilePath: 'output.txt', @@ -783,10 +787,12 @@ describe('defaultAction', () => { totalChars: 2500, totalCharacters: 2500, gitDiffTokenCount: 0, + gitLogTokenCount: 0, processedFiles: [], safeFilePaths: [], suspiciousFilesResults: [], suspiciousGitDiffResults: [], + suspiciousGitLogResults: [], fileCharCounts: {}, fileTokenCounts: {}, outputFilePath: 'output.txt', @@ -850,10 +856,12 @@ describe('defaultAction', () => { totalChars: 2500, totalCharacters: 2500, gitDiffTokenCount: 0, + gitLogTokenCount: 0, processedFiles: [], safeFilePaths: [], suspiciousFilesResults: [], suspiciousGitDiffResults: [], + suspiciousGitLogResults: [], fileCharCounts: {}, fileTokenCounts: {}, outputFilePath: 'output.txt', diff --git a/tests/cli/actions/remoteAction.test.ts b/tests/cli/actions/remoteAction.test.ts index 2cc9329d2..041efc7a4 100644 --- a/tests/cli/actions/remoteAction.test.ts +++ b/tests/cli/actions/remoteAction.test.ts @@ -45,9 +45,11 @@ describe('remoteAction functions', () => { fileTokenCounts: {}, suspiciousFilesResults: [], suspiciousGitDiffResults: [], + suspiciousGitLogResults: [], processedFiles: [], safeFilePaths: [], gitDiffTokenCount: 0, + gitLogTokenCount: 0, }, config: createMockConfig(), } satisfies DefaultActionRunnerResult; @@ -85,9 +87,11 @@ describe('remoteAction functions', () => { fileTokenCounts: {}, suspiciousFilesResults: [], suspiciousGitDiffResults: [], + suspiciousGitLogResults: [], processedFiles: [], safeFilePaths: [], gitDiffTokenCount: 0, + gitLogTokenCount: 0, }, config: createMockConfig(), } satisfies DefaultActionRunnerResult; @@ -128,9 +132,11 @@ describe('remoteAction functions', () => { fileTokenCounts: {}, suspiciousFilesResults: [], suspiciousGitDiffResults: [], + suspiciousGitLogResults: [], processedFiles: [], safeFilePaths: [], gitDiffTokenCount: 0, + gitLogTokenCount: 0, }, config: createMockConfig(), } satisfies DefaultActionRunnerResult; @@ -171,9 +177,11 @@ describe('remoteAction functions', () => { fileTokenCounts: {}, suspiciousFilesResults: [], suspiciousGitDiffResults: [], + suspiciousGitLogResults: [], processedFiles: [], safeFilePaths: [], gitDiffTokenCount: 0, + gitLogTokenCount: 0, }, config: createMockConfig(), } satisfies DefaultActionRunnerResult; diff --git a/tests/cli/cliReport.test.ts b/tests/cli/cliReport.test.ts index 5c53a03e9..c4c213775 100644 --- a/tests/cli/cliReport.test.ts +++ b/tests/cli/cliReport.test.ts @@ -41,9 +41,11 @@ describe('cliReport', () => { fileTokenCounts: { 'file1.txt': 50 }, suspiciousFilesResults: suspiciousFiles, suspiciousGitDiffResults: [], + suspiciousGitLogResults: [], processedFiles: [], safeFilePaths: [], gitDiffTokenCount: 0, + gitLogTokenCount: 0, }; reportSummary(packResult, config); @@ -64,9 +66,11 @@ describe('cliReport', () => { fileTokenCounts: { 'file1.txt': 50 }, suspiciousFilesResults: [], suspiciousGitDiffResults: [], + suspiciousGitLogResults: [], processedFiles: [], safeFilePaths: [], gitDiffTokenCount: 0, + gitLogTokenCount: 0, }; reportSummary(packResult, config); @@ -81,7 +85,7 @@ describe('cliReport', () => { security: { enableSecurityCheck: false }, }); - reportSecurityCheck('/root', [], [], config); + reportSecurityCheck('/root', [], [], [], config); expect(logger.log).not.toHaveBeenCalled(); }); @@ -90,7 +94,7 @@ describe('cliReport', () => { security: { enableSecurityCheck: true }, }); - reportSecurityCheck('/root', [], [], config); + reportSecurityCheck('/root', [], [], [], config); expect(logger.log).toHaveBeenCalledWith('WHITE:🔎 Security Check:'); expect(logger.log).toHaveBeenCalledWith('DIM:──────────────────'); @@ -110,7 +114,7 @@ describe('cliReport', () => { }, ]; - reportSecurityCheck('/root', suspiciousFiles, [], config); + reportSecurityCheck('/root', suspiciousFiles, [], [], config); expect(logger.log).toHaveBeenCalledWith('YELLOW:1 suspicious file(s) detected and excluded from the output:'); expect(logger.log).toHaveBeenCalledWith(`WHITE:1. WHITE:${configRelativePath}`); diff --git a/tests/cli/cliRun.test.ts b/tests/cli/cliRun.test.ts index 18d797693..c4434c1da 100644 --- a/tests/cli/cliRun.test.ts +++ b/tests/cli/cliRun.test.ts @@ -94,7 +94,9 @@ describe('cliRun', () => { fileTokenCounts: {}, suspiciousFilesResults: [], gitDiffTokenCount: 0, + gitLogTokenCount: 0, suspiciousGitDiffResults: [], + suspiciousGitLogResults: [], processedFiles: [], safeFilePaths: [], } satisfies PackResult, @@ -147,7 +149,9 @@ describe('cliRun', () => { fileTokenCounts: {}, suspiciousFilesResults: [], gitDiffTokenCount: 0, + gitLogTokenCount: 0, suspiciousGitDiffResults: [], + suspiciousGitLogResults: [], processedFiles: [], safeFilePaths: [], } satisfies PackResult, diff --git a/tests/config/configSchema.test.ts b/tests/config/configSchema.test.ts index 90b7e2d16..b25f8bec1 100644 --- a/tests/config/configSchema.test.ts +++ b/tests/config/configSchema.test.ts @@ -118,6 +118,8 @@ describe('configSchema', () => { sortByChanges: true, sortByChangesMaxCommits: 100, includeDiffs: false, + includeLogs: false, + includeLogsCount: 50, }, }, include: [], @@ -214,6 +216,8 @@ describe('configSchema', () => { sortByChanges: true, sortByChangesMaxCommits: 100, includeDiffs: false, + includeLogs: false, + includeLogsCount: 50, }, }, include: ['**/*.js', '**/*.ts'], diff --git a/tests/core/git/gitCommand.test.ts b/tests/core/git/gitCommand.test.ts index d49da06e9..6c26b53e8 100644 --- a/tests/core/git/gitCommand.test.ts +++ b/tests/core/git/gitCommand.test.ts @@ -1,6 +1,7 @@ import { beforeEach, describe, expect, test, vi } from 'vitest'; import { execGitDiff, + execGitLog, execGitLogFilenames, execGitRevParse, execGitShallowClone, @@ -283,6 +284,83 @@ file2.ts }); }); + describe('execGitLog', () => { + test('should return git log with null character separator', async () => { + const mockOutput = `\x002024-01-01 10:00:00 +0900|Initial commit +file1.txt +file2.txt +\x002024-01-02 11:00:00 +0900|Add new feature +src/feature.ts +test/feature.test.ts`; + const mockFileExecAsync = vi.fn().mockResolvedValue({ stdout: mockOutput }); + + const result = await execGitLog('/test/dir', 10, '%x00', { execFileAsync: mockFileExecAsync }); + + expect(result).toBe(mockOutput); + expect(mockFileExecAsync).toHaveBeenCalledWith('git', [ + '-C', + '/test/dir', + 'log', + '--pretty=format:%x00%ad|%s', + '--date=iso', + '--name-only', + '-n', + '10', + ]); + }); + + test('should use custom record separator when provided', async () => { + const customSeparator = '|SEPARATOR|'; + const mockOutput = `${customSeparator}2024-01-01 10:00:00 +0900|Initial commit +file1.txt`; + const mockFileExecAsync = vi.fn().mockResolvedValue({ stdout: mockOutput }); + + const result = await execGitLog('/test/dir', 5, customSeparator, { execFileAsync: mockFileExecAsync }); + + expect(result).toBe(mockOutput); + expect(mockFileExecAsync).toHaveBeenCalledWith('git', [ + '-C', + '/test/dir', + 'log', + `--pretty=format:${customSeparator}%ad|%s`, + '--date=iso', + '--name-only', + '-n', + '5', + ]); + }); + + test('should throw error when git log fails', async () => { + const mockFileExecAsync = vi.fn().mockRejectedValue(new Error('git command failed')); + + await expect(execGitLog('/test/dir', 10, '%x00', { execFileAsync: mockFileExecAsync })).rejects.toThrow( + 'git command failed', + ); + expect(logger.trace).toHaveBeenCalledWith('Failed to execute git log:', 'git command failed'); + }); + + test('should work with different separators', async () => { + const separator = '###'; + const mockOutput = `${separator}2024-01-01 10:00:00 +0900|Test commit +file.txt`; + const mockFileExecAsync = vi.fn().mockResolvedValue({ stdout: mockOutput }); + + const result = await execGitLog('/test/dir', 50, separator, { execFileAsync: mockFileExecAsync }); + + expect(result).toBe(mockOutput); + expect(mockFileExecAsync).toHaveBeenCalledWith('git', [ + '-C', + '/test/dir', + 'log', + `--pretty=format:${separator}%ad|%s`, + '--date=iso', + '--name-only', + '-n', + '50', + ]); + }); + }); + test('should reject URLs with dangerous parameters', async () => { const mockFileExecAsync = vi.fn(); diff --git a/tests/core/git/gitLogHandle.test.ts b/tests/core/git/gitLogHandle.test.ts new file mode 100644 index 000000000..475e7638f --- /dev/null +++ b/tests/core/git/gitLogHandle.test.ts @@ -0,0 +1,294 @@ +import { beforeEach, describe, expect, test, vi } from 'vitest'; +import type { RepomixConfigMerged } from '../../../src/config/configSchema.js'; +import { GIT_LOG_FORMAT_SEPARATOR, GIT_LOG_RECORD_SEPARATOR } from '../../../src/core/git/gitLogHandle.js'; +import { getGitLog, getGitLogs } from '../../../src/core/git/gitLogHandle.js'; +import { RepomixError } from '../../../src/shared/errorHandle.js'; +import { logger } from '../../../src/shared/logger.js'; + +vi.mock('../../../src/shared/logger'); + +describe('gitLogHandle', () => { + beforeEach(() => { + vi.resetAllMocks(); + }); + + describe('getGitLog', () => { + test('should return git log content when directory is a git repository', async () => { + const mockExecGitLog = vi.fn().mockResolvedValue('mock log content'); + const mockIsGitRepository = vi.fn().mockResolvedValue(true); + + const result = await getGitLog('/test/dir', 10, { + execGitLog: mockExecGitLog, + isGitRepository: mockIsGitRepository, + }); + + expect(result).toBe('mock log content'); + expect(mockIsGitRepository).toHaveBeenCalledWith('/test/dir'); + expect(mockExecGitLog).toHaveBeenCalledWith('/test/dir', 10, GIT_LOG_FORMAT_SEPARATOR); + }); + + test('should return empty string when directory is not a git repository', async () => { + const mockExecGitLog = vi.fn(); + const mockIsGitRepository = vi.fn().mockResolvedValue(false); + + const result = await getGitLog('/test/dir', 10, { + execGitLog: mockExecGitLog, + isGitRepository: mockIsGitRepository, + }); + + expect(result).toBe(''); + expect(mockIsGitRepository).toHaveBeenCalledWith('/test/dir'); + expect(mockExecGitLog).not.toHaveBeenCalled(); + expect(logger.trace).toHaveBeenCalledWith('Directory /test/dir is not a git repository'); + }); + + test('should throw error when git log command fails', async () => { + const mockError = new Error('git command failed'); + const mockExecGitLog = vi.fn().mockRejectedValue(mockError); + const mockIsGitRepository = vi.fn().mockResolvedValue(true); + + await expect( + getGitLog('/test/dir', 10, { + execGitLog: mockExecGitLog, + isGitRepository: mockIsGitRepository, + }), + ).rejects.toThrow('git command failed'); + + expect(logger.trace).toHaveBeenCalledWith('Failed to get git log:', 'git command failed'); + }); + }); + + describe('getGitLogs', () => { + test('should return git logs when includeLogs is enabled', async () => { + const mockLogContent = `${GIT_LOG_RECORD_SEPARATOR}2024-01-01 10:00:00 +0900|Initial commit +file1.txt +file2.txt +${GIT_LOG_RECORD_SEPARATOR}2024-01-02 11:00:00 +0900|Add feature +src/feature.ts`; + + const mockGetGitLog = vi.fn().mockResolvedValue(mockLogContent); + const config: RepomixConfigMerged = { + cwd: '/project', + output: { + git: { + includeLogs: true, + includeLogsCount: 25, + }, + }, + } as RepomixConfigMerged; + + const result = await getGitLogs(['/project/src'], config, { + getGitLog: mockGetGitLog, + }); + + expect(result).toEqual({ + logContent: mockLogContent, + commits: [ + { + date: '2024-01-01 10:00:00 +0900', + message: 'Initial commit', + files: ['file1.txt', 'file2.txt'], + }, + { + date: '2024-01-02 11:00:00 +0900', + message: 'Add feature', + files: ['src/feature.ts'], + }, + ], + }); + expect(mockGetGitLog).toHaveBeenCalledWith('/project/src', 25); + }); + + test('should return undefined when includeLogs is disabled', async () => { + const config: RepomixConfigMerged = { + cwd: '/project', + output: { + git: { + includeLogs: false, + }, + }, + } as RepomixConfigMerged; + + const result = await getGitLogs(['/project/src'], config); + + expect(result).toBeUndefined(); + }); + + test('should use default commit count when includeLogsCount is not specified', async () => { + const mockGetGitLog = vi.fn().mockResolvedValue(`${GIT_LOG_RECORD_SEPARATOR}2024-01-01 10:00:00 +0900|Test commit +test.txt`); + const config: RepomixConfigMerged = { + cwd: '/project', + output: { + git: { + includeLogs: true, + }, + }, + } as RepomixConfigMerged; + + await getGitLogs(['/project/src'], config, { + getGitLog: mockGetGitLog, + }); + + expect(mockGetGitLog).toHaveBeenCalledWith('/project/src', 50); + }); + + test('should use first directory as git root', async () => { + const mockGetGitLog = vi.fn().mockResolvedValue(''); + const config: RepomixConfigMerged = { + cwd: '/fallback', + output: { + git: { + includeLogs: true, + }, + }, + } as RepomixConfigMerged; + + await getGitLogs(['/first/dir', '/second/dir'], config, { + getGitLog: mockGetGitLog, + }); + + expect(mockGetGitLog).toHaveBeenCalledWith('/first/dir', 50); + }); + + test('should fallback to config.cwd when no directories provided', async () => { + const mockGetGitLog = vi.fn().mockResolvedValue(''); + const config: RepomixConfigMerged = { + cwd: '/fallback', + output: { + git: { + includeLogs: true, + }, + }, + } as RepomixConfigMerged; + + await getGitLogs([], config, { + getGitLog: mockGetGitLog, + }); + + expect(mockGetGitLog).toHaveBeenCalledWith('/fallback', 50); + }); + + test('should throw RepomixError when getGitLog fails', async () => { + const mockError = new Error('git failed'); + const mockGetGitLog = vi.fn().mockRejectedValue(mockError); + const config: RepomixConfigMerged = { + cwd: '/project', + output: { + git: { + includeLogs: true, + }, + }, + } as RepomixConfigMerged; + + await expect( + getGitLogs(['/project'], config, { + getGitLog: mockGetGitLog, + }), + ).rejects.toThrow(RepomixError); + await expect( + getGitLogs(['/project'], config, { + getGitLog: mockGetGitLog, + }), + ).rejects.toThrow('Failed to get git logs: git failed'); + }); + + test('should handle empty git log output', async () => { + const mockGetGitLog = vi.fn().mockResolvedValue(''); + const config: RepomixConfigMerged = { + cwd: '/project', + output: { + git: { + includeLogs: true, + }, + }, + } as RepomixConfigMerged; + + const result = await getGitLogs(['/project'], config, { + getGitLog: mockGetGitLog, + }); + + expect(result).toEqual({ + logContent: '', + commits: [], + }); + }); + + test('should parse git log correctly with malformed separator content', async () => { + // Test behavior when log content doesn't match expected separator + const malformedLogContent = 'random content without separator'; + + const mockGetGitLog = vi.fn().mockResolvedValue(malformedLogContent); + const config: RepomixConfigMerged = { + cwd: '/project', + output: { + git: { + includeLogs: true, + }, + }, + } as RepomixConfigMerged; + + const result = await getGitLogs(['/project'], config, { + getGitLog: mockGetGitLog, + }); + + // Should return empty commits array when content cannot be parsed properly + expect(result?.commits).toEqual([]); + expect(result?.logContent).toBe(malformedLogContent); + }); + + test('should handle Windows line endings (CRLF) correctly', async () => { + // Test with Windows-style line endings (\r\n) + const mockLogContent = `${GIT_LOG_RECORD_SEPARATOR}2024-01-01 10:00:00 +0900|Windows commit\r\nfile1.txt\r\nfile2.txt`; + + const mockGetGitLog = vi.fn().mockResolvedValue(mockLogContent); + const config: RepomixConfigMerged = { + cwd: '/project', + output: { + git: { + includeLogs: true, + }, + }, + } as RepomixConfigMerged; + + const result = await getGitLogs(['/project'], config, { + getGitLog: mockGetGitLog, + }); + + expect(result?.commits).toEqual([ + { + date: '2024-01-01 10:00:00 +0900', + message: 'Windows commit', + files: ['file1.txt', 'file2.txt'], + }, + ]); + }); + + test('should handle mixed line endings correctly', async () => { + // Test with mixed Unix (\n) and Windows (\r\n) line endings + const mockLogContent = `${GIT_LOG_RECORD_SEPARATOR}2024-01-01 10:00:00 +0900|Mixed line endings\nfile1.txt\r\nfile2.txt`; + + const mockGetGitLog = vi.fn().mockResolvedValue(mockLogContent); + const config: RepomixConfigMerged = { + cwd: '/project', + output: { + git: { + includeLogs: true, + }, + }, + } as RepomixConfigMerged; + + const result = await getGitLogs(['/project'], config, { + getGitLog: mockGetGitLog, + }); + + expect(result?.commits).toEqual([ + { + date: '2024-01-01 10:00:00 +0900', + message: 'Mixed line endings', + files: ['file1.txt', 'file2.txt'], + }, + ]); + }); + }); +}); diff --git a/tests/core/metrics/calculateMetrics.test.ts b/tests/core/metrics/calculateMetrics.test.ts index db6273cc4..32c41cd2c 100644 --- a/tests/core/metrics/calculateMetrics.test.ts +++ b/tests/core/metrics/calculateMetrics.test.ts @@ -48,16 +48,18 @@ describe('calculateMetrics', () => { 'file2.txt': 20, }, gitDiffTokenCount: 0, + gitLogTokenCount: 0, }; const config = createMockConfig(); const gitDiffResult: GitDiffResult | undefined = undefined; - const result = await calculateMetrics(processedFiles, output, progressCallback, config, gitDiffResult, { + const result = await calculateMetrics(processedFiles, output, progressCallback, config, gitDiffResult, undefined, { calculateSelectiveFileMetrics, calculateOutputMetrics: () => Promise.resolve(30), calculateGitDiffMetrics: () => Promise.resolve(0), + calculateGitLogMetrics: () => Promise.resolve({ gitLogTokenCount: 0 }), }); expect(progressCallback).toHaveBeenCalledWith('Calculating metrics...'); diff --git a/tests/core/metrics/diffTokenCount.test.ts b/tests/core/metrics/diffTokenCount.test.ts index 771ff043c..84ad318d6 100644 --- a/tests/core/metrics/diffTokenCount.test.ts +++ b/tests/core/metrics/diffTokenCount.test.ts @@ -100,10 +100,12 @@ index 123..456 100644 workTreeDiffContent: sampleDiff, stagedDiffContent: '', }, + undefined, { calculateSelectiveFileMetrics: vi.fn().mockResolvedValue([]), calculateOutputMetrics: mockCalculateOutputMetrics, calculateGitDiffMetrics: vi.fn().mockResolvedValue(25), + calculateGitLogMetrics: vi.fn().mockResolvedValue({ gitLogTokenCount: 0 }), }, ); @@ -173,10 +175,12 @@ index 123..456 100644 vi.fn(), // Progress callback config, undefined, // No diff content + undefined, { calculateSelectiveFileMetrics: vi.fn().mockResolvedValue([]), calculateOutputMetrics: mockCalculateOutputMetrics, calculateGitDiffMetrics: vi.fn().mockResolvedValue(0), + calculateGitLogMetrics: vi.fn().mockResolvedValue({ gitLogTokenCount: 0 }), }, ); @@ -244,10 +248,12 @@ index 123..456 100644 vi.fn(), // Progress callback config, undefined, // No diff content + undefined, { calculateSelectiveFileMetrics: vi.fn().mockResolvedValue([]), calculateOutputMetrics: mockCalculateOutputMetrics, calculateGitDiffMetrics: vi.fn().mockResolvedValue(0), + calculateGitLogMetrics: vi.fn().mockResolvedValue({ gitLogTokenCount: 0 }), }, ); diff --git a/tests/core/output/diffsInOutput.test.ts b/tests/core/output/diffsInOutput.test.ts index be07c5eb3..5056cbfcd 100644 --- a/tests/core/output/diffsInOutput.test.ts +++ b/tests/core/output/diffsInOutput.test.ts @@ -123,7 +123,7 @@ index 123..456 100644 }; // Call generateOutput with mocked deps - const output = await generateOutput(rootDirs, mockConfig, processedFiles, ['file1.js'], gitDiffResult, { + const output = await generateOutput(rootDirs, mockConfig, processedFiles, ['file1.js'], gitDiffResult, undefined, { buildOutputGeneratorContext: mockBuildOutputGeneratorContext, generateHandlebarOutput: mockGenerateHandlebarOutput, generateParsableXmlOutput: mockGenerateParsableXmlOutput, @@ -186,7 +186,7 @@ index 123..456 100644 }; // Call generateOutput with mocked deps - const output = await generateOutput(rootDirs, mockConfig, processedFiles, ['file1.js'], gitDiffResult, { + const output = await generateOutput(rootDirs, mockConfig, processedFiles, ['file1.js'], gitDiffResult, undefined, { buildOutputGeneratorContext: mockBuildOutputGeneratorContext, generateHandlebarOutput: mockGenerateHandlebarOutput, generateParsableXmlOutput: mockGenerateParsableXmlOutput, diff --git a/tests/core/output/outputGenerate.test.ts b/tests/core/output/outputGenerate.test.ts index 4749e8143..5e168a635 100644 --- a/tests/core/output/outputGenerate.test.ts +++ b/tests/core/output/outputGenerate.test.ts @@ -40,7 +40,15 @@ describe('outputGenerate', () => { }); mockDeps.generateHandlebarOutput.mockResolvedValue('mock output'); - const output = await generateOutput([process.cwd()], mockConfig, mockProcessedFiles, [], undefined, mockDeps); + const output = await generateOutput( + [process.cwd()], + mockConfig, + mockProcessedFiles, + [], + undefined, + undefined, + mockDeps, + ); expect(mockDeps.sortOutputFiles).toHaveBeenCalledWith(mockProcessedFiles, mockConfig); expect(mockDeps.buildOutputGeneratorContext).toHaveBeenCalledWith( @@ -49,6 +57,7 @@ describe('outputGenerate', () => { [], sortedFiles, undefined, + undefined, ); expect(output).toBe('mock output'); }); diff --git a/tests/core/output/outputGenerateDiffs.test.ts b/tests/core/output/outputGenerateDiffs.test.ts index 987fc348b..6c441a1f6 100644 --- a/tests/core/output/outputGenerateDiffs.test.ts +++ b/tests/core/output/outputGenerateDiffs.test.ts @@ -85,6 +85,7 @@ describe('Output Generation with Diffs', () => { mockProcessedFiles, allFilePaths, gitDiffResult, + undefined, mockDeps, ); @@ -112,7 +113,15 @@ describe('Output Generation with Diffs', () => { }); // Generate the output - const output = await generateOutput(rootDirs, mockConfig, mockProcessedFiles, allFilePaths, undefined, mockDeps); + const output = await generateOutput( + rootDirs, + mockConfig, + mockProcessedFiles, + allFilePaths, + undefined, + undefined, + mockDeps, + ); // Verify the diffs are included in the output expect(output).toContain(''); @@ -138,7 +147,15 @@ describe('Output Generation with Diffs', () => { }); // Generate the output - const output = await generateOutput(rootDirs, mockConfig, mockProcessedFiles, allFilePaths, undefined, mockDeps); + const output = await generateOutput( + rootDirs, + mockConfig, + mockProcessedFiles, + allFilePaths, + undefined, + undefined, + mockDeps, + ); // Verify the diffs are included in the output expect(output).toContain('# Git Diffs'); @@ -164,7 +181,15 @@ describe('Output Generation with Diffs', () => { }); // Generate the output - const output = await generateOutput(rootDirs, mockConfig, mockProcessedFiles, allFilePaths, undefined, mockDeps); + const output = await generateOutput( + rootDirs, + mockConfig, + mockProcessedFiles, + allFilePaths, + undefined, + undefined, + mockDeps, + ); // Verify the diffs are included in the output expect(output).toContain('===============\nGit Diffs\n==============='); @@ -200,7 +225,15 @@ describe('Output Generation with Diffs', () => { }); // Generate the output - const output = await generateOutput(rootDirs, mockConfig, mockProcessedFiles, allFilePaths, undefined, mockDeps); + const output = await generateOutput( + rootDirs, + mockConfig, + mockProcessedFiles, + allFilePaths, + undefined, + undefined, + mockDeps, + ); // Verify the diffs are not included in the output expect(output).not.toContain('Git Diffs'); diff --git a/tests/core/packager.test.ts b/tests/core/packager.test.ts index a1820e13b..7fdc6e41f 100644 --- a/tests/core/packager.test.ts +++ b/tests/core/packager.test.ts @@ -79,7 +79,13 @@ describe('packager', () => { expect(mockDeps.generateOutput).toHaveBeenCalled(); expect(mockDeps.calculateMetrics).toHaveBeenCalled(); - expect(mockDeps.validateFileSafety).toHaveBeenCalledWith(mockRawFiles, progressCallback, mockConfig, undefined); + expect(mockDeps.validateFileSafety).toHaveBeenCalledWith( + mockRawFiles, + progressCallback, + mockConfig, + undefined, + undefined, + ); expect(mockDeps.processFiles).toHaveBeenCalledWith(mockSafeRawFiles, mockConfig, progressCallback); expect(mockDeps.generateOutput).toHaveBeenCalledWith( ['root'], @@ -87,6 +93,7 @@ describe('packager', () => { mockProcessedFiles, mockFilePaths, undefined, + undefined, ); expect(mockDeps.writeOutputToDisk).toHaveBeenCalledWith(mockOutput, mockConfig); expect(mockDeps.copyToClipboardIfEnabled).toHaveBeenCalledWith(mockOutput, progressCallback, mockConfig); @@ -96,6 +103,7 @@ describe('packager', () => { progressCallback, mockConfig, undefined, + undefined, ); // Check the result of pack function diff --git a/tests/core/security/securityCheck.test.ts b/tests/core/security/securityCheck.test.ts index 3037819bb..ad929a6e9 100644 --- a/tests/core/security/securityCheck.test.ts +++ b/tests/core/security/securityCheck.test.ts @@ -52,7 +52,9 @@ const mockInitTaskRunner = (numOfTasks: number, workerPath: string) => { describe('runSecurityCheck', () => { it('should identify files with security issues', async () => { - const result = await runSecurityCheck(mockFiles, () => {}, undefined, { initTaskRunner: mockInitTaskRunner }); + const result = await runSecurityCheck(mockFiles, () => {}, undefined, undefined, { + initTaskRunner: mockInitTaskRunner, + }); expect(result).toHaveLength(1); expect(result[0].filePath).toBe('test1.js'); @@ -62,7 +64,7 @@ describe('runSecurityCheck', () => { it('should call progress callback with correct messages', async () => { const progressCallback = vi.fn(); - await runSecurityCheck(mockFiles, progressCallback, undefined, { + await runSecurityCheck(mockFiles, progressCallback, undefined, undefined, { initTaskRunner: mockInitTaskRunner, }); @@ -88,7 +90,7 @@ describe('runSecurityCheck', () => { }; await expect( - runSecurityCheck(mockFiles, () => {}, undefined, { + runSecurityCheck(mockFiles, () => {}, undefined, undefined, { initTaskRunner: mockErrorTaskRunner, }), ).rejects.toThrow('Worker error'); @@ -97,7 +99,7 @@ describe('runSecurityCheck', () => { }); it('should handle empty file list', async () => { - const result = await runSecurityCheck([], () => {}, undefined, { + const result = await runSecurityCheck([], () => {}, undefined, undefined, { initTaskRunner: mockInitTaskRunner, }); @@ -105,7 +107,7 @@ describe('runSecurityCheck', () => { }); it('should log performance metrics in trace mode', async () => { - await runSecurityCheck(mockFiles, () => {}, undefined, { + await runSecurityCheck(mockFiles, () => {}, undefined, undefined, { initTaskRunner: mockInitTaskRunner, }); @@ -116,7 +118,7 @@ describe('runSecurityCheck', () => { it('should process files in parallel', async () => { const startTime = Date.now(); - await runSecurityCheck(mockFiles, () => {}, undefined, { + await runSecurityCheck(mockFiles, () => {}, undefined, undefined, { initTaskRunner: mockInitTaskRunner, }); @@ -130,7 +132,7 @@ describe('runSecurityCheck', () => { it('should not modify original files', async () => { const originalFiles = JSON.parse(JSON.stringify(mockFiles)); - await runSecurityCheck(mockFiles, () => {}, undefined, { + await runSecurityCheck(mockFiles, () => {}, undefined, undefined, { initTaskRunner: mockInitTaskRunner, }); @@ -156,7 +158,7 @@ describe('runSecurityCheck', () => { }; const progressCallback = vi.fn(); - const result = await runSecurityCheck(mockFiles, progressCallback, gitDiffResult, { + const result = await runSecurityCheck(mockFiles, progressCallback, gitDiffResult, undefined, { initTaskRunner: mockInitTaskRunner, }); @@ -178,7 +180,7 @@ describe('runSecurityCheck', () => { }; const progressCallback = vi.fn(); - await runSecurityCheck(mockFiles, progressCallback, gitDiffResult, { + await runSecurityCheck(mockFiles, progressCallback, gitDiffResult, undefined, { initTaskRunner: mockInitTaskRunner, }); @@ -198,7 +200,7 @@ describe('runSecurityCheck', () => { }; const progressCallback = vi.fn(); - await runSecurityCheck(mockFiles, progressCallback, gitDiffResult, { + await runSecurityCheck(mockFiles, progressCallback, gitDiffResult, undefined, { initTaskRunner: mockInitTaskRunner, }); @@ -218,7 +220,7 @@ describe('runSecurityCheck', () => { }; const progressCallback = vi.fn(); - await runSecurityCheck(mockFiles, progressCallback, gitDiffResult, { + await runSecurityCheck(mockFiles, progressCallback, gitDiffResult, undefined, { initTaskRunner: mockInitTaskRunner, }); diff --git a/tests/core/security/validateFileSafety.test.ts b/tests/core/security/validateFileSafety.test.ts index 972316873..88a7e6fae 100644 --- a/tests/core/security/validateFileSafety.test.ts +++ b/tests/core/security/validateFileSafety.test.ts @@ -25,15 +25,16 @@ describe('validateFileSafety', () => { filterOutUntrustedFiles: vi.fn().mockReturnValue(safeRawFiles), }; - const result = await validateFileSafety(rawFiles, progressCallback, config, undefined, deps); + const result = await validateFileSafety(rawFiles, progressCallback, config, undefined, undefined, deps); - expect(deps.runSecurityCheck).toHaveBeenCalledWith(rawFiles, progressCallback, undefined); + expect(deps.runSecurityCheck).toHaveBeenCalledWith(rawFiles, progressCallback, undefined, undefined); expect(deps.filterOutUntrustedFiles).toHaveBeenCalledWith(rawFiles, suspiciousFilesResults); expect(result).toEqual({ safeRawFiles, safeFilePaths: ['file1.txt', 'file2.txt'], suspiciousFilesResults, suspiciousGitDiffResults: [], + suspiciousGitLogResults: [], }); }); }); diff --git a/tests/integration-tests/packager.test.ts b/tests/integration-tests/packager.test.ts index 7aaaa7a21..e8aa97bff 100644 --- a/tests/integration-tests/packager.test.ts +++ b/tests/integration-tests/packager.test.ts @@ -124,19 +124,20 @@ describe.runIf(!isWindows)('packager integration', () => { workTreeDiffContent: '', stagedDiffContent: '', }; - return validateFileSafety(rawFiles, progressCallback, config, gitDiffMock, { + return validateFileSafety(rawFiles, progressCallback, config, gitDiffMock, undefined, { runSecurityCheck: async () => [], filterOutUntrustedFiles, }); }, writeOutputToDisk, copyToClipboardIfEnabled, - calculateMetrics: async (processedFiles, output, progressCallback, config, gitDiffResult) => { + calculateMetrics: async (processedFiles, output, progressCallback, config, gitDiffResult, gitLogResult) => { return { totalFiles: processedFiles.length, totalCharacters: processedFiles.reduce((acc, file) => acc + file.content.length, 0), totalTokens: processedFiles.reduce((acc, file) => acc + file.content.split(/\s+/).length, 0), gitDiffTokenCount: 0, + gitLogTokenCount: 0, fileCharCounts: processedFiles.reduce( (acc, file) => { acc[file.path] = file.content.length; diff --git a/tests/mcp/tools/packCodebaseTool.test.ts b/tests/mcp/tools/packCodebaseTool.test.ts index ad400e284..4225b5bc6 100644 --- a/tests/mcp/tools/packCodebaseTool.test.ts +++ b/tests/mcp/tools/packCodebaseTool.test.ts @@ -39,7 +39,9 @@ describe('PackCodebaseTool', () => { fileTokenCounts: { 'test.js': 50 }, suspiciousFilesResults: [], gitDiffTokenCount: 0, + gitLogTokenCount: 0, suspiciousGitDiffResults: [], + suspiciousGitLogResults: [], processedFiles: [], safeFilePaths: [], }; diff --git a/website/client/src/de/guide/command-line-options.md b/website/client/src/de/guide/command-line-options.md index 7f8e8fdf6..f54ec1558 100644 --- a/website/client/src/de/guide/command-line-options.md +++ b/website/client/src/de/guide/command-line-options.md @@ -28,6 +28,8 @@ - `--instruction-file-path `: Pfad zu einer Datei mit detaillierten benutzerdefinierten Anweisungen - `--include-empty-directories`: Leere Verzeichnisse in die Ausgabe einschließen - `--include-diffs`: Git-Diffs in die Ausgabe einschließen (beinhaltet Arbeitsbaum- und gestufte Änderungen separat) +- `--include-logs`: Git-Logs in die Ausgabe einschließen (beinhaltet Commit-Historie mit Daten, Nachrichten und Dateipfaden) +- `--include-logs-count `: Anzahl der Git-Log-Commits, die eingeschlossen werden sollen (Standard: 50) - `--no-git-sort-by-changes`: Sortierung der Dateien nach Git-Änderungsanzahl deaktivieren (standardmäßig aktiviert) ## Dateiauswahloptionen @@ -87,6 +89,12 @@ find src -name "*.ts" -type f | repomix --stdin git ls-files "*.js" | repomix --stdin echo -e "src/index.ts\nsrc/utils.ts" | repomix --stdin +# Git-Integration +repomix --include-diffs # Git-Diffs für ungespeicherte Änderungen einschließen +repomix --include-logs # Git-Logs einschließen (standardmäßig die letzten 50 Commits) +repomix --include-logs --include-logs-count 10 # Letzten 10 Commits einschließen +repomix --include-diffs --include-logs # Sowohl Diffs als auch Logs einschließen + # Token-Anzahl-Analyse repomix --token-count-tree repomix --token-count-tree 1000 # Nur Dateien/Verzeichnisse mit 1000+ Tokens anzeigen diff --git a/website/client/src/de/guide/configuration.md b/website/client/src/de/guide/configuration.md index 9d6b14335..08f7b80a1 100644 --- a/website/client/src/de/guide/configuration.md +++ b/website/client/src/de/guide/configuration.md @@ -39,6 +39,8 @@ repomix --init --global | `output.git.sortByChanges` | Ob Dateien nach Git-Änderungen sortiert werden sollen. Häufiger geänderte Dateien erscheinen am Ende | `true` | | `output.git.sortByChangesMaxCommits` | Maximale Anzahl zu analysierender Commits für Git-Änderungen. Begrenzt die Historien-Tiefe für bessere Performance | `100` | | `output.git.includeDiffs` | Ob Git-Unterschiede in der Ausgabe enthalten sein sollen. Zeigt Arbeitsverzeichnis- und Stage-Änderungen separat an | `false` | +| `output.git.includeLogs` | Ob Git-Logs in der Ausgabe enthalten sein sollen. Zeigt Commit-Historie mit Daten, Nachrichten und Dateipfaden an | `false` | +| `output.git.includeLogsCount` | Anzahl der Git-Log-Commits, die in die Ausgabe einbezogen werden sollen | `50` | | `include` | Zu einschließende Dateimuster (verwendet [glob-Muster](https://github.com/mrmlnc/fast-glob?tab=readme-ov-file#pattern-syntax)) | `[]` | | `ignore.useGitignore` | Ob Muster aus der `.gitignore`-Datei des Projekts verwendet werden sollen | `true` | | `ignore.useDefaultPatterns` | Ob Standard-Ignorier-Muster (node_modules, .git etc.) verwendet werden sollen | `true` | @@ -97,7 +99,9 @@ Hier ist ein Beispiel einer vollständigen Konfigurationsdatei (`repomix.config. "git": { "sortByChanges": true, "sortByChangesMaxCommits": 100, - "includeDiffs": false + "includeDiffs": false, + "includeLogs": false, + "includeLogsCount": 50 } }, "include": ["**/*"], @@ -186,6 +190,8 @@ Die `output.git`-Konfiguration bietet leistungsstarke Git-bewusste Funktionen: - `sortByChanges`: Wenn auf true gesetzt, werden Dateien nach der Anzahl der Git-Änderungen (Commits, die die Datei modifiziert haben) sortiert. Häufiger geänderte Dateien erscheinen am Ende der Ausgabe. Dies hilft, aktiver entwickelte Dateien zu priorisieren. Standard: `true` - `sortByChangesMaxCommits`: Maximale Anzahl zu analysierender Commits bei der Zählung von Dateiänderungen. Standard: `100` - `includeDiffs`: Wenn auf true gesetzt, werden Git-Unterschiede in die Ausgabe einbezogen (enthält sowohl Arbeitsverzeichnis- als auch Stage-Änderungen separat). Dies ermöglicht es dem Leser, ausstehende Änderungen im Repository zu sehen. Standard: `false` +- `includeLogs`: Wenn auf true gesetzt, werden Git-Logs in die Ausgabe einbezogen. Zeigt Commit-Historie mit Daten, Nachrichten und Dateipfaden für jeden Commit an. Dies hilft der KI, Entwicklungsmuster und Dateibeziehungen zu verstehen. Standard: `false` +- `includeLogsCount`: Die Anzahl der letzten Commits, die in die Git-Logs einbezogen werden sollen. Standard: `50` Beispielkonfiguration: ```json @@ -194,7 +200,9 @@ Beispielkonfiguration: "git": { "sortByChanges": true, "sortByChangesMaxCommits": 100, - "includeDiffs": true + "includeDiffs": true, + "includeLogs": true, + "includeLogsCount": 25 } } } diff --git a/website/client/src/de/guide/output.md b/website/client/src/de/guide/output.md index 4dba32ce7..02425910a 100644 --- a/website/client/src/de/guide/output.md +++ b/website/client/src/de/guide/output.md @@ -37,6 +37,18 @@ src/ + +2025-08-20 00:47:19 +0900|feat(cli): Add --include-logs option for git commit history +README.md +src/cli/cliRun.ts +src/core/git/gitCommand.ts +src/core/git/gitLogHandle.ts +src/core/output/outputGenerate.ts + +2025-08-21 00:09:43 +0900|Merge pull request #795 from yamadashy/chore/ratchet-update-ci +.github/workflows/ratchet-update.yml + + ## Markdown-Format ```bash @@ -64,6 +76,19 @@ src/ ## Datei: src/index.ts ```typescript // Dateiinhalt hier +``` + +# Git-Logs +``` +2025-08-20 00:47:19 +0900|feat(cli): Add --include-logs option for git commit history +README.md +src/cli/cliRun.ts +src/core/git/gitCommand.ts +src/core/git/gitLogHandle.ts +src/core/output/outputGenerate.ts + +2025-08-21 00:09:43 +0900|Merge pull request #795 from yamadashy/chore/ratchet-update-ci +.github/workflows/ratchet-update.yml ``` ## Klartext-Format @@ -97,4 +122,17 @@ Dateien Datei: src/index.ts ================ // Dateiinhalt hier + +================ +Git-Logs +================ +2025-08-20 00:47:19 +0900|feat(cli): Add --include-logs option for git commit history +README.md +src/cli/cliRun.ts +src/core/git/gitCommand.ts +src/core/git/gitLogHandle.ts +src/core/output/outputGenerate.ts + +2025-08-21 00:09:43 +0900|Merge pull request #795 from yamadashy/chore/ratchet-update-ci +.github/workflows/ratchet-update.yml ``` diff --git a/website/client/src/de/guide/usage.md b/website/client/src/de/guide/usage.md index 3f42c23f5..54a97b93b 100644 --- a/website/client/src/de/guide/usage.md +++ b/website/client/src/de/guide/usage.md @@ -93,6 +93,30 @@ repomix --compress repomix --remote yamadashy/repomix --compress ``` +### Git-Integration + +Git-Informationen einschließen, um Entwicklungskontext für KI-Analysen bereitzustellen: + +```bash +# Git-Diffs einschließen (ungespeicherte Änderungen) +repomix --include-diffs + +# Git-Commit-Logs einschließen (standardmäßig die letzten 50 Commits) +repomix --include-logs + +# Bestimmte Anzahl von Commits einschließen +repomix --include-logs --include-logs-count 10 + +# Sowohl Diffs als auch Logs einschließen +repomix --include-diffs --include-logs +``` + +Dies fügt wertvollen Kontext hinzu über: +- **Letzte Änderungen**: Git-Diffs zeigen ungespeicherte Modifikationen +- **Entwicklungsmuster**: Git-Logs zeigen, welche Dateien typischerweise zusammen geändert werden +- **Commit-Historie**: Aktuelle Commit-Nachrichten geben Einblick in den Entwicklungsfokus +- **Dateibeziehungen**: Verstehen, welche Dateien in denselben Commits modifiziert werden + ### Token-Anzahl-Optimierung Das Verständnis der Token-Verteilung Ihrer Codebasis ist entscheidend für die Optimierung von KI-Interaktionen. Verwenden Sie die `--token-count-tree`-Option, um die Token-Nutzung in Ihrem gesamten Projekt zu visualisieren: diff --git a/website/client/src/en/guide/command-line-options.md b/website/client/src/en/guide/command-line-options.md index 989f32139..f45470fca 100644 --- a/website/client/src/en/guide/command-line-options.md +++ b/website/client/src/en/guide/command-line-options.md @@ -28,6 +28,8 @@ - `--instruction-file-path `: Path to a file containing detailed custom instructions - `--include-empty-directories`: Include empty directories in the output - `--include-diffs`: Include git diffs in the output (includes both work tree and staged changes separately) +- `--include-logs`: Include git logs in the output (includes commit history with dates, messages, and file paths) +- `--include-logs-count `: Number of git log commits to include (default: 50) - `--no-git-sort-by-changes`: Disable sorting files by git change count (enabled by default) ## File Selection Options @@ -85,6 +87,12 @@ find src -name "*.ts" -type f | repomix --stdin git ls-files "*.js" | repomix --stdin echo -e "src/index.ts\nsrc/utils.ts" | repomix --stdin +# Git integration +repomix --include-diffs # Include git diffs for uncommitted changes +repomix --include-logs # Include git logs (last 50 commits by default) +repomix --include-logs --include-logs-count 10 # Include last 10 commits +repomix --include-diffs --include-logs # Include both diffs and logs + # Token count analysis repomix --token-count-tree repomix --token-count-tree 1000 # Only show files/directories with 1000+ tokens diff --git a/website/client/src/en/guide/configuration.md b/website/client/src/en/guide/configuration.md index 97eacdb0f..82b2e8661 100644 --- a/website/client/src/en/guide/configuration.md +++ b/website/client/src/en/guide/configuration.md @@ -39,6 +39,8 @@ repomix --init --global | `output.git.sortByChanges` | Whether to sort files by git change count. Files with more changes appear at the bottom | `true` | | `output.git.sortByChangesMaxCommits` | Maximum number of commits to analyze for git changes. Limits the history depth for performance | `100` | | `output.git.includeDiffs` | Whether to include git diffs in the output. Shows both work tree and staged changes separately | `false` | +| `output.git.includeLogs` | Whether to include git logs in the output. Shows commit history with dates, messages, and file paths | `false` | +| `output.git.includeLogsCount` | Number of git log commits to include in the output | `50` | | `include` | Patterns of files to include using [glob patterns](https://github.com/mrmlnc/fast-glob?tab=readme-ov-file#pattern-syntax) | `[]` | | `ignore.useGitignore` | Whether to use patterns from the project's `.gitignore` file | `true` | | `ignore.useDefaultPatterns` | Whether to use default ignore patterns (node_modules, .git, etc.) | `true` | @@ -97,7 +99,9 @@ Here's an example of a complete configuration file (`repomix.config.json`): "git": { "sortByChanges": true, "sortByChangesMaxCommits": 100, - "includeDiffs": false + "includeDiffs": false, + "includeLogs": false, + "includeLogsCount": 50 } }, "include": ["**/*"], @@ -186,6 +190,8 @@ The `output.git` configuration provides powerful Git-aware features: - `sortByChanges`: When true, files are sorted by the number of Git changes (commits that modified the file). Files with more changes appear at the bottom of the output. This helps prioritize more actively developed files. Default: `true` - `sortByChangesMaxCommits`: The maximum number of commits to analyze when counting file changes. Default: `100` - `includeDiffs`: When true, includes Git differences in the output (includes both work tree and staged changes separately). This allows the reader to see pending changes in the repository. Default: `false` +- `includeLogs`: When true, includes Git commit history in the output. Shows commit dates, messages, and file paths for each commit. This helps AI understand development patterns and file relationships. Default: `false` +- `includeLogsCount`: The number of recent commits to include in the git logs. Default: `50` Example configuration: ```json @@ -194,7 +200,9 @@ Example configuration: "git": { "sortByChanges": true, "sortByChangesMaxCommits": 100, - "includeDiffs": true + "includeDiffs": true, + "includeLogs": true, + "includeLogsCount": 25 } } } diff --git a/website/client/src/en/guide/output.md b/website/client/src/en/guide/output.md index 8af14d8de..05284723a 100644 --- a/website/client/src/en/guide/output.md +++ b/website/client/src/en/guide/output.md @@ -32,6 +32,18 @@ src/ // File contents here + + +2025-08-20 00:47:19 +0900|feat(cli): Add --include-logs option for git commit history +README.md +src/cli/cliRun.ts +src/core/git/gitCommand.ts +src/core/git/gitLogHandle.ts +src/core/output/outputGenerate.ts + +2025-08-21 00:09:43 +0900|Merge pull request #795 from yamadashy/chore/ratchet-update-ci +.github/workflows/ratchet-update.yml + ``` ::: tip Why XML? @@ -66,6 +78,19 @@ helper.ts ```typescript // File contents here ``` + +# Git Logs +``` +2025-08-20 00:47:19 +0900|feat(cli): Add --include-logs option for git commit history +README.md +src/cli/cliRun.ts +src/core/git/gitCommand.ts +src/core/git/gitLogHandle.ts +src/core/output/outputGenerate.ts + +2025-08-21 00:09:43 +0900|Merge pull request #795 from yamadashy/chore/ratchet-update-ci +.github/workflows/ratchet-update.yml +``` ``` ## Usage with AI Models @@ -118,4 +143,17 @@ Files File: src/index.ts ================ // File contents here + +================ +Git Logs +================ +2025-08-20 00:47:19 +0900|feat(cli): Add --include-logs option for git commit history +README.md +src/cli/cliRun.ts +src/core/git/gitCommand.ts +src/core/git/gitLogHandle.ts +src/core/output/outputGenerate.ts + +2025-08-21 00:09:43 +0900|Merge pull request #795 from yamadashy/chore/ratchet-update-ci +.github/workflows/ratchet-update.yml ``` diff --git a/website/client/src/en/guide/usage.md b/website/client/src/en/guide/usage.md index 5b8882dc0..4f3856839 100644 --- a/website/client/src/en/guide/usage.md +++ b/website/client/src/en/guide/usage.md @@ -93,6 +93,30 @@ repomix --compress repomix --remote yamadashy/repomix --compress ``` +### Git Integration + +Include Git information to provide development context for AI analysis: + +```bash +# Include git diffs (uncommitted changes) +repomix --include-diffs + +# Include git commit logs (last 50 commits by default) +repomix --include-logs + +# Include specific number of commits +repomix --include-logs --include-logs-count 10 + +# Include both diffs and logs +repomix --include-diffs --include-logs +``` + +This adds valuable context about: +- **Recent changes**: Git diffs show uncommitted modifications +- **Development patterns**: Git logs reveal which files are typically changed together +- **Commit history**: Recent commit messages provide insight into development focus +- **File relationships**: Understanding which files are modified in the same commits + ### Token Count Optimization Understanding your codebase's token distribution is crucial for optimizing AI interactions. Use the `--token-count-tree` option to visualize token usage across your project: diff --git a/website/client/src/es/guide/command-line-options.md b/website/client/src/es/guide/command-line-options.md index cca4e2db8..eb89286f0 100644 --- a/website/client/src/es/guide/command-line-options.md +++ b/website/client/src/es/guide/command-line-options.md @@ -28,6 +28,8 @@ - `--instruction-file-path `: Ruta a un archivo que contiene instrucciones personalizadas detalladas - `--include-empty-directories`: Incluir directorios vacíos en la salida - `--include-diffs`: Incluir diffs de git en la salida (incluye cambios del árbol de trabajo y cambios en stage por separado) +- `--include-logs`: Incluir logs de git en la salida (incluye historial de commits con fechas, mensajes y rutas de archivos) +- `--include-logs-count `: Número de commits de log de git a incluir (predeterminado: 50) - `--no-git-sort-by-changes`: Deshabilitar ordenamiento de archivos por conteo de cambios de git (habilitado por defecto) ## Opciones de selección de archivos @@ -87,6 +89,12 @@ find src -name "*.ts" -type f | repomix --stdin git ls-files "*.js" | repomix --stdin echo -e "src/index.ts\nsrc/utils.ts" | repomix --stdin +# Integración con Git +repomix --include-diffs # Incluir diffs de git para cambios sin commit +repomix --include-logs # Incluir logs de git (últimos 50 commits por defecto) +repomix --include-logs --include-logs-count 10 # Incluir últimos 10 commits +repomix --include-diffs --include-logs # Incluir tanto diffs como logs + # Análisis de conteo de tokens repomix --token-count-tree repomix --token-count-tree 1000 # Solo mostrar archivos/directorios con 1000+ tokens diff --git a/website/client/src/es/guide/configuration.md b/website/client/src/es/guide/configuration.md index 99f10a5f0..f733c9f7f 100644 --- a/website/client/src/es/guide/configuration.md +++ b/website/client/src/es/guide/configuration.md @@ -39,6 +39,8 @@ repomix --init --global | `output.git.sortByChanges` | Indica si se deben ordenar los archivos por número de cambios git. Los archivos con más cambios aparecen al final | `true` | | `output.git.sortByChangesMaxCommits` | Número máximo de commits para analizar al contar cambios git. Limita la profundidad del historial por rendimiento | `100` | | `output.git.includeDiffs` | Indica si se deben incluir las diferencias git en la salida. Muestra por separado los cambios del árbol de trabajo y los cambios preparados | `false` | +| `output.git.includeLogs` | Indica si se deben incluir los logs de git en la salida. Muestra el historial de commits con fechas, mensajes y rutas de archivos | `false` | +| `output.git.includeLogsCount` | Número de commits de log de git a incluir en la salida | `50` | | `include` | Patrones de archivos a incluir usando [patrones glob](https://github.com/mrmlnc/fast-glob?tab=readme-ov-file#pattern-syntax) | `[]` | | `ignore.useGitignore` | Indica si se deben usar los patrones del archivo `.gitignore` del proyecto | `true` | | `ignore.useDefaultPatterns` | Indica si se deben usar los patrones de ignorar predeterminados (node_modules, .git, etc.) | `true` | @@ -97,7 +99,9 @@ Aquí hay un ejemplo de un archivo de configuración completo (`repomix.config.j "git": { "sortByChanges": true, "sortByChangesMaxCommits": 100, - "includeDiffs": false + "includeDiffs": false, + "includeLogs": false, + "includeLogsCount": 50 } }, "include": ["**/*"], @@ -186,6 +190,8 @@ La configuración `output.git` proporciona potentes características relacionada - `sortByChanges`: Cuando es verdadero, los archivos se ordenan por número de cambios Git (commits que modificaron el archivo). Los archivos con más cambios aparecen al final de la salida. Esto ayuda a priorizar los archivos más activamente desarrollados. Predeterminado: `true` - `sortByChangesMaxCommits`: El número máximo de commits para analizar al contar cambios de archivos. Predeterminado: `100` - `includeDiffs`: Cuando es verdadero, incluye las diferencias Git en la salida (incluye por separado los cambios del árbol de trabajo y los cambios preparados). Esto permite al lector ver los cambios pendientes en el repositorio. Predeterminado: `false` +- `includeLogs`: Cuando es verdadero, incluye el historial de commits Git en la salida. Muestra fechas de commits, mensajes y rutas de archivos para cada commit. Esto ayuda a la IA a entender patrones de desarrollo y relaciones entre archivos. Predeterminado: `false` +- `includeLogsCount`: El número de commits recientes a incluir en los logs de git. Predeterminado: `50` Ejemplo de configuración: ```json @@ -194,7 +200,9 @@ Ejemplo de configuración: "git": { "sortByChanges": true, "sortByChangesMaxCommits": 100, - "includeDiffs": true + "includeDiffs": true, + "includeLogs": true, + "includeLogsCount": 25 } } } diff --git a/website/client/src/es/guide/output.md b/website/client/src/es/guide/output.md index 85a0f6cce..0ca54770c 100644 --- a/website/client/src/es/guide/output.md +++ b/website/client/src/es/guide/output.md @@ -32,6 +32,28 @@ src/ // Contenido del archivo aquí + + + +2025-08-20 00:47:19 +0900 +feat(cli): Add --include-logs option for git commit history + +README.md +src/cli/cliRun.ts +src/core/git/gitCommand.ts +src/core/git/gitLogHandle.ts +src/core/output/outputGenerate.ts + + + + +2025-08-21 00:09:43 +0900 +Merge pull request #795 from yamadashy/chore/ratchet-update-ci + +.github/workflows/ratchet-update.yml + + + ``` ::: tip ¿Por qué XML? @@ -66,6 +88,19 @@ helper.ts ```typescript // Contenido del archivo aquí ``` + +# Logs de Git +``` +2025-08-20 00:47:19 +0900|feat(cli): Add --include-logs option for git commit history +README.md +src/cli/cliRun.ts +src/core/git/gitCommand.ts +src/core/git/gitLogHandle.ts +src/core/output/outputGenerate.ts + +2025-08-21 00:09:43 +0900|Merge pull request #795 from yamadashy/chore/ratchet-update-ci +.github/workflows/ratchet-update.yml +``` ``` ## Uso con modelos de IA @@ -85,6 +120,7 @@ Establece el formato predeterminado en `repomix.config.json`: "filePath": "output.xml" } } +``` ## Formato de texto sin formato @@ -117,4 +153,17 @@ Archivos Archivo: src/index.ts ================ // Contenido del archivo aquí + +================ +Logs de Git +================ +2025-08-20 00:47:19 +0900|feat(cli): Add --include-logs option for git commit history +README.md +src/cli/cliRun.ts +src/core/git/gitCommand.ts +src/core/git/gitLogHandle.ts +src/core/output/outputGenerate.ts + +2025-08-21 00:09:43 +0900|Merge pull request #795 from yamadashy/chore/ratchet-update-ci +.github/workflows/ratchet-update.yml ``` diff --git a/website/client/src/es/guide/usage.md b/website/client/src/es/guide/usage.md index da3a4d954..42dc6dd8e 100644 --- a/website/client/src/es/guide/usage.md +++ b/website/client/src/es/guide/usage.md @@ -93,6 +93,30 @@ repomix --compress repomix --remote yamadashy/repomix --compress ``` +### Integración con Git + +Incluye información de Git para proporcionar contexto de desarrollo al análisis de IA: + +```bash +# Incluir diffs de git (cambios sin commit) +repomix --include-diffs + +# Incluir logs de commits de git (últimos 50 commits por defecto) +repomix --include-logs + +# Incluir número específico de commits +repomix --include-logs --include-logs-count 10 + +# Incluir tanto diffs como logs +repomix --include-diffs --include-logs +``` + +Esto añade contexto valioso sobre: +- **Cambios recientes**: Los diffs de Git muestran modificaciones sin commit +- **Patrones de desarrollo**: Los logs de Git revelan qué archivos típicamente se cambian juntos +- **Historial de commits**: Los mensajes de commit recientes proporcionan información sobre el enfoque de desarrollo +- **Relaciones entre archivos**: Entender qué archivos se modifican en los mismos commits + ### Optimización del conteo de tokens Entender la distribución de tokens de tu base de código es crucial para optimizar las interacciones con IA. Usa la opción `--token-count-tree` para visualizar el uso de tokens en todo tu proyecto: diff --git a/website/client/src/fr/guide/command-line-options.md b/website/client/src/fr/guide/command-line-options.md index 4e5bbe6a0..334d3f0a9 100644 --- a/website/client/src/fr/guide/command-line-options.md +++ b/website/client/src/fr/guide/command-line-options.md @@ -28,6 +28,8 @@ - `--instruction-file-path `: Chemin vers un fichier contenant des instructions personnalisées détaillées - `--include-empty-directories`: Inclure les répertoires vides dans la sortie - `--include-diffs`: Inclure les diffs git dans la sortie (inclut les modifications de l'arbre de travail et les modifications indexées séparément) +- `--include-logs`: Inclure les journaux git dans la sortie (inclut l'historique des commits avec les dates, les messages et les chemins de fichiers) +- `--include-logs-count `: Nombre de commits de journaux git à inclure (par défaut : 50) - `--no-git-sort-by-changes`: Désactiver le tri des fichiers par nombre de modifications git (activé par défaut) ## Options de sélection de fichiers @@ -87,6 +89,12 @@ find src -name "*.ts" -type f | repomix --stdin git ls-files "*.js" | repomix --stdin echo -e "src/index.ts\nsrc/utils.ts" | repomix --stdin +# Intégration Git +repomix --include-diffs # Inclure les diffs git pour les modifications non commitées +repomix --include-logs # Inclure les journaux git (derniers 50 commits par défaut) +repomix --include-logs --include-logs-count 10 # Inclure les 10 derniers commits +repomix --include-diffs --include-logs # Inclure à la fois les diffs et les journaux + # Analyse du comptage de jetons repomix --token-count-tree repomix --token-count-tree 1000 # Afficher uniquement les fichiers/répertoires avec 1000+ jetons diff --git a/website/client/src/fr/guide/configuration.md b/website/client/src/fr/guide/configuration.md index eb612e168..017eacf27 100644 --- a/website/client/src/fr/guide/configuration.md +++ b/website/client/src/fr/guide/configuration.md @@ -39,6 +39,8 @@ repomix --init --global | `output.git.sortByChanges` | Indique s'il faut trier les fichiers par nombre de modifications git. Les fichiers avec plus de modifications apparaissent en bas | `true` | | `output.git.sortByChangesMaxCommits` | Nombre maximum de commits à analyser pour les modifications git. Limite la profondeur de l'historique pour les performances | `100` | | `output.git.includeDiffs` | Indique s'il faut inclure les différences git dans la sortie. Montre séparément les modifications de l'arborescence de travail et les modifications indexées | `false` | +| `output.git.includeLogs` | Indique s'il faut inclure les journaux git dans la sortie. Montre l'historique des commits avec les dates, les messages et les chemins de fichiers | `false` | +| `output.git.includeLogsCount` | Nombre de commits de journaux git récents à inclure dans la sortie | `50` | | `include` | Motifs des fichiers à inclure en utilisant les [motifs glob](https://github.com/mrmlnc/fast-glob?tab=readme-ov-file#pattern-syntax) | `[]` | | `ignore.useGitignore` | Indique s'il faut utiliser les motifs du fichier `.gitignore` du projet | `true` | | `ignore.useDefaultPatterns` | Indique s'il faut utiliser les motifs d'ignorance par défaut (node_modules, .git, etc.) | `true` | @@ -97,7 +99,9 @@ Voici un exemple de fichier de configuration complet (`repomix.config.json`) : "git": { "sortByChanges": true, "sortByChangesMaxCommits": 100, - "includeDiffs": false + "includeDiffs": false, + "includeLogs": false, + "includeLogsCount": 50 } }, "include": ["**/*"], @@ -186,6 +190,8 @@ La configuration `output.git` fournit des fonctionnalités puissantes liées à - `sortByChanges` : Lorsque vrai, les fichiers sont triés par nombre de modifications Git (commits qui ont modifié le fichier). Les fichiers avec plus de modifications apparaissent en bas de la sortie. Cela aide à prioriser les fichiers plus activement développés. Par défaut : `true` - `sortByChangesMaxCommits` : Le nombre maximum de commits à analyser lors du comptage des modifications de fichiers. Par défaut : `100` - `includeDiffs` : Lorsque vrai, inclut les différences Git dans la sortie (inclut séparément les modifications de l'arborescence de travail et les modifications indexées). Cela permet au lecteur de voir les modifications en attente dans le dépôt. Par défaut : `false` +- `includeLogs` : Lorsque vrai, inclut l'historique des commits Git dans la sortie. Montre les dates des commits, les messages et les chemins de fichiers pour chaque commit. Cela aide l'IA à comprendre les modèles de développement et les relations entre fichiers. Par défaut : `false` +- `includeLogsCount` : Le nombre de commits récents à inclure dans les journaux git. Par défaut : `50` Exemple de configuration : ```json @@ -194,7 +200,9 @@ Exemple de configuration : "git": { "sortByChanges": true, "sortByChangesMaxCommits": 100, - "includeDiffs": true + "includeDiffs": true, + "includeLogs": true, + "includeLogsCount": 25 } } } diff --git a/website/client/src/fr/guide/output.md b/website/client/src/fr/guide/output.md index 1eb820f4f..2de919591 100644 --- a/website/client/src/fr/guide/output.md +++ b/website/client/src/fr/guide/output.md @@ -29,6 +29,18 @@ src/ // Contenu du fichier ici + + +2025-08-20 00:47:19 +0900|feat(cli): Add --include-logs option for git commit history +README.md +src/cli/cliRun.ts +src/core/git/gitCommand.ts +src/core/git/gitLogHandle.ts +src/core/output/outputGenerate.ts + +2025-08-21 00:09:43 +0900|Merge pull request #795 from yamadashy/chore/ratchet-update-ci +.github/workflows/ratchet-update.yml + ``` ::: tip Pourquoi XML? @@ -59,6 +71,19 @@ helper.ts ```typescript // Contenu du fichier ici ``` + +# Journaux Git +``` +2025-08-20 00:47:19 +0900|feat(cli): Add --include-logs option for git commit history +README.md +src/cli/cliRun.ts +src/core/git/gitCommand.ts +src/core/git/gitLogHandle.ts +src/core/output/outputGenerate.ts + +2025-08-21 00:09:43 +0900|Merge pull request #795 from yamadashy/chore/ratchet-update-ci +.github/workflows/ratchet-update.yml +``` ``` ## Utilisation avec les modèles d'IA @@ -109,4 +134,17 @@ Fichiers Fichier: src/index.ts ================ // Contenu du fichier ici + +================ +Journaux Git +================ +2025-08-20 00:47:19 +0900|feat(cli): Add --include-logs option for git commit history +README.md +src/cli/cliRun.ts +src/core/git/gitCommand.ts +src/core/git/gitLogHandle.ts +src/core/output/outputGenerate.ts + +2025-08-21 00:09:43 +0900|Merge pull request #795 from yamadashy/chore/ratchet-update-ci +.github/workflows/ratchet-update.yml ``` diff --git a/website/client/src/fr/guide/usage.md b/website/client/src/fr/guide/usage.md index e49a1ffad..c2291d0c8 100644 --- a/website/client/src/fr/guide/usage.md +++ b/website/client/src/fr/guide/usage.md @@ -97,6 +97,30 @@ repomix --compress repomix --remote yamadashy/repomix --compress ``` +### Intégration Git + +Inclure des informations Git pour fournir un contexte de développement pour l'analyse IA : + +```bash +# Inclure les diffs git (modifications non commitées) +repomix --include-diffs + +# Inclure les journaux de commits git (derniers 50 commits par défaut) +repomix --include-logs + +# Inclure un nombre spécifique de commits +repomix --include-logs --include-logs-count 10 + +# Inclure à la fois les diffs et les journaux +repomix --include-diffs --include-logs +``` + +Cela ajoute un contexte précieux sur : +- **Modifications récentes** : Les diffs Git montrent les modifications non commitées +- **Modèles de développement** : Les journaux Git révèlent quels fichiers sont généralement modifiés ensemble +- **Historique des commits** : Les messages de commits récents donnent un aperçu du focus de développement +- **Relations entre fichiers** : Comprendre quels fichiers sont modifiés dans les mêmes commits + ### Optimisation du nombre de jetons Comprendre la distribution des jetons de votre base de code est crucial pour optimiser les interactions IA. Utilisez l'option `--token-count-tree` pour visualiser l'utilisation des jetons dans votre projet entier: diff --git a/website/client/src/hi/guide/command-line-options.md b/website/client/src/hi/guide/command-line-options.md index c86e7fdbe..162b02ebf 100644 --- a/website/client/src/hi/guide/command-line-options.md +++ b/website/client/src/hi/guide/command-line-options.md @@ -28,6 +28,8 @@ - `--instruction-file-path `: विस्तृत कस्टम निर्देश वाली फ़ाइल का पथ - `--include-empty-directories`: आउटपुट में खाली डायरेक्टरियां शामिल करें - `--include-diffs`: आउटपुट में git diffs शामिल करें (कार्य ट्री और staged परिवर्तनों को अलग से शामिल करता है) +- `--include-logs`: आउटपुट में git logs शामिल करें (तारीखों, संदेशों और फ़ाइल पथों के साथ कमिट इतिहास शामिल करता है) +- `--include-logs-count `: शामिल करने के लिए git log कमिट की संख्या (डिफ़ॉल्ट: 50) - `--no-git-sort-by-changes`: git परिवर्तन गिनती द्वारा फ़ाइल सॉर्टिंग अक्षम करें (डिफ़ॉल्ट रूप से सक्षम) ## फ़ाइल चयन विकल्प @@ -87,6 +89,12 @@ find src -name "*.ts" -type f | repomix --stdin git ls-files "*.js" | repomix --stdin echo -e "src/index.ts\nsrc/utils.ts" | repomix --stdin +# Git एकीकरण +repomix --include-diffs # अप्रतिबद्ध परिवर्तनों के लिए git diffs शामिल करें +repomix --include-logs # git logs शामिल करें (डिफ़ॉल्ट रूप से अंतिम 50 कमिट) +repomix --include-logs --include-logs-count 10 # अंतिम 10 कमिट शामिल करें +repomix --include-diffs --include-logs # diffs और logs दोनों शामिल करें + # टोकन गिनती विश्लेषण repomix --token-count-tree repomix --token-count-tree 1000 # केवल 1000+ टोकन वाली फ़ाइलें/डायरेक्टरियां दिखाएं diff --git a/website/client/src/hi/guide/configuration.md b/website/client/src/hi/guide/configuration.md index 6503b9361..053d22d77 100644 --- a/website/client/src/hi/guide/configuration.md +++ b/website/client/src/hi/guide/configuration.md @@ -39,6 +39,8 @@ repomix --init --global | `output.git.sortByChanges` | Git परिवर्तन संख्या के अनुसार फ़ाइलों को सॉर्ट करना है या नहीं। अधिक परिवर्तन वाली फ़ाइलें नीचे दिखाई देती हैं | `true` | | `output.git.sortByChangesMaxCommits` | Git परिवर्तनों का विश्लेषण करने के लिए अधिकतम कमिट संख्या। प्रदर्शन के लिए इतिहास गहराई को सीमित करता है | `100` | | `output.git.includeDiffs` | आउटपुट में Git अंतर शामिल करना है या नहीं। वर्क ट्री और स्टेज्ड परिवर्तनों को अलग-अलग दिखाता है | `false` | +| `output.git.includeLogs` | आउटपुट में Git logs शामिल करना है या नहीं। कमिट तारीखों, संदेशों और फ़ाइल पथों को दिखाता है | `false` | +| `output.git.includeLogsCount` | आउटपुट में शामिल करने के लिए git log कमिट की संख्या | `50` | | `include` | शामिल करने के लिए फ़ाइल पैटर्न [glob patterns](https://github.com/mrmlnc/fast-glob?tab=readme-ov-file#pattern-syntax) का उपयोग करके | `[]` | | `ignore.useGitignore` | प्रोजेक्ट की `.gitignore` फ़ाइल के पैटर्न का उपयोग करना है या नहीं | `true` | | `ignore.useDefaultPatterns` | डिफ़ॉल्ट ignore पैटर्न (node_modules, .git, आदि) का उपयोग करना है या नहीं | `true` | @@ -97,7 +99,9 @@ repomix --init --global "git": { "sortByChanges": true, "sortByChangesMaxCommits": 100, - "includeDiffs": false + "includeDiffs": false, + "includeLogs": false, + "includeLogsCount": 50 } }, "include": ["**/*"], @@ -186,6 +190,8 @@ dist/** - `sortByChanges`: जब true है, तो फ़ाइलें Git परिवर्तनों की संख्या (फ़ाइल को modify करने वाले commits) के अनुसार सॉर्ट होती हैं। अधिक परिवर्तन वाली फ़ाइलें आउटपुट के नीचे दिखाई देती हैं। यह अधिक सक्रिय रूप से विकसित फ़ाइलों को प्राथमिकता देने में मदद करता है। डिफ़ॉल्ट: `true` - `sortByChangesMaxCommits`: फ़ाइल परिवर्तनों की गिनती करते समय विश्लेषित करने के लिए अधिकतम commits। डिफ़ॉल्ट: `100` - `includeDiffs`: जब true है, तो आउटपुट में Git अंतर शामिल करता है (work tree और staged changes को अलग-अलग शामिल करता है)। यह reader को repository में pending changes देखने की अनुमति देता है। डिफ़ॉल्ट: `false` +- `includeLogs`: जब true है, तो आउटपुट में Git कमिट इतिहास शामिल करता है। प्रत्येक कमिट के लिए कमिट तारीखें, संदेश और फ़ाइल पथ दिखाता है। यह AI को विकास पैटर्न और फ़ाइल संबंधों को समझने में मदद करता है। डिफ़ॉल्ट: `false` +- `includeLogsCount`: git logs में शामिल करने के लिए हाल के commits की संख्या। डिफ़ॉल्ट: `50` कॉन्फिगरेशन उदाहरण: ```json @@ -194,7 +200,9 @@ dist/** "git": { "sortByChanges": true, "sortByChangesMaxCommits": 100, - "includeDiffs": true + "includeDiffs": true, + "includeLogs": true, + "includeLogsCount": 25 } } } diff --git a/website/client/src/hi/guide/output.md b/website/client/src/hi/guide/output.md index b7d49e289..b7e2d1fb1 100644 --- a/website/client/src/hi/guide/output.md +++ b/website/client/src/hi/guide/output.md @@ -1,173 +1,169 @@ # आउटपुट फॉर्मेट -Repomix तीन आउटपुट फॉर्मेट का समर्थन करता है: XML, मार्कडाउन और प्लेन टेक्स्ट। प्रत्येक फॉर्मेट के अपने फायदे हैं और विभिन्न उपयोग मामलों के लिए अनुकूलित हैं। - -## आउटपुट फॉर्मेट विकल्प - -आप `--style` विकल्प का उपयोग करके आउटपुट फॉर्मेट निर्दिष्ट कर सकते हैं: - -```bash -# XML फॉर्मेट (डिफॉल्ट) -repomix --style xml - -# मार्कडाउन फॉर्मेट -repomix --style markdown - -# प्लेन टेक्स्ट फॉर्मेट -repomix --style plain -``` +Repomix तीन आउटपुट फॉर्मेट का समर्थन करता है: +- XML (डिफ़ॉल्ट) +- मार्कडाउन +- प्लेन टेक्स्ट ## XML फॉर्मेट -XML फॉर्मेट AI मॉडल के साथ उपयोग के लिए अनुशंसित फॉर्मेट है। यह फाइल पथ, फाइल प्रकार और कोड संरचना के बारे में स्पष्ट मेटाडेटा प्रदान करता है। - ```bash repomix --style xml ``` -उदाहरण आउटपुट: +XML फॉर्मेट AI प्रसंस्करण के लिए अनुकूलित है: ```xml - - - import { processRepository } from './core'; - - export function main() { - processRepository('./my-repo'); - } - - - export function processRepository(path: string) { - // कार्यान्वयन विवरण - } - - -``` - -XML फॉर्मेट के लाभ: - -1. **स्पष्ट संरचना**: फाइलों और उनके संबंधों की स्पष्ट संरचना -2. **मेटाडेटा**: फाइल पथ और प्रकार जैसे मेटाडेटा शामिल -3. **AI पार्सिंग**: AI मॉडल द्वारा आसानी से पार्स किया जा सकता है -4. **संदर्भ संरक्षण**: फाइल संदर्भ और संरचना संरक्षित रहती है +यह फ़ाइल संपूर्ण कोडबेस का मर्ज किया गया प्रतिनिधित्व है... + + +(मेटाडेटा और AI निर्देश) + + + +src/ + index.ts + utils/ + helper.ts + + + + +// फ़ाइल सामग्री यहाँ + + + + + +2025-08-20 00:47:19 +0900 +feat(cli): Add --include-logs option for git commit history + +README.md +src/cli/cliRun.ts +src/core/git/gitCommand.ts +src/core/git/gitLogHandle.ts +src/core/output/outputGenerate.ts + + + + +2025-08-21 00:09:43 +0900 +Merge pull request #795 from yamadashy/chore/ratchet-update-ci + +.github/workflows/ratchet-update.yml + + + +``` + +::: tip XML क्यों? +XML टैग Claude जैसे AI मॉडल को सामग्री को अधिक सटीक रूप से पार्स करने में मदद करते हैं। [Claude डॉक्यूमेंटेशन](https://docs.anthropic.com/en/docs/build-with-claude/prompt-engineering/use-xml-tags) संरचित प्रॉम्प्ट के लिए XML टैग का उपयोग करने की सिफारिश करता है। +::: ## मार्कडाउन फॉर्मेट -मार्कडाउन फॉर्मेट मानव पठनीयता और AI प्रोसेसिंग के बीच एक संतुलन प्रदान करता है। यह GitHub और अन्य मार्कडाउन व्यूअर में अच्छी तरह से प्रदर्शित होता है। - ```bash repomix --style markdown ``` -उदाहरण आउटपुट: +मार्कडाउन पठनीय फॉर्मेटिंग प्रदान करता है: ```markdown -# Repository +यह फ़ाइल संपूर्ण कोडबेस का मर्ज किया गया प्रतिनिधित्व है... -## src/index.ts -```typescript -import { processRepository } from './core'; +# फ़ाइल सारांश +(मेटाडेटा और AI निर्देश) -export function main() { - processRepository('./my-repo'); -} -``` - -## src/core.ts -```typescript -export function processRepository(path: string) { - // कार्यान्वयन विवरण -} +# डायरेक्टरी संरचना ``` +src/ +index.ts +utils/ +helper.ts ``` -मार्कडाउन फॉर्मेट के लाभ: +# फ़ाइलें -1. **पठनीयता**: मानव पाठकों के लिए अधिक पठनीय -2. **प्रदर्शन**: GitHub और अन्य मार्कडाउन व्यूअर में अच्छी तरह से प्रदर्शित होता है -3. **सिंटैक्स हाइलाइटिंग**: कोड ब्लॉक में सिंटैक्स हाइलाइटिंग का समर्थन -4. **संपादन योग्यता**: आसानी से संपादित किया जा सकता है - -## प्लेन टेक्स्ट फॉर्मेट - -प्लेन टेक्स्ट फॉर्मेट सबसे सरल आउटपुट विकल्प है। यह फाइल पथ और सामग्री को बिना किसी विशेष फॉर्मेटिंग के प्रस्तुत करता है। - -```bash -repomix --style plain +## फ़ाइल: src/index.ts +```typescript +// फ़ाइल सामग्री यहाँ ``` -उदाहरण आउटपुट: - +# Git Logs ``` ---- src/index.ts --- -import { processRepository } from './core'; - -export function main() { - processRepository('./my-repo'); -} +2025-08-20 00:47:19 +0900|feat(cli): Add --include-logs option for git commit history +README.md +src/cli/cliRun.ts +src/core/git/gitCommand.ts +src/core/git/gitLogHandle.ts +src/core/output/outputGenerate.ts ---- src/core.ts --- -export function processRepository(path: string) { - // कार्यान्वयन विवरण -} +2025-08-21 00:09:43 +0900|Merge pull request #795 from yamadashy/chore/ratchet-update-ci +.github/workflows/ratchet-update.yml +``` ``` -प्लेन टेक्स्ट फॉर्मेट के लाभ: - -1. **सादगी**: कोई विशेष फॉर्मेटिंग नहीं -2. **संगतता**: सभी टेक्स्ट एडिटर और टूल के साथ संगत -3. **आकार**: आमतौर पर सबसे छोटा फाइल आकार +## AI मॉडल के साथ उपयोग -## डिफॉल्ट आउटपुट फॉर्मेट सेट करना +प्रत्येक फॉर्मेट AI मॉडल के साथ अच्छी तरह से काम करता है, लेकिन विचार करें: +- Claude के लिए XML का उपयोग करें (सर्वोत्तम पार्सिंग सटीकता) +- सामान्य पठनीयता के लिए मार्कडाउन का उपयोग करें +- सादगी और सार्वभौमिक संगतता के लिए प्लेन टेक्स्ट का उपयोग करें -आप अपने `repomix.config.json` में डिफॉल्ट आउटपुट फॉर्मेट सेट कर सकते हैं: +## अनुकूलन +`repomix.config.json` में डिफ़ॉल्ट फॉर्मेट सेट करें: ```json { "output": { - "style": "markdown" + "style": "xml", + "filePath": "output.xml" } } ``` -## आउटपुट फाइल नाम - -आप `--output-file` विकल्प का उपयोग करके आउटपुट फाइल का नाम निर्दिष्ट कर सकते हैं: +## प्लेन टेक्स्ट फॉर्मेट ```bash -repomix --output-file my-repo-code.xml -``` - -डिफॉल्ट फाइल नाम `repomix-output.xml`, `repomix-output.md`, या `repomix-output.txt` है, जो चुने गए आउटपुट फॉर्मेट पर निर्भर करता है। - -## AI मॉडल के साथ आउटपुट का उपयोग - -### XML के साथ - -XML फॉर्मेट AI मॉडल के साथ उपयोग के लिए अनुशंसित है। यह फाइल संरचना और संदर्भ को संरक्षित करता है, जिससे AI को कोडबेस को बेहतर ढंग से समझने में मदद मिलती है। - -``` -इस XML फाइल में मेरे रिपॉजिटरी की सभी फाइलें हैं। कृपया इसकी समीक्षा करें और सुधार के लिए सुझाव दें। -``` - -### मार्कडाउन के साथ - -मार्कडाउन फॉर्मेट मानव पठनीयता और AI प्रोसेसिंग के बीच एक अच्छा संतुलन प्रदान करता है। - -``` -इस मार्कडाउन फाइल में मेरे रिपॉजिटरी की सभी फाइलें हैं। कृपया इसकी समीक्षा करें और सुधार के लिए सुझाव दें। +repomix --style plain ``` -### प्लेन टेक्स्ट के साथ - -प्लेन टेक्स्ट फॉर्मेट सबसे सरल है लेकिन फाइल संरचना और संदर्भ के बारे में कम जानकारी प्रदान करता है। - +आउटपुट संरचना: +```text +यह फ़ाइल संपूर्ण कोडबेस का मर्ज किया गया प्रतिनिधित्व है... + +================ +फ़ाइल सारांश +================ +(मेटाडेटा और AI निर्देश) + +================ +डायरेक्टरी संरचना +================ +src/ + index.ts + utils/ + helper.ts + +================ +फ़ाइलें +================ + +================ +फ़ाइल: src/index.ts +================ +// फ़ाइल सामग्री यहाँ + +================ +Git Logs +================ +2025-08-20 00:47:19 +0900|feat(cli): Add --include-logs option for git commit history +README.md +src/cli/cliRun.ts +src/core/git/gitCommand.ts +src/core/git/gitLogHandle.ts +src/core/output/outputGenerate.ts + +2025-08-21 00:09:43 +0900|Merge pull request #795 from yamadashy/chore/ratchet-update-ci +.github/workflows/ratchet-update.yml ``` -इस टेक्स्ट फाइल में मेरे रिपॉजिटरी की सभी फाइलें हैं। कृपया इसकी समीक्षा करें और सुधार के लिए सुझाव दें। -``` - -## अगला क्या है? - -- [कमांड लाइन विकल्पों](command-line-options.md) के बारे में अधिक जानें -- [कॉन्फिगरेशन विकल्पों](configuration.md) का अन्वेषण करें -- [सुरक्षा सुविधाओं](security.md) के बारे में जानें diff --git a/website/client/src/hi/guide/usage.md b/website/client/src/hi/guide/usage.md index 2708685d4..83804324f 100644 --- a/website/client/src/hi/guide/usage.md +++ b/website/client/src/hi/guide/usage.md @@ -78,6 +78,30 @@ repomix --compress repomix --remote yamadashy/repomix --compress ``` +### Git एकीकरण + +AI विश्लेषण के लिए विकास संदर्भ प्रदान करने हेतु Git जानकारी शामिल करें: + +```bash +# git diffs शामिल करें (अप्रतिबद्ध परिवर्तन) +repomix --include-diffs + +# git कमिट logs शामिल करें (डिफ़ॉल्ट रूप से अंतिम 50 कमिट) +repomix --include-logs + +# विशिष्ट संख्या में कमिट शामिल करें +repomix --include-logs --include-logs-count 10 + +# diffs और logs दोनों शामिल करें +repomix --include-diffs --include-logs +``` + +यह निम्नलिखित के बारे में महत्वपूर्ण संदर्भ जोड़ता है: +- **हाल के परिवर्तन**: Git diffs अप्रतिबद्ध संशोधन दिखाते हैं +- **विकास पैटर्न**: Git logs प्रकट करते हैं कि कौन सी फ़ाइलें आमतौर पर एक साथ बदली जाती हैं +- **कमिट इतिहास**: हाल के कमिट संदेश विकास फोकस में अंतर्दृष्टि प्रदान करते हैं +- **फ़ाइल संबंध**: समझना कि कौन सी फ़ाइलें एक ही कमिट में संशोधित होती हैं + ### टोकन संख्या अनुकूलन अपने कोडबेस के टोकन वितरण को समझना AI इंटरैक्शन को अनुकूलित करने के लिए महत्वपूर्ण है। अपने पूरे प्रोजेक्ट में टोकन उपयोग को देखने के लिए `--token-count-tree` विकल्प का उपयोग करें: diff --git a/website/client/src/id/guide/command-line-options.md b/website/client/src/id/guide/command-line-options.md index d4e04afd8..991cd761b 100644 --- a/website/client/src/id/guide/command-line-options.md +++ b/website/client/src/id/guide/command-line-options.md @@ -28,6 +28,8 @@ - `--instruction-file-path `: Jalur ke file yang berisi instruksi kustom terperinci - `--include-empty-directories`: Menyertakan direktori kosong dalam output - `--include-diffs`: Menyertakan diff git dalam output (menyertakan perubahan pohon kerja dan perubahan staged secara terpisah) +- `--include-logs`: Menyertakan log git dalam output (menyertakan riwayat commit dengan tanggal, pesan, dan jalur file) +- `--include-logs-count `: Jumlah commit log git yang akan disertakan (default: 50) - `--no-git-sort-by-changes`: Menonaktifkan pengurutan file berdasarkan jumlah perubahan git (diaktifkan secara default) ## Opsi Seleksi File @@ -87,6 +89,12 @@ find src -name "*.ts" -type f | repomix --stdin git ls-files "*.js" | repomix --stdin echo -e "src/index.ts\nsrc/utils.ts" | repomix --stdin +# Integrasi Git +repomix --include-diffs # Sertakan diff git untuk perubahan yang belum di-commit +repomix --include-logs # Sertakan log git (50 commit terakhir secara default) +repomix --include-logs --include-logs-count 10 # Sertakan 10 commit terakhir +repomix --include-diffs --include-logs # Sertakan diff dan log + # Analisis jumlah token repomix --token-count-tree repomix --token-count-tree 1000 # Hanya tampilkan file/direktori dengan 1000+ token diff --git a/website/client/src/id/guide/configuration.md b/website/client/src/id/guide/configuration.md index 832d8948f..83c178993 100644 --- a/website/client/src/id/guide/configuration.md +++ b/website/client/src/id/guide/configuration.md @@ -39,6 +39,8 @@ repomix --init --global | `output.git.sortByChanges` | Apakah akan mengurutkan file berdasarkan jumlah perubahan git. File dengan lebih banyak perubahan muncul di bagian bawah | `true` | | `output.git.sortByChangesMaxCommits` | Jumlah maksimum commit untuk dianalisis saat menghitung perubahan git. Membatasi kedalaman riwayat untuk performa | `100` | | `output.git.includeDiffs` | Apakah akan menyertakan perbedaan git dalam output. Menampilkan perubahan work tree dan staged secara terpisah | `false` | +| `output.git.includeLogs` | Apakah akan menyertakan log git dalam output. Menampilkan riwayat commit dengan tanggal, pesan, dan jalur file | `false` | +| `output.git.includeLogsCount` | Jumlah commit log git yang akan disertakan dalam output | `50` | | `include` | Pola file untuk disertakan menggunakan [pola glob](https://github.com/mrmlnc/fast-glob?tab=readme-ov-file#pattern-syntax) | `[]` | | `ignore.useGitignore` | Apakah akan menggunakan pola dari file `.gitignore` proyek | `true` | | `ignore.useDefaultPatterns` | Apakah akan menggunakan pola ignore default (node_modules, .git, dll.) | `true` | @@ -97,7 +99,9 @@ Berikut adalah contoh file konfigurasi lengkap (`repomix.config.json`): "git": { "sortByChanges": true, "sortByChangesMaxCommits": 100, - "includeDiffs": false + "includeDiffs": false, + "includeLogs": false, + "includeLogsCount": 50 } }, "include": ["**/*"], @@ -186,6 +190,8 @@ Konfigurasi `output.git` menyediakan fitur Git-aware yang kuat: - `sortByChanges`: Ketika true, file diurutkan berdasarkan jumlah perubahan Git (commit yang memodifikasi file). File dengan lebih banyak perubahan muncul di bagian bawah output. Ini membantu memprioritaskan file yang lebih aktif dikembangkan. Default: `true` - `sortByChangesMaxCommits`: Jumlah maksimum commit untuk dianalisis saat menghitung perubahan file. Default: `100` - `includeDiffs`: Ketika true, menyertakan perbedaan Git dalam output (termasuk perubahan work tree dan staged secara terpisah). Ini memungkinkan pembaca melihat perubahan yang tertunda di repository. Default: `false` +- `includeLogs`: Ketika true, menyertakan riwayat commit Git dalam output. Menampilkan tanggal commit, pesan, dan jalur file untuk setiap commit. Ini membantu AI memahami pola pengembangan dan hubungan file. Default: `false` +- `includeLogsCount`: Jumlah commit terbaru yang akan disertakan dalam log git. Default: `50` Contoh konfigurasi: ```json @@ -194,7 +200,9 @@ Contoh konfigurasi: "git": { "sortByChanges": true, "sortByChangesMaxCommits": 100, - "includeDiffs": true + "includeDiffs": true, + "includeLogs": true, + "includeLogsCount": 25 } } } diff --git a/website/client/src/id/guide/output.md b/website/client/src/id/guide/output.md index 30160fc94..544c66243 100644 --- a/website/client/src/id/guide/output.md +++ b/website/client/src/id/guide/output.md @@ -1,113 +1,170 @@ # Format Output +Repomix mendukung tiga format output: +- XML (default) +- Markdown +- Plain Text -Repomix mendukung beberapa format output untuk memenuhi berbagai kebutuhan. Anda dapat memilih format yang paling sesuai dengan kasus penggunaan Anda. - -## Format yang Tersedia - -Repomix mendukung tiga format output utama: - -1. **XML** (default): Format terstruktur yang ideal untuk pemrosesan AI -2. **Markdown**: Format yang mudah dibaca manusia dengan dukungan sintaks -3. **Teks Biasa**: Format sederhana tanpa markup - -## Memilih Format - -Anda dapat menentukan format output menggunakan flag `--style`: +## Format XML ```bash -# Format XML (default) repomix --style xml - -# Format Markdown -repomix --style markdown - -# Format teks biasa -repomix --style plain ``` -## Contoh Output - -### Format XML +Format XML dioptimalkan untuk pemrosesan AI: ```xml - - - 10 - 500 - 5000 - - - - // Kode sumber di sini - - - - +Ini adalah representasi gabungan dari seluruh codebase... + + +(Metadata dan instruksi AI) + + + +src/ + index.ts + utils/ + helper.ts + + + + +// Konten file di sini + + + + + +2025-08-20 00:47:19 +0900 +feat(cli): Add --include-logs option for git commit history + +README.md +src/cli/cliRun.ts +src/core/git/gitCommand.ts +src/core/git/gitLogHandle.ts +src/core/output/outputGenerate.ts + + + + +2025-08-21 00:09:43 +0900 +Merge pull request #795 from yamadashy/chore/ratchet-update-ci + +.github/workflows/ratchet-update.yml + + + ``` -### Format Markdown +::: tip Mengapa XML? +Tag XML membantu model AI seperti Claude mem-parsing konten dengan lebih akurat. [Dokumentasi Claude](https://docs.anthropic.com/en/docs/build-with-claude/prompt-engineering/use-xml-tags) merekomendasikan penggunaan tag XML untuk prompt terstruktur. +::: -```markdown -# Repomix Output: example-repo +## Format Markdown -Generated on: 2023-04-01T12:00:00Z +```bash +repomix --style markdown +``` -## Stats -- Files: 10 -- Lines: 500 -- Tokens: 5000 +Markdown menyediakan format yang mudah dibaca: -## Files +```markdown +Ini adalah representasi gabungan dari seluruh codebase... -### src/index.js (JavaScript, 120 tokens) +# File Summary +(Metadata dan instruksi AI) -```javascript -// Kode sumber di sini +# Directory Structure ``` - - +src/ +index.ts +utils/ +helper.ts ``` -### Format Teks Biasa +# Files +## File: src/index.ts +```typescript +// Konten file di sini ``` -Repomix Output: example-repo -Generated on: 2023-04-01T12:00:00Z - -Stats: -- Files: 10 -- Lines: 500 -- Tokens: 5000 - -Files: -src/index.js (JavaScript, 120 tokens) ------------------------------------- -// Kode sumber di sini - -// File lainnya +# Git Logs +``` +2025-08-20 00:47:19 +0900|feat(cli): Add --include-logs option for git commit history +README.md +src/cli/cliRun.ts +src/core/git/gitCommand.ts +src/core/git/gitLogHandle.ts +src/core/output/outputGenerate.ts + +2025-08-21 00:09:43 +0900|Merge pull request #795 from yamadashy/chore/ratchet-update-ci +.github/workflows/ratchet-update.yml +``` ``` -## Konfigurasi +## Penggunaan dengan Model AI -Anda dapat menentukan format output dalam file konfigurasi Anda: +Setiap format bekerja dengan baik dengan model AI, tetapi pertimbangkan: +- Gunakan XML untuk Claude (akurasi parsing terbaik) +- Gunakan Markdown untuk keterbacaan umum +- Gunakan Plain Text untuk kesederhanaan dan kompatibilitas universal +## Kustomisasi + +Atur format default di `repomix.config.json`: ```json { "output": { - "style": "markdown", - "filePath": "custom-output.md" + "style": "xml", + "filePath": "output.xml" } } ``` -## Opsi Terkait +## Format Plain Text + +```bash +repomix --style plain +``` -Beberapa opsi terkait yang dapat memengaruhi output: +Struktur output: +```text +Ini adalah representasi gabungan dari seluruh codebase... + +================ +File Summary +================ +(Metadata dan instruksi AI) + +================ +Directory Structure +================ +src/ + index.ts + utils/ + helper.ts + +================ +Files +================ + +================ +File: src/index.ts +================ +// Konten file di sini + +================ +Git Logs +================ +2025-08-20 00:47:19 +0900|feat(cli): Add --include-logs option for git commit history +README.md +src/cli/cliRun.ts +src/core/git/gitCommand.ts +src/core/git/gitLogHandle.ts +src/core/output/outputGenerate.ts + +2025-08-21 00:09:43 +0900|Merge pull request #795 from yamadashy/chore/ratchet-update-ci +.github/workflows/ratchet-update.yml +``` -- `--output`, `-o`: Menentukan jalur file output -- `--no-line-numbers`: Menonaktifkan nomor baris -- `--remove-comments`: Menghapus komentar dari kode sumber -- `--top-files`: Menentukan jumlah file teratas yang akan ditampilkan di ringkasan -- `--copy-to-clipboard`: Menyalin output ke clipboard diff --git a/website/client/src/id/guide/usage.md b/website/client/src/id/guide/usage.md index 40a851302..48cede537 100644 --- a/website/client/src/id/guide/usage.md +++ b/website/client/src/id/guide/usage.md @@ -108,6 +108,30 @@ repomix --compress repomix --remote yamadashy/repomix --compress ``` +### Integrasi Git + +Sertakan informasi Git untuk memberikan konteks pengembangan bagi analisis AI: + +```bash +# Sertakan diff git (perubahan yang belum di-commit) +repomix --include-diffs + +# Sertakan log commit git (50 commit terakhir secara default) +repomix --include-logs + +# Sertakan jumlah commit tertentu +repomix --include-logs --include-logs-count 10 + +# Sertakan diff dan log +repomix --include-diffs --include-logs +``` + +Ini menambahkan konteks berharga tentang: +- **Perubahan terbaru**: Diff Git menunjukkan modifikasi yang belum di-commit +- **Pola pengembangan**: Log Git mengungkapkan file mana yang biasanya diubah bersamaan +- **Riwayat commit**: Pesan commit terbaru memberikan wawasan tentang fokus pengembangan +- **Hubungan file**: Memahami file mana yang dimodifikasi dalam commit yang sama + ### Optimisasi Jumlah Token Memahami distribusi token dari basis kode Anda sangat penting untuk mengoptimalkan interaksi AI. Gunakan opsi `--token-count-tree` untuk memvisualisasikan penggunaan token di seluruh proyek Anda: @@ -144,19 +168,43 @@ Ini membantu Anda: ## Format Output -Pilih format output yang Anda inginkan: - +### XML (Default) ```bash -# Format XML (default) repomix --style xml +``` -# Format Markdown +### Markdown +```bash repomix --style markdown +``` -# Format teks biasa +### Plain Text +```bash repomix --style plain ``` +## Opsi Tambahan + +### Hapus Komentar +```bash +repomix --remove-comments +``` + +### Tampilkan Nomor Baris +```bash +repomix --output-show-line-numbers +``` + +### Salin ke Clipboard +```bash +repomix --copy +``` + +### Nonaktifkan Pemeriksaan Keamanan +```bash +repomix --no-security-check +``` + ## Konfigurasi Untuk menginisialisasi file konfigurasi baru (`repomix.config.json`): diff --git a/website/client/src/ja/guide/command-line-options.md b/website/client/src/ja/guide/command-line-options.md index 8eee77782..f3d9864f0 100644 --- a/website/client/src/ja/guide/command-line-options.md +++ b/website/client/src/ja/guide/command-line-options.md @@ -28,6 +28,8 @@ - `--instruction-file-path `: 詳細なカスタム指示を含むファイルのパス - `--include-empty-directories`: 空のディレクトリを出力に含める - `--include-diffs`: Git差分を出力に含める(ワークツリーとステージングされた変更を別々に含む) +- `--include-logs`: Gitログを出力に含める(日時、メッセージ、ファイルパスを含むコミット履歴) +- `--include-logs-count `: 含めるGitログのコミット数(デフォルト: 50) - `--no-git-sort-by-changes`: Gitの変更回数によるファイルのソートを無効化(デフォルトで有効) ## ファイル選択オプション @@ -70,6 +72,11 @@ repomix --stdout | llm "このコードについて説明してください" # 圧縮を使用したカスタム出力 repomix --compress +# Git統合機能 +repomix --include-logs # Gitログを含める(デフォルトで50コミット) +repomix --include-logs --include-logs-count 10 # 最新10コミットを含める +repomix --include-diffs --include-logs # 差分とログの両方を含める + # 特定のファイルを処理 repomix --include "src/**/*.ts" --ignore "**/*.test.ts" diff --git a/website/client/src/ja/guide/configuration.md b/website/client/src/ja/guide/configuration.md index 8d887aecb..6ce3a61ce 100644 --- a/website/client/src/ja/guide/configuration.md +++ b/website/client/src/ja/guide/configuration.md @@ -39,6 +39,8 @@ repomix --init --global | `output.git.sortByChanges` | Gitの変更回数でファイルをソートするかどうか。変更が多いファイルが下部に表示されます | `true` | | `output.git.sortByChangesMaxCommits` | Gitの変更を分析する最大コミット数。パフォーマンスのために履歴の深さを制限します | `100` | | `output.git.includeDiffs` | 出力にGitの差分を含めるかどうか。作業ツリーとステージング済みの変更を別々に表示します | `false` | +| `output.git.includeLogs` | 出力にGitログを含めるかどうか。コミット履歴の日時、メッセージ、ファイルパスを表示します | `false` | +| `output.git.includeLogsCount` | 含めるGitログのコミット数。開発パターンを理解するための履歴の深さを制限します | `50` | | `include` | 含めるファイルのパターン([globパターン](https://github.com/mrmlnc/fast-glob?tab=readme-ov-file#pattern-syntax)を使用) | `[]` | | `ignore.useGitignore` | プロジェクトの`.gitignore`ファイルのパターンを使用するかどうか | `true` | | `ignore.useDefaultPatterns` | デフォルトの除外パターン(node_modules、.gitなど)を使用するかどうか | `true` | @@ -97,7 +99,9 @@ repomix --init --global "git": { "sortByChanges": true, "sortByChangesMaxCommits": 100, - "includeDiffs": false + "includeDiffs": false, + "includeLogs": false, + "includeLogsCount": 50 } }, "include": ["**/*"], @@ -186,6 +190,8 @@ dist/** - `sortByChanges`: trueに設定すると、ファイルはGitの変更回数(そのファイルを変更したコミット数)でソートされます。変更が多いファイルが出力の下部に表示されます。これは、より活発に開発されているファイルを優先するのに役立ちます。デフォルト: `true` - `sortByChangesMaxCommits`: ファイルの変更回数を数える際に分析する最大コミット数。デフォルト: `100` - `includeDiffs`: trueに設定すると、Git差分を出力に含めます(ワークツリーとステージング済みの変更を別々に含みます)。これにより、リポジトリの保留中の変更を確認できます。デフォルト: `false` +- `includeLogs`: trueに設定すると、Gitログを出力に含めます。コミット履歴の日時、メッセージ、ファイルパスが表示され、AIがどのファイルが一緒に変更される傾向があるかを理解できます。デフォルト: `false` +- `includeLogsCount`: 含めるGitログのコミット数。開発パターンの分析に使用する履歴の深さを制御します。デフォルト: `50` 設定例: ```json @@ -194,7 +200,9 @@ dist/** "git": { "sortByChanges": true, "sortByChangesMaxCommits": 100, - "includeDiffs": true + "includeDiffs": true, + "includeLogs": true, + "includeLogsCount": 30 } } } diff --git a/website/client/src/ja/guide/output.md b/website/client/src/ja/guide/output.md index 3cdb12f17..426cfa140 100644 --- a/website/client/src/ja/guide/output.md +++ b/website/client/src/ja/guide/output.md @@ -33,6 +33,28 @@ src/ + + +2025-08-20 00:47:19 +0900 +feat(cli): Add --include-logs option for git commit history + +README.md +src/cli/cliRun.ts +src/core/git/gitCommand.ts +src/core/git/gitLogHandle.ts +src/core/output/outputGenerate.ts + + + + +2025-08-21 00:09:43 +0900 +Merge pull request #795 from yamadashy/chore/ratchet-update-ci + +.github/workflows/ratchet-update.yml + + + + (output.instructionFilePathで指定されたカスタム指示) @@ -70,6 +92,24 @@ helper.ts ```typescript // ファイルの内容がここに表示されます ``` + +# Gitログ + +## コミット: 2025-08-20 00:47:19 +0900 +**メッセージ:** feat(cli): Add --include-logs option for git commit history + +**ファイル:** +- README.md +- src/cli/cliRun.ts +- src/core/git/gitCommand.ts +- src/core/git/gitLogHandle.ts +- src/core/output/outputGenerate.ts + +## コミット: 2025-08-21 00:09:43 +0900 +**メッセージ:** Merge pull request #795 from yamadashy/chore/ratchet-update-ci + +**ファイル:** +- .github/workflows/ratchet-update.yml ``` ## AIモデルとの使用 @@ -127,4 +167,25 @@ File: src/index.js File: src/utils.js ================ // ファイルの内容がここに表示されます + +================ +Gitログ +================ +================ +Date: 2025-08-20 00:47:19 +0900 +Message: feat(cli): Add --include-logs option for git commit history +Files: + - README.md + - src/cli/cliRun.ts + - src/core/git/gitCommand.ts + - src/core/git/gitLogHandle.ts + - src/core/output/outputGenerate.ts +================ + +================ +Date: 2025-08-21 00:09:43 +0900 +Message: Merge pull request #795 from yamadashy/chore/ratchet-update-ci +Files: + - .github/workflows/ratchet-update.yml +================ ``` diff --git a/website/client/src/ja/guide/usage.md b/website/client/src/ja/guide/usage.md index dcf1844c7..67736075e 100644 --- a/website/client/src/ja/guide/usage.md +++ b/website/client/src/ja/guide/usage.md @@ -93,6 +93,30 @@ repomix --compress repomix --remote yamadashy/repomix --compress ``` +### Git統合 + +AI分析のための開発コンテキストを提供するためにGit情報を含めます: + +```bash +# Git差分を含める(コミットされていない変更) +repomix --include-diffs + +# Gitコミットログを含める(デフォルトで最新50コミット) +repomix --include-logs + +# 特定の数のコミットを含める +repomix --include-logs --include-logs-count 10 + +# 差分とログの両方を含める +repomix --include-diffs --include-logs +``` + +これにより以下の貴重なコンテキストが追加されます: +- **最近の変更**: Git差分はコミットされていない変更を表示 +- **開発パターン**: Gitログは通常一緒に変更されるファイルを明らかにする +- **コミット履歴**: 最近のコミットメッセージは開発の焦点についての洞察を提供 +- **ファイル関係**: 同じコミットで変更されるファイルの理解 + ### トークン数最適化 コードベースのトークン分布を理解することは、AIとの対話を最適化するために重要です。`--token-count-tree`オプションを使用して、プロジェクト全体のトークン使用量を視覚化できます: diff --git a/website/client/src/ko/guide/command-line-options.md b/website/client/src/ko/guide/command-line-options.md index f34dafb43..700f9a6b6 100644 --- a/website/client/src/ko/guide/command-line-options.md +++ b/website/client/src/ko/guide/command-line-options.md @@ -28,6 +28,8 @@ - `--instruction-file-path `: 상세한 사용자 정의 지침이 포함된 파일 경로 - `--include-empty-directories`: 출력에 빈 디렉토리 포함 - `--include-diffs`: 출력에 git 차이점 포함 (작업 트리와 스테이징된 변경사항을 별도로 포함) +- `--include-logs`: 출력에 git 로그 포함 (날짜, 메시지, 파일 경로를 포함한 커밋 히스토리) +- `--include-logs-count `: 포함할 git 로그 커밋 수 (기본값: 50) - `--no-git-sort-by-changes`: git 변경 횟수별 파일 정렬 비활성화 (기본적으로 활성화됨) ## 파일 선택 옵션 @@ -70,6 +72,11 @@ repomix --stdout | llm "이 코드가 무엇을 하는지 설명해주세요." # 압축을 사용한 사용자 정의 출력 repomix --compress +# Git 통합 기능 +repomix --include-logs # git 로그 포함 (기본 50개 커밋) +repomix --include-logs --include-logs-count 10 # 최근 10개 커밋 포함 +repomix --include-diffs --include-logs # 차이점과 로그 모두 포함 + # 특정 파일 처리 repomix --include "src/**/*.ts" --ignore "**/*.test.ts" diff --git a/website/client/src/ko/guide/configuration.md b/website/client/src/ko/guide/configuration.md index 7de41c92e..f63c5626e 100644 --- a/website/client/src/ko/guide/configuration.md +++ b/website/client/src/ko/guide/configuration.md @@ -39,6 +39,8 @@ repomix --init --global | `output.git.sortByChanges` | Git 변경 횟수로 파일을 정렬할지 여부. 변경이 많은 파일이 하단에 표시됩니다 | `true` | | `output.git.sortByChangesMaxCommits` | Git 변경을 분석할 때 분석할 최대 커밋 수. 성능을 위해 이력 깊이를 제한합니다 | `100` | | `output.git.includeDiffs` | 출력에 Git 차이를 포함할지 여부. 작업 트리와 스테이징된 변경 사항을 별도로 표시합니다 | `false` | +| `output.git.includeLogs` | 출력에 Git 로그를 포함할지 여부. 커밋 히스토리의 날짜, 메시지, 파일 경로를 표시합니다 | `false` | +| `output.git.includeLogsCount` | 포함할 Git 로그 커밋 수. 개발 패턴을 이해하기 위한 히스토리 깊이를 제한합니다 | `50` | | `include` | 포함할 파일 패턴([glob 패턴](https://github.com/mrmlnc/fast-glob?tab=readme-ov-file#pattern-syntax) 사용) | `[]` | | `ignore.useGitignore` | 프로젝트의 `.gitignore` 파일의 패턴을 사용할지 여부 | `true` | | `ignore.useDefaultPatterns` | 기본 무시 패턴(node_modules, .git 등)을 사용할지 여부 | `true` | @@ -97,7 +99,9 @@ repomix --init --global "git": { "sortByChanges": true, "sortByChangesMaxCommits": 100, - "includeDiffs": false + "includeDiffs": false, + "includeLogs": false, + "includeLogsCount": 50 } }, "include": ["**/*"], @@ -186,6 +190,8 @@ dist/** - `sortByChanges`: true로 설정하면 파일이 Git 변경 횟수(해당 파일을 수정한 커밋 수)로 정렬됩니다. 변경이 많은 파일이 출력 하단에 나타납니다. 이는 더 활발하게 개발되는 파일을 우선시하는 데 도움이 됩니다. 기본값: `true` - `sortByChangesMaxCommits`: 파일 변경 횟수를 계산할 때 분석할 최대 커밋 수. 기본값: `100` - `includeDiffs`: true로 설정하면 Git 차이를 출력에 포함합니다(작업 트리와 스테이징된 변경 사항을 별도로 포함). 이를 통해 독자는 저장소의 대기 중인 변경 사항을 볼 수 있습니다. 기본값: `false` +- `includeLogs`: true로 설정하면 Git 로그를 출력에 포함합니다. 커밋 히스토리의 날짜, 메시지, 파일 경로가 표시되어 AI가 어떤 파일들이 일반적으로 함께 변경되는지 이해할 수 있습니다. 기본값: `false` +- `includeLogsCount`: 포함할 Git 로그 커밋 수입니다. 개발 패턴 분석에 사용되는 히스토리 깊이를 제어합니다. 기본값: `50` 설정 예시: ```json @@ -194,7 +200,9 @@ dist/** "git": { "sortByChanges": true, "sortByChangesMaxCommits": 100, - "includeDiffs": true + "includeDiffs": true, + "includeLogs": true, + "includeLogsCount": 30 } } } diff --git a/website/client/src/ko/guide/output.md b/website/client/src/ko/guide/output.md index eda1f44e0..28acc9cf5 100644 --- a/website/client/src/ko/guide/output.md +++ b/website/client/src/ko/guide/output.md @@ -32,6 +32,28 @@ src/ // 파일 내용 + + + +2025-08-20 00:47:19 +0900 +feat(cli): Add --include-logs option for git commit history + +README.md +src/cli/cliRun.ts +src/core/git/gitCommand.ts +src/core/git/gitLogHandle.ts +src/core/output/outputGenerate.ts + + + + +2025-08-21 00:09:43 +0900 +Merge pull request #795 from yamadashy/chore/ratchet-update-ci + +.github/workflows/ratchet-update.yml + + + ``` ::: tip XML을 사용하는 이유 @@ -66,6 +88,24 @@ helper.ts ```typescript // 파일 내용 ``` + +# Git 로그 + +## 커밋: 2025-08-20 00:47:19 +0900 +**메시지:** feat(cli): Add --include-logs option for git commit history + +**파일:** +- README.md +- src/cli/cliRun.ts +- src/core/git/gitCommand.ts +- src/core/git/gitLogHandle.ts +- src/core/output/outputGenerate.ts + +## 커밋: 2025-08-21 00:09:43 +0900 +**메시지:** Merge pull request #795 from yamadashy/chore/ratchet-update-ci + +**파일:** +- .github/workflows/ratchet-update.yml ``` ## AI 모델과의 사용 @@ -118,4 +158,25 @@ src/ File: src/index.ts ================ // 파일 내용 + +================ +Git 로그 +================ +================ +Date: 2025-08-20 00:47:19 +0900 +Message: feat(cli): Add --include-logs option for git commit history +Files: + - README.md + - src/cli/cliRun.ts + - src/core/git/gitCommand.ts + - src/core/git/gitLogHandle.ts + - src/core/output/outputGenerate.ts +================ + +================ +Date: 2025-08-21 00:09:43 +0900 +Message: Merge pull request #795 from yamadashy/chore/ratchet-update-ci +Files: + - .github/workflows/ratchet-update.yml +================ ``` diff --git a/website/client/src/ko/guide/usage.md b/website/client/src/ko/guide/usage.md index e95726cc7..9583ade23 100644 --- a/website/client/src/ko/guide/usage.md +++ b/website/client/src/ko/guide/usage.md @@ -93,6 +93,30 @@ repomix --compress repomix --remote yamadashy/repomix --compress ``` +### Git 통합 + +AI 분석을 위한 개발 컨텍스트를 제공하기 위해 Git 정보를 포함합니다: + +```bash +# git 차이점 포함 (커밋되지 않은 변경사항) +repomix --include-diffs + +# git 커밋 로그 포함 (기본값: 최근 50개 커밋) +repomix --include-logs + +# 특정 수의 커밋 포함 +repomix --include-logs --include-logs-count 10 + +# 차이점과 로그 모두 포함 +repomix --include-diffs --include-logs +``` + +이것은 다음과 같은 귀중한 컨텍스트를 추가합니다: +- **최근 변경사항**: Git 차이점은 커밋되지 않은 수정사항을 보여줍니다 +- **개발 패턴**: Git 로그는 일반적으로 함께 변경되는 파일을 드러냅니다 +- **커밋 히스토리**: 최근 커밋 메시지는 개발 초점에 대한 통찰을 제공합니다 +- **파일 관계**: 같은 커밋에서 수정되는 파일들에 대한 이해 + ### 토큰 수 최적화 코드베이스의 토큰 분포를 이해하는 것은 AI 상호 작용을 최적화하는 데 중요합니다. `--token-count-tree` 옵션을 사용하여 프로젝트 전체의 토큰 사용량을 시각화하세요: diff --git a/website/client/src/pt-br/guide/command-line-options.md b/website/client/src/pt-br/guide/command-line-options.md index 58b054991..fd200da69 100644 --- a/website/client/src/pt-br/guide/command-line-options.md +++ b/website/client/src/pt-br/guide/command-line-options.md @@ -28,6 +28,8 @@ - `--instruction-file-path `: Caminho para um arquivo contendo instruções personalizadas detalhadas - `--include-empty-directories`: Incluir diretórios vazios na saída - `--include-diffs`: Incluir diffs do git na saída (inclui mudanças da árvore de trabalho e mudanças em stage separadamente) +- `--include-logs`: Incluir logs do git na saída (inclui histórico de commits com datas, mensagens e caminhos de arquivos) +- `--include-logs-count `: Número de commits do log do git para incluir (padrão: 50) - `--no-git-sort-by-changes`: Desabilitar ordenação de arquivos por contagem de mudanças do git (habilitado por padrão) ## Opções de Seleção de Arquivos @@ -87,6 +89,12 @@ find src -name "*.ts" -type f | repomix --stdin git ls-files "*.js" | repomix --stdin echo -e "src/index.ts\nsrc/utils.ts" | repomix --stdin +# Integração Git +repomix --include-diffs # Incluir diffs do git para mudanças não commitadas +repomix --include-logs # Incluir logs do git (últimos 50 commits por padrão) +repomix --include-logs --include-logs-count 10 # Incluir últimos 10 commits +repomix --include-diffs --include-logs # Incluir tanto diffs quanto logs + # Análise de contagem de tokens repomix --token-count-tree repomix --token-count-tree 1000 # Mostrar apenas arquivos/diretórios com 1000+ tokens diff --git a/website/client/src/pt-br/guide/configuration.md b/website/client/src/pt-br/guide/configuration.md index a0eccff70..4a3795166 100644 --- a/website/client/src/pt-br/guide/configuration.md +++ b/website/client/src/pt-br/guide/configuration.md @@ -39,6 +39,8 @@ repomix --init --global | `output.git.sortByChanges` | Indica se deve ordenar arquivos por número de alterações git. Arquivos com mais alterações aparecem no final | `true` | | `output.git.sortByChangesMaxCommits` | Número máximo de commits para analisar ao contar alterações git. Limita a profundidade do histórico por desempenho | `100` | | `output.git.includeDiffs` | Indica se deve incluir as diferenças git na saída. Mostra separadamente as alterações da árvore de trabalho e as alterações preparadas | `false` | +| `output.git.includeLogs` | Indica se deve incluir logs do git na saída. Mostra histórico de commits com datas, mensagens e caminhos de arquivos | `false` | +| `output.git.includeLogsCount` | Número de commits do log do git para incluir na saída | `50` | | `include` | Padrões de arquivos para incluir usando [padrões glob](https://github.com/mrmlnc/fast-glob?tab=readme-ov-file#pattern-syntax) | `[]` | | `ignore.useGitignore` | Indica se deve usar os padrões do arquivo `.gitignore` do projeto | `true` | | `ignore.useDefaultPatterns` | Indica se deve usar os padrões de ignorar padrão (node_modules, .git, etc.) | `true` | @@ -97,7 +99,9 @@ Aqui está um exemplo de um arquivo de configuração completo (`repomix.config. "git": { "sortByChanges": true, "sortByChangesMaxCommits": 100, - "includeDiffs": false + "includeDiffs": false, + "includeLogs": false, + "includeLogsCount": 50 } }, "include": ["**/*"], @@ -186,6 +190,8 @@ A configuração `output.git` fornece recursos poderosos relacionados ao Git: - `sortByChanges`: Quando verdadeiro, os arquivos são ordenados por número de alterações Git (commits que modificaram o arquivo). Arquivos com mais alterações aparecem no final da saída. Isso ajuda a priorizar os arquivos mais ativamente desenvolvidos. Padrão: `true` - `sortByChangesMaxCommits`: O número máximo de commits para analisar ao contar alterações de arquivos. Padrão: `100` - `includeDiffs`: Quando verdadeiro, inclui as diferenças Git na saída (inclui separadamente as alterações da árvore de trabalho e as alterações preparadas). Isso permite que o leitor veja as alterações pendentes no repositório. Padrão: `false` +- `includeLogs`: Quando verdadeiro, inclui o histórico de commits Git na saída. Mostra datas de commit, mensagens e caminhos de arquivos para cada commit. Isso ajuda a IA a entender padrões de desenvolvimento e relacionamentos entre arquivos. Padrão: `false` +- `includeLogsCount`: O número de commits recentes para incluir nos logs git. Padrão: `50` Exemplo de configuração: ```json @@ -194,7 +200,9 @@ Exemplo de configuração: "git": { "sortByChanges": true, "sortByChangesMaxCommits": 100, - "includeDiffs": true + "includeDiffs": true, + "includeLogs": true, + "includeLogsCount": 25 } } } diff --git a/website/client/src/pt-br/guide/output.md b/website/client/src/pt-br/guide/output.md index dc2e6f1ff..50e0ceb7e 100644 --- a/website/client/src/pt-br/guide/output.md +++ b/website/client/src/pt-br/guide/output.md @@ -3,7 +3,7 @@ O Repomix suporta três formatos de saída: - XML (padrão) - Markdown -- Texto simples +- Texto simples ## Formato XML @@ -13,10 +13,6 @@ repomix --style xml O formato XML é otimizado para processamento por IA: -::: tip Por que XML? -As tags XML ajudam modelos de IA como o Claude a analisar o conteúdo com mais precisão. A [documentação do Claude](https://docs.anthropic.com/en/docs/build-with-claude/prompt-engineering/use-xml-tags) recomenda o uso de tags XML para prompts estruturados. -::: - ```xml Este arquivo é uma representação consolidada de toda a base de código... @@ -36,8 +32,34 @@ src/ // Conteúdo do arquivo aqui + + + +2025-08-20 00:47:19 +0900 +feat(cli): Add --include-logs option for git commit history + +README.md +src/cli/cliRun.ts +src/core/git/gitCommand.ts +src/core/git/gitLogHandle.ts +src/core/output/outputGenerate.ts + + + + +2025-08-21 00:09:43 +0900 +Merge pull request #795 from yamadashy/chore/ratchet-update-ci + +.github/workflows/ratchet-update.yml + + + ``` +::: tip Por que XML? +As tags XML ajudam modelos de IA como o Claude a analisar o conteúdo com mais precisão. A [documentação do Claude](https://docs.anthropic.com/en/docs/build-with-claude/prompt-engineering/use-xml-tags) recomenda o uso de tags XML para prompts estruturados. +::: + ## Formato Markdown ```bash @@ -53,11 +75,11 @@ Este arquivo é uma representação consolidada de toda a base de código... (Metadados e instruções para IA) # Estrutura de Diretórios -```text +``` src/ - index.ts - utils/ - helper.ts +index.ts +utils/ +helper.ts ``` # Arquivos @@ -66,6 +88,19 @@ src/ ```typescript // Conteúdo do arquivo aqui ``` + +# Logs do Git +``` +2025-08-20 00:47:19 +0900|feat(cli): Add --include-logs option for git commit history +README.md +src/cli/cliRun.ts +src/core/git/gitCommand.ts +src/core/git/gitLogHandle.ts +src/core/output/outputGenerate.ts + +2025-08-21 00:09:43 +0900|Merge pull request #795 from yamadashy/chore/ratchet-update-ci +.github/workflows/ratchet-update.yml +``` ``` ## Uso com Modelos de IA @@ -118,4 +153,17 @@ Arquivos Arquivo: src/index.ts ================ // Conteúdo do arquivo aqui + +================ +Logs do Git +================ +2025-08-20 00:47:19 +0900|feat(cli): Add --include-logs option for git commit history +README.md +src/cli/cliRun.ts +src/core/git/gitCommand.ts +src/core/git/gitLogHandle.ts +src/core/output/outputGenerate.ts + +2025-08-21 00:09:43 +0900|Merge pull request #795 from yamadashy/chore/ratchet-update-ci +.github/workflows/ratchet-update.yml ``` diff --git a/website/client/src/pt-br/guide/usage.md b/website/client/src/pt-br/guide/usage.md index 1c2301a1d..0a9746f9c 100644 --- a/website/client/src/pt-br/guide/usage.md +++ b/website/client/src/pt-br/guide/usage.md @@ -93,6 +93,30 @@ repomix --compress repomix --remote yamadashy/repomix --compress ``` +### Integração Git + +Incluir informações do Git para fornecer contexto de desenvolvimento para análise de IA: + +```bash +# Incluir diffs do git (alterações não commitadas) +repomix --include-diffs + +# Incluir logs de commits do git (últimos 50 commits por padrão) +repomix --include-logs + +# Incluir número específico de commits +repomix --include-logs --include-logs-count 10 + +# Incluir tanto diffs quanto logs +repomix --include-diffs --include-logs +``` + +Isso adiciona contexto valioso sobre: +- **Alterações recentes**: Diffs do Git mostram modificações não commitadas +- **Padrões de desenvolvimento**: Logs do Git revelam quais arquivos são tipicamente alterados juntos +- **Histórico de commits**: Mensagens de commits recentes fornecem insights sobre o foco do desenvolvimento +- **Relacionamentos entre arquivos**: Entender quais arquivos são modificados nos mesmos commits + ### Otimização da Contagem de Tokens Entender a distribuição de tokens da sua base de código é crucial para otimizar as interações com IA. Use a opção `--token-count-tree` para visualizar o uso de tokens em todo o seu projeto: diff --git a/website/client/src/vi/guide/command-line-options.md b/website/client/src/vi/guide/command-line-options.md index e71c9fe47..79c7e2c27 100644 --- a/website/client/src/vi/guide/command-line-options.md +++ b/website/client/src/vi/guide/command-line-options.md @@ -28,6 +28,8 @@ - `--instruction-file-path `: Đường dẫn đến tệp chứa hướng dẫn tùy chỉnh chi tiết - `--include-empty-directories`: Bao gồm các thư mục trống trong đầu ra - `--include-diffs`: Bao gồm các diff git trong đầu ra (bao gồm các thay đổi cây làm việc và các thay đổi đã staged riêng biệt) +- `--include-logs`: Bao gồm nhật ký git trong đầu ra (bao gồm lịch sử commit với ngày tháng, thông điệp và đường dẫn tệp) +- `--include-logs-count `: Số lượng commit git logs để bao gồm (mặc định: 50) - `--no-git-sort-by-changes`: Tắt sắp xếp tệp theo số lượng thay đổi git (được bật mặc định) ## Tùy chọn Lựa chọn Tệp @@ -87,6 +89,12 @@ find src -name "*.ts" -type f | repomix --stdin git ls-files "*.js" | repomix --stdin echo -e "src/index.ts\nsrc/utils.ts" | repomix --stdin +# Tích hợp Git +repomix --include-diffs # Bao gồm diff git cho các thay đổi chưa commit +repomix --include-logs # Bao gồm nhật ký git (50 commit cuối cùng theo mặc định) +repomix --include-logs --include-logs-count 10 # Bao gồm 10 commit cuối cùng +repomix --include-diffs --include-logs # Bao gồm cả diff và logs + # Phân tích số lượng token repomix --token-count-tree repomix --token-count-tree 1000 # Chỉ hiển thị tệp/thư mục với 1000+ token diff --git a/website/client/src/vi/guide/configuration.md b/website/client/src/vi/guide/configuration.md index 328af3c0d..967bdba11 100644 --- a/website/client/src/vi/guide/configuration.md +++ b/website/client/src/vi/guide/configuration.md @@ -39,6 +39,8 @@ repomix --init --global | `output.git.sortByChanges` | Có nên sắp xếp file theo số lượng thay đổi git hay không. Các file có nhiều thay đổi hơn xuất hiện ở cuối | `true` | | `output.git.sortByChangesMaxCommits` | Số lượng commit tối đa để phân tích khi đếm các thay đổi git. Giới hạn độ sâu lịch sử để cải thiện hiệu suất | `100` | | `output.git.includeDiffs` | Có nên bao gồm các sự khác biệt git trong đầu ra hay không. Hiển thị riêng biệt các thay đổi work tree và staged | `false` | +| `output.git.includeLogs` | Có nên bao gồm nhật ký git trong đầu ra hay không. Hiển thị lịch sử commit với ngày tháng, thông điệp và đường dẫn tệp | `false` | +| `output.git.includeLogsCount` | Số lượng commit git logs để bao gồm trong đầu ra | `50` | | `include` | Các mẫu file để bao gồm sử dụng [mẫu glob](https://github.com/mrmlnc/fast-glob?tab=readme-ov-file#pattern-syntax) | `[]` | | `ignore.useGitignore` | Có nên sử dụng các mẫu từ file `.gitignore` của dự án hay không | `true` | | `ignore.useDefaultPatterns` | Có nên sử dụng các mẫu ignore mặc định (node_modules, .git, v.v.) hay không | `true` | @@ -97,7 +99,9 @@ Bạn có thể bật xác thực schema cho file cấu hình của mình bằng "git": { "sortByChanges": true, "sortByChangesMaxCommits": 100, - "includeDiffs": false + "includeDiffs": false, + "includeLogs": false, + "includeLogsCount": 50 } }, "include": ["**/*"], @@ -186,6 +190,8 @@ Cấu hình `output.git` cung cấp các tính năng Git-aware mạnh mẽ: - `sortByChanges`: Khi là true, các file được sắp xếp theo số lượng thay đổi Git (các commit đã sửa đổi file). Các file có nhiều thay đổi hơn xuất hiện ở cuối đầu ra. Điều này giúp ưu tiên các file được phát triển tích cực hơn. Mặc định: `true` - `sortByChangesMaxCommits`: Số lượng commit tối đa để phân tích khi đếm các thay đổi file. Mặc định: `100` - `includeDiffs`: Khi là true, bao gồm các sự khác biệt Git trong đầu ra (bao gồm riêng biệt các thay đổi work tree và staged). Điều này cho phép người đọc xem các thay đổi đang chờ trong repository. Mặc định: `false` +- `includeLogs`: Khi là true, bao gồm nhật ký Git trong đầu ra. Hiển thị lịch sử commit với ngày tháng, thông điệp và đường dẫn tệp. Điều này giúp AI hiểu các mẫu phát triển và mối quan hệ tệp. Mặc định: `false` +- `includeLogsCount`: Số lượng commit gần đây để bao gồm trong nhật ký git. Mặc định: `50` Ví dụ cấu hình: ```json @@ -194,7 +200,9 @@ Ví dụ cấu hình: "git": { "sortByChanges": true, "sortByChangesMaxCommits": 100, - "includeDiffs": true + "includeDiffs": true, + "includeLogs": true, + "includeLogsCount": 25 } } } diff --git a/website/client/src/vi/guide/output.md b/website/client/src/vi/guide/output.md index 5920e4851..5cc04c191 100644 --- a/website/client/src/vi/guide/output.md +++ b/website/client/src/vi/guide/output.md @@ -53,6 +53,26 @@ Ví dụ về đầu ra XML: + + + 2025-08-20 00:47:19 +0900 + feat(cli): Add --include-logs option for git commit history + + README.md + src/cli/cliRun.ts + src/core/git/gitCommand.ts + src/core/git/gitLogHandle.ts + src/core/output/outputGenerate.ts + + + + 2025-08-21 00:09:43 +0900 + Merge pull request #795 from yamadashy/chore/ratchet-update-ci + + .github/workflows/ratchet-update.yml + + + ``` @@ -94,6 +114,19 @@ export function formatOutput(data) { // Nội dung tệp... } ``` + +# Git Logs +``` +2025-08-20 00:47:19 +0900|feat(cli): Add --include-logs option for git commit history +README.md +src/cli/cliRun.ts +src/core/git/gitCommand.ts +src/core/git/gitLogHandle.ts +src/core/output/outputGenerate.ts + +2025-08-21 00:09:43 +0900|Merge pull request #795 from yamadashy/chore/ratchet-update-ci +.github/workflows/ratchet-update.yml +``` ... ``` @@ -131,6 +164,19 @@ File: src/utils.ts (typescript) export function formatOutput(data) { // Nội dung tệp... } + +================ +Git Logs +================ +2025-08-20 00:47:19 +0900|feat(cli): Add --include-logs option for git commit history +README.md +src/cli/cliRun.ts +src/core/git/gitCommand.ts +src/core/git/gitLogHandle.ts +src/core/output/outputGenerate.ts + +2025-08-21 00:09:43 +0900|Merge pull request #795 from yamadashy/chore/ratchet-update-ci +.github/workflows/ratchet-update.yml ... ``` diff --git a/website/client/src/vi/guide/usage.md b/website/client/src/vi/guide/usage.md index fa1134710..fc79f0804 100644 --- a/website/client/src/vi/guide/usage.md +++ b/website/client/src/vi/guide/usage.md @@ -170,6 +170,30 @@ repomix --compress repomix --remote yamadashy/repomix --compress ``` +### Tích hợp Git + +Bao gồm thông tin Git để cung cấp ngữ cảnh phát triển cho phân tích AI: + +```bash +# Bao gồm diff git (các thay đổi chưa commit) +repomix --include-diffs + +# Bao gồm nhật ký commit git (50 commit cuối cùng theo mặc định) +repomix --include-logs + +# Bao gồm số lượng commit cụ thể +repomix --include-logs --include-logs-count 10 + +# Bao gồm cả diff và logs +repomix --include-diffs --include-logs +``` + +Điều này thêm ngữ cảnh có giá trị về: +- **Các thay đổi gần đây**: Git diff hiển thị các sửa đổi chưa commit +- **Các mẫu phát triển**: Git logs tiết lộ tệp nào thường được thay đổi cùng nhau +- **Lịch sử commit**: Các thông điệp commit gần đây cung cấp hiểu biết về trọng tâm phát triển +- **Mối quan hệ tệp**: Hiểu tệp nào được sửa đổi trong cùng một commit + ### Tối ưu hóa số lượng token Hiểu được phân phối token của codebase là rất quan trọng để tối ưu hóa tương tác AI. Sử dụng tùy chọn `--token-count-tree` để trực quan hóa việc sử dụng token trong toàn bộ dự án của bạn: diff --git a/website/client/src/zh-cn/guide/command-line-options.md b/website/client/src/zh-cn/guide/command-line-options.md index f6d0ba19e..66e7a8a10 100644 --- a/website/client/src/zh-cn/guide/command-line-options.md +++ b/website/client/src/zh-cn/guide/command-line-options.md @@ -28,6 +28,8 @@ - `--instruction-file-path `: 包含详细自定义指令的文件路径 - `--include-empty-directories`: 在输出中包含空目录 - `--include-diffs`: 在输出中包含git差异(分别包含工作树和暂存的更改) +- `--include-logs`: 在输出中包含git日志(包含日期、消息和文件路径的提交历史) +- `--include-logs-count `: 要包含的git日志提交数量(默认:50) - `--no-git-sort-by-changes`: 禁用按git更改次数排序文件(默认启用) ## 文件选择选项 @@ -70,6 +72,11 @@ repomix --stdout | llm "请解释这段代码的作用。" # 使用压缩的自定义输出 repomix --compress +# Git集成功能 +repomix --include-logs # 包含git日志(默认50个提交) +repomix --include-logs --include-logs-count 10 # 包含最近10个提交 +repomix --include-diffs --include-logs # 同时包含差异和日志 + # 处理特定文件 repomix --include "src/**/*.ts" --ignore "**/*.test.ts" diff --git a/website/client/src/zh-cn/guide/configuration.md b/website/client/src/zh-cn/guide/configuration.md index edc823a0c..abce81b39 100644 --- a/website/client/src/zh-cn/guide/configuration.md +++ b/website/client/src/zh-cn/guide/configuration.md @@ -39,6 +39,8 @@ repomix --init --global | `output.git.sortByChanges` | 是否按Git更改次数对文件进行排序。更改较多的文件显示在底部 | `true` | | `output.git.sortByChangesMaxCommits` | 分析Git更改时要分析的最大提交数。限制历史深度以提高性能 | `100` | | `output.git.includeDiffs` | 是否在输出中包含Git差异。分别显示工作树和暂存区的更改 | `false` | +| `output.git.includeLogs` | 是否在输出中包含Git日志。显示提交历史的日期、消息和文件路径 | `false` | +| `output.git.includeLogsCount` | 要包含的Git日志提交数量。限制历史深度以了解开发模式 | `50` | | `include` | 要包含的文件模式(使用[glob模式](https://github.com/mrmlnc/fast-glob?tab=readme-ov-file#pattern-syntax)) | `[]` | | `ignore.useGitignore` | 是否使用项目的`.gitignore`文件中的模式 | `true` | | `ignore.useDefaultPatterns` | 是否使用默认忽略模式(node_modules、.git等) | `true` | @@ -97,7 +99,9 @@ repomix --init --global "git": { "sortByChanges": true, "sortByChangesMaxCommits": 100, - "includeDiffs": false + "includeDiffs": false, + "includeLogs": false, + "includeLogsCount": 50 } }, "include": ["**/*"], @@ -186,6 +190,8 @@ dist/** - `sortByChanges`:当设置为true时,文件按Git更改次数(修改该文件的提交数)排序。更改次数较多的文件出现在输出的底部。这有助于优先处理更活跃开发的文件。默认值:`true` - `sortByChangesMaxCommits`:计算文件更改次数时要分析的最大提交数。默认值:`100` - `includeDiffs`:当设置为true时,在输出中包含Git差异(同时分别包含工作树和暂存区的更改)。这允许读者查看存储库中的待处理更改。默认值:`false` +- `includeLogs`:当设置为true时,在输出中包含Git日志。显示提交历史的日期、消息和文件路径,帮助AI理解哪些文件通常一起更改。默认值:`false` +- `includeLogsCount`:要包含的Git日志提交数量。控制用于分析开发模式的历史深度。默认值:`50` 配置示例: ```json @@ -194,7 +200,9 @@ dist/** "git": { "sortByChanges": true, "sortByChangesMaxCommits": 100, - "includeDiffs": true + "includeDiffs": true, + "includeLogs": true, + "includeLogsCount": 30 } } } diff --git a/website/client/src/zh-cn/guide/output.md b/website/client/src/zh-cn/guide/output.md index 9eafb8308..68429c506 100644 --- a/website/client/src/zh-cn/guide/output.md +++ b/website/client/src/zh-cn/guide/output.md @@ -32,6 +32,28 @@ src/ // 文件内容 + + + +2025-08-20 00:47:19 +0900 +feat(cli): Add --include-logs option for git commit history + +README.md +src/cli/cliRun.ts +src/core/git/gitCommand.ts +src/core/git/gitLogHandle.ts +src/core/output/outputGenerate.ts + + + + +2025-08-21 00:09:43 +0900 +Merge pull request #795 from yamadashy/chore/ratchet-update-ci + +.github/workflows/ratchet-update.yml + + + ``` ::: tip 为什么选择 XML? @@ -66,6 +88,24 @@ helper.ts ```typescript // 文件内容 ``` + +# Git Logs + +## 提交:2025-08-20 00:47:19 +0900 +**消息:** feat(cli): Add --include-logs option for git commit history + +**文件:** +- README.md +- src/cli/cliRun.ts +- src/core/git/gitCommand.ts +- src/core/git/gitLogHandle.ts +- src/core/output/outputGenerate.ts + +## 提交:2025-08-21 00:09:43 +0900 +**消息:** Merge pull request #795 from yamadashy/chore/ratchet-update-ci + +**文件:** +- .github/workflows/ratchet-update.yml ``` ## 在 AI 模型中的使用 @@ -118,4 +158,25 @@ src/ File: src/index.ts ================ // 文件内容 + +================ +Git Logs +================ +================ +Date: 2025-08-20 00:47:19 +0900 +Message: feat(cli): Add --include-logs option for git commit history +Files: + - README.md + - src/cli/cliRun.ts + - src/core/git/gitCommand.ts + - src/core/git/gitLogHandle.ts + - src/core/output/outputGenerate.ts +================ + +================ +Date: 2025-08-21 00:09:43 +0900 +Message: Merge pull request #795 from yamadashy/chore/ratchet-update-ci +Files: + - .github/workflows/ratchet-update.yml +================ ``` diff --git a/website/client/src/zh-cn/guide/usage.md b/website/client/src/zh-cn/guide/usage.md index 3cd332a7e..b68921ed8 100644 --- a/website/client/src/zh-cn/guide/usage.md +++ b/website/client/src/zh-cn/guide/usage.md @@ -93,6 +93,30 @@ repomix --compress repomix --remote yamadashy/repomix --compress ``` +### Git 集成 + +包含Git信息为AI分析提供开发上下文: + +```bash +# 包含git差异(未提交的更改) +repomix --include-diffs + +# 包含git提交日志(默认最近50个提交) +repomix --include-logs + +# 包含特定数量的提交 +repomix --include-logs --include-logs-count 10 + +# 同时包含差异和日志 +repomix --include-diffs --include-logs +``` + +这增加了宝贵的上下文信息: +- **最近更改**:Git差异显示未提交的修改 +- **开发模式**:Git日志揭示通常一起更改的文件 +- **提交历史**:最近的提交消息提供开发重点的洞察 +- **文件关系**:理解在同一提交中修改的文件 + ### 令牌数量优化 了解代码库的令牌分布对于优化AI交互至关重要。使用 `--token-count-tree` 选项可视化整个项目的令牌使用情况: diff --git a/website/client/src/zh-tw/guide/command-line-options.md b/website/client/src/zh-tw/guide/command-line-options.md index 2a6350fdf..44c8cf0a6 100644 --- a/website/client/src/zh-tw/guide/command-line-options.md +++ b/website/client/src/zh-tw/guide/command-line-options.md @@ -28,6 +28,8 @@ - `--instruction-file-path `: 包含詳細自訂指令的檔案路徑 - `--include-empty-directories`: 在輸出中包含空目錄 - `--include-diffs`: 在輸出中包含git差異(分別包含工作樹和暫存的變更) +- `--include-logs`: 在輸出中包含git記錄(包含提交歷史,包括日期、訊息和檔案路徑) +- `--include-logs-count `: 要包含的git記錄提交數量(預設:50) - `--no-git-sort-by-changes`: 停用按git變更次數排序檔案(預設啟用) ## 檔案選擇選項 @@ -87,6 +89,12 @@ find src -name "*.ts" -type f | repomix --stdin git ls-files "*.js" | repomix --stdin echo -e "src/index.ts\nsrc/utils.ts" | repomix --stdin +# Git整合 +repomix --include-diffs # 包含git差異用於未提交的變更 +repomix --include-logs # 包含git記錄(預設為最後50次提交) +repomix --include-logs --include-logs-count 10 # 包含最後10次提交 +repomix --include-diffs --include-logs # 同時包含差異和記錄 + # 權杖計數分析 repomix --token-count-tree repomix --token-count-tree 1000 # 僅顯示擁有1000+權杖的檔案/目錄 diff --git a/website/client/src/zh-tw/guide/configuration.md b/website/client/src/zh-tw/guide/configuration.md index da9dfb015..0ae24290e 100644 --- a/website/client/src/zh-tw/guide/configuration.md +++ b/website/client/src/zh-tw/guide/configuration.md @@ -39,6 +39,8 @@ repomix --init --global | `output.git.sortByChanges` | 是否按Git更改次數對檔案進行排序。更改較多的檔案顯示在底部 | `true` | | `output.git.sortByChangesMaxCommits` | 分析Git更改時要分析的最大提交數。限制歷史深度以提高效能 | `100` | | `output.git.includeDiffs` | 是否在輸出中包含Git差異。分別顯示工作樹和暫存區的更改 | `false` | +| `output.git.includeLogs` | 是否在輸出中包含Git記錄。顯示提交歷史包括日期、訊息和檔案路徑 | `false` | +| `output.git.includeLogsCount` | 在輸出中包含的git記錄提交數量 | `50` | | `include` | 要包含的檔案模式(使用[glob模式](https://github.com/mrmlnc/fast-glob?tab=readme-ov-file#pattern-syntax)) | `[]` | | `ignore.useGitignore` | 是否使用專案的`.gitignore`檔案中的模式 | `true` | | `ignore.useDefaultPatterns` | 是否使用預設忽略模式(node_modules、.git等) | `true` | @@ -97,7 +99,9 @@ repomix --init --global "git": { "sortByChanges": true, "sortByChangesMaxCommits": 100, - "includeDiffs": false + "includeDiffs": false, + "includeLogs": false, + "includeLogsCount": 50 } }, "include": ["**/*"], @@ -186,6 +190,8 @@ dist/** - `sortByChanges`:當設定為true時,檔案按Git更改次數(修改該檔案的提交數)排序。更改次數較多的檔案出現在輸出的底部。這有助於優先處理更活躍開發的檔案。預設值:`true` - `sortByChangesMaxCommits`:計算檔案更改次數時要分析的最大提交數。預設值:`100` - `includeDiffs`:當設定為true時,在輸出中包含Git差異(同時分別包含工作樹和暫存區的更改)。這允許讀者查看儲存庫中的待處理更改。預設值:`false` +- `includeLogs`:當設定為true時,在輸出中包含Git記錄。顯示提交歷史包括日期、訊息和檔案路徑。這有助於AI理解開發模式和檔案關係。預設值:`false` +- `includeLogsCount`:在git記錄中包含的最近提交數量。預設值:`50` 設定範例: ```json @@ -194,7 +200,9 @@ dist/** "git": { "sortByChanges": true, "sortByChangesMaxCommits": 100, - "includeDiffs": true + "includeDiffs": true, + "includeLogs": true, + "includeLogsCount": 25 } } } diff --git a/website/client/src/zh-tw/guide/output.md b/website/client/src/zh-tw/guide/output.md index 7c33deea3..4b554f449 100644 --- a/website/client/src/zh-tw/guide/output.md +++ b/website/client/src/zh-tw/guide/output.md @@ -32,6 +32,27 @@ src/ // 文件內容 + + + +2025-08-20 00:47:19 +0900 +feat(cli): Add --include-logs option for git commit history + +README.md +src/cli/cliRun.ts +src/core/git/gitCommand.ts +src/core/git/gitLogHandle.ts +src/core/output/outputGenerate.ts + + + +2025-08-21 00:09:43 +0900 +Merge pull request #795 from yamadashy/chore/ratchet-update-ci + +.github/workflows/ratchet-update.yml + + + ``` ::: tip 為什麼選擇 XML? @@ -66,6 +87,19 @@ helper.ts ```typescript // 文件內容 ``` + +# Git 記錄 +``` +2025-08-20 00:47:19 +0900|feat(cli): Add --include-logs option for git commit history +README.md +src/cli/cliRun.ts +src/core/git/gitCommand.ts +src/core/git/gitLogHandle.ts +src/core/output/outputGenerate.ts + +2025-08-21 00:09:43 +0900|Merge pull request #795 from yamadashy/chore/ratchet-update-ci +.github/workflows/ratchet-update.yml +``` ``` ## 在 AI 模型中的使用 @@ -99,4 +133,36 @@ repomix --style plain ================ 文件概要 +================ +(元數據和 AI 指令) + +================ +目錄結構 +================ +src/ + index.ts + utils/ + helper.ts + +================ +文件 +================ + +================ +File: src/index.ts +================ +// 文件內容 + +================ +Git 記錄 +================ +2025-08-20 00:47:19 +0900|feat(cli): Add --include-logs option for git commit history +README.md +src/cli/cliRun.ts +src/core/git/gitCommand.ts +src/core/git/gitLogHandle.ts +src/core/output/outputGenerate.ts + +2025-08-21 00:09:43 +0900|Merge pull request #795 from yamadashy/chore/ratchet-update-ci +.github/workflows/ratchet-update.yml ``` diff --git a/website/client/src/zh-tw/guide/usage.md b/website/client/src/zh-tw/guide/usage.md index b2f8c8cf5..62e27ce1e 100644 --- a/website/client/src/zh-tw/guide/usage.md +++ b/website/client/src/zh-tw/guide/usage.md @@ -93,6 +93,30 @@ repomix --compress repomix --remote yamadashy/repomix --compress ``` +### Git整合 + +包含Git資訊以為AI分析提供開發脈絡: + +```bash +# 包含git差異(未提交的變更) +repomix --include-diffs + +# 包含git提交記錄(預設為最後50次提交) +repomix --include-logs + +# 包含特定數量的提交 +repomix --include-logs --include-logs-count 10 + +# 同時包含差異和記錄 +repomix --include-diffs --include-logs +``` + +這會添加有價值的脈絡資訊: +- **最近的變更**:Git差異顯示未提交的修改 +- **開發模式**:Git記錄揭示哪些檔案通常一起變更 +- **提交歷史**:最近的提交訊息提供對開發重點的洞察 +- **檔案關係**:了解哪些檔案在同一次提交中被修改 + ### 權杖數量最佳化 了解程式碼庫的權杖分布對於最佳化AI互動至關重要。使用 `--token-count-tree` 選項可視化整個專案的權杖使用情況: