Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

2.2 KB
Raw Blame
import type { SlashCommand } from './types'

const NAV_ITEMS = [
  { id: 'apps', label: 'Apps', path: '/apps', iconClassName: 'i-ri-apps-2-line' },
  { id: 'datasets', label: 'Knowledge', path: '/datasets', iconClassName: 'i-ri-book-open-line' },
  {
    id: 'agents',
    label: 'Agents',
    path: '/agents',
    iconClassName: 'i-custom-vender-main-nav-roster',
    availability: 'agents',
  },
  {
    id: 'skills',
    label: 'Skills',
    path: '/skills',
    iconClassName: 'i-custom-vender-main-nav-skill',
    availability: 'skills',
  },
  { id: 'plugins', label: 'Plugins', path: '/plugins', iconClassName: 'i-ri-plug-line' },
  { id: 'tools', label: 'Tools', path: '/tools', iconClassName: 'i-ri-tools-line' },
  { id: 'home', label: 'Home', path: '/', iconClassName: 'i-ri-compass-line' },
  { id: 'account', label: 'Account', path: '/account', iconClassName: 'i-ri-user-line' },
] as const

/**
 * Go command - Navigate to a top-level section of the app
 */
export const goCommand: SlashCommand = {
  name: 'go',
  aliases: ['navigate', 'nav'],
  description: 'Navigate to a section',
  mode: 'submenu',
  execute(args, context) {
    const item = NAV_ITEMS.find((item) => item.path === args.path)
    if (!item) return
    if ('availability' in item && !context[`${item.availability}Available`]) return
    context.navigate(item.path)
  },

  search(args: string, context) {
    const query = args.trim().toLowerCase()
    const items = NAV_ITEMS.filter((item) => {
      if ('availability' in item) {
        if (item.availability === 'agents' && !context.agentsAvailable) return false
        if (item.availability === 'skills' && !context.skillsAvailable) return false
      }

      return !query || item.id.includes(query) || item.label.toLowerCase().includes(query)
    })
    return items.map((item) => ({
      id: `go-${item.id}`,
      title: item.label,
      description: item.path,
      type: 'command' as const,
      icon: (
        <div className="flex h-6 w-6 items-center justify-center rounded-md border-[0.5px] border-divider-regular bg-components-panel-bg">
          <span aria-hidden className={`${item.iconClassName} size-4 text-text-tertiary`} />
        </div>
      ),
      data: { command: 'go', args: { path: item.path } },
    }))
  },
}