@lemonriver/core 0.7.0 → 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 (66) hide show
  1. package/README.md +3 -1
  2. package/dist/{build-CKwrex8y.js → build-CiT4CNey.js} +1 -1
  3. package/dist/cli/bin.js +12 -5
  4. package/dist/client-DpO_eR9X.js +57 -0
  5. package/dist/{config-B1_gk0sy.js → config-BI3VRI2n.js} +7186 -5275
  6. package/dist/{dev-DZ2Yzl2p.js → dev-DpzBn_sf.js} +3 -3
  7. package/dist/index.js +1 -1
  8. package/dist/locale/index.js +1 -1
  9. package/dist/mcp-CjYDzcJa.js +262 -0
  10. package/dist/{preview-hMDcuHfP.js → preview-Dro8hl5_.js} +2 -2
  11. package/dist/{update-CMRxtTc9.js → update-b1dSg_FW.js} +17 -17
  12. package/dist/vite/index.js +1 -1
  13. package/dist/{zh-tw-DcrDeKxr.js → zh-tw-BhYyMx0-.js} +40 -40
  14. package/package.json +1 -1
  15. package/skills/slide-authoring/SKILL.md +2 -0
  16. package/src/app/lemonriver/agent-providers/section.tsx +13 -4
  17. package/src/app/lemonriver/backup/client.ts +177 -0
  18. package/src/app/lemonriver/backup/guide.test.ts +45 -0
  19. package/src/app/lemonriver/backup/guide.ts +138 -0
  20. package/src/app/lemonriver/backup/model.test.ts +96 -0
  21. package/src/app/lemonriver/backup/model.ts +255 -0
  22. package/src/app/lemonriver/backup/places.test.ts +154 -0
  23. package/src/app/lemonriver/backup/places.ts +74 -0
  24. package/src/app/lemonriver/board/blocks/snapshot.ts +10 -2
  25. package/src/app/lemonriver/board/self-check-runner.tsx +60 -15
  26. package/src/app/lemonriver/board/use-self-check.ts +1 -1
  27. package/src/app/lemonriver/chrome/app-chrome.tsx +6 -0
  28. package/src/app/lemonriver/chrome/sidebar-extras.tsx +9 -1
  29. package/src/app/lemonriver/features.test.ts +5 -0
  30. package/src/app/lemonriver/features.ts +11 -1
  31. package/src/app/lemonriver/guide/guide-prompt.tsx +89 -0
  32. package/src/app/lemonriver/guide/state.ts +29 -0
  33. package/src/app/lemonriver/guide/use-guide.ts +17 -0
  34. package/src/app/lemonriver/help/help-page.tsx +267 -0
  35. package/src/app/lemonriver/help/model.test.ts +179 -0
  36. package/src/app/lemonriver/help/model.ts +105 -0
  37. package/src/app/lemonriver/home/home-page.tsx +25 -7
  38. package/src/app/lemonriver/mcp/respond.ts +47 -0
  39. package/src/app/lemonriver/mcp/screenshot.tsx +155 -0
  40. package/src/app/lemonriver/mcp/self-check.tsx +65 -0
  41. package/src/app/lemonriver/outline/describe-page.tsx +3 -1
  42. package/src/app/lemonriver/routes.test.tsx +4 -2
  43. package/src/app/lemonriver/routes.tsx +2 -0
  44. package/src/app/lemonriver/settings/backup-restore-dialog.tsx +525 -0
  45. package/src/app/lemonriver/settings/backup-section.tsx +489 -0
  46. package/src/app/lemonriver/settings/settings-page.tsx +25 -3
  47. package/src/app/lemonriver/share/client.ts +6 -0
  48. package/src/app/lemonriver/share/freeze.ts +13 -5
  49. package/src/app/lemonriver/share/import-dialog.tsx +14 -0
  50. package/src/app/lemonriver/share/paths.test.ts +41 -0
  51. package/src/app/lemonriver/share/paths.ts +45 -11
  52. package/src/app/lemonriver/share/share-dialog.tsx +54 -1
  53. package/src/app/lemonriver/text/en.ts +742 -4
  54. package/src/app/lemonriver/text/es.ts +97 -4
  55. package/src/app/lemonriver/text/ja.ts +94 -4
  56. package/src/app/lemonriver/text/types.ts +103 -1
  57. package/src/app/lemonriver/text/zh-cn.ts +711 -3
  58. package/src/app/lemonriver/text/zh-tw.ts +711 -3
  59. package/src/app/lemonriver/update/beta-badge.tsx +3 -0
  60. package/src/app/lemonriver/update/version.test.ts +14 -0
  61. package/src/app/lemonriver/update/version.ts +5 -0
  62. package/src/locale/en.ts +8 -8
  63. package/src/locale/es.ts +10 -8
  64. package/src/locale/ja.ts +9 -8
  65. package/src/locale/zh-cn.ts +9 -8
  66. package/src/locale/zh-tw.ts +9 -8
