Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .git-ai/lancedb.tar.gz
Git LFS file not shown
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"scripts": {
"build": "tsc",
"start": "ts-node bin/git-ai.ts",
"test": "npm run build && node --test test/*.test.mjs test/*.test.ts",
"test": "npm run build && node dist/bin/git-ai.js ai index --overwrite && node --test test/*.test.mjs test/*.test.ts",
"test:parser": "ts-node test/verify_parsing.ts"
},
"files": [
Expand Down
51 changes: 0 additions & 51 deletions src/cli/commands/dsrCommands.ts

This file was deleted.

14 changes: 14 additions & 0 deletions src/cli/commands/repoMapCommand.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Command } from 'commander';
import { executeHandler } from '../types';

export const repoMapCommand = new Command('repo-map')
.description('Generate a lightweight repository map (ranked files + top symbols + wiki links)')
.option('-p, --path <path>', 'Path inside the repository', '.')
.option('--max-files <n>', 'Maximum files to include', '20')
.option('--max-symbols <n>', 'Maximum symbols per file', '5')
.option('--depth <n>', 'PageRank iterations (1-20)', '5')
.option('--max-nodes <n>', 'Maximum symbols to process (performance)', '5000')
.option('--wiki <dir>', 'Wiki directory relative to repo root', '')
.action(async (options) => {
await executeHandler('repo-map', options);
});
149 changes: 0 additions & 149 deletions src/cli/handlers/dsrHandlers.ts

This file was deleted.

53 changes: 53 additions & 0 deletions src/cli/handlers/repoMapHandler.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import path from 'path';
import fs from 'fs-extra';
import type { RepoMapInput } from '../schemas/repoMapSchema';
import type { CLIResult, CLIError } from '../types';
import { success, error } from '../types';
import { resolveRepoContext, validateIndex } from '../helpers';
import { generateRepoMap, formatRepoMap } from '../../core/repoMap';

function resolveWikiDir(repoRoot: string, wikiOpt: string): string {
const w = String(wikiOpt ?? '').trim();
if (w) return path.resolve(repoRoot, w);
const candidates = [path.join(repoRoot, 'docs', 'wiki'), path.join(repoRoot, 'wiki')];
for (const c of candidates) {
if (fs.existsSync(c)) return c;
}
return '';
}

export async function handleRepoMap(input: RepoMapInput): Promise<CLIResult | CLIError> {
const ctxResult = await resolveRepoContext(input.path);

if (!('indexStatus' in ctxResult)) {
return error('repo_not_found', { path: input.path });
}

const ctx = ctxResult as { repoRoot: string; meta: unknown; indexStatus: { ok: boolean } };

const validationError = validateIndex(ctx as Parameters<typeof validateIndex>[0]);
if (validationError) {
return validationError;
}

const wikiDir = resolveWikiDir(ctx.repoRoot, input.wiki);

try {
const files = await generateRepoMap({
repoRoot: ctx.repoRoot,
maxFiles: input.maxFiles,
maxSymbolsPerFile: input.maxSymbols,
wikiDir: wikiDir || undefined,
depth: input.depth,
maxNodes: input.maxNodes,
});

return success({
repoRoot: ctx.repoRoot,
files,
formatted: formatRepoMap(files),
});
} catch (e: any) {
return error('repo_map_failed', { message: String(e?.message ?? e) });
}
}
33 changes: 5 additions & 28 deletions src/cli/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,6 @@ import { SearchSymbolsSchema } from './schemas/querySchemas';
import { handleSemanticSearch } from './handlers/semanticHandlers';
import { handleIndexRepo } from './handlers/indexHandlers';
import { handleSearchSymbols } from './handlers/queryHandlers';
import {
DsrContextSchema,
DsrGenerateSchema,
DsrRebuildIndexSchema,
DsrSymbolEvolutionSchema,
} from './schemas/dsrSchemas';
import {
handleDsrContext,
handleDsrGenerate,
handleDsrRebuildIndex,
handleDsrSymbolEvolution,
} from './handlers/dsrHandlers';
import { CheckIndexSchema, StatusSchema } from './schemas/statusSchemas';
import { handleCheckIndex, handleStatus } from './handlers/statusHandlers';
import { PackIndexSchema, UnpackIndexSchema } from './schemas/archiveSchemas';
Expand All @@ -43,6 +31,8 @@ import { InstallHooksSchema, UninstallHooksSchema, HooksStatusSchema } from './s
import { handleInstallHooks, handleUninstallHooks, handleHooksStatus } from './handlers/hooksHandlers';
import { ServeSchema, AgentInstallSchema } from './schemas/serveSchemas';
import { handleServe, handleAgentInstall } from './handlers/serveHandlers';
import { RepoMapSchema } from './schemas/repoMapSchema';
import { handleRepoMap } from './handlers/repoMapHandler';

/**
* Registry of all CLI command handlers
Expand Down Expand Up @@ -93,22 +83,9 @@ export const cliHandlers: Record<string, HandlerRegistration<any>> = {
schema: AgentInstallSchema,
handler: handleAgentInstall,
},
// DSR subcommands
'dsr:context': {
schema: DsrContextSchema,
handler: handleDsrContext,
},
'dsr:generate': {
schema: DsrGenerateSchema,
handler: handleDsrGenerate,
},
'dsr:rebuild-index': {
schema: DsrRebuildIndexSchema,
handler: handleDsrRebuildIndex,
},
'dsr:symbol-evolution': {
schema: DsrSymbolEvolutionSchema,
handler: handleDsrSymbolEvolution,
'repo-map': {
schema: RepoMapSchema,
handler: handleRepoMap,
},
// Hooks subcommands
'hooks:install': {
Expand Down
27 changes: 0 additions & 27 deletions src/cli/schemas/dsrSchemas.ts

This file was deleted.

12 changes: 12 additions & 0 deletions src/cli/schemas/repoMapSchema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { z } from 'zod';

export const RepoMapSchema = z.object({
path: z.string().default('.'),
maxFiles: z.coerce.number().int().positive().default(20),
maxSymbols: z.coerce.number().int().positive().default(5),
depth: z.coerce.number().int().min(1).max(20).default(5),
maxNodes: z.coerce.number().int().positive().default(5000),
wiki: z.string().default(''),
});

export type RepoMapInput = z.infer<typeof RepoMapSchema>;
4 changes: 2 additions & 2 deletions src/commands/ai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import { packCommand, unpackCommand } from '../cli/commands/archiveCommands.js';
import { hooksCommand } from '../cli/commands/hooksCommands.js';
import { graphCommand } from '../cli/commands/graphCommands.js';
import { checkIndexCommand, statusCommand } from '../cli/commands/statusCommands.js';
import { dsrCommand } from '../cli/commands/dsrCommands.js';
import { repoMapCommand } from '../cli/commands/repoMapCommand.js';

export const aiCommand = new Command('ai')
.description('AI features (indexing, search, hooks, MCP)')
.addCommand(indexCommand)
.addCommand(checkIndexCommand)
.addCommand(statusCommand)
.addCommand(dsrCommand)
.addCommand(repoMapCommand)
.addCommand(queryCommand)
.addCommand(semanticCommand)
.addCommand(graphCommand)
Expand Down
Loading