mirror of
https://github.com/lobehub/lobehub
synced 2026-04-21 17:47:27 +00:00
* ✨ feat: add slash action tags in chat input Made-with: Cursor * ✨ feat: enhance editor with new slash actions and localization updates - Added new slash actions: change tone, condense, expand, polish, rewrite, summarize, and translate. - Updated localization files for English and Chinese to include new action tags and slash commands. - Removed deprecated useSlashItems component and integrated its functionality directly into InputEditor. Signed-off-by: Innei <tukon479@gmail.com> * ✨ feat: add slash placement configuration to chat input components - Introduced `slashPlacement` prop to `ChatInputProvider`, `StoreUpdater`, and `InputEditor` for customizable slash menu positioning. - Updated initial state to include `slashPlacement` with default value 'top'. - Adjusted `ChatInput` and `InputArea` components to utilize the new `slashPlacement` prop. This enhancement allows for better control over the user interface in chat input interactions. Signed-off-by: Innei <tukon479@gmail.com> * ✨ feat: implement command bus for slash action tags processing Add command bus system to parse and execute slash commands (compact context, new topic). Refactor action tag categories from ai/prompt to command/skill. Add useEnabledSkills hook for dynamic skill registration. * feat: compress command Signed-off-by: Innei <tukon479@gmail.com> * refactor: compress Signed-off-by: Innei <tukon479@gmail.com> * fix: skill inject * ✨ feat: slash action tags with context engine integration Made-with: Cursor * ✨ feat: add topic reference builtin tool and server runtime Made-with: Cursor * ✨ feat: add topic mention items and update ReferTopic integration Made-with: Cursor * 🐛 fix: preserve editorData through assistant-group edit flow and update RichTextMessage reactively - EditState now forwards editorData from EditorModal to modifyMessageContent - modifyMessageContent accepts and passes editorData to updateMessageContent - RichTextMessage uses useEditor + effect to update document on content change instead of key-based remount - Refactored RichTextMessage plugins to use shared createChatInputRichPlugins() * ✨ feat(context-engine): add metadata types and update processors/providers Made-with: Cursor * ✨ feat(chat-input): add slash action tags and restore failed input state * 🔧 chore: update package dependencies and enhance Vite configuration - Changed @lobehub/ui dependency to a specific package URL. - Added multiple SPA entry points and layout files to the Vite warmup configuration. - Removed unused monorepo packages from sharedOptimizeDeps and added various dayjs locales for better localization support. Signed-off-by: Innei <tukon479@gmail.com> * 🔧 chore: update @lobehub/ui dependency to version 5.4.0 in package.json Signed-off-by: Innei <tukon479@gmail.com> * 🐛 fix: correct SkillsApiName.runSkill to activateSkill and update trimmed content assertions * 🐛 fix: resolve type errors in context-engine tests and InputEditor slashPlacement * 🐛 fix: update runSkill to activateSkill in conversationLifecycle test * 🐛 fix: avoid regex backtracking in placeholder parser * ✨ feat(localization): add action tags and tooltips for slash commands across multiple languages Signed-off-by: Innei <tukon479@gmail.com> * 🐛 fix: preserve file attachments when /newTopic has no text content * cleanup Signed-off-by: Innei <tukon479@gmail.com> --------- Signed-off-by: Innei <tukon479@gmail.com>
76 lines
2.4 KiB
TypeScript
76 lines
2.4 KiB
TypeScript
import debug from 'debug';
|
|
|
|
import { BaseProcessor } from '../base/BaseProcessor';
|
|
import type { Message, PipelineContext, ProcessorOptions } from '../types';
|
|
|
|
declare module '../types' {
|
|
interface PipelineContextMetadataOverrides {
|
|
compressedGroupRoleTransformProcessed?: number;
|
|
}
|
|
}
|
|
|
|
const log = debug('context-engine:processor:CompressedGroupRoleTransformProcessor');
|
|
|
|
/**
|
|
* Compressed Group Role Transform Processor
|
|
*
|
|
* Transforms messages with role='compressedGroup' to role='user' before
|
|
* sending to the model. The 'compressedGroup' role is used for UI rendering
|
|
* to display compressed/summarized conversation history, but models don't
|
|
* understand this role.
|
|
*
|
|
* The compressed summary content is wrapped in a system context block to
|
|
* provide historical context to the model.
|
|
*
|
|
* Flow:
|
|
* 1. DB stores compression groups with role='compressedGroup'
|
|
* 2. conversation-flow passes them through for UI rendering
|
|
* 3. This processor transforms to role='user' with wrapped content before model API call
|
|
*
|
|
* @example
|
|
* ```typescript
|
|
* const processor = new CompressedGroupRoleTransformProcessor();
|
|
* const result = await processor.process(context);
|
|
* // All compressedGroup messages are now user messages with wrapped content
|
|
* ```
|
|
*/
|
|
export class CompressedGroupRoleTransformProcessor extends BaseProcessor {
|
|
readonly name = 'CompressedGroupRoleTransformProcessor';
|
|
|
|
constructor(options: ProcessorOptions = {}) {
|
|
super(options);
|
|
}
|
|
|
|
protected async doProcess(context: PipelineContext): Promise<PipelineContext> {
|
|
const clonedContext = this.cloneContext(context);
|
|
|
|
let processedCount = 0;
|
|
|
|
clonedContext.messages = clonedContext.messages.map((msg: Message) => {
|
|
if (msg.role === 'compressedGroup') {
|
|
processedCount++;
|
|
log(`Transforming compressedGroup message to user role`);
|
|
|
|
// Wrap the compressed summary content in a context block
|
|
const wrappedContent = msg.content
|
|
? `<compressed_history_summary>\n${msg.content}\n</compressed_history_summary>`
|
|
: '';
|
|
|
|
return {
|
|
...msg,
|
|
content: wrappedContent,
|
|
role: 'user',
|
|
};
|
|
}
|
|
|
|
return msg;
|
|
});
|
|
|
|
// Update metadata
|
|
clonedContext.metadata.compressedGroupRoleTransformProcessed = processedCount;
|
|
|
|
log(`Compressed group role transform completed: ${processedCount} messages processed`);
|
|
|
|
return this.markAsExecuted(clonedContext);
|
|
}
|
|
}
|