@rahul05ranjan/dhruv-cli 0.0.0-development

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.
Files changed (69) hide show
  1. package/.eslintignore +1 -0
  2. package/.eslintrc.cjs +43 -0
  3. package/.github/ISSUE_TEMPLATE/bug_report.md +28 -0
  4. package/.github/ISSUE_TEMPLATE/feature_request.md +17 -0
  5. package/.github/PULL_REQUEST_TEMPLATE.md +13 -0
  6. package/.github/auto_assign.yml +10 -0
  7. package/.github/copilot-instructions.md +3 -0
  8. package/.github/dependabot.yml +15 -0
  9. package/.github/labeler.yml +27 -0
  10. package/.github/workflows/auto-assign.yml +14 -0
  11. package/.github/workflows/ci.yml +53 -0
  12. package/.github/workflows/contribution.yml +51 -0
  13. package/.github/workflows/dependabot-auto-merge.yml +19 -0
  14. package/.github/workflows/labeler.yml +13 -0
  15. package/.github/workflows/stale.yml +17 -0
  16. package/.releaserc +12 -0
  17. package/CHANGELOG.md +56 -0
  18. package/CODE_OF_CONDUCT.md +19 -0
  19. package/CONTRIBUTING.md +60 -0
  20. package/README.md +61 -0
  21. package/SECURITY.md +8 -0
  22. package/dist/commands/explain.d.ts +1 -0
  23. package/dist/commands/explain.js +46 -0
  24. package/dist/commands/fix.d.ts +1 -0
  25. package/dist/commands/fix.js +40 -0
  26. package/dist/commands/generate.d.ts +1 -0
  27. package/dist/commands/generate.js +62 -0
  28. package/dist/commands/init.d.ts +1 -0
  29. package/dist/commands/init.js +54 -0
  30. package/dist/commands/menu.d.ts +1 -0
  31. package/dist/commands/menu.js +33 -0
  32. package/dist/commands/optimize.d.ts +1 -0
  33. package/dist/commands/optimize.js +42 -0
  34. package/dist/commands/review.d.ts +1 -0
  35. package/dist/commands/review.js +54 -0
  36. package/dist/commands/security-check.d.ts +1 -0
  37. package/dist/commands/security-check.js +48 -0
  38. package/dist/commands/suggest.d.ts +1 -0
  39. package/dist/commands/suggest.js +41 -0
  40. package/dist/config/config.d.ts +8 -0
  41. package/dist/config/config.js +20 -0
  42. package/dist/core/ai.d.ts +5 -0
  43. package/dist/core/ai.js +43 -0
  44. package/dist/index.d.ts +2 -0
  45. package/dist/index.js +143 -0
  46. package/dist/utils/projectType.d.ts +1 -0
  47. package/dist/utils/projectType.js +17 -0
  48. package/dist/utils/ux.d.ts +5 -0
  49. package/dist/utils/ux.js +44 -0
  50. package/docs/index.html +537 -0
  51. package/node-fetch.d.ts +4 -0
  52. package/package.json +55 -0
  53. package/plugins/hello.js +10 -0
  54. package/src/commands/explain.ts +45 -0
  55. package/src/commands/fix.ts +34 -0
  56. package/src/commands/generate.ts +55 -0
  57. package/src/commands/init.ts +54 -0
  58. package/src/commands/menu.ts +35 -0
  59. package/src/commands/optimize.ts +36 -0
  60. package/src/commands/review.ts +47 -0
  61. package/src/commands/security-check.ts +41 -0
  62. package/src/commands/suggest.ts +35 -0
  63. package/src/config/config.ts +32 -0
  64. package/src/core/ai.test.js +40 -0
  65. package/src/core/ai.ts +41 -0
  66. package/src/index.ts +154 -0
  67. package/src/utils/projectType.ts +14 -0
  68. package/src/utils/ux.ts +50 -0
  69. package/tsconfig.json +17 -0
