@rahul05ranjan/dhruv-cli 1.0.1 → 1.1.1

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/.eslintignore ADDED
@@ -0,0 +1 @@
1
+ node-fetch.d.ts
@@ -1,11 +1,11 @@
1
1
  # Automatically label PRs based on file paths or globs
2
- 'cli':
2
+ cli:
3
3
  - 'src/**'
4
4
  - 'bin/**'
5
- 'docs':
5
+ docs:
6
6
  - 'docs/**'
7
7
  - '**/*.md'
8
- 'ci':
8
+ ci:
9
9
  - '.github/workflows/**'
10
10
  - '.github/ISSUE_TEMPLATE/**'
11
11
  - '.github/PULL_REQUEST_TEMPLATE.md'
@@ -14,13 +14,8 @@
14
14
  - '.github/contribution.yml'
15
15
  - '.github/stale.yml'
16
16
  - '.github/release-please.yml'
17
- - '.github/labeler.yml'
18
- - '.github/auto_assign.yml'
19
- - '.github/contribution.yml'
20
- - '.github/stale.yml'
21
- - '.github/release-please.yml'
22
- 'tests':
17
+ tests:
23
18
  - 'tests/**'
24
19
  - '**/*.test.*'
25
- 'plugins':
20
+ plugins:
26
21
  - 'plugins/**'
@@ -32,6 +32,7 @@ jobs:
32
32
  run: npm test || echo "No tests yet"
33
33
 
34
34
  pr-title:
35
+ if: github.event.pull_request.head.repo.full_name == github.repository
35
36
  runs-on: ubuntu-latest
36
37
  steps:
37
38
  - uses: amannn/action-semantic-pull-request@v5
