@nocturnium/svelte-ide 1.0.0-rc.1
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/LICENSE +21 -0
- package/README.md +251 -0
- package/dist/components/agents/AgentActivityPanel.svelte +565 -0
- package/dist/components/agents/AgentActivityPanel.svelte.d.ts +24 -0
- package/dist/components/agents/AgentAvatar.svelte +417 -0
- package/dist/components/agents/AgentAvatar.svelte.d.ts +23 -0
- package/dist/components/agents/AgentCursor.svelte +224 -0
- package/dist/components/agents/AgentCursor.svelte.d.ts +35 -0
- package/dist/components/agents/AgentPresenceBar.svelte +261 -0
- package/dist/components/agents/AgentPresenceBar.svelte.d.ts +20 -0
- package/dist/components/agents/index.d.ts +4 -0
- package/dist/components/agents/index.js +5 -0
- package/dist/components/ai/AIConversationList.svelte +524 -0
- package/dist/components/ai/AIConversationList.svelte.d.ts +17 -0
- package/dist/components/ai/AIEditPreview.svelte +132 -0
- package/dist/components/ai/AIEditPreview.svelte.d.ts +8 -0
- package/dist/components/ai/AIInlineEdit.svelte +155 -0
- package/dist/components/ai/AIInlineEdit.svelte.d.ts +10 -0
- package/dist/components/ai/AIMessage.svelte +239 -0
- package/dist/components/ai/AIMessage.svelte.d.ts +13 -0
- package/dist/components/ai/AIMessageActions.svelte +176 -0
- package/dist/components/ai/AIMessageActions.svelte.d.ts +12 -0
- package/dist/components/ai/AIMessageContent.svelte +355 -0
- package/dist/components/ai/AIMessageContent.svelte.d.ts +7 -0
- package/dist/components/ai/AIPanel.svelte +561 -0
- package/dist/components/ai/AIPanel.svelte.d.ts +7 -0
- package/dist/components/ai/AISuggestionWidget.svelte +132 -0
- package/dist/components/ai/AISuggestionWidget.svelte.d.ts +10 -0
- package/dist/components/ai/AIToolCallDisplay.svelte +317 -0
- package/dist/components/ai/AIToolCallDisplay.svelte.d.ts +12 -0
- package/dist/components/ai/index.d.ts +9 -0
- package/dist/components/ai/index.js +10 -0
- package/dist/components/core/Avatar.svelte +110 -0
- package/dist/components/core/Avatar.svelte.d.ts +12 -0
- package/dist/components/core/Badge.svelte +98 -0
- package/dist/components/core/Badge.svelte.d.ts +11 -0
- package/dist/components/core/Button.svelte +175 -0
- package/dist/components/core/Button.svelte.d.ts +18 -0
- package/dist/components/core/ConnectionStatus.svelte +294 -0
- package/dist/components/core/ConnectionStatus.svelte.d.ts +20 -0
- package/dist/components/core/ContextMenu.svelte +176 -0
- package/dist/components/core/ContextMenu.svelte.d.ts +19 -0
- package/dist/components/core/ErrorBoundary.svelte +277 -0
- package/dist/components/core/ErrorBoundary.svelte.d.ts +23 -0
- package/dist/components/core/Icon.svelte +107 -0
- package/dist/components/core/Icon.svelte.d.ts +8 -0
- package/dist/components/core/Input.svelte +138 -0
- package/dist/components/core/Input.svelte.d.ts +20 -0
- package/dist/components/core/Kbd.svelte +34 -0
- package/dist/components/core/Kbd.svelte.d.ts +7 -0
- package/dist/components/core/ResizeHandle.svelte +200 -0
- package/dist/components/core/ResizeHandle.svelte.d.ts +23 -0
- package/dist/components/core/Spinner.svelte +35 -0
- package/dist/components/core/Spinner.svelte.d.ts +7 -0
- package/dist/components/core/Textarea.svelte +112 -0
- package/dist/components/core/Textarea.svelte.d.ts +18 -0
- package/dist/components/core/Tooltip.svelte +103 -0
- package/dist/components/core/Tooltip.svelte.d.ts +11 -0
- package/dist/components/core/index.d.ts +13 -0
- package/dist/components/core/index.js +14 -0
- package/dist/components/editor/AIFocusLayer.svelte +430 -0
- package/dist/components/editor/AIFocusLayer.svelte.d.ts +32 -0
- package/dist/components/editor/Breadcrumbs.svelte +435 -0
- package/dist/components/editor/Breadcrumbs.svelte.d.ts +33 -0
- package/dist/components/editor/BreakpointLayer.svelte +642 -0
- package/dist/components/editor/BreakpointLayer.svelte.d.ts +20 -0
- package/dist/components/editor/CognitiveLoadMeter.svelte +324 -0
- package/dist/components/editor/CognitiveLoadMeter.svelte.d.ts +18 -0
- package/dist/components/editor/CollaborativeEditor.svelte +218 -0
- package/dist/components/editor/CollaborativeEditor.svelte.d.ts +32 -0
- package/dist/components/editor/CommandPalette.svelte +434 -0
- package/dist/components/editor/CommandPalette.svelte.d.ts +11 -0
- package/dist/components/editor/ComplexityLayer.svelte +293 -0
- package/dist/components/editor/ComplexityLayer.svelte.d.ts +23 -0
- package/dist/components/editor/ConflictZoneLayer.svelte +441 -0
- package/dist/components/editor/ConflictZoneLayer.svelte.d.ts +25 -0
- package/dist/components/editor/ContextLens.svelte +262 -0
- package/dist/components/editor/ContextLens.svelte.d.ts +27 -0
- package/dist/components/editor/CustomEditor.svelte +1242 -0
- package/dist/components/editor/CustomEditor.svelte.d.ts +37 -0
- package/dist/components/editor/DebugConsole.svelte +646 -0
- package/dist/components/editor/DebugConsole.svelte.d.ts +41 -0
- package/dist/components/editor/EchoCursorLayer.svelte +363 -0
- package/dist/components/editor/EchoCursorLayer.svelte.d.ts +24 -0
- package/dist/components/editor/Editor.svelte +61 -0
- package/dist/components/editor/Editor.svelte.d.ts +22 -0
- package/dist/components/editor/EditorGutter.svelte +119 -0
- package/dist/components/editor/EditorGutter.svelte.d.ts +19 -0
- package/dist/components/editor/EditorLines.svelte +182 -0
- package/dist/components/editor/EditorLines.svelte.d.ts +43 -0
- package/dist/components/editor/EditorPane.svelte +134 -0
- package/dist/components/editor/EditorPane.svelte.d.ts +9 -0
- package/dist/components/editor/EditorSelections.svelte +186 -0
- package/dist/components/editor/EditorSelections.svelte.d.ts +25 -0
- package/dist/components/editor/EditorTabs.svelte +170 -0
- package/dist/components/editor/EditorTabs.svelte.d.ts +12 -0
- package/dist/components/editor/FileExplorer.svelte +811 -0
- package/dist/components/editor/FileExplorer.svelte.d.ts +67 -0
- package/dist/components/editor/FileIcon.svelte +110 -0
- package/dist/components/editor/FileIcon.svelte.d.ts +10 -0
- package/dist/components/editor/FindReplace.svelte +448 -0
- package/dist/components/editor/FindReplace.svelte.d.ts +40 -0
- package/dist/components/editor/GhostBracketLayer.svelte +391 -0
- package/dist/components/editor/GhostBracketLayer.svelte.d.ts +24 -0
- package/dist/components/editor/GitBlameLayer.svelte +436 -0
- package/dist/components/editor/GitBlameLayer.svelte.d.ts +18 -0
- package/dist/components/editor/InlineDiagnosticsLayer.svelte +540 -0
- package/dist/components/editor/InlineDiagnosticsLayer.svelte.d.ts +35 -0
- package/dist/components/editor/InlineDiffLayer.svelte +337 -0
- package/dist/components/editor/InlineDiffLayer.svelte.d.ts +31 -0
- package/dist/components/editor/MinimalEditor.svelte +75 -0
- package/dist/components/editor/MinimalEditor.svelte.d.ts +6 -0
- package/dist/components/editor/MinimalEditor2.svelte +84 -0
- package/dist/components/editor/MinimalEditor2.svelte.d.ts +6 -0
- package/dist/components/editor/Minimap.svelte +327 -0
- package/dist/components/editor/Minimap.svelte.d.ts +34 -0
- package/dist/components/editor/PluginPreviewSandbox.svelte +793 -0
- package/dist/components/editor/PluginPreviewSandbox.svelte.d.ts +49 -0
- package/dist/components/editor/ProblemsPanel.svelte +628 -0
- package/dist/components/editor/ProblemsPanel.svelte.d.ts +25 -0
- package/dist/components/editor/QuickActionsMenu.svelte +403 -0
- package/dist/components/editor/QuickActionsMenu.svelte.d.ts +18 -0
- package/dist/components/editor/SnippetPalette.svelte +530 -0
- package/dist/components/editor/SnippetPalette.svelte.d.ts +16 -0
- package/dist/components/editor/StructureMap.svelte +431 -0
- package/dist/components/editor/StructureMap.svelte.d.ts +37 -0
- package/dist/components/editor/SymbolOutline.svelte +722 -0
- package/dist/components/editor/SymbolOutline.svelte.d.ts +44 -0
- package/dist/components/editor/TimelineScrubber.svelte +470 -0
- package/dist/components/editor/TimelineScrubber.svelte.d.ts +40 -0
- package/dist/components/editor/TokenRenderer.svelte +69 -0
- package/dist/components/editor/TokenRenderer.svelte.d.ts +15 -0
- package/dist/components/editor/constants.d.ts +32 -0
- package/dist/components/editor/constants.js +36 -0
- package/dist/components/editor/core/ai-awareness.d.ts +176 -0
- package/dist/components/editor/core/ai-awareness.js +210 -0
- package/dist/components/editor/core/bracket-healer.d.ts +189 -0
- package/dist/components/editor/core/bracket-healer.js +406 -0
- package/dist/components/editor/core/breakpoints.d.ts +203 -0
- package/dist/components/editor/core/breakpoints.js +414 -0
- package/dist/components/editor/core/commands.d.ts +108 -0
- package/dist/components/editor/core/commands.js +246 -0
- package/dist/components/editor/core/complexity-analyzer.d.ts +123 -0
- package/dist/components/editor/core/complexity-analyzer.js +376 -0
- package/dist/components/editor/core/conflict-predictor.d.ts +135 -0
- package/dist/components/editor/core/conflict-predictor.js +316 -0
- package/dist/components/editor/core/crdt-binding.d.ts +118 -0
- package/dist/components/editor/core/crdt-binding.js +286 -0
- package/dist/components/editor/core/diagnostics.d.ts +210 -0
- package/dist/components/editor/core/diagnostics.js +335 -0
- package/dist/components/editor/core/echo-cursor.d.ts +201 -0
- package/dist/components/editor/core/echo-cursor.js +267 -0
- package/dist/components/editor/core/folding.d.ts +124 -0
- package/dist/components/editor/core/folding.js +672 -0
- package/dist/components/editor/core/ghost-pair.d.ts +122 -0
- package/dist/components/editor/core/ghost-pair.js +221 -0
- package/dist/components/editor/core/git-blame.d.ts +170 -0
- package/dist/components/editor/core/git-blame.js +324 -0
- package/dist/components/editor/core/index.d.ts +26 -0
- package/dist/components/editor/core/index.js +24 -0
- package/dist/components/editor/core/keybindings.d.ts +79 -0
- package/dist/components/editor/core/keybindings.js +357 -0
- package/dist/components/editor/core/multi-cursor.d.ts +196 -0
- package/dist/components/editor/core/multi-cursor.js +521 -0
- package/dist/components/editor/core/navigation.d.ts +107 -0
- package/dist/components/editor/core/navigation.js +408 -0
- package/dist/components/editor/core/quick-actions.d.ts +189 -0
- package/dist/components/editor/core/quick-actions.js +427 -0
- package/dist/components/editor/core/search.d.ts +88 -0
- package/dist/components/editor/core/search.js +192 -0
- package/dist/components/editor/core/semantic-analyzer.d.ts +77 -0
- package/dist/components/editor/core/semantic-analyzer.js +424 -0
- package/dist/components/editor/core/snippet-manager.d.ts +202 -0
- package/dist/components/editor/core/snippet-manager.js +565 -0
- package/dist/components/editor/core/state.d.ts +367 -0
- package/dist/components/editor/core/state.js +900 -0
- package/dist/components/editor/core/timeline.d.ts +204 -0
- package/dist/components/editor/core/timeline.js +349 -0
- package/dist/components/editor/editor-find.d.ts +56 -0
- package/dist/components/editor/editor-find.js +148 -0
- package/dist/components/editor/editor-input.d.ts +77 -0
- package/dist/components/editor/editor-input.js +445 -0
- package/dist/components/editor/editor-multicursor.d.ts +21 -0
- package/dist/components/editor/editor-multicursor.js +196 -0
- package/dist/components/editor/editor-scroll.d.ts +14 -0
- package/dist/components/editor/editor-scroll.js +34 -0
- package/dist/components/editor/index.d.ts +15 -0
- package/dist/components/editor/index.js +21 -0
- package/dist/components/editor/languages.d.ts +62 -0
- package/dist/components/editor/languages.js +285 -0
- package/dist/components/editor/theme.d.ts +88 -0
- package/dist/components/editor/theme.js +139 -0
- package/dist/components/editor/tokenizer/base.d.ts +40 -0
- package/dist/components/editor/tokenizer/base.js +203 -0
- package/dist/components/editor/tokenizer/index.d.ts +56 -0
- package/dist/components/editor/tokenizer/index.js +215 -0
- package/dist/components/editor/tokenizer/languages/css.d.ts +17 -0
- package/dist/components/editor/tokenizer/languages/css.js +194 -0
- package/dist/components/editor/tokenizer/languages/go.d.ts +17 -0
- package/dist/components/editor/tokenizer/languages/go.js +220 -0
- package/dist/components/editor/tokenizer/languages/html.d.ts +24 -0
- package/dist/components/editor/tokenizer/languages/html.js +145 -0
- package/dist/components/editor/tokenizer/languages/javascript.d.ts +56 -0
- package/dist/components/editor/tokenizer/languages/javascript.js +452 -0
- package/dist/components/editor/tokenizer/languages/json.d.ts +12 -0
- package/dist/components/editor/tokenizer/languages/json.js +91 -0
- package/dist/components/editor/tokenizer/languages/markdown.d.ts +16 -0
- package/dist/components/editor/tokenizer/languages/markdown.js +156 -0
- package/dist/components/editor/tokenizer/languages/python.d.ts +20 -0
- package/dist/components/editor/tokenizer/languages/python.js +227 -0
- package/dist/components/editor/tokenizer/languages/svelte.d.ts +40 -0
- package/dist/components/editor/tokenizer/languages/svelte.js +326 -0
- package/dist/components/editor/tokenizer/types.d.ts +86 -0
- package/dist/components/editor/tokenizer/types.js +4 -0
- package/dist/components/layout/IDELayout.svelte +274 -0
- package/dist/components/layout/IDELayout.svelte.d.ts +29 -0
- package/dist/components/layout/StatusBar.svelte +511 -0
- package/dist/components/layout/StatusBar.svelte.d.ts +47 -0
- package/dist/components/layout/index.d.ts +2 -0
- package/dist/components/layout/index.js +3 -0
- package/dist/components/lsp/AutocompleteWidget.svelte +364 -0
- package/dist/components/lsp/AutocompleteWidget.svelte.d.ts +33 -0
- package/dist/components/lsp/DiagnosticMarker.svelte +166 -0
- package/dist/components/lsp/DiagnosticMarker.svelte.d.ts +19 -0
- package/dist/components/lsp/DiagnosticsPanel.svelte +388 -0
- package/dist/components/lsp/DiagnosticsPanel.svelte.d.ts +21 -0
- package/dist/components/lsp/HoverTooltip.svelte +274 -0
- package/dist/components/lsp/HoverTooltip.svelte.d.ts +24 -0
- package/dist/components/lsp/LSPEditor.svelte +486 -0
- package/dist/components/lsp/LSPEditor.svelte.d.ts +39 -0
- package/dist/components/lsp/SignatureHelpWidget.svelte +216 -0
- package/dist/components/lsp/SignatureHelpWidget.svelte.d.ts +22 -0
- package/dist/components/lsp/index.d.ts +6 -0
- package/dist/components/lsp/index.js +7 -0
- package/dist/components/plugins/PluginCard.svelte +153 -0
- package/dist/components/plugins/PluginCard.svelte.d.ts +19 -0
- package/dist/components/plugins/PluginPanel.svelte +280 -0
- package/dist/components/plugins/PluginPanel.svelte.d.ts +8 -0
- package/dist/components/plugins/PluginProposalForm.svelte +250 -0
- package/dist/components/plugins/PluginProposalForm.svelte.d.ts +6 -0
- package/dist/components/plugins/PluginStatusBadge.svelte +14 -0
- package/dist/components/plugins/PluginStatusBadge.svelte.d.ts +8 -0
- package/dist/components/plugins/index.d.ts +4 -0
- package/dist/components/plugins/index.js +5 -0
- package/dist/components/vfs/LockConflictDialog.svelte +705 -0
- package/dist/components/vfs/LockConflictDialog.svelte.d.ts +21 -0
- package/dist/components/vfs/LockIndicator.svelte +194 -0
- package/dist/components/vfs/LockIndicator.svelte.d.ts +29 -0
- package/dist/components/vfs/LockOverlay.svelte +344 -0
- package/dist/components/vfs/LockOverlay.svelte.d.ts +17 -0
- package/dist/components/vfs/VersionConflictDialog.svelte +549 -0
- package/dist/components/vfs/VersionConflictDialog.svelte.d.ts +24 -0
- package/dist/components/vfs/index.d.ts +4 -0
- package/dist/components/vfs/index.js +5 -0
- package/dist/crdt/awareness.d.ts +42 -0
- package/dist/crdt/awareness.js +109 -0
- package/dist/crdt/document.d.ts +101 -0
- package/dist/crdt/document.js +187 -0
- package/dist/crdt/index.d.ts +9 -0
- package/dist/crdt/index.js +8 -0
- package/dist/crdt/provider.d.ts +85 -0
- package/dist/crdt/provider.js +150 -0
- package/dist/crdt/types.d.ts +61 -0
- package/dist/crdt/types.js +4 -0
- package/dist/crdt/undo.d.ts +34 -0
- package/dist/crdt/undo.js +70 -0
- package/dist/index.d.ts +277 -0
- package/dist/index.js +280 -0
- package/dist/plugins/index.d.ts +103 -0
- package/dist/plugins/index.js +153 -0
- package/dist/services/error-handling.d.ts +95 -0
- package/dist/services/error-handling.js +413 -0
- package/dist/services/ide-integration.d.ts +83 -0
- package/dist/services/ide-integration.js +367 -0
- package/dist/services/lsp-client.d.ts +69 -0
- package/dist/services/lsp-client.js +667 -0
- package/dist/services/mock-ai.d.ts +37 -0
- package/dist/services/mock-ai.js +318 -0
- package/dist/services/optimistic.d.ts +141 -0
- package/dist/services/optimistic.js +367 -0
- package/dist/services/vfs-client.d.ts +81 -0
- package/dist/services/vfs-client.js +348 -0
- package/dist/stores/agents.svelte.d.ts +85 -0
- package/dist/stores/agents.svelte.js +459 -0
- package/dist/stores/ai-persistence.svelte.d.ts +76 -0
- package/dist/stores/ai-persistence.svelte.js +334 -0
- package/dist/stores/ai.svelte.d.ts +140 -0
- package/dist/stores/ai.svelte.js +383 -0
- package/dist/stores/collaboration.svelte.d.ts +164 -0
- package/dist/stores/collaboration.svelte.js +334 -0
- package/dist/stores/editor.svelte.d.ts +131 -0
- package/dist/stores/editor.svelte.js +250 -0
- package/dist/stores/index.d.ts +10 -0
- package/dist/stores/index.js +29 -0
- package/dist/stores/layout.svelte.d.ts +171 -0
- package/dist/stores/layout.svelte.js +351 -0
- package/dist/stores/plugin.svelte.d.ts +121 -0
- package/dist/stores/plugin.svelte.js +410 -0
- package/dist/stores/vfs.svelte.d.ts +123 -0
- package/dist/stores/vfs.svelte.js +680 -0
- package/dist/styles/theme.css +623 -0
- package/dist/types/agents.d.ts +127 -0
- package/dist/types/agents.js +5 -0
- package/dist/types/ai.d.ts +137 -0
- package/dist/types/ai.js +4 -0
- package/dist/types/crdt.d.ts +222 -0
- package/dist/types/crdt.js +5 -0
- package/dist/types/editor.d.ts +52 -0
- package/dist/types/editor.js +18 -0
- package/dist/types/events.d.ts +133 -0
- package/dist/types/events.js +4 -0
- package/dist/types/filesystem.d.ts +77 -0
- package/dist/types/filesystem.js +4 -0
- package/dist/types/index.d.ts +9 -0
- package/dist/types/index.js +12 -0
- package/dist/types/lsp.d.ts +691 -0
- package/dist/types/lsp.js +108 -0
- package/dist/types/plugin.d.ts +239 -0
- package/dist/types/plugin.js +5 -0
- package/dist/types/vfs.d.ts +191 -0
- package/dist/types/vfs.js +18 -0
- package/dist/utils/format.d.ts +55 -0
- package/dist/utils/format.js +152 -0
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/index.js +4 -0
- package/dist/utils/keybindings.d.ts +33 -0
- package/dist/utils/keybindings.js +171 -0
- package/dist/utils/language.d.ts +27 -0
- package/dist/utils/language.js +222 -0
- package/package.json +178 -0
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Command System
|
|
3
|
+
*
|
|
4
|
+
* Provides a centralized command registry for the editor.
|
|
5
|
+
* Commands can be executed via keyboard shortcuts or the command palette.
|
|
6
|
+
*/
|
|
7
|
+
import { getSemanticAnalyzer, DEFAULT_FOLD_PRESETS } from './semantic-analyzer';
|
|
8
|
+
/**
|
|
9
|
+
* Command registry
|
|
10
|
+
*/
|
|
11
|
+
class CommandRegistry {
|
|
12
|
+
commands = new Map();
|
|
13
|
+
categories = new Map();
|
|
14
|
+
/**
|
|
15
|
+
* Register a command
|
|
16
|
+
*/
|
|
17
|
+
register(command) {
|
|
18
|
+
this.commands.set(command.id, command);
|
|
19
|
+
return () => this.commands.delete(command.id);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Register multiple commands
|
|
23
|
+
*/
|
|
24
|
+
registerMany(commands) {
|
|
25
|
+
const unsubscribes = commands.map((cmd) => this.register(cmd));
|
|
26
|
+
return () => unsubscribes.forEach((unsub) => unsub());
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Register a category
|
|
30
|
+
*/
|
|
31
|
+
registerCategory(category) {
|
|
32
|
+
this.categories.set(category.id, category);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Get a command by ID
|
|
36
|
+
*/
|
|
37
|
+
get(id) {
|
|
38
|
+
return this.commands.get(id);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Execute a command by ID
|
|
42
|
+
*/
|
|
43
|
+
async execute(id) {
|
|
44
|
+
const command = this.commands.get(id);
|
|
45
|
+
if (!command)
|
|
46
|
+
return false;
|
|
47
|
+
if (command.isEnabled && !command.isEnabled()) {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
await command.execute();
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Get all commands
|
|
55
|
+
*/
|
|
56
|
+
getAll() {
|
|
57
|
+
return Array.from(this.commands.values());
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Get commands by category
|
|
61
|
+
*/
|
|
62
|
+
getByCategory(categoryId) {
|
|
63
|
+
return this.getAll().filter((cmd) => cmd.category === categoryId);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Search commands
|
|
67
|
+
*/
|
|
68
|
+
search(query) {
|
|
69
|
+
const q = query.toLowerCase();
|
|
70
|
+
return this.getAll().filter((cmd) => cmd.label.toLowerCase().includes(q) ||
|
|
71
|
+
cmd.description?.toLowerCase().includes(q) ||
|
|
72
|
+
cmd.category.toLowerCase().includes(q));
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Get all categories
|
|
76
|
+
*/
|
|
77
|
+
getCategories() {
|
|
78
|
+
return Array.from(this.categories.values());
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Clear all commands
|
|
82
|
+
*/
|
|
83
|
+
clear() {
|
|
84
|
+
this.commands.clear();
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
// Global command registry
|
|
88
|
+
let globalRegistry = null;
|
|
89
|
+
/**
|
|
90
|
+
* Get the global command registry
|
|
91
|
+
*/
|
|
92
|
+
export function getCommandRegistry() {
|
|
93
|
+
if (!globalRegistry) {
|
|
94
|
+
globalRegistry = new CommandRegistry();
|
|
95
|
+
initializeCategories(globalRegistry);
|
|
96
|
+
}
|
|
97
|
+
return globalRegistry;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Initialize default categories
|
|
101
|
+
*/
|
|
102
|
+
function initializeCategories(registry) {
|
|
103
|
+
registry.registerCategory({ id: 'fold', label: 'Folding', icon: '▼' });
|
|
104
|
+
registry.registerCategory({ id: 'fold.semantic', label: 'Semantic Folding', icon: '◇' });
|
|
105
|
+
registry.registerCategory({ id: 'fold.preset', label: 'Fold Presets', icon: '◈' });
|
|
106
|
+
registry.registerCategory({ id: 'navigation', label: 'Navigation', icon: '→' });
|
|
107
|
+
registry.registerCategory({ id: 'edit', label: 'Edit', icon: '✎' });
|
|
108
|
+
registry.registerCategory({ id: 'view', label: 'View', icon: '◉' });
|
|
109
|
+
registry.registerCategory({ id: 'search', label: 'Search', icon: '⌕' });
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Create semantic fold commands for the editor
|
|
113
|
+
*/
|
|
114
|
+
export function createSemanticFoldCommands(editorState, options) {
|
|
115
|
+
const analyzer = getSemanticAnalyzer();
|
|
116
|
+
const commands = [];
|
|
117
|
+
// Helper to get regions
|
|
118
|
+
const getRegions = () => {
|
|
119
|
+
const language = options.getLanguage?.() || 'typescript';
|
|
120
|
+
return analyzer.analyze(editorState.lines, language);
|
|
121
|
+
};
|
|
122
|
+
// Helper to fold by category
|
|
123
|
+
const foldByCategory = (category, action) => {
|
|
124
|
+
const regions = getRegions();
|
|
125
|
+
const categoryRegions = analyzer.getByCategory(regions, category);
|
|
126
|
+
for (const region of categoryRegions) {
|
|
127
|
+
if (action === 'fold' && options.onFoldLines) {
|
|
128
|
+
options.onFoldLines(region.startLine, region.endLine);
|
|
129
|
+
}
|
|
130
|
+
else if (action === 'unfold' && options.onUnfoldLines) {
|
|
131
|
+
options.onUnfoldLines(region.startLine, region.endLine);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
// Category-based fold commands
|
|
136
|
+
const categoryCommands = [
|
|
137
|
+
{ category: 'imports', label: 'Imports', icon: '↓' },
|
|
138
|
+
{ category: 'exports', label: 'Exports', icon: '↑' },
|
|
139
|
+
{ category: 'types', label: 'Types/Interfaces', icon: 'T' },
|
|
140
|
+
{ category: 'function', label: 'Functions', icon: 'ƒ' },
|
|
141
|
+
{ category: 'class', label: 'Classes', icon: 'C' },
|
|
142
|
+
{ category: 'tests', label: 'Tests', icon: '✓' },
|
|
143
|
+
{ category: 'comments', label: 'Comments', icon: '#' },
|
|
144
|
+
{ category: 'error-handling', label: 'Error Handling', icon: '!' },
|
|
145
|
+
{ category: 'logging', label: 'Logging', icon: '⊙' },
|
|
146
|
+
{ category: 'private', label: 'Private Members', icon: '_' }
|
|
147
|
+
];
|
|
148
|
+
// Add fold/unfold commands for each category
|
|
149
|
+
for (const { category, label, icon } of categoryCommands) {
|
|
150
|
+
commands.push({
|
|
151
|
+
id: `fold.semantic.${category}`,
|
|
152
|
+
label: `Fold ${label}`,
|
|
153
|
+
category: 'fold.semantic',
|
|
154
|
+
description: `Collapse all ${label.toLowerCase()} in the document`,
|
|
155
|
+
icon,
|
|
156
|
+
execute: () => foldByCategory(category, 'fold')
|
|
157
|
+
}, {
|
|
158
|
+
id: `unfold.semantic.${category}`,
|
|
159
|
+
label: `Unfold ${label}`,
|
|
160
|
+
category: 'fold.semantic',
|
|
161
|
+
description: `Expand all ${label.toLowerCase()} in the document`,
|
|
162
|
+
icon,
|
|
163
|
+
execute: () => foldByCategory(category, 'unfold')
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
// Preset commands
|
|
167
|
+
for (const preset of DEFAULT_FOLD_PRESETS) {
|
|
168
|
+
commands.push({
|
|
169
|
+
id: `fold.preset.${preset.id}`,
|
|
170
|
+
label: `Apply Preset: ${preset.name}`,
|
|
171
|
+
category: 'fold.preset',
|
|
172
|
+
description: preset.description,
|
|
173
|
+
icon: preset.icon,
|
|
174
|
+
execute: () => options.onApplyPreset?.(preset)
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
// General fold commands
|
|
178
|
+
commands.push({
|
|
179
|
+
id: 'fold.all',
|
|
180
|
+
label: 'Fold All',
|
|
181
|
+
category: 'fold',
|
|
182
|
+
description: 'Collapse all foldable regions',
|
|
183
|
+
shortcut: 'Ctrl+K Ctrl+0',
|
|
184
|
+
icon: '▼',
|
|
185
|
+
execute: () => options.onFoldAll?.()
|
|
186
|
+
}, {
|
|
187
|
+
id: 'unfold.all',
|
|
188
|
+
label: 'Unfold All',
|
|
189
|
+
category: 'fold',
|
|
190
|
+
description: 'Expand all folded regions',
|
|
191
|
+
shortcut: 'Ctrl+K Ctrl+J',
|
|
192
|
+
icon: '▶',
|
|
193
|
+
execute: () => options.onUnfoldAll?.()
|
|
194
|
+
}, {
|
|
195
|
+
id: 'fold.showOnlyPublicAPI',
|
|
196
|
+
label: 'Show Only Public API',
|
|
197
|
+
category: 'fold.semantic',
|
|
198
|
+
description: 'Fold everything except exports and public methods',
|
|
199
|
+
icon: '◉',
|
|
200
|
+
execute: () => {
|
|
201
|
+
// Fold all first
|
|
202
|
+
options.onFoldAll?.();
|
|
203
|
+
// Then unfold exports
|
|
204
|
+
foldByCategory('exports', 'unfold');
|
|
205
|
+
}
|
|
206
|
+
}, {
|
|
207
|
+
id: 'fold.hideBoilerplate',
|
|
208
|
+
label: 'Hide Boilerplate',
|
|
209
|
+
category: 'fold.semantic',
|
|
210
|
+
description: 'Fold imports, types, and constants',
|
|
211
|
+
icon: '◌',
|
|
212
|
+
execute: () => {
|
|
213
|
+
foldByCategory('imports', 'fold');
|
|
214
|
+
foldByCategory('types', 'fold');
|
|
215
|
+
foldByCategory('constants', 'fold');
|
|
216
|
+
}
|
|
217
|
+
}, {
|
|
218
|
+
id: 'fold.focusFunction',
|
|
219
|
+
label: 'Focus Current Function',
|
|
220
|
+
category: 'fold.semantic',
|
|
221
|
+
description: 'Fold everything except the current function',
|
|
222
|
+
icon: 'ƒ',
|
|
223
|
+
execute: () => {
|
|
224
|
+
const cursorLine = editorState.selection.head.line;
|
|
225
|
+
const regions = getRegions();
|
|
226
|
+
const functions = analyzer.getByCategory(regions, 'function');
|
|
227
|
+
// Find function containing cursor
|
|
228
|
+
const currentFn = functions.find((r) => r.startLine <= cursorLine && r.endLine >= cursorLine);
|
|
229
|
+
if (currentFn) {
|
|
230
|
+
// Fold all
|
|
231
|
+
options.onFoldAll?.();
|
|
232
|
+
// Unfold current function
|
|
233
|
+
options.onUnfoldLines?.(currentFn.startLine, currentFn.endLine);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
return commands;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Register semantic fold commands with the global registry
|
|
241
|
+
*/
|
|
242
|
+
export function registerSemanticFoldCommands(editorState, options) {
|
|
243
|
+
const registry = getCommandRegistry();
|
|
244
|
+
const commands = createSemanticFoldCommands(editorState, options);
|
|
245
|
+
return registry.registerMany(commands);
|
|
246
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cognitive Complexity Analyzer
|
|
3
|
+
*
|
|
4
|
+
* Analyzes code complexity in real-time to help developers understand
|
|
5
|
+
* cognitive load and identify areas that may benefit from refactoring.
|
|
6
|
+
*
|
|
7
|
+
* Based on cognitive complexity research and common code quality metrics.
|
|
8
|
+
*/
|
|
9
|
+
import type { Line } from './state';
|
|
10
|
+
/**
|
|
11
|
+
* Complexity factors for a code region
|
|
12
|
+
*/
|
|
13
|
+
export interface ComplexityFactors {
|
|
14
|
+
/** Maximum nesting depth (if/for/while/try) */
|
|
15
|
+
nestingDepth: number;
|
|
16
|
+
/** Number of branching statements (if/else/switch/case/ternary) */
|
|
17
|
+
branchingFactor: number;
|
|
18
|
+
/** Total line count */
|
|
19
|
+
lineCount: number;
|
|
20
|
+
/** Number of unique identifiers */
|
|
21
|
+
identifierCount: number;
|
|
22
|
+
/** Number of function calls */
|
|
23
|
+
callCount: number;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* A region of code with its complexity analysis
|
|
27
|
+
*/
|
|
28
|
+
export interface ComplexityRegion {
|
|
29
|
+
/** Start line (0-based) */
|
|
30
|
+
startLine: number;
|
|
31
|
+
/** End line (0-based) */
|
|
32
|
+
endLine: number;
|
|
33
|
+
/** Complexity score (0-100) */
|
|
34
|
+
score: number;
|
|
35
|
+
/** Individual factors */
|
|
36
|
+
factors: ComplexityFactors;
|
|
37
|
+
/** Suggested improvement if score is high */
|
|
38
|
+
suggestion?: string;
|
|
39
|
+
/** Region type */
|
|
40
|
+
type: 'function' | 'class' | 'block' | 'file';
|
|
41
|
+
/** Region name if identifiable */
|
|
42
|
+
name?: string;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Overall complexity metrics for a document
|
|
46
|
+
*/
|
|
47
|
+
export interface ComplexityMetrics {
|
|
48
|
+
/** Overall complexity score (0-100) */
|
|
49
|
+
overall: number;
|
|
50
|
+
/** Complexity level for display */
|
|
51
|
+
level: 'low' | 'medium' | 'high' | 'critical';
|
|
52
|
+
/** Per-region breakdown */
|
|
53
|
+
regions: ComplexityRegion[];
|
|
54
|
+
/** Lines that exceed threshold */
|
|
55
|
+
hotspots: number[];
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Complexity Analyzer class
|
|
59
|
+
*/
|
|
60
|
+
export declare class ComplexityAnalyzer {
|
|
61
|
+
private cache;
|
|
62
|
+
private cacheKey;
|
|
63
|
+
/**
|
|
64
|
+
* Analyze complexity of the given lines
|
|
65
|
+
*/
|
|
66
|
+
analyze(lines: readonly Line[], language?: string): ComplexityMetrics;
|
|
67
|
+
/**
|
|
68
|
+
* Get complexity for a specific line
|
|
69
|
+
*/
|
|
70
|
+
getLineComplexity(metrics: ComplexityMetrics, line: number): number;
|
|
71
|
+
/**
|
|
72
|
+
* Check if a line is a hotspot
|
|
73
|
+
*/
|
|
74
|
+
isHotspot(metrics: ComplexityMetrics, line: number): boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Compute a cache key from all line content using a fast hash
|
|
77
|
+
*/
|
|
78
|
+
private computeCacheKey;
|
|
79
|
+
/**
|
|
80
|
+
* Identify code regions (functions, classes, blocks)
|
|
81
|
+
*
|
|
82
|
+
* Uses brace-depth tracking to correctly handle inline braces
|
|
83
|
+
* (object literals, destructuring) that don't represent new blocks.
|
|
84
|
+
*/
|
|
85
|
+
private identifyRegions;
|
|
86
|
+
/**
|
|
87
|
+
* Check if a `{` at position `ch` is the opening brace of a function/class definition
|
|
88
|
+
*/
|
|
89
|
+
private isDefOpeningBrace;
|
|
90
|
+
/**
|
|
91
|
+
* Analyze a specific region
|
|
92
|
+
*/
|
|
93
|
+
private analyzeRegion;
|
|
94
|
+
/**
|
|
95
|
+
* Calculate complexity factors for a range of lines
|
|
96
|
+
*/
|
|
97
|
+
private calculateFactors;
|
|
98
|
+
/**
|
|
99
|
+
* Calculate complexity score from factors
|
|
100
|
+
*/
|
|
101
|
+
private calculateScore;
|
|
102
|
+
/**
|
|
103
|
+
* Get suggestion based on factors
|
|
104
|
+
*/
|
|
105
|
+
private getSuggestion;
|
|
106
|
+
/**
|
|
107
|
+
* Find hotspot lines (lines in high-complexity regions)
|
|
108
|
+
*/
|
|
109
|
+
private findHotspots;
|
|
110
|
+
/**
|
|
111
|
+
* Calculate overall complexity
|
|
112
|
+
*/
|
|
113
|
+
private calculateOverall;
|
|
114
|
+
/**
|
|
115
|
+
* Get complexity level from score
|
|
116
|
+
*/
|
|
117
|
+
private getLevel;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Create a new complexity analyzer
|
|
121
|
+
*/
|
|
122
|
+
export declare function createComplexityAnalyzer(): ComplexityAnalyzer;
|
|
123
|
+
export declare function getComplexityAnalyzer(): ComplexityAnalyzer;
|