@lemonriver/core 0.2.0 → 0.4.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 (160) hide show
  1. package/dist/{build-Df_xwIpg.js → build-Nl7EeJ6x.js} +1 -1
  2. package/dist/cli/bin.js +4 -4
  3. package/dist/{config-rMGCkz6i.d.ts → config-CYNOR93W.d.ts} +1 -1
  4. package/dist/{config-BjWCLoMQ.js → config-CpC0nM3r.js} +3152 -1837
  5. package/dist/{dev-Ctsx9IeO.js → dev-BB3THd5I.js} +2 -2
  6. package/dist/index.d.ts +2 -2
  7. package/dist/index.js +1 -1
  8. package/dist/locale/index.d.ts +1 -1
  9. package/dist/locale/index.js +1 -1
  10. package/dist/{preview-CJgcqsPk.js → preview-BGjgTg7H.js} +1 -1
  11. package/dist/{types-8VUyA2bu.d.ts → types-tdaXSyah.d.ts} +1 -35
  12. package/dist/{update-BKOA3Z6o.js → update-DsxZBtwv.js} +2 -70
  13. package/dist/vite/index.d.ts +1 -1
  14. package/dist/vite/index.js +1 -1
  15. package/dist/{zh-tw-CeLrYwRE.js → zh-tw-DcrDeKxr.js} +11 -172
  16. package/package.json +1 -1
  17. package/src/agent/prompt.ts +2 -0
  18. package/src/app/app.tsx +5 -18
  19. package/src/app/components/agent/agent-panel.tsx +5 -0
  20. package/src/app/components/agent/agent-presence.tsx +2 -2
  21. package/src/app/components/agent/history-view.tsx +3 -2
  22. package/src/app/components/agent/transcript.tsx +15 -4
  23. package/src/app/components/asset-view.tsx +6 -6
  24. package/src/app/components/command/command-menu.tsx +2 -1
  25. package/src/app/components/inspector/asset-picker-dialog.tsx +7 -5
  26. package/src/app/components/inspector/comment-layer.tsx +2 -1
  27. package/src/app/components/inspector/inspector-panel.tsx +2 -2
  28. package/src/app/components/player.tsx +105 -23
  29. package/src/app/components/present/curtain.tsx +52 -0
  30. package/src/app/components/present/last-slide-hint.tsx +36 -0
  31. package/src/app/components/sidebar/sidebar-footer.tsx +7 -2
  32. package/src/app/components/sidebar/sidebar.tsx +3 -2
  33. package/src/app/components/themes/theme-detail.tsx +4 -2
  34. package/src/app/components/thumbnail-rail.tsx +2 -28
  35. package/src/app/index.html +2 -2
  36. package/src/app/lemonriver/agent/lemon.tsx +79 -0
  37. package/src/app/lemonriver/agent-prefs/prefs.test.ts +173 -0
  38. package/src/app/lemonriver/agent-prefs/prefs.ts +137 -0
  39. package/src/app/lemonriver/agent-prefs/use-prefs.ts +36 -0
  40. package/src/app/{components → lemonriver}/board/board-canvas.tsx +17 -17
  41. package/src/app/{routes/board.tsx → lemonriver/board/board-page.tsx} +16 -15
  42. package/src/app/{components → lemonriver}/board/layout.ts +1 -1
  43. package/src/app/lemonriver/board/model/cards.test.ts +239 -0
  44. package/src/app/lemonriver/board/model/cards.ts +234 -0
  45. package/src/app/lemonriver/board/model/structure.test.ts +101 -0
  46. package/src/app/lemonriver/board/model/structure.ts +82 -0
  47. package/src/app/{components → lemonriver}/board/page-node.tsx +34 -31
  48. package/src/app/{components → lemonriver}/board/use-board-cards.ts +6 -6
  49. package/src/app/{components → lemonriver}/board/use-board-columns.ts +7 -7
  50. package/src/app/{components → lemonriver}/board/use-page-order.ts +10 -6
  51. package/src/app/lemonriver/brand/app-icon.svg +44 -0
  52. package/src/app/lemonriver/brand/apple-touch-icon.png +0 -0
  53. package/src/app/lemonriver/brand/favicon-32.png +0 -0
  54. package/src/app/lemonriver/brand/mascot.tsx +145 -0
  55. package/src/app/lemonriver/brand/mascots/design-done.png +0 -0
  56. package/src/app/lemonriver/brand/mascots/design-idle.png +0 -0
  57. package/src/app/lemonriver/brand/mascots/design-needs-you.png +0 -0
  58. package/src/app/lemonriver/brand/mascots/design-working.png +0 -0
  59. package/src/app/lemonriver/brand/mascots/lemon-done.png +0 -0
  60. package/src/app/lemonriver/brand/mascots/lemon-idle.png +0 -0
  61. package/src/app/lemonriver/brand/mascots/lemon-needs-you.png +0 -0
  62. package/src/app/lemonriver/brand/mascots/lemon-thinking.png +0 -0
  63. package/src/app/lemonriver/brand/mascots/lemon-working.png +0 -0
  64. package/src/app/lemonriver/brand/mascots/outline-done.png +0 -0
  65. package/src/app/lemonriver/brand/mascots/outline-idle.png +0 -0
  66. package/src/app/lemonriver/brand/mascots/outline-needs-you.png +0 -0
  67. package/src/app/lemonriver/brand/mascots/outline-working.png +0 -0
  68. package/src/app/lemonriver/brand/mascots/research-done.png +0 -0
  69. package/src/app/lemonriver/brand/mascots/research-idle.png +0 -0
  70. package/src/app/lemonriver/brand/mascots/research-needs-you.png +0 -0
  71. package/src/app/lemonriver/brand/mascots/research-working.png +0 -0
  72. package/src/app/lemonriver/brand/mascots/review-done.png +0 -0
  73. package/src/app/lemonriver/brand/mascots/review-idle.png +0 -0
  74. package/src/app/lemonriver/brand/mascots/review-needs-you.png +0 -0
  75. package/src/app/lemonriver/brand/mascots/review-working.png +0 -0
  76. package/src/app/lemonriver/chrome/app-chrome.tsx +101 -0
  77. package/src/app/lemonriver/chrome/nav-row.tsx +34 -0
  78. package/src/app/lemonriver/chrome/not-found.tsx +34 -0
  79. package/src/app/lemonriver/chrome/sidebar-extras.tsx +57 -0
  80. package/src/app/lemonriver/chrome/use-slot.ts +23 -0
  81. package/src/app/lemonriver/features.test.ts +34 -0
  82. package/src/app/lemonriver/features.ts +27 -0
  83. package/src/app/lemonriver/feedback/export.ts +7 -0
  84. package/src/app/lemonriver/feedback/lemon-empty.tsx +54 -0
  85. package/src/app/lemonriver/feedback/offline-banner.tsx +41 -0
  86. package/src/app/lemonriver/feedback/pending-toast.test.ts +44 -0
  87. package/src/app/lemonriver/feedback/pending-toast.ts +39 -0
  88. package/src/app/lemonriver/feedback/toaster.tsx +34 -0
  89. package/src/app/lemonriver/feedback/upload.test.ts +26 -0
  90. package/src/app/lemonriver/feedback/upload.ts +19 -0
  91. package/src/app/lemonriver/home/brief-card.tsx +70 -0
  92. package/src/app/lemonriver/home/brief.test.ts +38 -0
  93. package/src/app/lemonriver/home/brief.ts +34 -0
  94. package/src/app/lemonriver/home/controls.tsx +93 -0
  95. package/src/app/lemonriver/home/deck-card.tsx +183 -0
  96. package/src/app/lemonriver/home/dialogs.tsx +292 -0
  97. package/src/app/lemonriver/home/home-page.tsx +339 -0
  98. package/src/app/lemonriver/home/sorting.test.ts +24 -0
  99. package/src/app/lemonriver/home/sorting.ts +59 -0
  100. package/src/app/lemonriver/home/time.test.ts +33 -0
  101. package/src/app/lemonriver/home/time.ts +33 -0
  102. package/src/app/lemonriver/home/use-deck-times.ts +27 -0
  103. package/src/app/lemonriver/home/use-delayed.ts +15 -0
  104. package/src/app/lemonriver/onboarding/onboarding.tsx +182 -0
  105. package/src/app/lemonriver/outline/build-team.tsx +278 -0
  106. package/src/app/lemonriver/outline/describe-page.tsx +380 -0
  107. package/src/app/lemonriver/outline/files.test.ts +90 -0
  108. package/src/app/lemonriver/outline/files.ts +69 -0
  109. package/src/app/lemonriver/outline/model.test.ts +633 -0
  110. package/src/app/lemonriver/outline/model.ts +443 -0
  111. package/src/app/lemonriver/outline/outline-page.tsx +504 -0
  112. package/src/app/lemonriver/outline/pending-pages.tsx +39 -0
  113. package/src/app/lemonriver/outline/rule.ts +3 -0
  114. package/src/app/lemonriver/outline/steps.tsx +43 -0
  115. package/src/app/lemonriver/outline/use-build-driver.ts +258 -0
  116. package/src/app/lemonriver/routes.test.tsx +37 -0
  117. package/src/app/lemonriver/routes.tsx +66 -0
  118. package/src/app/lemonriver/settings/settings-page.tsx +314 -0
  119. package/src/app/lemonriver/slide-extensions.tsx +80 -0
  120. package/src/app/lemonriver/text/all.ts +19 -0
  121. package/src/app/lemonriver/text/en.ts +255 -0
  122. package/src/app/lemonriver/text/es.ts +256 -0
  123. package/src/app/lemonriver/text/index.ts +9 -0
  124. package/src/app/lemonriver/text/ja.ts +256 -0
  125. package/src/app/lemonriver/text/text.test.ts +90 -0
  126. package/src/app/lemonriver/text/types.ts +280 -0
  127. package/src/app/lemonriver/text/zh-cn.ts +247 -0
  128. package/src/app/lemonriver/text/zh-tw.ts +247 -0
  129. package/src/app/lemonriver/theme/app.css +299 -0
  130. package/src/app/lemonriver/theme/controls.css +463 -0
  131. package/src/app/lemonriver/theme/index.css +3 -0
  132. package/src/app/lemonriver/theme/motion.ts +52 -0
  133. package/src/app/lemonriver/theme/pages.test.ts +70 -0
  134. package/src/app/lemonriver/theme/pages.ts +65 -0
  135. package/src/app/lemonriver/theme/theme-menu.tsx +64 -0
  136. package/src/app/lemonriver/theme/themes.test.ts +18 -0
  137. package/src/app/lemonriver/theme/themes.ts +16 -0
  138. package/src/app/lemonriver/theme/tokens.css +226 -0
  139. package/src/app/lemonriver/theme/use-theme.tsx +49 -0
  140. package/src/app/lemonriver/trash/api.test.ts +19 -0
  141. package/src/app/lemonriver/trash/api.ts +77 -0
  142. package/src/app/lemonriver/trash/trash-page.tsx +131 -0
  143. package/src/app/lemonriver/update/beta-badge.tsx +26 -0
  144. package/src/app/lemonriver/update/prompt.test.ts +84 -0
  145. package/src/app/lemonriver/update/prompt.ts +48 -0
  146. package/src/app/lemonriver/update/update-prompt.tsx +113 -0
  147. package/src/app/lib/pptx/raster.ts +1 -1
  148. package/src/app/main.tsx +8 -1
  149. package/src/app/routes/home-shell.tsx +4 -2
  150. package/src/app/routes/home.tsx +13 -5
  151. package/src/app/routes/slide.tsx +81 -28
  152. package/src/app/styles.css +1 -0
  153. package/src/locale/en.ts +1 -35
  154. package/src/locale/es.ts +1 -34
  155. package/src/locale/ja.ts +1 -34
  156. package/src/locale/types.ts +1 -36
  157. package/src/locale/zh-cn.ts +4 -37
  158. package/src/locale/zh-tw.ts +4 -37
  159. /package/src/app/{components → lemonriver}/board/board.css +0 -0
  160. /package/src/app/{components → lemonriver}/board/layout.test.ts +0 -0
