@movk/nuxt-docs 1.14.2 → 1.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/app/app.config.ts +5 -32
- package/app/app.vue +54 -32
- package/app/components/DocsAsideRightBottom.vue +1 -1
- package/app/components/OgImage/OgImageDocs.takumi.vue +90 -0
- package/app/components/PageHeaderLinks.vue +6 -16
- package/app/components/content/CommitChangelog.vue +1 -0
- package/app/components/content/Mermaid.vue +3 -1
- package/app/components/header/HeaderCTA.vue +1 -10
- package/app/components/theme-picker/ThemePicker.vue +22 -33
- package/app/composables/useTheme.ts +64 -84
- package/app/composables/useToolCall.ts +5 -8
- package/app/error.vue +1 -1
- package/app/pages/docs/[...slug].vue +6 -6
- package/app/plugins/theme.ts +39 -68
- package/app/templates/landing.vue +5 -2
- package/app/templates/releases.vue +5 -2
- package/app/types/index.d.ts +8 -57
- package/content.config.ts +1 -0
- package/modules/ai-chat/index.ts +16 -26
- package/modules/ai-chat/runtime/components/AiChat.vue +3 -3
- package/modules/ai-chat/runtime/components/AiChatFloatingInput.vue +6 -6
- package/modules/ai-chat/runtime/components/AiChatPanel.vue +216 -231
- package/modules/ai-chat/runtime/components/AiChatPreStream.vue +0 -14
- package/modules/ai-chat/runtime/composables/useAIChat.ts +25 -73
- package/modules/ai-chat/runtime/composables/useModels.ts +0 -19
- package/modules/ai-chat/runtime/server/api/ai-chat.ts +74 -48
- package/modules/ai-chat/runtime/server/utils/getModel.ts +1 -9
- package/modules/ai-chat/runtime/types.ts +5 -0
- package/nuxt.config.ts +42 -36
- package/nuxt.schema.ts +14 -99
- package/package.json +21 -25
- package/server/mcp/tools/get-page.ts +5 -47
- package/server/mcp/tools/list-getting-started-guides.ts +1 -3
- package/server/mcp/tools/list-pages.ts +9 -44
- package/utils/git.ts +26 -79
- package/app/components/OgImage/Nuxt.vue +0 -247
- package/app/composables/useAnalytics.ts +0 -7
- package/modules/ai-chat/runtime/components/AiChatReasoning.vue +0 -49
- package/modules/ai-chat/runtime/components/AiChatSlideoverFaq.vue +0 -38
- package/modules/ai-chat/runtime/components/AiChatToolCall.vue +0 -31
- package/modules/ai-chat/runtime/server/utils/docs_agent.ts +0 -54
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
const { isStreaming = false } = defineProps<{
|
|
3
|
-
/**
|
|
4
|
-
* 思考过程的文本内容
|
|
5
|
-
*/
|
|
6
|
-
text: string
|
|
7
|
-
/**
|
|
8
|
-
* 是否正在流式接收思考内容
|
|
9
|
-
* @defaultValue false
|
|
10
|
-
*/
|
|
11
|
-
isStreaming?: boolean
|
|
12
|
-
}>()
|
|
13
|
-
|
|
14
|
-
const open = ref(false)
|
|
15
|
-
const { ui, aiChat } = useAppConfig()
|
|
16
|
-
|
|
17
|
-
watch(() => isStreaming, () => {
|
|
18
|
-
open.value = isStreaming
|
|
19
|
-
}, { immediate: true })
|
|
20
|
-
|
|
21
|
-
function cleanMarkdown(text: string): string {
|
|
22
|
-
return text
|
|
23
|
-
.replace(/\*\*(.+?)\*\*/g, '$1') // Remove bold
|
|
24
|
-
.replace(/\*(.+?)\*/g, '$1') // Remove italic
|
|
25
|
-
.replace(/`(.+?)`/g, '$1') // Remove inline code
|
|
26
|
-
.replace(/^#+\s+/gm, '') // Remove headers
|
|
27
|
-
}
|
|
28
|
-
</script>
|
|
29
|
-
|
|
30
|
-
<template>
|
|
31
|
-
<UCollapsible v-model:open="open" class="flex flex-col gap-1 my-5">
|
|
32
|
-
<UButton
|
|
33
|
-
class="p-0 group"
|
|
34
|
-
color="neutral"
|
|
35
|
-
variant="link"
|
|
36
|
-
:trailing-icon="aiChat.icons.streaming || ui.icons.chevronDown"
|
|
37
|
-
:ui="{
|
|
38
|
-
trailingIcon: text.length > 0 ? 'group-data-[state=open]:rotate-180 transition-transform duration-200' : 'hidden'
|
|
39
|
-
}"
|
|
40
|
-
:label="isStreaming ? aiChat.texts.streaming : aiChat.texts.streamed"
|
|
41
|
-
/>
|
|
42
|
-
|
|
43
|
-
<template #content>
|
|
44
|
-
<div v-for="(value, index) in cleanMarkdown(text).split('\n').filter(Boolean)" :key="index">
|
|
45
|
-
<span class="whitespace-pre-wrap text-sm text-muted font-normal">{{ value }}</span>
|
|
46
|
-
</div>
|
|
47
|
-
</template>
|
|
48
|
-
</UCollapsible>
|
|
49
|
-
</template>
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
<script lang="ts" setup>
|
|
2
|
-
import type { FaqCategory } from '../types'
|
|
3
|
-
|
|
4
|
-
defineProps<{
|
|
5
|
-
/**
|
|
6
|
-
* 聊天为空时显示的常见问题分类
|
|
7
|
-
*/
|
|
8
|
-
faqQuestions: FaqCategory[]
|
|
9
|
-
}>()
|
|
10
|
-
|
|
11
|
-
defineEmits<{
|
|
12
|
-
(e: 'ask-question', question: string): void
|
|
13
|
-
}>()
|
|
14
|
-
</script>
|
|
15
|
-
|
|
16
|
-
<template>
|
|
17
|
-
<div class="flex flex-col gap-5">
|
|
18
|
-
<div
|
|
19
|
-
v-for="category in faqQuestions"
|
|
20
|
-
:key="category.category"
|
|
21
|
-
class="flex flex-col gap-1.5"
|
|
22
|
-
>
|
|
23
|
-
<h4 class="text-xs font-medium text-muted uppercase tracking-wide">
|
|
24
|
-
{{ category.category }}
|
|
25
|
-
</h4>
|
|
26
|
-
<div class="flex flex-col">
|
|
27
|
-
<button
|
|
28
|
-
v-for="question in category.items"
|
|
29
|
-
:key="question"
|
|
30
|
-
class="text-left text-sm text-muted hover:text-highlighted py-1.5 transition-colors"
|
|
31
|
-
@click="$emit('ask-question', question)"
|
|
32
|
-
>
|
|
33
|
-
{{ question }}
|
|
34
|
-
</button>
|
|
35
|
-
</div>
|
|
36
|
-
</div>
|
|
37
|
-
</div>
|
|
38
|
-
</template>
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import { motion } from 'motion-v'
|
|
3
|
-
|
|
4
|
-
defineProps<{
|
|
5
|
-
/**
|
|
6
|
-
* 工具调用的标签文本
|
|
7
|
-
*/
|
|
8
|
-
text: string
|
|
9
|
-
/**
|
|
10
|
-
* 为 true 时显示加载旋转圈
|
|
11
|
-
* @defaultValue false
|
|
12
|
-
*/
|
|
13
|
-
isLoading?: boolean
|
|
14
|
-
}>()
|
|
15
|
-
</script>
|
|
16
|
-
|
|
17
|
-
<template>
|
|
18
|
-
<motion.div
|
|
19
|
-
:initial="{ opacity: 0, y: 4 }"
|
|
20
|
-
:animate="{ opacity: 1, y: 0 }"
|
|
21
|
-
:transition="{ duration: 0.2 }"
|
|
22
|
-
class="flex items-center gap-2 px-2.5 py-1.5 rounded-lg bg-elevated/50 border border-default text-xs text-muted"
|
|
23
|
-
>
|
|
24
|
-
<UIcon
|
|
25
|
-
:name="isLoading ? 'i-lucide-loader-circle' : 'i-lucide-file-text'"
|
|
26
|
-
:class="[isLoading && 'animate-spin']"
|
|
27
|
-
class="size-4 shrink-0 text-muted"
|
|
28
|
-
/>
|
|
29
|
-
<span class="truncate">{{ text }}</span>
|
|
30
|
-
</motion.div>
|
|
31
|
-
</template>
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { tool, stepCountIs, generateText } from 'ai'
|
|
2
|
-
import { z } from 'zod'
|
|
3
|
-
|
|
4
|
-
function getSubAgentSystemPrompt(siteName: string) {
|
|
5
|
-
return `您是 ${siteName} 的文档搜索代理。您的工作是从文档中查找并检索相关信息。
|
|
6
|
-
|
|
7
|
-
**您的任务:**
|
|
8
|
-
- 使用可用的工具搜索和阅读文档页面
|
|
9
|
-
|
|
10
|
-
**指南:**
|
|
11
|
-
- 在回答之前阅读所有相关页面
|
|
12
|
-
- 返回你找到的原始信息,让主代理格式化响应
|
|
13
|
-
- 如果找不到信息,请明确说明
|
|
14
|
-
|
|
15
|
-
**输出:**
|
|
16
|
-
返回您找到的相关文档内容,包括代码示例(如果存在)。`
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export function createDocumentationAgentTool(mcpTools: Record<string, any>, model: any, siteName: string) {
|
|
20
|
-
return tool({
|
|
21
|
-
description: '从文档中搜索并检索信息。使用此工具回答有关文档的任何问题。将用户的问题作为查询参数传递。',
|
|
22
|
-
inputSchema: z.object({
|
|
23
|
-
query: z.string().describe('要在文档中搜索的问题')
|
|
24
|
-
}),
|
|
25
|
-
execute: async ({ query }, executionOptions) => {
|
|
26
|
-
const writer = (executionOptions as any)?.experimental_context?.writer
|
|
27
|
-
|
|
28
|
-
const result = await generateText({
|
|
29
|
-
model,
|
|
30
|
-
tools: mcpTools,
|
|
31
|
-
system: getSubAgentSystemPrompt(siteName),
|
|
32
|
-
stopWhen: stepCountIs(6),
|
|
33
|
-
onStepFinish: ({ toolCalls }) => {
|
|
34
|
-
if (toolCalls.length === 0) return
|
|
35
|
-
|
|
36
|
-
writer?.write({
|
|
37
|
-
id: toolCalls[0]?.toolCallId,
|
|
38
|
-
type: 'data-tool-calls',
|
|
39
|
-
data: {
|
|
40
|
-
tools: toolCalls.map((toolCall: any) => ({
|
|
41
|
-
toolName: toolCall.toolName,
|
|
42
|
-
toolCallId: toolCall.toolCallId,
|
|
43
|
-
args: toolCall.args || toolCall.input || {}
|
|
44
|
-
}))
|
|
45
|
-
}
|
|
46
|
-
})
|
|
47
|
-
},
|
|
48
|
-
prompt: query
|
|
49
|
-
})
|
|
50
|
-
|
|
51
|
-
return result.text
|
|
52
|
-
}
|
|
53
|
-
})
|
|
54
|
-
}
|