jvcs 1.5.6 → 1.5.8

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.
@@ -0,0 +1,32 @@
1
+ async function aiAnalyzer({ filePath="", leftContent="", rightContent="", mode=""}) {
2
+
3
+ const { ChatOllama } = await import("@langchain/ollama");
4
+
5
+ const llm = new ChatOllama({
6
+ model: "gpt-oss:120b-cloud",
7
+ baseUrl: "https://ollama.com",
8
+ apiKey: "31dbc890aff540ac8fe835a4bdf7853b.Y7yR3jLgZ5CQu5WlqQOanCp0",
9
+ temperature: 0,
10
+ });
11
+
12
+ const prompt = `
13
+ You are a code reviewer. Analyze the changes in the file "${filePath}".
14
+ Diff mode: ${mode}
15
+
16
+ OLD CONTENT:
17
+ ${leftContent || "<empty>"}
18
+
19
+ NEW CONTENT:
20
+ ${rightContent || "<empty>"}
21
+
22
+ Provide:
23
+ - Summary of changes
24
+ - Suggestions or improvements
25
+ - Risks or bugs introduced
26
+ `;
27
+
28
+ const response = await llm.invoke(prompt);
29
+ return response.content
30
+ }
31
+
32
+ module.exports = aiAnalyzer
@@ -1,4 +1,11 @@
1
1
  const blessed = require("blessed")
2
+ const aiAnalyzer = require("./aiAnalyzer")
3
+ const marked = require("marked");
4
+ const TerminalRenderer = require("marked-terminal");
5
+
6
+ marked.setOptions({
7
+ renderer: new TerminalRenderer()
8
+ });
2
9
 
3
10
  function startUI(state) {
4
11
  const screen = blessed.screen({
@@ -120,29 +127,36 @@ function startUI(state) {
120
127
  }).join("\n")
121
128
  }
122
129
 
123
- function renderFileView() {
130
+ async function renderFileView() {
124
131
  const file = state.getCurrentFile()
125
132
  if (!file) return
126
133
 
127
134
  leftBox.setContent(colorDiffContent(file.leftContent, "removed"))
128
135
  rightBox.setContent(colorDiffContent(file.rightContent, "added"))
129
136
 
130
- aiBox.setContent(`
131
- {bold}Summary:{/bold}
132
- Status: ${file.status.toUpperCase()}
133
-
134
- {green-fg}Lines Added: ${file.stats.added}{/green-fg}
135
- {red-fg}Lines Removed: ${file.stats.removed}{/red-fg}
136
-
137
- (Real AI analysis will appear here later)
138
- `)
139
-
137
+ aiBox.setContent("AI Analysis: Loading...");
140
138
  screen.append(leftBox)
141
139
  screen.append(rightBox)
142
140
  screen.append(aiBox)
143
-
144
- updateActiveTabHighlight()
145
- screen.render()
141
+ updateActiveTabHighlight();
142
+ screen.render();
143
+
144
+ try {
145
+ const aiSummary = await aiAnalyzer({
146
+ filePath: file.path,
147
+ leftContent: file.leftContent,
148
+ rightContent: file.rightContent,
149
+ mode: state.mode
150
+ })
151
+
152
+ const parsed = marked(aiSummary); // Markdown → terminal-friendly text
153
+ aiBox.setContent(parsed);
154
+ screen.render()
155
+ }
156
+ catch(error) {
157
+ aiBox.setContent(`AI Analysis failed: ${error.message || error}`);
158
+ screen.render()
159
+ }
146
160
  }
147
161
 
148
162
  function destroyFileView() {
@@ -184,10 +198,10 @@ Status: ${file.status.toUpperCase()}
184
198
  })
185
199
 
186
200
  // Enter → Open file view
187
- fileList.key(["enter"], () => {
201
+ fileList.key(["enter"], async () => {
188
202
  state.goToFileView()
189
203
  fileList.detach()
190
- renderFileView()
204
+ await renderFileView()
191
205
  })
192
206
 
193
207
  // ESC → Back to list
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jvcs",
3
- "version": "1.5.6",
3
+ "version": "1.5.8",
4
4
  "bin": {
5
5
  "jvcs": "index.js"
6
6
  },
@@ -8,6 +8,8 @@
8
8
  "author": "",
9
9
  "license": "ISC",
10
10
  "dependencies": {
11
+ "@langchain/core": "^1.1.29",
12
+ "@langchain/ollama": "^1.2.5",
11
13
  "blessed": "^0.1.81",
12
14
  "chalk": "^4.1.2",
13
15
  "dotenv": "^17.2.3",
@@ -18,4 +20,4 @@
18
20
  "validator": "^13.15.20",
19
21
  "yargs": "^18.0.0"
20
22
  }
21
- }
23
+ }