vzcode 0.45.0 → 0.47.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/{index-iQRmsAKc.css → index-0U2uzpmH.css} +1 -1
- package/dist/assets/{index-pub_uACz.js → index-r3WFw-uS.js} +38 -41
- package/dist/index.html +2 -2
- package/package.json +5 -5
- package/src/client/AIAssist/AIAssistCodeMirrorKeyMap.ts +42 -0
- package/src/client/AIAssist/AIAssistWidget/index.tsx +96 -0
- package/src/client/AIAssist/AIAssistWidget/style.scss +19 -0
- package/src/client/AIAssist/formatFile.ts +27 -0
- package/src/client/AIAssist/generateFilesContext.ts +25 -0
- package/src/client/AIAssist/index.ts +3 -0
- package/src/client/AIAssist/startAIAssist.ts +120 -0
- package/src/client/CodeEditor/getOrCreateEditor.ts +9 -18
- package/src/client/CodeEditor/index.tsx +0 -16
- package/src/client/CodeEditor/typeScriptCompletions.ts +1 -5
- package/src/client/CodeEditor/typeScriptLinter.ts +2 -2
- package/src/client/CodeErrorOverlay/index.tsx +23 -18
- package/src/client/Icons/SparklesSVG.tsx +31 -0
- package/src/client/Icons/StopSVG.tsx +15 -0
- package/src/client/Icons/index.tsx +2 -0
- package/src/client/VZMiddle.tsx +20 -8
- package/src/client/generateRequestId.ts +6 -0
- package/src/client/useTypeScript/index.ts +4 -0
- package/src/server/generateAIResponse.js +111 -0
- package/src/server/handleAIAssist.js +11 -100
- package/src/server/index.js +49 -55
- package/src/types.ts +21 -21
- package/src/client/AIAssist.ts +0 -133
- package/src/client/AIAssistWidget/index.tsx +0 -101
- package/src/client/AIAssistWidget/style.scss +0 -10
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import { useCallback, useEffect, useState } from 'react';
|
|
2
|
-
import { Button } from '../bootstrap';
|
|
3
|
-
import './style.scss';
|
|
4
|
-
import {
|
|
5
|
-
mostRecentStreamId,
|
|
6
|
-
haltAIAssist,
|
|
7
|
-
startAIAssist,
|
|
8
|
-
} from '../AIAssist';
|
|
9
|
-
import {
|
|
10
|
-
FileId,
|
|
11
|
-
ShareDBDoc,
|
|
12
|
-
VZCodeContent,
|
|
13
|
-
} from '../../types';
|
|
14
|
-
import { EditorCache } from '../useEditorCache';
|
|
15
|
-
import { TabState } from '../vzReducer';
|
|
16
|
-
// From
|
|
17
|
-
// https://primer.style/foundations/icons/zap-24
|
|
18
|
-
const ZapSVG = () => (
|
|
19
|
-
<svg
|
|
20
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
21
|
-
viewBox="0 0 24 24"
|
|
22
|
-
width="24"
|
|
23
|
-
height="24"
|
|
24
|
-
>
|
|
25
|
-
<path d="M15.716 1.329a1.341 1.341 0 0 1 2.109 1.55L15.147 9h4.161c1.623 0 2.372 2.016 1.143 3.075L8.102 22.721a1.148 1.148 0 0 1-1.81-1.317L8.996 15H4.674c-1.619 0-2.37-2.008-1.148-3.07l12.19-10.6Zm.452 1.595L4.51 13.061a.25.25 0 0 0 .164.439h5.45a.749.749 0 0 1 .692 1.041l-2.559 6.066 11.215-9.668a.25.25 0 0 0-.164-.439H14a.75.75 0 0 1-.687-1.05Z"></path>
|
|
26
|
-
</svg>
|
|
27
|
-
);
|
|
28
|
-
|
|
29
|
-
// From Wikimedia
|
|
30
|
-
// https://commons.wikimedia.org/wiki/File:Stopsign.svg
|
|
31
|
-
const StopSVG = () => (
|
|
32
|
-
<svg
|
|
33
|
-
width="15pt"
|
|
34
|
-
height="15pt"
|
|
35
|
-
version="1.1"
|
|
36
|
-
viewBox="0 0 15 15"
|
|
37
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
38
|
-
>
|
|
39
|
-
<g transform="scale(.75)" fill="#fff" stroke="#000">
|
|
40
|
-
<path d="m17.5 0.5c1.1055 0 2 0.89453 2 2v15c0 1.1055-0.89453 2-2 2h-15c-1.1055 0-2-0.89453-2-2v-15c0-1.1055 0.89453-2 2-2z" />
|
|
41
|
-
</g>
|
|
42
|
-
</svg>
|
|
43
|
-
);
|
|
44
|
-
|
|
45
|
-
export const AIAssistWidget = ({
|
|
46
|
-
activeFileId,
|
|
47
|
-
shareDBDoc,
|
|
48
|
-
editorCache,
|
|
49
|
-
tabList,
|
|
50
|
-
}: {
|
|
51
|
-
activeFileId: FileId;
|
|
52
|
-
shareDBDoc: ShareDBDoc<VZCodeContent>;
|
|
53
|
-
editorCache: EditorCache;
|
|
54
|
-
tabList: Array<TabState>;
|
|
55
|
-
}) => {
|
|
56
|
-
const [AIAssistRunning, setAIAssistRunning] =
|
|
57
|
-
useState(false);
|
|
58
|
-
|
|
59
|
-
useEffect(() => {
|
|
60
|
-
const handleOp = (op, source) => {
|
|
61
|
-
if (op !== null && op[0] === 'aiStreams') {
|
|
62
|
-
// The check if the value is true is required
|
|
63
|
-
// because the value could be null rather than false.
|
|
64
|
-
setAIAssistRunning(
|
|
65
|
-
shareDBDoc.data.aiStreams[mostRecentStreamId]
|
|
66
|
-
?.AIStreamStatus.serverIsRunning === true,
|
|
67
|
-
);
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
shareDBDoc.on('op', handleOp);
|
|
71
|
-
|
|
72
|
-
return () => {
|
|
73
|
-
shareDBDoc.off('op', handleOp);
|
|
74
|
-
};
|
|
75
|
-
}, [shareDBDoc]);
|
|
76
|
-
|
|
77
|
-
const handleClick = useCallback(() => {
|
|
78
|
-
if (!AIAssistRunning) {
|
|
79
|
-
startAIAssist(
|
|
80
|
-
editorCache.get(activeFileId).editor,
|
|
81
|
-
shareDBDoc,
|
|
82
|
-
activeFileId,
|
|
83
|
-
tabList,
|
|
84
|
-
);
|
|
85
|
-
} else {
|
|
86
|
-
haltAIAssist(shareDBDoc);
|
|
87
|
-
}
|
|
88
|
-
}, [activeFileId, AIAssistRunning]);
|
|
89
|
-
|
|
90
|
-
return (
|
|
91
|
-
<div className="vz-code-ai-assist-widget">
|
|
92
|
-
<Button
|
|
93
|
-
variant="light"
|
|
94
|
-
title="Start AI Assist"
|
|
95
|
-
onClick={handleClick}
|
|
96
|
-
>
|
|
97
|
-
{AIAssistRunning ? <StopSVG /> : <ZapSVG />}
|
|
98
|
-
</Button>
|
|
99
|
-
</div>
|
|
100
|
-
);
|
|
101
|
-
};
|