Fix OpenCode config path, FTS extension load order, error messages, and CLAUDE.md stats (#781)

This commit is contained in:
Mr. WorldwideBrown 2026-04-11 10:48:14 +05:30 committed by GitHub
parent d87744fffc
commit 7c983d798f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 39 additions and 16 deletions

View file

@ -264,11 +264,13 @@ const fetchWithTimeout = async (
const assertOk = async (response: Response): Promise<void> => {
if (response.ok) return;
let message = `Backend returned ${response.status} ${response.statusText}`;
let message = response.statusText;
try {
const body = await response.json();
if (body && typeof body.error === 'string') {
message = body.error;
} else if (body && typeof body.message === 'string') {
message = body.message;
}
} catch {
// Response body was not JSON

View file

@ -26,6 +26,7 @@ interface RepoStats {
export interface AIContextOptions {
skipAgentsMd?: boolean;
noStats?: boolean;
}
const GITNEXUS_START_MARKER = '<!-- gitnexus:start -->';
@ -64,6 +65,7 @@ function generateGitNexusContent(
stats: RepoStats,
generatedSkills?: GeneratedSkillInfo[],
groupNames?: string[],
noStats?: boolean,
): string {
const generatedRows =
generatedSkills && generatedSkills.length > 0
@ -87,7 +89,7 @@ function generateGitNexusContent(
return `${GITNEXUS_START_MARKER}
# GitNexus Code Intelligence
This project is indexed by GitNexus as **${projectName}** (${stats.nodes || 0} symbols, ${stats.edges || 0} relationships, ${stats.processes || 0} execution flows). Use the GitNexus MCP tools to understand code, assess impact, and navigate safely.
This project is indexed by GitNexus as **${projectName}**${noStats ? '' : ` (${stats.nodes || 0} symbols, ${stats.edges || 0} relationships, ${stats.processes || 0} execution flows)`}. Use the GitNexus MCP tools to understand code, assess impact, and navigate safely.
> If any GitNexus tool warns the index is stale, run \`npx gitnexus analyze\` in terminal first.
@ -332,7 +334,13 @@ export async function generateAIContextFiles(
options?: AIContextOptions,
): Promise<{ files: string[] }> {
const groupNames = await findGroupsContainingRegistryName(projectName);
const content = generateGitNexusContent(projectName, stats, generatedSkills, groupNames);
const content = generateGitNexusContent(
projectName,
stats,
generatedSkills,
groupNames,
options?.noStats,
);
const createdFiles: string[] = [];
if (!options?.skipAgentsMd) {

View file

@ -47,6 +47,8 @@ export interface AnalyzeOptions {
verbose?: boolean;
/** Skip AGENTS.md and CLAUDE.md gitnexus block updates. */
skipAgentsMd?: boolean;
/** Omit volatile symbol/relationship counts from AGENTS.md and CLAUDE.md. */
noStats?: boolean;
/** Index the folder even when no .git directory is present. */
skipGit?: boolean;
}
@ -177,6 +179,7 @@ export const analyzeCommand = async (inputPath?: string, options?: AnalyzeOption
embeddings: options?.embeddings,
skipGit: options?.skipGit,
skipAgentsMd: options?.skipAgentsMd,
noStats: options?.noStats,
},
{
onProgress: (_phase, percent, message) => {
@ -240,7 +243,7 @@ export const analyzeCommand = async (inputPath?: string, options?: AnalyzeOption
processes: s.processes,
},
skillResult.skills,
{ skipAgentsMd: options?.skipAgentsMd },
{ skipAgentsMd: options?.skipAgentsMd, noStats: options?.noStats },
);
}
} catch {

View file

@ -26,6 +26,7 @@ program
.option('--embeddings', 'Enable embedding generation for semantic search (off by default)')
.option('--skills', 'Generate repo-specific skill files from detected communities')
.option('--skip-agents-md', 'Skip updating the gitnexus section in AGENTS.md and CLAUDE.md')
.option('--no-stats', 'Omit volatile file/symbol counts from AGENTS.md and CLAUDE.md')
.option('--skip-git', 'Index a folder without requiring a .git directory')
.option('-v, --verbose', 'Enable verbose ingestion warnings (default: false)')
.addHelpText(

View file

@ -265,7 +265,7 @@ async function setupOpenCode(result: SetupResult): Promise<void> {
return;
}
const configPath = path.join(opencodeDir, 'config.json');
const configPath = path.join(opencodeDir, 'opencode.json');
try {
const existing = await readJsonFile(configPath);
const config = existing || {};

View file

@ -909,19 +909,26 @@ export const loadFTSExtension = async (): Promise<void> => {
throw new Error('LadybugDB not initialized. Call initLbug first.');
}
try {
await conn.query('INSTALL fts');
// Try loading locally first (no network required)
await conn.query('LOAD EXTENSION fts');
ftsLoaded = true;
} catch (err: any) {
const msg = err?.message || '';
if (
msg.includes('already loaded') ||
msg.includes('already installed') ||
msg.includes('already exists')
) {
} catch {
// Fall back to install + load (requires network)
try {
await conn.query('INSTALL fts');
await conn.query('LOAD EXTENSION fts');
ftsLoaded = true;
} else {
console.error('GitNexus: FTS extension load failed:', msg);
} catch (err: any) {
const msg = err?.message || '';
if (
msg.includes('already loaded') ||
msg.includes('already installed') ||
msg.includes('already exists')
) {
ftsLoaded = true;
} else {
console.error('GitNexus: FTS extension load failed:', msg);
}
}
}
};

View file

@ -48,6 +48,8 @@ export interface AnalyzeOptions {
skipGit?: boolean;
/** Skip AGENTS.md and CLAUDE.md gitnexus block updates. */
skipAgentsMd?: boolean;
/** Omit volatile symbol/relationship counts from AGENTS.md and CLAUDE.md. */
noStats?: boolean;
}
export interface AnalyzeResult {
@ -327,7 +329,7 @@ export async function runFullAnalysis(
processes: pipelineResult.processResult?.stats.totalProcesses,
},
undefined,
{ skipAgentsMd: options.skipAgentsMd },
{ skipAgentsMd: options.skipAgentsMd, noStats: options.noStats },
);
} catch {
// Best-effort — don't fail the entire analysis for context file issues