@open-document/core 0.14.0 → 0.14.1
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/dist/{build-CyBlmrjS.js → build-I0cgoERP.js} +1 -1
- package/dist/{check-DUKDEem-.js → check-Dys96QSL.js} +3 -3
- package/dist/cli/bin.js +9 -9
- package/dist/{context-BPApOW9n.js → context-C-osJW5f.js} +1 -1
- package/dist/{dev-DrnOvsX3.js → dev-CC4PrIOC.js} +1 -1
- package/dist/{diff-BPMD2Knh.js → diff-DhutD4TJ.js} +2 -2
- package/dist/{export-DeVtL8aX.js → export-KrajVJO7.js} +3 -3
- package/dist/{import-WAgWsuOv.js → import-Yv34za3L.js} +3 -3
- package/dist/ops/index.js +2 -2
- package/dist/{ops-raK6424A.js → ops-Dux5HlkH.js} +2 -422
- package/dist/{preview-B8Vw9QCh.js → preview-7eqn9Wzf.js} +1 -1
- package/dist/{config-cNpYUpF6.js → session-BSbrC5gK.js} +510 -4
- package/dist/{templates-D9jAFJ8R.js → templates-s-VLTSRc.js} +3 -3
- package/dist/vite/index.js +1 -1
- package/package.json +1 -1
- package/src/app/components/agent/agent-panel.tsx +6 -1
- package/src/app/components/agent/transcript.tsx +111 -3
- package/src/app/lib/i18n-ja/agent-panel.ts +8 -0
- package/src/app/lib/i18n-ko/agent-panel.ts +8 -0
- package/src/app/lib/i18n-zh-cn/agent-panel.ts +8 -0
- package/src/app/lib/i18n-zh-tw/agent-panel.ts +8 -0
- package/src/app/lib/use-locale.ts +7 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Check, ChevronRight, CircleAlert, Copy, Pencil } from 'lucide-react';
|
|
1
|
+
import { Check, ChevronRight, CircleAlert, Copy, LoaderCircle, Pencil } from 'lucide-react';
|
|
2
2
|
import { type ReactNode, useEffect, useLayoutEffect, useRef, useState } from 'react';
|
|
3
3
|
import { Button } from '@/components/ui/button';
|
|
4
4
|
import { useAutoGrow } from '@/lib/use-auto-grow';
|
|
5
5
|
import { format, plural, useLocale } from '@/lib/use-locale';
|
|
6
6
|
import { cn } from '@/lib/utils';
|
|
7
|
-
import { stripDocSlug } from '../../../agent/prompt';
|
|
7
|
+
import { checkFixPrompt, stripDocSlug } from '../../../agent/prompt';
|
|
8
8
|
import type { AgentItem, AgentQuestion, AgentSession, RespondPayload } from '../../../agent/types';
|
|
9
9
|
import { AgentMarkdown } from './agent-markdown';
|
|
10
10
|
|
|
@@ -12,10 +12,13 @@ export function Transcript({
|
|
|
12
12
|
session,
|
|
13
13
|
onRespond,
|
|
14
14
|
onEdit,
|
|
15
|
+
onFix,
|
|
15
16
|
}: {
|
|
16
17
|
session: AgentSession;
|
|
17
18
|
onRespond: (itemId: string, payload: RespondPayload) => Promise<void>;
|
|
18
19
|
onEdit: (itemId: string, text: string) => Promise<void>;
|
|
20
|
+
/** Sends a message asking the agent to fix what a check found. */
|
|
21
|
+
onFix: (text: string) => Promise<void>;
|
|
19
22
|
}) {
|
|
20
23
|
const scrollRef = useRef<HTMLDivElement>(null);
|
|
21
24
|
const stickRef = useRef(true);
|
|
@@ -23,15 +26,20 @@ export function Transcript({
|
|
|
23
26
|
const lastText = lastItem?.kind === 'assistant' ? lastItem.text.length : 0;
|
|
24
27
|
const running = session.status === 'running';
|
|
25
28
|
const replies = replyTexts(session.items, running);
|
|
29
|
+
// Only the newest check offers a fix; an older one was already acted on or
|
|
30
|
+
// describes a file that has changed since.
|
|
31
|
+
const lastCheckId = [...session.items].reverse().find((i) => i.kind === 'check')?.id;
|
|
26
32
|
|
|
27
33
|
// Follow the stream while the user is parked at the bottom; stop once they
|
|
28
34
|
// scroll up to read, like a terminal.
|
|
35
|
+
// `lastItem` too: an item can grow in place — a check that finishes turns a
|
|
36
|
+
// one-line "checking" into a card — without the transcript getting longer.
|
|
29
37
|
// biome-ignore lint/correctness/useExhaustiveDependencies: re-run as the transcript grows or streams
|
|
30
38
|
useLayoutEffect(() => {
|
|
31
39
|
const node = scrollRef.current;
|
|
32
40
|
if (!node || !stickRef.current) return;
|
|
33
41
|
node.scrollTop = node.scrollHeight;
|
|
34
|
-
}, [session.items.length, lastText, session.status]);
|
|
42
|
+
}, [session.items.length, lastText, session.status, lastItem]);
|
|
35
43
|
|
|
36
44
|
return (
|
|
37
45
|
<div
|
|
@@ -54,6 +62,7 @@ export function Transcript({
|
|
|
54
62
|
replyText={replies.get(block.item.id)}
|
|
55
63
|
onRespond={(payload) => onRespond(block.item.id, payload)}
|
|
56
64
|
onEdit={(text) => onEdit(block.item.id, text)}
|
|
65
|
+
onFix={block.item.id === lastCheckId && !running ? onFix : undefined}
|
|
57
66
|
/>
|
|
58
67
|
)}
|
|
59
68
|
</li>
|
|
@@ -105,12 +114,14 @@ function TranscriptItem({
|
|
|
105
114
|
replyText,
|
|
106
115
|
onRespond,
|
|
107
116
|
onEdit,
|
|
117
|
+
onFix,
|
|
108
118
|
}: {
|
|
109
119
|
item: AgentItem;
|
|
110
120
|
running: boolean;
|
|
111
121
|
replyText?: string;
|
|
112
122
|
onRespond: (payload: RespondPayload) => Promise<void>;
|
|
113
123
|
onEdit: (text: string) => Promise<void>;
|
|
124
|
+
onFix?: (text: string) => Promise<void>;
|
|
114
125
|
}) {
|
|
115
126
|
switch (item.kind) {
|
|
116
127
|
case 'user':
|
|
@@ -126,6 +137,8 @@ function TranscriptItem({
|
|
|
126
137
|
return <ErrorItem text={item.text} />;
|
|
127
138
|
case 'result':
|
|
128
139
|
return <ResultItem item={item} />;
|
|
140
|
+
case 'check':
|
|
141
|
+
return <CheckItem item={item} onFix={onFix} />;
|
|
129
142
|
default:
|
|
130
143
|
return null;
|
|
131
144
|
}
|
|
@@ -417,6 +430,101 @@ function ErrorItem({ text }: { text: string }) {
|
|
|
417
430
|
);
|
|
418
431
|
}
|
|
419
432
|
|
|
433
|
+
const CHECK_SHOWN = 5;
|
|
434
|
+
|
|
435
|
+
function CheckItem({
|
|
436
|
+
item,
|
|
437
|
+
onFix,
|
|
438
|
+
}: {
|
|
439
|
+
item: Extract<AgentItem, { kind: 'check' }>;
|
|
440
|
+
onFix?: (text: string) => Promise<void>;
|
|
441
|
+
}) {
|
|
442
|
+
const t = useLocale();
|
|
443
|
+
const [busy, runBusy] = useBusy();
|
|
444
|
+
|
|
445
|
+
if (item.status === 'running') {
|
|
446
|
+
return (
|
|
447
|
+
<p className="flex items-center gap-1.5 text-[11.5px] text-muted-foreground" data-agent-check>
|
|
448
|
+
<LoaderCircle aria-hidden className="size-3 animate-spin motion-reduce:animate-none" />
|
|
449
|
+
<span className="agent-shimmer">{t.agent.checkRunning}</span>
|
|
450
|
+
</p>
|
|
451
|
+
);
|
|
452
|
+
}
|
|
453
|
+
if (item.status === 'failed') {
|
|
454
|
+
return (
|
|
455
|
+
<p className="text-[11.5px] leading-relaxed text-muted-foreground" data-agent-check>
|
|
456
|
+
<span className="text-foreground/80">{t.agent.checkFailed}</span>
|
|
457
|
+
{item.error && item.error !== 'interrupted' && (
|
|
458
|
+
<span className="mt-0.5 block break-words font-mono text-[10.5px]">{item.error}</span>
|
|
459
|
+
)}
|
|
460
|
+
</p>
|
|
461
|
+
);
|
|
462
|
+
}
|
|
463
|
+
if (item.total === 0) {
|
|
464
|
+
return (
|
|
465
|
+
<p className="flex items-center gap-1.5 text-[11.5px] text-muted-foreground" data-agent-check>
|
|
466
|
+
<Check aria-hidden className="size-3" />
|
|
467
|
+
{item.pageCount !== null
|
|
468
|
+
? format(t.agent.checkCleanPages, { count: item.pageCount })
|
|
469
|
+
: t.agent.checkClean}
|
|
470
|
+
</p>
|
|
471
|
+
);
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
const shown = item.findings.slice(0, CHECK_SHOWN);
|
|
475
|
+
const hidden = item.total - shown.length;
|
|
476
|
+
return (
|
|
477
|
+
<div
|
|
478
|
+
className="rounded-[8px] border border-hairline bg-background px-3 py-2.5"
|
|
479
|
+
data-agent-check
|
|
480
|
+
>
|
|
481
|
+
<p className="text-[11.5px] text-muted-foreground">
|
|
482
|
+
{format(plural(item.total, t.agent.checkFound), { count: item.total })}
|
|
483
|
+
</p>
|
|
484
|
+
<ul className="mt-1.5 flex flex-col gap-1">
|
|
485
|
+
{shown.map((f, n) => (
|
|
486
|
+
// biome-ignore lint/suspicious/noArrayIndexKey: a fixed report, never reordered
|
|
487
|
+
<li key={n} className="flex gap-1.5 text-[12px] leading-snug">
|
|
488
|
+
<span
|
|
489
|
+
aria-hidden
|
|
490
|
+
className={cn(
|
|
491
|
+
'mt-[0.45em] size-1.5 shrink-0 rounded-full',
|
|
492
|
+
f.severity === 'error' ? 'bg-destructive' : 'bg-muted-foreground/50',
|
|
493
|
+
)}
|
|
494
|
+
/>
|
|
495
|
+
<span className="min-w-0">
|
|
496
|
+
{f.page > 0 && (
|
|
497
|
+
<span className="mr-1 font-mono text-[10.5px] text-muted-foreground">
|
|
498
|
+
{format(t.agent.contextPage, { n: f.page })}
|
|
499
|
+
</span>
|
|
500
|
+
)}
|
|
501
|
+
{f.message}
|
|
502
|
+
</span>
|
|
503
|
+
</li>
|
|
504
|
+
))}
|
|
505
|
+
</ul>
|
|
506
|
+
{hidden > 0 && (
|
|
507
|
+
<p className="mt-1 text-[11px] text-muted-foreground">
|
|
508
|
+
{format(t.agent.checkMore, { count: hidden })}
|
|
509
|
+
</p>
|
|
510
|
+
)}
|
|
511
|
+
{onFix && (
|
|
512
|
+
<div className="mt-2.5 flex justify-end">
|
|
513
|
+
<Button
|
|
514
|
+
size="xs"
|
|
515
|
+
disabled={busy}
|
|
516
|
+
onClick={() =>
|
|
517
|
+
runBusy(() => onFix(checkFixPrompt(item.docId, item.findings, item.total)))
|
|
518
|
+
}
|
|
519
|
+
>
|
|
520
|
+
{t.agent.checkFix}
|
|
521
|
+
</Button>
|
|
522
|
+
</div>
|
|
523
|
+
)}
|
|
524
|
+
</div>
|
|
525
|
+
);
|
|
526
|
+
}
|
|
527
|
+
|
|
420
528
|
function ResultItem({ item }: { item: Extract<AgentItem, { kind: 'result' }> }) {
|
|
421
529
|
const t = useLocale();
|
|
422
530
|
const parts = [item.aborted ? t.agent.resultStopped : t.agent.resultDone];
|
|
@@ -104,4 +104,12 @@ export const AGENT_PANEL: Record<string, string> = {
|
|
|
104
104
|
'Waiting for you': 'あなたの回答待ち',
|
|
105
105
|
'Draft with agent': 'エージェントで下書き',
|
|
106
106
|
'Resize the agent panel': 'エージェントパネルの幅を変更',
|
|
107
|
+
'Checking the document…': 'ドキュメントをチェック中…',
|
|
108
|
+
'Could not check the document': 'ドキュメントをチェックできませんでした',
|
|
109
|
+
'Checked · no problems': 'チェック済み · 問題なし',
|
|
110
|
+
'Checked · no problems · {count} pages': 'チェック済み · 問題なし · {count} ページ',
|
|
111
|
+
'The check found {count} problem': 'チェックで {count} 件の問題が見つかりました',
|
|
112
|
+
'The check found {count} problems': 'チェックで {count} 件の問題が見つかりました',
|
|
113
|
+
'+{count} more': 'ほか {count} 件',
|
|
114
|
+
'Ask the agent to fix': 'エージェントに修正を依頼',
|
|
107
115
|
};
|
|
@@ -103,4 +103,12 @@ export const AGENT_PANEL: Record<string, string> = {
|
|
|
103
103
|
'Waiting for you': '입력을 기다리는 중',
|
|
104
104
|
'Draft with agent': '에이전트로 초안 작성',
|
|
105
105
|
'Resize the agent panel': '에이전트 패널 너비 조절',
|
|
106
|
+
'Checking the document…': '문서를 검사하는 중…',
|
|
107
|
+
'Could not check the document': '문서를 검사할 수 없습니다',
|
|
108
|
+
'Checked · no problems': '검사 완료 · 문제 없음',
|
|
109
|
+
'Checked · no problems · {count} pages': '검사 완료 · 문제 없음 · {count}쪽',
|
|
110
|
+
'The check found {count} problem': '검사에서 문제 {count}개를 찾았습니다',
|
|
111
|
+
'The check found {count} problems': '검사에서 문제 {count}개를 찾았습니다',
|
|
112
|
+
'+{count} more': '그 외 {count}개',
|
|
113
|
+
'Ask the agent to fix': '에이전트에게 수정 요청',
|
|
106
114
|
};
|
|
@@ -102,4 +102,12 @@ export const AGENT_PANEL: Record<string, string> = {
|
|
|
102
102
|
'Waiting for you': '等待你的回复',
|
|
103
103
|
'Draft with agent': '用 Agent 起草',
|
|
104
104
|
'Resize the agent panel': '调整 Agent 面板宽度',
|
|
105
|
+
'Checking the document…': '正在检查文档…',
|
|
106
|
+
'Could not check the document': '无法检查文档',
|
|
107
|
+
'Checked · no problems': '已检查 · 没有问题',
|
|
108
|
+
'Checked · no problems · {count} pages': '已检查 · 没有问题 · 共 {count} 页',
|
|
109
|
+
'The check found {count} problem': '检查发现 {count} 个问题',
|
|
110
|
+
'The check found {count} problems': '检查发现 {count} 个问题',
|
|
111
|
+
'+{count} more': '还有 {count} 个',
|
|
112
|
+
'Ask the agent to fix': '请 agent 修正',
|
|
105
113
|
};
|
|
@@ -102,4 +102,12 @@ export const AGENT_PANEL: Record<string, string> = {
|
|
|
102
102
|
'Waiting for you': '等待你的回覆',
|
|
103
103
|
'Draft with agent': '用 Agent 起草',
|
|
104
104
|
'Resize the agent panel': '調整 Agent 面板寬度',
|
|
105
|
+
'Checking the document…': '正在檢查文件…',
|
|
106
|
+
'Could not check the document': '無法檢查文件',
|
|
107
|
+
'Checked · no problems': '已檢查 · 沒有問題',
|
|
108
|
+
'Checked · no problems · {count} pages': '已檢查 · 沒有問題 · 共 {count} 頁',
|
|
109
|
+
'The check found {count} problem': '檢查發現 {count} 個問題',
|
|
110
|
+
'The check found {count} problems': '檢查發現 {count} 個問題',
|
|
111
|
+
'+{count} more': '還有 {count} 個',
|
|
112
|
+
'Ask the agent to fix': '請 agent 修正',
|
|
105
113
|
};
|
|
@@ -113,6 +113,13 @@ const AGENT = {
|
|
|
113
113
|
xhigh: 'Extra high',
|
|
114
114
|
max: 'Max',
|
|
115
115
|
},
|
|
116
|
+
checkRunning: 'Checking the document…',
|
|
117
|
+
checkFailed: 'Could not check the document',
|
|
118
|
+
checkClean: 'Checked · no problems',
|
|
119
|
+
checkCleanPages: 'Checked · no problems · {count} pages',
|
|
120
|
+
checkFound: { one: 'The check found {count} problem', other: 'The check found {count} problems' },
|
|
121
|
+
checkMore: '+{count} more',
|
|
122
|
+
checkFix: 'Ask the agent to fix',
|
|
116
123
|
presenceEditing: '{provider} is editing',
|
|
117
124
|
presenceThinking: 'Thinking',
|
|
118
125
|
presenceWaiting: 'Waiting for you',
|