agent-configs 1.0.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.
Files changed (85) hide show
  1. package/README.md +223 -0
  2. package/agents/architect.md +211 -0
  3. package/agents/code-reviewer.md +104 -0
  4. package/agents/planner.md +119 -0
  5. package/agents/refactor-cleaner.md +306 -0
  6. package/agents/security-reviewer.md +545 -0
  7. package/agents/tdd-guide.md +280 -0
  8. package/bundles/bk-chat-bundle/README.md +48 -0
  9. package/bundles/bk-chat-bundle/manifest.json +10 -0
  10. package/bundles/continuous-learning/.claude/commands/evolve.md +190 -0
  11. package/bundles/continuous-learning/.claude/commands/instinct-status.md +64 -0
  12. package/bundles/continuous-learning/.claude/commands/learn.md +83 -0
  13. package/bundles/continuous-learning/.claude/hooks/learning-end.js +85 -0
  14. package/bundles/continuous-learning/.claude/hooks/observe.js +131 -0
  15. package/bundles/continuous-learning/.claude/lib/learning.js +559 -0
  16. package/bundles/continuous-learning/.claude/lib/utils.js +312 -0
  17. package/bundles/continuous-learning/.claude/skills/continuous-learning/SKILL.md +200 -0
  18. package/bundles/continuous-learning/.cursor/hooks/learning-end.js +102 -0
  19. package/bundles/continuous-learning/.cursor/rules/continuous-learning.mdc +34 -0
  20. package/bundles/continuous-learning/.cursor/skills/continuous-learning/SKILL.md +77 -0
  21. package/bundles/continuous-learning/README.md +159 -0
  22. package/bundles/continuous-learning/manifest.json +51 -0
  23. package/bundles/planning-bundle/README.md +34 -0
  24. package/bundles/planning-bundle/manifest.json +10 -0
  25. package/bundles/review-bundle/README.md +43 -0
  26. package/bundles/review-bundle/manifest.json +11 -0
  27. package/bundles/shared-memory/.claude/commands/list-sessions.md +124 -0
  28. package/bundles/shared-memory/.claude/commands/load-session.md +169 -0
  29. package/bundles/shared-memory/.claude/commands/save-session.md +137 -0
  30. package/bundles/shared-memory/.claude/hooks/memory-compact.js +43 -0
  31. package/bundles/shared-memory/.claude/hooks/memory-end.js +42 -0
  32. package/bundles/shared-memory/.claude/hooks/memory-start.js +59 -0
  33. package/bundles/shared-memory/.claude/lib/memory.js +416 -0
  34. package/bundles/shared-memory/.claude/lib/utils.js +209 -0
  35. package/bundles/shared-memory/.claude/skills/shared-memory/SKILL.md +183 -0
  36. package/bundles/shared-memory/.cursor/hooks/memory-start.js +42 -0
  37. package/bundles/shared-memory/.cursor/rules/shared-memory.mdc +37 -0
  38. package/bundles/shared-memory/.cursor/skills/shared-memory/SKILL.md +183 -0
  39. package/bundles/tdd-bundle/README.md +33 -0
  40. package/bundles/tdd-bundle/manifest.json +10 -0
  41. package/cli.js +978 -0
  42. package/commands/build-fix.md +29 -0
  43. package/commands/code-review.md +40 -0
  44. package/commands/e2e.md +363 -0
  45. package/commands/learn.md +114 -0
  46. package/commands/plan.md +113 -0
  47. package/commands/refactor-clean.md +28 -0
  48. package/commands/tdd.md +326 -0
  49. package/commands/test-coverage.md +27 -0
  50. package/commands/update-codemaps.md +17 -0
  51. package/commands/update-docs.md +31 -0
  52. package/configs.json +158 -0
  53. package/hooks/hooks.json +101 -0
  54. package/package.json +58 -0
  55. package/rules/agents.md +49 -0
  56. package/rules/coding-style.md +70 -0
  57. package/rules/git-workflow.md +45 -0
  58. package/rules/hooks.md +46 -0
  59. package/rules/patterns.md +55 -0
  60. package/rules/performance.md +47 -0
  61. package/rules/security.md +36 -0
  62. package/rules/testing.md +30 -0
  63. package/skills/ai-config-architect/SKILL.md +59 -0
  64. package/skills/ai-config-architect/references/agents.md +77 -0
  65. package/skills/ai-config-architect/references/commands.md +66 -0
  66. package/skills/ai-config-architect/references/hooks.md +70 -0
  67. package/skills/ai-config-architect/references/patterns.md +66 -0
  68. package/skills/ai-config-architect/references/platforms.md +82 -0
  69. package/skills/ai-config-architect/references/rules.md +66 -0
  70. package/skills/ai-config-architect/references/skills.md +67 -0
  71. package/skills/bk-chat-helper/SKILL.md +398 -0
  72. package/skills/bk-chat-helper/references/api-reference.md +606 -0
  73. package/skills/bk-chat-helper/references/examples.md +789 -0
  74. package/skills/bk-chat-helper/references/integration-guide.md +583 -0
  75. package/skills/bk-chat-x/SKILL.md +400 -0
  76. package/skills/bk-chat-x/references/components-api.md +340 -0
  77. package/skills/bk-chat-x/references/examples.md +386 -0
  78. package/skills/bk-chat-x/references/shortcuts-guide.md +375 -0
  79. package/skills/coding-standards/SKILL.md +523 -0
  80. package/skills/security-review/SKILL.md +497 -0
  81. package/skills/security-review/references/cloud-infrastructure-security.md +361 -0
  82. package/skills/strategic-compact/SKILL.md +66 -0
  83. package/skills/strategic-compact/scripts/suggest-compact.sh +52 -0
  84. package/skills/tdd-workflow/SKILL.md +412 -0
  85. package/skills/verification-loop/SKILL.md +128 -0
