@code-rag/cli 0.1.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/LICENSE +21 -0
- package/README.md +27 -0
- package/dist/cli.test.d.ts +1 -0
- package/dist/cli.test.js +369 -0
- package/dist/cli.test.js.map +1 -0
- package/dist/commands/hooks-cmd.d.ts +53 -0
- package/dist/commands/hooks-cmd.js +279 -0
- package/dist/commands/index-cmd.d.ts +4 -0
- package/dist/commands/index-cmd.js +1037 -0
- package/dist/commands/index-cmd.js.map +1 -0
- package/dist/commands/index-cmd.test.d.ts +1 -0
- package/dist/commands/index-cmd.test.js +74 -0
- package/dist/commands/index-cmd.test.js.map +1 -0
- package/dist/commands/init-wizard.d.ts +95 -0
- package/dist/commands/init-wizard.js +526 -0
- package/dist/commands/init.d.ts +7 -0
- package/dist/commands/init.js +125 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/search.d.ts +7 -0
- package/dist/commands/search.js +124 -0
- package/dist/commands/search.js.map +1 -0
- package/dist/commands/serve.d.ts +2 -0
- package/dist/commands/serve.js +56 -0
- package/dist/commands/serve.js.map +1 -0
- package/dist/commands/status.d.ts +21 -0
- package/dist/commands/status.js +117 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/commands/viewer.d.ts +20 -0
- package/dist/commands/viewer.js +197 -0
- package/dist/commands/viewer.js.map +1 -0
- package/dist/commands/viewer.test.d.ts +1 -0
- package/dist/commands/viewer.test.js +69 -0
- package/dist/commands/viewer.test.js.map +1 -0
- package/dist/commands/watch-cmd.d.ts +8 -0
- package/dist/commands/watch-cmd.js +152 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/package.json +66 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 CodeRAG Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# @code-rag/cli
|
|
2
|
+
|
|
3
|
+
CLI tool for CodeRAG -- init, index, search, serve, and status commands for the intelligent codebase context engine.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g @code-rag/cli
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
coderag init # Initialize a .coderag.yaml config
|
|
15
|
+
coderag index # Index the codebase
|
|
16
|
+
coderag search <q> # Search the indexed codebase
|
|
17
|
+
coderag serve # Start the MCP server
|
|
18
|
+
coderag status # Show index status
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Documentation
|
|
22
|
+
|
|
23
|
+
See the [main repository](https://dev.azure.com/momc-pl/CodeRAG/_git/CodeRAG) for full documentation.
|
|
24
|
+
|
|
25
|
+
## License
|
|
26
|
+
|
|
27
|
+
MIT
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/cli.test.js
ADDED
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
|
2
|
+
import { Command } from 'commander';
|
|
3
|
+
import { registerInitCommand } from './commands/init.js';
|
|
4
|
+
import { registerIndexCommand } from './commands/index-cmd.js';
|
|
5
|
+
import { registerSearchCommand } from './commands/search.js';
|
|
6
|
+
import { registerServeCommand } from './commands/serve.js';
|
|
7
|
+
import { registerStatusCommand } from './commands/status.js';
|
|
8
|
+
import { registerViewerCommand } from './commands/viewer.js';
|
|
9
|
+
import { detectLanguages } from './commands/init.js';
|
|
10
|
+
import { formatSearchResult } from './commands/search.js';
|
|
11
|
+
import { formatStatus, formatStatusJSON } from './commands/status.js';
|
|
12
|
+
import { mkdtemp, writeFile, readFile, mkdir, rm } from 'node:fs/promises';
|
|
13
|
+
import { join } from 'node:path';
|
|
14
|
+
import { tmpdir } from 'node:os';
|
|
15
|
+
// --- Program Setup Tests ---
|
|
16
|
+
describe('CLI program setup', () => {
|
|
17
|
+
let program;
|
|
18
|
+
beforeEach(() => {
|
|
19
|
+
program = new Command();
|
|
20
|
+
program
|
|
21
|
+
.name('coderag')
|
|
22
|
+
.description('CodeRAG — intelligent codebase context engine for AI coding agents')
|
|
23
|
+
.version('0.1.0');
|
|
24
|
+
registerInitCommand(program);
|
|
25
|
+
registerIndexCommand(program);
|
|
26
|
+
registerSearchCommand(program);
|
|
27
|
+
registerServeCommand(program);
|
|
28
|
+
registerStatusCommand(program);
|
|
29
|
+
registerViewerCommand(program);
|
|
30
|
+
});
|
|
31
|
+
it('should create program with correct name', () => {
|
|
32
|
+
expect(program.name()).toBe('coderag');
|
|
33
|
+
});
|
|
34
|
+
it('should create program with correct version', () => {
|
|
35
|
+
expect(program.version()).toBe('0.1.0');
|
|
36
|
+
});
|
|
37
|
+
it('should register all 6 commands', () => {
|
|
38
|
+
const commandNames = program.commands.map((cmd) => cmd.name());
|
|
39
|
+
expect(commandNames).toContain('init');
|
|
40
|
+
expect(commandNames).toContain('index');
|
|
41
|
+
expect(commandNames).toContain('search');
|
|
42
|
+
expect(commandNames).toContain('serve');
|
|
43
|
+
expect(commandNames).toContain('status');
|
|
44
|
+
expect(commandNames).toContain('viewer');
|
|
45
|
+
});
|
|
46
|
+
it('should have exactly 6 commands', () => {
|
|
47
|
+
expect(program.commands).toHaveLength(6);
|
|
48
|
+
});
|
|
49
|
+
it('init command should have --languages, --force, and --multi options', () => {
|
|
50
|
+
const initCmd = program.commands.find((c) => c.name() === 'init');
|
|
51
|
+
expect(initCmd).toBeDefined();
|
|
52
|
+
const opts = initCmd.options.map((o) => o.long);
|
|
53
|
+
expect(opts).toContain('--languages');
|
|
54
|
+
expect(opts).toContain('--force');
|
|
55
|
+
expect(opts).toContain('--multi');
|
|
56
|
+
});
|
|
57
|
+
it('index command should have --full option', () => {
|
|
58
|
+
const indexCmd = program.commands.find((c) => c.name() === 'index');
|
|
59
|
+
expect(indexCmd).toBeDefined();
|
|
60
|
+
const opts = indexCmd.options.map((o) => o.long);
|
|
61
|
+
expect(opts).toContain('--full');
|
|
62
|
+
});
|
|
63
|
+
it('search command should accept a query argument', () => {
|
|
64
|
+
const searchCmd = program.commands.find((c) => c.name() === 'search');
|
|
65
|
+
expect(searchCmd).toBeDefined();
|
|
66
|
+
// Commander registers arguments as _args
|
|
67
|
+
const args = searchCmd.registeredArguments;
|
|
68
|
+
expect(args.length).toBeGreaterThan(0);
|
|
69
|
+
expect(args[0].name()).toBe('query');
|
|
70
|
+
});
|
|
71
|
+
it('search command should have --top-k, --language, --type, --file options', () => {
|
|
72
|
+
const searchCmd = program.commands.find((c) => c.name() === 'search');
|
|
73
|
+
expect(searchCmd).toBeDefined();
|
|
74
|
+
const opts = searchCmd.options.map((o) => o.long);
|
|
75
|
+
expect(opts).toContain('--top-k');
|
|
76
|
+
expect(opts).toContain('--language');
|
|
77
|
+
expect(opts).toContain('--type');
|
|
78
|
+
expect(opts).toContain('--file');
|
|
79
|
+
});
|
|
80
|
+
it('serve command should have --port option', () => {
|
|
81
|
+
const serveCmd = program.commands.find((c) => c.name() === 'serve');
|
|
82
|
+
expect(serveCmd).toBeDefined();
|
|
83
|
+
const opts = serveCmd.options.map((o) => o.long);
|
|
84
|
+
expect(opts).toContain('--port');
|
|
85
|
+
});
|
|
86
|
+
it('status command should have --json option', () => {
|
|
87
|
+
const statusCmd = program.commands.find((c) => c.name() === 'status');
|
|
88
|
+
expect(statusCmd).toBeDefined();
|
|
89
|
+
const opts = statusCmd.options.map((o) => o.long);
|
|
90
|
+
expect(opts).toContain('--json');
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
// --- Language Detection Tests ---
|
|
94
|
+
describe('detectLanguages', () => {
|
|
95
|
+
let tempDir;
|
|
96
|
+
beforeEach(async () => {
|
|
97
|
+
tempDir = await mkdtemp(join(tmpdir(), 'coderag-test-'));
|
|
98
|
+
});
|
|
99
|
+
afterEach(async () => {
|
|
100
|
+
await rm(tempDir, { recursive: true, force: true });
|
|
101
|
+
});
|
|
102
|
+
it('should detect TypeScript files', async () => {
|
|
103
|
+
await writeFile(join(tempDir, 'app.ts'), 'const x = 1;');
|
|
104
|
+
const langs = await detectLanguages(tempDir);
|
|
105
|
+
expect(langs).toContain('typescript');
|
|
106
|
+
});
|
|
107
|
+
it('should detect Python files', async () => {
|
|
108
|
+
await writeFile(join(tempDir, 'main.py'), 'x = 1');
|
|
109
|
+
const langs = await detectLanguages(tempDir);
|
|
110
|
+
expect(langs).toContain('python');
|
|
111
|
+
});
|
|
112
|
+
it('should detect JavaScript files', async () => {
|
|
113
|
+
await writeFile(join(tempDir, 'app.js'), 'const x = 1;');
|
|
114
|
+
const langs = await detectLanguages(tempDir);
|
|
115
|
+
expect(langs).toContain('javascript');
|
|
116
|
+
});
|
|
117
|
+
it('should detect multiple languages', async () => {
|
|
118
|
+
await writeFile(join(tempDir, 'app.ts'), '');
|
|
119
|
+
await writeFile(join(tempDir, 'main.py'), '');
|
|
120
|
+
await writeFile(join(tempDir, 'lib.go'), '');
|
|
121
|
+
const langs = await detectLanguages(tempDir);
|
|
122
|
+
expect(langs).toContain('typescript');
|
|
123
|
+
expect(langs).toContain('python');
|
|
124
|
+
expect(langs).toContain('go');
|
|
125
|
+
});
|
|
126
|
+
it('should return sorted languages', async () => {
|
|
127
|
+
await writeFile(join(tempDir, 'app.ts'), '');
|
|
128
|
+
await writeFile(join(tempDir, 'main.go'), '');
|
|
129
|
+
await writeFile(join(tempDir, 'lib.py'), '');
|
|
130
|
+
const langs = await detectLanguages(tempDir);
|
|
131
|
+
const sorted = [...langs].sort();
|
|
132
|
+
expect(langs).toEqual(sorted);
|
|
133
|
+
});
|
|
134
|
+
it('should return empty array for directory with no source files', async () => {
|
|
135
|
+
await writeFile(join(tempDir, 'readme.md'), 'Hello');
|
|
136
|
+
await writeFile(join(tempDir, 'data.json'), '{}');
|
|
137
|
+
const langs = await detectLanguages(tempDir);
|
|
138
|
+
expect(langs).toEqual([]);
|
|
139
|
+
});
|
|
140
|
+
it('should skip node_modules directory', async () => {
|
|
141
|
+
await mkdir(join(tempDir, 'node_modules'), { recursive: true });
|
|
142
|
+
await writeFile(join(tempDir, 'node_modules', 'lib.js'), '');
|
|
143
|
+
const langs = await detectLanguages(tempDir);
|
|
144
|
+
expect(langs).not.toContain('javascript');
|
|
145
|
+
});
|
|
146
|
+
it('should scan nested directories', async () => {
|
|
147
|
+
await mkdir(join(tempDir, 'src', 'utils'), { recursive: true });
|
|
148
|
+
await writeFile(join(tempDir, 'src', 'utils', 'helper.ts'), '');
|
|
149
|
+
const langs = await detectLanguages(tempDir);
|
|
150
|
+
expect(langs).toContain('typescript');
|
|
151
|
+
});
|
|
152
|
+
it('should deduplicate languages', async () => {
|
|
153
|
+
await writeFile(join(tempDir, 'a.ts'), '');
|
|
154
|
+
await writeFile(join(tempDir, 'b.ts'), '');
|
|
155
|
+
await writeFile(join(tempDir, 'c.tsx'), '');
|
|
156
|
+
const langs = await detectLanguages(tempDir);
|
|
157
|
+
// typescript should appear only once
|
|
158
|
+
expect(langs.filter((l) => l === 'typescript')).toHaveLength(1);
|
|
159
|
+
});
|
|
160
|
+
it('should detect Rust files', async () => {
|
|
161
|
+
await writeFile(join(tempDir, 'main.rs'), '');
|
|
162
|
+
const langs = await detectLanguages(tempDir);
|
|
163
|
+
expect(langs).toContain('rust');
|
|
164
|
+
});
|
|
165
|
+
it('should detect Java files', async () => {
|
|
166
|
+
await writeFile(join(tempDir, 'Main.java'), '');
|
|
167
|
+
const langs = await detectLanguages(tempDir);
|
|
168
|
+
expect(langs).toContain('java');
|
|
169
|
+
});
|
|
170
|
+
it('should detect C/C++ files', async () => {
|
|
171
|
+
await writeFile(join(tempDir, 'main.c'), '');
|
|
172
|
+
await writeFile(join(tempDir, 'lib.cpp'), '');
|
|
173
|
+
const langs = await detectLanguages(tempDir);
|
|
174
|
+
expect(langs).toContain('c');
|
|
175
|
+
expect(langs).toContain('cpp');
|
|
176
|
+
});
|
|
177
|
+
it('should handle non-existent directory gracefully', async () => {
|
|
178
|
+
const langs = await detectLanguages(join(tempDir, 'nonexistent'));
|
|
179
|
+
expect(langs).toEqual([]);
|
|
180
|
+
});
|
|
181
|
+
});
|
|
182
|
+
// --- Multi-repo Init Tests ---
|
|
183
|
+
describe('init --multi', () => {
|
|
184
|
+
let tempDir;
|
|
185
|
+
let originalCwd;
|
|
186
|
+
beforeEach(async () => {
|
|
187
|
+
tempDir = await mkdtemp(join(tmpdir(), 'coderag-multi-'));
|
|
188
|
+
originalCwd = process.cwd();
|
|
189
|
+
process.chdir(tempDir);
|
|
190
|
+
});
|
|
191
|
+
afterEach(async () => {
|
|
192
|
+
process.chdir(originalCwd);
|
|
193
|
+
await rm(tempDir, { recursive: true, force: true });
|
|
194
|
+
});
|
|
195
|
+
it('--multi flag generates config with repos array and comment', async () => {
|
|
196
|
+
const program = new Command();
|
|
197
|
+
program.exitOverride();
|
|
198
|
+
registerInitCommand(program);
|
|
199
|
+
// Suppress console output during test
|
|
200
|
+
const origLog = console.log;
|
|
201
|
+
const origErr = console.error;
|
|
202
|
+
console.log = () => { };
|
|
203
|
+
console.error = () => { };
|
|
204
|
+
try {
|
|
205
|
+
await program.parseAsync(['node', 'coderag', 'init', '--multi']);
|
|
206
|
+
}
|
|
207
|
+
finally {
|
|
208
|
+
console.log = origLog;
|
|
209
|
+
console.error = origErr;
|
|
210
|
+
}
|
|
211
|
+
const content = await readFile(join(tempDir, '.coderag.yaml'), 'utf-8');
|
|
212
|
+
expect(content).toContain('repos:');
|
|
213
|
+
expect(content).toContain('# repos:');
|
|
214
|
+
expect(content).toContain('# - path: /absolute/path/to/repo-a');
|
|
215
|
+
expect(content).toContain('# name: repo-a');
|
|
216
|
+
});
|
|
217
|
+
});
|
|
218
|
+
// --- Search Output Formatting Tests ---
|
|
219
|
+
describe('formatSearchResult', () => {
|
|
220
|
+
function makeResult(overrides = {}) {
|
|
221
|
+
return {
|
|
222
|
+
chunkId: 'chunk-1',
|
|
223
|
+
content: 'function hello() {}',
|
|
224
|
+
nlSummary: 'A greeting function',
|
|
225
|
+
score: 0.9512,
|
|
226
|
+
method: 'hybrid',
|
|
227
|
+
metadata: {
|
|
228
|
+
chunkType: 'function',
|
|
229
|
+
name: 'hello',
|
|
230
|
+
declarations: [],
|
|
231
|
+
imports: [],
|
|
232
|
+
exports: [],
|
|
233
|
+
},
|
|
234
|
+
chunk: {
|
|
235
|
+
id: 'chunk-1',
|
|
236
|
+
content: 'function hello() {}',
|
|
237
|
+
nlSummary: 'A greeting function',
|
|
238
|
+
filePath: 'src/utils/hello.ts',
|
|
239
|
+
startLine: 10,
|
|
240
|
+
endLine: 15,
|
|
241
|
+
language: 'typescript',
|
|
242
|
+
metadata: {
|
|
243
|
+
chunkType: 'function',
|
|
244
|
+
name: 'hello',
|
|
245
|
+
declarations: [],
|
|
246
|
+
imports: [],
|
|
247
|
+
exports: [],
|
|
248
|
+
},
|
|
249
|
+
},
|
|
250
|
+
...overrides,
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
it('should include file path in output', () => {
|
|
254
|
+
const output = formatSearchResult(makeResult(), 0);
|
|
255
|
+
expect(output).toContain('src/utils/hello.ts');
|
|
256
|
+
});
|
|
257
|
+
it('should include score in output', () => {
|
|
258
|
+
const output = formatSearchResult(makeResult(), 0);
|
|
259
|
+
expect(output).toContain('0.9512');
|
|
260
|
+
});
|
|
261
|
+
it('should include chunk type in output', () => {
|
|
262
|
+
const output = formatSearchResult(makeResult(), 0);
|
|
263
|
+
expect(output).toContain('function');
|
|
264
|
+
});
|
|
265
|
+
it('should include line range in output', () => {
|
|
266
|
+
const output = formatSearchResult(makeResult(), 0);
|
|
267
|
+
expect(output).toContain('L10-15');
|
|
268
|
+
});
|
|
269
|
+
it('should include NL summary in output', () => {
|
|
270
|
+
const output = formatSearchResult(makeResult(), 0);
|
|
271
|
+
expect(output).toContain('A greeting function');
|
|
272
|
+
});
|
|
273
|
+
it('should show rank starting from 1', () => {
|
|
274
|
+
const output = formatSearchResult(makeResult(), 0);
|
|
275
|
+
expect(output).toContain('[1]');
|
|
276
|
+
const output2 = formatSearchResult(makeResult(), 4);
|
|
277
|
+
expect(output2).toContain('[5]');
|
|
278
|
+
});
|
|
279
|
+
it('should handle result without chunk gracefully', () => {
|
|
280
|
+
const result = makeResult();
|
|
281
|
+
delete result.chunk;
|
|
282
|
+
const output = formatSearchResult(result, 0);
|
|
283
|
+
// Should not throw
|
|
284
|
+
expect(output).toBeDefined();
|
|
285
|
+
});
|
|
286
|
+
it('should handle empty NL summary', () => {
|
|
287
|
+
const result = makeResult({ nlSummary: '' });
|
|
288
|
+
const output = formatSearchResult(result, 0);
|
|
289
|
+
expect(output).toBeDefined();
|
|
290
|
+
// Should not include the summary line
|
|
291
|
+
expect(output.split('\n')).toHaveLength(1);
|
|
292
|
+
});
|
|
293
|
+
});
|
|
294
|
+
// --- Status Formatting Tests ---
|
|
295
|
+
describe('formatStatus', () => {
|
|
296
|
+
function makeStatus(overrides = {}) {
|
|
297
|
+
return {
|
|
298
|
+
totalChunks: 42,
|
|
299
|
+
model: 'nomic-embed-text',
|
|
300
|
+
dimensions: 768,
|
|
301
|
+
languages: ['typescript', 'python'],
|
|
302
|
+
storagePath: '/path/to/.coderag',
|
|
303
|
+
health: 'ok',
|
|
304
|
+
...overrides,
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
it('should include total chunks', () => {
|
|
308
|
+
const output = formatStatus(makeStatus());
|
|
309
|
+
expect(output).toContain('42');
|
|
310
|
+
});
|
|
311
|
+
it('should include model name', () => {
|
|
312
|
+
const output = formatStatus(makeStatus());
|
|
313
|
+
expect(output).toContain('nomic-embed-text');
|
|
314
|
+
});
|
|
315
|
+
it('should include health status', () => {
|
|
316
|
+
const output = formatStatus(makeStatus());
|
|
317
|
+
expect(output).toContain('ok');
|
|
318
|
+
});
|
|
319
|
+
it('should include languages', () => {
|
|
320
|
+
const output = formatStatus(makeStatus());
|
|
321
|
+
expect(output).toContain('typescript');
|
|
322
|
+
expect(output).toContain('python');
|
|
323
|
+
});
|
|
324
|
+
it('should show "auto" for auto languages', () => {
|
|
325
|
+
const output = formatStatus(makeStatus({ languages: 'auto' }));
|
|
326
|
+
expect(output).toContain('auto');
|
|
327
|
+
});
|
|
328
|
+
it('should include storage path', () => {
|
|
329
|
+
const output = formatStatus(makeStatus());
|
|
330
|
+
expect(output).toContain('/path/to/.coderag');
|
|
331
|
+
});
|
|
332
|
+
it('should include dimensions', () => {
|
|
333
|
+
const output = formatStatus(makeStatus());
|
|
334
|
+
expect(output).toContain('768');
|
|
335
|
+
});
|
|
336
|
+
});
|
|
337
|
+
describe('formatStatusJSON', () => {
|
|
338
|
+
it('should return valid JSON', () => {
|
|
339
|
+
const status = {
|
|
340
|
+
totalChunks: 100,
|
|
341
|
+
model: 'nomic-embed-text',
|
|
342
|
+
dimensions: 768,
|
|
343
|
+
languages: ['typescript'],
|
|
344
|
+
storagePath: '.coderag',
|
|
345
|
+
health: 'ok',
|
|
346
|
+
};
|
|
347
|
+
const json = formatStatusJSON(status);
|
|
348
|
+
const parsed = JSON.parse(json);
|
|
349
|
+
expect(parsed.totalChunks).toBe(100);
|
|
350
|
+
expect(parsed.model).toBe('nomic-embed-text');
|
|
351
|
+
expect(parsed.health).toBe('ok');
|
|
352
|
+
expect(parsed.languages).toEqual(['typescript']);
|
|
353
|
+
});
|
|
354
|
+
it('should handle not_initialized health', () => {
|
|
355
|
+
const status = {
|
|
356
|
+
totalChunks: 0,
|
|
357
|
+
model: 'unknown',
|
|
358
|
+
dimensions: 0,
|
|
359
|
+
languages: 'auto',
|
|
360
|
+
storagePath: '',
|
|
361
|
+
health: 'not_initialized',
|
|
362
|
+
};
|
|
363
|
+
const json = formatStatusJSON(status);
|
|
364
|
+
const parsed = JSON.parse(json);
|
|
365
|
+
expect(parsed.health).toBe('not_initialized');
|
|
366
|
+
expect(parsed.totalChunks).toBe(0);
|
|
367
|
+
});
|
|
368
|
+
});
|
|
369
|
+
//# sourceMappingURL=cli.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.test.js","sourceRoot":"","sources":["../src/cli.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACrE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB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ES: readonly ["post-commit", "post-merge", "post-checkout"];
|
|
4
|
+
type HookName = typeof HOOK_NAMES[number];
|
|
5
|
+
/**
|
|
6
|
+
* Determine the .git/hooks directory path for the current project.
|
|
7
|
+
*/
|
|
8
|
+
declare function getHooksDir(rootDir: string): string;
|
|
9
|
+
/**
|
|
10
|
+
* Check whether a hook file already contains the CodeRAG marker.
|
|
11
|
+
*/
|
|
12
|
+
declare function hookHasCoderagSection(content: string): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Remove the CodeRAG section from a hook file's content.
|
|
15
|
+
* Returns the cleaned content, or null if the file becomes empty/shebang-only.
|
|
16
|
+
*/
|
|
17
|
+
declare function removeCoderagSection(content: string): string | null;
|
|
18
|
+
/**
|
|
19
|
+
* Install the CodeRAG hook fragment into a single hook file.
|
|
20
|
+
* If the hook file already exists, append the fragment (don't overwrite).
|
|
21
|
+
* If it already contains the CodeRAG section, skip it.
|
|
22
|
+
*/
|
|
23
|
+
declare function installHook(hooksDir: string, hookName: HookName): Promise<'installed' | 'already' | 'appended'>;
|
|
24
|
+
/**
|
|
25
|
+
* Uninstall the CodeRAG hook fragment from a single hook file.
|
|
26
|
+
* If the hook file only contains the CodeRAG section, delete the file.
|
|
27
|
+
* If it contains other content, remove only the CodeRAG section.
|
|
28
|
+
*/
|
|
29
|
+
declare function uninstallHook(hooksDir: string, hookName: HookName): Promise<'removed' | 'deleted' | 'not_found'>;
|
|
30
|
+
/**
|
|
31
|
+
* Register the `coderag hooks` CLI command group.
|
|
32
|
+
*
|
|
33
|
+
* Subcommands:
|
|
34
|
+
* - `coderag hooks install` — install post-commit/post-merge/post-checkout hooks
|
|
35
|
+
* - `coderag hooks uninstall` — remove CodeRAG hooks
|
|
36
|
+
* - `coderag hooks status` — check which hooks are installed
|
|
37
|
+
*/
|
|
38
|
+
export declare function registerHooksCommand(program: Command): void;
|
|
39
|
+
/**
|
|
40
|
+
* Exported for testing.
|
|
41
|
+
*/
|
|
42
|
+
export declare const _testing: {
|
|
43
|
+
HOOK_MARKER_START: string;
|
|
44
|
+
HOOK_MARKER_END: string;
|
|
45
|
+
HOOK_SCRIPT: string;
|
|
46
|
+
HOOK_NAMES: readonly ["post-commit", "post-merge", "post-checkout"];
|
|
47
|
+
hookHasCoderagSection: typeof hookHasCoderagSection;
|
|
48
|
+
removeCoderagSection: typeof removeCoderagSection;
|
|
49
|
+
installHook: typeof installHook;
|
|
50
|
+
uninstallHook: typeof uninstallHook;
|
|
51
|
+
getHooksDir: typeof getHooksDir;
|
|
52
|
+
};
|
|
53
|
+
export {};
|