@@ -24,7 +24,6 @@ import {
24
24
  type LucideIcon,
25
25
  Sparkles,
26
26
  Trash2,
27
- Workflow,
28
27
  } from 'lucide-react';
29
28
  import { Fragment, useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react';
30
29
  import { useOptionalInspector } from '@/components/inspector/inspector-provider';
@@ -74,8 +73,6 @@ type Props = {
74
73
  moduleTransition?: SlideTransition;
75
74
  /** When provided, the vertical rail header renders a button that opens the overview grid. */
76
75
  onOverview?: () => void;
77
- /** When provided, the vertical rail header renders a button that opens the story board. */
78
- onBoard?: () => void;
79
76
  };
80
77
 
81
78
  // Per-page pending comment counts, shown on the rail only while the
@@ -132,7 +129,6 @@ export function ThumbnailRail({
132
129
  width,
133
130
  moduleTransition,
134
131
  onOverview,
135
- onBoard,
136
132
  }: Props) {
137
133
  const activeRef = useRef<HTMLButtonElement | null>(null);
138
134
  const virtualListRef = useRef<HTMLDivElement | null>(null);
@@ -335,7 +331,7 @@ export function ThumbnailRail({
335
331
  <div className="-mx-3 sticky top-0 z-10 bg-sidebar px-4 pt-3 pb-1">
336
332
  <div className="flex items-center justify-between gap-2">
337
333
  <span className="eyebrow">{t.thumbnailRail.pages}</span>
338
- <div className="flex items-center gap-1.5">
334
+ <div className="flex items-center gap-1.5" data-lr-rail-actions="">
339
335
  <span className="folio">{pad2(pages.length)}</span>
340
336
  {onOverview && (
341
337
  <Tooltip>
@@ -360,29 +356,6 @@ export function ThumbnailRail({
360
356
  </TooltipContent>
361
357
  </Tooltip>
362
358
  )}
363
- {onBoard && (
364
- <Tooltip>
365
- <TooltipTrigger
366
- render={
367
- <button
368
- type="button"
369
- onClick={onBoard}
370
- aria-label={t.board.openBoard}
371
- className={cn(
372
- 'flex size-5 items-center justify-center rounded-[3px] text-muted-foreground/70 outline-none',
373
- 'motion-safe:transition-colors hover:bg-muted hover:text-foreground',
374
- 'focus-visible:ring-1 focus-visible:ring-brand',
375
- )}
376
- >
377
- <Workflow className="size-3.5" strokeWidth={1.75} />
378
- </button>
379
- }
380
- />
381
- <TooltipContent side="bottom" sideOffset={6}>
382
- {t.board.openBoard}
383
- </TooltipContent>
384
- </Tooltip>
385
- )}
386
359
  </div>
387
360
  </div>
388
361
  </div>
@@ -396,6 +369,7 @@ export function ThumbnailRail({
396
369
  onCurrentPositionChange={setCurrentPosition}
397
370
  renderThumb={renderThumb}
398
371
  />
372
+ <div data-lr-rail-pending="" />
399
373
  </aside>
400
374
  );
401
375
 
@@ -2,8 +2,8 @@
2
2
  <html lang="en">
3
3
  <head>
4
4
  <meta charset="UTF-8" />
5
- <link rel="icon" href="./favicon.ico" sizes="32x32" />
6
- <link rel="icon" href="./favicon.svg" type="image/svg+xml" />
5
+ <link rel="icon" href="./lemonriver/brand/favicon-32.png" sizes="32x32" type="image/png" />
6
+ <link rel="icon" href="./lemonriver/brand/app-icon.svg" type="image/svg+xml" />
7
7
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
8
8
  <title>LemonRiver</title>
9
9
  <style>
@@ -0,0 +1,79 @@
1
+ import type { ReactNode } from 'react';
2
+ import type { AgentActivity } from '@/lib/agent/use-agent';
3
+ import { HelperMascot, type HelperRole, Mascot, type MascotState } from '../brand/mascot';
4
+ import { useBuildOutline } from '../outline/use-build-driver';
5
+ import { useLrText } from '../text';
6
+
7
+ const REVIEW_ROLE: HelperRole = 'review';
8
+
9
+ const PHASE_STATE: Record<AgentActivity['phase'], MascotState> = {
10
+ thinking: 'thinking',
11
+ tool: 'working',
12
+ waiting: 'needs-you',
13
+ };
14
+
15
+ /** Lemon in the presence pill above the canvas: thinking, working, or waiting for you. */
16
+ export function PresenceLemon({ phase }: { phase: AgentActivity['phase'] }) {
17
+ return <Mascot state={PHASE_STATE[phase]} size={20} className="-my-1 -ml-1" />;
18
+ }
19
+
20
+ /** Lemon at the top of an idle agent panel. */
21
+ export function PanelLemon() {
22
+ return <Mascot state="idle" size={56} float className="mb-2" />;
23
+ }
24
+
25
+ export function WorkingLemon() {
26
+ return <Mascot state="working" size={20} className="-my-1 mr-1 inline-block align-middle" />;
27
+ }
28
+
29
+ export function ErrorLemon() {
30
+ return <Mascot state="needs-you" size={20} className="-my-1 mr-0.5 inline-block align-middle" />;
31
+ }
32
+
33
+ export function ResultLemon({ aborted }: { aborted: boolean }) {
34
+ return (
35
+ <Mascot
36
+ state={aborted ? 'idle' : 'done'}
37
+ size={18}
38
+ className="-my-1 mr-1 inline-block align-middle"
39
+ />
40
+ );
41
+ }
42
+
43
+ /** The header of a question the agent asks: the design package's confirmation card. */
44
+ export function ConfirmWho() {
45
+ const lr = useLrText();
46
+ const outline = useBuildOutline();
47
+ if (outline?.state === 'building' && outline.stage === 'review') {
48
+ return (
49
+ <div
50
+ data-lr-confirm-who="review"
51
+ className="mb-2 flex items-center gap-2 px-1.5 text-[12.5px] font-semibold"
52
+ >
53
+ <HelperMascot role={REVIEW_ROLE} state="needs-you" size={36} />
54
+ {lr.feedback.confirmReview}
55
+ </div>
56
+ );
57
+ }
58
+ return (
59
+ <div className="mb-2 flex items-center gap-2 px-1.5 text-[12.5px] font-semibold">
60
+ <Mascot state="needs-you" size={36} />
61
+ {lr.feedback.confirmWho}
62
+ </div>
63
+ );
64
+ }
65
+
66
+ /** Lemon beside an empty state in the editor's compact panels. */
67
+ export function EmptyLemon({ size = 56 }: { size?: number }) {
68
+ return <Mascot state="idle" size={size} float />;
69
+ }
70
+
71
+ /** The comment-mode hint pill, with Lemon in front. */
72
+ export function HintLemon({ children }: { children: ReactNode }) {
73
+ return (
74
+ <span className="inline-flex items-center gap-1.5">
75
+ <Mascot state="idle" size={16} className="-my-1" />
76
+ {children}
77
+ </span>
78
+ );
79
+ }
@@ -0,0 +1,173 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import {
3
+ type AgentPrefs,
4
+ DEFAULT_PREFS,
5
+ PREFS_KEY,
6
+ prefsLines,
7
+ readPrefs,
8
+ sanitizePrefs,
9
+ savePrefs,
10
+ toneForUses,
11
+ } from './prefs';
12
+
13
+ function memoryStorage(initial: Record<string, string> = {}): Storage {
14
+ const data = new Map(Object.entries(initial));
15
+ return {
16
+ get length() {
17
+ return data.size;
18
+ },
19
+ clear: () => data.clear(),
20
+ getItem: (key: string) => data.get(key) ?? null,
21
+ key: (index: number) => [...data.keys()][index] ?? null,
22
+ removeItem: (key: string) => {
23
+ data.delete(key);
24
+ },
25
+ setItem: (key: string, value: string) => {
26
+ data.set(key, value);
27
+ },
28
+ };
29
+ }
30
+
31
+ describe('sanitizePrefs', () => {
32
+ it('returns the defaults for anything that is not an object', () => {
33
+ expect(sanitizePrefs(null)).toEqual(DEFAULT_PREFS);
34
+ expect(sanitizePrefs('dense')).toEqual(DEFAULT_PREFS);
35
+ expect(sanitizePrefs(['dense'])).toEqual(DEFAULT_PREFS);
36
+ });
37
+
38
+ it('keeps the values it knows', () => {
39
+ const prefs: AgentPrefs = {
40
+ confirmEachPage: true,
41
+ askOnMismatch: false,
42
+ autoImages: false,
43
+ tone: 'concise',
44
+ research: 'web',
45
+ outline: 'direct',
46
+ design: 'dense',
47
+ review: 'numbers',
48
+ };
49
+ expect(sanitizePrefs(prefs)).toEqual(prefs);
50
+ });
51
+
52
+ it('replaces the values it does not know with the defaults', () => {
53
+ expect(
54
+ sanitizePrefs({
55
+ confirmEachPage: 'yes',
56
+ askOnMismatch: 0,
57
+ autoImages: null,
58
+ tone: 'shouty',
59
+ research: 'library',
60
+ outline: 'auto',
61
+ design: 'sparse',
62
+ review: 'loose',
63
+ }),
64
+ ).toEqual(DEFAULT_PREFS);
65
+ });
66
+
67
+ it('fills a partial record', () => {
68
+ expect(sanitizePrefs({ design: 'visual' })).toEqual({ ...DEFAULT_PREFS, design: 'visual' });
69
+ });
70
+ });
71
+
72
+ describe('readPrefs and savePrefs', () => {
73
+ it('round-trips through storage', () => {
74
+ const storage = memoryStorage();
75
+ const prefs: AgentPrefs = { ...DEFAULT_PREFS, tone: 'friendly', confirmEachPage: true };
76
+ savePrefs(storage, prefs);
77
+ expect(storage.getItem(PREFS_KEY)).toBe(JSON.stringify(prefs));
78
+ expect(readPrefs(storage)).toEqual(prefs);
79
+ });
80
+
81
+ it('falls back to the defaults on junk or a missing key', () => {
82
+ expect(readPrefs(memoryStorage())).toEqual(DEFAULT_PREFS);
83
+ expect(readPrefs(memoryStorage({ [PREFS_KEY]: 'not json' }))).toEqual(DEFAULT_PREFS);
84
+ expect(readPrefs(memoryStorage({ [PREFS_KEY]: '{"tone":"loud"}' }))).toEqual(DEFAULT_PREFS);
85
+ });
86
+
87
+ it('swallows a storage that throws', () => {
88
+ const broken = {
89
+ getItem: () => {
90
+ throw new Error('blocked');
91
+ },
92
+ setItem: () => {
93
+ throw new Error('blocked');
94
+ },
95
+ } as unknown as Storage;
96
+ expect(readPrefs(broken)).toEqual(DEFAULT_PREFS);
97
+ expect(() => savePrefs(broken, DEFAULT_PREFS)).not.toThrow();
98
+ });
99
+ });
100
+
101
+ describe('prefsLines', () => {
102
+ const prefs = (patch: Partial<AgentPrefs> = {}): AgentPrefs => ({ ...DEFAULT_PREFS, ...patch });
103
+
104
+ it('gives every step the tone', () => {
105
+ for (const step of ['outline', 'page', 'review'] as const) {
106
+ expect(prefsLines(prefs(), step)[0]).toBe('Write in a steady, professional tone.');
107
+ }
108
+ expect(prefsLines(prefs({ tone: 'friendly' }), 'page')[0]).toBe(
109
+ 'Write in a light, friendly tone.',
110
+ );
111
+ expect(prefsLines(prefs({ tone: 'concise' }), 'review')[0]).toBe(
112
+ 'Keep the wording short and punchy.',
113
+ );
114
+ });
115
+
116
+ it('tells the outline step where facts may come from', () => {
117
+ expect(prefsLines(prefs(), 'outline')).toEqual([
118
+ 'Write in a steady, professional tone.',
119
+ "Use only the user's reference files; do not look anything up on the web.",
120
+ ]);
121
+ expect(prefsLines(prefs({ research: 'web' }), 'outline')).toContain(
122
+ 'You may look up facts the files do not cover; say where each one came from.',
123
+ );
124
+ });
125
+
126
+ it('tells the page step how dense to lay out and whether to use images', () => {
127
+ expect(prefsLines(prefs(), 'page')).toEqual([
128
+ 'Write in a steady, professional tone.',
129
+ 'Balance text and visuals.',
130
+ 'Use icons and image placeholders where a picture helps; never invent photos the user did not provide.',
131
+ ]);
132
+ expect(prefsLines(prefs({ design: 'dense' }), 'page')).toContain(
133
+ 'A page may carry more text and data when the content needs it.',
134
+ );
135
+ expect(prefsLines(prefs({ autoImages: false }), 'page')).toContain(
136
+ 'Do not add any image the user did not provide.',
137
+ );
138
+ });
139
+
140
+ it('tells the review step how far to check and what to do with a mismatch', () => {
141
+ expect(prefsLines(prefs(), 'review')).toEqual([
142
+ 'Write in a steady, professional tone.',
143
+ 'Check wording, typos and every number.',
144
+ ]);
145
+ expect(prefsLines(prefs({ review: 'numbers' }), 'review')).toContain(
146
+ 'Check only the numbers against the reference files.',
147
+ );
148
+ const lenient = prefsLines(prefs({ askOnMismatch: false }), 'review');
149
+ expect(lenient).toContain(
150
+ 'When two files disagree on a number, use the one from the spreadsheet (.xlsx, .xls or .csv) and say which you used.',
151
+ );
152
+ });
153
+ });
154
+
155
+ describe('toneForUses', () => {
156
+ it('picks a tone from what the deck is for', () => {
157
+ expect(toneForUses(['report'])).toBe('steady');
158
+ expect(toneForUses(['pitch'])).toBe('steady');
159
+ expect(toneForUses(['lecture'])).toBe('friendly');
160
+ expect(toneForUses(['training'])).toBe('friendly');
161
+ expect(toneForUses(['launch'])).toBe('concise');
162
+ });
163
+
164
+ it('lets a launch win over anything else picked with it', () => {
165
+ expect(toneForUses(['lecture', 'launch'])).toBe('concise');
166
+ expect(toneForUses(['report', 'training'])).toBe('friendly');
167
+ });
168
+
169
+ it('changes nothing for other or an empty pick', () => {
170
+ expect(toneForUses([])).toBeNull();
171
+ expect(toneForUses(['other'])).toBeNull();
172
+ });
173
+ });
@@ -0,0 +1,137 @@
1
+ export type Tone = 'steady' | 'friendly' | 'concise';
2
+ export type ResearchSource = 'uploads' | 'web';
3
+ export type OutlineMode = 'review' | 'direct';
4
+ export type DesignDensity = 'visual' | 'balanced' | 'dense';
5
+ export type ReviewMode = 'strict' | 'numbers';
6
+
7
+ export type AgentPrefs = {
8
+ confirmEachPage: boolean;
9
+ askOnMismatch: boolean;
10
+ autoImages: boolean;
11
+ tone: Tone;
12
+ research: ResearchSource;
13
+ outline: OutlineMode;
14
+ design: DesignDensity;
15
+ review: ReviewMode;
16
+ };
17
+
18
+ export const DEFAULT_PREFS: AgentPrefs = {
19
+ confirmEachPage: false,
20
+ askOnMismatch: true,
21
+ autoImages: true,
22
+ tone: 'steady',
23
+ research: 'uploads',
24
+ outline: 'review',
25
+ design: 'balanced',
26
+ review: 'strict',
27
+ };
28
+
29
+ export const PREFS_KEY = 'lemonriver:agent-prefs';
30
+
31
+ const TONES: readonly Tone[] = ['steady', 'friendly', 'concise'];
32
+ const RESEARCH: readonly ResearchSource[] = ['uploads', 'web'];
33
+ const OUTLINES: readonly OutlineMode[] = ['review', 'direct'];
34
+ const DESIGNS: readonly DesignDensity[] = ['visual', 'balanced', 'dense'];
35
+ const REVIEWS: readonly ReviewMode[] = ['strict', 'numbers'];
36
+
37
+ function pick<T extends string>(value: unknown, allowed: readonly T[], fallback: T): T {
38
+ return typeof value === 'string' && (allowed as readonly string[]).includes(value)
39
+ ? (value as T)
40
+ : fallback;
41
+ }
42
+
43
+ function flag(value: unknown, fallback: boolean): boolean {
44
+ return typeof value === 'boolean' ? value : fallback;
45
+ }
46
+
47
+ export function sanitizePrefs(raw: unknown): AgentPrefs {
48
+ if (!raw || typeof raw !== 'object' || Array.isArray(raw)) return { ...DEFAULT_PREFS };
49
+ const r = raw as Record<string, unknown>;
50
+ return {
51
+ confirmEachPage: flag(r.confirmEachPage, DEFAULT_PREFS.confirmEachPage),
52
+ askOnMismatch: flag(r.askOnMismatch, DEFAULT_PREFS.askOnMismatch),
53
+ autoImages: flag(r.autoImages, DEFAULT_PREFS.autoImages),
54
+ tone: pick(r.tone, TONES, DEFAULT_PREFS.tone),
55
+ research: pick(r.research, RESEARCH, DEFAULT_PREFS.research),
56
+ outline: pick(r.outline, OUTLINES, DEFAULT_PREFS.outline),
57
+ design: pick(r.design, DESIGNS, DEFAULT_PREFS.design),
58
+ review: pick(r.review, REVIEWS, DEFAULT_PREFS.review),
59
+ };
60
+ }
61
+
62
+ export function readPrefs(storage: Storage): AgentPrefs {
63
+ let raw: string | null = null;
64
+ try {
65
+ raw = storage.getItem(PREFS_KEY);
66
+ } catch {
67
+ return { ...DEFAULT_PREFS };
68
+ }
69
+ if (!raw) return { ...DEFAULT_PREFS };
70
+ try {
71
+ return sanitizePrefs(JSON.parse(raw));
72
+ } catch {
73
+ return { ...DEFAULT_PREFS };
74
+ }
75
+ }
76
+
77
+ export function savePrefs(storage: Storage, prefs: AgentPrefs): void {
78
+ try {
79
+ storage.setItem(PREFS_KEY, JSON.stringify(sanitizePrefs(prefs)));
80
+ } catch {}
81
+ }
82
+
83
+ const TONE_LINE: Record<Tone, string> = {
84
+ steady: 'Write in a steady, professional tone.',
85
+ friendly: 'Write in a light, friendly tone.',
86
+ concise: 'Keep the wording short and punchy.',
87
+ };
88
+
89
+ const RESEARCH_LINE: Record<ResearchSource, string> = {
90
+ uploads: "Use only the user's reference files; do not look anything up on the web.",
91
+ web: 'You may look up facts the files do not cover; say where each one came from.',
92
+ };
93
+
94
+ const DESIGN_LINE: Record<DesignDensity, string> = {
95
+ visual: 'Keep text short and give each page one large visual, chart or icon.',
96
+ balanced: 'Balance text and visuals.',
97
+ dense: 'A page may carry more text and data when the content needs it.',
98
+ };
99
+
100
+ const IMAGES_LINE = {
101
+ yes: 'Use icons and image placeholders where a picture helps; never invent photos the user did not provide.',
102
+ no: 'Do not add any image the user did not provide.',
103
+ };
104
+
105
+ const REVIEW_LINE: Record<ReviewMode, string> = {
106
+ strict: 'Check wording, typos and every number.',
107
+ numbers: 'Check only the numbers against the reference files.',
108
+ };
109
+
110
+ const MISMATCH_LINE =
111
+ 'When two files disagree on a number, use the one from the spreadsheet (.xlsx, .xls or .csv) and say which you used.';
112
+
113
+ export type PrefStep = 'outline' | 'page' | 'review';
114
+
115
+ export function prefsLines(prefs: AgentPrefs, step: PrefStep): string[] {
116
+ const lines = [TONE_LINE[prefs.tone]];
117
+ if (step === 'outline') lines.push(RESEARCH_LINE[prefs.research]);
118
+ if (step === 'page') {
119
+ lines.push(DESIGN_LINE[prefs.design]);
120
+ lines.push(prefs.autoImages ? IMAGES_LINE.yes : IMAGES_LINE.no);
121
+ }
122
+ if (step === 'review') {
123
+ lines.push(REVIEW_LINE[prefs.review]);
124
+ if (!prefs.askOnMismatch) lines.push(MISMATCH_LINE);
125
+ }
126
+ return lines;
127
+ }
128
+
129
+ export const USE_IDS = ['report', 'pitch', 'lecture', 'launch', 'training', 'other'] as const;
130
+ export type UseId = (typeof USE_IDS)[number];
131
+
132
+ export function toneForUses(uses: readonly string[]): Tone | null {
133
+ if (uses.includes('launch')) return 'concise';
134
+ if (uses.includes('lecture') || uses.includes('training')) return 'friendly';
135
+ if (uses.includes('report') || uses.includes('pitch')) return 'steady';
136
+ return null;
137
+ }
@@ -0,0 +1,36 @@
1
+ import { useSyncExternalStore } from 'react';
2
+ import { type AgentPrefs, DEFAULT_PREFS, readPrefs, sanitizePrefs, savePrefs } from './prefs';
3
+
4
+ let current: AgentPrefs =
5
+ typeof window === 'undefined' ? DEFAULT_PREFS : readPrefs(window.localStorage);
6
+
7
+ const listeners = new Set<() => void>();
8
+
9
+ function subscribe(listener: () => void): () => void {
10
+ listeners.add(listener);
11
+ return () => {
12
+ listeners.delete(listener);
13
+ };
14
+ }
15
+
16
+ function snapshot(): AgentPrefs {
17
+ return current;
18
+ }
19
+
20
+ function serverSnapshot(): AgentPrefs {
21
+ return DEFAULT_PREFS;
22
+ }
23
+
24
+ export function useAgentPrefs(): AgentPrefs {
25
+ return useSyncExternalStore(subscribe, snapshot, serverSnapshot);
26
+ }
27
+
28
+ export function setAgentPrefs(next: AgentPrefs): void {
29
+ current = sanitizePrefs(next);
30
+ savePrefs(window.localStorage, current);
31
+ for (const listener of listeners) listener();
32
+ }
33
+
34
+ export function updateAgentPrefs(patch: Partial<AgentPrefs>): void {
35
+ setAgentPrefs({ ...current, ...patch });
36
+ }
@@ -25,12 +25,10 @@ import {
25
25
  import { Link2, Link2Off, Maximize2, Minus, Plus, X } from 'lucide-react';
26
26
  import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
27
27
  import { Button } from '@/components/ui/button';
28
- import { useLocale } from '@/lib/use-locale';
29
28
  import { cn, pad2 } from '@/lib/utils';
30
- import type { BoardCard, CardPatch } from '../../../files/board-cards';
31
- import { type BoardColumn, columnsAfterMove } from '../../../files/board-structure';
32
29
  import type { DesignSystem } from '../../lib/design';
33
30
  import type { Page } from '../../lib/sdk';
31
+ import { useLrText } from '../text';
34
32
  import {
35
33
  type BoardLayout,
36
34
  type Box,
@@ -43,6 +41,8 @@ import {
43
41
  orderAfterMove,
44
42
  slotAtPoint,
45
43
  } from './layout';
44
+ import type { BoardCard, CardPatch } from './model/cards';
45
+ import { type BoardColumn, columnsAfterMove } from './model/structure';
46
46
  import { PageNode, type PageNodeData } from './page-node';
47
47
  import '@xyflow/react/dist/base.css';
48
48
  import './board.css';
@@ -81,7 +81,7 @@ type ColumnLabelData = {
81
81
 
82
82
  function ColumnLabel({ data }: NodeProps) {
83
83
  const { title, count, index, onRename, onAddPage } = data as unknown as ColumnLabelData;
84
- const t = useLocale();
84
+ const lr = useLrText();
85
85
  const [editing, setEditing] = useState(false);
86
86
 
87
87
  return (
@@ -94,8 +94,8 @@ function ColumnLabel({ data }: NodeProps) {
94
94
  // biome-ignore lint/a11y/noAutofocus: the field only exists once the title is clicked
95
95
  autoFocus
96
96
  defaultValue={title}
97
- aria-label={t.board.renameColumn}
98
- placeholder={t.board.columnTitlePlaceholder}
97
+ aria-label={lr.board.renameColumn}
98
+ placeholder={lr.board.columnTitlePlaceholder}
99
99
  onKeyDown={(e) => {
100
100
  e.stopPropagation();
101
101
  if (e.key === 'Enter') e.currentTarget.blur();
@@ -115,7 +115,7 @@ function ColumnLabel({ data }: NodeProps) {
115
115
  <button
116
116
  type="button"
117
117
  onClick={() => setEditing(true)}
118
- aria-label={t.board.renameColumn}
118
+ aria-label={lr.board.renameColumn}
119
119
  className="eyebrow min-w-0 truncate rounded-[4px] px-1.5 py-1 text-left motion-safe:transition-colors hover:bg-muted/60"
120
120
  >
121
121
  {title}
@@ -125,7 +125,7 @@ function ColumnLabel({ data }: NodeProps) {
125
125
  <button
126
126
  type="button"
127
127
  onClick={() => onAddPage(index)}
128
- aria-label={t.board.addPage}
128
+ aria-label={lr.board.addPage}
129
129
  className={cn(
130
130
  'ml-auto flex size-6 items-center justify-center rounded-[4px] text-muted-foreground/60',
131
131
  'motion-safe:transition-colors hover:bg-muted hover:text-foreground',
@@ -167,7 +167,7 @@ function boxOf(node: InternalNode | undefined): Box | null {
167
167
  * never be read as the deck's order, and it follows the cards as they move.
168
168
  */
169
169
  function LinkEdge({ id, source, target, data }: EdgeProps) {
170
- const t = useLocale();
170
+ const lr = useLrText();
171
171
  const { a, b, onUnlink } = data as unknown as LinkEdgeData;
172
172
  const from = boxOf(useInternalNode(source));
173
173
  const to = boxOf(useInternalNode(target));
@@ -180,8 +180,8 @@ function LinkEdge({ id, source, target, data }: EdgeProps) {
180
180
  <EdgeLabelRenderer>
181
181
  <button
182
182
  type="button"
183
- aria-label={t.board.removeLink}
184
- title={t.board.removeLink}
183
+ aria-label={lr.board.removeLink}
184
+ title={lr.board.removeLink}
185
185
  onClick={() => onUnlink(a, b)}
186
186
  className="osd-board-link-remove nodrag nopan"
187
187
  style={{ transform: `translate(-50%, -50%) translate(${curve.x}px, ${curve.y}px)` }}
@@ -323,7 +323,7 @@ function BoardFlow({
323
323
  onUnlink,
324
324
  onToggleLinks,
325
325
  }: Props) {
326
- const t = useLocale();
326
+ const lr = useLrText();
327
327
  const { fitView, zoomIn, zoomOut, screenToFlowPosition } = useReactFlow();
328
328
 
329
329
  const layout = useMemo(() => layoutBoard(columns), [columns]);
@@ -530,7 +530,7 @@ function BoardFlow({
530
530
  <Button
531
531
  variant="outline"
532
532
  size="icon-sm"
533
- aria-label={t.board.zoomOut}
533
+ aria-label={lr.board.zoomOut}
534
534
  onClick={() => zoomOut()}
535
535
  >
536
536
  <Minus />
@@ -538,20 +538,20 @@ function BoardFlow({
538
538
  <Button
539
539
  variant="outline"
540
540
  size="icon-sm"
541
- aria-label={t.board.zoomIn}
541
+ aria-label={lr.board.zoomIn}
542
542
  onClick={() => zoomIn()}
543
543
  >
544
544
  <Plus />
545
545
  </Button>
546
- <Button variant="outline" size="icon-sm" aria-label={t.board.fitView} onClick={fitAll}>
546
+ <Button variant="outline" size="icon-sm" aria-label={lr.board.fitView} onClick={fitAll}>
547
547
  <Maximize2 />
548
548
  </Button>
549
549
  <Button
550
550
  variant="outline"
551
551
  size="icon-sm"
552
- aria-label={showLinks ? t.board.hideLinks : t.board.showLinks}
552
+ aria-label={showLinks ? lr.board.hideLinks : lr.board.showLinks}
553
553
  aria-pressed={showLinks}
554
- title={showLinks ? t.board.hideLinks : t.board.showLinks}
554
+ title={showLinks ? lr.board.hideLinks : lr.board.showLinks}
555
555
  onClick={onToggleLinks}
556
556
  >
557
557
  {showLinks ? <Link2 /> : <Link2Off />}