vzcode 2.22.0 → 2.26.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/dist/assets/{buildWorker-Bi6wsfQk.js → buildWorker-DylWm2VX.js} +64 -72
- package/dist/assets/index-CkFweu5-.js +403 -0
- package/dist/assets/{index-fSroLVgi.css → index-Dyt9tpmu.css} +1 -5
- package/dist/assets/{worker-BSzbM0Uo.js → worker-VPLhQVba.js} +230 -230
- package/dist/assets/worker-b9bkZkXK.js +116 -0
- package/dist/assets/{worker-Cm3I3tnR.js → worker-k7HZ3t-V.js} +3 -20
- package/dist/index.html +2 -2
- package/dist/llm-streaming-server/chatOperations.js +19 -0
- package/dist/llm-streaming-server/llmStreaming.js +21 -14
- package/dist/server/aiChatHandler/index.js +6 -3
- package/package.json +23 -22
- package/src/llm-streaming-server/chatOperations.ts +27 -0
- package/src/llm-streaming-server/llmStreaming.ts +27 -14
- package/src/llm-streaming-ui/components/Message.tsx +8 -7
- package/src/llm-streaming-ui/components/MessageList.tsx +5 -0
- package/src/llm-streaming-ui/components/index.tsx +2 -2
- package/src/llm-streaming-ui/components/styles.scss +10 -0
- package/src/server/aiChatHandler/index.ts +9 -1
- package/src/types.ts +1 -0
- package/dist/assets/index-CfDs-dAu.js +0 -476
- package/dist/assets/worker-KiuLM-X4.js +0 -136
- package/dist/server/aiChatHandler/aiEditing.js +0 -58
- package/dist/server/aiChatHandler/chatOperations.js +0 -494
- package/dist/server/aiChatHandler/errorHandling.js +0 -49
- package/dist/server/aiChatHandler/llmStreaming.js +0 -265
- package/dist/server/aiChatHandler/validation.js +0 -19
- package/src/client/VZSidebar/AIChat/ChatInput.tsx +0 -237
- package/src/client/VZSidebar/AIChat/DiffView.scss +0 -173
- package/src/client/VZSidebar/AIChat/DiffView.tsx +0 -236
- package/src/client/VZSidebar/AIChat/FileEditingIndicator.tsx +0 -89
- package/src/client/VZSidebar/AIChat/IndividualFileDiff.tsx +0 -86
- package/src/client/VZSidebar/AIChat/JumpToLatestButton.tsx +0 -64
- package/src/client/VZSidebar/AIChat/Message.tsx +0 -145
- package/src/client/VZSidebar/AIChat/MessageList.tsx +0 -241
- package/src/client/VZSidebar/AIChat/ThinkingScratchpad.tsx +0 -42
- package/src/client/VZSidebar/AIChat/TypingIndicator.tsx +0 -19
- package/src/client/VZSidebar/AIChat/index.tsx +0 -388
- package/src/client/VZSidebar/AIChat/styles.scss +0 -831
- package/src/client/VZSidebar/AIChat/useSpeechRecognition.ts +0 -116
- package/src/server/aiChatHandler/aiEditing.ts +0 -102
- package/src/server/aiChatHandler/chatOperations.ts +0 -655
- package/src/server/aiChatHandler/errorHandling.ts +0 -66
- package/src/server/aiChatHandler/llmStreaming.ts +0 -403
- package/src/server/aiChatHandler/validation.ts +0 -24
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
useState,
|
|
3
|
-
useEffect,
|
|
4
|
-
useCallback,
|
|
5
|
-
Dispatch,
|
|
6
|
-
SetStateAction,
|
|
7
|
-
} from 'react';
|
|
8
|
-
|
|
9
|
-
export interface UseSpeechRecognitionResult {
|
|
10
|
-
isSpeaking: boolean;
|
|
11
|
-
toggleSpeechRecognition: () => void;
|
|
12
|
-
stopSpeaking: () => void;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export const useSpeechRecognition = (
|
|
16
|
-
onTranscriptChange: Dispatch<SetStateAction<string>>,
|
|
17
|
-
): UseSpeechRecognitionResult => {
|
|
18
|
-
const [isSpeaking, setIsSpeaking] =
|
|
19
|
-
useState<boolean>(false);
|
|
20
|
-
const [recognition, setRecognition] =
|
|
21
|
-
// @ts-ignore
|
|
22
|
-
useState<SpeechRecognition | null>(null);
|
|
23
|
-
const [, setFinalTranscript] = useState<string>('');
|
|
24
|
-
|
|
25
|
-
// Speech recognition setup
|
|
26
|
-
useEffect(() => {
|
|
27
|
-
// Check if browser supports SpeechRecognition
|
|
28
|
-
const SpeechRecognition =
|
|
29
|
-
// @ts-ignore
|
|
30
|
-
window.SpeechRecognition ||
|
|
31
|
-
// @ts-ignore
|
|
32
|
-
window.webkitSpeechRecognition;
|
|
33
|
-
|
|
34
|
-
if (SpeechRecognition) {
|
|
35
|
-
const recognitionInstance = new SpeechRecognition();
|
|
36
|
-
recognitionInstance.continuous = true;
|
|
37
|
-
recognitionInstance.interimResults = true;
|
|
38
|
-
|
|
39
|
-
recognitionInstance.onresult = (event) => {
|
|
40
|
-
let finalText = '';
|
|
41
|
-
let interimText = '';
|
|
42
|
-
|
|
43
|
-
// Process all results to separate final and interim text
|
|
44
|
-
for (let i = 0; i < event.results.length; i++) {
|
|
45
|
-
const result = event.results[i];
|
|
46
|
-
if (result.isFinal) {
|
|
47
|
-
finalText += result[0].transcript;
|
|
48
|
-
} else {
|
|
49
|
-
interimText += result[0].transcript;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// Update our final transcript state
|
|
54
|
-
setFinalTranscript(finalText);
|
|
55
|
-
|
|
56
|
-
// Combine final and interim text and update the prompt
|
|
57
|
-
const fullTranscript = finalText + interimText;
|
|
58
|
-
onTranscriptChange(fullTranscript);
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
recognitionInstance.onerror = (event) => {
|
|
62
|
-
console.error(
|
|
63
|
-
'Speech recognition error',
|
|
64
|
-
event.error,
|
|
65
|
-
);
|
|
66
|
-
setIsSpeaking(false);
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
recognitionInstance.onend = () => {
|
|
70
|
-
setIsSpeaking(false);
|
|
71
|
-
// Reset final transcript when recognition ends
|
|
72
|
-
setFinalTranscript('');
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
setRecognition(recognitionInstance);
|
|
76
|
-
|
|
77
|
-
return () => {
|
|
78
|
-
recognitionInstance.abort();
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
}, [onTranscriptChange]);
|
|
82
|
-
|
|
83
|
-
const toggleSpeechRecognition = useCallback(() => {
|
|
84
|
-
if (!recognition) {
|
|
85
|
-
console.error(
|
|
86
|
-
'Speech recognition not supported in this browser',
|
|
87
|
-
);
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
if (isSpeaking) {
|
|
92
|
-
recognition.stop();
|
|
93
|
-
setIsSpeaking(false);
|
|
94
|
-
} else {
|
|
95
|
-
// Reset final transcript when starting new recognition
|
|
96
|
-
setFinalTranscript('');
|
|
97
|
-
recognition.start();
|
|
98
|
-
setIsSpeaking(true);
|
|
99
|
-
}
|
|
100
|
-
}, [isSpeaking, recognition]);
|
|
101
|
-
|
|
102
|
-
const stopSpeaking = useCallback(() => {
|
|
103
|
-
if (recognition && isSpeaking) {
|
|
104
|
-
recognition.stop();
|
|
105
|
-
setIsSpeaking(false);
|
|
106
|
-
// Reset final transcript when manually stopping
|
|
107
|
-
setFinalTranscript('');
|
|
108
|
-
}
|
|
109
|
-
}, [isSpeaking, recognition]);
|
|
110
|
-
|
|
111
|
-
return {
|
|
112
|
-
isSpeaking,
|
|
113
|
-
toggleSpeechRecognition,
|
|
114
|
-
stopSpeaking,
|
|
115
|
-
};
|
|
116
|
-
};
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
assembleFullPrompt,
|
|
3
|
-
prepareFilesForPrompt,
|
|
4
|
-
} from 'editcodewithai';
|
|
5
|
-
import { formatMarkdownFiles } from 'llm-code-format';
|
|
6
|
-
import {
|
|
7
|
-
createFilesSnapshot,
|
|
8
|
-
generateFilesUnifiedDiff,
|
|
9
|
-
} from '../../utils/fileDiff.js';
|
|
10
|
-
|
|
11
|
-
// Dev flag for waiting 1 second before starting the LLM function.
|
|
12
|
-
// Useful for debugging and testing purposes, e.g. checking the typing indicator.
|
|
13
|
-
const delayStart = false;
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Performs AI chat without editing - just generates a response
|
|
17
|
-
*/
|
|
18
|
-
export const performAIChat = async ({
|
|
19
|
-
prompt,
|
|
20
|
-
shareDBDoc,
|
|
21
|
-
llmFunction,
|
|
22
|
-
}) => {
|
|
23
|
-
const { files } = prepareFilesForPrompt(
|
|
24
|
-
shareDBDoc.data.files,
|
|
25
|
-
);
|
|
26
|
-
const filesContext = formatMarkdownFiles(files);
|
|
27
|
-
|
|
28
|
-
// 2. Assemble the final prompt for Q&A mode
|
|
29
|
-
const fullPrompt = assembleFullPrompt({
|
|
30
|
-
filesContext,
|
|
31
|
-
prompt,
|
|
32
|
-
editFormat: 'whole',
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
if (delayStart) {
|
|
36
|
-
await new Promise((resolve) =>
|
|
37
|
-
setTimeout(resolve, 1000),
|
|
38
|
-
);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// Call the LLM function which will handle streaming but won't edit files
|
|
42
|
-
const result = await llmFunction(fullPrompt);
|
|
43
|
-
|
|
44
|
-
return {
|
|
45
|
-
content: result.content,
|
|
46
|
-
generationId: result.generationId,
|
|
47
|
-
diffData: {}, // No file changes in ask mode
|
|
48
|
-
};
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Performs AI editing operations using streaming with incremental OT operations
|
|
53
|
-
*/
|
|
54
|
-
export const performAIEditing = async ({
|
|
55
|
-
prompt,
|
|
56
|
-
shareDBDoc,
|
|
57
|
-
llmFunction,
|
|
58
|
-
runCode,
|
|
59
|
-
}) => {
|
|
60
|
-
// Capture the current state of files before editing
|
|
61
|
-
const beforeFiles = createFilesSnapshot(
|
|
62
|
-
shareDBDoc.data.files,
|
|
63
|
-
);
|
|
64
|
-
|
|
65
|
-
const { files } = prepareFilesForPrompt(
|
|
66
|
-
shareDBDoc.data.files,
|
|
67
|
-
);
|
|
68
|
-
const filesContext = formatMarkdownFiles(files);
|
|
69
|
-
|
|
70
|
-
// Assemble the final prompt
|
|
71
|
-
const fullPrompt = assembleFullPrompt({
|
|
72
|
-
filesContext,
|
|
73
|
-
prompt,
|
|
74
|
-
editFormat: 'whole',
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
if (delayStart) {
|
|
78
|
-
await new Promise((resolve) =>
|
|
79
|
-
setTimeout(resolve, 1000),
|
|
80
|
-
);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// Call the LLM function which will handle streaming, incremental file updates, and Prettier formatting
|
|
84
|
-
const result = await llmFunction(fullPrompt);
|
|
85
|
-
|
|
86
|
-
runCode();
|
|
87
|
-
|
|
88
|
-
// 4. Capture the state of files after editing and formatting, then generate diff
|
|
89
|
-
const afterFiles = createFilesSnapshot(
|
|
90
|
-
shareDBDoc.data.files,
|
|
91
|
-
);
|
|
92
|
-
const diffData = generateFilesUnifiedDiff(
|
|
93
|
-
beforeFiles,
|
|
94
|
-
afterFiles,
|
|
95
|
-
);
|
|
96
|
-
|
|
97
|
-
return {
|
|
98
|
-
content: result.content,
|
|
99
|
-
generationId: result.generationId,
|
|
100
|
-
diffData,
|
|
101
|
-
};
|
|
102
|
-
};
|