@@ -0,0 +1,400 @@
1
+ ---
2
+ name: bk-chat-x
3
+ description: 蓝鲸智云 AI Chat UI 组件库使用指南,提供 ChatInput/MessageContainer/ShortcutBtns 等纯 UI 组件。**必须与 bk-chat-helper skill 配合使用**:chat-x 负责 UI 渲染,chat-helper 负责业务逻辑和 API 调用。当用户开发 AI 小鲸、智能体、AI 聊天界面时,应同时参考这两个 skill。
4
+ metadata:
5
+ author: blueking
6
+ version: "1.0"
7
+ ---
8
+
9
+ # @blueking/chat-x 组件库使用指南
10
+
11
+ ## 快速开始
12
+
13
+ ### 安装
14
+
15
+ ```bash
16
+ pnpm add @blueking/chat-x
17
+ ```
18
+
19
+ ### 核心组件引入
20
+
21
+ ```typescript
22
+ import {
23
+ // 分子组件
24
+ ChatInput, // 聊天输入框
25
+ MessageContainer, // 消息容器
26
+ MessageRender, // 消息渲染器
27
+ ContentRender, // 内容渲染器
28
+ ShortcutBtns, // 快捷指令按钮组
29
+ ShortcutRender, // 快捷指令表单渲染
30
+ AiSelection, // AI 划词选择弹窗
31
+
32
+ // 枚举和类型
33
+ MessageRole,
34
+ MessageStatus,
35
+ MessageContentType,
36
+ type Message,
37
+ type Shortcut,
38
+ type IToolBtn,
39
+ type TagSchema,
40
+ } from '@blueking/chat-x';
41
+ ```
42
+
43
+ ## 核心组件
44
+
45
+ ### 1. ChatInput 聊天输入框
46
+
47
+ ```vue
48
+ <template>
49
+ <ChatInput
50
+ v-model="inputValue"
51
+ v-model:cite="citeContent"
52
+ :message-status="messageStatus"
53
+ :placeholder="placeholder"
54
+ :prompts="prompts"
55
+ :resources="resources"
56
+ :shortcuts="shortcuts"
57
+ :shortcut-id="selectedShortcutId"
58
+ :on-send-message="handleSendMessage"
59
+ :on-stop-sending="handleStopSending"
60
+ @select-shortcut="handleSelectShortcut"
61
+ @delete-shortcut="handleDeleteShortcut"
62
+ />
63
+ </template>
64
+
65
+ <script setup lang="ts">
66
+ import { ref } from 'vue';
67
+ import { ChatInput, MessageStatus, type TagSchema, type Shortcut } from '@blueking/chat-x';
68
+
69
+ const inputValue = ref<string | TagSchema>('');
70
+ const citeContent = ref('');
71
+ const messageStatus = ref(MessageStatus.Complete);
72
+ const selectedShortcutId = ref<string | null>(null);
73
+
74
+ // Prompts (输入 / 触发)
75
+ const prompts = ref(['帮我写一篇文章', '解释这段代码']);
76
+
77
+ // Resources (输入 @ 触发)
78
+ const resources = ref([
79
+ { id: 'file', name: '上传文件', type: 'file' },
80
+ { id: 'image', name: '上传图片', type: 'image' },
81
+ ]);
82
+
83
+ // Shortcuts 快捷指令
84
+ const shortcuts = ref<Shortcut[]>([
85
+ { id: 'translate', name: '翻译' },
86
+ { id: 'explain', name: '解释' },
87
+ ]);
88
+
89
+ const handleSendMessage = async (value: string, docSchema: TagSchema) => {
90
+ messageStatus.value = MessageStatus.Streaming;
91
+ // 发送消息逻辑...
92
+ messageStatus.value = MessageStatus.Complete;
93
+ };
94
+
95
+ const handleStopSending = async () => {
96
+ messageStatus.value = MessageStatus.Stop;
97
+ };
98
+
99
+ const handleSelectShortcut = (shortcut: Shortcut, text?: string) => {
100
+ selectedShortcutId.value = shortcut.id;
101
+ };
102
+
103
+ const handleDeleteShortcut = () => {
104
+ selectedShortcutId.value = null;
105
+ };
106
+ </script>
107
+ ```
108
+
109
+ **ChatInput Props:**
110
+
111
+ | 属性 | 类型 | 说明 |
112
+ |------|------|------|
113
+ | modelValue | `string \| TagSchema` | 输入值 (v-model) |
114
+ | cite | `string` | 引用内容 (v-model:cite) |
115
+ | messageStatus | `MessageStatus` | 控制按钮状态 |
116
+ | placeholder | `string` | 占位文本 |
117
+ | prompts | `string[]` | Prompt 列表 (/ 触发) |
118
+ | resources | `IAiSlashMenuItem[]` | 资源列表 (@ 触发) |
119
+ | shortcuts | `Shortcut[]` | 快捷指令列表 |
120
+ | shortcutId | `string` | 当前选中的快捷指令 ID |
121
+ | onSendMessage | `(value, docSchema) => Promise<void>` | 发送回调 |
122
+ | onStopSending | `() => Promise<void>` | 停止回调 |
123
+
124
+ ### 2. MessageContainer 消息容器
125
+
126
+ ```vue
127
+ <template>
128
+ <MessageContainer
129
+ v-model:selected-messages="selectedMessages"
130
+ :messages="messages"
131
+ :message-status="messageStatus"
132
+ :enable-selection="enableSelection"
133
+ :on-agent-action="handleAgentAction"
134
+ :on-user-action="handleUserAction"
135
+ @stop-streaming="handleStopStreaming"
136
+ >
137
+ <!-- 自定义消息渲染 (可选) -->
138
+ <template #default="{ message }">
139
+ <CustomMessage v-if="message.role === 'custom'" :message="message" />
140
+ <MessageRender v-else :message="message" :on-action="handleAction" />
141
+ </template>
142
+ </MessageContainer>
143
+ </template>
144
+
145
+ <script setup lang="ts">
146
+ import { ref } from 'vue';
147
+ import {
148
+ MessageContainer,
149
+ MessageRender,
150
+ MessageRole,
151
+ MessageStatus,
152
+ type Message,
153
+ type IToolBtn
154
+ } from '@blueking/chat-x';
155
+
156
+ const messages = ref<Message[]>([]);
157
+ const messageStatus = ref(MessageStatus.Complete);
158
+ const selectedMessages = ref<Message[]>([]);
159
+ const enableSelection = ref(false);
160
+
161
+ // AI 消息工具操作
162
+ const handleAgentAction = async (tool: IToolBtn) => {
163
+ switch (tool.id) {
164
+ case 'copy':
165
+ // 复制由组件内部处理
166
+ break;
167
+ case 'like':
168
+ return ['回答准确', '信息全面']; // 返回反馈原因列表
169
+ case 'unlike':
170
+ return ['信息错误', '回答不相关'];
171
+ case 'rebuild':
172
+ // 重新生成逻辑
173
+ break;
174
+ }
175
+ };
176
+
177
+ // 用户消息工具操作
178
+ const handleUserAction = async (tool: IToolBtn) => {
179
+ switch (tool.id) {
180
+ case 'edit':
181
+ // 编辑逻辑
182
+ break;
183
+ case 'delete':
184
+ // 删除逻辑
185
+ break;
186
+ }
187
+ };
188
+
189
+ const handleStopStreaming = () => {
190
+ messageStatus.value = MessageStatus.Stop;
191
+ };
192
+ </script>
193
+ ```
194
+
195
+ **MessageContainer Props:**
196
+
197
+ | 属性 | 类型 | 说明 |
198
+ |------|------|------|
199
+ | messages | `Message[]` | 消息列表 |
200
+ | messageStatus | `MessageStatus` | 当前消息状态 |
201
+ | enableSelection | `boolean` | 是否启用多选 |
202
+ | selectedMessages | `Message[]` | 选中的消息 (v-model) |
203
+ | onAgentAction | `(tool) => Promise<string[] \| void>` | AI 消息操作回调 |
204
+ | onUserAction | `(tool) => Promise<void>` | 用户消息操作回调 |
205
+
206
+ ### 3. AiSelection 划词选择
207
+
208
+ ```vue
209
+ <template>
210
+ <AiSelection
211
+ v-model:visible="selectionVisible"
212
+ :shortcuts="shortcuts"
213
+ :max-shortcut-count="3"
214
+ :offset="10"
215
+ @select-shortcut="handleSelectShortcut"
216
+ @selection-change="handleSelectionChange"
217
+ />
218
+ </template>
219
+
220
+ <script setup lang="ts">
221
+ import { ref } from 'vue';
222
+ import { AiSelection, type Shortcut } from '@blueking/chat-x';
223
+
224
+ const selectionVisible = ref(false);
225
+ const shortcuts = ref<Shortcut[]>([
226
+ { id: 'ask', name: '问问小鲸' },
227
+ { id: 'translate', name: '翻译' },
228
+ ]);
229
+
230
+ const handleSelectShortcut = (shortcut: Shortcut, selectedText: string) => {
231
+ console.log('快捷指令:', shortcut.name, '选中文本:', selectedText);
232
+ };
233
+
234
+ const handleSelectionChange = (text: string) => {
235
+ console.log('选区变化:', text);
236
+ };
237
+ </script>
238
+ ```
239
+
240
+ ### 4. ShortcutRender 快捷指令表单
241
+
242
+ ```vue
243
+ <template>
244
+ <ShortcutRender
245
+ v-if="selectedShortcut?.components?.length"
246
+ :name="selectedShortcut.name"
247
+ :components="selectedShortcut.components"
248
+ :form-model="selectedShortcut.formModel"
249
+ @close="handleClose"
250
+ @submit="handleSubmit"
251
+ />
252
+ </template>
253
+
254
+ <script setup lang="ts">
255
+ import { ref } from 'vue';
256
+ import { ShortcutRender, type Shortcut } from '@blueking/chat-x';
257
+
258
+ const selectedShortcut = ref<Shortcut>({
259
+ id: 'translate',
260
+ name: '翻译',
261
+ components: [
262
+ {
263
+ type: 'select',
264
+ key: 'targetLang',
265
+ name: '目标语言',
266
+ props: {
267
+ options: [
268
+ { label: '英文', value: 'en' },
269
+ { label: '中文', value: 'zh' },
270
+ ]
271
+ }
272
+ },
273
+ {
274
+ type: 'textarea',
275
+ key: 'content',
276
+ name: '翻译内容',
277
+ fillBack: true,
278
+ }
279
+ ]
280
+ });
281
+
282
+ const handleClose = () => {
283
+ selectedShortcut.value = null;
284
+ };
285
+
286
+ const handleSubmit = (formModel: Record<string, unknown>) => {
287
+ console.log('提交表单:', formModel);
288
+ };
289
+ </script>
290
+ ```
291
+
292
+ ## 消息类型
293
+
294
+ ```typescript
295
+ // 消息角色
296
+ enum MessageRole {
297
+ User = 'user', // 用户消息
298
+ Assistant = 'assistant', // AI 助手
299
+ Reasoning = 'reasoning', // 推理过程
300
+ Tool = 'tool', // 工具调用结果
301
+ Activity = 'activity', // 活动消息 (引用文档等)
302
+ Info = 'info', // 信息消息
303
+ System = 'system', // 系统消息
304
+ }
305
+
306
+ // 消息状态
307
+ enum MessageStatus {
308
+ Pending = 'pending', // 等待中
309
+ Streaming = 'streaming', // 流式输出中
310
+ Complete = 'complete', // 完成
311
+ Error = 'error', // 错误
312
+ Stop = 'stop', // 已停止
313
+ Disabled = 'disabled', // 禁用
314
+ }
315
+ ```
316
+
317
+ ## 组件组合使用
318
+
319
+ 典型的 AI 聊天页面结构:
320
+
321
+ ```vue
322
+ <template>
323
+ <div class="chat-page">
324
+ <!-- 1. 空消息时显示快捷指令 -->
325
+ <ShortcutBtns v-if="messages.length === 0" :shortcuts="shortcuts" />
326
+
327
+ <!-- 2. 有消息时显示消息列表 -->
328
+ <MessageContainer v-else :messages="messages" :message-status="messageStatus" />
329
+
330
+ <!-- 3. 快捷指令表单 (与 ChatInput 互斥) -->
331
+ <ShortcutRender v-if="selectedShortcut?.components?.length" v-bind="selectedShortcut" />
332
+
333
+ <!-- 4. 输入框 -->
334
+ <ChatInput v-else v-model="userInput" :on-send-message="handleSendMessage" />
335
+
336
+ <!-- 5. 划词选择 (全局) -->
337
+ <AiSelection v-model:visible="aiSelectionVisible" :shortcuts="shortcuts" />
338
+ </div>
339
+ </template>
340
+ ```
341
+
342
+ **关键交互流程:**
343
+
344
+ 1. **发送消息**:`ChatInput.onSendMessage` → 添加用户消息 → 添加 AI 占位消息 → 流式更新
345
+ 2. **快捷指令**:选择快捷指令 → 有表单则显示 `ShortcutRender`,无表单则直接发送
346
+ 3. **划词操作**:选中文本 → `AiSelection` 显示 → 选择指令 → 执行或填充表单
347
+ 4. **消息操作**:`onAgentAction` / `onUserAction` 处理复制、点赞、编辑等
348
+
349
+ > 完整实现代码见 [examples.md](examples.md)
350
+
351
+ ## 自定义消息类型
352
+
353
+ 通过声明合并扩展消息类型:
354
+
355
+ ```typescript
356
+ // 在项目中声明
357
+ declare global {
358
+ interface AIBluekingMessageMap {
359
+ flow: BaseMessage<'flow', FlowContent>;
360
+ custom: BaseMessage<'custom', CustomContent>;
361
+ }
362
+ }
363
+
364
+ // 使用自定义消息
365
+ <MessageContainer :messages="messages">
366
+ <template #default="{ message }">
367
+ <FlowMessage v-if="message.role === 'flow'" :content="message.content" />
368
+ <MessageRender v-else :message="message" />
369
+ </template>
370
+ </MessageContainer>
371
+ ```
372
+
373
+ ## Composables 组合式函数
374
+
375
+ ```typescript
376
+ import {
377
+ useClipboard, // 剪贴板操作
378
+ useContainerScrollProvider, // 滚动控制 (Provider)
379
+ useContainerScrollConsumer, // 滚动控制 (Consumer)
380
+ useAnimationText, // 文本动画
381
+ useGlobalConfig, // 全局配置
382
+ } from '@blueking/chat-x';
383
+
384
+ // 示例:剪贴板
385
+ const { copy } = useClipboard();
386
+ await copy('复制的文本');
387
+
388
+ // 示例:滚动控制
389
+ const { isScrollBottom, toScrollBottom } = useContainerScrollProvider(
390
+ containerRef,
391
+ bottomRef
392
+ );
393
+ ```
394
+
395
+ ## 更多资源
396
+
397
+ - 详细组件 API 参考: [references/components-api.md](references/components-api.md)
398
+ - 快捷指令配置: [references/shortcuts-guide.md](references/shortcuts-guide.md)
399
+ - 完整代码示例: [references/examples.md](references/examples.md)
400
+ - 主题定制: 查看 `packages/chat-x/wikis/theme/theme.md`