package/.eslintignore ADDED
@@ -0,0 +1 @@
1
+ node-fetch.d.ts
package/.eslintrc.cjs ADDED
@@ -0,0 +1,43 @@
1
+ module.exports = {
2
+ root: true,
3
+ ignorePatterns: ['dist/', 'node_modules/'],
4
+ overrides: [
5
+ {
6
+ files: ['**/*.ts', '**/*.tsx'],
7
+ parser: '@typescript-eslint/parser',
8
+ parserOptions: {
9
+ project: './tsconfig.json',
10
+ sourceType: 'module',
11
+ ecmaVersion: 2020,
12
+ },
13
+ plugins: ['@typescript-eslint'],
14
+ extends: [
15
+ 'eslint:recommended',
16
+ 'plugin:@typescript-eslint/recommended',
17
+ ],
18
+ rules: {
19
+ 'no-console': 'off',
20
+ '@typescript-eslint/no-unused-vars': ['warn', { 'argsIgnorePattern': '^_' }],
21
+ '@typescript-eslint/explicit-function-return-type': 'off',
22
+ '@typescript-eslint/no-explicit-any': 'warn',
23
+ 'no-var': 'error',
24
+ 'prefer-const': 'error',
25
+ 'eqeqeq': ['error', 'always'],
26
+ },
27
+ },
28
+ {
29
+ files: ['**/*.js'],
30
+ parserOptions: {
31
+ sourceType: 'module',
32
+ ecmaVersion: 2020,
33
+ },
34
+ extends: ['eslint:recommended'],
35
+ rules: {
36
+ 'no-console': 'off',
37
+ 'no-var': 'error',
38
+ 'prefer-const': 'error',
39
+ 'eqeqeq': ['error', 'always'],
40
+ },
41
+ },
42
+ ],
43
+ };
@@ -0,0 +1,28 @@
1
+ ---
2
+ name: Bug Report
3
+ about: Create a report to help us improve
4
+ labels: bug
5
+ ---
6
+
7
+ **Describe the bug**
8
+ A clear and concise description of what the bug is.
9
+
10
+ **To Reproduce**
11
+ Steps to reproduce the behavior:
12
+ 1. Go to '...'
13
+ 2. Run '...'
14
+ 3. See error
15
+
16
+ **Expected behavior**
17
+ A clear and concise description of what you expected to happen.
18
+
19
+ **Screenshots**
20
+ If applicable, add screenshots to help explain your problem.
21
+
22
+ **Environment (please complete the following information):**
23
+ - OS: [e.g. Windows, Mac, Linux]
24
+ - Node version: [e.g. 18]
25
+ - CLI version: [e.g. 1.0.0]
26
+
27
+ **Additional context**
28
+ Add any other context about the problem here.
@@ -0,0 +1,17 @@
1
+ ---
2
+ name: Feature Request
3
+ about: Suggest an idea for this project
4
+ labels: enhancement
5
+ ---
6
+
7
+ **Is your feature request related to a problem? Please describe.**
8
+ A clear and concise description of what the problem is.
9
+
10
+ **Describe the solution you'd like**
11
+ A clear and concise description of what you want to happen.
12
+
13
+ **Describe alternatives you've considered**
14
+ A clear and concise description of any alternative solutions or features you've considered.
15
+
16
+ **Additional context**
17
+ Add any other context or screenshots about the feature request here.
@@ -0,0 +1,13 @@
1
+ # Pull Request
2
+
3
+ ## Description
4
+ Please include a summary of the change and which issue is fixed. Also include relevant motivation and context.
5
+
6
+ ## Checklist
7
+ - [ ] My code follows the style guidelines of this project
8
+ - [ ] I have performed a self-review of my code
9
+ - [ ] I have commented my code, particularly in hard-to-understand areas
10
+ - [ ] I have made corresponding changes to the documentation
11
+ - [ ] My changes generate no new warnings
12
+ - [ ] I have added tests that prove my fix is effective or that my feature works
13
+ - [ ] New and existing unit tests pass locally with my changes
@@ -0,0 +1,10 @@
1
+ addReviewers: true
2
+ addAssignees: true
3
+ reviewers:
4
+ - dhruv-ai
5
+ - dhruv-maintainers
6
+ assignees:
7
+ - dhruv-ai
8
+ - dhruv-maintainers
9
+ numberOfReviewers: 1
10
+ numberOfAssignees: 1
@@ -0,0 +1,3 @@
1
+ <!-- Use this file to provide workspace-specific custom instructions to Copilot. For more details, visit https://code.visualstudio.com/docs/copilot/copilot-customization#_use-a-githubcopilotinstructionsmd-file -->
2
+
3
+ This project is a TypeScript-based CLI tool for developers, powered by local AI models via Ollama. Focus on CLI best practices, robust error handling, and extensibility.
@@ -0,0 +1,15 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: "npm"
4
+ directory: "/"
5
+ schedule:
6
+ interval: "weekly"
7
+ open-pull-requests-limit: 5
8
+ commit-message:
9
+ prefix: "chore(deps)"
10
+ labels:
11
+ - "dependencies"
12
+ reviewers:
13
+ - "dhruv-maintainers"
14
+ assignees:
15
+ - "dhruv-ai"
@@ -0,0 +1,27 @@
1
+ # Automatically label PRs based on file paths or globs
2
+ labels:
3
+ - label: 'cli'
4
+ patterns:
5
+ - 'src/**'
6
+ - 'bin/**'
7
+ - label: 'docs'
8
+ patterns:
9
+ - 'docs/**'
10
+ - '**/*.md'
11
+ - label: 'ci'
12
+ patterns:
13
+ - '.github/workflows/**'
14
+ - '.github/ISSUE_TEMPLATE/**'
15
+ - '.github/PULL_REQUEST_TEMPLATE.md'
16
+ - '.github/labeler.yml'
17
+ - '.github/auto_assign.yml'
18
+ - '.github/contribution.yml'
19
+ - '.github/stale.yml'
20
+ - '.github/release-please.yml'
21
+ - label: 'tests'
22
+ patterns:
23
+ - 'tests/**'
24
+ - '**/*.test.*'
25
+ - label: 'plugins'
26
+ patterns:
27
+ - 'plugins/**'
@@ -0,0 +1,14 @@
1
+ name: Auto Assign
2
+
3
+ on:
4
+ pull_request:
5
+ types: [opened, reopened]
6
+
7
+ jobs:
8
+ add-assignees:
9
+ runs-on: ubuntu-latest
10
+ steps:
11
+ - uses: kentaro-m/auto-assign-action@v1.2.4
12
+ with:
13
+ repo-token: ${{ secrets.GITHUB_TOKEN }}
14
+ configuration-path: .github/auto_assign.yml
@@ -0,0 +1,53 @@
1
+ name: Dhruv CLI CI/CD
2
+
3
+ on:
4
+ push:
5
+ branches: [ main ]
6
+ pull_request:
7
+ branches: [ main ]
8
+
9
+ permissions:
10
+ contents: write
11
+
12
+ jobs:
13
+ build:
14
+ runs-on: ubuntu-latest
15
+ steps:
16
+ - uses: actions/checkout@v4
17
+ - name: Set up Node.js
18
+ uses: actions/setup-node@v4
19
+ with:
20
+ node-version: '20.8.1'
21
+ - name: Install dependencies
22
+ run: npm ci
23
+ - name: Lint
24
+ run: npx eslint .
25
+ - name: Build
26
+ run: npm run build
27
+ - name: Test
28
+ run: npm test || echo "No tests yet"
29
+ - name: Upload docs to GitHub Pages
30
+ if: github.ref == 'refs/heads/main'
31
+ uses: peaceiris/actions-gh-pages@v4
32
+ with:
33
+ github_token: ${{ secrets.GITHUB_TOKEN }}
34
+ publish_dir: ./docs
35
+ publish_branch: gh-pages
36
+ - name: Publish to npm
37
+ if: github.ref == 'refs/heads/main' && github.event_name == 'push'
38
+ run: |
39
+ npm config set //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}
40
+ npm publish --access public
41
+ - name: Create GitHub Release
42
+ if: startsWith(github.ref, 'refs/tags/v')
43
+ uses: softprops/action-gh-release@v2
44
+ with:
45
+ files: |
46
+ dist/**
47
+ docs/**
48
+ - name: Release (semantic-release)
49
+ if: github.ref == 'refs/heads/main' && github.event_name == 'push'
50
+ env:
51
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
52
+ NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
53
+ run: npx semantic-release
@@ -0,0 +1,51 @@
1
+ name: Community Contribution Checks
2
+
3
+ on:
4
+ pull_request:
5
+ types: [opened, synchronize, reopened]
6
+
7
+ jobs:
8
+ lint:
9
+ runs-on: ubuntu-latest
10
+ steps:
11
+ - uses: actions/checkout@v4
12
+ - name: Set up Node.js
13
+ uses: actions/setup-node@v4
14
+ with:
15
+ node-version: '18.x'
16
+ - name: Install dependencies
17
+ run: npm ci
18
+ - name: Lint
19
+ run: npx eslint .
20
+
21
+ test:
22
+ runs-on: ubuntu-latest
23
+ steps:
24
+ - uses: actions/checkout@v4
25
+ - name: Set up Node.js
26
+ uses: actions/setup-node@v4
27
+ with:
28
+ node-version: '18.x'
29
+ - name: Install dependencies
30
+ run: npm ci
31
+ - name: Run tests
32
+ run: npm test || echo "No tests yet"
33
+
34
+ pr-title:
35
+ if: github.event.pull_request.head.repo.full_name == github.repository
36
+ runs-on: ubuntu-latest
37
+ steps:
38
+ - uses: amannn/action-semantic-pull-request@v5
39
+ with:
40
+ types: |
41
+ feat
42
+ fix
43
+ chore
44
+ docs
45
+ refactor
46
+ style
47
+ test
48
+ ci
49
+ githubBaseUrl: https://api.github.com
50
+ env:
51
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -0,0 +1,19 @@
1
+ name: Dependabot Auto Merge
2
+
3
+ on:
4
+ pull_request:
5
+ types:
6
+ - opened
7
+ - synchronize
8
+ - reopened
9
+
10
+ jobs:
11
+ auto-merge:
12
+ if: github.actor == 'dependabot[bot]'
13
+ runs-on: ubuntu-latest
14
+ steps:
15
+ - name: Enable auto-merge for Dependabot PRs
16
+ uses: peter-evans/enable-pull-request-automerge@v3
17
+ with:
18
+ token: ${{ secrets.GITHUB_TOKEN }}
19
+ merge-method: squash
@@ -0,0 +1,13 @@
1
+ name: Pull Request Labeler
2
+
3
+ on:
4
+ pull_request:
5
+ types: [opened, synchronize, reopened]
6
+
7
+ jobs:
8
+ label:
9
+ runs-on: ubuntu-latest
10
+ steps:
11
+ - uses: actions/labeler@v5
12
+ with:
13
+ repo-token: ${{ secrets.GITHUB_TOKEN }}
@@ -0,0 +1,17 @@
1
+ name: Mark stale issues and pull requests
2
+
3
+ on:
4
+ schedule:
5
+ - cron: '0 0 * * *'
6
+
7
+ jobs:
8
+ stale:
9
+ runs-on: ubuntu-latest
10
+ steps:
11
+ - uses: actions/stale@v9
12
+ with:
13
+ repo-token: ${{ secrets.GITHUB_TOKEN }}
14
+ stale-issue-message: 'This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.'
15
+ stale-pr-message: 'This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.'
16
+ days-before-stale: 30
17
+ days-before-close: 7
package/.releaserc ADDED
@@ -0,0 +1,12 @@
1
+ {
2
+ "types": [
3
+ {"type": "feat", "section": "Features"},
4
+ {"type": "fix", "section": "Bug Fixes"},
5
+ {"type": "chore", "section": "Chores"},
6
+ {"type": "docs", "section": "Documentation"},
7
+ {"type": "refactor", "section": "Refactoring"},
8
+ {"type": "style", "section": "Style"},
9
+ {"type": "test", "section": "Tests"},
10
+ {"type": "ci", "section": "CI"}
11
+ ]
12
+ }
package/CHANGELOG.md ADDED
@@ -0,0 +1,56 @@
1
+ # Changelog
2
+
3
+ ## [1.1.1](https://github.com/rahul05ranjan/dhruv-cli/compare/v1.1.0...v1.1.1) (2025-06-29)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * **init:** add type declaration for dynamically imported node-fetch ([4014dc4](https://github.com/rahul05ranjan/dhruv-cli/commit/4014dc4e8f3e4779296a2d97c7526cabb1cc05ec))
9
+
10
+ ## [1.1.0](https://github.com/rahul05ranjan/dhruv-cli/compare/v1.0.0...v1.1.0) (2025-06-29)
11
+
12
+
13
+ ### Features
14
+
15
+ * Add ESLint configuration for TypeScript and Node.js in devai-cli ([ebc0879](https://github.com/rahul05ranjan/dhruv-cli/commit/ebc0879d3359462773d39e5effa7d21618367bab))
16
+ * **api:** update model fetching to use REST API and improve error handling ([de3f86f](https://github.com/rahul05ranjan/dhruv-cli/commit/de3f86f3bf01e44cc0aa6579bf27cf39d56ebc75))
17
+ * Enhance README and index.html with updated documentation, improved layout, and new features ([2075819](https://github.com/rahul05ranjan/dhruv-cli/commit/2075819ac732a72620d5eb560b3e88a5583cd37c))
18
+ * Initialize Dhruv CLI project with core commands and configuration ([aacab76](https://github.com/rahul05ranjan/dhruv-cli/commit/aacab76cdc0369f0c3c0f8b40573cc7bd89e5206))
19
+ * Initialize Dhruv CLI project with core functionality and AI integration ([6f5987b](https://github.com/rahul05ranjan/dhruv-cli/commit/6f5987b296799c51b2c99488148dae2663f7fa0d))
20
+ * **types:** add node-fetch type declaration and update tsconfig to include it ([d3c12dd](https://github.com/rahul05ranjan/dhruv-cli/commit/d3c12dd6ddbcde3ca6dd7fad04601c00205d0a46))
21
+ * Update devDependencies for ESLint and TypeScript in package.json and package-lock.json ([a01255d](https://github.com/rahul05ranjan/dhruv-cli/commit/a01255d1540ba0f16e4548a57cae78ea26a9d4fb))
22
+ * Update package-lock.json to use scoped package name for dhruv-cli ([4e0e47e](https://github.com/rahul05ranjan/dhruv-cli/commit/4e0e47e166af30fdf62c43935325900489f7ac63))
23
+ * Update package.json with scoped name and repository details; enhance release workflow ([f380f07](https://github.com/rahul05ranjan/dhruv-cli/commit/f380f079393926baff0d4421edf1494f68501320))
24
+
25
+
26
+ ### Bug Fixes
27
+
28
+ * **ci:** remove redundant entries in labeler configuration ([de3f86f](https://github.com/rahul05ranjan/dhruv-cli/commit/de3f86f3bf01e44cc0aa6579bf27cf39d56ebc75))
29
+ * correct bin path and update repository URL format in package.json ([20952d8](https://github.com/rahul05ranjan/dhruv-cli/commit/20952d83edce54cb5d5e499938a5f9e257bbcbdc))
30
+ * **init:** dynamically import node-fetch for compatibility ([62b568a](https://github.com/rahul05ranjan/dhruv-cli/commit/62b568abeeb6d3e24eb1694e5bda1b588442c632))
31
+ * **release:** ensure RELEASE_PLEASE_TOKEN is set for release action ([78978e4](https://github.com/rahul05ranjan/dhruv-cli/commit/78978e4a7d55dc4c69d90642f54a28632da4b5ba))
32
+ * update installation command to include the correct package scope ([0004a7c](https://github.com/rahul05ranjan/dhruv-cli/commit/0004a7cfa51fb7cc8d36305eeabde89fd73b39fb))
33
+ * update publishConfig registry URL to npm registry ([7cda997](https://github.com/rahul05ranjan/dhruv-cli/commit/7cda9975cc95cac82a6ef7a39d285613ba6a0abf))
34
+ * update version in package.json and package-lock.json; refactor askOllama to await result directly ([e4db280](https://github.com/rahul05ranjan/dhruv-cli/commit/e4db280428878ce9b9c45e8df509f54b1833d37a))
35
+ * update version to 1.0.1 in package.json and add permissions to release workflow ([e4adaee](https://github.com/rahul05ranjan/dhruv-cli/commit/e4adaee8d2bbd3918bde91afc104dd78ce7dea82))
36
+
37
+ ## 1.0.0 (2025-06-29)
38
+
39
+
40
+ ### Features
41
+
42
+ * Add ESLint configuration for TypeScript and Node.js in devai-cli ([ebc0879](https://github.com/rahul05ranjan/dhruv-cli/commit/ebc0879d3359462773d39e5effa7d21618367bab))
43
+ * Enhance README and index.html with updated documentation, improved layout, and new features ([2075819](https://github.com/rahul05ranjan/dhruv-cli/commit/2075819ac732a72620d5eb560b3e88a5583cd37c))
44
+ * Initialize Dhruv CLI project with core commands and configuration ([aacab76](https://github.com/rahul05ranjan/dhruv-cli/commit/aacab76cdc0369f0c3c0f8b40573cc7bd89e5206))
45
+ * Initialize Dhruv CLI project with core functionality and AI integration ([6f5987b](https://github.com/rahul05ranjan/dhruv-cli/commit/6f5987b296799c51b2c99488148dae2663f7fa0d))
46
+ * Update devDependencies for ESLint and TypeScript in package.json and package-lock.json ([a01255d](https://github.com/rahul05ranjan/dhruv-cli/commit/a01255d1540ba0f16e4548a57cae78ea26a9d4fb))
47
+ * Update package-lock.json to use scoped package name for dhruv-cli ([4e0e47e](https://github.com/rahul05ranjan/dhruv-cli/commit/4e0e47e166af30fdf62c43935325900489f7ac63))
48
+ * Update package.json with scoped name and repository details; enhance release workflow ([f380f07](https://github.com/rahul05ranjan/dhruv-cli/commit/f380f079393926baff0d4421edf1494f68501320))
49
+
50
+
51
+ ### Bug Fixes
52
+
53
+ * correct bin path and update repository URL format in package.json ([20952d8](https://github.com/rahul05ranjan/dhruv-cli/commit/20952d83edce54cb5d5e499938a5f9e257bbcbdc))
54
+ * update installation command to include the correct package scope ([0004a7c](https://github.com/rahul05ranjan/dhruv-cli/commit/0004a7cfa51fb7cc8d36305eeabde89fd73b39fb))
55
+ * update publishConfig registry URL to npm registry ([7cda997](https://github.com/rahul05ranjan/dhruv-cli/commit/7cda9975cc95cac82a6ef7a39d285613ba6a0abf))
56
+ * update version to 1.0.1 in package.json and add permissions to release workflow ([e4adaee](https://github.com/rahul05ranjan/dhruv-cli/commit/e4adaee8d2bbd3918bde91afc104dd78ce7dea82))
@@ -0,0 +1,19 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ ## Our Standards
8
+
9
+ - Be respectful and considerate.
10
+ - No harassment, trolling, or discrimination.
11
+ - Accept constructive criticism gracefully.
12
+
13
+ ## Enforcement
14
+
15
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the maintainers.
16
+
17
+ ## Attribution
18
+
19
+ This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org/).
@@ -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.
package/README.md ADDED
@@ -0,0 +1,61 @@
1
+ # Dhruv CLI
2
+
3
+ [📦 View on npm](https://www.npmjs.com/package/@rahul05ranjan/dhruv-cli)
4
+ [📖 View Documentation on GitHub Pages](https://rahul05ranjan.github.io/dhruv-cli/)
5
+
6
+ AI-powered CLI assistant for developers using Ollama.
7
+
8
+ ## 🚀 Features
9
+ - Smart command suggestions: `suggest`, `explain`, `fix`
10
+ - Project context detection (Node, React, Python, etc.)
11
+ - Code review: `review <fileOrDir>`
12
+ - Code optimization: `optimize <file>`
13
+ - Security analysis: `security-check [fileOrDir]`
14
+ - Test/code generation: `generate <type> <target>`
15
+ - Interactive setup: `init`
16
+ - Streaming AI responses in terminal
17
+ - Syntax highlighting for code output
18
+ - Progress bars for long operations
19
+ - Plugin system: drop ESM modules in `plugins/`
20
+ - Autocomplete: `completion [shell]`
21
+ - Offline-first with local Ollama models
22
+ - Beautiful, modern CLI UX
23
+
24
+ ## 🛠️ Installation
25
+ ```bash
26
+ npm install -g @rahul05ranjan/dhruv-cli
27
+ ```
28
+
29
+ Or visit the npm page: https://www.npmjs.com/package/@rahul05ranjan/dhruv-cli
30
+
31
+ ## 📝 Usage Examples
32
+ ```bash
33
+ dhruv suggest "deploy react app to vercel"
34
+ dhruv explain "git rebase vs merge"
35
+ dhruv fix "cors error in express"
36
+ dhruv review src/
37
+ dhruv optimize package.json
38
+ dhruv security-check src/
39
+ dhruv generate tests src/utils/helpers.js
40
+ dhruv init
41
+ dhruv completion bash > dhruv-complete.sh # Enable tab completion
42
+ ```
43
+
44
+ ## 🧩 Plugins
45
+ Add new commands by dropping ESM modules in the `plugins/` directory. Example:
46
+ ```js
47
+ // plugins/hello.js
48
+ export default (program) => {
49
+ program.command('hello-plugin').action(() => console.log('Hello from plugin!'));
50
+ };
51
+ ```
52
+
53
+ ## 📦 Configuration
54
+ - Run `dhruv init` to set model, response format, and verbosity.
55
+ - Project type auto-detected for context-aware suggestions.
56
+
57
+ ## 🖥️ Advanced UX
58
+ - Streaming output, syntax highlighting, progress bars, colored errors, and interactive menus.
59
+
60
+ ## License
61
+ MIT
package/SECURITY.md ADDED
@@ -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.
@@ -0,0 +1 @@
1
+ export declare function explain(query: string): Promise<void>;
@@ -0,0 +1,46 @@
1
+ import { askOllama } from '../core/ai.js';
2
+ import ora from 'ora';
3
+ import chalk from 'chalk';
4
+ import { loadConfig } from '../config/config.js';
5
+ import { highlightCode, printError } from '../utils/ux.js';
6
+ export async function explain(query) {
7
+ const config = loadConfig();
8
+ const spinner = ora('Thinking...').start();
9
+ let streamed = '';
10
+ const dhruvIntro = chalk.yellowBright('Dhruv CLI: Your AI-powered CLI assistant for developers using Ollama.\n');
11
+ try {
12
+ spinner.stop();
13
+ process.stdout.write(dhruvIntro); // Print Dhruv intro before explanation
14
+ process.stdout.write(chalk.green('Explanation: '));
15
+ await askOllama({
16
+ prompt: `Explain: ${query}`,
17
+ model: config.model,
18
+ onToken: (token) => {
19
+ streamed += token;
20
+ process.stdout.write(chalk.cyan(token));
21
+ }
22
+ });
23
+ process.stdout.write('\n');
24
+ if (typeof highlightCode === 'function' && streamed.match(/```[a-z]*[\s\S]*?```/)) {
25
+ const codeBlocks = streamed.match(/```([a-z]*)\n([\s\S]*?)```/g) || [];
26
+ for (const block of codeBlocks) {
27
+ const [, lang, code] = block.match(/```([a-z]*)\n([\s\S]*?)```/) || [];
28
+ if (code) {
29
+ try {
30
+ console.log(highlightCode(code, lang || 'js'));
31
+ }
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
+ }
42
+ catch (err) {
43
+ printError('Failed to get explanation.');
44
+ console.error(chalk.red(err.message));
45
+ }
46
+ }
@@ -0,0 +1 @@
1
+ export declare function fix(query: string): Promise<void>;
@@ -0,0 +1,40 @@
1
+ import { askOllama } from '../core/ai.js';
2
+ import ora from 'ora';
3
+ import chalk from 'chalk';
4
+ import { loadConfig } from '../config/config.js';
5
+ import { highlightCode, printError } from '../utils/ux.js';
6
+ export async function fix(query) {
7
+ const config = loadConfig();
8
+ const spinner = ora('Analyzing issue...').start();
9
+ let streamed = '';
10
+ try {
11
+ spinner.stop();
12
+ process.stdout.write(chalk.green('Fix suggestion: '));
13
+ await askOllama({
14
+ prompt: `Fix: ${query}`,
15
+ model: config.model,
16
+ onToken: (token) => {
17
+ streamed += token;
18
+ process.stdout.write(chalk.cyan(token));
19
+ }
20
+ });
21
+ process.stdout.write('\n');
22
+ if (typeof highlightCode === 'function' && streamed.match(/```[a-z]*[\s\S]*?```/)) {
23
+ const codeBlocks = streamed.match(/```([a-z]*)\n([\s\S]*?)```/g) || [];
24
+ for (const block of codeBlocks) {
25
+ const [, lang, code] = block.match(/```([a-z]*)\n([\s\S]*?)```/) || [];
26
+ if (code)
27
+ try {
28
+ console.log(highlightCode(code, lang || 'js'));
29
+ }
30
+ catch (err) {
31
+ console.error('Highlight error:', err);
32
+ }
33
+ }
34
+ }
35
+ }
36
+ catch (err) {
37
+ printError('Failed to get fix suggestion.');
38
+ console.error(chalk.red(err.message));
39
+ }
40
+ }
@@ -0,0 +1 @@
1
+ export declare function generate(type: string, target: string): Promise<void>;