@@ -1,5 +1,13 @@
1
1
  export type Tier = 'free' | 'pro';
2
- export type FeatureId = 'board' | 'trash' | 'settings' | 'outline' | 'templates' | 'share';
2
+ export type FeatureId =
3
+ | 'board'
4
+ | 'trash'
5
+ | 'settings'
6
+ | 'outline'
7
+ | 'templates'
8
+ | 'share'
9
+ | 'backup'
10
+ | 'help';
3
11
 
4
12
  export type Feature = { id: FeatureId; tier: Tier; devOnly: boolean };
5
13
 
@@ -10,6 +18,8 @@ export const FEATURES: readonly Feature[] = [
10
18
  { id: 'outline', tier: 'free', devOnly: true },
11
19
  { id: 'templates', tier: 'free', devOnly: true },
12
20
  { id: 'share', tier: 'free', devOnly: true },
21
+ { id: 'backup', tier: 'free', devOnly: true },
22
+ { id: 'help', tier: 'free', devOnly: true },
13
23
  ];
14
24
 
15
25
  /** The single place a paid tier will hook into later; today every tier is unlocked. */
@@ -0,0 +1,89 @@
1
+ import { useEffect, useState } from 'react';
2
+ import { useNavigate } from 'react-router-dom';
3
+ import { Button } from '@/components/ui/button';
4
+ import {
5
+ Dialog,
6
+ DialogContent,
7
+ DialogDescription,
8
+ DialogFooter,
9
+ DialogHeader,
10
+ DialogTitle,
11
+ } from '@/components/ui/dialog';
12
+ import { Mascot } from '../brand/mascot';
13
+ import { useLrText } from '../text';
14
+ import { guideSeen, markGuideSeen } from './state';
15
+ import { useGuideFlags } from './use-guide';
16
+
17
+ const CARD =
18
+ 'flex min-h-[170px] flex-col items-start gap-2 rounded-[14px] border border-border bg-card p-4 text-left outline-none transition-colors hover:border-[var(--lr-focus)] focus-visible:ring-2 focus-visible:ring-ring/40';
19
+
20
+ /** The first-open chooser: two ways to work, shown once. */
21
+ export function GuidePrompt() {
22
+ const lr = useLrText();
23
+ const g = lr.guide;
24
+ const navigate = useNavigate();
25
+ const flags = useGuideFlags();
26
+ const [open, setOpen] = useState(false);
27
+
28
+ useEffect(() => {
29
+ if (flags?.prompt === true && !guideSeen()) setOpen(true);
30
+ }, [flags]);
31
+
32
+ const skip = () => {
33
+ markGuideSeen();
34
+ setOpen(false);
35
+ };
36
+
37
+ const pick = (anchor: 'guide-agent' | 'guide-ui') => {
38
+ markGuideSeen();
39
+ setOpen(false);
40
+ navigate(`/help#${anchor}`);
41
+ };
42
+
43
+ return (
44
+ <Dialog
45
+ open={open}
46
+ onOpenChange={(next) => {
47
+ if (!next) skip();
48
+ }}
49
+ >
50
+ <DialogContent data-lr-guide-prompt className="sm:max-w-[560px]">
51
+ <DialogHeader>
52
+ <DialogTitle>{g.promptTitle}</DialogTitle>
53
+ <DialogDescription>{g.promptIntro}</DialogDescription>
54
+ </DialogHeader>
55
+ <div className="mt-1 grid gap-3 sm:grid-cols-2">
56
+ <button
57
+ type="button"
58
+ data-lr-guide-card="agent"
59
+ onClick={() => pick('guide-agent')}
60
+ className={CARD}
61
+ >
62
+ <Mascot state="idle" size={44} />
63
+ <span className="text-[15px] font-semibold">{g.cardAgentTitle}</span>
64
+ <span className="text-[13px] leading-relaxed text-muted-foreground">
65
+ {g.cardAgentBody}
66
+ </span>
67
+ </button>
68
+ <button
69
+ type="button"
70
+ data-lr-guide-card="ui"
71
+ onClick={() => pick('guide-ui')}
72
+ className={CARD}
73
+ >
74
+ <Mascot state="done" size={44} />
75
+ <span className="text-[15px] font-semibold">{g.cardUiTitle}</span>
76
+ <span className="text-[13px] leading-relaxed text-muted-foreground">
77
+ {g.cardUiBody}
78
+ </span>
79
+ </button>
80
+ </div>
81
+ <DialogFooter>
82
+ <Button type="button" variant="ghost" size="sm" data-lr-guide-skip onClick={skip}>
83
+ {g.skip}
84
+ </Button>
85
+ </DialogFooter>
86
+ </DialogContent>
87
+ </Dialog>
88
+ );
89
+ }
@@ -0,0 +1,29 @@
1
+ export type GuideFlags = { prompt: boolean; guided: boolean };
2
+
3
+ export const GUIDE_SEEN_KEY = 'lemonriver:guide-seen';
4
+
5
+ export function guideSeen(): boolean {
6
+ try {
7
+ return localStorage.getItem(GUIDE_SEEN_KEY) === '1';
8
+ } catch {
9
+ return true;
10
+ }
11
+ }
12
+
13
+ export function markGuideSeen(): void {
14
+ try {
15
+ localStorage.setItem(GUIDE_SEEN_KEY, '1');
16
+ } catch {}
17
+ }
18
+
19
+ /** The server decides both: the chooser on first open, and the in-app agent entry points. */
20
+ export async function guideFlags(): Promise<GuideFlags> {
21
+ try {
22
+ const res = await fetch('/__lr/guide');
23
+ if (!res.ok) throw new Error(String(res.status));
24
+ const data = (await res.json()) as { prompt?: unknown; guided?: unknown };
25
+ return { prompt: data.prompt !== false, guided: data.guided === true };
26
+ } catch {
27
+ return { prompt: true, guided: false };
28
+ }
29
+ }
@@ -0,0 +1,17 @@
1
+ import { useEffect, useState } from 'react';
2
+ import { type GuideFlags, guideFlags } from './state';
3
+
4
+ /** Null until the server answers; callers treat that as "not shown". */
5
+ export function useGuideFlags(): GuideFlags | null {
6
+ const [flags, setFlags] = useState<GuideFlags | null>(null);
7
+ useEffect(() => {
8
+ let alive = true;
9
+ void guideFlags().then((value) => {
10
+ if (alive) setFlags(value);
11
+ });
12
+ return () => {
13
+ alive = false;
14
+ };
15
+ }, []);
16
+ return flags;
17
+ }
@@ -0,0 +1,267 @@
1
+ import { Cloud, Folder, HardDrive } from 'lucide-react';
2
+ import { useEffect, useMemo, useState } from 'react';
3
+ import { Link, useLocation } from 'react-router-dom';
4
+ import { format } from '@/lib/use-locale';
5
+ import { cn } from '@/lib/utils';
6
+ import { markGuideSeen } from '../guide/state';
7
+ import { useLrText } from '../text';
8
+ import { useReduceMotionSetting } from '../theme/motion';
9
+ import {
10
+ filterHelpSections,
11
+ type HelpBlock,
12
+ type HelpContent,
13
+ type HelpItem,
14
+ type HelpSection,
15
+ } from './model';
16
+
17
+ const HIGHLIGHT_MS = 1500;
18
+
19
+ function Inline({ text, values }: { text: string; values: Record<string, string> }) {
20
+ const filled = format(text, values);
21
+ let at = 0;
22
+ const parts = filled.split(/(https?:\/\/[^\s)]+)/g).map((part) => {
23
+ const key = `${at}`;
24
+ at += part.length;
25
+ return { key, part };
26
+ });
27
+ return (
28
+ <>
29
+ {parts.map(({ key, part }) =>
30
+ /^https?:\/\//.test(part) ? (
31
+ <a
32
+ key={key}
33
+ href={part}
34
+ target="_blank"
35
+ rel="noreferrer"
36
+ className="break-all text-foreground underline underline-offset-2"
37
+ >
38
+ {part}
39
+ </a>
40
+ ) : (
41
+ <span key={key}>{part}</span>
42
+ ),
43
+ )}
44
+ </>
45
+ );
46
+ }
47
+
48
+ function Item({ item, values }: { item: HelpItem; values: Record<string, string> }) {
49
+ return (
50
+ <li className="leading-relaxed">
51
+ {item.strong !== undefined && (
52
+ <strong className="font-semibold">
53
+ <Inline text={item.strong} values={values} />
54
+ </strong>
55
+ )}
56
+ <Inline text={item.text} values={values} />
57
+ {item.children !== undefined && item.children.length > 0 && (
58
+ <ul className="mt-1 list-disc space-y-0.5 pl-5 text-[13.5px] text-muted-foreground">
59
+ {item.children.map((child) => (
60
+ <li key={child} className="leading-relaxed">
61
+ <Inline text={child} values={values} />
62
+ </li>
63
+ ))}
64
+ </ul>
65
+ )}
66
+ </li>
67
+ );
68
+ }
69
+
70
+ function Block({ block, values }: { block: HelpBlock; values: Record<string, string> }) {
71
+ if (block.kind === 'p') {
72
+ return (
73
+ <p className="text-[14px] leading-relaxed">
74
+ {block.strong !== undefined && (
75
+ <strong className="font-semibold">
76
+ <Inline text={block.strong} values={values} />
77
+ </strong>
78
+ )}
79
+ <Inline text={block.text} values={values} />
80
+ </p>
81
+ );
82
+ }
83
+ if (block.kind === 'note') {
84
+ return (
85
+ <div className="flex items-start gap-2.5 rounded-[10px] border border-[var(--lr-warn-border,var(--lr-accent))] bg-[var(--lr-accent-soft)] px-3 py-2.5 text-[13.5px] leading-relaxed">
86
+ <strong className="shrink-0 font-semibold">
87
+ <Inline text={block.strong} values={values} />
88
+ </strong>
89
+ <span>
90
+ <Inline text={block.text} values={values} />
91
+ </span>
92
+ </div>
93
+ );
94
+ }
95
+ if (block.kind === 'steps') {
96
+ return (
97
+ <ol className="list-decimal space-y-1.5 pl-5 text-[14px]">
98
+ {block.items.map((item) => (
99
+ <Item key={item.text} item={item} values={values} />
100
+ ))}
101
+ </ol>
102
+ );
103
+ }
104
+ return (
105
+ <ul className="list-disc space-y-1.5 pl-5 text-[14px]">
106
+ {block.items.map((item) => (
107
+ <Item key={item.text} item={item} values={values} />
108
+ ))}
109
+ </ul>
110
+ );
111
+ }
112
+
113
+ function SectionIcon({ section }: { section: HelpSection }) {
114
+ if (section.icon === undefined) return null;
115
+ const className = 'size-4 shrink-0 text-muted-foreground';
116
+ if (section.icon === 'folder') return <Folder className={className} aria-hidden />;
117
+ if (section.icon === 'drive') return <HardDrive className={className} aria-hidden />;
118
+ return <Cloud className={className} aria-hidden />;
119
+ }
120
+
121
+ function Section({
122
+ section,
123
+ values,
124
+ highlighted,
125
+ }: {
126
+ section: HelpSection;
127
+ values: Record<string, string>;
128
+ highlighted: boolean;
129
+ }) {
130
+ let at = 0;
131
+ return (
132
+ <section
133
+ id={`help-${section.id}`}
134
+ data-lr-help-section={section.id}
135
+ className="scroll-mt-6 border-t border-border pt-6 first:border-t-0 first:pt-0"
136
+ >
137
+ <h2
138
+ className={cn(
139
+ '-mx-1 rounded-[8px] px-1 font-heading text-[20px] font-bold leading-[27px] tracking-[-0.01em] transition-colors',
140
+ highlighted && 'bg-[var(--lr-accent-soft)]',
141
+ )}
142
+ >
143
+ <span className="inline-flex items-center gap-2">
144
+ <SectionIcon section={section} />
145
+ <Inline text={section.title} values={values} />
146
+ </span>
147
+ </h2>
148
+ <div className="mt-3 flex flex-col gap-3">
149
+ {section.blocks.map((block) => {
150
+ const key = `${section.id}-${at}`;
151
+ at += JSON.stringify(block).length;
152
+ return <Block key={key} block={block} values={values} />;
153
+ })}
154
+ </div>
155
+ </section>
156
+ );
157
+ }
158
+
159
+ function Index({ help }: { help: HelpContent }) {
160
+ const top = help.sections.filter((section) => section.parent === undefined);
161
+ return (
162
+ <nav className="flex flex-col gap-1 text-[13.5px]">
163
+ {top.map((section) => {
164
+ const children = help.sections.filter((child) => child.parent === section.id);
165
+ return (
166
+ <div key={section.id} className="flex flex-col gap-0.5">
167
+ <Link
168
+ to={`/help#${section.id}`}
169
+ data-lr-help-nav={section.id}
170
+ className="rounded-[6px] px-2 py-1 font-medium outline-none hover:bg-muted/50 focus-visible:ring-2 focus-visible:ring-ring/40"
171
+ >
172
+ {section.title}
173
+ </Link>
174
+ {children.length > 0 && (
175
+ <div className="ml-2 flex flex-col gap-0.5 border-l border-border pl-2">
176
+ {children.map((child) => (
177
+ <Link
178
+ key={child.id}
179
+ to={`/help#${child.id}`}
180
+ data-lr-help-nav={child.id}
181
+ className="rounded-[6px] px-2 py-1 text-[13px] text-muted-foreground outline-none hover:bg-muted/50 hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/40"
182
+ >
183
+ {child.title}
184
+ </Link>
185
+ ))}
186
+ </div>
187
+ )}
188
+ </div>
189
+ );
190
+ })}
191
+ </nav>
192
+ );
193
+ }
194
+
195
+ export function HelpPage() {
196
+ const lr = useLrText();
197
+ const help = lr.help;
198
+ const location = useLocation();
199
+ const reduceMotion = useReduceMotionSetting();
200
+ const [query, setQuery] = useState('');
201
+ const [highlight, setHighlight] = useState<string | null>(null);
202
+
203
+ const sections = useMemo(() => filterHelpSections(help.sections, query), [help.sections, query]);
204
+ const searching = query.trim() !== '';
205
+
206
+ const anchor = location.hash.replace(/^#/, '');
207
+
208
+ useEffect(() => {
209
+ if (anchor.startsWith('guide')) markGuideSeen();
210
+ }, [anchor]);
211
+
212
+ useEffect(() => {
213
+ if (anchor === '') return;
214
+ const target = document.getElementById(`help-${anchor}`);
215
+ if (!target) return;
216
+ target.scrollIntoView({ behavior: reduceMotion ? 'auto' : 'smooth', block: 'start' });
217
+ setHighlight(anchor);
218
+ const timer = setTimeout(() => setHighlight(null), HIGHLIGHT_MS);
219
+ return () => clearTimeout(timer);
220
+ }, [anchor, reduceMotion]);
221
+
222
+ return (
223
+ <div data-lr-help className="flex max-w-[1020px] gap-10">
224
+ {!searching && (
225
+ <aside className="sticky top-6 hidden w-[210px] shrink-0 self-start md:block">
226
+ <Index help={help} />
227
+ </aside>
228
+ )}
229
+
230
+ <div className="min-w-0 max-w-[720px] flex-1">
231
+ <header className="mb-5">
232
+ <h1 className="font-heading text-[28px] font-bold leading-[34px] tracking-[-0.01em]">
233
+ {help.title}
234
+ </h1>
235
+ <p className="mt-0.5 text-[14px] text-muted-foreground">{help.intro}</p>
236
+ </header>
237
+
238
+ <input
239
+ type="search"
240
+ data-lr-help-search
241
+ value={query}
242
+ onChange={(event) => setQuery(event.target.value)}
243
+ placeholder={help.searchPlaceholder}
244
+ aria-label={help.searchPlaceholder}
245
+ className="mb-6 w-full rounded-[10px] border border-border bg-card px-3 py-2 text-[14px] outline-none focus-visible:ring-2 focus-visible:ring-ring/40"
246
+ />
247
+
248
+ {sections.length === 0 ? (
249
+ <p data-lr-help-empty className="text-[14px] text-muted-foreground">
250
+ {help.noResults}
251
+ </p>
252
+ ) : (
253
+ <div className="flex flex-col gap-6">
254
+ {sections.map((section) => (
255
+ <Section
256
+ key={section.id}
257
+ section={section}
258
+ values={help.buttons}
259
+ highlighted={highlight === section.id}
260
+ />
261
+ ))}
262
+ </div>
263
+ )}
264
+ </div>
265
+ </div>
266
+ );
267
+ }
@@ -0,0 +1,179 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { en } from '../../../locale/en.ts';
3
+ import type { Locale } from '../../../locale/types.ts';
4
+ import { zhCN } from '../../../locale/zh-cn.ts';
5
+ import { zhTW } from '../../../locale/zh-tw.ts';
6
+ import { lrTextFor } from '../text/all';
7
+ import { filterHelpSections, helpAnchorForPlace, helpStrings, placeholdersIn } from './model.ts';
8
+
9
+ const ANCHORS = [
10
+ 'guide',
11
+ 'guide-prepare',
12
+ 'guide-agent',
13
+ 'guide-ui',
14
+ 'guide-finish',
15
+ 'guide-faq',
16
+ 'share',
17
+ 'import',
18
+ 'backup',
19
+ 'restore',
20
+ 'cloud',
21
+ 'cloud-icloud',
22
+ 'cloud-baidu',
23
+ 'cloud-weiyun',
24
+ 'cloud-dropbox',
25
+ 'cloud-onedrive',
26
+ 'cloud-nutstore',
27
+ 'cloud-other',
28
+ 'cloud-faq',
29
+ ];
30
+
31
+ const PLACES = [
32
+ 'icloud',
33
+ 'dropbox',
34
+ 'onedrive',
35
+ 'baidu',
36
+ 'nutstore',
37
+ 'other',
38
+ 'local',
39
+ 'google',
40
+ ] as const;
41
+
42
+ const LOCALES: Locale['id'][] = ['en', 'es', 'ja', 'zh-CN', 'zh-TW'];
43
+
44
+ /** The two example lines under "Prepare", in the order the guide shows them. */
45
+ function agentLists(id: Locale['id']): string[] {
46
+ const section = lrTextFor(id).help.sections.find((item) => item.id === 'guide-prepare');
47
+ const block = section?.blocks[0];
48
+ if (block?.kind !== 'steps') throw new Error(`${id}: guide-prepare does not open with steps`);
49
+ return block.items[0]?.children ?? [];
50
+ }
51
+
52
+ describe('the help page', () => {
53
+ const zh = lrTextFor('zh-CN');
54
+
55
+ it('has one section for every anchor the app links to', () => {
56
+ expect(zh.help.sections.map((section) => section.id)).toEqual(ANCHORS);
57
+ for (const place of PLACES) {
58
+ expect(ANCHORS, place).toContain(helpAnchorForPlace(place));
59
+ }
60
+ const ids = new Set(zh.help.sections.map((section) => section.id));
61
+ for (const section of zh.help.sections) {
62
+ if (section.parent !== undefined) expect(ids, section.id).toContain(section.parent);
63
+ }
64
+ });
65
+
66
+ it('names every app button the way the interface does', () => {
67
+ // Japanese and Spanish show the English help, so they keep the English names.
68
+ const locale = { en, 'zh-CN': zhCN, 'zh-TW': zhTW } as const;
69
+ for (const id of ['en', 'zh-CN', 'zh-TW'] as const) {
70
+ const text = lrTextFor(id);
71
+ const ui = locale[id];
72
+ const buttons = text.help.buttons;
73
+ const expected = {
74
+ settings: text.settings.title,
75
+ backupSection: text.backup.title,
76
+ share: text.share.open,
77
+ generate: text.share.generate,
78
+ import: text.share.importAction,
79
+ backupNow: text.backup.runNow,
80
+ autoBackup: text.backup.auto,
81
+ keep: text.backup.keep,
82
+ restore: text.backup.restore,
83
+ restoreGo: text.backup.restoreGo,
84
+ chooseOtherFile: text.backup.chooseOtherFile,
85
+ change: text.backup.change,
86
+ chooseOther: text.backup.chooseOther,
87
+ reveal: text.backup.reveal,
88
+ format: ui.inspector.format,
89
+ replaceImage: ui.inspector.replaceImageDialogTitle,
90
+ assets: ui.home.assets,
91
+ board: text.board.title,
92
+ notes: ui.presenter.speakerNotes,
93
+ comments: ui.inspector.commentMode,
94
+ selfCheck: text.board.selfCheck,
95
+ present: ui.slide.present,
96
+ duplicate: ui.home.duplicate,
97
+ };
98
+ for (const [key, value] of Object.entries(expected)) {
99
+ expect(buttons[key as keyof typeof buttons], `${id}: ${key}`).toBe(value);
100
+ }
101
+ }
102
+ });
103
+
104
+ it('puts the agent line each language leads with first', () => {
105
+ const domestic = 'WorkBuddy';
106
+ const overseas = 'Claude Code';
107
+ for (const id of ['zh-CN', 'zh-TW'] as const) {
108
+ const lists = agentLists(id);
109
+ expect(lists[0], id).toContain(domestic);
110
+ expect(lists[1], id).toContain(overseas);
111
+ }
112
+ for (const id of ['en', 'ja', 'es'] as const) {
113
+ const lists = agentLists(id);
114
+ expect(lists[0], id).toContain(overseas);
115
+ expect(lists[1], id).toContain(domestic);
116
+ }
117
+ });
118
+
119
+ it('lists the agents word for word as the guide text file does', () => {
120
+ expect(agentLists('zh-CN')).toEqual([
121
+ '国内常用:WorkBuddy、DuMate、DeepSeek Harness、Trae、千问办公、豆包、Kimi CLI 等',
122
+ '海外常用:Claude Code、Codex、Gemini CLI、Grok、Cursor、GitHub Copilot、OpenCode 等',
123
+ ]);
124
+ expect(agentLists('en')).toEqual([
125
+ 'Common elsewhere: Claude Code, Codex, Gemini CLI, Grok, Cursor, GitHub Copilot, OpenCode and others',
126
+ 'Common in China: WorkBuddy, DuMate, DeepSeek Harness, Trae, 千问办公, 豆包, Kimi CLI and others',
127
+ ]);
128
+ });
129
+
130
+ it('leads with the usage guide', () => {
131
+ for (const id of ['en', 'zh-CN', 'zh-TW'] as const) {
132
+ const help = lrTextFor(id).help;
133
+ expect(help.sections[0]?.id, id).toBe('guide');
134
+ const children = help.sections
135
+ .filter((section) => section.parent === 'guide')
136
+ .map((s) => s.id);
137
+ expect(children, id).toEqual([
138
+ 'guide-prepare',
139
+ 'guide-agent',
140
+ 'guide-ui',
141
+ 'guide-finish',
142
+ 'guide-faq',
143
+ ]);
144
+ }
145
+ expect(lrTextFor('zh-CN').help.title).toBe('使用指南和帮助');
146
+ });
147
+
148
+ it('fills every placeholder from the button list', () => {
149
+ for (const id of LOCALES) {
150
+ const help = lrTextFor(id).help;
151
+ const keys = new Set(Object.keys(help.buttons));
152
+ for (const text of helpStrings(help)) {
153
+ for (const name of placeholdersIn(text)) {
154
+ expect(keys, `${id}: ${text}`).toContain(name);
155
+ }
156
+ }
157
+ }
158
+ });
159
+
160
+ it('searches the body, not only the titles', () => {
161
+ const ids = (query: string) => filterHelpSections(zh.help.sections, query).map((s) => s.id);
162
+ // Only this section's body says 冲突副本; its title does not.
163
+ expect(ids('冲突副本')).toEqual(['cloud-faq']);
164
+ expect(ids('iCloud')).toEqual(['cloud-icloud']);
165
+ expect(ids('Dropbox')).toEqual(['cloud-dropbox']);
166
+ expect(ids('没有这个词')).toEqual([]);
167
+ });
168
+
169
+ it('has the same sections in every language', () => {
170
+ const counts = LOCALES.map((id) => lrTextFor(id).help.sections.length);
171
+ expect(counts).toEqual(LOCALES.map(() => ANCHORS.length));
172
+ for (const id of LOCALES) {
173
+ expect(
174
+ lrTextFor(id).help.sections.map((section) => section.id),
175
+ id,
176
+ ).toEqual(ANCHORS);
177
+ }
178
+ });
179
+ });