@rahul05ranjan/dhruv-cli 1.0.1 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintignore +1 -0
- package/.github/labeler.yml +5 -10
- package/.github/workflows/contribution.yml +1 -0
- package/.github/workflows/release-please.yml +1 -0
- package/CHANGELOG.md +49 -0
- package/dist/commands/init.js +10 -5
- package/dist/core/ai.js +11 -11
- package/node-fetch.d.ts +4 -0
- package/package.json +6 -5
- package/src/commands/init.ts +10 -5
- package/src/core/ai.ts +9 -9
- package/tsconfig.json +1 -1
package/.eslintignore
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
node-fetch.d.ts
|
package/.github/labeler.yml
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# Automatically label PRs based on file paths or globs
|
|
2
|
-
|
|
2
|
+
cli:
|
|
3
3
|
- 'src/**'
|
|
4
4
|
- 'bin/**'
|
|
5
|
-
|
|
5
|
+
docs:
|
|
6
6
|
- 'docs/**'
|
|
7
7
|
- '**/*.md'
|
|
8
|
-
|
|
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
|
-
|
|
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
|
-
|
|
20
|
+
plugins:
|
|
26
21
|
- 'plugins/**'
|
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))
|
package/dist/commands/init.js
CHANGED
|
@@ -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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
|
}
|
package/node-fetch.d.ts
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rahul05ranjan/dhruv-cli",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
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": "^
|
|
31
|
-
"inquirer": "^
|
|
32
|
-
"
|
|
33
|
-
"
|
|
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",
|
package/src/commands/init.ts
CHANGED
|
@@ -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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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) {
|