@nexus-cortex/tui 4.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/LICENSE +202 -0
- package/NOTICE +2 -0
- package/README.md +13 -0
- package/bin/cli-full.js +23 -0
- package/bin/cortex-ui.js +26 -0
- package/bin/ink-ui.js +108 -0
- package/bin/launcher-dev.js +266 -0
- package/bin/launcher.js +516 -0
- package/dist/commands/agent/InteractiveAgentMenu.d.ts +100 -0
- package/dist/commands/agent/InteractiveAgentMenu.d.ts.map +1 -0
- package/dist/commands/agent/InteractiveAgentMenu.js +909 -0
- package/dist/commands/agent/InteractiveAgentMenu.js.map +1 -0
- package/dist/commands/agent/index.d.ts +55 -0
- package/dist/commands/agent/index.d.ts.map +1 -0
- package/dist/commands/agent/index.js +714 -0
- package/dist/commands/agent/index.js.map +1 -0
- package/dist/commands/chat/interactive.d.ts +13 -0
- package/dist/commands/chat/interactive.d.ts.map +1 -0
- package/dist/commands/chat/interactive.js +2055 -0
- package/dist/commands/chat/interactive.js.map +1 -0
- package/dist/commands/system-message/EditorLauncher.d.ts +65 -0
- package/dist/commands/system-message/EditorLauncher.d.ts.map +1 -0
- package/dist/commands/system-message/EditorLauncher.js +143 -0
- package/dist/commands/system-message/EditorLauncher.js.map +1 -0
- package/dist/commands/system-message/InlineEditor.d.ts +23 -0
- package/dist/commands/system-message/InlineEditor.d.ts.map +1 -0
- package/dist/commands/system-message/InlineEditor.js +225 -0
- package/dist/commands/system-message/InlineEditor.js.map +1 -0
- package/dist/commands/system-message/InteractiveMenu.d.ts +76 -0
- package/dist/commands/system-message/InteractiveMenu.d.ts.map +1 -0
- package/dist/commands/system-message/InteractiveMenu.js +979 -0
- package/dist/commands/system-message/InteractiveMenu.js.map +1 -0
- package/dist/commands/system-message/index.d.ts +56 -0
- package/dist/commands/system-message/index.d.ts.map +1 -0
- package/dist/commands/system-message/index.js +694 -0
- package/dist/commands/system-message/index.js.map +1 -0
- package/dist/commands/ui/artifacts.d.ts +14 -0
- package/dist/commands/ui/artifacts.d.ts.map +1 -0
- package/dist/commands/ui/artifacts.js +22 -0
- package/dist/commands/ui/artifacts.js.map +1 -0
- package/dist/commands/ui/config.d.ts +12 -0
- package/dist/commands/ui/config.d.ts.map +1 -0
- package/dist/commands/ui/config.js +26 -0
- package/dist/commands/ui/config.js.map +1 -0
- package/dist/commands/ui/context.d.ts +16 -0
- package/dist/commands/ui/context.d.ts.map +1 -0
- package/dist/commands/ui/context.js +28 -0
- package/dist/commands/ui/context.js.map +1 -0
- package/dist/commands/ui/middleware.d.ts +14 -0
- package/dist/commands/ui/middleware.d.ts.map +1 -0
- package/dist/commands/ui/middleware.js +22 -0
- package/dist/commands/ui/middleware.js.map +1 -0
- package/dist/commands/ui/models.d.ts +14 -0
- package/dist/commands/ui/models.d.ts.map +1 -0
- package/dist/commands/ui/models.js +50 -0
- package/dist/commands/ui/models.js.map +1 -0
- package/dist/commands/ui/permissions.d.ts +14 -0
- package/dist/commands/ui/permissions.d.ts.map +1 -0
- package/dist/commands/ui/permissions.js +22 -0
- package/dist/commands/ui/permissions.js.map +1 -0
- package/dist/commands/ui/sessions.d.ts +13 -0
- package/dist/commands/ui/sessions.d.ts.map +1 -0
- package/dist/commands/ui/sessions.js +45 -0
- package/dist/commands/ui/sessions.js.map +1 -0
- package/dist/commands/ui/system-messages.d.ts +5 -0
- package/dist/commands/ui/system-messages.d.ts.map +1 -0
- package/dist/commands/ui/system-messages.js +19 -0
- package/dist/commands/ui/system-messages.js.map +1 -0
- package/dist/commands/ui/themes.d.ts +12 -0
- package/dist/commands/ui/themes.d.ts.map +1 -0
- package/dist/commands/ui/themes.js +40 -0
- package/dist/commands/ui/themes.js.map +1 -0
- package/dist/commands/ui/tmux.d.ts +5 -0
- package/dist/commands/ui/tmux.d.ts.map +1 -0
- package/dist/commands/ui/tmux.js +19 -0
- package/dist/commands/ui/tmux.js.map +1 -0
- package/dist/cortex.d.ts +12 -0
- package/dist/cortex.d.ts.map +1 -0
- package/dist/cortex.js +320 -0
- package/dist/cortex.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +112 -0
- package/dist/index.js.map +1 -0
- package/dist/ink-ui/CortexApp.d.ts +28 -0
- package/dist/ink-ui/CortexApp.d.ts.map +1 -0
- package/dist/ink-ui/CortexApp.js +2291 -0
- package/dist/ink-ui/CortexApp.js.map +1 -0
- package/dist/ink-ui/SimpleInputBuffer.d.ts +63 -0
- package/dist/ink-ui/SimpleInputBuffer.d.ts.map +1 -0
- package/dist/ink-ui/SimpleInputBuffer.js +369 -0
- package/dist/ink-ui/SimpleInputBuffer.js.map +1 -0
- package/dist/ink-ui/commands/slashCommands.d.ts +40 -0
- package/dist/ink-ui/commands/slashCommands.d.ts.map +1 -0
- package/dist/ink-ui/commands/slashCommands.js +111 -0
- package/dist/ink-ui/commands/slashCommands.js.map +1 -0
- package/dist/ink-ui/commands/types.d.ts +161 -0
- package/dist/ink-ui/commands/types.d.ts.map +1 -0
- package/dist/ink-ui/commands/types.js +12 -0
- package/dist/ink-ui/commands/types.js.map +1 -0
- package/dist/ink-ui/components/ApprovalDialog.d.ts +21 -0
- package/dist/ink-ui/components/ApprovalDialog.d.ts.map +1 -0
- package/dist/ink-ui/components/ApprovalDialog.js +81 -0
- package/dist/ink-ui/components/ApprovalDialog.js.map +1 -0
- package/dist/ink-ui/components/CommandSuggestions.d.ts +19 -0
- package/dist/ink-ui/components/CommandSuggestions.d.ts.map +1 -0
- package/dist/ink-ui/components/CommandSuggestions.js +36 -0
- package/dist/ink-ui/components/CommandSuggestions.js.map +1 -0
- package/dist/ink-ui/components/DiffPreview.d.ts +60 -0
- package/dist/ink-ui/components/DiffPreview.d.ts.map +1 -0
- package/dist/ink-ui/components/DiffPreview.js +195 -0
- package/dist/ink-ui/components/DiffPreview.js.map +1 -0
- package/dist/ink-ui/components/DocumentPreview.d.ts +50 -0
- package/dist/ink-ui/components/DocumentPreview.d.ts.map +1 -0
- package/dist/ink-ui/components/DocumentPreview.js +92 -0
- package/dist/ink-ui/components/DocumentPreview.js.map +1 -0
- package/dist/ink-ui/components/MarkdownText.d.ts +27 -0
- package/dist/ink-ui/components/MarkdownText.d.ts.map +1 -0
- package/dist/ink-ui/components/MarkdownText.js +342 -0
- package/dist/ink-ui/components/MarkdownText.js.map +1 -0
- package/dist/ink-ui/components/MenuRenderer.d.ts +26 -0
- package/dist/ink-ui/components/MenuRenderer.d.ts.map +1 -0
- package/dist/ink-ui/components/MenuRenderer.js +264 -0
- package/dist/ink-ui/components/MenuRenderer.js.map +1 -0
- package/dist/ink-ui/components/ModelPickerDialog.d.ts +33 -0
- package/dist/ink-ui/components/ModelPickerDialog.d.ts.map +1 -0
- package/dist/ink-ui/components/ModelPickerDialog.js +98 -0
- package/dist/ink-ui/components/ModelPickerDialog.js.map +1 -0
- package/dist/ink-ui/components/StreamDisplay.d.ts +31 -0
- package/dist/ink-ui/components/StreamDisplay.d.ts.map +1 -0
- package/dist/ink-ui/components/StreamDisplay.js +573 -0
- package/dist/ink-ui/components/StreamDisplay.js.map +1 -0
- package/dist/ink-ui/components/SubAgentPanel.d.ts +98 -0
- package/dist/ink-ui/components/SubAgentPanel.d.ts.map +1 -0
- package/dist/ink-ui/components/SubAgentPanel.js +155 -0
- package/dist/ink-ui/components/SubAgentPanel.js.map +1 -0
- package/dist/ink-ui/components/ThinkingDisplay.d.ts +46 -0
- package/dist/ink-ui/components/ThinkingDisplay.d.ts.map +1 -0
- package/dist/ink-ui/components/ThinkingDisplay.js +176 -0
- package/dist/ink-ui/components/ThinkingDisplay.js.map +1 -0
- package/dist/ink-ui/components/ToolCallDisplay.d.ts +51 -0
- package/dist/ink-ui/components/ToolCallDisplay.d.ts.map +1 -0
- package/dist/ink-ui/components/ToolCallDisplay.js +378 -0
- package/dist/ink-ui/components/ToolCallDisplay.js.map +1 -0
- package/dist/ink-ui/components/WritePreview.d.ts +42 -0
- package/dist/ink-ui/components/WritePreview.d.ts.map +1 -0
- package/dist/ink-ui/components/WritePreview.js +100 -0
- package/dist/ink-ui/components/WritePreview.js.map +1 -0
- package/dist/ink-ui/contexts/KeypressContext.d.ts +32 -0
- package/dist/ink-ui/contexts/KeypressContext.d.ts.map +1 -0
- package/dist/ink-ui/contexts/KeypressContext.js +529 -0
- package/dist/ink-ui/contexts/KeypressContext.js.map +1 -0
- package/dist/ink-ui/contexts/SessionContext.d.ts +46 -0
- package/dist/ink-ui/contexts/SessionContext.d.ts.map +1 -0
- package/dist/ink-ui/contexts/SessionContext.js +162 -0
- package/dist/ink-ui/contexts/SessionContext.js.map +1 -0
- package/dist/ink-ui/core-stubs.d.ts +270 -0
- package/dist/ink-ui/core-stubs.d.ts.map +1 -0
- package/dist/ink-ui/core-stubs.js +276 -0
- package/dist/ink-ui/core-stubs.js.map +1 -0
- package/dist/ink-ui/cortex-types.d.ts +214 -0
- package/dist/ink-ui/cortex-types.d.ts.map +1 -0
- package/dist/ink-ui/cortex-types.js +52 -0
- package/dist/ink-ui/cortex-types.js.map +1 -0
- package/dist/ink-ui/hooks/useCortexStream.d.ts +75 -0
- package/dist/ink-ui/hooks/useCortexStream.d.ts.map +1 -0
- package/dist/ink-ui/hooks/useCortexStream.js +518 -0
- package/dist/ink-ui/hooks/useCortexStream.js.map +1 -0
- package/dist/ink-ui/hooks/useFocus.d.ts +11 -0
- package/dist/ink-ui/hooks/useFocus.d.ts.map +1 -0
- package/dist/ink-ui/hooks/useFocus.js +51 -0
- package/dist/ink-ui/hooks/useFocus.js.map +1 -0
- package/dist/ink-ui/hooks/useHistoryManager.d.ts +23 -0
- package/dist/ink-ui/hooks/useHistoryManager.d.ts.map +1 -0
- package/dist/ink-ui/hooks/useHistoryManager.js +63 -0
- package/dist/ink-ui/hooks/useHistoryManager.js.map +1 -0
- package/dist/ink-ui/hooks/useKeypress.d.ts +18 -0
- package/dist/ink-ui/hooks/useKeypress.d.ts.map +1 -0
- package/dist/ink-ui/hooks/useKeypress.js +27 -0
- package/dist/ink-ui/hooks/useKeypress.js.map +1 -0
- package/dist/ink-ui/hooks/useReactApprovalHandler.d.ts +74 -0
- package/dist/ink-ui/hooks/useReactApprovalHandler.d.ts.map +1 -0
- package/dist/ink-ui/hooks/useReactApprovalHandler.js +83 -0
- package/dist/ink-ui/hooks/useReactApprovalHandler.js.map +1 -0
- package/dist/ink-ui/hooks/useTerminalSize.d.ts +10 -0
- package/dist/ink-ui/hooks/useTerminalSize.d.ts.map +1 -0
- package/dist/ink-ui/hooks/useTerminalSize.js +28 -0
- package/dist/ink-ui/hooks/useTerminalSize.js.map +1 -0
- package/dist/ink-ui/semantic-colors.d.ts +8 -0
- package/dist/ink-ui/semantic-colors.d.ts.map +1 -0
- package/dist/ink-ui/semantic-colors.js +24 -0
- package/dist/ink-ui/semantic-colors.js.map +1 -0
- package/dist/ink-ui/state/extensions.d.ts +68 -0
- package/dist/ink-ui/state/extensions.d.ts.map +1 -0
- package/dist/ink-ui/state/extensions.js +97 -0
- package/dist/ink-ui/state/extensions.js.map +1 -0
- package/dist/ink-ui/themes/ansi-light.d.ts +8 -0
- package/dist/ink-ui/themes/ansi-light.d.ts.map +1 -0
- package/dist/ink-ui/themes/ansi-light.js +143 -0
- package/dist/ink-ui/themes/ansi-light.js.map +1 -0
- package/dist/ink-ui/themes/ansi.d.ts +8 -0
- package/dist/ink-ui/themes/ansi.d.ts.map +1 -0
- package/dist/ink-ui/themes/ansi.js +153 -0
- package/dist/ink-ui/themes/ansi.js.map +1 -0
- package/dist/ink-ui/themes/atom-one-dark.d.ts +8 -0
- package/dist/ink-ui/themes/atom-one-dark.d.ts.map +1 -0
- package/dist/ink-ui/themes/atom-one-dark.js +140 -0
- package/dist/ink-ui/themes/atom-one-dark.js.map +1 -0
- package/dist/ink-ui/themes/ayu-light.d.ts +8 -0
- package/dist/ink-ui/themes/ayu-light.d.ts.map +1 -0
- package/dist/ink-ui/themes/ayu-light.js +132 -0
- package/dist/ink-ui/themes/ayu-light.js.map +1 -0
- package/dist/ink-ui/themes/ayu.d.ts +8 -0
- package/dist/ink-ui/themes/ayu.d.ts.map +1 -0
- package/dist/ink-ui/themes/ayu.js +106 -0
- package/dist/ink-ui/themes/ayu.js.map +1 -0
- package/dist/ink-ui/themes/color-utils.d.ts +23 -0
- package/dist/ink-ui/themes/color-utils.d.ts.map +1 -0
- package/dist/ink-ui/themes/color-utils.js +237 -0
- package/dist/ink-ui/themes/color-utils.js.map +1 -0
- package/dist/ink-ui/themes/default-light.d.ts +8 -0
- package/dist/ink-ui/themes/default-light.d.ts.map +1 -0
- package/dist/ink-ui/themes/default-light.js +100 -0
- package/dist/ink-ui/themes/default-light.js.map +1 -0
- package/dist/ink-ui/themes/default.d.ts +8 -0
- package/dist/ink-ui/themes/default.d.ts.map +1 -0
- package/dist/ink-ui/themes/default.js +143 -0
- package/dist/ink-ui/themes/default.js.map +1 -0
- package/dist/ink-ui/themes/dracula.d.ts +8 -0
- package/dist/ink-ui/themes/dracula.d.ts.map +1 -0
- package/dist/ink-ui/themes/dracula.js +117 -0
- package/dist/ink-ui/themes/dracula.js.map +1 -0
- package/dist/ink-ui/themes/github-dark.d.ts +8 -0
- package/dist/ink-ui/themes/github-dark.d.ts.map +1 -0
- package/dist/ink-ui/themes/github-dark.js +140 -0
- package/dist/ink-ui/themes/github-dark.js.map +1 -0
- package/dist/ink-ui/themes/github-light.d.ts +8 -0
- package/dist/ink-ui/themes/github-light.d.ts.map +1 -0
- package/dist/ink-ui/themes/github-light.js +142 -0
- package/dist/ink-ui/themes/github-light.js.map +1 -0
- package/dist/ink-ui/themes/googlecode.d.ts +8 -0
- package/dist/ink-ui/themes/googlecode.d.ts.map +1 -0
- package/dist/ink-ui/themes/googlecode.js +139 -0
- package/dist/ink-ui/themes/googlecode.js.map +1 -0
- package/dist/ink-ui/themes/no-color.d.ts +8 -0
- package/dist/ink-ui/themes/no-color.d.ts.map +1 -0
- package/dist/ink-ui/themes/no-color.js +118 -0
- package/dist/ink-ui/themes/no-color.js.map +1 -0
- package/dist/ink-ui/themes/semantic-tokens.d.ts +40 -0
- package/dist/ink-ui/themes/semantic-tokens.d.ts.map +1 -0
- package/dist/ink-ui/themes/semantic-tokens.js +100 -0
- package/dist/ink-ui/themes/semantic-tokens.js.map +1 -0
- package/dist/ink-ui/themes/shades-of-purple.d.ts +12 -0
- package/dist/ink-ui/themes/shades-of-purple.d.ts.map +1 -0
- package/dist/ink-ui/themes/shades-of-purple.js +306 -0
- package/dist/ink-ui/themes/shades-of-purple.js.map +1 -0
- package/dist/ink-ui/themes/theme-manager.d.ts +67 -0
- package/dist/ink-ui/themes/theme-manager.d.ts.map +1 -0
- package/dist/ink-ui/themes/theme-manager.js +263 -0
- package/dist/ink-ui/themes/theme-manager.js.map +1 -0
- package/dist/ink-ui/themes/theme.d.ts +134 -0
- package/dist/ink-ui/themes/theme.d.ts.map +1 -0
- package/dist/ink-ui/themes/theme.js +390 -0
- package/dist/ink-ui/themes/theme.js.map +1 -0
- package/dist/ink-ui/themes/xcode.d.ts +8 -0
- package/dist/ink-ui/themes/xcode.d.ts.map +1 -0
- package/dist/ink-ui/themes/xcode.js +147 -0
- package/dist/ink-ui/themes/xcode.js.map +1 -0
- package/dist/ink-ui/types.d.ts +306 -0
- package/dist/ink-ui/types.d.ts.map +1 -0
- package/dist/ink-ui/types.js +65 -0
- package/dist/ink-ui/types.js.map +1 -0
- package/dist/ink-ui/utils/input.d.ts +18 -0
- package/dist/ink-ui/utils/input.d.ts.map +1 -0
- package/dist/ink-ui/utils/input.js +51 -0
- package/dist/ink-ui/utils/input.js.map +1 -0
- package/dist/ink-ui/utils/mouse.d.ts +33 -0
- package/dist/ink-ui/utils/mouse.d.ts.map +1 -0
- package/dist/ink-ui/utils/mouse.js +182 -0
- package/dist/ink-ui/utils/mouse.js.map +1 -0
- package/dist/services/BuiltinCommandLoader.d.ts +21 -0
- package/dist/services/BuiltinCommandLoader.d.ts.map +1 -0
- package/dist/services/BuiltinCommandLoader.js +182 -0
- package/dist/services/BuiltinCommandLoader.js.map +1 -0
- package/dist/services/CommandService.d.ts +39 -0
- package/dist/services/CommandService.d.ts.map +1 -0
- package/dist/services/CommandService.js +49 -0
- package/dist/services/CommandService.js.map +1 -0
- package/dist/services/FileCommandLoader.d.ts +16 -0
- package/dist/services/FileCommandLoader.d.ts.map +1 -0
- package/dist/services/FileCommandLoader.js +19 -0
- package/dist/services/FileCommandLoader.js.map +1 -0
- package/dist/services/McpPromptLoader.d.ts +16 -0
- package/dist/services/McpPromptLoader.d.ts.map +1 -0
- package/dist/services/McpPromptLoader.js +19 -0
- package/dist/services/McpPromptLoader.js.map +1 -0
- package/dist/services/index.d.ts +8 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/index.js +8 -0
- package/dist/services/index.js.map +1 -0
- package/dist/ui/ChalkMenuRenderer.d.ts +22 -0
- package/dist/ui/ChalkMenuRenderer.d.ts.map +1 -0
- package/dist/ui/ChalkMenuRenderer.js +478 -0
- package/dist/ui/ChalkMenuRenderer.js.map +1 -0
- package/dist/ui/ChalkModelPicker.d.ts +20 -0
- package/dist/ui/ChalkModelPicker.d.ts.map +1 -0
- package/dist/ui/ChalkModelPicker.js +363 -0
- package/dist/ui/ChalkModelPicker.js.map +1 -0
- package/dist/ui/ChalkThemePicker.d.ts +20 -0
- package/dist/ui/ChalkThemePicker.d.ts.map +1 -0
- package/dist/ui/ChalkThemePicker.js +370 -0
- package/dist/ui/ChalkThemePicker.js.map +1 -0
- package/dist/ui/InkApprovalDialog.d.ts +8 -0
- package/dist/ui/InkApprovalDialog.d.ts.map +1 -0
- package/dist/ui/InkApprovalDialog.js +25 -0
- package/dist/ui/InkApprovalDialog.js.map +1 -0
- package/dist/ui/InkCommandPalette.d.ts +43 -0
- package/dist/ui/InkCommandPalette.d.ts.map +1 -0
- package/dist/ui/InkCommandPalette.js +105 -0
- package/dist/ui/InkCommandPalette.js.map +1 -0
- package/dist/ui/InkConfigMenu.d.ts +24 -0
- package/dist/ui/InkConfigMenu.d.ts.map +1 -0
- package/dist/ui/InkConfigMenu.js +259 -0
- package/dist/ui/InkConfigMenu.js.map +1 -0
- package/dist/ui/InkHelp.d.ts +25 -0
- package/dist/ui/InkHelp.d.ts.map +1 -0
- package/dist/ui/InkHelp.js +55 -0
- package/dist/ui/InkHelp.js.map +1 -0
- package/dist/ui/InkMenuPicker.d.ts +19 -0
- package/dist/ui/InkMenuPicker.d.ts.map +1 -0
- package/dist/ui/InkMenuPicker.js +33 -0
- package/dist/ui/InkMenuPicker.js.map +1 -0
- package/dist/ui/InkModelPicker.d.ts +23 -0
- package/dist/ui/InkModelPicker.d.ts.map +1 -0
- package/dist/ui/InkModelPicker.js +53 -0
- package/dist/ui/InkModelPicker.js.map +1 -0
- package/dist/ui/PersistentInput.d.ts +91 -0
- package/dist/ui/PersistentInput.d.ts.map +1 -0
- package/dist/ui/PersistentInput.js +283 -0
- package/dist/ui/PersistentInput.js.map +1 -0
- package/dist/ui/RawInput.d.ts +27 -0
- package/dist/ui/RawInput.d.ts.map +1 -0
- package/dist/ui/RawInput.js +731 -0
- package/dist/ui/RawInput.js.map +1 -0
- package/dist/ui/SlashCommandAutocomplete.d.ts +94 -0
- package/dist/ui/SlashCommandAutocomplete.d.ts.map +1 -0
- package/dist/ui/SlashCommandAutocomplete.js +274 -0
- package/dist/ui/SlashCommandAutocomplete.js.map +1 -0
- package/dist/ui/SplashScreen.d.ts +76 -0
- package/dist/ui/SplashScreen.d.ts.map +1 -0
- package/dist/ui/SplashScreen.js +316 -0
- package/dist/ui/SplashScreen.js.map +1 -0
- package/dist/ui/components/ArtifactDashboard.d.ts +16 -0
- package/dist/ui/components/ArtifactDashboard.d.ts.map +1 -0
- package/dist/ui/components/ArtifactDashboard.js +102 -0
- package/dist/ui/components/ArtifactDashboard.js.map +1 -0
- package/dist/ui/components/ChatInput.d.ts +36 -0
- package/dist/ui/components/ChatInput.d.ts.map +1 -0
- package/dist/ui/components/ChatInput.js +11 -0
- package/dist/ui/components/ChatInput.js.map +1 -0
- package/dist/ui/components/ConfigWizard.d.ts +17 -0
- package/dist/ui/components/ConfigWizard.d.ts.map +1 -0
- package/dist/ui/components/ConfigWizard.js +134 -0
- package/dist/ui/components/ConfigWizard.js.map +1 -0
- package/dist/ui/components/ContextViewer.d.ts +18 -0
- package/dist/ui/components/ContextViewer.d.ts.map +1 -0
- package/dist/ui/components/ContextViewer.js +85 -0
- package/dist/ui/components/ContextViewer.js.map +1 -0
- package/dist/ui/components/MiddlewareDashboard.d.ts +16 -0
- package/dist/ui/components/MiddlewareDashboard.d.ts.map +1 -0
- package/dist/ui/components/MiddlewareDashboard.js +98 -0
- package/dist/ui/components/MiddlewareDashboard.js.map +1 -0
- package/dist/ui/components/ModelPicker.d.ts +24 -0
- package/dist/ui/components/ModelPicker.d.ts.map +1 -0
- package/dist/ui/components/ModelPicker.js +96 -0
- package/dist/ui/components/ModelPicker.js.map +1 -0
- package/dist/ui/components/MultiLineInput.d.ts +27 -0
- package/dist/ui/components/MultiLineInput.d.ts.map +1 -0
- package/dist/ui/components/MultiLineInput.js +182 -0
- package/dist/ui/components/MultiLineInput.js.map +1 -0
- package/dist/ui/components/PermissionsBrowser.d.ts +16 -0
- package/dist/ui/components/PermissionsBrowser.d.ts.map +1 -0
- package/dist/ui/components/PermissionsBrowser.js +110 -0
- package/dist/ui/components/PermissionsBrowser.js.map +1 -0
- package/dist/ui/components/SessionBrowser.d.ts +19 -0
- package/dist/ui/components/SessionBrowser.d.ts.map +1 -0
- package/dist/ui/components/SessionBrowser.js +66 -0
- package/dist/ui/components/SessionBrowser.js.map +1 -0
- package/dist/ui/components/StatusBar.d.ts +32 -0
- package/dist/ui/components/StatusBar.d.ts.map +1 -0
- package/dist/ui/components/StatusBar.js +27 -0
- package/dist/ui/components/StatusBar.js.map +1 -0
- package/dist/ui/components/SystemMessageBrowser.d.ts +11 -0
- package/dist/ui/components/SystemMessageBrowser.d.ts.map +1 -0
- package/dist/ui/components/SystemMessageBrowser.js +106 -0
- package/dist/ui/components/SystemMessageBrowser.js.map +1 -0
- package/dist/ui/components/ThemePicker.d.ts +11 -0
- package/dist/ui/components/ThemePicker.d.ts.map +1 -0
- package/dist/ui/components/ThemePicker.js +62 -0
- package/dist/ui/components/ThemePicker.js.map +1 -0
- package/dist/ui/components/TmuxBrowser.d.ts +11 -0
- package/dist/ui/components/TmuxBrowser.d.ts.map +1 -0
- package/dist/ui/components/TmuxBrowser.js +85 -0
- package/dist/ui/components/TmuxBrowser.js.map +1 -0
- package/dist/ui/components/index.d.ts +22 -0
- package/dist/ui/components/index.d.ts.map +1 -0
- package/dist/ui/components/index.js +21 -0
- package/dist/ui/components/index.js.map +1 -0
- package/package.json +70 -0
|
@@ -0,0 +1,714 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Management Command
|
|
3
|
+
*
|
|
4
|
+
* Entry point for /agent slash command
|
|
5
|
+
* Launches interactive menu for managing Task Agent profiles
|
|
6
|
+
* with AI-powered agent creation
|
|
7
|
+
*/
|
|
8
|
+
import React from 'react';
|
|
9
|
+
import { render } from 'ink';
|
|
10
|
+
import { AgentStore, resolveProjectAgentsDir } from '@nexus-cortex/core';
|
|
11
|
+
import { InteractiveAgentMenu, } from './InteractiveAgentMenu.js';
|
|
12
|
+
import * as fs from 'fs/promises';
|
|
13
|
+
/**
|
|
14
|
+
* System prompt for generating agent profiles
|
|
15
|
+
*/
|
|
16
|
+
const AGENT_GENERATOR_PROMPT = `You are an expert at designing Task Agent profiles for an AI development CLI.
|
|
17
|
+
|
|
18
|
+
Given a user's description of what they want an agent to do, generate a complete agent profile.
|
|
19
|
+
|
|
20
|
+
IMPORTANT: Your response must be ONLY valid JSON with no markdown code fences or other text.
|
|
21
|
+
|
|
22
|
+
The JSON must have exactly these fields:
|
|
23
|
+
{
|
|
24
|
+
"name": "agent-name-in-kebab-case",
|
|
25
|
+
"description": "A clear, concise description of what this agent does (max 200 chars)",
|
|
26
|
+
"tools": ["Tool1", "Tool2"] or "all",
|
|
27
|
+
"systemPrompt": "The complete system prompt for the agent"
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
Available tools to choose from:
|
|
31
|
+
- Read: Read file contents
|
|
32
|
+
- Write: Write/create files
|
|
33
|
+
- Edit: Edit existing files
|
|
34
|
+
- Glob: Find files by pattern
|
|
35
|
+
- Grep: Search file contents
|
|
36
|
+
- Bash: Execute shell commands
|
|
37
|
+
- WebSearch: Search the web
|
|
38
|
+
- WebFetch: Fetch web pages
|
|
39
|
+
- TodoCreate: Create individual tasks
|
|
40
|
+
- TodoUpdate: Update task status by ID
|
|
41
|
+
- TodoList: List all tasks with progress
|
|
42
|
+
- AskUserQuestion: Ask user questions
|
|
43
|
+
|
|
44
|
+
Guidelines for the system prompt:
|
|
45
|
+
1. Start with a clear role definition ("You are a...")
|
|
46
|
+
2. List the agent's key responsibilities
|
|
47
|
+
3. Include approach/methodology section
|
|
48
|
+
4. Add specific guidelines and constraints
|
|
49
|
+
5. Define output format expectations
|
|
50
|
+
6. Be specific and actionable
|
|
51
|
+
|
|
52
|
+
Guidelines for tool selection:
|
|
53
|
+
- Only include tools the agent actually needs
|
|
54
|
+
- Use "all" only for agents that truly need unrestricted access
|
|
55
|
+
- Read-only agents: Read, Glob, Grep
|
|
56
|
+
- Analysis agents: Read, Glob, Grep, maybe WebSearch
|
|
57
|
+
- Code modification agents: Read, Write, Edit, Glob, Grep, Bash
|
|
58
|
+
- Research agents: Read, Glob, Grep, WebSearch, WebFetch
|
|
59
|
+
|
|
60
|
+
The name should be:
|
|
61
|
+
- Lowercase, hyphenated (kebab-case)
|
|
62
|
+
- Descriptive but concise (max 32 chars)
|
|
63
|
+
- No special characters except hyphens`;
|
|
64
|
+
/**
|
|
65
|
+
* Create an AI profile generator using the orchestrator
|
|
66
|
+
*/
|
|
67
|
+
function createProfileGenerator(orchestratorClient) {
|
|
68
|
+
return async (description, _selectedModel) => {
|
|
69
|
+
const prompt = `Create an agent profile for the following description:
|
|
70
|
+
|
|
71
|
+
"${description}"
|
|
72
|
+
|
|
73
|
+
Remember: Respond with ONLY valid JSON, no markdown code fences.`;
|
|
74
|
+
try {
|
|
75
|
+
// Send message to orchestrator with system prompt for agent generation
|
|
76
|
+
const response = await orchestratorClient.sendMessage(prompt, {
|
|
77
|
+
system: AGENT_GENERATOR_PROMPT,
|
|
78
|
+
temperature: 0.7,
|
|
79
|
+
});
|
|
80
|
+
// Extract the response text
|
|
81
|
+
let responseText = '';
|
|
82
|
+
if (typeof response === 'string') {
|
|
83
|
+
responseText = response;
|
|
84
|
+
}
|
|
85
|
+
else if (response && typeof response === 'object') {
|
|
86
|
+
// Handle streaming or complex response
|
|
87
|
+
if ('text' in response) {
|
|
88
|
+
responseText = response.text;
|
|
89
|
+
}
|
|
90
|
+
else if ('content' in response && Array.isArray(response.content)) {
|
|
91
|
+
for (const block of response.content) {
|
|
92
|
+
if (block && typeof block === 'object' && 'text' in block) {
|
|
93
|
+
responseText += block.text;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
// Try to extract JSON from the response
|
|
99
|
+
let jsonStr = responseText.trim();
|
|
100
|
+
// Remove markdown code fences if present
|
|
101
|
+
const jsonMatch = jsonStr.match(/```(?:json)?\s*([\s\S]*?)```/);
|
|
102
|
+
if (jsonMatch) {
|
|
103
|
+
jsonStr = jsonMatch[1]?.trim() || jsonStr;
|
|
104
|
+
}
|
|
105
|
+
// Find JSON object boundaries
|
|
106
|
+
const startBrace = jsonStr.indexOf('{');
|
|
107
|
+
const endBrace = jsonStr.lastIndexOf('}');
|
|
108
|
+
if (startBrace !== -1 && endBrace !== -1) {
|
|
109
|
+
jsonStr = jsonStr.slice(startBrace, endBrace + 1);
|
|
110
|
+
}
|
|
111
|
+
// Parse the JSON
|
|
112
|
+
const profile = JSON.parse(jsonStr);
|
|
113
|
+
// Validate required fields
|
|
114
|
+
if (!profile.name || typeof profile.name !== 'string') {
|
|
115
|
+
throw new Error('Invalid profile: missing or invalid name');
|
|
116
|
+
}
|
|
117
|
+
if (!profile.description || typeof profile.description !== 'string') {
|
|
118
|
+
throw new Error('Invalid profile: missing or invalid description');
|
|
119
|
+
}
|
|
120
|
+
if (!profile.tools || (profile.tools !== 'all' && !Array.isArray(profile.tools))) {
|
|
121
|
+
throw new Error('Invalid profile: missing or invalid tools');
|
|
122
|
+
}
|
|
123
|
+
if (!profile.systemPrompt || typeof profile.systemPrompt !== 'string') {
|
|
124
|
+
throw new Error('Invalid profile: missing or invalid systemPrompt');
|
|
125
|
+
}
|
|
126
|
+
// Sanitize name
|
|
127
|
+
const safeName = profile.name
|
|
128
|
+
.toLowerCase()
|
|
129
|
+
.replace(/[^a-z0-9-]/g, '-')
|
|
130
|
+
.replace(/--+/g, '-')
|
|
131
|
+
.replace(/^-|-$/g, '')
|
|
132
|
+
.slice(0, 32);
|
|
133
|
+
return {
|
|
134
|
+
name: safeName || `agent-${Date.now()}`,
|
|
135
|
+
description: profile.description.slice(0, 200),
|
|
136
|
+
tools: profile.tools,
|
|
137
|
+
systemPrompt: profile.systemPrompt,
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
catch (error) {
|
|
141
|
+
// If JSON parsing fails, create a fallback profile
|
|
142
|
+
console.error('Failed to parse AI response:', error.message);
|
|
143
|
+
const safeName = description
|
|
144
|
+
.toLowerCase()
|
|
145
|
+
.replace(/[^a-z0-9]+/g, '-')
|
|
146
|
+
.replace(/^-|-$/g, '')
|
|
147
|
+
.slice(0, 32) || `agent-${Date.now()}`;
|
|
148
|
+
return {
|
|
149
|
+
name: safeName,
|
|
150
|
+
description: description.slice(0, 200),
|
|
151
|
+
tools: ['Read', 'Glob', 'Grep', 'Write', 'Edit'],
|
|
152
|
+
systemPrompt: `# ${safeName}\n\n${description}\n\n## Your Role\n\nYou are a specialized agent designed to help with the tasks described above.\n\n## Guidelines\n\n- Be thorough and methodical in your approach\n- Explain your reasoning clearly\n- Ask for clarification when requirements are ambiguous\n- Focus on quality over speed`,
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
const AGENT_DOMAINS = [
|
|
158
|
+
{
|
|
159
|
+
domainName: 'frontend',
|
|
160
|
+
keywords: ['landing', 'page', 'ui', 'ux', 'design', 'frontend', 'react', 'vue', 'html', 'css', 'website', 'web', 'interface', 'component', 'layout'],
|
|
161
|
+
suggestedTools: ['Read', 'Write', 'Edit', 'Glob', 'Grep', 'Bash', 'WebFetch'],
|
|
162
|
+
followUpQuestions: [
|
|
163
|
+
'What tech stack should this agent use? (React, Vue, vanilla HTML/CSS, Tailwind, etc.)',
|
|
164
|
+
'Should the agent focus on responsive design, accessibility, or specific design patterns?',
|
|
165
|
+
'What style/aesthetic should the generated designs follow? (minimal, corporate, playful, dark mode, etc.)',
|
|
166
|
+
],
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
domainName: 'backend',
|
|
170
|
+
keywords: ['api', 'server', 'backend', 'database', 'rest', 'graphql', 'endpoint', 'service', 'microservice'],
|
|
171
|
+
suggestedTools: ['Read', 'Write', 'Edit', 'Glob', 'Grep', 'Bash'],
|
|
172
|
+
followUpQuestions: [
|
|
173
|
+
'What language/framework should this agent work with? (Node.js, Python, Go, etc.)',
|
|
174
|
+
'Should it handle database operations, authentication, or API design?',
|
|
175
|
+
'Are there specific patterns to follow? (REST, GraphQL, middleware patterns)',
|
|
176
|
+
],
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
domainName: 'security',
|
|
180
|
+
keywords: ['security', 'audit', 'vulnerability', 'pentest', 'owasp', 'scan', 'exploit', 'secure', 'authentication', 'authorization'],
|
|
181
|
+
suggestedTools: ['Read', 'Glob', 'Grep', 'Bash', 'WebSearch'],
|
|
182
|
+
followUpQuestions: [
|
|
183
|
+
'What type of security analysis? (code review, dependency scanning, penetration testing concepts)',
|
|
184
|
+
'Should it check for specific vulnerability types? (OWASP Top 10, CWE categories)',
|
|
185
|
+
'Should it provide remediation guidance or just identify issues?',
|
|
186
|
+
],
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
domainName: 'testing',
|
|
190
|
+
keywords: ['test', 'testing', 'unit', 'integration', 'e2e', 'spec', 'coverage', 'qa', 'quality'],
|
|
191
|
+
suggestedTools: ['Read', 'Write', 'Edit', 'Glob', 'Grep', 'Bash'],
|
|
192
|
+
followUpQuestions: [
|
|
193
|
+
'What testing framework should it use? (Jest, Vitest, pytest, etc.)',
|
|
194
|
+
'What types of tests? (unit, integration, e2e, snapshot)',
|
|
195
|
+
'Should it focus on coverage goals or specific testing patterns?',
|
|
196
|
+
],
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
domainName: 'documentation',
|
|
200
|
+
keywords: ['doc', 'documentation', 'readme', 'comment', 'jsdoc', 'api doc', 'guide', 'tutorial', 'explain'],
|
|
201
|
+
suggestedTools: ['Read', 'Write', 'Edit', 'Glob', 'Grep'],
|
|
202
|
+
followUpQuestions: [
|
|
203
|
+
'What documentation format? (Markdown, JSDoc, API docs, README)',
|
|
204
|
+
'Should it generate examples, diagrams, or just text descriptions?',
|
|
205
|
+
'What audience level? (beginner-friendly, technical reference, internal team)',
|
|
206
|
+
],
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
domainName: 'refactoring',
|
|
210
|
+
keywords: ['refactor', 'clean', 'optimize', 'improve', 'restructure', 'modernize', 'migrate', 'upgrade'],
|
|
211
|
+
suggestedTools: ['Read', 'Write', 'Edit', 'Glob', 'Grep', 'Bash'],
|
|
212
|
+
followUpQuestions: [
|
|
213
|
+
'What aspects to focus on? (performance, readability, maintainability, patterns)',
|
|
214
|
+
'Are there specific coding standards or style guides to follow?',
|
|
215
|
+
'Should it preserve backward compatibility or make breaking changes?',
|
|
216
|
+
],
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
domainName: 'devops',
|
|
220
|
+
keywords: ['deploy', 'docker', 'kubernetes', 'ci', 'cd', 'pipeline', 'infrastructure', 'aws', 'cloud', 'terraform'],
|
|
221
|
+
suggestedTools: ['Read', 'Write', 'Edit', 'Glob', 'Grep', 'Bash'],
|
|
222
|
+
followUpQuestions: [
|
|
223
|
+
'What platform/tools? (Docker, Kubernetes, AWS, GCP, Azure)',
|
|
224
|
+
'What type of automation? (CI/CD pipelines, infrastructure as code, monitoring)',
|
|
225
|
+
'Should it handle secrets management or environment configuration?',
|
|
226
|
+
],
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
domainName: 'data',
|
|
230
|
+
keywords: ['data', 'analysis', 'analytics', 'etl', 'pipeline', 'transform', 'parse', 'csv', 'json', 'database', 'sql'],
|
|
231
|
+
suggestedTools: ['Read', 'Write', 'Edit', 'Glob', 'Grep', 'Bash'],
|
|
232
|
+
followUpQuestions: [
|
|
233
|
+
'What data formats does it need to handle? (JSON, CSV, databases, APIs)',
|
|
234
|
+
'Should it perform analysis, transformation, or visualization?',
|
|
235
|
+
'Are there specific data quality or validation requirements?',
|
|
236
|
+
],
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
domainName: 'research',
|
|
240
|
+
keywords: ['research', 'find', 'search', 'explore', 'investigate', 'analyze', 'understand', 'learn', 'discover'],
|
|
241
|
+
suggestedTools: ['Read', 'Glob', 'Grep', 'WebSearch', 'WebFetch'],
|
|
242
|
+
followUpQuestions: [
|
|
243
|
+
'What sources should it search? (codebase, web, documentation)',
|
|
244
|
+
'Should it provide summaries, detailed reports, or actionable recommendations?',
|
|
245
|
+
'What depth of analysis? (quick overview vs. comprehensive deep-dive)',
|
|
246
|
+
],
|
|
247
|
+
},
|
|
248
|
+
];
|
|
249
|
+
/**
|
|
250
|
+
* Analyze user description to detect domain and context
|
|
251
|
+
*/
|
|
252
|
+
function analyzeAgentDescription(description) {
|
|
253
|
+
const lowerDesc = description.toLowerCase();
|
|
254
|
+
const detectedDomains = [];
|
|
255
|
+
// Find matching domains
|
|
256
|
+
for (const domain of AGENT_DOMAINS) {
|
|
257
|
+
const matchCount = domain.keywords.filter((kw) => lowerDesc.includes(kw)).length;
|
|
258
|
+
if (matchCount > 0) {
|
|
259
|
+
detectedDomains.push(domain);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
// Sort by relevance (more keyword matches = more relevant)
|
|
263
|
+
detectedDomains.sort((a, b) => {
|
|
264
|
+
const aMatches = a.keywords.filter((kw) => lowerDesc.includes(kw)).length;
|
|
265
|
+
const bMatches = b.keywords.filter((kw) => lowerDesc.includes(kw)).length;
|
|
266
|
+
return bMatches - aMatches;
|
|
267
|
+
});
|
|
268
|
+
// Collect suggested tools from detected domains
|
|
269
|
+
const toolSet = new Set();
|
|
270
|
+
for (const domain of detectedDomains) {
|
|
271
|
+
for (const tool of domain.suggestedTools) {
|
|
272
|
+
toolSet.add(tool);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
// Build contextual questions based on detected domains
|
|
276
|
+
const contextualQuestions = [];
|
|
277
|
+
if (detectedDomains.length > 0) {
|
|
278
|
+
// Get questions from the most relevant domain
|
|
279
|
+
const primaryDomain = detectedDomains[0];
|
|
280
|
+
if (primaryDomain) {
|
|
281
|
+
contextualQuestions.push(...primaryDomain.followUpQuestions);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
// Add generic but useful questions if we don't have domain-specific ones
|
|
285
|
+
if (contextualQuestions.length === 0) {
|
|
286
|
+
contextualQuestions.push(`What specific outputs should this "${description}" agent produce?`, 'What constraints or quality standards should the agent follow?', 'Should the agent modify files, or just analyze and report?');
|
|
287
|
+
}
|
|
288
|
+
return {
|
|
289
|
+
detectedDomains,
|
|
290
|
+
suggestedTools: Array.from(toolSet),
|
|
291
|
+
contextualQuestions,
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* System prompt for generating the final agent profile
|
|
296
|
+
*/
|
|
297
|
+
const PROFILE_GENERATOR_PROMPT = `You are an expert at designing Task Agent profiles for an AI development CLI.
|
|
298
|
+
|
|
299
|
+
Based on the conversation below, generate a complete agent profile.
|
|
300
|
+
|
|
301
|
+
Your response must be ONLY valid JSON with this exact structure:
|
|
302
|
+
{
|
|
303
|
+
"name": "agent-name-kebab-case",
|
|
304
|
+
"description": "A clear, concise description (max 200 chars)",
|
|
305
|
+
"tools": ["Tool1", "Tool2"],
|
|
306
|
+
"systemPrompt": "# Agent Name\\n\\nFull system prompt with role, responsibilities, guidelines, and constraints..."
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
Available tools: Read, Write, Edit, Glob, Grep, Bash, WebSearch, WebFetch, TodoCreate, TodoUpdate, TodoList, AskUserQuestion
|
|
310
|
+
|
|
311
|
+
Guidelines:
|
|
312
|
+
- The name should be lowercase, hyphenated, max 32 chars
|
|
313
|
+
- Choose specific tools needed, not "all" unless truly necessary
|
|
314
|
+
- The systemPrompt should be comprehensive: include role definition, key responsibilities, approach, specific guidelines, output format expectations
|
|
315
|
+
- Make the systemPrompt actionable and specific to the agent's purpose
|
|
316
|
+
|
|
317
|
+
IMPORTANT: Return ONLY valid JSON. No markdown, no explanation, just the JSON object.`;
|
|
318
|
+
/**
|
|
319
|
+
* Create a conversational agent creator using the orchestrator
|
|
320
|
+
*
|
|
321
|
+
* Uses intelligent domain detection to ask relevant follow-up questions,
|
|
322
|
+
* then uses AI only for generating the final profile.
|
|
323
|
+
*/
|
|
324
|
+
function createConversationalCreator(orchestratorClient) {
|
|
325
|
+
return async (messages, _selectedModel) => {
|
|
326
|
+
const userMessages = messages.filter((m) => m.role === 'user');
|
|
327
|
+
const exchangeCount = Math.floor(messages.length / 2);
|
|
328
|
+
// First message - analyze and ask first contextual question
|
|
329
|
+
if (messages.length === 1 && userMessages[0]) {
|
|
330
|
+
const initialDescription = userMessages[0].content;
|
|
331
|
+
const analysis = analyzeAgentDescription(initialDescription);
|
|
332
|
+
// Pick the most relevant question based on domain analysis
|
|
333
|
+
if (analysis.contextualQuestions.length > 0) {
|
|
334
|
+
const firstQuestion = analysis.contextualQuestions[0];
|
|
335
|
+
return {
|
|
336
|
+
type: 'question',
|
|
337
|
+
question: firstQuestion || `What specific capabilities should this agent have?`,
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
// Second exchange - ask another contextual question
|
|
342
|
+
if (exchangeCount === 1 && userMessages[0]) {
|
|
343
|
+
const initialDescription = userMessages[0].content;
|
|
344
|
+
const analysis = analyzeAgentDescription(initialDescription);
|
|
345
|
+
// Get the second question
|
|
346
|
+
if (analysis.contextualQuestions.length > 1) {
|
|
347
|
+
const secondQuestion = analysis.contextualQuestions[1];
|
|
348
|
+
return {
|
|
349
|
+
type: 'question',
|
|
350
|
+
question: secondQuestion || 'What quality standards or constraints should this agent follow?',
|
|
351
|
+
};
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
// Third exchange or more - generate the profile using AI
|
|
355
|
+
if (exchangeCount >= 2 || messages.length >= 4) {
|
|
356
|
+
// Build conversation summary for AI
|
|
357
|
+
const conversationSummary = messages
|
|
358
|
+
.map((m) => `${m.role === 'user' ? 'User' : 'AI'}: ${m.content}`)
|
|
359
|
+
.join('\n\n');
|
|
360
|
+
const prompt = `Based on this conversation, generate a complete agent profile:
|
|
361
|
+
|
|
362
|
+
${conversationSummary}
|
|
363
|
+
|
|
364
|
+
Generate the JSON profile now. Remember: ONLY valid JSON, no other text.`;
|
|
365
|
+
try {
|
|
366
|
+
const response = await orchestratorClient.sendMessage(prompt, {
|
|
367
|
+
system: PROFILE_GENERATOR_PROMPT,
|
|
368
|
+
temperature: 0.7,
|
|
369
|
+
});
|
|
370
|
+
// Extract the response text
|
|
371
|
+
let responseText = '';
|
|
372
|
+
if (typeof response === 'string') {
|
|
373
|
+
responseText = response;
|
|
374
|
+
}
|
|
375
|
+
else if (response && typeof response === 'object') {
|
|
376
|
+
if ('text' in response) {
|
|
377
|
+
responseText = response.text;
|
|
378
|
+
}
|
|
379
|
+
else if ('content' in response && Array.isArray(response.content)) {
|
|
380
|
+
for (const block of response.content) {
|
|
381
|
+
if (block && typeof block === 'object' && 'text' in block) {
|
|
382
|
+
responseText += block.text;
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
// Extract JSON from response
|
|
388
|
+
let jsonStr = responseText.trim();
|
|
389
|
+
// Remove markdown code fences if present
|
|
390
|
+
const jsonMatch = jsonStr.match(/```(?:json)?\s*([\s\S]*?)```/);
|
|
391
|
+
if (jsonMatch) {
|
|
392
|
+
jsonStr = jsonMatch[1]?.trim() || jsonStr;
|
|
393
|
+
}
|
|
394
|
+
// Find JSON object
|
|
395
|
+
const startBrace = jsonStr.indexOf('{');
|
|
396
|
+
const endBrace = jsonStr.lastIndexOf('}');
|
|
397
|
+
if (startBrace !== -1 && endBrace !== -1) {
|
|
398
|
+
jsonStr = jsonStr.slice(startBrace, endBrace + 1);
|
|
399
|
+
}
|
|
400
|
+
const profile = JSON.parse(jsonStr);
|
|
401
|
+
// Validate and sanitize
|
|
402
|
+
if (!profile.name || !profile.description || !profile.systemPrompt) {
|
|
403
|
+
throw new Error('Missing required profile fields');
|
|
404
|
+
}
|
|
405
|
+
const safeName = String(profile.name)
|
|
406
|
+
.toLowerCase()
|
|
407
|
+
.replace(/[^a-z0-9-]/g, '-')
|
|
408
|
+
.replace(/--+/g, '-')
|
|
409
|
+
.replace(/^-|-$/g, '')
|
|
410
|
+
.slice(0, 32);
|
|
411
|
+
return {
|
|
412
|
+
type: 'profile',
|
|
413
|
+
profile: {
|
|
414
|
+
name: safeName || `agent-${Date.now()}`,
|
|
415
|
+
description: String(profile.description).slice(0, 200),
|
|
416
|
+
tools: Array.isArray(profile.tools) ? profile.tools : ['Read', 'Write', 'Edit', 'Glob', 'Grep'],
|
|
417
|
+
systemPrompt: String(profile.systemPrompt),
|
|
418
|
+
},
|
|
419
|
+
};
|
|
420
|
+
}
|
|
421
|
+
catch (error) {
|
|
422
|
+
// Fallback: generate a reasonable profile from conversation
|
|
423
|
+
console.error('AI profile generation failed:', error.message);
|
|
424
|
+
const initialDescription = userMessages[0]?.content || 'custom agent';
|
|
425
|
+
const allUserInput = userMessages.map((m) => m.content).join(' ');
|
|
426
|
+
const analysis = analyzeAgentDescription(allUserInput);
|
|
427
|
+
const safeName = initialDescription
|
|
428
|
+
.toLowerCase()
|
|
429
|
+
.replace(/[^a-z0-9]+/g, '-')
|
|
430
|
+
.replace(/^-|-$/g, '')
|
|
431
|
+
.slice(0, 32) || `agent-${Date.now()}`;
|
|
432
|
+
const tools = analysis.suggestedTools.length > 0
|
|
433
|
+
? analysis.suggestedTools
|
|
434
|
+
: ['Read', 'Write', 'Edit', 'Glob', 'Grep'];
|
|
435
|
+
return {
|
|
436
|
+
type: 'profile',
|
|
437
|
+
profile: {
|
|
438
|
+
name: safeName,
|
|
439
|
+
description: initialDescription.slice(0, 200),
|
|
440
|
+
tools,
|
|
441
|
+
systemPrompt: `# ${safeName}
|
|
442
|
+
|
|
443
|
+
## Your Role
|
|
444
|
+
|
|
445
|
+
You are a specialized ${initialDescription} agent.
|
|
446
|
+
|
|
447
|
+
## Context from User
|
|
448
|
+
|
|
449
|
+
${allUserInput}
|
|
450
|
+
|
|
451
|
+
## Responsibilities
|
|
452
|
+
|
|
453
|
+
- Understand and fulfill requests related to ${initialDescription}
|
|
454
|
+
- Use available tools effectively to accomplish tasks
|
|
455
|
+
- Provide clear explanations of your actions
|
|
456
|
+
- Ask for clarification when requirements are ambiguous
|
|
457
|
+
|
|
458
|
+
## Guidelines
|
|
459
|
+
|
|
460
|
+
- Be thorough and methodical in your approach
|
|
461
|
+
- Focus on quality and correctness
|
|
462
|
+
- Explain your reasoning when making decisions
|
|
463
|
+
- Follow best practices for the domain
|
|
464
|
+
|
|
465
|
+
## Output Format
|
|
466
|
+
|
|
467
|
+
Provide clear, well-structured output appropriate to the task.`,
|
|
468
|
+
},
|
|
469
|
+
};
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
// Fallback - ask a contextual question based on what we know
|
|
473
|
+
const allText = userMessages.map((m) => m.content).join(' ');
|
|
474
|
+
const analysis = analyzeAgentDescription(allText);
|
|
475
|
+
// Try to find an unused question
|
|
476
|
+
const questionIndex = Math.min(exchangeCount, analysis.contextualQuestions.length - 1);
|
|
477
|
+
const question = analysis.contextualQuestions[questionIndex] ||
|
|
478
|
+
'What output format or deliverables should this agent produce?';
|
|
479
|
+
return {
|
|
480
|
+
type: 'question',
|
|
481
|
+
question,
|
|
482
|
+
};
|
|
483
|
+
};
|
|
484
|
+
}
|
|
485
|
+
/**
|
|
486
|
+
* System prompt for AI-assisted agent editing
|
|
487
|
+
*/
|
|
488
|
+
const EDIT_ASSISTANT_PROMPT = `You are an expert at editing Task Agent profiles for an AI development CLI.
|
|
489
|
+
|
|
490
|
+
Given the current agent definition (in YAML frontmatter + markdown format) and the user's edit request,
|
|
491
|
+
produce an updated version of the agent that incorporates the requested changes.
|
|
492
|
+
|
|
493
|
+
IMPORTANT:
|
|
494
|
+
1. Preserve the YAML frontmatter structure exactly (---, fields, ---)
|
|
495
|
+
2. Only modify what the user requested
|
|
496
|
+
3. Maintain the existing style and tone
|
|
497
|
+
4. Keep all fields that weren't mentioned in the edit request
|
|
498
|
+
5. Return ONLY the updated content, no explanations
|
|
499
|
+
|
|
500
|
+
The agent file format is:
|
|
501
|
+
---
|
|
502
|
+
name: agent-name
|
|
503
|
+
description: Short description
|
|
504
|
+
model: model-id
|
|
505
|
+
tools:
|
|
506
|
+
- Tool1
|
|
507
|
+
- Tool2
|
|
508
|
+
---
|
|
509
|
+
|
|
510
|
+
# Agent Name
|
|
511
|
+
|
|
512
|
+
System prompt content here...
|
|
513
|
+
|
|
514
|
+
After providing the updated content, also provide a brief summary of what was changed.
|
|
515
|
+
|
|
516
|
+
Response format (JSON):
|
|
517
|
+
{
|
|
518
|
+
"content": "---\\nname: ...\\n---\\n\\n# Agent Name\\n\\nUpdated content...",
|
|
519
|
+
"summary": "Brief description of changes made"
|
|
520
|
+
}`;
|
|
521
|
+
/**
|
|
522
|
+
* Create an edit assistant using the orchestrator
|
|
523
|
+
*/
|
|
524
|
+
function createEditAssistant(orchestratorClient) {
|
|
525
|
+
return async (currentContent, editRequest, agentName) => {
|
|
526
|
+
const prompt = `Edit the following agent "${agentName}":
|
|
527
|
+
|
|
528
|
+
CURRENT CONTENT:
|
|
529
|
+
\`\`\`
|
|
530
|
+
${currentContent}
|
|
531
|
+
\`\`\`
|
|
532
|
+
|
|
533
|
+
USER'S EDIT REQUEST:
|
|
534
|
+
"${editRequest}"
|
|
535
|
+
|
|
536
|
+
Apply the requested changes and return the updated content as JSON with "content" and "summary" fields.`;
|
|
537
|
+
try {
|
|
538
|
+
const response = await orchestratorClient.sendMessage(prompt, {
|
|
539
|
+
system: EDIT_ASSISTANT_PROMPT,
|
|
540
|
+
temperature: 0.3, // Lower temperature for more precise edits
|
|
541
|
+
});
|
|
542
|
+
// Extract the response text
|
|
543
|
+
let responseText = '';
|
|
544
|
+
if (typeof response === 'string') {
|
|
545
|
+
responseText = response;
|
|
546
|
+
}
|
|
547
|
+
else if (response && typeof response === 'object') {
|
|
548
|
+
if ('text' in response) {
|
|
549
|
+
responseText = response.text;
|
|
550
|
+
}
|
|
551
|
+
else if ('content' in response && Array.isArray(response.content)) {
|
|
552
|
+
for (const block of response.content) {
|
|
553
|
+
if (block && typeof block === 'object' && 'text' in block) {
|
|
554
|
+
responseText += block.text;
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
// Try to extract JSON from the response
|
|
560
|
+
let jsonStr = responseText.trim();
|
|
561
|
+
// Remove markdown code fences if present
|
|
562
|
+
const jsonMatch = jsonStr.match(/```(?:json)?\s*([\s\S]*?)```/);
|
|
563
|
+
if (jsonMatch) {
|
|
564
|
+
jsonStr = jsonMatch[1]?.trim() || jsonStr;
|
|
565
|
+
}
|
|
566
|
+
// Find JSON object boundaries
|
|
567
|
+
const startBrace = jsonStr.indexOf('{');
|
|
568
|
+
const endBrace = jsonStr.lastIndexOf('}');
|
|
569
|
+
if (startBrace !== -1 && endBrace !== -1) {
|
|
570
|
+
jsonStr = jsonStr.slice(startBrace, endBrace + 1);
|
|
571
|
+
}
|
|
572
|
+
// Parse the JSON
|
|
573
|
+
const result = JSON.parse(jsonStr);
|
|
574
|
+
if (!result.content || typeof result.content !== 'string') {
|
|
575
|
+
throw new Error('Invalid response: missing content field');
|
|
576
|
+
}
|
|
577
|
+
return {
|
|
578
|
+
content: result.content,
|
|
579
|
+
summary: result.summary || 'Agent updated',
|
|
580
|
+
};
|
|
581
|
+
}
|
|
582
|
+
catch (error) {
|
|
583
|
+
// If JSON parsing fails, try to extract content directly
|
|
584
|
+
console.error('Failed to parse AI edit response:', error.message);
|
|
585
|
+
throw new Error(`AI edit failed: ${error.message}`);
|
|
586
|
+
}
|
|
587
|
+
};
|
|
588
|
+
}
|
|
589
|
+
/**
|
|
590
|
+
* Run agent management command
|
|
591
|
+
*
|
|
592
|
+
* @param config - Command configuration
|
|
593
|
+
*/
|
|
594
|
+
export async function runAgentCommand(config) {
|
|
595
|
+
const projectDir = resolveProjectAgentsDir(config.projectRoot);
|
|
596
|
+
// Ensure agents directory exists
|
|
597
|
+
await fs.mkdir(projectDir, { recursive: true });
|
|
598
|
+
// Initialize store
|
|
599
|
+
const store = new AgentStore({
|
|
600
|
+
projectDir,
|
|
601
|
+
enableWatching: true,
|
|
602
|
+
debug: config.debug || false,
|
|
603
|
+
});
|
|
604
|
+
await store.initialize();
|
|
605
|
+
// Create profile generator, conversational creator, edit assistant, and model list function if orchestrator is available
|
|
606
|
+
let generateAgentProfile;
|
|
607
|
+
let conversationalCreator;
|
|
608
|
+
let editAssistant;
|
|
609
|
+
let listModels;
|
|
610
|
+
if (config.orchestratorClient) {
|
|
611
|
+
generateAgentProfile = createProfileGenerator(config.orchestratorClient);
|
|
612
|
+
conversationalCreator = createConversationalCreator(config.orchestratorClient);
|
|
613
|
+
editAssistant = createEditAssistant(config.orchestratorClient);
|
|
614
|
+
// Wrap listModels to match the expected signature
|
|
615
|
+
listModels = async () => {
|
|
616
|
+
const models = await config.orchestratorClient.listModels();
|
|
617
|
+
return models;
|
|
618
|
+
};
|
|
619
|
+
}
|
|
620
|
+
// Render interactive menu
|
|
621
|
+
const { unmount, waitUntilExit } = render(React.createElement(InteractiveAgentMenu, {
|
|
622
|
+
store,
|
|
623
|
+
initialAgentName: config.initialAgentName,
|
|
624
|
+
currentModel: config.currentModel || 'sonnet',
|
|
625
|
+
generateAgentProfile,
|
|
626
|
+
conversationalCreator,
|
|
627
|
+
editAssistant,
|
|
628
|
+
listModels,
|
|
629
|
+
onExit: () => {
|
|
630
|
+
// Use unmount for graceful return to CLI instead of exit() which kills the process
|
|
631
|
+
unmount();
|
|
632
|
+
},
|
|
633
|
+
}));
|
|
634
|
+
// Wait for user to exit
|
|
635
|
+
await waitUntilExit();
|
|
636
|
+
// Cleanup
|
|
637
|
+
await store.destroy();
|
|
638
|
+
}
|
|
639
|
+
/**
|
|
640
|
+
* Create agent command with default paths
|
|
641
|
+
*
|
|
642
|
+
* @param projectRoot - Project root directory
|
|
643
|
+
* @param options - Additional options
|
|
644
|
+
*/
|
|
645
|
+
export async function createAgentCommand(projectRoot, options = {}) {
|
|
646
|
+
await runAgentCommand({
|
|
647
|
+
projectRoot,
|
|
648
|
+
debug: options.debug,
|
|
649
|
+
initialAgentName: options.initialAgentName,
|
|
650
|
+
currentModel: options.currentModel,
|
|
651
|
+
orchestratorClient: options.orchestratorClient,
|
|
652
|
+
});
|
|
653
|
+
}
|
|
654
|
+
/**
|
|
655
|
+
* List agents (non-interactive)
|
|
656
|
+
*/
|
|
657
|
+
export async function listAgents(projectRoot) {
|
|
658
|
+
const projectDir = resolveProjectAgentsDir(projectRoot);
|
|
659
|
+
const store = new AgentStore({
|
|
660
|
+
projectDir,
|
|
661
|
+
enableWatching: false,
|
|
662
|
+
});
|
|
663
|
+
await store.initialize();
|
|
664
|
+
const agents = store.getAll();
|
|
665
|
+
if (agents.length === 0) {
|
|
666
|
+
console.log('No agents found.');
|
|
667
|
+
console.log(`Create agents in: ${projectDir}`);
|
|
668
|
+
}
|
|
669
|
+
else {
|
|
670
|
+
console.log(`Found ${agents.length} agent(s):\n`);
|
|
671
|
+
for (const agent of agents) {
|
|
672
|
+
const locationIcon = agent.location === 'project' ? '[P]' : '[G]';
|
|
673
|
+
const toolsInfo = agent.tools === 'all' ? 'all' : `${agent.tools.length} tools`;
|
|
674
|
+
console.log(` ${locationIcon} ${agent.name}`);
|
|
675
|
+
console.log(` Model: ${agent.model} | Tools: ${toolsInfo}`);
|
|
676
|
+
console.log(` ${agent.description}`);
|
|
677
|
+
console.log('');
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
await store.destroy();
|
|
681
|
+
}
|
|
682
|
+
/**
|
|
683
|
+
* Show agent info (non-interactive)
|
|
684
|
+
*/
|
|
685
|
+
export async function showAgentInfo(projectRoot, agentName) {
|
|
686
|
+
const projectDir = resolveProjectAgentsDir(projectRoot);
|
|
687
|
+
const store = new AgentStore({
|
|
688
|
+
projectDir,
|
|
689
|
+
enableWatching: false,
|
|
690
|
+
});
|
|
691
|
+
await store.initialize();
|
|
692
|
+
const agent = store.getAgent(agentName);
|
|
693
|
+
if (!agent) {
|
|
694
|
+
console.error(`Agent '${agentName}' not found.`);
|
|
695
|
+
await store.destroy();
|
|
696
|
+
return;
|
|
697
|
+
}
|
|
698
|
+
console.log(`\nAgent: ${agent.name}`);
|
|
699
|
+
console.log(`${'─'.repeat(50)}`);
|
|
700
|
+
console.log(`Location: ${agent.location}`);
|
|
701
|
+
console.log(`Model: ${agent.model}`);
|
|
702
|
+
console.log(`Tools: ${agent.tools === 'all' ? 'all' : agent.tools.join(', ')}`);
|
|
703
|
+
console.log(`File: ${agent.filePath}`);
|
|
704
|
+
console.log(`Description: ${agent.description}`);
|
|
705
|
+
console.log(`\nSystem Prompt:`);
|
|
706
|
+
console.log(`${'─'.repeat(50)}`);
|
|
707
|
+
console.log(agent.systemPrompt);
|
|
708
|
+
await store.destroy();
|
|
709
|
+
}
|
|
710
|
+
/**
|
|
711
|
+
* Export components for external use
|
|
712
|
+
*/
|
|
713
|
+
export { InteractiveAgentMenu } from './InteractiveAgentMenu.js';
|
|
714
|
+
//# sourceMappingURL=index.js.map
|