@notebook-intelligence/notebook-intelligence 1.3.4 → 2.0.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/README.md +1 -1
- package/lib/api.d.ts +3 -2
- package/lib/api.js +13 -2
- package/lib/chat-sidebar.d.ts +3 -1
- package/lib/chat-sidebar.js +365 -14
- package/lib/index.js +199 -1
- package/lib/tokens.d.ts +13 -0
- package/lib/tokens.js +5 -0
- package/package.json +1 -1
- package/src/api.ts +16 -1
- package/src/chat-sidebar.tsx +630 -19
- package/src/index.ts +252 -1
- package/src/tokens.ts +15 -0
- package/style/base.css +167 -3
package/lib/index.js
CHANGED
|
@@ -37,6 +37,18 @@ var CommandIDs;
|
|
|
37
37
|
CommandIDs.editorTroubleshootThisOutput = 'notebook-intelligence:editor-troubleshoot-this-output';
|
|
38
38
|
CommandIDs.openGitHubCopilotLoginDialog = 'notebook-intelligence:open-github-copilot-login-dialog';
|
|
39
39
|
CommandIDs.openConfigurationDialog = 'notebook-intelligence:open-configuration-dialog';
|
|
40
|
+
CommandIDs.addMarkdownCellToActiveNotebook = 'notebook-intelligence:add-markdown-cell-to-active-notebook';
|
|
41
|
+
CommandIDs.addCodeCellToActiveNotebook = 'notebook-intelligence:add-code-cell-to-active-notebook';
|
|
42
|
+
CommandIDs.deleteCellAtIndex = 'notebook-intelligence:delete-cell-at-index';
|
|
43
|
+
CommandIDs.insertCellAtIndex = 'notebook-intelligence:insert-cell-at-index';
|
|
44
|
+
CommandIDs.setCellTypeAndSource = 'notebook-intelligence:set-cell-type-and-source';
|
|
45
|
+
CommandIDs.getNumberOfCells = 'notebook-intelligence:get-number-of-cells';
|
|
46
|
+
CommandIDs.getCellType = 'notebook-intelligence:get-cell-type';
|
|
47
|
+
CommandIDs.getCellSource = 'notebook-intelligence:get-cell-source';
|
|
48
|
+
CommandIDs.getCellOutput = 'notebook-intelligence:get-cell-output';
|
|
49
|
+
CommandIDs.runCellAtIndex = 'notebook-intelligence:run-cell-at-index';
|
|
50
|
+
CommandIDs.getCurrentFileContent = 'notebook-intelligence:get-current-file-content';
|
|
51
|
+
CommandIDs.setCurrentFileContent = 'notebook-intelligence:set-current-file-content';
|
|
40
52
|
})(CommandIDs || (CommandIDs = {}));
|
|
41
53
|
const DOCUMENT_WATCH_INTERVAL = 1000;
|
|
42
54
|
const MAX_TOKENS = 4096;
|
|
@@ -625,6 +637,192 @@ const plugin = {
|
|
|
625
637
|
return addCellToNotebook(args.path, 'markdown', args.markdown);
|
|
626
638
|
}
|
|
627
639
|
});
|
|
640
|
+
const ensureANotebookIsActive = () => {
|
|
641
|
+
const currentWidget = app.shell.currentWidget;
|
|
642
|
+
const notebookOpen = currentWidget instanceof NotebookPanel && currentWidget.model;
|
|
643
|
+
if (!notebookOpen) {
|
|
644
|
+
app.commands.execute('apputils:notify', {
|
|
645
|
+
message: 'Failed to find active notebook',
|
|
646
|
+
type: 'error',
|
|
647
|
+
options: { autoClose: true }
|
|
648
|
+
});
|
|
649
|
+
return false;
|
|
650
|
+
}
|
|
651
|
+
return true;
|
|
652
|
+
};
|
|
653
|
+
const ensureAFileEditorIsActive = () => {
|
|
654
|
+
const currentWidget = app.shell.currentWidget;
|
|
655
|
+
const textFileOpen = currentWidget instanceof FileEditorWidget;
|
|
656
|
+
if (!textFileOpen) {
|
|
657
|
+
app.commands.execute('apputils:notify', {
|
|
658
|
+
message: 'Failed to find active file',
|
|
659
|
+
type: 'error',
|
|
660
|
+
options: { autoClose: true }
|
|
661
|
+
});
|
|
662
|
+
return false;
|
|
663
|
+
}
|
|
664
|
+
return true;
|
|
665
|
+
};
|
|
666
|
+
app.commands.addCommand(CommandIDs.addMarkdownCellToActiveNotebook, {
|
|
667
|
+
execute: args => {
|
|
668
|
+
if (!ensureANotebookIsActive()) {
|
|
669
|
+
return false;
|
|
670
|
+
}
|
|
671
|
+
const np = app.shell.currentWidget;
|
|
672
|
+
const model = np.model.sharedModel;
|
|
673
|
+
const newCellIndex = isNewEmptyNotebook(model)
|
|
674
|
+
? 0
|
|
675
|
+
: model.cells.length - 1;
|
|
676
|
+
model.insertCell(newCellIndex, {
|
|
677
|
+
cell_type: 'markdown',
|
|
678
|
+
metadata: { trusted: true },
|
|
679
|
+
source: args.source
|
|
680
|
+
});
|
|
681
|
+
return true;
|
|
682
|
+
}
|
|
683
|
+
});
|
|
684
|
+
app.commands.addCommand(CommandIDs.addCodeCellToActiveNotebook, {
|
|
685
|
+
execute: args => {
|
|
686
|
+
if (!ensureANotebookIsActive()) {
|
|
687
|
+
return false;
|
|
688
|
+
}
|
|
689
|
+
const np = app.shell.currentWidget;
|
|
690
|
+
const model = np.model.sharedModel;
|
|
691
|
+
const newCellIndex = isNewEmptyNotebook(model)
|
|
692
|
+
? 0
|
|
693
|
+
: model.cells.length - 1;
|
|
694
|
+
model.insertCell(newCellIndex, {
|
|
695
|
+
cell_type: 'code',
|
|
696
|
+
metadata: { trusted: true },
|
|
697
|
+
source: args.source
|
|
698
|
+
});
|
|
699
|
+
return true;
|
|
700
|
+
}
|
|
701
|
+
});
|
|
702
|
+
app.commands.addCommand(CommandIDs.setCellTypeAndSource, {
|
|
703
|
+
execute: args => {
|
|
704
|
+
if (!ensureANotebookIsActive()) {
|
|
705
|
+
return false;
|
|
706
|
+
}
|
|
707
|
+
const np = app.shell.currentWidget;
|
|
708
|
+
const model = np.model.sharedModel;
|
|
709
|
+
const cellIndex = args.cellIndex;
|
|
710
|
+
const cellType = args.cellType;
|
|
711
|
+
const cell = model.getCell(cellIndex);
|
|
712
|
+
model.deleteCell(cellIndex);
|
|
713
|
+
model.insertCell(cellIndex, {
|
|
714
|
+
cell_type: cellType,
|
|
715
|
+
metadata: cell.metadata,
|
|
716
|
+
source: args.source
|
|
717
|
+
});
|
|
718
|
+
return true;
|
|
719
|
+
}
|
|
720
|
+
});
|
|
721
|
+
app.commands.addCommand(CommandIDs.getNumberOfCells, {
|
|
722
|
+
execute: args => {
|
|
723
|
+
if (!ensureANotebookIsActive()) {
|
|
724
|
+
return false;
|
|
725
|
+
}
|
|
726
|
+
const np = app.shell.currentWidget;
|
|
727
|
+
const model = np.model.sharedModel;
|
|
728
|
+
return model.cells.length;
|
|
729
|
+
}
|
|
730
|
+
});
|
|
731
|
+
app.commands.addCommand(CommandIDs.getCellType, {
|
|
732
|
+
execute: args => {
|
|
733
|
+
if (!ensureANotebookIsActive()) {
|
|
734
|
+
return false;
|
|
735
|
+
}
|
|
736
|
+
const np = app.shell.currentWidget;
|
|
737
|
+
const model = np.model.sharedModel;
|
|
738
|
+
return model.cells[args.cellIndex].cell_type;
|
|
739
|
+
}
|
|
740
|
+
});
|
|
741
|
+
app.commands.addCommand(CommandIDs.getCellSource, {
|
|
742
|
+
execute: args => {
|
|
743
|
+
if (!ensureANotebookIsActive()) {
|
|
744
|
+
return false;
|
|
745
|
+
}
|
|
746
|
+
const np = app.shell.currentWidget;
|
|
747
|
+
const model = np.model.sharedModel;
|
|
748
|
+
return model.cells[args.cellIndex].source;
|
|
749
|
+
}
|
|
750
|
+
});
|
|
751
|
+
app.commands.addCommand(CommandIDs.getCellOutput, {
|
|
752
|
+
execute: args => {
|
|
753
|
+
if (!ensureANotebookIsActive()) {
|
|
754
|
+
return false;
|
|
755
|
+
}
|
|
756
|
+
const np = app.shell.currentWidget;
|
|
757
|
+
const cellIndex = args.cellIndex;
|
|
758
|
+
const cell = np.content.widgets[cellIndex];
|
|
759
|
+
if (!(cell instanceof CodeCell)) {
|
|
760
|
+
return '';
|
|
761
|
+
}
|
|
762
|
+
const content = cellOutputAsText(cell);
|
|
763
|
+
return content;
|
|
764
|
+
}
|
|
765
|
+
});
|
|
766
|
+
app.commands.addCommand(CommandIDs.insertCellAtIndex, {
|
|
767
|
+
execute: args => {
|
|
768
|
+
if (!ensureANotebookIsActive()) {
|
|
769
|
+
return false;
|
|
770
|
+
}
|
|
771
|
+
const np = app.shell.currentWidget;
|
|
772
|
+
const model = np.model.sharedModel;
|
|
773
|
+
const cellIndex = args.cellIndex;
|
|
774
|
+
const cellType = args.cellType;
|
|
775
|
+
model.insertCell(cellIndex, {
|
|
776
|
+
cell_type: cellType,
|
|
777
|
+
metadata: { trusted: true },
|
|
778
|
+
source: args.source
|
|
779
|
+
});
|
|
780
|
+
return true;
|
|
781
|
+
}
|
|
782
|
+
});
|
|
783
|
+
app.commands.addCommand(CommandIDs.deleteCellAtIndex, {
|
|
784
|
+
execute: args => {
|
|
785
|
+
if (!ensureANotebookIsActive()) {
|
|
786
|
+
return false;
|
|
787
|
+
}
|
|
788
|
+
const np = app.shell.currentWidget;
|
|
789
|
+
const model = np.model.sharedModel;
|
|
790
|
+
const cellIndex = args.cellIndex;
|
|
791
|
+
model.deleteCell(cellIndex);
|
|
792
|
+
return true;
|
|
793
|
+
}
|
|
794
|
+
});
|
|
795
|
+
app.commands.addCommand(CommandIDs.runCellAtIndex, {
|
|
796
|
+
execute: async (args) => {
|
|
797
|
+
if (!ensureANotebookIsActive()) {
|
|
798
|
+
return false;
|
|
799
|
+
}
|
|
800
|
+
const currentWidget = app.shell.currentWidget;
|
|
801
|
+
currentWidget.content.activeCellIndex = args.cellIndex;
|
|
802
|
+
await app.commands.execute('notebook:run-cell');
|
|
803
|
+
}
|
|
804
|
+
});
|
|
805
|
+
app.commands.addCommand(CommandIDs.getCurrentFileContent, {
|
|
806
|
+
execute: async (args) => {
|
|
807
|
+
if (!ensureAFileEditorIsActive()) {
|
|
808
|
+
return false;
|
|
809
|
+
}
|
|
810
|
+
const currentWidget = app.shell.currentWidget;
|
|
811
|
+
const editor = currentWidget.content.editor;
|
|
812
|
+
return editor.model.sharedModel.getSource();
|
|
813
|
+
}
|
|
814
|
+
});
|
|
815
|
+
app.commands.addCommand(CommandIDs.setCurrentFileContent, {
|
|
816
|
+
execute: async (args) => {
|
|
817
|
+
if (!ensureAFileEditorIsActive()) {
|
|
818
|
+
return false;
|
|
819
|
+
}
|
|
820
|
+
const currentWidget = app.shell.currentWidget;
|
|
821
|
+
const editor = currentWidget.content.editor;
|
|
822
|
+
editor.model.sharedModel.setSource(args.content);
|
|
823
|
+
return editor.model.sharedModel.getSource();
|
|
824
|
+
}
|
|
825
|
+
});
|
|
628
826
|
app.commands.addCommand(CommandIDs.openGitHubCopilotLoginDialog, {
|
|
629
827
|
execute: args => {
|
|
630
828
|
let dialog = null;
|
|
@@ -1044,7 +1242,7 @@ const plugin = {
|
|
|
1044
1242
|
});
|
|
1045
1243
|
const copilotContextMenu = new Menu({ commands: copilotMenuCommands });
|
|
1046
1244
|
copilotContextMenu.id = 'notebook-intelligence:editor-context-menu';
|
|
1047
|
-
copilotContextMenu.title.label = '
|
|
1245
|
+
copilotContextMenu.title.label = 'Notebook Intelligence';
|
|
1048
1246
|
copilotContextMenu.title.icon = sidebarIcon;
|
|
1049
1247
|
copilotContextMenu.addItem({ command: CommandIDs.editorGenerateCode });
|
|
1050
1248
|
copilotContextMenu.addItem({ command: CommandIDs.editorExplainThisCode });
|
package/lib/tokens.d.ts
CHANGED
|
@@ -62,6 +62,19 @@ export interface IChatParticipant {
|
|
|
62
62
|
iconPath: string;
|
|
63
63
|
commands: string[];
|
|
64
64
|
}
|
|
65
|
+
export interface IToolSelections {
|
|
66
|
+
builtinToolsets?: string[];
|
|
67
|
+
mcpServers?: {
|
|
68
|
+
[key: string]: string[];
|
|
69
|
+
};
|
|
70
|
+
extensions?: {
|
|
71
|
+
[key: string]: string[];
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
export declare enum BuiltinToolsetType {
|
|
75
|
+
NotebookEdit = "nbi-notebook-edit",
|
|
76
|
+
NotebookExecute = "nbi-notebook-execute"
|
|
77
|
+
}
|
|
65
78
|
export declare const GITHUB_COPILOT_PROVIDER_ID = "github-copilot";
|
|
66
79
|
export declare enum TelemetryEventType {
|
|
67
80
|
InlineCompletionRequest = "inline-completion-request",
|
package/lib/tokens.js
CHANGED
|
@@ -34,6 +34,11 @@ export var ContextType;
|
|
|
34
34
|
ContextType["Custom"] = "custom";
|
|
35
35
|
ContextType["CurrentFile"] = "current-file";
|
|
36
36
|
})(ContextType || (ContextType = {}));
|
|
37
|
+
export var BuiltinToolsetType;
|
|
38
|
+
(function (BuiltinToolsetType) {
|
|
39
|
+
BuiltinToolsetType["NotebookEdit"] = "nbi-notebook-edit";
|
|
40
|
+
BuiltinToolsetType["NotebookExecute"] = "nbi-notebook-execute";
|
|
41
|
+
})(BuiltinToolsetType || (BuiltinToolsetType = {}));
|
|
37
42
|
export const GITHUB_COPILOT_PROVIDER_ID = 'github-copilot';
|
|
38
43
|
export var TelemetryEventType;
|
|
39
44
|
(function (TelemetryEventType) {
|
package/package.json
CHANGED
package/src/api.ts
CHANGED
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
IChatParticipant,
|
|
12
12
|
IContextItem,
|
|
13
13
|
ITelemetryEvent,
|
|
14
|
+
IToolSelections,
|
|
14
15
|
RequestDataType
|
|
15
16
|
} from './tokens';
|
|
16
17
|
|
|
@@ -60,6 +61,10 @@ export class NBIConfig {
|
|
|
60
61
|
return this.capabilities.store_github_access_token === true;
|
|
61
62
|
}
|
|
62
63
|
|
|
64
|
+
get toolConfig(): any {
|
|
65
|
+
return this.capabilities.tool_config;
|
|
66
|
+
}
|
|
67
|
+
|
|
63
68
|
capabilities: any = {};
|
|
64
69
|
chatParticipants: IChatParticipant[] = [];
|
|
65
70
|
|
|
@@ -230,6 +235,8 @@ export class NBIAPI {
|
|
|
230
235
|
language: string,
|
|
231
236
|
filename: string,
|
|
232
237
|
additionalContext: IContextItem[],
|
|
238
|
+
chatMode: string,
|
|
239
|
+
toolSelections: IToolSelections,
|
|
233
240
|
responseEmitter: IChatCompletionResponseEmitter
|
|
234
241
|
) {
|
|
235
242
|
this._messageReceived.connect((_, msg) => {
|
|
@@ -242,7 +249,15 @@ export class NBIAPI {
|
|
|
242
249
|
JSON.stringify({
|
|
243
250
|
id: messageId,
|
|
244
251
|
type: RequestDataType.ChatRequest,
|
|
245
|
-
data: {
|
|
252
|
+
data: {
|
|
253
|
+
chatId,
|
|
254
|
+
prompt,
|
|
255
|
+
language,
|
|
256
|
+
filename,
|
|
257
|
+
additionalContext,
|
|
258
|
+
chatMode,
|
|
259
|
+
toolSelections
|
|
260
|
+
}
|
|
246
261
|
})
|
|
247
262
|
);
|
|
248
263
|
}
|