rlm-analyzer 1.5.1 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +55 -0
- package/README.md +35 -0
- package/dist/analyzer.d.ts +32 -2
- package/dist/analyzer.d.ts.map +1 -1
- package/dist/analyzer.js +132 -7
- package/dist/analyzer.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +57 -4
- package/dist/cli.js.map +1 -1
- package/dist/file-chunker.d.ts +61 -0
- package/dist/file-chunker.d.ts.map +1 -0
- package/dist/file-chunker.js +256 -0
- package/dist/file-chunker.js.map +1 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/mcp-server.js +1 -1
- package/dist/orchestrator.d.ts +6 -0
- package/dist/orchestrator.d.ts.map +1 -1
- package/dist/orchestrator.js +79 -6
- package/dist/orchestrator.js.map +1 -1
- package/dist/prompts.d.ts +5 -0
- package/dist/prompts.d.ts.map +1 -1
- package/dist/prompts.js +12 -0
- package/dist/prompts.js.map +1 -1
- package/dist/structural-index.d.ts +89 -0
- package/dist/structural-index.d.ts.map +1 -0
- package/dist/structural-index.js +721 -0
- package/dist/structural-index.js.map +1 -0
- package/dist/supply-chain.d.ts +11 -0
- package/dist/supply-chain.d.ts.map +1 -0
- package/dist/supply-chain.js +359 -0
- package/dist/supply-chain.js.map +1 -0
- package/dist/types.d.ts +146 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +51 -14
- package/dist/types.js.map +1 -1
- package/package.json +9 -3
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,61 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [Unreleased] - 2026-03-31
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- **`rlm supply-chain` command** (BZL-21): Real-time CVE and malicious package detection
|
|
12
|
+
- Scans `package.json` (npm), `requirements.txt` (PyPI), and `go.mod` (Go) dependencies
|
|
13
|
+
- Queries [OSV.dev API](https://osv.dev) for each dependency with max 10 concurrent requests
|
|
14
|
+
- Flags `MAL-*` prefixed OSV IDs as MALICIOUS (separate from CVEs) with CRITICAL severity
|
|
15
|
+
- Runs `npm audit --json` as secondary signal and merges results
|
|
16
|
+
- Outputs color-coded report: 🚨 MALICIOUS / ⚠️ CRITICAL / HIGH / MEDIUM
|
|
17
|
+
- `--fix` flag shows remediation commands for vulnerable packages
|
|
18
|
+
- `--deep` flag for transitive dependency scanning
|
|
19
|
+
- `--ecosystem <npm|pypi|go>` flag to override auto-detection
|
|
20
|
+
- New types: `SupplyChainResult`, `VulnerabilityFinding`, `SupplyChainOptions`
|
|
21
|
+
- New prompt: `SUPPLY_CHAIN_PROMPT` for AI-assisted supply chain risk assessment
|
|
22
|
+
|
|
23
|
+
## [1.6.0] - 2026-01-22
|
|
24
|
+
|
|
25
|
+
### Added
|
|
26
|
+
- **Structural Indexing with Caching**: Smart file indexing for faster analysis
|
|
27
|
+
- SHA-256 file hashing for change detection
|
|
28
|
+
- Import/export extraction for dependency analysis
|
|
29
|
+
- File clustering for grouped analysis
|
|
30
|
+
- Cache stored in `~/.rlm-analyzer/cache/`
|
|
31
|
+
- ~10x faster subsequent runs on unchanged files
|
|
32
|
+
- **Large File Chunking**: Intelligent handling of files >200KB
|
|
33
|
+
- Smart chunking by logical boundaries (functions, classes, interfaces)
|
|
34
|
+
- Skeleton extraction without LLM (signatures, exports, imports)
|
|
35
|
+
- Summary generation for context preservation
|
|
36
|
+
- **Stuck Detection and Recovery**: Prevents infinite analysis loops
|
|
37
|
+
- Tracks consecutive no-code turns
|
|
38
|
+
- Escalating prompts after repeated failures
|
|
39
|
+
- Force completion after turn 5 with 0 sub-LLM calls
|
|
40
|
+
- Before: 20 turns, timeout ❌ → After: 1 turn, completion ✅
|
|
41
|
+
- **Extended File Extensions**: Better coverage for modern codebases
|
|
42
|
+
- Added `.graphql`, `.gql`, `.proto`, `.prisma`
|
|
43
|
+
- Added `.tf`, `.tfvars`, `.hcl` (Infrastructure as Code)
|
|
44
|
+
- Added common config files (Dockerfile, Makefile, etc.)
|
|
45
|
+
- **CLI Cache Options**: Control over structural index caching
|
|
46
|
+
- `--no-cache` flag to force fresh analysis
|
|
47
|
+
- `clear-cache` command to clear index for a directory
|
|
48
|
+
|
|
49
|
+
### Changed
|
|
50
|
+
- `analyzeCodebase()` now uses structural index by default
|
|
51
|
+
- File loading prioritizes entry points based on cluster analysis
|
|
52
|
+
- Analysis order optimized based on dependency graph
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## [1.5.1] - 2026-01-22
|
|
57
|
+
|
|
58
|
+
### Fixed
|
|
59
|
+
- Fixed hardcoded version strings in CLI and MCP server
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
8
63
|
## [1.5.0] - 2026-01-22
|
|
9
64
|
|
|
10
65
|
### Added
|
package/README.md
CHANGED
|
@@ -17,6 +17,7 @@ Analyze any codebase with AI that can process **100x beyond context limits**. Po
|
|
|
17
17
|
- **Symbol Search** - Find all usages of functions, classes, variables
|
|
18
18
|
- **Custom Questions** - Ask anything about your codebase
|
|
19
19
|
- **Multi-Provider Support** - Choose between Gemini (default), Amazon Bedrock (Nova/Claude/Llama), or Claude (Anthropic API)
|
|
20
|
+
- **Supply Chain Security** - Real-time CVE and malicious package detection via OSV.dev API
|
|
20
21
|
- **Web Grounding** - Verify package versions with real-time web search (Gemini & Nova Premier)
|
|
21
22
|
- **MCP Integration** - Works with Claude Code, Cursor, and other MCP clients
|
|
22
23
|
- **Cost Efficient** - Save 60-73% on API costs by offloading to Gemini/Nova
|
|
@@ -141,6 +142,40 @@ rlm ask "How does authentication work?"
|
|
|
141
142
|
|
|
142
143
|
---
|
|
143
144
|
|
|
145
|
+
|
|
146
|
+
### Supply Chain Scan (CVE & Malicious Package Detection)
|
|
147
|
+
|
|
148
|
+
Scan your project dependencies against [OSV.dev](https://osv.dev) for known CVEs and malicious packages:
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
# Scan npm dependencies (auto-detects package.json)
|
|
152
|
+
rlm supply-chain
|
|
153
|
+
|
|
154
|
+
# Show fix versions for all vulnerable packages
|
|
155
|
+
rlm supply-chain --fix
|
|
156
|
+
|
|
157
|
+
# Scan a specific ecosystem
|
|
158
|
+
rlm supply-chain --ecosystem pypi
|
|
159
|
+
|
|
160
|
+
# Include transitive dependencies
|
|
161
|
+
rlm supply-chain --deep
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
Example output:
|
|
165
|
+
```
|
|
166
|
+
🔍 Supply Chain Scan — my-project
|
|
167
|
+
|
|
168
|
+
🚨 MALICIOUS (1)
|
|
169
|
+
axios@1.14.1 — MAL-2026-2307
|
|
170
|
+
Malicious code detected. Remove immediately. Safe version: 1.13.5
|
|
171
|
+
|
|
172
|
+
⚠️ CRITICAL CVEs (0)
|
|
173
|
+
✅ HIGH CVEs (0)
|
|
174
|
+
|
|
175
|
+
📦 Scanned: 47 packages | Clean: 46 | At risk: 1
|
|
176
|
+
Run with --fix to see remediation commands.
|
|
177
|
+
```
|
|
178
|
+
|
|
144
179
|
## CLI Reference
|
|
145
180
|
|
|
146
181
|
### Commands
|
package/dist/analyzer.d.ts
CHANGED
|
@@ -1,24 +1,54 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Code Analysis High-Level API
|
|
3
3
|
* Provides easy-to-use functions for common analysis tasks
|
|
4
|
+
*
|
|
5
|
+
* Features:
|
|
6
|
+
* - Structural indexing with caching for faster subsequent runs
|
|
7
|
+
* - Dependency graph for cross-file analysis
|
|
8
|
+
* - Large file chunking to avoid missing important code
|
|
9
|
+
* - Smart analysis ordering based on file clusters
|
|
4
10
|
*/
|
|
5
|
-
import type { CodeAnalysisOptions, CodeAnalysisResult } from './types.js';
|
|
11
|
+
import type { CodeAnalysisOptions, CodeAnalysisResult, StructuralIndex } from './types.js';
|
|
6
12
|
/** Default maximum file size in bytes (100KB) */
|
|
7
13
|
export declare const DEFAULT_MAX_FILE_SIZE = 100000;
|
|
8
14
|
/** Default analysis type when not specified */
|
|
9
15
|
export declare const DEFAULT_ANALYSIS_TYPE: "summary";
|
|
10
16
|
/**
|
|
11
|
-
* Load files from a directory
|
|
17
|
+
* Load files from a directory (legacy function for backward compatibility)
|
|
12
18
|
*/
|
|
13
19
|
export declare function loadFiles(directory: string, options?: {
|
|
14
20
|
include?: string[];
|
|
15
21
|
exclude?: string[];
|
|
16
22
|
maxFileSize?: number;
|
|
17
23
|
}): Record<string, string>;
|
|
24
|
+
/**
|
|
25
|
+
* Load files using structural index with large file handling
|
|
26
|
+
* Returns both the files and the structural index for dependency information
|
|
27
|
+
*/
|
|
28
|
+
export declare function loadFilesWithIndex(directory: string, options?: {
|
|
29
|
+
include?: string[];
|
|
30
|
+
exclude?: string[];
|
|
31
|
+
maxFileSize?: number;
|
|
32
|
+
useCache?: boolean;
|
|
33
|
+
verbose?: boolean;
|
|
34
|
+
}): Promise<{
|
|
35
|
+
files: Record<string, string>;
|
|
36
|
+
index: StructuralIndex;
|
|
37
|
+
largeFiles: string[];
|
|
38
|
+
}>;
|
|
18
39
|
/**
|
|
19
40
|
* Analyze a codebase with custom query
|
|
41
|
+
* Now uses structural indexing for:
|
|
42
|
+
* - Faster subsequent runs (cached file index)
|
|
43
|
+
* - Better analysis ordering (entry points first)
|
|
44
|
+
* - Large file handling (chunking with summaries)
|
|
45
|
+
* - Dependency information for cross-file analysis
|
|
20
46
|
*/
|
|
21
47
|
export declare function analyzeCodebase(options: CodeAnalysisOptions): Promise<CodeAnalysisResult>;
|
|
48
|
+
/**
|
|
49
|
+
* Clear the structural index cache for a directory
|
|
50
|
+
*/
|
|
51
|
+
export declare function clearIndexCache(directory: string): void;
|
|
22
52
|
/**
|
|
23
53
|
* Analyze architecture
|
|
24
54
|
*/
|
package/dist/analyzer.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analyzer.d.ts","sourceRoot":"","sources":["../src/analyzer.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"analyzer.d.ts","sourceRoot":"","sources":["../src/analyzer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,KAAK,EACV,mBAAmB,EACnB,kBAAkB,EAClB,eAAe,EAChB,MAAM,YAAY,CAAC;AAgBpB,iDAAiD;AACjD,eAAO,MAAM,qBAAqB,SAAU,CAAC;AAK7C,+CAA+C;AAC/C,eAAO,MAAM,qBAAqB,EAAG,SAAkB,CAAC;AAyBxD;;GAEG;AACH,wBAAgB,SAAS,CACvB,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE;IACP,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;CACjB,GACL,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CA6CxB;AAED;;;GAGG;AACH,wBAAsB,kBAAkB,CACtC,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE;IACP,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;CACd,GACL,OAAO,CAAC;IACT,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,KAAK,EAAE,eAAe,CAAC;IACvB,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC,CA4DD;AAED;;;;;;;GAOG;AACH,wBAAsB,eAAe,CACnC,OAAO,EAA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C,mBAAmB,CAAM,GACzC,OAAO,CAAC,kBAAkB,CAAC,CAiB7B;AAED;;GAEG;AACH,wBAAsB,WAAW,CAC/B,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,OAAO,CAAC,mBAAmB,CAAM,GACzC,OAAO,CAAC,kBAAkB,CAAC,CAO7B"}
|
package/dist/analyzer.js
CHANGED
|
@@ -1,15 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Code Analysis High-Level API
|
|
3
3
|
* Provides easy-to-use functions for common analysis tasks
|
|
4
|
+
*
|
|
5
|
+
* Features:
|
|
6
|
+
* - Structural indexing with caching for faster subsequent runs
|
|
7
|
+
* - Dependency graph for cross-file analysis
|
|
8
|
+
* - Large file chunking to avoid missing important code
|
|
9
|
+
* - Smart analysis ordering based on file clusters
|
|
4
10
|
*/
|
|
5
11
|
import * as fs from 'fs';
|
|
6
12
|
import * as path from 'path';
|
|
7
|
-
import { CODE_EXTENSIONS, IGNORE_DIRS } from './types.js';
|
|
13
|
+
import { CODE_EXTENSIONS, INCLUDE_FILENAMES, IGNORE_DIRS } from './types.js';
|
|
8
14
|
import { RLMOrchestrator } from './orchestrator.js';
|
|
9
15
|
import { getAnalysisPrompt } from './prompts.js';
|
|
10
16
|
import { verifySecurityRecommendations, appendGroundingSources } from './grounding.js';
|
|
17
|
+
import { buildStructuralIndex, updateStructuralIndex, getAnalysisPriority, clearCache, } from './structural-index.js';
|
|
18
|
+
import { processLargeFile, createLargeFileSummary, } from './file-chunker.js';
|
|
11
19
|
/** Default maximum file size in bytes (100KB) */
|
|
12
20
|
export const DEFAULT_MAX_FILE_SIZE = 100_000;
|
|
21
|
+
/** Large file threshold - files above this get chunked (200KB) */
|
|
22
|
+
const LARGE_FILE_THRESHOLD = 200_000;
|
|
13
23
|
/** Default analysis type when not specified */
|
|
14
24
|
export const DEFAULT_ANALYSIS_TYPE = 'summary';
|
|
15
25
|
/**
|
|
@@ -41,14 +51,18 @@ function calculateTimeout(fileCount) {
|
|
|
41
51
|
return 300000; // 5 minutes default
|
|
42
52
|
}
|
|
43
53
|
/**
|
|
44
|
-
* Load files from a directory
|
|
54
|
+
* Load files from a directory (legacy function for backward compatibility)
|
|
45
55
|
*/
|
|
46
56
|
export function loadFiles(directory, options = {}) {
|
|
47
57
|
const files = {};
|
|
48
58
|
const maxSize = options.maxFileSize || DEFAULT_MAX_FILE_SIZE;
|
|
49
59
|
const includeExts = options.include || CODE_EXTENSIONS;
|
|
50
60
|
const excludeDirs = [...IGNORE_DIRS, ...(options.exclude || [])];
|
|
51
|
-
function shouldInclude(filePath) {
|
|
61
|
+
function shouldInclude(filePath, fileName) {
|
|
62
|
+
// Check by filename first
|
|
63
|
+
if (INCLUDE_FILENAMES.includes(fileName)) {
|
|
64
|
+
return true;
|
|
65
|
+
}
|
|
52
66
|
const ext = path.extname(filePath);
|
|
53
67
|
return includeExts.some(e => ext === e || filePath.endsWith(e));
|
|
54
68
|
}
|
|
@@ -63,7 +77,7 @@ export function loadFiles(directory, options = {}) {
|
|
|
63
77
|
walk(fullPath);
|
|
64
78
|
}
|
|
65
79
|
}
|
|
66
|
-
else if (entry.isFile() && shouldInclude(entry.name)) {
|
|
80
|
+
else if (entry.isFile() && shouldInclude(relativePath, entry.name)) {
|
|
67
81
|
try {
|
|
68
82
|
const stats = fs.statSync(fullPath);
|
|
69
83
|
if (stats.size <= maxSize) {
|
|
@@ -83,16 +97,81 @@ export function loadFiles(directory, options = {}) {
|
|
|
83
97
|
walk(directory);
|
|
84
98
|
return files;
|
|
85
99
|
}
|
|
100
|
+
/**
|
|
101
|
+
* Load files using structural index with large file handling
|
|
102
|
+
* Returns both the files and the structural index for dependency information
|
|
103
|
+
*/
|
|
104
|
+
export async function loadFilesWithIndex(directory, options = {}) {
|
|
105
|
+
const { maxFileSize = DEFAULT_MAX_FILE_SIZE, useCache = true, verbose = false, } = options;
|
|
106
|
+
// Build or load structural index
|
|
107
|
+
let index;
|
|
108
|
+
let changedFiles;
|
|
109
|
+
if (useCache) {
|
|
110
|
+
const result = await updateStructuralIndex(directory, { verbose });
|
|
111
|
+
index = result.index;
|
|
112
|
+
changedFiles = result.changedFiles;
|
|
113
|
+
if (verbose && changedFiles.length > 0) {
|
|
114
|
+
console.log(`[Index] ${changedFiles.length} files changed since last run`);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
index = await buildStructuralIndex(directory, { force: true, verbose });
|
|
119
|
+
}
|
|
120
|
+
const files = {};
|
|
121
|
+
const largeFiles = [];
|
|
122
|
+
// Get files in analysis priority order (entry points first)
|
|
123
|
+
const prioritizedFiles = getAnalysisPriority(index);
|
|
124
|
+
for (const relativePath of prioritizedFiles) {
|
|
125
|
+
const entry = index.files[relativePath];
|
|
126
|
+
if (!entry)
|
|
127
|
+
continue;
|
|
128
|
+
const fullPath = path.join(directory, relativePath);
|
|
129
|
+
try {
|
|
130
|
+
const content = fs.readFileSync(fullPath, 'utf-8');
|
|
131
|
+
if (entry.size > LARGE_FILE_THRESHOLD) {
|
|
132
|
+
// Process large file - create summary instead of full content
|
|
133
|
+
const processed = processLargeFile(content, relativePath);
|
|
134
|
+
files[relativePath] = createLargeFileSummary(processed);
|
|
135
|
+
largeFiles.push(relativePath);
|
|
136
|
+
if (verbose) {
|
|
137
|
+
console.log(`[Chunker] Large file ${relativePath}: ${processed.chunkCount} chunks`);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
else if (entry.size <= maxFileSize) {
|
|
141
|
+
// Normal file - include full content
|
|
142
|
+
files[relativePath] = content;
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
// Medium-large file - include but note it's truncated
|
|
146
|
+
files[relativePath] = content.slice(0, maxFileSize) +
|
|
147
|
+
`\n\n// ... truncated (${Math.round(entry.size / 1024)}KB total)`;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
catch {
|
|
151
|
+
// Skip unreadable files
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return { files, index, largeFiles };
|
|
155
|
+
}
|
|
86
156
|
/**
|
|
87
157
|
* Analyze a codebase with custom query
|
|
158
|
+
* Now uses structural indexing for:
|
|
159
|
+
* - Faster subsequent runs (cached file index)
|
|
160
|
+
* - Better analysis ordering (entry points first)
|
|
161
|
+
* - Large file handling (chunking with summaries)
|
|
162
|
+
* - Dependency information for cross-file analysis
|
|
88
163
|
*/
|
|
89
164
|
export async function analyzeCodebase(options) {
|
|
90
|
-
const
|
|
165
|
+
const useCache = options.useCache !== false; // Default to true
|
|
166
|
+
const analysisType = options.analysisType || DEFAULT_ANALYSIS_TYPE;
|
|
167
|
+
// Load files with structural index
|
|
168
|
+
const { files, index, largeFiles } = await loadFilesWithIndex(options.directory, {
|
|
91
169
|
include: options.include,
|
|
92
170
|
exclude: options.exclude,
|
|
171
|
+
useCache,
|
|
172
|
+
verbose: options.verbose,
|
|
93
173
|
});
|
|
94
174
|
const fileCount = Object.keys(files).length;
|
|
95
|
-
const analysisType = options.analysisType || DEFAULT_ANALYSIS_TYPE;
|
|
96
175
|
if (fileCount === 0) {
|
|
97
176
|
return {
|
|
98
177
|
success: false,
|
|
@@ -105,7 +184,13 @@ export async function analyzeCodebase(options) {
|
|
|
105
184
|
error: 'No files found to analyze',
|
|
106
185
|
};
|
|
107
186
|
}
|
|
108
|
-
|
|
187
|
+
// Build enhanced query with structural context
|
|
188
|
+
let query = options.query || getAnalysisPrompt(analysisType);
|
|
189
|
+
// Add structural context to help LLM understand codebase organization
|
|
190
|
+
if (index.clusters.length > 0 || index.metadata.frameworks.length > 0) {
|
|
191
|
+
const structuralContext = buildStructuralContext(index, largeFiles);
|
|
192
|
+
query = `${structuralContext}\n\n${query}`;
|
|
193
|
+
}
|
|
109
194
|
// Calculate smart max turns and timeout based on codebase size
|
|
110
195
|
const maxTurns = options.maxTurns || calculateMaxTurns(fileCount);
|
|
111
196
|
const timeoutMs = calculateTimeout(fileCount);
|
|
@@ -122,6 +207,46 @@ export async function analyzeCodebase(options) {
|
|
|
122
207
|
analysisType,
|
|
123
208
|
};
|
|
124
209
|
}
|
|
210
|
+
/**
|
|
211
|
+
* Build structural context string to prepend to analysis queries
|
|
212
|
+
*/
|
|
213
|
+
function buildStructuralContext(index, largeFiles) {
|
|
214
|
+
const parts = ['## Codebase Structure\n'];
|
|
215
|
+
// Add metadata
|
|
216
|
+
if (index.metadata.frameworks.length > 0) {
|
|
217
|
+
parts.push(`**Frameworks detected:** ${index.metadata.frameworks.join(', ')}`);
|
|
218
|
+
}
|
|
219
|
+
if (index.metadata.packageManager) {
|
|
220
|
+
parts.push(`**Package manager:** ${index.metadata.packageManager}`);
|
|
221
|
+
}
|
|
222
|
+
if (index.metadata.languages.length > 0) {
|
|
223
|
+
parts.push(`**Languages:** ${index.metadata.languages.join(', ')}`);
|
|
224
|
+
}
|
|
225
|
+
// Add cluster summary
|
|
226
|
+
if (index.clusters.length > 0) {
|
|
227
|
+
parts.push('\n**File clusters (related modules):**');
|
|
228
|
+
for (const cluster of index.clusters.slice(0, 10)) {
|
|
229
|
+
const entryPoints = cluster.entryPoints.slice(0, 2).join(', ');
|
|
230
|
+
parts.push(`- ${cluster.type}: ${cluster.files.length} files (entry: ${entryPoints || 'N/A'})`);
|
|
231
|
+
}
|
|
232
|
+
if (index.clusters.length > 10) {
|
|
233
|
+
parts.push(`- ... and ${index.clusters.length - 10} more clusters`);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
// Note large files
|
|
237
|
+
if (largeFiles.length > 0) {
|
|
238
|
+
parts.push(`\n**Large files (summarized):** ${largeFiles.join(', ')}`);
|
|
239
|
+
parts.push('*Note: Large files are shown as summaries. Request specific sections if needed.*');
|
|
240
|
+
}
|
|
241
|
+
parts.push('');
|
|
242
|
+
return parts.join('\n');
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Clear the structural index cache for a directory
|
|
246
|
+
*/
|
|
247
|
+
export function clearIndexCache(directory) {
|
|
248
|
+
clearCache(directory);
|
|
249
|
+
}
|
|
125
250
|
/**
|
|
126
251
|
* Analyze architecture
|
|
127
252
|
*/
|
package/dist/analyzer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analyzer.js","sourceRoot":"","sources":["../src/analyzer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAK7B,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,6BAA6B,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAEvF,iDAAiD;AACjD,MAAM,CAAC,MAAM,qBAAqB,GAAG,OAAO,CAAC;AAE7C,+CAA+C;AAC/C,MAAM,CAAC,MAAM,qBAAqB,GAAG,SAAkB,CAAC;AAExD;;;GAGG;AACH,SAAS,iBAAiB,CAAC,SAAiB;IAC1C,IAAI,SAAS,IAAI,GAAG;QAAE,OAAO,EAAE,CAAC,CAAE,sBAAsB;IACxD,IAAI,SAAS,IAAI,GAAG;QAAE,OAAO,EAAE,CAAC,CAAE,iBAAiB;IACnD,IAAI,SAAS,IAAI,EAAE;QAAE,OAAO,EAAE,CAAC,CAAG,kBAAkB;IACpD,IAAI,SAAS,IAAI,EAAE;QAAE,OAAO,EAAE,CAAC,CAAG,iBAAiB;IACnD,OAAO,EAAE,CAAC,CAAyB,gBAAgB;AACrD,CAAC;AAED;;;GAGG;AACH,SAAS,gBAAgB,CAAC,SAAiB;IACzC,IAAI,SAAS,IAAI,GAAG;QAAE,OAAO,MAAM,CAAC,CAAE,aAAa;IACnD,IAAI,SAAS,IAAI,GAAG;QAAE,OAAO,MAAM,CAAC,CAAE,aAAa;IACnD,IAAI,SA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AAC;QACrB,GAAG,OAAO;QACV,SAAS;QACT,YAAY,EAAE,QAAQ;QACtB,KAAK;KACN,CAAC,CAAC;AACL,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,SAAiB,EACjB,QAAgB,EAChB,UAAwC,EAAE;IAE1C,OAAO,eAAe,CAAC;QACrB,GAAG,OAAO;QACV,SAAS;QACT,YAAY,EAAE,QAAQ;QACtB,KAAK,EAAE,QAAQ;KAChB,CAAC,CAAC;AACL,CAAC"}
|
package/dist/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAyrBH,wBAAsB,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CA0I5C"}
|
package/dist/cli.js
CHANGED
|
@@ -27,10 +27,11 @@
|
|
|
27
27
|
* --help, -h Show help
|
|
28
28
|
*/
|
|
29
29
|
import * as path from 'path';
|
|
30
|
-
import { analyzeArchitecture, analyzeDependencies, analyzeSecurity, analyzePerformance, analyzeRefactoring, summarizeCodebase, findUsages, explainFile, askQuestion, } from './analyzer.js';
|
|
30
|
+
import { analyzeArchitecture, analyzeDependencies, analyzeSecurity, analyzePerformance, analyzeRefactoring, summarizeCodebase, findUsages, explainFile, askQuestion, clearIndexCache, } from './analyzer.js';
|
|
31
31
|
import { hasApiKey, hasBedrockCredentials, hasClaudeCredentials, initConfig, getApiKey, initializeProvider, detectProvider, } from './config.js';
|
|
32
32
|
import { getDefaultModel, resolveModelConfig, resolveProviderModelAlias, AVAILABLE_MODELS, AVAILABLE_BEDROCK_MODELS, AVAILABLE_CLAUDE_MODELS, getAliasesDisplay, } from './models.js';
|
|
33
33
|
import * as fs from 'fs';
|
|
34
|
+
import { runSupplyChainScan } from './supply-chain.js';
|
|
34
35
|
// ANSI colors
|
|
35
36
|
const colors = {
|
|
36
37
|
reset: '\x1b[0m',
|
|
@@ -146,6 +147,8 @@ ${colors.bold}Commands:${colors.reset}
|
|
|
146
147
|
${colors.green}ask${colors.reset} "<question>" Ask a custom question
|
|
147
148
|
${colors.green}config${colors.reset} [api-key] Configure or show API key status
|
|
148
149
|
${colors.green}test${colors.reset} Test API connection and model availability
|
|
150
|
+
${colors.green}clear-cache${colors.reset} Clear structural index cache for a directory
|
|
151
|
+
${colors.green}supply-chain${colors.reset} Scan dependencies for CVEs and supply chain risks
|
|
149
152
|
|
|
150
153
|
${colors.bold}Options:${colors.reset}
|
|
151
154
|
--dir, -d <path> Directory to analyze (default: current directory)
|
|
@@ -156,6 +159,7 @@ ${colors.bold}Options:${colors.reset}
|
|
|
156
159
|
Aliases: sonnet, opus, haiku (claude)
|
|
157
160
|
--output, -o <file> Save results to markdown file (e.g., rlm-context.md)
|
|
158
161
|
--grounding, -g Enable web grounding to verify package versions (security only)
|
|
162
|
+
--no-cache Disable structural index caching (force fresh analysis)
|
|
159
163
|
--verbose, -v Show detailed turn-by-turn output
|
|
160
164
|
--json Output results as JSON
|
|
161
165
|
--help, -h Show this help message
|
|
@@ -252,6 +256,10 @@ function parseArgs(args) {
|
|
|
252
256
|
version: false,
|
|
253
257
|
output: null,
|
|
254
258
|
grounding: false,
|
|
259
|
+
noCache: false,
|
|
260
|
+
deep: false,
|
|
261
|
+
fix: false,
|
|
262
|
+
ecosystem: 'npm',
|
|
255
263
|
};
|
|
256
264
|
let command = '';
|
|
257
265
|
let target;
|
|
@@ -323,6 +331,28 @@ function parseArgs(args) {
|
|
|
323
331
|
else if (arg === '--grounding' || arg === '-g') {
|
|
324
332
|
options.grounding = true;
|
|
325
333
|
}
|
|
334
|
+
else if (arg === '--deep') {
|
|
335
|
+
options.deep = true;
|
|
336
|
+
}
|
|
337
|
+
else if (arg === '--fix') {
|
|
338
|
+
options.fix = true;
|
|
339
|
+
}
|
|
340
|
+
else if (arg === '--ecosystem') {
|
|
341
|
+
i++;
|
|
342
|
+
const eco = args[i]?.toLowerCase();
|
|
343
|
+
if (eco === 'npm' || eco === 'pypi' || eco === 'go') {
|
|
344
|
+
options.ecosystem = eco;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
else if (arg.startsWith('--ecosystem=')) {
|
|
348
|
+
const eco = arg.slice(12).toLowerCase();
|
|
349
|
+
if (eco === 'npm' || eco === 'pypi' || eco === 'go') {
|
|
350
|
+
options.ecosystem = eco;
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
else if (arg === '--no-cache') {
|
|
354
|
+
options.noCache = true;
|
|
355
|
+
}
|
|
326
356
|
else if (!command) {
|
|
327
357
|
command = arg;
|
|
328
358
|
}
|
|
@@ -384,8 +414,22 @@ async function runCommand(command, target, options) {
|
|
|
384
414
|
progressTracker?.start();
|
|
385
415
|
const onTurnComplete = createTurnCallback(options.verbose);
|
|
386
416
|
const onProgress = progressTracker ? createProgressCallback(progressTracker) : undefined;
|
|
387
|
-
const analysisOpts = {
|
|
417
|
+
const analysisOpts = {
|
|
418
|
+
verbose: options.verbose,
|
|
419
|
+
onTurnComplete,
|
|
420
|
+
onProgress,
|
|
421
|
+
model: options.model,
|
|
422
|
+
useCache: !options.noCache,
|
|
423
|
+
};
|
|
388
424
|
let result;
|
|
425
|
+
// Handle clear-cache command before switch
|
|
426
|
+
if (command === 'clear-cache') {
|
|
427
|
+
progressTracker?.stop();
|
|
428
|
+
clearIndexCache(options.dir);
|
|
429
|
+
log(`\nCache cleared for: ${options.dir}`, 'green');
|
|
430
|
+
log('Next analysis will rebuild the structural index.', 'dim');
|
|
431
|
+
process.exit(0);
|
|
432
|
+
}
|
|
389
433
|
switch (command) {
|
|
390
434
|
case 'summary':
|
|
391
435
|
result = await summarizeCodebase(options.dir, analysisOpts);
|
|
@@ -436,6 +480,15 @@ async function runCommand(command, target, options) {
|
|
|
436
480
|
}
|
|
437
481
|
result = await askQuestion(options.dir, target, analysisOpts);
|
|
438
482
|
break;
|
|
483
|
+
case 'supply-chain': {
|
|
484
|
+
progressTracker?.stop();
|
|
485
|
+
await runSupplyChainScan(options.dir, {
|
|
486
|
+
deep: options.deep,
|
|
487
|
+
fix: options.fix,
|
|
488
|
+
ecosystem: options.ecosystem,
|
|
489
|
+
});
|
|
490
|
+
return;
|
|
491
|
+
}
|
|
439
492
|
default:
|
|
440
493
|
log(`Unknown command: ${command}`, 'red');
|
|
441
494
|
log('Run "rlm --help" for usage information', 'dim');
|
|
@@ -527,7 +580,7 @@ function generateMarkdownReport(command, target, directory, result, duration, pr
|
|
|
527
580
|
}
|
|
528
581
|
md += '\n';
|
|
529
582
|
}
|
|
530
|
-
md += `---\n*Analysis performed with RLM Analyzer v1.
|
|
583
|
+
md += `---\n*Analysis performed with RLM Analyzer v1.6.0 using ${provider} provider*\n`;
|
|
531
584
|
return md;
|
|
532
585
|
}
|
|
533
586
|
/**
|
|
@@ -581,7 +634,7 @@ export async function runCli() {
|
|
|
581
634
|
const { command, target, options } = parseArgs(args);
|
|
582
635
|
// Show version
|
|
583
636
|
if (options.version) {
|
|
584
|
-
console.log('rlm-analyzer v1.
|
|
637
|
+
console.log('rlm-analyzer v1.6.0');
|
|
585
638
|
process.exit(0);
|
|
586
639
|
}
|
|
587
640
|
// Show help
|