feat: enhance magic notes AI comments

This commit is contained in:
lofyer
2026-08-10 22:27:50 +08:00
parent ad79659308
commit 7d15e83153
20 changed files with 1293 additions and 116 deletions
+3 -1
View File
@@ -1,4 +1,5 @@
import { z } from 'zod'
import { magicNoteCommentFormatSchema } from './magic-notes-contracts'
export const magicNoteCommentModeSchema = z.enum([
'immediate',
@@ -14,7 +15,8 @@ export const applicationSettingsSchema = z
.object({
checkUpdatesOnStartup: z.boolean(),
magicNotesEnabled: z.boolean(),
magicNoteCommentMode: magicNoteCommentModeSchema
magicNoteCommentMode: magicNoteCommentModeSchema,
magicNoteCommentFormat: magicNoteCommentFormatSchema
})
.strict()
+15 -3
View File
@@ -37,6 +37,8 @@ import {
type ExpertUpdateInput
} from './assistant-contracts'
import type {
MagicNoteAnalysisOptions,
MagicNoteAnalysisStreamEvent,
MagicNoteDraftAnalysis,
MagicNoteDetail,
MagicNoteCreateInput,
@@ -1212,12 +1214,22 @@ export type DesktopApi = {
input: MagicNoteEntryUpdateInput
) => Promise<MagicNoteDetail>
removeEntry: (entryId: string) => Promise<MagicNoteDetail>
analyze: (entryId: string) => Promise<MagicNoteDetail>
analyze: (
entryId: string,
options: MagicNoteAnalysisOptions
) => Promise<MagicNoteDetail>
analyzeDraft: (
content: MagicNoteRichContent
content: MagicNoteRichContent,
options: MagicNoteAnalysisOptions
) => Promise<MagicNoteDraftAnalysis>
listTodos: () => Promise<MagicTodosSnapshot>
analyzeTodo: (todoId: string) => Promise<MagicTodoItem>
analyzeTodo: (
todoId: string,
options: MagicNoteAnalysisOptions
) => Promise<MagicTodoItem>
onAnalysisEvent: (
listener: (event: MagicNoteAnalysisStreamEvent) => void
) => () => void
}
knowledge: {
getSnapshot: (libraryId?: string) => Promise<KnowledgeSnapshot>
+1
View File
@@ -128,6 +128,7 @@ export const ipcChannels = {
magicNotesDeleteEntry: 'magic-notes:delete-entry',
magicNotesAnalyze: 'magic-notes:analyze',
magicNotesAnalyzeDraft: 'magic-notes:analyze-draft',
magicNotesAnalysisEvent: 'magic-notes:analysis-event',
magicTodosList: 'magic-todos:list',
magicTodosAnalyze: 'magic-todos:analyze',
knowledgeSnapshot: 'knowledge:snapshot',
+53 -4
View File
@@ -153,30 +153,79 @@ export const magicNoteEntryDeleteSchema = z
})
.strict()
export const magicNoteCommentDirectionSchema = z.enum([
'general',
'expand',
'polish',
'challenge',
'brainstorm'
])
export type MagicNoteCommentDirection = z.infer<
typeof magicNoteCommentDirectionSchema
>
export const magicNoteCommentFormatSchema = z.enum([
'combined',
'narrative',
'structured'
])
export type MagicNoteCommentFormat = z.infer<
typeof magicNoteCommentFormatSchema
>
export const magicNoteAnalysisOptionsSchema = z
.object({
requestId: z.string().uuid(),
direction: magicNoteCommentDirectionSchema,
format: magicNoteCommentFormatSchema
})
.strict()
export type MagicNoteAnalysisOptions = z.infer<
typeof magicNoteAnalysisOptionsSchema
>
export const magicNoteAnalyzeSchema = z
.object({
entryId: magicNoteIdSchema
entryId: magicNoteIdSchema,
...magicNoteAnalysisOptionsSchema.shape
})
.strict()
export const magicNoteDraftAnalyzeSchema = z
.object({
content: magicNoteRichContentSchema
content: magicNoteRichContentSchema,
...magicNoteAnalysisOptionsSchema.shape
})
.strict()
export const magicTodoIdSchema = z
.object({
todoId: magicNoteIdSchema
todoId: magicNoteIdSchema,
...magicNoteAnalysisOptionsSchema.shape
})
.strict()
export type MagicNoteCommentKind = 'summary' | 'suggestion' | 'warning'
export type MagicNoteCommentKind =
| 'narrative'
| 'summary'
| 'suggestion'
| 'warning'
export type MagicNoteComment = {
id: string
kind: MagicNoteCommentKind
content: string
direction?: MagicNoteCommentDirection
format?: MagicNoteCommentFormat
analyzedAt?: string
}
export type MagicNoteAnalysisStreamEvent = {
requestId: string
type: 'text'
delta: string
direction: MagicNoteCommentDirection
format: 'combined' | 'narrative'
}
export type MagicNoteEntry = {