diff --git a/CLAUDE.md b/CLAUDE.md index 8bd71a7..0438532 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -1,4 +1,3 @@ - # sync-docs > Sync documentation with code changes. Find outdated refs, update CHANGELOG, flag stale examples. @@ -24,7 +23,7 @@ 5. **Always run git hooks** - Never bypass pre-commit or pre-push hooks. 6. **Use single dash for em-dashes** - In prose, use ` - ` (single dash with spaces), never ` -- `. 7. **Report script failures before manual fallback** - Never silently bypass broken tooling. -8. **Token efficiency** - Be concise. Save tokens over decorations. +8. **Token efficiency** - Save tokens over decorations. ## Model Selection diff --git a/lib/collectors/docs-patterns.js b/lib/collectors/docs-patterns.js index 66b22ea..7485246 100644 --- a/lib/collectors/docs-patterns.js +++ b/lib/collectors/docs-patterns.js @@ -17,10 +17,6 @@ const { execFileSync } = require('child_process'); let repoMapModule = null; let repoMapLoadError = null; -// Lazy-load binary module (only available when agent-core syncs it) -let binaryModule = null; -let binaryLoadError = null; - /** * Get the repo-map module, loading it lazily * @returns {{module: Object|null, error: string|null}} @@ -46,27 +42,6 @@ function getRepoMapLoadError() { return repoMapLoadError; } -/** - * Get the binary module, loading it lazily - * @returns {Object|null} - */ -function getBinary() { - if (!binaryModule && !binaryLoadError) { - try { - const lib = require('../index'); - if (lib.binary && typeof lib.binary.runAnalyzer === 'function') { - binaryModule = lib.binary; - } else { - binaryLoadError = 'binary module not available in @agentsys/lib'; - } - } catch (err) { - binaryLoadError = err.message || 'Failed to load binary module'; - binaryModule = null; - } - } - return binaryModule; -} - const DEFAULT_OPTIONS = { cwd: process.cwd() }; @@ -682,40 +657,6 @@ function checkChangelog(changedFiles, options = {}) { }; } -/** - * Get doc-drift signals from agent-analyzer binary. - * - * Returns docs with low code coupling - files that rarely co-change with code - * and are likely drifting out of sync. Requires repo-intel map file to exist. - * - * @param {string} cwd - Working directory (repository root) - * @returns {Array|null} Array of drift entries or null if unavailable - */ -function getDocDriftSignals(cwd) { - const binary = getBinary(); - if (!binary) return null; - - // Resolve map file path: /repo-intel.json - const stateDir = ['.claude', '.opencode', '.codex'] - .find(d => fs.existsSync(path.join(cwd, d))) || '.claude'; - const mapFile = path.join(cwd, stateDir, 'repo-intel.json'); - - if (!fs.existsSync(mapFile)) return null; - - try { - const output = binary.runAnalyzer([ - 'repo-intel', 'query', 'doc-drift', - '--top', '20', - '--map-file', mapFile, - cwd - ]); - return JSON.parse(output); - } catch { - // Binary not available, query failed, or parse error - not critical - return null; - } -} - /** * Collect all documentation-related data * @param {Object} options - Collection options @@ -742,11 +683,9 @@ function collect(options = {}) { } : null }, // New: undocumented exports detection (pass repoMapStatus to avoid redundant call) - undocumentedExports: repoMapStatus.available + undocumentedExports: repoMapStatus.available ? findUndocumentedExports(changedFiles, { ...opts, repoMapStatus }) - : [], - // Doc-drift signals from agent-analyzer (optional, null if unavailable) - docDrift: getDocDriftSignals(opts.cwd) + : [] }; } @@ -767,8 +706,6 @@ module.exports = { findUndocumentedExports, isInternalExport, isEntryPoint, - // Doc-drift integration - getDocDriftSignals, // Utilities escapeRegex, // Diagnostic diff --git a/lib/collectors/git.js b/lib/collectors/git.js index 209a028..552c23d 100644 --- a/lib/collectors/git.js +++ b/lib/collectors/git.js @@ -2,7 +2,7 @@ * Git History Collector * * Collects git history analysis data using the agent-analyzer binary. - * Runs a full git-map init and extracts key metrics for downstream consumers. + * Runs a full repo-intel init and extracts key metrics for downstream consumers. * * @module lib/collectors/git */ @@ -20,7 +20,7 @@ const DEFAULT_OPTIONS = { /** * Collect git history data for the given repository. * - * Runs agent-analyzer git-map init to produce a full map, then extracts + * Runs agent-analyzer repo-intel init to produce a full map, then extracts * key metrics (hotspots, bus factor, AI ratio, etc.) from the result. * * @param {Object} [options={}] - Collection options @@ -44,7 +44,7 @@ function collectGitData(options = {}) { let map; try { - const json = binary.runAnalyzer(['git-map', 'init', cwd]); + const json = binary.runAnalyzer(['repo-intel', 'init', cwd]); map = JSON.parse(json); } catch (err) { return { @@ -57,7 +57,6 @@ function collectGitData(options = {}) { const fileActivity = map.fileActivity || {}; const contributors = map.contributors || {}; const aiAttribution = map.aiAttribution || {}; - const commitShape = map.commitShape || {}; const conventions = map.conventions || {}; const releases = map.releases || {}; @@ -66,6 +65,7 @@ function collectGitData(options = {}) { .map(([path, activity]) => ({ path, changes: activity.totalChanges || 0, + recentChanges: activity.recentChanges || 0, authors: activity.authors ? Object.keys(activity.authors).length : 0, lastChanged: activity.lastChanged || null })) @@ -114,13 +114,14 @@ function collectGitData(options = {}) { attributed: aiAttribution.attributed || 0, heuristic: aiAttribution.heuristic || 0, none: aiAttribution.none || 0, + confidence: aiAttribution.confidence || 'low', tools: aiAttribution.tools || {} }, busFactor, conventions: { style: conventions.style || null, prefixes: conventions.prefixes || {}, - scopes: conventions.scopes || {} + usesScopes: conventions.usesScopes || false }, releaseInfo: { tagCount: releases.tags ? releases.tags.length : 0, @@ -128,11 +129,6 @@ function collectGitData(options = {}) { ? releases.tags[releases.tags.length - 1] : null, cadence: releases.cadence || null - }, - commitShape: { - typicalSize: commitShape.typicalSize || null, - filesPerCommit: commitShape.filesPerCommit || null, - mergeCount: commitShape.mergeCount || 0 } }; } diff --git a/lib/collectors/index.js b/lib/collectors/index.js index f65c8fb..33dfb4b 100644 --- a/lib/collectors/index.js +++ b/lib/collectors/index.js @@ -127,7 +127,6 @@ module.exports = { findUndocumentedExports: docsPatterns.findUndocumentedExports, isInternalExport: docsPatterns.isInternalExport, isEntryPoint: docsPatterns.isEntryPoint, - getDocDriftSignals: docsPatterns.getDocDriftSignals, collectGitData: git.collectGitData,