package/CHANGELOG.md ADDED
@@ -0,0 +1,49 @@
1
+ # Changelog
2
+
3
+ ## [1.1.0](https://github.com/rahul05ranjan/dhruv-cli/compare/v1.0.0...v1.1.0) (2025-06-29)
4
+
5
+
6
+ ### Features
7
+
8
+ * Add ESLint configuration for TypeScript and Node.js in devai-cli ([ebc0879](https://github.com/rahul05ranjan/dhruv-cli/commit/ebc0879d3359462773d39e5effa7d21618367bab))
9
+ * **api:** update model fetching to use REST API and improve error handling ([de3f86f](https://github.com/rahul05ranjan/dhruv-cli/commit/de3f86f3bf01e44cc0aa6579bf27cf39d56ebc75))
10
+ * Enhance README and index.html with updated documentation, improved layout, and new features ([2075819](https://github.com/rahul05ranjan/dhruv-cli/commit/2075819ac732a72620d5eb560b3e88a5583cd37c))
11
+ * Initialize Dhruv CLI project with core commands and configuration ([aacab76](https://github.com/rahul05ranjan/dhruv-cli/commit/aacab76cdc0369f0c3c0f8b40573cc7bd89e5206))
12
+ * Initialize Dhruv CLI project with core functionality and AI integration ([6f5987b](https://github.com/rahul05ranjan/dhruv-cli/commit/6f5987b296799c51b2c99488148dae2663f7fa0d))
13
+ * **types:** add node-fetch type declaration and update tsconfig to include it ([d3c12dd](https://github.com/rahul05ranjan/dhruv-cli/commit/d3c12dd6ddbcde3ca6dd7fad04601c00205d0a46))
14
+ * Update devDependencies for ESLint and TypeScript in package.json and package-lock.json ([a01255d](https://github.com/rahul05ranjan/dhruv-cli/commit/a01255d1540ba0f16e4548a57cae78ea26a9d4fb))
15
+ * Update package-lock.json to use scoped package name for dhruv-cli ([4e0e47e](https://github.com/rahul05ranjan/dhruv-cli/commit/4e0e47e166af30fdf62c43935325900489f7ac63))
16
+ * Update package.json with scoped name and repository details; enhance release workflow ([f380f07](https://github.com/rahul05ranjan/dhruv-cli/commit/f380f079393926baff0d4421edf1494f68501320))
17
+
18
+
19
+ ### Bug Fixes
20
+
21
+ * **ci:** remove redundant entries in labeler configuration ([de3f86f](https://github.com/rahul05ranjan/dhruv-cli/commit/de3f86f3bf01e44cc0aa6579bf27cf39d56ebc75))
22
+ * correct bin path and update repository URL format in package.json ([20952d8](https://github.com/rahul05ranjan/dhruv-cli/commit/20952d83edce54cb5d5e499938a5f9e257bbcbdc))
23
+ * **init:** dynamically import node-fetch for compatibility ([62b568a](https://github.com/rahul05ranjan/dhruv-cli/commit/62b568abeeb6d3e24eb1694e5bda1b588442c632))
24
+ * **release:** ensure RELEASE_PLEASE_TOKEN is set for release action ([78978e4](https://github.com/rahul05ranjan/dhruv-cli/commit/78978e4a7d55dc4c69d90642f54a28632da4b5ba))
25
+ * update installation command to include the correct package scope ([0004a7c](https://github.com/rahul05ranjan/dhruv-cli/commit/0004a7cfa51fb7cc8d36305eeabde89fd73b39fb))
26
+ * update publishConfig registry URL to npm registry ([7cda997](https://github.com/rahul05ranjan/dhruv-cli/commit/7cda9975cc95cac82a6ef7a39d285613ba6a0abf))
27
+ * update version in package.json and package-lock.json; refactor askOllama to await result directly ([e4db280](https://github.com/rahul05ranjan/dhruv-cli/commit/e4db280428878ce9b9c45e8df509f54b1833d37a))
28
+ * update version to 1.0.1 in package.json and add permissions to release workflow ([e4adaee](https://github.com/rahul05ranjan/dhruv-cli/commit/e4adaee8d2bbd3918bde91afc104dd78ce7dea82))
29
+
30
+ ## 1.0.0 (2025-06-29)
31
+
32
+
33
+ ### Features
34
+
35
+ * Add ESLint configuration for TypeScript and Node.js in devai-cli ([ebc0879](https://github.com/rahul05ranjan/dhruv-cli/commit/ebc0879d3359462773d39e5effa7d21618367bab))
36
+ * Enhance README and index.html with updated documentation, improved layout, and new features ([2075819](https://github.com/rahul05ranjan/dhruv-cli/commit/2075819ac732a72620d5eb560b3e88a5583cd37c))
37
+ * Initialize Dhruv CLI project with core commands and configuration ([aacab76](https://github.com/rahul05ranjan/dhruv-cli/commit/aacab76cdc0369f0c3c0f8b40573cc7bd89e5206))
38
+ * Initialize Dhruv CLI project with core functionality and AI integration ([6f5987b](https://github.com/rahul05ranjan/dhruv-cli/commit/6f5987b296799c51b2c99488148dae2663f7fa0d))
39
+ * Update devDependencies for ESLint and TypeScript in package.json and package-lock.json ([a01255d](https://github.com/rahul05ranjan/dhruv-cli/commit/a01255d1540ba0f16e4548a57cae78ea26a9d4fb))
40
+ * Update package-lock.json to use scoped package name for dhruv-cli ([4e0e47e](https://github.com/rahul05ranjan/dhruv-cli/commit/4e0e47e166af30fdf62c43935325900489f7ac63))
41
+ * Update package.json with scoped name and repository details; enhance release workflow ([f380f07](https://github.com/rahul05ranjan/dhruv-cli/commit/f380f079393926baff0d4421edf1494f68501320))
42
+
43
+
44
+ ### Bug Fixes
45
+
46
+ * correct bin path and update repository URL format in package.json ([20952d8](https://github.com/rahul05ranjan/dhruv-cli/commit/20952d83edce54cb5d5e499938a5f9e257bbcbdc))
47
+ * update installation command to include the correct package scope ([0004a7c](https://github.com/rahul05ranjan/dhruv-cli/commit/0004a7cfa51fb7cc8d36305eeabde89fd73b39fb))
48
+ * update publishConfig registry URL to npm registry ([7cda997](https://github.com/rahul05ranjan/dhruv-cli/commit/7cda9975cc95cac82a6ef7a39d285613ba6a0abf))
49
+ * update version to 1.0.1 in package.json and add permissions to release workflow ([e4adaee](https://github.com/rahul05ranjan/dhruv-cli/commit/e4adaee8d2bbd3918bde91afc104dd78ce7dea82))
@@ -1,15 +1,20 @@
1
1
  import inquirer from 'inquirer';
2
2
  import { saveConfig, loadConfig } from '../config/config.js';
3
3
  import chalk from 'chalk';
4
- import { Ollama } from 'ollama';
5
4
  export async function init() {
6
5
  const current = loadConfig();
7
6
  let modelChoices = [current.model];
8
7
  try {
9
- const ollama = new Ollama();
10
- const tags = await ollama.tags();
11
- if (Array.isArray(tags) && tags.length > 0) {
12
- modelChoices = tags.map(t => t.name);
8
+ // Dynamically import node-fetch for compatibility
9
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
+ const fetch = (await import('node-fetch')).default;
11
+ // Fetch models from Ollama REST API
12
+ const res = await fetch('http://localhost:11434/api/tags');
13
+ if (res.ok) {
14
+ const data = (await res.json());
15
+ if (Array.isArray(data.models) && data.models.length > 0) {
16
+ modelChoices = data.models.map((m) => m.name);
17
+ }
13
18
  }
14
19
  }
15
20
  catch {
package/dist/core/ai.js CHANGED
@@ -20,18 +20,18 @@ export async function askOllama({ prompt, model, onToken }) {
20
20
  try {
21
21
  let result = '';
22
22
  const ollama = new Ollama();
23
- for await (const chunk of ollama.generate(model || 'codellama', prompt)) {
24
- let token = '';
25
- if (typeof chunk === 'object' && chunk !== null && 'response' in chunk) {
26
- token = chunk.response;
27
- }
28
- else if (typeof chunk === 'string') {
29
- token = chunk;
30
- }
31
- if (onToken)
32
- onToken(token);
33
- result += token;
23
+ // Await the result directly (no streaming)
24
+ const chunk = await ollama.generate({ model: model || 'codellama', prompt });
25
+ let token = '';
26
+ if (typeof chunk === 'object' && chunk !== null && 'response' in chunk) {
27
+ token = chunk.response;
34
28
  }
29
+ else if (typeof chunk === 'string') {
30
+ token = chunk;
31
+ }
32
+ if (onToken)
33
+ onToken(token);
34
+ result += token;
35
35
  fs.writeFileSync(cacheKey, result.trim());
36
36
  return result.trim();
37
37
  }
@@ -0,0 +1,4 @@
1
+ declare module 'node-fetch' {
2
+ const fetch: typeof import('node-fetch');
3
+ export default fetch;
4
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rahul05ranjan/dhruv-cli",
3
- "version": "1.0.1",
3
+ "version": "1.1.1",
4
4
  "description": "AI-powered CLI assistant for developers using Ollama",
5
5
  "keywords": [
6
6
  "ai",
@@ -27,10 +27,11 @@
27
27
  "chalk": "^5.3.0",
28
28
  "cli-highlight": "^2.1.11",
29
29
  "cli-progress": "^3.12.0",
30
- "commander": "^11.0.0",
31
- "inquirer": "^9.2.0",
32
- "ollama": "^0.1.0",
33
- "ora": "^7.0.1"
30
+ "commander": "^14.0.0",
31
+ "inquirer": "^12.6.3",
32
+ "node-fetch": "^2.7.0",
33
+ "ollama": "^0.5.16",
34
+ "ora": "^8.2.0"
34
35
  },
35
36
  "devDependencies": {
36
37
  "@eslint/js": "^8.57.1",
@@ -1,16 +1,21 @@
1
1
  import inquirer from 'inquirer';
2
2
  import { saveConfig, loadConfig } from '../config/config.js';
3
3
  import chalk from 'chalk';
4
- import { Ollama } from 'ollama';
5
4
 
6
5
  export async function init() {
7
6
  const current = loadConfig();
8
7
  let modelChoices = [current.model];
9
8
  try {
10
- const ollama = new Ollama();
11
- const tags = await ollama.tags();
12
- if (Array.isArray(tags) && tags.length > 0) {
13
- modelChoices = tags.map(t => t.name);
9
+ // Dynamically import node-fetch for compatibility
10
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
11
+ const fetch: any = (await import('node-fetch')).default;
12
+ // Fetch models from Ollama REST API
13
+ const res = await fetch('http://localhost:11434/api/tags');
14
+ if (res.ok) {
15
+ const data = (await res.json()) as { models?: { name: string }[] };
16
+ if (Array.isArray(data.models) && data.models.length > 0) {
17
+ modelChoices = data.models.map((m) => m.name);
18
+ }
14
19
  }
15
20
  } catch {
16
21
  // If Ollama is not running or fails, fallback to current model
package/src/core/ai.ts CHANGED
@@ -21,16 +21,16 @@ export async function askOllama({ prompt, model, onToken }: { prompt: string; mo
21
21
  try {
22
22
  let result = '';
23
23
  const ollama = new Ollama();
24
- for await (const chunk of ollama.generate(model || 'codellama', prompt)) {
25
- let token = '';
26
- if (typeof chunk === 'object' && chunk !== null && 'response' in chunk) {
27
- token = (chunk as unknown as { response: string }).response;
28
- } else if (typeof chunk === 'string') {
29
- token = chunk;
30
- }
31
- if (onToken) onToken(token);
32
- result += token;
24
+ // Await the result directly (no streaming)
25
+ const chunk = await ollama.generate({ model: model || 'codellama', prompt });
26
+ let token = '';
27
+ if (typeof chunk === 'object' && chunk !== null && 'response' in chunk) {
28
+ token = (chunk as { response: string }).response;
29
+ } else if (typeof chunk === 'string') {
30
+ token = chunk;
33
31
  }
32
+ if (onToken) onToken(token);
33
+ result += token;
34
34
  fs.writeFileSync(cacheKey, result.trim());
35
35
  return result.trim();
36
36
  } catch (err) {
package/tsconfig.json CHANGED
@@ -12,6 +12,6 @@
12
12
  "resolveJsonModule": true,
13
13
  "declaration": true
14
14
  },
15
- "include": ["src/**/*"],
15
+ "include": ["src/**/*", "node-fetch.d.ts"],
16
16
  "exclude": ["node_modules", "dist"]
17
17
  }
@@ -1,33 +0,0 @@
1
- name: Release Please
2
-
3
- on:
4
- push:
5
- branches:
6
- - main
7
-
8
- permissions:
9
- contents: write
10
- pull-requests: write
11
-
12
- jobs:
13
- release-please:
14
- runs-on: ubuntu-latest
15
- steps:
16
- - uses: google-github-actions/release-please-action@v4
17
- with:
18
- release-type: node
19
- - name: Checkout
20
- uses: actions/checkout@v4
21
- - name: Set up Node.js
22
- uses: actions/setup-node@v4
23
- with:
24
- node-version: '18.x'
25
- registry-url: 'https://npm.pkg.github.com/'
26
- - name: Install dependencies
27
- run: npm ci
28
- - name: Build
29
- run: npm run build
30
- - name: Publish to GitHub Packages
31
- run: npm publish
32
- env:
33
- NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}