bingocode 1.0.1 → 1.0.3
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/bin/bingo-win.cjs +34 -3
- package/desktop/README.md +30 -0
- package/desktop/bunfig.toml +1 -0
- package/desktop/index.html +17 -0
- package/desktop/package.json +55 -0
- package/desktop/pnpm-lock.yaml +3832 -0
- package/desktop/public/app-icon.jpg +0 -0
- package/desktop/public/fonts/inter-latin-ext.woff2 +0 -0
- package/desktop/public/fonts/inter-latin.woff2 +0 -0
- package/desktop/public/fonts/jetbrains-mono-latin-ext.woff2 +0 -0
- package/desktop/public/fonts/jetbrains-mono-latin.woff2 +0 -0
- package/desktop/public/fonts/manrope-latin-ext.woff2 +0 -0
- package/desktop/public/fonts/manrope-latin.woff2 +0 -0
- package/desktop/public/fonts/material-symbols-outlined.woff2 +0 -0
- package/desktop/public/icons/bilibili.svg +1 -0
- package/desktop/public/icons/douyin.svg +1 -0
- package/desktop/public/icons/github.svg +3 -0
- package/desktop/public/icons/xiaohongshu.svg +1 -0
- package/desktop/scripts/build-macos-arm64.sh +270 -0
- package/desktop/scripts/build-sidecars.ts +183 -0
- package/desktop/scripts/build-windows-x64.ps1 +295 -0
- package/desktop/scripts/scan-missing-imports.ts +235 -0
- package/desktop/sidecars/claude-sidecar.ts +156 -0
- package/desktop/src/App.tsx +5 -0
- package/desktop/src/__tests__/agentsSettings.test.tsx +349 -0
- package/desktop/src/__tests__/pages.test.tsx +290 -0
- package/desktop/src/__tests__/skillsSettings.test.tsx +205 -0
- package/desktop/src/api/adapters.ts +12 -0
- package/desktop/src/api/agents.ts +36 -0
- package/desktop/src/api/cliTasks.ts +28 -0
- package/desktop/src/api/client.ts +63 -0
- package/desktop/src/api/computerUse.ts +76 -0
- package/desktop/src/api/filesystem.ts +30 -0
- package/desktop/src/api/hahaOAuth.ts +38 -0
- package/desktop/src/api/models.ts +28 -0
- package/desktop/src/api/providers.ts +63 -0
- package/desktop/src/api/search.ts +29 -0
- package/desktop/src/api/sessions.ts +56 -0
- package/desktop/src/api/settings.ts +20 -0
- package/desktop/src/api/skills.ts +19 -0
- package/desktop/src/api/tasks.ts +36 -0
- package/desktop/src/api/teams.ts +44 -0
- package/desktop/src/api/websocket.ts +164 -0
- package/desktop/src/components/chat/AskUserQuestion.tsx +268 -0
- package/desktop/src/components/chat/AssistantMessage.tsx +29 -0
- package/desktop/src/components/chat/AttachmentGallery.tsx +113 -0
- package/desktop/src/components/chat/ChatInput.tsx +622 -0
- package/desktop/src/components/chat/CodeViewer.tsx +161 -0
- package/desktop/src/components/chat/ComputerUsePermissionModal.test.tsx +174 -0
- package/desktop/src/components/chat/ComputerUsePermissionModal.tsx +311 -0
- package/desktop/src/components/chat/DiffViewer.tsx +157 -0
- package/desktop/src/components/chat/FileSearchMenu.tsx +198 -0
- package/desktop/src/components/chat/ImageGalleryModal.tsx +91 -0
- package/desktop/src/components/chat/InlineImageGallery.tsx +106 -0
- package/desktop/src/components/chat/InlineTaskSummary.tsx +60 -0
- package/desktop/src/components/chat/MermaidRenderer.test.tsx +98 -0
- package/desktop/src/components/chat/MermaidRenderer.tsx +361 -0
- package/desktop/src/components/chat/MessageActionBar.tsx +27 -0
- package/desktop/src/components/chat/MessageList.test.tsx +313 -0
- package/desktop/src/components/chat/MessageList.tsx +249 -0
- package/desktop/src/components/chat/PermissionDialog.tsx +262 -0
- package/desktop/src/components/chat/SessionTaskBar.test.tsx +99 -0
- package/desktop/src/components/chat/SessionTaskBar.tsx +159 -0
- package/desktop/src/components/chat/StreamingIndicator.tsx +41 -0
- package/desktop/src/components/chat/TerminalChrome.tsx +35 -0
- package/desktop/src/components/chat/ThinkingBlock.tsx +87 -0
- package/desktop/src/components/chat/ToolCallBlock.tsx +247 -0
- package/desktop/src/components/chat/ToolCallGroup.tsx +617 -0
- package/desktop/src/components/chat/ToolResultBlock.tsx +107 -0
- package/desktop/src/components/chat/UserMessage.tsx +38 -0
- package/desktop/src/components/chat/chatBlocks.test.tsx +136 -0
- package/desktop/src/components/chat/clipboard.ts +25 -0
- package/desktop/src/components/chat/composerUtils.test.ts +55 -0
- package/desktop/src/components/chat/composerUtils.ts +149 -0
- package/desktop/src/components/controls/ModelSelector.tsx +156 -0
- package/desktop/src/components/controls/PermissionModeSelector.tsx +229 -0
- package/desktop/src/components/layout/AppShell.tsx +107 -0
- package/desktop/src/components/layout/ContentRouter.tsx +27 -0
- package/desktop/src/components/layout/ProjectFilter.tsx +126 -0
- package/desktop/src/components/layout/Sidebar.test.tsx +158 -0
- package/desktop/src/components/layout/Sidebar.tsx +384 -0
- package/desktop/src/components/layout/StatusBar.tsx +31 -0
- package/desktop/src/components/layout/TabBar.test.tsx +136 -0
- package/desktop/src/components/layout/TabBar.tsx +318 -0
- package/desktop/src/components/layout/TitleBar.tsx +96 -0
- package/desktop/src/components/layout/WindowControls.test.tsx +69 -0
- package/desktop/src/components/layout/WindowControls.tsx +89 -0
- package/desktop/src/components/markdown/MarkdownRenderer.test.tsx +100 -0
- package/desktop/src/components/markdown/MarkdownRenderer.tsx +229 -0
- package/desktop/src/components/settings/ClaudeOfficialLogin.tsx +107 -0
- package/desktop/src/components/shared/Button.tsx +63 -0
- package/desktop/src/components/shared/CopyButton.tsx +58 -0
- package/desktop/src/components/shared/DirectoryPicker.tsx +316 -0
- package/desktop/src/components/shared/Dropdown.tsx +91 -0
- package/desktop/src/components/shared/Input.tsx +38 -0
- package/desktop/src/components/shared/Modal.tsx +65 -0
- package/desktop/src/components/shared/ProjectContextChip.tsx +30 -0
- package/desktop/src/components/shared/Spinner.tsx +30 -0
- package/desktop/src/components/shared/Textarea.tsx +38 -0
- package/desktop/src/components/shared/Toast.tsx +47 -0
- package/desktop/src/components/shared/UpdateChecker.tsx +90 -0
- package/desktop/src/components/skills/SkillDetail.test.tsx +89 -0
- package/desktop/src/components/skills/SkillDetail.tsx +403 -0
- package/desktop/src/components/skills/SkillList.tsx +254 -0
- package/desktop/src/components/tasks/DayOfWeekPicker.tsx +57 -0
- package/desktop/src/components/tasks/NewTaskModal.tsx +407 -0
- package/desktop/src/components/tasks/PromptEditor.tsx +74 -0
- package/desktop/src/components/tasks/TaskEmptyState.tsx +30 -0
- package/desktop/src/components/tasks/TaskList.tsx +46 -0
- package/desktop/src/components/tasks/TaskRow.tsx +253 -0
- package/desktop/src/components/tasks/TaskRunsPanel.tsx +195 -0
- package/desktop/src/components/teams/TeamStatusBar.tsx +147 -0
- package/desktop/src/config/providerPresets.ts +78 -0
- package/desktop/src/config/spinnerVerbs.ts +193 -0
- package/desktop/src/hooks/useKeyboardShortcuts.ts +60 -0
- package/desktop/src/i18n/index.ts +54 -0
- package/desktop/src/i18n/locales/en.ts +670 -0
- package/desktop/src/i18n/locales/zh.ts +670 -0
- package/desktop/src/lib/__tests__/cronDescribe.test.ts +93 -0
- package/desktop/src/lib/cronDescribe.ts +188 -0
- package/desktop/src/lib/desktopRuntime.ts +54 -0
- package/desktop/src/lib/parseRunOutput.ts +79 -0
- package/desktop/src/main.tsx +13 -0
- package/desktop/src/mocks/data.ts +202 -0
- package/desktop/src/pages/ActiveSession.test.tsx +181 -0
- package/desktop/src/pages/ActiveSession.tsx +219 -0
- package/desktop/src/pages/AdapterSettings.tsx +375 -0
- package/desktop/src/pages/AgentTeams.tsx +200 -0
- package/desktop/src/pages/ComputerUseSettings.tsx +420 -0
- package/desktop/src/pages/EmptySession.tsx +518 -0
- package/desktop/src/pages/NewTaskModal.tsx +346 -0
- package/desktop/src/pages/ScheduledTasks.tsx +66 -0
- package/desktop/src/pages/ScheduledTasksEmpty.tsx +152 -0
- package/desktop/src/pages/ScheduledTasksList.tsx +416 -0
- package/desktop/src/pages/SessionControls.tsx +460 -0
- package/desktop/src/pages/Settings.tsx +1448 -0
- package/desktop/src/pages/ToolInspection.tsx +235 -0
- package/desktop/src/stores/adapterStore.ts +106 -0
- package/desktop/src/stores/agentStore.ts +34 -0
- package/desktop/src/stores/chatStore.test.ts +505 -0
- package/desktop/src/stores/chatStore.ts +850 -0
- package/desktop/src/stores/cliTaskStore.ts +152 -0
- package/desktop/src/stores/hahaOAuthStore.test.ts +77 -0
- package/desktop/src/stores/hahaOAuthStore.ts +97 -0
- package/desktop/src/stores/providerStore.ts +101 -0
- package/desktop/src/stores/sessionStore.test.ts +63 -0
- package/desktop/src/stores/sessionStore.ts +102 -0
- package/desktop/src/stores/settingsStore.ts +120 -0
- package/desktop/src/stores/skillStore.ts +51 -0
- package/desktop/src/stores/tabStore.ts +169 -0
- package/desktop/src/stores/taskStore.ts +68 -0
- package/desktop/src/stores/teamStore.ts +344 -0
- package/desktop/src/stores/uiStore.ts +100 -0
- package/desktop/src/stores/updateStore.test.ts +71 -0
- package/desktop/src/stores/updateStore.ts +221 -0
- package/desktop/src/theme/globals.css +465 -0
- package/desktop/src/types/adapter.ts +33 -0
- package/desktop/src/types/chat.ts +152 -0
- package/desktop/src/types/cliTask.ts +24 -0
- package/desktop/src/types/provider.ts +62 -0
- package/desktop/src/types/session.ts +27 -0
- package/desktop/src/types/settings.ts +22 -0
- package/desktop/src/types/skill.ts +38 -0
- package/desktop/src/types/task.ts +56 -0
- package/desktop/src/types/team.ts +38 -0
- package/desktop/src-tauri/Cargo.lock +5549 -0
- package/desktop/src-tauri/Cargo.toml +20 -0
- package/desktop/src-tauri/app-icon.svg +13 -0
- package/desktop/src-tauri/build.rs +3 -0
- package/desktop/src-tauri/capabilities/default.json +106 -0
- package/desktop/src-tauri/icons/android/mipmap-anydpi-v26/ic_launcher.xml +5 -0
- package/desktop/src-tauri/icons/android/values/ic_launcher_background.xml +4 -0
- package/desktop/src-tauri/icons/icon.icns +0 -0
- package/desktop/src-tauri/icons/icon.ico +0 -0
- package/desktop/src-tauri/src/lib.rs +408 -0
- package/desktop/src-tauri/src/main.rs +6 -0
- package/desktop/src-tauri/tauri.conf.json +78 -0
- package/desktop/src-tauri/tauri.macos.conf.json +18 -0
- package/desktop/src-tauri/tauri.release-ci.json +5 -0
- package/desktop/src-tauri/tauri.windows.conf.json +16 -0
- package/desktop/src-tauri/windows-installer-hooks.nsh +17 -0
- package/desktop/tsconfig.json +25 -0
- package/desktop/vite.config.ts +26 -0
- package/desktop/vitest.config.ts +18 -0
- package/package.json +1 -1
- package/src/commands/desktop/desktop.tsx +9 -0
- package/src/commands/desktop/index.ts +26 -0
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { useEffect } from 'react'
|
|
2
|
+
import { useTranslation } from '../../i18n'
|
|
3
|
+
import { isTauriRuntime } from '../../lib/desktopRuntime'
|
|
4
|
+
import { useUpdateStore } from '../../stores/updateStore'
|
|
5
|
+
|
|
6
|
+
export function UpdateChecker() {
|
|
7
|
+
const t = useTranslation()
|
|
8
|
+
const status = useUpdateStore((s) => s.status)
|
|
9
|
+
const availableVersion = useUpdateStore((s) => s.availableVersion)
|
|
10
|
+
const releaseNotes = useUpdateStore((s) => s.releaseNotes)
|
|
11
|
+
const progressPercent = useUpdateStore((s) => s.progressPercent)
|
|
12
|
+
const error = useUpdateStore((s) => s.error)
|
|
13
|
+
const shouldPrompt = useUpdateStore((s) => s.shouldPrompt)
|
|
14
|
+
const initialize = useUpdateStore((s) => s.initialize)
|
|
15
|
+
const installUpdate = useUpdateStore((s) => s.installUpdate)
|
|
16
|
+
const dismissPrompt = useUpdateStore((s) => s.dismissPrompt)
|
|
17
|
+
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
void initialize()
|
|
20
|
+
}, [initialize])
|
|
21
|
+
|
|
22
|
+
if (!isTauriRuntime()) return null
|
|
23
|
+
|
|
24
|
+
const showPopup =
|
|
25
|
+
shouldPrompt && !!availableVersion && ['available', 'downloading', 'restarting'].includes(status)
|
|
26
|
+
|
|
27
|
+
if (!showPopup) return null
|
|
28
|
+
|
|
29
|
+
const statusText =
|
|
30
|
+
status === 'restarting'
|
|
31
|
+
? t('update.restarting')
|
|
32
|
+
: status === 'downloading'
|
|
33
|
+
? t('update.downloading')
|
|
34
|
+
: null
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<div className="fixed top-4 right-4 z-[200] max-w-sm">
|
|
38
|
+
<div className="bg-[var(--color-surface-container-low)] border border-[var(--color-border)] rounded-[var(--radius-lg)] shadow-[var(--shadow-dropdown)] p-4">
|
|
39
|
+
<p className="text-sm font-medium text-[var(--color-text-primary)]">
|
|
40
|
+
{t('update.available', { version: availableVersion })}
|
|
41
|
+
</p>
|
|
42
|
+
|
|
43
|
+
{releaseNotes && (
|
|
44
|
+
<p className="mt-2 text-xs leading-5 text-[var(--color-text-secondary)] whitespace-pre-wrap line-clamp-5">
|
|
45
|
+
{releaseNotes}
|
|
46
|
+
</p>
|
|
47
|
+
)}
|
|
48
|
+
|
|
49
|
+
{(status === 'downloading' || status === 'restarting') && (
|
|
50
|
+
<div className="mt-3">
|
|
51
|
+
<div className="h-1.5 bg-[var(--color-surface)] rounded-full overflow-hidden">
|
|
52
|
+
<div
|
|
53
|
+
className="h-full bg-[var(--color-text-accent)] transition-all duration-300"
|
|
54
|
+
style={{ width: `${Math.min(progressPercent, 100)}%` }}
|
|
55
|
+
/>
|
|
56
|
+
</div>
|
|
57
|
+
{statusText && (
|
|
58
|
+
<p className="text-xs text-[var(--color-text-tertiary)] mt-1">
|
|
59
|
+
{statusText} {status === 'downloading' ? `${progressPercent}%` : ''}
|
|
60
|
+
</p>
|
|
61
|
+
)}
|
|
62
|
+
</div>
|
|
63
|
+
)}
|
|
64
|
+
|
|
65
|
+
{error && (
|
|
66
|
+
<p className="mt-2 text-xs text-[var(--color-error)]">
|
|
67
|
+
{t('update.failed', { error })}
|
|
68
|
+
</p>
|
|
69
|
+
)}
|
|
70
|
+
|
|
71
|
+
{status === 'available' && (
|
|
72
|
+
<div className="mt-3 flex gap-2">
|
|
73
|
+
<button
|
|
74
|
+
onClick={() => void installUpdate()}
|
|
75
|
+
className="px-3 py-1 text-xs font-medium rounded-[var(--radius-md)] bg-[var(--color-text-accent)] text-white hover:opacity-90 transition-opacity"
|
|
76
|
+
>
|
|
77
|
+
{t('update.now')}
|
|
78
|
+
</button>
|
|
79
|
+
<button
|
|
80
|
+
onClick={dismissPrompt}
|
|
81
|
+
className="px-3 py-1 text-xs text-[var(--color-text-tertiary)] hover:text-[var(--color-text-primary)] transition-colors"
|
|
82
|
+
>
|
|
83
|
+
{t('update.later')}
|
|
84
|
+
</button>
|
|
85
|
+
</div>
|
|
86
|
+
)}
|
|
87
|
+
</div>
|
|
88
|
+
</div>
|
|
89
|
+
)
|
|
90
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeEach } from 'vitest'
|
|
2
|
+
import { render, screen } from '@testing-library/react'
|
|
3
|
+
import '@testing-library/jest-dom'
|
|
4
|
+
|
|
5
|
+
vi.mock('../markdown/MarkdownRenderer', () => ({
|
|
6
|
+
MarkdownRenderer: ({
|
|
7
|
+
content,
|
|
8
|
+
variant,
|
|
9
|
+
className,
|
|
10
|
+
}: {
|
|
11
|
+
content: string
|
|
12
|
+
variant?: string
|
|
13
|
+
className?: string
|
|
14
|
+
}) => (
|
|
15
|
+
<div
|
|
16
|
+
data-testid="markdown-renderer"
|
|
17
|
+
data-content={content}
|
|
18
|
+
data-variant={variant}
|
|
19
|
+
data-classname={className}
|
|
20
|
+
/>
|
|
21
|
+
),
|
|
22
|
+
}))
|
|
23
|
+
|
|
24
|
+
vi.mock('../chat/CodeViewer', () => ({
|
|
25
|
+
CodeViewer: ({ code }: { code: string }) => <div data-testid="code-viewer">{code}</div>,
|
|
26
|
+
}))
|
|
27
|
+
|
|
28
|
+
import { SkillDetail } from './SkillDetail'
|
|
29
|
+
import { useSkillStore } from '../../stores/skillStore'
|
|
30
|
+
import { useSettingsStore } from '../../stores/settingsStore'
|
|
31
|
+
|
|
32
|
+
const fetchSkills = vi.fn()
|
|
33
|
+
const fetchSkillDetail = vi.fn()
|
|
34
|
+
const clearSelection = vi.fn(() => {
|
|
35
|
+
useSkillStore.setState({ selectedSkill: null })
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
beforeEach(() => {
|
|
39
|
+
useSettingsStore.setState({ locale: 'en' })
|
|
40
|
+
useSkillStore.setState({
|
|
41
|
+
skills: [],
|
|
42
|
+
selectedSkill: null,
|
|
43
|
+
isLoading: false,
|
|
44
|
+
isDetailLoading: false,
|
|
45
|
+
error: null,
|
|
46
|
+
fetchSkills,
|
|
47
|
+
fetchSkillDetail,
|
|
48
|
+
clearSelection,
|
|
49
|
+
})
|
|
50
|
+
fetchSkills.mockReset()
|
|
51
|
+
fetchSkillDetail.mockReset()
|
|
52
|
+
clearSelection.mockClear()
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
describe('SkillDetail markdown presentation', () => {
|
|
56
|
+
it('renders markdown files with the document variant and readable width', () => {
|
|
57
|
+
useSkillStore.setState({
|
|
58
|
+
selectedSkill: {
|
|
59
|
+
meta: {
|
|
60
|
+
name: 'skill-test',
|
|
61
|
+
displayName: 'Skill Test',
|
|
62
|
+
description: 'Skill description',
|
|
63
|
+
source: 'user',
|
|
64
|
+
userInvocable: true,
|
|
65
|
+
contentLength: 120,
|
|
66
|
+
hasDirectory: true,
|
|
67
|
+
},
|
|
68
|
+
tree: [{ name: 'SKILL.md', path: 'SKILL.md', type: 'file' }],
|
|
69
|
+
files: [
|
|
70
|
+
{
|
|
71
|
+
path: 'SKILL.md',
|
|
72
|
+
content: '# Skill Body',
|
|
73
|
+
language: 'markdown',
|
|
74
|
+
isEntry: true,
|
|
75
|
+
},
|
|
76
|
+
],
|
|
77
|
+
skillRoot: '/tmp/skill-test',
|
|
78
|
+
},
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
render(<SkillDetail />)
|
|
82
|
+
|
|
83
|
+
const markdown = screen.getByTestId('markdown-renderer')
|
|
84
|
+
expect(markdown).toBeInTheDocument()
|
|
85
|
+
expect(markdown).toHaveAttribute('data-variant', 'document')
|
|
86
|
+
expect(markdown).toHaveAttribute('data-classname', 'mx-auto max-w-[72ch]')
|
|
87
|
+
expect(markdown).toHaveAttribute('data-content', '# Skill Body')
|
|
88
|
+
})
|
|
89
|
+
})
|
|
@@ -0,0 +1,403 @@
|
|
|
1
|
+
import { useMemo, useState, type ReactNode } from 'react'
|
|
2
|
+
import { useSkillStore } from '../../stores/skillStore'
|
|
3
|
+
import { useTranslation } from '../../i18n'
|
|
4
|
+
import { MarkdownRenderer } from '../markdown/MarkdownRenderer'
|
|
5
|
+
import { CodeViewer } from '../chat/CodeViewer'
|
|
6
|
+
import type { FileTreeNode, SkillFrontmatter } from '../../types/skill'
|
|
7
|
+
|
|
8
|
+
const META_PRIORITY = [
|
|
9
|
+
'description',
|
|
10
|
+
'when_to_use',
|
|
11
|
+
'argument-hint',
|
|
12
|
+
'model',
|
|
13
|
+
'effort',
|
|
14
|
+
'allowed-tools',
|
|
15
|
+
'paths',
|
|
16
|
+
'agent',
|
|
17
|
+
'context',
|
|
18
|
+
'version',
|
|
19
|
+
'user-invocable',
|
|
20
|
+
] as const
|
|
21
|
+
|
|
22
|
+
export function SkillDetail() {
|
|
23
|
+
const { selectedSkill, isDetailLoading, clearSelection } = useSkillStore()
|
|
24
|
+
const t = useTranslation()
|
|
25
|
+
const [selectedFile, setSelectedFile] = useState<string>('SKILL.md')
|
|
26
|
+
|
|
27
|
+
const normalizedSelection = useMemo(() => {
|
|
28
|
+
if (!selectedSkill) return 'SKILL.md'
|
|
29
|
+
return selectedSkill.files.some((file) => file.path === selectedFile)
|
|
30
|
+
? selectedFile
|
|
31
|
+
: selectedSkill.files[0]?.path || 'SKILL.md'
|
|
32
|
+
}, [selectedFile, selectedSkill])
|
|
33
|
+
|
|
34
|
+
if (isDetailLoading) {
|
|
35
|
+
return (
|
|
36
|
+
<div className="flex justify-center py-12">
|
|
37
|
+
<div className="animate-spin w-5 h-5 border-2 border-[var(--color-brand)] border-t-transparent rounded-full" />
|
|
38
|
+
</div>
|
|
39
|
+
)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (!selectedSkill) return null
|
|
43
|
+
|
|
44
|
+
const { meta, tree, files } = selectedSkill
|
|
45
|
+
const currentFile = files.find((f) => f.path === normalizedSelection) || files[0]
|
|
46
|
+
const frontmatter = currentFile?.frontmatter
|
|
47
|
+
const metaEntries = getMetaEntries(frontmatter)
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<div className="flex h-full min-h-0 flex-col gap-4 min-w-0">
|
|
51
|
+
<div>
|
|
52
|
+
<button
|
|
53
|
+
onClick={clearSelection}
|
|
54
|
+
className="inline-flex items-center gap-1 rounded-lg px-2 py-1 text-sm text-[var(--color-text-secondary)] transition-colors hover:bg-[var(--color-surface-hover)] hover:text-[var(--color-text-primary)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-brand)]"
|
|
55
|
+
>
|
|
56
|
+
<span className="material-symbols-outlined text-[16px]">arrow_back</span>
|
|
57
|
+
{t('settings.skills.back')}
|
|
58
|
+
</button>
|
|
59
|
+
</div>
|
|
60
|
+
|
|
61
|
+
<section className="rounded-2xl border border-[var(--color-border)] bg-[var(--color-surface-container-low)] overflow-hidden">
|
|
62
|
+
<div className="grid gap-4 px-5 py-5 lg:grid-cols-[minmax(0,1.5fr)_minmax(280px,0.9fr)] lg:items-start">
|
|
63
|
+
<div className="min-w-0">
|
|
64
|
+
<div className="text-[11px] font-semibold uppercase tracking-[0.2em] text-[var(--color-text-tertiary)] mb-2">
|
|
65
|
+
{t('settings.skills.entryEyebrow')}
|
|
66
|
+
</div>
|
|
67
|
+
<div className="flex flex-wrap items-center gap-2 mb-2">
|
|
68
|
+
<h3 className="text-[22px] font-semibold leading-tight text-[var(--color-text-primary)] break-all">
|
|
69
|
+
{meta.displayName || meta.name}
|
|
70
|
+
</h3>
|
|
71
|
+
<MetaPill>{t(`settings.skills.source.${meta.source}`)}</MetaPill>
|
|
72
|
+
{meta.version && <MetaPill>v{meta.version}</MetaPill>}
|
|
73
|
+
{meta.userInvocable && <MetaPill>{t('settings.skills.slashCommand')}</MetaPill>}
|
|
74
|
+
</div>
|
|
75
|
+
<p className="max-w-4xl text-sm leading-6 text-[var(--color-text-secondary)]">
|
|
76
|
+
{meta.description}
|
|
77
|
+
</p>
|
|
78
|
+
<div className="mt-3 flex flex-wrap gap-x-4 gap-y-2 text-xs text-[var(--color-text-tertiary)]">
|
|
79
|
+
<span>{t('settings.skills.tokenEstimate', { count: String(Math.ceil(meta.contentLength / 4)) })}</span>
|
|
80
|
+
<span>
|
|
81
|
+
{files.length} {t('settings.skills.files')}
|
|
82
|
+
</span>
|
|
83
|
+
<span>{currentFile?.isEntry ? t('settings.skills.entryFile') : currentFile?.path}</span>
|
|
84
|
+
</div>
|
|
85
|
+
</div>
|
|
86
|
+
|
|
87
|
+
<div className="grid grid-cols-2 gap-3 sm:grid-cols-4 lg:grid-cols-2">
|
|
88
|
+
<DetailStat
|
|
89
|
+
label={t('settings.skills.summary.totalFiles')}
|
|
90
|
+
value={String(files.length)}
|
|
91
|
+
icon="folder_open"
|
|
92
|
+
/>
|
|
93
|
+
<DetailStat
|
|
94
|
+
label={t('settings.skills.summary.tokens')}
|
|
95
|
+
value={t('settings.skills.tokenEstimateShort', { count: String(Math.ceil(meta.contentLength / 4)) })}
|
|
96
|
+
icon="notes"
|
|
97
|
+
/>
|
|
98
|
+
<DetailStat
|
|
99
|
+
label={t('settings.skills.summary.source')}
|
|
100
|
+
value={t(`settings.skills.source.${meta.source}`)}
|
|
101
|
+
icon="layers"
|
|
102
|
+
/>
|
|
103
|
+
<DetailStat
|
|
104
|
+
label={t('settings.skills.summary.entry')}
|
|
105
|
+
value={files.some((file) => file.isEntry) ? 'SKILL.md' : '—'}
|
|
106
|
+
icon="article"
|
|
107
|
+
/>
|
|
108
|
+
</div>
|
|
109
|
+
</div>
|
|
110
|
+
</section>
|
|
111
|
+
|
|
112
|
+
{metaEntries.length > 0 && (
|
|
113
|
+
<section className="rounded-2xl border border-[var(--color-border)] bg-[var(--color-surface)] px-5 py-4">
|
|
114
|
+
<div className="flex items-center gap-2 mb-3">
|
|
115
|
+
<span className="material-symbols-outlined text-[18px] text-[var(--color-text-tertiary)]">
|
|
116
|
+
tune
|
|
117
|
+
</span>
|
|
118
|
+
<h4 className="text-sm font-semibold text-[var(--color-text-primary)]">
|
|
119
|
+
{t('settings.skills.metaTitle')}
|
|
120
|
+
</h4>
|
|
121
|
+
</div>
|
|
122
|
+
<div className="grid gap-3 md:grid-cols-2 xl:grid-cols-3">
|
|
123
|
+
{metaEntries.map(([key, value]) => (
|
|
124
|
+
<div
|
|
125
|
+
key={key}
|
|
126
|
+
className="rounded-xl border border-[var(--color-border)] bg-[var(--color-surface-container-low)] px-3 py-3 min-w-0"
|
|
127
|
+
>
|
|
128
|
+
<div className="text-[11px] font-semibold uppercase tracking-[0.16em] text-[var(--color-text-tertiary)]">
|
|
129
|
+
{formatMetaKey(key)}
|
|
130
|
+
</div>
|
|
131
|
+
<div className="mt-2 text-sm leading-6 text-[var(--color-text-primary)] break-words">
|
|
132
|
+
{formatMetaValue(value)}
|
|
133
|
+
</div>
|
|
134
|
+
</div>
|
|
135
|
+
))}
|
|
136
|
+
</div>
|
|
137
|
+
</section>
|
|
138
|
+
)}
|
|
139
|
+
|
|
140
|
+
<section className="flex flex-1 min-h-0 min-w-0 overflow-hidden rounded-2xl border border-[var(--color-border)] bg-[var(--color-surface)]">
|
|
141
|
+
<aside className="hidden w-[250px] flex-shrink-0 border-r border-[var(--color-border)] bg-[var(--color-surface-container-low)] lg:flex lg:flex-col">
|
|
142
|
+
<div className="border-b border-[var(--color-border)] px-4 py-3">
|
|
143
|
+
<div className="text-[11px] font-semibold uppercase tracking-[0.18em] text-[var(--color-text-tertiary)]">
|
|
144
|
+
{t('settings.skills.filesPanel')}
|
|
145
|
+
</div>
|
|
146
|
+
<p className="mt-1 text-xs leading-5 text-[var(--color-text-tertiary)]">
|
|
147
|
+
{t('settings.skills.filesPanelHint')}
|
|
148
|
+
</p>
|
|
149
|
+
</div>
|
|
150
|
+
<div className="min-h-0 flex-1 overflow-y-auto p-2">
|
|
151
|
+
<TreeView
|
|
152
|
+
nodes={tree}
|
|
153
|
+
selectedPath={normalizedSelection}
|
|
154
|
+
onSelect={setSelectedFile}
|
|
155
|
+
depth={0}
|
|
156
|
+
/>
|
|
157
|
+
</div>
|
|
158
|
+
</aside>
|
|
159
|
+
|
|
160
|
+
<div className="flex min-w-0 flex-1 flex-col overflow-hidden">
|
|
161
|
+
<div className="flex flex-wrap items-center justify-between gap-2 border-b border-[var(--color-border)] bg-[var(--color-surface-container-low)] px-4 py-3">
|
|
162
|
+
<div className="min-w-0">
|
|
163
|
+
<div className="flex items-center gap-2 flex-wrap">
|
|
164
|
+
<span className="text-xs font-mono text-[var(--color-text-secondary)] break-all">
|
|
165
|
+
{currentFile?.path}
|
|
166
|
+
</span>
|
|
167
|
+
{currentFile?.isEntry && <MetaPill>{t('settings.skills.entryFile')}</MetaPill>}
|
|
168
|
+
</div>
|
|
169
|
+
<div className="mt-1 text-[11px] text-[var(--color-text-tertiary)]">
|
|
170
|
+
{t('settings.skills.readingMode', {
|
|
171
|
+
mode:
|
|
172
|
+
currentFile?.language === 'markdown'
|
|
173
|
+
? t('settings.skills.docMode')
|
|
174
|
+
: t('settings.skills.codeMode'),
|
|
175
|
+
})}
|
|
176
|
+
</div>
|
|
177
|
+
</div>
|
|
178
|
+
<div className="flex items-center gap-2">
|
|
179
|
+
<span className="rounded-full bg-[var(--color-surface)] px-2.5 py-1 text-[10px] font-semibold uppercase tracking-[0.12em] text-[var(--color-text-tertiary)] border border-[var(--color-border)]">
|
|
180
|
+
{currentFile?.language}
|
|
181
|
+
</span>
|
|
182
|
+
</div>
|
|
183
|
+
</div>
|
|
184
|
+
|
|
185
|
+
<div className="lg:hidden border-b border-[var(--color-border)] bg-[var(--color-surface)] px-3 py-2 overflow-x-auto">
|
|
186
|
+
<div className="flex gap-2 min-w-max">
|
|
187
|
+
{files.map((file) => {
|
|
188
|
+
const active = file.path === normalizedSelection
|
|
189
|
+
return (
|
|
190
|
+
<button
|
|
191
|
+
key={file.path}
|
|
192
|
+
onClick={() => setSelectedFile(file.path)}
|
|
193
|
+
className={`rounded-full border px-3 py-1.5 text-xs transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-brand)] ${
|
|
194
|
+
active
|
|
195
|
+
? 'border-[var(--color-brand)] bg-[var(--color-primary-fixed)] text-[var(--color-text-primary)]'
|
|
196
|
+
: 'border-[var(--color-border)] text-[var(--color-text-secondary)] hover:bg-[var(--color-surface-hover)]'
|
|
197
|
+
}`}
|
|
198
|
+
>
|
|
199
|
+
{file.path}
|
|
200
|
+
</button>
|
|
201
|
+
)
|
|
202
|
+
})}
|
|
203
|
+
</div>
|
|
204
|
+
</div>
|
|
205
|
+
|
|
206
|
+
<div className="min-h-0 flex-1 overflow-y-auto bg-[var(--color-surface-container-lowest)]">
|
|
207
|
+
{currentFile && (
|
|
208
|
+
<div className={currentFile.language === 'markdown' ? 'px-6 py-5 lg:px-8' : 'p-4'}>
|
|
209
|
+
{currentFile.language === 'markdown' ? (
|
|
210
|
+
<MarkdownRenderer
|
|
211
|
+
content={currentFile.body ?? currentFile.content}
|
|
212
|
+
variant="document"
|
|
213
|
+
className="mx-auto max-w-[72ch]"
|
|
214
|
+
/>
|
|
215
|
+
) : (
|
|
216
|
+
<CodeViewer
|
|
217
|
+
code={currentFile.content}
|
|
218
|
+
language={currentFile.language}
|
|
219
|
+
maxLines={9999}
|
|
220
|
+
showLineNumbers
|
|
221
|
+
/>
|
|
222
|
+
)}
|
|
223
|
+
</div>
|
|
224
|
+
)}
|
|
225
|
+
</div>
|
|
226
|
+
</div>
|
|
227
|
+
</section>
|
|
228
|
+
</div>
|
|
229
|
+
)
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
function TreeView({
|
|
233
|
+
nodes,
|
|
234
|
+
selectedPath,
|
|
235
|
+
onSelect,
|
|
236
|
+
depth,
|
|
237
|
+
}: {
|
|
238
|
+
nodes: FileTreeNode[]
|
|
239
|
+
selectedPath: string
|
|
240
|
+
onSelect: (path: string) => void
|
|
241
|
+
depth: number
|
|
242
|
+
}) {
|
|
243
|
+
return (
|
|
244
|
+
<>
|
|
245
|
+
{nodes.map((node) => (
|
|
246
|
+
<TreeItem
|
|
247
|
+
key={node.path}
|
|
248
|
+
node={node}
|
|
249
|
+
selectedPath={selectedPath}
|
|
250
|
+
onSelect={onSelect}
|
|
251
|
+
depth={depth}
|
|
252
|
+
/>
|
|
253
|
+
))}
|
|
254
|
+
</>
|
|
255
|
+
)
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
function TreeItem({
|
|
259
|
+
node,
|
|
260
|
+
selectedPath,
|
|
261
|
+
onSelect,
|
|
262
|
+
depth,
|
|
263
|
+
}: {
|
|
264
|
+
node: FileTreeNode
|
|
265
|
+
selectedPath: string
|
|
266
|
+
onSelect: (path: string) => void
|
|
267
|
+
depth: number
|
|
268
|
+
}) {
|
|
269
|
+
const [expanded, setExpanded] = useState(true)
|
|
270
|
+
const isSelected = node.path === selectedPath
|
|
271
|
+
const isDir = node.type === 'directory'
|
|
272
|
+
|
|
273
|
+
const icon = isDir ? (expanded ? 'folder_open' : 'folder') : fileIcon(node.name)
|
|
274
|
+
|
|
275
|
+
return (
|
|
276
|
+
<div>
|
|
277
|
+
<button
|
|
278
|
+
onClick={() => (isDir ? setExpanded(!expanded) : onSelect(node.path))}
|
|
279
|
+
className={`flex w-full items-center gap-1.5 rounded-lg px-2 py-1.5 text-left text-xs transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-brand)] ${
|
|
280
|
+
isSelected
|
|
281
|
+
? 'bg-[var(--color-surface-selected)] text-[var(--color-text-primary)] font-medium'
|
|
282
|
+
: 'text-[var(--color-text-secondary)] hover:bg-[var(--color-surface-hover)]'
|
|
283
|
+
}`}
|
|
284
|
+
style={{ marginLeft: `${depth * 12}px`, width: `calc(100% - ${depth * 12}px)` }}
|
|
285
|
+
>
|
|
286
|
+
{isDir ? (
|
|
287
|
+
<span className="material-symbols-outlined text-[12px] text-[var(--color-text-tertiary)]">
|
|
288
|
+
{expanded ? 'expand_more' : 'chevron_right'}
|
|
289
|
+
</span>
|
|
290
|
+
) : (
|
|
291
|
+
<span style={{ width: 12 }} />
|
|
292
|
+
)}
|
|
293
|
+
<span className="material-symbols-outlined text-[14px] text-[var(--color-text-tertiary)]">
|
|
294
|
+
{icon}
|
|
295
|
+
</span>
|
|
296
|
+
<span className="truncate">{node.name}</span>
|
|
297
|
+
</button>
|
|
298
|
+
|
|
299
|
+
{isDir && expanded && node.children && (
|
|
300
|
+
<TreeView
|
|
301
|
+
nodes={node.children}
|
|
302
|
+
selectedPath={selectedPath}
|
|
303
|
+
onSelect={onSelect}
|
|
304
|
+
depth={depth + 1}
|
|
305
|
+
/>
|
|
306
|
+
)}
|
|
307
|
+
</div>
|
|
308
|
+
)
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
function DetailStat({
|
|
312
|
+
label,
|
|
313
|
+
value,
|
|
314
|
+
icon,
|
|
315
|
+
}: {
|
|
316
|
+
label: string
|
|
317
|
+
value: string
|
|
318
|
+
icon: string
|
|
319
|
+
}) {
|
|
320
|
+
return (
|
|
321
|
+
<div className="rounded-xl border border-[var(--color-border)] bg-[var(--color-surface)] px-3 py-3">
|
|
322
|
+
<div className="flex items-center gap-2 text-[11px] uppercase tracking-[0.16em] text-[var(--color-text-tertiary)]">
|
|
323
|
+
<span className="material-symbols-outlined text-[14px]">{icon}</span>
|
|
324
|
+
<span>{label}</span>
|
|
325
|
+
</div>
|
|
326
|
+
<div className="mt-2 text-base font-semibold text-[var(--color-text-primary)] break-all">
|
|
327
|
+
{value}
|
|
328
|
+
</div>
|
|
329
|
+
</div>
|
|
330
|
+
)
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
function MetaPill({ children }: { children: ReactNode }) {
|
|
334
|
+
return (
|
|
335
|
+
<span className="rounded-full border border-[var(--color-border)] bg-[var(--color-surface)] px-2.5 py-1 text-[10px] font-semibold uppercase tracking-[0.12em] text-[var(--color-text-tertiary)]">
|
|
336
|
+
{children}
|
|
337
|
+
</span>
|
|
338
|
+
)
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
function getMetaEntries(frontmatter?: SkillFrontmatter): Array<[string, unknown]> {
|
|
342
|
+
if (!frontmatter) return []
|
|
343
|
+
|
|
344
|
+
const entries = Object.entries(frontmatter).filter(([, value]) => {
|
|
345
|
+
if (value == null) return false
|
|
346
|
+
if (typeof value === 'string') return value.trim().length > 0
|
|
347
|
+
if (Array.isArray(value)) return value.length > 0
|
|
348
|
+
return true
|
|
349
|
+
})
|
|
350
|
+
|
|
351
|
+
entries.sort((a, b) => {
|
|
352
|
+
const aIndex = META_PRIORITY.indexOf(a[0] as (typeof META_PRIORITY)[number])
|
|
353
|
+
const bIndex = META_PRIORITY.indexOf(b[0] as (typeof META_PRIORITY)[number])
|
|
354
|
+
const normalizedA = aIndex === -1 ? Number.MAX_SAFE_INTEGER : aIndex
|
|
355
|
+
const normalizedB = bIndex === -1 ? Number.MAX_SAFE_INTEGER : bIndex
|
|
356
|
+
return normalizedA - normalizedB || a[0].localeCompare(b[0])
|
|
357
|
+
})
|
|
358
|
+
|
|
359
|
+
return entries
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
function formatMetaKey(key: string) {
|
|
363
|
+
return key.replace(/[-_]/g, ' ')
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
function formatMetaValue(value: unknown) {
|
|
367
|
+
if (Array.isArray(value)) {
|
|
368
|
+
return value.map((item) => String(item)).join(', ')
|
|
369
|
+
}
|
|
370
|
+
if (typeof value === 'boolean') {
|
|
371
|
+
return value ? 'true' : 'false'
|
|
372
|
+
}
|
|
373
|
+
if (typeof value === 'object' && value !== null) {
|
|
374
|
+
return JSON.stringify(value)
|
|
375
|
+
}
|
|
376
|
+
return String(value)
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
function fileIcon(filename: string): string {
|
|
380
|
+
const ext = filename.split('.').pop()?.toLowerCase()
|
|
381
|
+
switch (ext) {
|
|
382
|
+
case 'md':
|
|
383
|
+
return 'description'
|
|
384
|
+
case 'ts':
|
|
385
|
+
case 'tsx':
|
|
386
|
+
case 'js':
|
|
387
|
+
case 'jsx':
|
|
388
|
+
case 'py':
|
|
389
|
+
case 'rs':
|
|
390
|
+
case 'go':
|
|
391
|
+
return 'code'
|
|
392
|
+
case 'json':
|
|
393
|
+
case 'yaml':
|
|
394
|
+
case 'yml':
|
|
395
|
+
case 'toml':
|
|
396
|
+
return 'data_object'
|
|
397
|
+
case 'sh':
|
|
398
|
+
case 'bash':
|
|
399
|
+
return 'terminal'
|
|
400
|
+
default:
|
|
401
|
+
return 'draft'
|
|
402
|
+
}
|
|
403
|
+
}
|