@rahul05ranjan/dhruv-cli 1.4.6 → 1.5.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/.github/workflows/ci.yml +18 -238
- package/.github/workflows/contribution.yml +6 -141
- package/.github/workflows/dependabot-auto-merge.yml +1 -0
- package/.github/workflows/labeler.yml +1 -0
- package/.github/workflows/security.yml +3 -0
- package/CHANGELOG.md +9 -4
- package/README.md +145 -40
- package/__tests__/cli-contract.test.ts +104 -0
- package/__tests__/core.test.ts +121 -0
- package/__tests__/diagnostics.test.ts +155 -0
- package/__tests__/file-workflows.test.ts +195 -0
- package/__tests__/interactive.test.ts +119 -0
- package/__tests__/setup.ts +1 -0
- package/__tests__/workflows.test.ts +27 -4
- package/dist/commands/generate.d.ts +6 -1
- package/dist/commands/generate.js +18 -4
- package/dist/commands/health.d.ts +4 -1
- package/dist/commands/health.js +59 -16
- package/dist/commands/init.js +11 -2
- package/dist/commands/menu.js +125 -100
- package/dist/commands/metrics.d.ts +5 -1
- package/dist/commands/metrics.js +37 -8
- package/dist/commands/optimize.js +1 -1
- package/dist/commands/review.d.ts +4 -1
- package/dist/commands/review.js +48 -8
- package/dist/commands/security-check.d.ts +4 -1
- package/dist/commands/security-check.js +67 -6
- package/dist/commands/status.js +40 -2
- package/dist/config/config.d.ts +5 -1
- package/dist/config/config.js +24 -7
- package/dist/core/ai.d.ts +11 -0
- package/dist/core/ai.js +33 -9
- package/dist/core/command-catalog.d.ts +10 -0
- package/dist/core/command-catalog.js +27 -0
- package/dist/core/command-runner.js +100 -21
- package/dist/core/logger.js +1 -0
- package/dist/core/metrics.d.ts +28 -0
- package/dist/core/metrics.js +78 -0
- package/dist/index.js +46 -24
- package/dist/utils/projectType.d.ts +1 -1
- package/dist/utils/projectType.js +26 -7
- package/docs/api/assets/highlight.css +4 -4
- package/docs/api/index.html +161 -39
- package/docs/api/media/CONTRIBUTING.md +60 -0
- package/docs/api/media/SECURITY.md +8 -0
- package/docs/api/media/dhruv-cli-preview.svg +42 -0
- package/docs/api/media/publishing-fix.md +34 -0
- package/docs/dhruv-cli-preview.svg +42 -0
- package/docs/index.html +631 -533
- package/docs/publishing-fix.md +34 -0
- package/package.json +1 -1
- package/src/commands/generate.ts +23 -4
- package/src/commands/health.ts +62 -17
- package/src/commands/init.ts +11 -2
- package/src/commands/menu.ts +54 -30
- package/src/commands/metrics.ts +42 -7
- package/src/commands/optimize.ts +1 -1
- package/src/commands/review.ts +53 -8
- package/src/commands/security-check.ts +80 -6
- package/src/commands/status.ts +39 -3
- package/src/config/config.ts +26 -7
- package/src/core/ai.ts +36 -8
- package/src/core/command-catalog.ts +37 -0
- package/src/core/command-runner.ts +102 -22
- package/src/core/logger.ts +1 -0
- package/src/core/metrics.ts +103 -0
- package/src/index.ts +45 -24
- package/src/utils/projectType.ts +22 -7
- package/tsconfig.json +1 -1
- package/.github/workflows/auto-assign.yml +0 -14
- package/.github/workflows/build-publish.yml +0 -154
- package/.github/workflows/deploy.yml +0 -336
- package/.github/workflows/monitoring.yml +0 -270
- package/PUBLISHING_FIX.md +0 -92
- package/logs/.8a99b6cf655346317fdbf29f4fffcf91131432f3-audit.json +0 -15
- package/logs/.eee104bf8fff5ecd38a6a2842df260de6470a7c3-audit.json +0 -15
package/dist/index.js
CHANGED
|
@@ -19,6 +19,7 @@ import { menu } from './commands/menu.js';
|
|
|
19
19
|
import { createRequire } from 'module';
|
|
20
20
|
import { logger, logInfo, logError } from './core/logger.js';
|
|
21
21
|
import { metricsCollector } from './core/metrics.js';
|
|
22
|
+
import { commandDescription, completionCommands, completionOptions } from './core/command-catalog.js';
|
|
22
23
|
const require = createRequire(import.meta.url);
|
|
23
24
|
const pkg = require('../package.json');
|
|
24
25
|
const program = new Command();
|
|
@@ -28,69 +29,78 @@ program
|
|
|
28
29
|
.version(pkg.version);
|
|
29
30
|
program
|
|
30
31
|
.command('explain <query>')
|
|
31
|
-
.description('
|
|
32
|
+
.description(commandDescription('explain'))
|
|
32
33
|
.addHelpText('after', '\nExamples:\n $ dhruv explain "What is async/await?"\n $ dhruv explain "Docker containers vs VMs"')
|
|
33
34
|
.action(explain);
|
|
34
35
|
program
|
|
35
36
|
.command('suggest <query>')
|
|
36
|
-
.description('
|
|
37
|
+
.description(commandDescription('suggest'))
|
|
37
38
|
.addHelpText('after', '\nExamples:\n $ dhruv suggest "React performance optimization"\n $ dhruv suggest "Node.js project structure"')
|
|
38
39
|
.action(suggest);
|
|
39
40
|
program
|
|
40
41
|
.command('fix <query>')
|
|
41
|
-
.description('
|
|
42
|
+
.description(commandDescription('fix'))
|
|
42
43
|
.addHelpText('after', '\nExamples:\n $ dhruv fix "TypeError: Cannot read property of undefined"\n $ dhruv fix "CORS error in Express.js"')
|
|
43
44
|
.action(fix);
|
|
44
45
|
program
|
|
45
46
|
.command('review <fileOrDir>')
|
|
46
|
-
.description('
|
|
47
|
-
.
|
|
47
|
+
.description(commandDescription('review'))
|
|
48
|
+
.option('--diff', 'Review the current uncommitted git diff')
|
|
49
|
+
.action((fileOrDir, command) => review(fileOrDir, command.opts()));
|
|
48
50
|
program
|
|
49
51
|
.command('optimize <file>')
|
|
50
|
-
.description(
|
|
52
|
+
.description(commandDescription('optimize'))
|
|
51
53
|
.action(optimize);
|
|
52
54
|
program
|
|
53
55
|
.command('security-check [fileOrDir]')
|
|
54
|
-
.description('
|
|
55
|
-
.
|
|
56
|
+
.description(commandDescription('security-check'))
|
|
57
|
+
.option('--strict', 'Exit with failure when high-confidence findings are detected')
|
|
58
|
+
.action((fileOrDir, command) => securityCheck(fileOrDir, command.opts()));
|
|
56
59
|
program
|
|
57
60
|
.command('generate <type> <target>')
|
|
58
|
-
.description('
|
|
59
|
-
.
|
|
61
|
+
.description(commandDescription('generate'))
|
|
62
|
+
.option('--apply', 'Write generated tests to disk (preview is the default)')
|
|
63
|
+
.option('--output <path>', 'Write generated tests to this path')
|
|
64
|
+
.option('--overwrite', 'Allow replacing an existing output file')
|
|
65
|
+
.action((type, target, command) => generate(type, target, command.opts()));
|
|
60
66
|
program
|
|
61
67
|
.command('init')
|
|
62
|
-
.description('
|
|
68
|
+
.description(commandDescription('init'))
|
|
63
69
|
.action(init);
|
|
64
70
|
program
|
|
65
71
|
.command('status')
|
|
66
|
-
.description('
|
|
72
|
+
.description(commandDescription('status'))
|
|
67
73
|
.action(status);
|
|
68
74
|
program
|
|
69
75
|
.command('health')
|
|
70
|
-
.description('
|
|
71
|
-
.
|
|
76
|
+
.description(commandDescription('health'))
|
|
77
|
+
.option('--details', 'Show every health check and diagnostic detail')
|
|
78
|
+
.action((command) => health(command.opts()));
|
|
72
79
|
program
|
|
73
80
|
.command('metrics')
|
|
74
|
-
.description('
|
|
75
|
-
.
|
|
81
|
+
.description(commandDescription('metrics'))
|
|
82
|
+
.option('--raw', 'Export raw Prometheus metrics')
|
|
83
|
+
.option('--reset', 'Clear persisted local metrics')
|
|
84
|
+
.action((command) => metrics(command.opts()));
|
|
76
85
|
program
|
|
77
86
|
.command('project-type')
|
|
78
|
-
.description('
|
|
87
|
+
.description(commandDescription('project-type'))
|
|
79
88
|
.action(() => {
|
|
80
89
|
const type = detectProjectType();
|
|
81
90
|
console.log(chalk.blue(`Detected project type: ${type}`));
|
|
82
91
|
});
|
|
83
92
|
program
|
|
84
93
|
.command('menu')
|
|
85
|
-
.description('
|
|
94
|
+
.description(commandDescription('menu'))
|
|
86
95
|
.action(menu);
|
|
87
96
|
program
|
|
88
97
|
.option('--model <model>', 'Set Ollama model')
|
|
89
98
|
.option('--verbose', 'Enable verbose output')
|
|
90
99
|
.option('--json', 'Output in JSON format')
|
|
100
|
+
.option('--timeout <milliseconds>', 'Set the AI request timeout')
|
|
91
101
|
.hook('preAction', async (thisCommand) => {
|
|
92
102
|
const opts = thisCommand.opts();
|
|
93
|
-
if (opts.model || opts.verbose || opts.json) {
|
|
103
|
+
if (opts.model || opts.verbose || opts.json || opts.timeout) {
|
|
94
104
|
const config = {};
|
|
95
105
|
if (opts.model)
|
|
96
106
|
config.model = opts.model;
|
|
@@ -98,6 +108,8 @@ program
|
|
|
98
108
|
config.verbose = true;
|
|
99
109
|
if (opts.json)
|
|
100
110
|
config.responseFormat = 'json';
|
|
111
|
+
if (opts.timeout)
|
|
112
|
+
config.timeoutMs = Number(opts.timeout);
|
|
101
113
|
// Save config for session
|
|
102
114
|
const configModule = await import('./config/config.js');
|
|
103
115
|
configModule.saveConfig(config);
|
|
@@ -148,23 +160,33 @@ async function loadPlugins(program) {
|
|
|
148
160
|
// Autocomplete: Generate shell completion scripts
|
|
149
161
|
program
|
|
150
162
|
.command('completion')
|
|
151
|
-
.description('
|
|
163
|
+
.description(commandDescription('completion'))
|
|
152
164
|
.argument('[shell]', 'shell type (bash|zsh|fish)', 'bash')
|
|
153
165
|
.action((shell) => {
|
|
166
|
+
const commands = completionCommands();
|
|
167
|
+
const options = completionOptions();
|
|
154
168
|
let script = '';
|
|
155
169
|
switch (shell) {
|
|
156
170
|
case 'zsh':
|
|
157
|
-
script = `#compdef dhruv\n_dhruv_completion() {\n
|
|
171
|
+
script = `#compdef dhruv\n_dhruv_completion() {\n _arguments '1:command:(${commands})' '*:option:(${options})'\n}\ncompdef _dhruv_completion dhruv`;
|
|
158
172
|
break;
|
|
159
173
|
case 'fish':
|
|
160
|
-
script = `
|
|
174
|
+
script = `complete -c dhruv -f -n '__fish_use_subcommand' -a '${commands}'\ncomplete -c dhruv -f -n 'not __fish_use_subcommand' -a '${options}'`;
|
|
161
175
|
break;
|
|
162
|
-
|
|
176
|
+
case 'bash':
|
|
163
177
|
script = String.raw `#!/bin/bash
|
|
164
178
|
_dhruv_completion() {
|
|
165
|
-
|
|
179
|
+
local commands="${commands}"
|
|
180
|
+
local options="${options}"
|
|
181
|
+
local choices="$commands $options"
|
|
182
|
+
COMPREPLY=( $(compgen -W "$choices" -- "\${COMP_WORDS[COMP_CWORD]}") )
|
|
166
183
|
}
|
|
167
184
|
complete -F _dhruv_completion dhruv`;
|
|
185
|
+
break;
|
|
186
|
+
default:
|
|
187
|
+
console.error(chalk.red(`Unsupported shell "${shell}". Choose bash, zsh, or fish.`));
|
|
188
|
+
process.exitCode = 2;
|
|
189
|
+
return;
|
|
168
190
|
}
|
|
169
191
|
console.log(script);
|
|
170
192
|
console.log(`\n# To enable tab completion, add the above to your shell profile or source it directly.`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function detectProjectType(): string;
|
|
1
|
+
export declare function detectProjectType(directory?: string): string;
|
|
@@ -1,17 +1,36 @@
|
|
|
1
1
|
// Use .js extension for ESM compatibility
|
|
2
2
|
import fs from 'fs';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
import path from 'path';
|
|
4
|
+
export function detectProjectType(directory = process.cwd()) {
|
|
5
|
+
const file = (name) => path.join(directory, name);
|
|
6
|
+
if (fs.existsSync(file('package.json'))) {
|
|
7
|
+
let pkg;
|
|
8
|
+
try {
|
|
9
|
+
pkg = JSON.parse(fs.readFileSync(file('package.json'), 'utf-8'));
|
|
10
|
+
}
|
|
11
|
+
catch {
|
|
12
|
+
return 'unknown';
|
|
13
|
+
}
|
|
14
|
+
const dependencies = { ...pkg.dependencies, ...pkg.devDependencies };
|
|
15
|
+
if (dependencies.react)
|
|
7
16
|
return 'react';
|
|
8
|
-
if (
|
|
17
|
+
if (dependencies.next)
|
|
18
|
+
return 'nextjs';
|
|
19
|
+
if (dependencies.express)
|
|
9
20
|
return 'node-express';
|
|
21
|
+
if (dependencies.typescript || fs.existsSync(file('tsconfig.json')))
|
|
22
|
+
return 'node-typescript';
|
|
10
23
|
return 'node';
|
|
11
24
|
}
|
|
12
|
-
if (fs.existsSync('requirements.txt'))
|
|
25
|
+
if (fs.existsSync(file('requirements.txt')))
|
|
13
26
|
return 'python';
|
|
14
|
-
if (fs.existsSync('pyproject.toml'))
|
|
27
|
+
if (fs.existsSync(file('pyproject.toml')))
|
|
15
28
|
return 'python';
|
|
29
|
+
if (fs.existsSync(file('go.mod')))
|
|
30
|
+
return 'go';
|
|
31
|
+
if (fs.existsSync(file('Cargo.toml')))
|
|
32
|
+
return 'rust';
|
|
33
|
+
if (fs.existsSync(file('pom.xml')) || fs.existsSync(file('build.gradle')))
|
|
34
|
+
return 'java';
|
|
16
35
|
return 'unknown';
|
|
17
36
|
}
|
|
@@ -7,10 +7,10 @@
|
|
|
7
7
|
--dark-hl-2: #9ECBFF;
|
|
8
8
|
--light-hl-3: #005CC5;
|
|
9
9
|
--dark-hl-3: #79B8FF;
|
|
10
|
-
--light-hl-4: #
|
|
11
|
-
--dark-hl-4: #
|
|
12
|
-
--light-hl-5: #
|
|
13
|
-
--dark-hl-5: #
|
|
10
|
+
--light-hl-4: #6A737D;
|
|
11
|
+
--dark-hl-4: #6A737D;
|
|
12
|
+
--light-hl-5: #D73A49;
|
|
13
|
+
--dark-hl-5: #F97583;
|
|
14
14
|
--light-hl-6: #E36209;
|
|
15
15
|
--dark-hl-6: #FFAB70;
|
|
16
16
|
--light-code-background: #fff;
|
package/docs/api/index.html
CHANGED
|
@@ -1,39 +1,161 @@
|
|
|
1
|
-
<!DOCTYPE html><html class="default" lang="en" data-base="./"><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>Dhruv CLI API - v1.4.0</title><meta name="description" content="Documentation for Dhruv CLI API"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="assets/style.css"/><link rel="stylesheet" href="assets/highlight.css"/><script defer src="assets/main.js"></script><script async src="assets/icons.js" id="tsd-icons-script"></script><script async src="assets/search.js" id="tsd-search-script"></script><script async src="assets/navigation.js" id="tsd-nav-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => window.app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><a href="index.html" class="title">Dhruv CLI API - v1.4.0</a><div id="tsd-toolbar-links"><a href="https://rahul05ranjan.github.io/dhruv-cli/">Home</a><a href="https://github.com/rahul05ranjan/dhruv-cli">GitHub</a></div><button id="tsd-search-trigger" class="tsd-widget" aria-label="Search"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="assets/icons.svg#icon-search"></use></svg></button><dialog id="tsd-search" aria-label="Search"><input role="combobox" id="tsd-search-input" aria-controls="tsd-search-results" aria-autocomplete="list" aria-expanded="true" autocapitalize="off" autocomplete="off" placeholder="Search the docs" maxLength="100"/><ul role="listbox" id="tsd-search-results"></ul><div id="tsd-search-status" aria-live="polite" aria-atomic="true"><div>Preparing search index...</div></div></dialog><a href="#" class="tsd-widget menu" id="tsd-toolbar-menu-trigger" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="assets/icons.svg#icon-menu"></use></svg></a></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><h1>Dhruv CLI API - v1.4.0</h1></div><div class="tsd-panel tsd-typography"><
|
|
2
|
-
<a href="https://
|
|
3
|
-
<
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
<
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
<
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
<
|
|
13
|
-
<
|
|
14
|
-
|
|
15
|
-
<
|
|
16
|
-
|
|
17
|
-
<
|
|
18
|
-
|
|
19
|
-
</
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
<
|
|
24
|
-
<
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
<
|
|
28
|
-
<
|
|
29
|
-
</
|
|
30
|
-
|
|
31
|
-
<
|
|
32
|
-
<
|
|
33
|
-
<
|
|
34
|
-
</
|
|
35
|
-
<
|
|
36
|
-
|
|
37
|
-
</
|
|
38
|
-
<h2 id="
|
|
39
|
-
</
|
|
1
|
+
<!DOCTYPE html><html class="default" lang="en" data-base="./"><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>Dhruv CLI API - v1.4.0</title><meta name="description" content="Documentation for Dhruv CLI API"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="assets/style.css"/><link rel="stylesheet" href="assets/highlight.css"/><script defer src="assets/main.js"></script><script async src="assets/icons.js" id="tsd-icons-script"></script><script async src="assets/search.js" id="tsd-search-script"></script><script async src="assets/navigation.js" id="tsd-nav-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => window.app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><a href="index.html" class="title">Dhruv CLI API - v1.4.0</a><div id="tsd-toolbar-links"><a href="https://rahul05ranjan.github.io/dhruv-cli/">Home</a><a href="https://github.com/rahul05ranjan/dhruv-cli">GitHub</a></div><button id="tsd-search-trigger" class="tsd-widget" aria-label="Search"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="assets/icons.svg#icon-search"></use></svg></button><dialog id="tsd-search" aria-label="Search"><input role="combobox" id="tsd-search-input" aria-controls="tsd-search-results" aria-autocomplete="list" aria-expanded="true" autocapitalize="off" autocomplete="off" placeholder="Search the docs" maxLength="100"/><ul role="listbox" id="tsd-search-results"></ul><div id="tsd-search-status" aria-live="polite" aria-atomic="true"><div>Preparing search index...</div></div></dialog><a href="#" class="tsd-widget menu" id="tsd-toolbar-menu-trigger" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="assets/icons.svg#icon-menu"></use></svg></a></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><h1>Dhruv CLI API - v1.4.0</h1></div><div class="tsd-panel tsd-typography"><p align="center">
|
|
2
|
+
<a href="https://github.com/rahul05ranjan/dhruv-cli">
|
|
3
|
+
<strong>⚡ Dhruv CLI</strong>
|
|
4
|
+
</a>
|
|
5
|
+
</p>
|
|
6
|
+
<p align="center">
|
|
7
|
+
A local-first AI command center for your terminal.
|
|
8
|
+
</p>
|
|
9
|
+
<p align="center">
|
|
10
|
+
Ask better questions. Understand unfamiliar code. Ship with confidence.
|
|
11
|
+
</p>
|
|
12
|
+
<p align="center">
|
|
13
|
+
<a href="https://rahul05ranjan.github.io/dhruv-cli/">Website</a>
|
|
14
|
+
·
|
|
15
|
+
<a href="https://www.npmjs.com/package/@rahul05ranjan/dhruv-cli">npm</a>
|
|
16
|
+
·
|
|
17
|
+
<a href="https://github.com/rahul05ranjan/dhruv-cli/issues">Issues</a>
|
|
18
|
+
·
|
|
19
|
+
<a href="media/CONTRIBUTING.md">Contributing</a>
|
|
20
|
+
</p>
|
|
21
|
+
<p align="center">
|
|
22
|
+
<a href="https://github.com/rahul05ranjan/dhruv-cli/actions/workflows/deploy.yml"><img src="https://github.com/rahul05ranjan/dhruv-cli/actions/workflows/deploy.yml/badge.svg" alt="Deployment status"></a>
|
|
23
|
+
<a href="https://www.npmjs.com/package/@rahul05ranjan/dhruv-cli"><img src="https://img.shields.io/npm/v/%40rahul05ranjan%2Fdhruv-cli?style=flat-square&label=npm" alt="npm version"></a>
|
|
24
|
+
<a href="https://www.npmjs.com/package/@rahul05ranjan/dhruv-cli"><img src="https://img.shields.io/npm/dm/%40rahul05ranjan%2Fdhruv-cli?style=flat-square&label=downloads" alt="npm downloads"></a>
|
|
25
|
+
<img src="https://img.shields.io/github/license/rahul05ranjan/dhruv-cli?style=flat-square" alt="MIT license">
|
|
26
|
+
</p>
|
|
27
|
+
<p align="center">
|
|
28
|
+
<img src="media/dhruv-cli-preview.svg" alt="Dhruv CLI terminal preview" width="760">
|
|
29
|
+
</p>
|
|
30
|
+
<h2 id="why-dhruv" class="tsd-anchor-link">Why Dhruv?<a href="#why-dhruv" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h2><p>Dhruv brings a focused AI toolkit into the terminal, powered by local Ollama models. It keeps your workflow close to the codebase, works without a hosted AI account, and turns everyday developer questions into fast, actionable output.</p>
|
|
31
|
+
<table>
|
|
32
|
+
<tr>
|
|
33
|
+
<td width="33%"><strong>✦ Think with you</strong><br>Explain concepts, suggest approaches, and turn errors into clear next steps.</td>
|
|
34
|
+
<td width="33%"><strong>◈ Inspect deeply</strong><br>Review code, optimize files, and scan projects for common security risks.</td>
|
|
35
|
+
<td width="33%"><strong>⌁ Fit your flow</strong><br>Use an interactive menu, shell completion, JSON output, or your own plugins.</td>
|
|
36
|
+
</tr>
|
|
37
|
+
</table>
|
|
38
|
+
<h2 id="start-in-60-seconds" class="tsd-anchor-link">Start in 60 seconds<a href="#start-in-60-seconds" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h2><h3 id="1-install-dhruv" class="tsd-anchor-link">1. Install Dhruv<a href="#1-install-dhruv" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h3><pre><code class="bash"><span class="hl-0">npm</span><span class="hl-1"> </span><span class="hl-2">install</span><span class="hl-1"> </span><span class="hl-3">-g</span><span class="hl-1"> </span><span class="hl-2">@rahul05ranjan/dhruv-cli</span>
|
|
39
|
+
</code><button type="button">Copy</button></pre>
|
|
40
|
+
|
|
41
|
+
<h3 id="2-start-a-local-model" class="tsd-anchor-link">2. Start a local model<a href="#2-start-a-local-model" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h3><p>Install <a href="https://ollama.com/">Ollama</a>, then run:</p>
|
|
42
|
+
<pre><code class="bash"><span class="hl-0">ollama</span><span class="hl-1"> </span><span class="hl-2">serve</span><br/><span class="hl-0">ollama</span><span class="hl-1"> </span><span class="hl-2">pull</span><span class="hl-1"> </span><span class="hl-2">gemma3:270m</span>
|
|
43
|
+
</code><button type="button">Copy</button></pre>
|
|
44
|
+
|
|
45
|
+
<h3 id="3-configure-once-then-go" class="tsd-anchor-link">3. Configure once, then go<a href="#3-configure-once-then-go" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h3><pre><code class="bash"><span class="hl-0">dhruv</span><span class="hl-1"> </span><span class="hl-2">init</span><br/><span class="hl-0">dhruv</span><span class="hl-1"> </span><span class="hl-2">suggest</span><span class="hl-1"> </span><span class="hl-2">"how should I structure this Node.js service?"</span>
|
|
46
|
+
</code><button type="button">Copy</button></pre>
|
|
47
|
+
|
|
48
|
+
<p>Dhruv requires Node.js 18 or newer. The default model is <code>gemma3:270m</code>; choose any model available in your Ollama installation during setup.</p>
|
|
49
|
+
<h2 id="a-command-surface-built-for-shipping" class="tsd-anchor-link">A command surface built for shipping<a href="#a-command-surface-built-for-shipping" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h2><table>
|
|
50
|
+
<thead>
|
|
51
|
+
<tr>
|
|
52
|
+
<th>Command</th>
|
|
53
|
+
<th>What it does</th>
|
|
54
|
+
</tr>
|
|
55
|
+
</thead>
|
|
56
|
+
<tbody>
|
|
57
|
+
<tr>
|
|
58
|
+
<td><code>dhruv suggest <query></code></td>
|
|
59
|
+
<td>Generate practical suggestions for a development task</td>
|
|
60
|
+
</tr>
|
|
61
|
+
<tr>
|
|
62
|
+
<td><code>dhruv explain <query></code></td>
|
|
63
|
+
<td>Explain a concept, command, or unfamiliar error</td>
|
|
64
|
+
</tr>
|
|
65
|
+
<tr>
|
|
66
|
+
<td><code>dhruv fix <query></code></td>
|
|
67
|
+
<td>Analyze a coding issue and propose a fix</td>
|
|
68
|
+
</tr>
|
|
69
|
+
<tr>
|
|
70
|
+
<td><code>dhruv review <file-or-dir></code></td>
|
|
71
|
+
<td>Review up to ten code files for quality and maintainability; add <code>--diff</code> for uncommitted changes</td>
|
|
72
|
+
</tr>
|
|
73
|
+
<tr>
|
|
74
|
+
<td><code>dhruv optimize <file></code></td>
|
|
75
|
+
<td>Find actionable improvements for source or configuration files</td>
|
|
76
|
+
</tr>
|
|
77
|
+
<tr>
|
|
78
|
+
<td><code>dhruv security-check [file-or-dir]</code></td>
|
|
79
|
+
<td>Run a redacted local security analysis; add <code>--strict</code> for CI failure on high-confidence findings</td>
|
|
80
|
+
</tr>
|
|
81
|
+
<tr>
|
|
82
|
+
<td><code>dhruv generate <type> <target></code></td>
|
|
83
|
+
<td>Preview generated tests by default; use <code>--apply</code>, <code>--output</code>, or <code>--overwrite</code> to write safely</td>
|
|
84
|
+
</tr>
|
|
85
|
+
<tr>
|
|
86
|
+
<td><code>dhruv status</code></td>
|
|
87
|
+
<td>Check Ollama connectivity and configured models</td>
|
|
88
|
+
</tr>
|
|
89
|
+
<tr>
|
|
90
|
+
<td><code>dhruv health</code></td>
|
|
91
|
+
<td>Show a concise health summary; use <code>--details</code> for diagnostics</td>
|
|
92
|
+
</tr>
|
|
93
|
+
<tr>
|
|
94
|
+
<td><code>dhruv metrics</code></td>
|
|
95
|
+
<td>Inspect local usage and performance metrics; use <code>--raw</code> or <code>--reset</code> explicitly</td>
|
|
96
|
+
</tr>
|
|
97
|
+
<tr>
|
|
98
|
+
<td><code>dhruv project-type</code></td>
|
|
99
|
+
<td>Detect the current project type</td>
|
|
100
|
+
</tr>
|
|
101
|
+
<tr>
|
|
102
|
+
<td><code>dhruv menu</code></td>
|
|
103
|
+
<td>Open the interactive command palette</td>
|
|
104
|
+
</tr>
|
|
105
|
+
<tr>
|
|
106
|
+
<td><code>dhruv completion [shell]</code></td>
|
|
107
|
+
<td>Generate Bash, Zsh, or Fish completion</td>
|
|
108
|
+
</tr>
|
|
109
|
+
</tbody>
|
|
110
|
+
</table>
|
|
111
|
+
<h3 id="common-workflows" class="tsd-anchor-link">Common workflows<a href="#common-workflows" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h3><pre><code class="bash"><span class="hl-4"># Understand and plan</span><br/><span class="hl-0">dhruv</span><span class="hl-1"> </span><span class="hl-2">explain</span><span class="hl-1"> </span><span class="hl-2">"git rebase vs merge"</span><br/><span class="hl-0">dhruv</span><span class="hl-1"> </span><span class="hl-2">suggest</span><span class="hl-1"> </span><span class="hl-2">"deploy a React app to Vercel"</span><br/><br/><span class="hl-4"># Improve an existing project</span><br/><span class="hl-0">dhruv</span><span class="hl-1"> </span><span class="hl-2">review</span><span class="hl-1"> </span><span class="hl-2">src/</span><br/><span class="hl-0">dhruv</span><span class="hl-1"> </span><span class="hl-2">review</span><span class="hl-1"> </span><span class="hl-3">--diff</span><span class="hl-1"> </span><span class="hl-2">.</span><br/><span class="hl-0">dhruv</span><span class="hl-1"> </span><span class="hl-2">optimize</span><span class="hl-1"> </span><span class="hl-2">package.json</span><br/><span class="hl-0">dhruv</span><span class="hl-1"> </span><span class="hl-2">security-check</span><span class="hl-1"> </span><span class="hl-2">src/</span><br/><span class="hl-0">dhruv</span><span class="hl-1"> </span><span class="hl-2">security-check</span><span class="hl-1"> </span><span class="hl-2">src/</span><span class="hl-1"> </span><span class="hl-3">--strict</span><br/><br/><span class="hl-4"># Generate and automate</span><br/><span class="hl-0">dhruv</span><span class="hl-1"> </span><span class="hl-2">generate</span><span class="hl-1"> </span><span class="hl-2">tests</span><span class="hl-1"> </span><span class="hl-2">src/utils/helpers.js</span><span class="hl-1"> </span><span class="hl-4"># preview only</span><br/><span class="hl-0">dhruv</span><span class="hl-1"> </span><span class="hl-2">generate</span><span class="hl-1"> </span><span class="hl-2">tests</span><span class="hl-1"> </span><span class="hl-2">src/utils/helpers.js</span><span class="hl-1"> </span><span class="hl-3">--apply</span><br/><span class="hl-0">dhruv</span><span class="hl-1"> </span><span class="hl-2">completion</span><span class="hl-1"> </span><span class="hl-2">zsh</span><span class="hl-1"> </span><span class="hl-5">></span><span class="hl-1"> </span><span class="hl-2">~/.zsh/completions/_dhruv</span>
|
|
112
|
+
</code><button type="button">Copy</button></pre>
|
|
113
|
+
|
|
114
|
+
<h2 id="configuration-that-stays-out-of-your-way" class="tsd-anchor-link">Configuration that stays out of your way<a href="#configuration-that-stays-out-of-your-way" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h2><p>Run <code>dhruv init</code> to set the Ollama model, response format, verbosity, terminal theme, and whether settings are project-local or user-global. Local configuration is stored in <code>.dhruv-config.json</code>; global settings live under your user config directory.</p>
|
|
115
|
+
<p>For one-off runs, use global flags:</p>
|
|
116
|
+
<pre><code class="bash"><span class="hl-0">dhruv</span><span class="hl-1"> </span><span class="hl-2">suggest</span><span class="hl-1"> </span><span class="hl-2">"summarize this migration"</span><span class="hl-1"> </span><span class="hl-3">--model</span><span class="hl-1"> </span><span class="hl-2">llama3.2</span><span class="hl-1"> </span><span class="hl-3">--json</span><br/><span class="hl-0">dhruv</span><span class="hl-1"> </span><span class="hl-2">review</span><span class="hl-1"> </span><span class="hl-2">src/</span><span class="hl-1"> </span><span class="hl-3">--verbose</span><br/><span class="hl-0">dhruv</span><span class="hl-1"> </span><span class="hl-2">explain</span><span class="hl-1"> </span><span class="hl-2">"what changed?"</span><span class="hl-1"> </span><span class="hl-3">--timeout</span><span class="hl-1"> </span><span class="hl-3">60000</span>
|
|
117
|
+
</code><button type="button">Copy</button></pre>
|
|
118
|
+
|
|
119
|
+
<h2 id="extend-it-with-plugins" class="tsd-anchor-link">Extend it with plugins<a href="#extend-it-with-plugins" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h2><p>Drop an ESM module into your project's <code>plugins/</code> directory. Dhruv loads <code>.js</code> plugins before parsing the command line, so you can add commands without changing the core CLI.</p>
|
|
120
|
+
<pre><code class="js"><span class="hl-4">// plugins/hello.js</span><br/><span class="hl-5">export</span><span class="hl-1"> </span><span class="hl-5">default</span><span class="hl-1"> (</span><span class="hl-6">program</span><span class="hl-1">) </span><span class="hl-5">=></span><span class="hl-1"> {</span><br/><span class="hl-1"> program</span><br/><span class="hl-1"> .</span><span class="hl-0">command</span><span class="hl-1">(</span><span class="hl-2">'hello-plugin'</span><span class="hl-1">)</span><br/><span class="hl-1"> .</span><span class="hl-0">description</span><span class="hl-1">(</span><span class="hl-2">'Say hello from a project plugin'</span><span class="hl-1">)</span><br/><span class="hl-1"> .</span><span class="hl-0">action</span><span class="hl-1">(() </span><span class="hl-5">=></span><span class="hl-1"> console.</span><span class="hl-0">log</span><span class="hl-1">(</span><span class="hl-2">'Hello from Dhruv!'</span><span class="hl-1">));</span><br/><span class="hl-1">};</span>
|
|
121
|
+
</code><button type="button">Copy</button></pre>
|
|
122
|
+
|
|
123
|
+
<p>Then run:</p>
|
|
124
|
+
<pre><code class="bash"><span class="hl-0">dhruv</span><span class="hl-1"> </span><span class="hl-2">hello-plugin</span>
|
|
125
|
+
</code><button type="button">Copy</button></pre>
|
|
126
|
+
|
|
127
|
+
<h2 id="documentation--project-guides" class="tsd-anchor-link">Documentation & project guides<a href="#documentation--project-guides" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h2><table>
|
|
128
|
+
<thead>
|
|
129
|
+
<tr>
|
|
130
|
+
<th>Resource</th>
|
|
131
|
+
<th>Link</th>
|
|
132
|
+
</tr>
|
|
133
|
+
</thead>
|
|
134
|
+
<tbody>
|
|
135
|
+
<tr>
|
|
136
|
+
<td>Product site</td>
|
|
137
|
+
<td><a href="https://rahul05ranjan.github.io/dhruv-cli/">rahul05ranjan.github.io/dhruv-cli</a></td>
|
|
138
|
+
</tr>
|
|
139
|
+
<tr>
|
|
140
|
+
<td>API reference</td>
|
|
141
|
+
<td><a href="https://rahul05ranjan.github.io/dhruv-cli/api/">Generated TypeDoc</a></td>
|
|
142
|
+
</tr>
|
|
143
|
+
<tr>
|
|
144
|
+
<td>Contributing</td>
|
|
145
|
+
<td><a href="media/CONTRIBUTING.md">CONTRIBUTING.md</a></td>
|
|
146
|
+
</tr>
|
|
147
|
+
<tr>
|
|
148
|
+
<td>Security policy</td>
|
|
149
|
+
<td><a href="media/SECURITY.md">SECURITY.md</a></td>
|
|
150
|
+
</tr>
|
|
151
|
+
<tr>
|
|
152
|
+
<td>Publishing notes</td>
|
|
153
|
+
<td><a href="media/publishing-fix.md">docs/publishing-fix.md</a></td>
|
|
154
|
+
</tr>
|
|
155
|
+
</tbody>
|
|
156
|
+
</table>
|
|
157
|
+
<h2 id="development" class="tsd-anchor-link">Development<a href="#development" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h2><pre><code class="bash"><span class="hl-0">npm</span><span class="hl-1"> </span><span class="hl-2">install</span><br/><span class="hl-0">npm</span><span class="hl-1"> </span><span class="hl-2">run</span><span class="hl-1"> </span><span class="hl-2">type-check</span><br/><span class="hl-0">npm</span><span class="hl-1"> </span><span class="hl-2">test</span><br/><span class="hl-0">npm</span><span class="hl-1"> </span><span class="hl-2">run</span><span class="hl-1"> </span><span class="hl-2">lint</span><br/><span class="hl-0">npm</span><span class="hl-1"> </span><span class="hl-2">run</span><span class="hl-1"> </span><span class="hl-2">build</span>
|
|
158
|
+
</code><button type="button">Copy</button></pre>
|
|
159
|
+
|
|
160
|
+
<h2 id="license" class="tsd-anchor-link">License<a href="#license" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h2><p>MIT © <a href="https://github.com/rahul05ranjan">Rahul Ranjan</a></p>
|
|
161
|
+
</div></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-accordion"><summary class="tsd-accordion-summary"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="assets/icons.svg#icon-chevronDown"></use></svg><h3>Settings</h3></summary><div class="tsd-accordion-details"><div class="tsd-filter-visibility"><span class="settings-label">Member Visibility</span><ul id="tsd-filter-options"><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-external" name="external"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>External</span></label></li></ul></div><div class="tsd-theme-toggle"><label class="settings-label" for="tsd-theme">Theme</label><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div><details open class="tsd-accordion tsd-page-navigation"><summary class="tsd-accordion-summary"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="assets/icons.svg#icon-chevronDown"></use></svg><h3>On This Page</h3></summary><div class="tsd-accordion-details"><a href="#why-dhruv"><span>Why <wbr/>Dhruv?</span></a><a href="#start-in-60-seconds"><span>Start in 60 seconds</span></a><ul><li><a href="#1-install-dhruv"><span>1. <wbr/>Install <wbr/>Dhruv</span></a></li><li><a href="#2-start-a-local-model"><span>2. <wbr/>Start a local model</span></a></li><li><a href="#3-configure-once-then-go"><span>3. <wbr/>Configure once, then go</span></a></li></ul><a href="#a-command-surface-built-for-shipping"><span>A command surface built for shipping</span></a><ul><li><a href="#common-workflows"><span>Common workflows</span></a></li></ul><a href="#configuration-that-stays-out-of-your-way"><span>Configuration that stays out of your way</span></a><a href="#extend-it-with-plugins"><span>Extend it with plugins</span></a><a href="#documentation--project-guides"><span>Documentation & project guides</span></a><a href="#development"><span>Development</span></a><a href="#license"><span>License</span></a></div></details></div><div class="site-menu"><nav id="tsd-sidebar-links" class="tsd-navigation"><a href="https://rahul05ranjan.github.io/dhruv-cli/" class="tsd-nav-link">Home</a><a href="https://github.com/rahul05ranjan/dhruv-cli" class="tsd-nav-link">GitHub</a></nav><nav class="tsd-navigation"><a href="modules.html">Dhruv CLI API - v1.4.0</a><ul class="tsd-small-nested-navigation" id="tsd-nav-container"><li>Loading...</li></ul></nav></div></div></div><footer><p class="tsd-generator">Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></footer><div class="overlay"></div></body></html>
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Contributing to Dhruv CLI
|
|
2
|
+
|
|
3
|
+
Thank you for your interest in contributing! 🎉
|
|
4
|
+
|
|
5
|
+
## How to Contribute
|
|
6
|
+
|
|
7
|
+
- **Bug Reports & Feature Requests:**
|
|
8
|
+
- Use [GitHub Issues](../../issues) to report bugs or request features.
|
|
9
|
+
- **Pull Requests:**
|
|
10
|
+
- Fork the repo and create a new branch for your change.
|
|
11
|
+
- Write clear, concise commit messages.
|
|
12
|
+
- Ensure your code passes lint and build checks.
|
|
13
|
+
- Add or update tests as needed.
|
|
14
|
+
- Document your changes in the PR description.
|
|
15
|
+
|
|
16
|
+
## Development Setup
|
|
17
|
+
|
|
18
|
+
1. Clone the repo and install dependencies:
|
|
19
|
+
```sh
|
|
20
|
+
git clone <repo-url>
|
|
21
|
+
cd devai-cli
|
|
22
|
+
npm install
|
|
23
|
+
```
|
|
24
|
+
2. Build and run locally:
|
|
25
|
+
```sh
|
|
26
|
+
npm run build
|
|
27
|
+
npm start
|
|
28
|
+
```
|
|
29
|
+
3. For development:
|
|
30
|
+
```sh
|
|
31
|
+
npm run dev
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Code Style
|
|
35
|
+
- Use TypeScript and follow the existing code style.
|
|
36
|
+
- Run `npx eslint .` before submitting a PR.
|
|
37
|
+
|
|
38
|
+
## Testing
|
|
39
|
+
- Add tests for new features or bug fixes.
|
|
40
|
+
- Run tests with `npm test`.
|
|
41
|
+
|
|
42
|
+
## Commit Message Guidelines
|
|
43
|
+
- Use [Conventional Commits](https://www.conventionalcommits.org/) for commit messages.
|
|
44
|
+
- **Allowed PR title types:**
|
|
45
|
+
- feat
|
|
46
|
+
- fix
|
|
47
|
+
- chore
|
|
48
|
+
- docs
|
|
49
|
+
- refactor
|
|
50
|
+
- style
|
|
51
|
+
- test
|
|
52
|
+
- ci
|
|
53
|
+
- Example: `fix: update version to 1.1.3 and improve streaming response handling`
|
|
54
|
+
- PR titles are checked automatically in CI. See `.github/workflows/contribution.yml` for details.
|
|
55
|
+
|
|
56
|
+
## Code of Conduct
|
|
57
|
+
- Be respectful and inclusive. See [CODE_OF_CONDUCT.md](./CODE_OF_CONDUCT.md).
|
|
58
|
+
|
|
59
|
+
## License
|
|
60
|
+
By contributing, you agree that your contributions will be licensed under the MIT License.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# Security Policy
|
|
2
|
+
|
|
3
|
+
## Reporting a Vulnerability
|
|
4
|
+
|
|
5
|
+
If you discover a security vulnerability, please report it via GitHub Issues or contact the maintainers directly. We will respond as quickly as possible.
|
|
6
|
+
|
|
7
|
+
- Do not disclose security issues publicly until they are resolved.
|
|
8
|
+
- Provide as much detail as possible to help us resolve the issue quickly.
|