@rahul05ranjan/dhruv-cli 1.2.4 โ 1.4.6
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/ENTERPRISE.md +275 -0
- package/.github/ISSUE_TEMPLATE/bug_report.md +45 -17
- package/.github/ISSUE_TEMPLATE/documentation_issue.md +61 -0
- package/.github/ISSUE_TEMPLATE/feature_request.md +61 -9
- package/.github/ISSUE_TEMPLATE/security_vulnerability.md +74 -0
- package/.github/dependabot.yml +42 -2
- package/.github/pull_request_template.md +13 -0
- package/.github/workflows/build-publish.yml +154 -0
- package/.github/workflows/ci.yml +251 -18
- package/.github/workflows/contribution.yml +169 -27
- package/.github/workflows/dependabot-auto-merge.yml +61 -2
- package/.github/workflows/deploy.yml +336 -0
- package/.github/workflows/monitoring.yml +270 -0
- package/.github/workflows/release.yml +229 -0
- package/.github/workflows/security.yml +198 -0
- package/.releaserc.json +50 -0
- package/AGENTS.md +13 -0
- package/CHANGELOG.md +8 -0
- package/PUBLISHING_FIX.md +92 -0
- package/__tests__/core.test.ts +318 -0
- package/__tests__/setup.ts +61 -0
- package/__tests__/workflows.test.ts +95 -0
- package/dist/commands/explain.js +13 -44
- package/dist/commands/fix.js +13 -38
- package/dist/commands/generate.js +45 -54
- package/dist/commands/health.d.ts +1 -0
- package/dist/commands/health.js +376 -0
- package/dist/commands/init.js +47 -42
- package/dist/commands/menu.js +90 -2
- package/dist/commands/metrics.d.ts +1 -0
- package/dist/commands/metrics.js +51 -0
- package/dist/commands/optimize.js +42 -34
- package/dist/commands/review.js +52 -48
- package/dist/commands/security-check.js +52 -42
- package/dist/commands/status.d.ts +1 -0
- package/dist/commands/status.js +45 -0
- package/dist/commands/suggest.js +13 -39
- package/dist/config/config.js +30 -2
- package/dist/core/ai.d.ts +77 -2
- package/dist/core/ai.js +207 -30
- package/dist/core/command-runner.d.ts +17 -0
- package/dist/core/command-runner.js +78 -0
- package/dist/core/logger.d.ts +40 -0
- package/dist/core/logger.js +138 -0
- package/dist/core/metrics.d.ts +34 -0
- package/dist/core/metrics.js +206 -0
- package/dist/core/prompts.d.ts +1 -0
- package/dist/core/prompts.js +121 -0
- package/dist/core/security.d.ts +34 -0
- package/dist/core/security.js +197 -0
- package/dist/index.js +40 -2
- package/dist/utils/ux.d.ts +3 -0
- package/dist/utils/ux.js +15 -0
- package/docs/agents/domain.md +51 -0
- package/docs/agents/issue-tracker.md +45 -0
- package/docs/agents/triage-labels.md +15 -0
- package/docs/api/.nojekyll +1 -0
- package/docs/api/assets/hierarchy.js +1 -0
- package/docs/api/assets/highlight.css +71 -0
- package/docs/api/assets/icons.js +18 -0
- package/docs/api/assets/icons.svg +1 -0
- package/docs/api/assets/main.js +60 -0
- package/docs/api/assets/navigation.js +1 -0
- package/docs/api/assets/search.js +1 -0
- package/docs/api/assets/style.css +1633 -0
- package/docs/api/hierarchy.html +1 -0
- package/docs/api/index.html +39 -0
- package/docs/api/modules.html +1 -0
- package/eslint.config.js +170 -0
- package/jest.config.json +37 -0
- package/lighthouserc.json +22 -0
- package/logs/.8a99b6cf655346317fdbf29f4fffcf91131432f3-audit.json +15 -0
- package/logs/.eee104bf8fff5ecd38a6a2842df260de6470a7c3-audit.json +15 -0
- package/package.json +62 -8
- package/src/commands/explain.ts +13 -42
- package/src/commands/fix.ts +13 -31
- package/src/commands/generate.ts +47 -46
- package/src/commands/health.ts +440 -0
- package/src/commands/init.ts +48 -42
- package/src/commands/menu.ts +86 -2
- package/src/commands/metrics.ts +65 -0
- package/src/commands/optimize.ts +40 -28
- package/src/commands/review.ts +54 -40
- package/src/commands/security-check.ts +54 -34
- package/src/commands/status.ts +47 -0
- package/src/commands/suggest.ts +13 -32
- package/src/config/config.ts +35 -2
- package/src/core/ai.ts +237 -26
- package/src/core/command-runner.ts +105 -0
- package/src/core/logger.ts +194 -0
- package/src/core/metrics.ts +232 -0
- package/src/core/prompts.ts +128 -0
- package/src/core/security.ts +243 -0
- package/src/index.ts +47 -2
- package/src/utils/ux.ts +18 -0
- package/test-suite.sh +147 -0
- package/tsconfig.json +3 -2
- package/typedoc.json +44 -0
- package/types/global.d.ts +13 -0
- package/validate-workflows.sh +270 -0
- package/.eslintignore +0 -1
- package/.eslintrc.cjs +0 -43
- package/src/core/ai.test.js +0 -40
|
@@ -0,0 +1 @@
|
|
|
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><h2>Hierarchy Summary</h2></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></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,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"><h1 id="dhruv-cli" class="tsd-anchor-link">Dhruv CLI<a href="#dhruv-cli" 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></h1><p><a href="https://www.npmjs.com/package/@rahul05ranjan/dhruv-cli">๐ฆ View on npm</a>
|
|
2
|
+
<a href="https://rahul05ranjan.github.io/dhruv-cli/">๐ View Documentation on GitHub Pages</a></p>
|
|
3
|
+
<p>AI-powered CLI assistant for developers using Ollama.</p>
|
|
4
|
+
<h2 id="๐-features" class="tsd-anchor-link">๐ Features<a href="#๐-features" 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><ul>
|
|
5
|
+
<li>Smart command suggestions: <code>suggest</code>, <code>explain</code>, <code>fix</code></li>
|
|
6
|
+
<li>Project context detection (Node, React, Python, etc.)</li>
|
|
7
|
+
<li>Code review: <code>review <fileOrDir></code></li>
|
|
8
|
+
<li>Code optimization: <code>optimize <file></code></li>
|
|
9
|
+
<li>Security analysis: <code>security-check [fileOrDir]</code></li>
|
|
10
|
+
<li>Test/code generation: <code>generate <type> <target></code></li>
|
|
11
|
+
<li>Interactive setup: <code>init</code></li>
|
|
12
|
+
<li>Streaming AI responses in terminal</li>
|
|
13
|
+
<li>Syntax highlighting for code output</li>
|
|
14
|
+
<li>Progress bars for long operations</li>
|
|
15
|
+
<li>Plugin system: drop ESM modules in <code>plugins/</code></li>
|
|
16
|
+
<li>Autocomplete: <code>completion [shell]</code></li>
|
|
17
|
+
<li>Offline-first with local Ollama models</li>
|
|
18
|
+
<li>Beautiful, modern CLI UX</li>
|
|
19
|
+
</ul>
|
|
20
|
+
<h2 id="๐ ๏ธ-installation" class="tsd-anchor-link">๐ ๏ธ Installation<a href="#๐ ๏ธ-installation" 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><span class="hl-1"> </span><span class="hl-3">-g</span><span class="hl-1"> </span><span class="hl-2">@rahul05ranjan/dhruv-cli</span>
|
|
21
|
+
</code><button type="button">Copy</button></pre>
|
|
22
|
+
|
|
23
|
+
<p>Or visit the npm page: <a href="https://www.npmjs.com/package/@rahul05ranjan/dhruv-cli">https://www.npmjs.com/package/@rahul05ranjan/dhruv-cli</a></p>
|
|
24
|
+
<h2 id="๐-usage-examples" class="tsd-anchor-link">๐ Usage Examples<a href="#๐-usage-examples" 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">dhruv</span><span class="hl-1"> </span><span class="hl-2">suggest</span><span class="hl-1"> </span><span class="hl-2">"deploy react app to vercel"</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">fix</span><span class="hl-1"> </span><span class="hl-2">"cors error in express"</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">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">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><br/><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">completion</span><span class="hl-1"> </span><span class="hl-2">bash</span><span class="hl-1"> </span><span class="hl-4">></span><span class="hl-1"> </span><span class="hl-2">dhruv-complete.sh</span><span class="hl-1"> </span><span class="hl-5"># Enable tab completion</span>
|
|
25
|
+
</code><button type="button">Copy</button></pre>
|
|
26
|
+
|
|
27
|
+
<h2 id="๐งฉ-plugins" class="tsd-anchor-link">๐งฉ Plugins<a href="#๐งฉ-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>Add new commands by dropping ESM modules in the <code>plugins/</code> directory. Example:</p>
|
|
28
|
+
<pre><code class="js"><span class="hl-5">// plugins/hello.js</span><br/><span class="hl-4">export</span><span class="hl-1"> </span><span class="hl-4">default</span><span class="hl-1"> (</span><span class="hl-6">program</span><span class="hl-1">) </span><span class="hl-4">=></span><span class="hl-1"> {</span><br/><span class="hl-1"> program.</span><span class="hl-0">command</span><span class="hl-1">(</span><span class="hl-2">'hello-plugin'</span><span class="hl-1">).</span><span class="hl-0">action</span><span class="hl-1">(() </span><span class="hl-4">=></span><span class="hl-1"> console.</span><span class="hl-0">log</span><span class="hl-1">(</span><span class="hl-2">'Hello from plugin!'</span><span class="hl-1">));</span><br/><span class="hl-1">};</span>
|
|
29
|
+
</code><button type="button">Copy</button></pre>
|
|
30
|
+
|
|
31
|
+
<h2 id="๐ฆ-configuration" class="tsd-anchor-link">๐ฆ Configuration<a href="#๐ฆ-configuration" 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><ul>
|
|
32
|
+
<li>Run <code>dhruv init</code> to set model, response format, and verbosity.</li>
|
|
33
|
+
<li>Project type auto-detected for context-aware suggestions.</li>
|
|
34
|
+
</ul>
|
|
35
|
+
<h2 id="๐ฅ๏ธ-advanced-ux" class="tsd-anchor-link">๐ฅ๏ธ Advanced UX<a href="#๐ฅ๏ธ-advanced-ux" 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><ul>
|
|
36
|
+
<li>Streaming output, syntax highlighting, progress bars, colored errors, and interactive menus.</li>
|
|
37
|
+
</ul>
|
|
38
|
+
<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</p>
|
|
39
|
+
</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="#dhruv-cli"><span>Dhruv <wbr/>CLI</span></a><ul><li><a href="#๐-features"><span>๐ <wbr/>Features</span></a></li><li><a href="#๐ ๏ธ-installation"><span>๐ ๏ธ <wbr/>Installation</span></a></li><li><a href="#๐-usage-examples"><span>๐ <wbr/>Usage <wbr/>Examples</span></a></li><li><a href="#๐งฉ-plugins"><span>๐งฉ <wbr/>Plugins</span></a></li><li><a href="#๐ฆ-configuration"><span>๐ฆ <wbr/>Configuration</span></a></li><li><a href="#๐ฅ๏ธ-advanced-ux"><span>๐ฅ๏ธ <wbr/>Advanced <wbr/>UX</span></a></li><li><a href="#license"><span>License</span></a></li></ul></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 @@
|
|
|
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"><ul class="tsd-breadcrumb" aria-label="Breadcrumb"></ul><h1>Dhruv CLI API - v1.4.0</h1></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></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" class="current">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>
|
package/eslint.config.js
ADDED
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import js from '@eslint/js';
|
|
2
|
+
import tseslint from 'typescript-eslint';
|
|
3
|
+
|
|
4
|
+
export default [
|
|
5
|
+
// Base configuration
|
|
6
|
+
js.configs.recommended,
|
|
7
|
+
|
|
8
|
+
// Global ignores (migrated from .eslintignore)
|
|
9
|
+
{
|
|
10
|
+
ignores: [
|
|
11
|
+
'dist/',
|
|
12
|
+
'node_modules/',
|
|
13
|
+
'node-fetch.d.ts',
|
|
14
|
+
'coverage/',
|
|
15
|
+
'.dhruv-cache/',
|
|
16
|
+
'logs/',
|
|
17
|
+
'docs/'
|
|
18
|
+
]
|
|
19
|
+
},
|
|
20
|
+
|
|
21
|
+
// TypeScript files configuration (excluding test files)
|
|
22
|
+
{
|
|
23
|
+
files: ['**/*.ts', '**/*.tsx'],
|
|
24
|
+
ignores: ['__tests__/**/*', '**/*.test.ts', '**/*.spec.ts', 'src/core/logger.ts', 'src/core/security.ts'],
|
|
25
|
+
languageOptions: {
|
|
26
|
+
parser: tseslint.parser,
|
|
27
|
+
parserOptions: {
|
|
28
|
+
project: './tsconfig.json',
|
|
29
|
+
sourceType: 'module',
|
|
30
|
+
ecmaVersion: 2020,
|
|
31
|
+
},
|
|
32
|
+
globals: {
|
|
33
|
+
console: 'readonly',
|
|
34
|
+
process: 'readonly',
|
|
35
|
+
Buffer: 'readonly',
|
|
36
|
+
setTimeout: 'readonly',
|
|
37
|
+
__dirname: 'readonly',
|
|
38
|
+
__filename: 'readonly',
|
|
39
|
+
global: 'readonly',
|
|
40
|
+
module: 'readonly',
|
|
41
|
+
require: 'readonly',
|
|
42
|
+
exports: 'readonly',
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
plugins: {
|
|
46
|
+
'@typescript-eslint': tseslint.plugin,
|
|
47
|
+
},
|
|
48
|
+
rules: {
|
|
49
|
+
...tseslint.configs.recommended.rules,
|
|
50
|
+
'no-console': 'off',
|
|
51
|
+
'@typescript-eslint/no-unused-vars': ['warn', {
|
|
52
|
+
'argsIgnorePattern': '^_|error|e',
|
|
53
|
+
'varsIgnorePattern': '^_|response|error|e|Command|printSuccess|printInfo|printWarning|detectProjectType',
|
|
54
|
+
'ignoreRestSiblings': true
|
|
55
|
+
}],
|
|
56
|
+
'@typescript-eslint/explicit-function-return-type': 'off',
|
|
57
|
+
'@typescript-eslint/no-explicit-any': ['warn', {
|
|
58
|
+
'ignoreRestArgs': true
|
|
59
|
+
}],
|
|
60
|
+
'no-var': 'error',
|
|
61
|
+
'prefer-const': 'error',
|
|
62
|
+
'eqeqeq': ['error', 'always'],
|
|
63
|
+
'no-undef': 'off', // Turn off because we're using globals
|
|
64
|
+
'no-redeclare': 'off', // Allow redeclaration of globals
|
|
65
|
+
'no-unused-vars': 'off', // Turn off base rule, use @typescript-eslint/no-unused-vars
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
|
|
69
|
+
// Lenient configuration for files with external library interfaces
|
|
70
|
+
{
|
|
71
|
+
files: ['src/core/logger.ts', 'src/core/security.ts'],
|
|
72
|
+
languageOptions: {
|
|
73
|
+
parser: tseslint.parser,
|
|
74
|
+
parserOptions: {
|
|
75
|
+
project: './tsconfig.json',
|
|
76
|
+
sourceType: 'module',
|
|
77
|
+
ecmaVersion: 2020,
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
plugins: {
|
|
81
|
+
'@typescript-eslint': tseslint.plugin,
|
|
82
|
+
},
|
|
83
|
+
rules: {
|
|
84
|
+
...tseslint.configs.recommended.rules,
|
|
85
|
+
'no-console': 'off',
|
|
86
|
+
'@typescript-eslint/no-unused-vars': 'off',
|
|
87
|
+
'@typescript-eslint/explicit-function-return-type': 'off',
|
|
88
|
+
'@typescript-eslint/no-explicit-any': 'off', // Allow any in these files due to Winston/security libraries
|
|
89
|
+
'no-var': 'error',
|
|
90
|
+
'prefer-const': 'error',
|
|
91
|
+
'eqeqeq': ['error', 'always'],
|
|
92
|
+
'no-undef': 'off',
|
|
93
|
+
'no-redeclare': 'off',
|
|
94
|
+
'no-unused-vars': 'off',
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
|
|
98
|
+
// JavaScript files configuration
|
|
99
|
+
{
|
|
100
|
+
files: ['**/*.js'],
|
|
101
|
+
languageOptions: {
|
|
102
|
+
sourceType: 'module',
|
|
103
|
+
ecmaVersion: 2020,
|
|
104
|
+
globals: {
|
|
105
|
+
console: 'readonly',
|
|
106
|
+
process: 'readonly',
|
|
107
|
+
Buffer: 'readonly',
|
|
108
|
+
setTimeout: 'readonly',
|
|
109
|
+
__dirname: 'readonly',
|
|
110
|
+
__filename: 'readonly',
|
|
111
|
+
global: 'readonly',
|
|
112
|
+
module: 'readonly',
|
|
113
|
+
require: 'readonly',
|
|
114
|
+
exports: 'readonly',
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
rules: {
|
|
118
|
+
'no-console': 'off',
|
|
119
|
+
'no-var': 'error',
|
|
120
|
+
'prefer-const': 'error',
|
|
121
|
+
'eqeqeq': ['error', 'always'],
|
|
122
|
+
'no-undef': 'off', // Turn off because we're using globals
|
|
123
|
+
'no-redeclare': 'off', // Allow redeclaration of globals
|
|
124
|
+
'no-unused-vars': 'off', // Allow unused vars in JS files for flexibility
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
|
|
128
|
+
// Test files configuration (separate project config)
|
|
129
|
+
{
|
|
130
|
+
files: ['__tests__/**/*.{ts,js}', '**/*.test.{ts,js}', '**/*.spec.{ts,js}'],
|
|
131
|
+
languageOptions: {
|
|
132
|
+
parser: tseslint.parser,
|
|
133
|
+
parserOptions: {
|
|
134
|
+
sourceType: 'module',
|
|
135
|
+
ecmaVersion: 2020,
|
|
136
|
+
// Don't use project for test files since they're not in tsconfig.json
|
|
137
|
+
},
|
|
138
|
+
globals: {
|
|
139
|
+
console: 'readonly',
|
|
140
|
+
process: 'readonly',
|
|
141
|
+
Buffer: 'readonly',
|
|
142
|
+
setTimeout: 'readonly',
|
|
143
|
+
describe: 'readonly',
|
|
144
|
+
it: 'readonly',
|
|
145
|
+
test: 'readonly',
|
|
146
|
+
expect: 'readonly',
|
|
147
|
+
beforeEach: 'readonly',
|
|
148
|
+
afterEach: 'readonly',
|
|
149
|
+
beforeAll: 'readonly',
|
|
150
|
+
afterAll: 'readonly',
|
|
151
|
+
jest: 'readonly',
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
plugins: {
|
|
155
|
+
'@typescript-eslint': tseslint.plugin,
|
|
156
|
+
},
|
|
157
|
+
rules: {
|
|
158
|
+
'@typescript-eslint/no-unused-vars': ['warn', {
|
|
159
|
+
'argsIgnorePattern': '^_|error|e',
|
|
160
|
+
'varsIgnorePattern': '^_|response|error|e|Command|printSuccess|printInfo|printWarning|detectProjectType',
|
|
161
|
+
'ignoreRestSiblings': true
|
|
162
|
+
}],
|
|
163
|
+
'@typescript-eslint/explicit-function-return-type': 'off',
|
|
164
|
+
'@typescript-eslint/no-explicit-any': 'warn',
|
|
165
|
+
'no-undef': 'off', // Turn off because we're using globals
|
|
166
|
+
'no-redeclare': 'off', // Allow redeclaration of globals
|
|
167
|
+
'no-unused-vars': 'off', // Turn off base rule, use @typescript-eslint/no-unused-vars
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
];
|
package/jest.config.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"preset": "ts-jest",
|
|
3
|
+
"testEnvironment": "node",
|
|
4
|
+
"roots": ["<rootDir>/src", "<rootDir>/__tests__"],
|
|
5
|
+
"testMatch": ["**/__tests__/**/*.test.ts", "**/*.test.ts", "**/*.spec.ts"],
|
|
6
|
+
"testPathIgnorePatterns": ["/node_modules/", "/dist/", "/coverage/", "\\.test\\.js$", "\\.spec\\.js$"],
|
|
7
|
+
"transform": {
|
|
8
|
+
"^.+\\.ts$": "ts-jest"
|
|
9
|
+
},
|
|
10
|
+
"moduleNameMapper": {
|
|
11
|
+
"^(\\.{1,2}/.*)\\.js$": "$1"
|
|
12
|
+
},
|
|
13
|
+
"collectCoverageFrom": [
|
|
14
|
+
"src/**/*.ts",
|
|
15
|
+
"!src/**/*.d.ts",
|
|
16
|
+
"!src/index.ts"
|
|
17
|
+
],
|
|
18
|
+
"coverageDirectory": "coverage",
|
|
19
|
+
"coverageReporters": ["text", "lcov", "html"],
|
|
20
|
+
"reporters": [
|
|
21
|
+
"default",
|
|
22
|
+
["jest-junit", { "outputDirectory": "coverage", "outputName": "junit.xml" }]
|
|
23
|
+
],
|
|
24
|
+
"coverageThreshold": {
|
|
25
|
+
"global": {
|
|
26
|
+
"branches": 7,
|
|
27
|
+
"functions": 5,
|
|
28
|
+
"lines": 6,
|
|
29
|
+
"statements": 6
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"setupFilesAfterEnv": ["<rootDir>/__tests__/setup.ts"],
|
|
33
|
+
"testTimeout": 10000,
|
|
34
|
+
"verbose": true,
|
|
35
|
+
"forceExit": true,
|
|
36
|
+
"detectOpenHandles": true
|
|
37
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"ci": {
|
|
3
|
+
"collect": {
|
|
4
|
+
"numberOfRuns": 3,
|
|
5
|
+
"startServerCommand": "npm run start",
|
|
6
|
+
"startServerReadyPattern": "Dhruv CLI is running",
|
|
7
|
+
"url": ["http://localhost:3000"]
|
|
8
|
+
},
|
|
9
|
+
"assert": {
|
|
10
|
+
"assertions": {
|
|
11
|
+
"categories:performance": ["error", {"minScore": 0.8}],
|
|
12
|
+
"categories:accessibility": ["error", {"minScore": 0.9}],
|
|
13
|
+
"categories:best-practices": ["error", {"minScore": 0.9}],
|
|
14
|
+
"categories:seo": ["error", {"minScore": 0.9}],
|
|
15
|
+
"categories:pwa": "off"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"upload": {
|
|
19
|
+
"target": "temporary-public-storage"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"keep": {
|
|
3
|
+
"days": true,
|
|
4
|
+
"amount": 30
|
|
5
|
+
},
|
|
6
|
+
"auditLog": "/home/rahul/Desktop/PROJECTS/dhruv-cli/logs/.8a99b6cf655346317fdbf29f4fffcf91131432f3-audit.json",
|
|
7
|
+
"files": [
|
|
8
|
+
{
|
|
9
|
+
"date": 1756285433393,
|
|
10
|
+
"name": "/home/rahul/Desktop/PROJECTS/dhruv-cli/logs/dhruv-error-2025-08-27.log",
|
|
11
|
+
"hash": "d7b55f1604a32af70dd71097f288f4c64aa78342ca90305309f78dad8905ed37"
|
|
12
|
+
}
|
|
13
|
+
],
|
|
14
|
+
"hashType": "sha256"
|
|
15
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"keep": {
|
|
3
|
+
"days": true,
|
|
4
|
+
"amount": 14
|
|
5
|
+
},
|
|
6
|
+
"auditLog": "/home/rahul/Desktop/PROJECTS/dhruv-cli/logs/.eee104bf8fff5ecd38a6a2842df260de6470a7c3-audit.json",
|
|
7
|
+
"files": [
|
|
8
|
+
{
|
|
9
|
+
"date": 1756285433392,
|
|
10
|
+
"name": "/home/rahul/Desktop/PROJECTS/dhruv-cli/logs/dhruv-2025-08-27.log",
|
|
11
|
+
"hash": "8e168d328c6da1e7736e2cde8c8d11f1c272f96976c25c5d55aabd90c1afc44b"
|
|
12
|
+
}
|
|
13
|
+
],
|
|
14
|
+
"hashType": "sha256"
|
|
15
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rahul05ranjan/dhruv-cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.6",
|
|
4
4
|
"description": "AI-powered CLI assistant for developers using Ollama",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai",
|
|
@@ -21,7 +21,30 @@
|
|
|
21
21
|
"scripts": {
|
|
22
22
|
"build": "tsc",
|
|
23
23
|
"start": "node ./dist/index.js",
|
|
24
|
-
"dev": "ts-node src/index.ts"
|
|
24
|
+
"dev": "ts-node src/index.ts",
|
|
25
|
+
"test": "jest",
|
|
26
|
+
"test:watch": "jest --watch",
|
|
27
|
+
"test:coverage": "jest --coverage",
|
|
28
|
+
"test:ci": "jest --coverage --watchAll=false --passWithNoTests",
|
|
29
|
+
"test:e2e": "jest --config jest.e2e.config.js",
|
|
30
|
+
"lint": "eslint . --ext .ts,.js",
|
|
31
|
+
"lint:fix": "eslint . --ext .ts,.js --fix",
|
|
32
|
+
"type-check": "tsc --noEmit",
|
|
33
|
+
"docs": "typedoc --out docs/api src",
|
|
34
|
+
"docs:serve": "npx serve docs",
|
|
35
|
+
"docs:publish": "npm run docs && gh-pages -d docs",
|
|
36
|
+
"benchmark": "autocannon -c 100 -d 10 http://localhost:3000",
|
|
37
|
+
"performance": "lighthouse http://localhost:3000 --output=json --output-path=./reports/lighthouse.json",
|
|
38
|
+
"security": "npm audit --audit-level=moderate",
|
|
39
|
+
"security:full": "npm audit --audit-level=info",
|
|
40
|
+
"clean": "rm -rf dist coverage .dhruv-cache logs/*.log",
|
|
41
|
+
"prepublishOnly": "npm run clean && npm run lint && npm run test:ci && npm run build",
|
|
42
|
+
"release": "semantic-release",
|
|
43
|
+
"release:beta": "semantic-release --tag beta",
|
|
44
|
+
"docker:build": "docker build -t dhruv-cli .",
|
|
45
|
+
"docker:run": "docker run -it dhruv-cli",
|
|
46
|
+
"health": "node dist/index.js health",
|
|
47
|
+
"metrics": "node dist/index.js metrics"
|
|
25
48
|
},
|
|
26
49
|
"dependencies": {
|
|
27
50
|
"chalk": "^5.3.0",
|
|
@@ -29,21 +52,52 @@
|
|
|
29
52
|
"cli-progress": "^3.12.0",
|
|
30
53
|
"commander": "^14.0.0",
|
|
31
54
|
"inquirer": "^12.6.3",
|
|
32
|
-
"
|
|
55
|
+
"joi": "^18.2.9",
|
|
56
|
+
"node-fetch": "^3.3.2",
|
|
33
57
|
"ollama": "^0.5.16",
|
|
34
|
-
"ora": "^8.2.0"
|
|
58
|
+
"ora": "^8.2.0",
|
|
59
|
+
"prom-client": "^15.1.3",
|
|
60
|
+
"validator": "^13.15.35",
|
|
61
|
+
"winston": "^3.17.0",
|
|
62
|
+
"winston-daily-rotate-file": "^5.0.0"
|
|
35
63
|
},
|
|
36
64
|
"devDependencies": {
|
|
37
|
-
"@eslint/js": "^
|
|
65
|
+
"@eslint/js": "^9.30.1",
|
|
66
|
+
"@lhci/cli": "^0.15.1",
|
|
67
|
+
"@semantic-release/changelog": "^6.0.3",
|
|
68
|
+
"@semantic-release/commit-analyzer": "^12.0.0",
|
|
69
|
+
"@semantic-release/git": "^10.0.1",
|
|
70
|
+
"@semantic-release/github": "^10.3.5",
|
|
71
|
+
"@semantic-release/npm": "^13.1.5",
|
|
72
|
+
"@semantic-release/release-notes-generator": "^12.1.0",
|
|
38
73
|
"@types/inquirer": "^9.0.8",
|
|
74
|
+
"@types/jest": "^30.0.0",
|
|
75
|
+
"@types/nock": "^10.0.3",
|
|
39
76
|
"@types/node": "^24.0.7",
|
|
77
|
+
"@types/supertest": "^6.0.3",
|
|
78
|
+
"@types/validator": "^13.15.2",
|
|
40
79
|
"@typescript-eslint/eslint-plugin": "^8.35.0",
|
|
41
80
|
"@typescript-eslint/parser": "^8.35.0",
|
|
42
|
-
"
|
|
43
|
-
"
|
|
81
|
+
"autocannon": "^8.0.0",
|
|
82
|
+
"benchmark": "^2.1.4",
|
|
83
|
+
"eslint": "^9.30.0",
|
|
84
|
+
"istanbul-lib-coverage": "^3.2.2",
|
|
85
|
+
"istanbul-lib-report": "^3.0.1",
|
|
86
|
+
"istanbul-reports": "^3.2.0",
|
|
87
|
+
"jest": "^30.1.0",
|
|
88
|
+
"jest-junit": "^17.0.0",
|
|
89
|
+
"jsdoc-to-markdown": "^9.1.2",
|
|
90
|
+
"lighthouse": "^12.8.1",
|
|
91
|
+
"nock": "^14.0.10",
|
|
92
|
+
"semantic-release": "^25.0.1",
|
|
93
|
+
"supertest": "^7.1.4",
|
|
94
|
+
"ts-jest": "^29.4.1",
|
|
44
95
|
"ts-node": "^10.9.1",
|
|
96
|
+
"typedoc": "^0.28.11",
|
|
97
|
+
"typedoc-plugin-markdown": "^4.8.1",
|
|
45
98
|
"typescript": "^5.8.3",
|
|
46
|
-
"typescript-eslint": "^8.35.0"
|
|
99
|
+
"typescript-eslint": "^8.35.0",
|
|
100
|
+
"yaml": "^2.9.1"
|
|
47
101
|
},
|
|
48
102
|
"repository": {
|
|
49
103
|
"type": "git",
|
package/src/commands/explain.ts
CHANGED
|
@@ -1,45 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import chalk from 'chalk';
|
|
4
|
-
import { loadConfig } from '../config/config.js';
|
|
5
|
-
import { highlightCode, printError } from '../utils/ux.js';
|
|
1
|
+
import { runCommand } from '../core/command-runner.js';
|
|
2
|
+
import { getSystemMessage } from '../core/prompts.js';
|
|
6
3
|
|
|
7
4
|
export async function explain(query: string) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
onToken: (token: string) => {
|
|
20
|
-
streamed += token;
|
|
21
|
-
process.stdout.write(chalk.cyan(token));
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
process.stdout.write('\n');
|
|
25
|
-
if (typeof highlightCode === 'function' && streamed.match(/```[a-z]*[\s\S]*?```/)) {
|
|
26
|
-
const codeBlocks = streamed.match(/```([a-z]*)\n([\s\S]*?)```/g) || [];
|
|
27
|
-
for (const block of codeBlocks) {
|
|
28
|
-
const [, lang, code] = block.match(/```([a-z]*)\n([\s\S]*?)```/) || [];
|
|
29
|
-
if (code) {
|
|
30
|
-
try {
|
|
31
|
-
console.log(highlightCode(code, lang || 'js'));
|
|
32
|
-
} catch (err) {
|
|
33
|
-
// Only log highlight errors in development
|
|
34
|
-
if (process.env.NODE_ENV === 'development') {
|
|
35
|
-
console.error('Highlight error:', err);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
} catch (err) {
|
|
42
|
-
printError('Failed to get explanation.');
|
|
43
|
-
console.error(chalk.red((err as Error).message));
|
|
44
|
-
}
|
|
5
|
+
await runCommand({
|
|
6
|
+
name: 'explain',
|
|
7
|
+
input: { query },
|
|
8
|
+
header: '๐ Explanation: ',
|
|
9
|
+
buildRequest: (input, model) => ({
|
|
10
|
+
prompt: input.query,
|
|
11
|
+
systemMessage: getSystemMessage('explain'),
|
|
12
|
+
model,
|
|
13
|
+
}),
|
|
14
|
+
footer: `๐ก Need more help? Try: dhruv suggest "${query}"`,
|
|
15
|
+
});
|
|
45
16
|
}
|
package/src/commands/fix.ts
CHANGED
|
@@ -1,34 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import chalk from 'chalk';
|
|
4
|
-
import { loadConfig } from '../config/config.js';
|
|
5
|
-
import { highlightCode, printError } from '../utils/ux.js';
|
|
1
|
+
import { runCommand } from '../core/command-runner.js';
|
|
2
|
+
import { getSystemMessage } from '../core/prompts.js';
|
|
6
3
|
|
|
7
4
|
export async function fix(query: string) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
process.stdout.write(chalk.cyan(token));
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
process.stdout.write('\n');
|
|
23
|
-
if (typeof highlightCode === 'function' && streamed.match(/```[a-z]*[\s\S]*?```/)) {
|
|
24
|
-
const codeBlocks = streamed.match(/```([a-z]*)\n([\s\S]*?)```/g) || [];
|
|
25
|
-
for (const block of codeBlocks) {
|
|
26
|
-
const [, lang, code] = block.match(/```([a-z]*)\n([\s\S]*?)```/) || [];
|
|
27
|
-
if (code) try { console.log(highlightCode(code, lang || 'js')); } catch (err) { console.error('Highlight error:', err); }
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
} catch (err) {
|
|
31
|
-
printError('Failed to get fix suggestion.');
|
|
32
|
-
console.error(chalk.red((err as Error).message));
|
|
33
|
-
}
|
|
5
|
+
await runCommand({
|
|
6
|
+
name: 'fix',
|
|
7
|
+
input: { query },
|
|
8
|
+
header: '๐ง Fix Analysis: ',
|
|
9
|
+
buildRequest: (input, model) => ({
|
|
10
|
+
prompt: input.query,
|
|
11
|
+
systemMessage: getSystemMessage('fix'),
|
|
12
|
+
model,
|
|
13
|
+
}),
|
|
14
|
+
footer: `๐งช Want to test this? Try: dhruv generate tests <your-file>`,
|
|
15
|
+
});
|
|
34
16
|
}
|