@contractspec/bundle.library 3.9.7 → 3.9.9

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 (71) hide show
  1. package/.turbo/turbo-build.log +186 -174
  2. package/CHANGELOG.md +96 -0
  3. package/dist/components/docs/DocsIndexPage.js +2 -2
  4. package/dist/components/docs/docsManifest.js +1 -1
  5. package/dist/components/docs/getting-started/DataViewTutorialPage.js +117 -6
  6. package/dist/components/docs/getting-started/index.js +130 -19
  7. package/dist/components/docs/guides/GuideDataExchangeImportTemplatesPage.content.d.ts +6 -0
  8. package/dist/components/docs/guides/GuideDataExchangeImportTemplatesPage.content.js +176 -0
  9. package/dist/components/docs/guides/GuideDataExchangeImportTemplatesPage.d.ts +1 -0
  10. package/dist/components/docs/guides/GuideDataExchangeImportTemplatesPage.js +176 -0
  11. package/dist/components/docs/guides/GuidesIndexPage.js +2 -2
  12. package/dist/components/docs/guides/index.d.ts +1 -0
  13. package/dist/components/docs/guides/index.js +220 -46
  14. package/dist/components/docs/index.js +1195 -276
  15. package/dist/components/docs/libraries/LibrariesApplicationShellPage.content.d.ts +33 -0
  16. package/dist/components/docs/libraries/LibrariesApplicationShellPage.content.js +236 -0
  17. package/dist/components/docs/libraries/LibrariesApplicationShellPage.d.ts +1 -0
  18. package/dist/components/docs/libraries/LibrariesApplicationShellPage.js +236 -0
  19. package/dist/components/docs/libraries/LibrariesDataViewsPage.js +130 -6
  20. package/dist/components/docs/libraries/LibrariesDesignSystemPage.js +102 -3
  21. package/dist/components/docs/libraries/LibrariesOverviewPage.js +1 -1
  22. package/dist/components/docs/libraries/LibrariesPersonalizationPage.js +58 -4
  23. package/dist/components/docs/libraries/LibrariesTranslationRuntimePage.content.d.ts +10 -0
  24. package/dist/components/docs/libraries/LibrariesTranslationRuntimePage.content.js +43 -0
  25. package/dist/components/docs/libraries/LibrariesTranslationRuntimePage.d.ts +1 -0
  26. package/dist/components/docs/libraries/LibrariesTranslationRuntimePage.js +43 -0
  27. package/dist/components/docs/libraries/index.d.ts +2 -0
  28. package/dist/components/docs/libraries/index.js +616 -64
  29. package/dist/components/docs/specs/SpecsDataViewsPage.js +85 -3
  30. package/dist/components/docs/specs/index.js +96 -14
  31. package/dist/index.js +1206 -287
  32. package/dist/node/components/docs/DocsIndexPage.js +2 -2
  33. package/dist/node/components/docs/docsManifest.js +1 -1
  34. package/dist/node/components/docs/getting-started/DataViewTutorialPage.js +117 -6
  35. package/dist/node/components/docs/getting-started/index.js +130 -19
  36. package/dist/node/components/docs/guides/GuideDataExchangeImportTemplatesPage.content.js +175 -0
  37. package/dist/node/components/docs/guides/GuideDataExchangeImportTemplatesPage.js +175 -0
  38. package/dist/node/components/docs/guides/GuidesIndexPage.js +2 -2
  39. package/dist/node/components/docs/guides/index.js +220 -46
  40. package/dist/node/components/docs/index.js +1195 -276
  41. package/dist/node/components/docs/libraries/LibrariesApplicationShellPage.content.js +235 -0
  42. package/dist/node/components/docs/libraries/LibrariesApplicationShellPage.js +235 -0
  43. package/dist/node/components/docs/libraries/LibrariesDataViewsPage.js +130 -6
  44. package/dist/node/components/docs/libraries/LibrariesDesignSystemPage.js +102 -3
  45. package/dist/node/components/docs/libraries/LibrariesOverviewPage.js +1 -1
  46. package/dist/node/components/docs/libraries/LibrariesPersonalizationPage.js +58 -4
  47. package/dist/node/components/docs/libraries/LibrariesTranslationRuntimePage.content.js +42 -0
  48. package/dist/node/components/docs/libraries/LibrariesTranslationRuntimePage.js +42 -0
  49. package/dist/node/components/docs/libraries/index.js +616 -64
  50. package/dist/node/components/docs/specs/SpecsDataViewsPage.js +85 -3
  51. package/dist/node/components/docs/specs/index.js +96 -14
  52. package/dist/node/index.js +1206 -287
  53. package/package.json +98 -26
  54. package/src/components/docs/docsManifest.test.ts +87 -0
  55. package/src/components/docs/docsManifest.ts +98 -1
  56. package/src/components/docs/generated/docs-index.notifications.json +7 -7
  57. package/src/components/docs/getting-started/DataViewTutorialPage.tsx +217 -47
  58. package/src/components/docs/guides/GuideDataExchangeImportTemplatesPage.content.ts +185 -0
  59. package/src/components/docs/guides/GuideDataExchangeImportTemplatesPage.tsx +186 -0
  60. package/src/components/docs/guides/GuidesIndexPage.tsx +49 -42
  61. package/src/components/docs/guides/index.ts +1 -0
  62. package/src/components/docs/libraries/LibrariesApplicationShellPage.content.ts +283 -0
  63. package/src/components/docs/libraries/LibrariesApplicationShellPage.tsx +145 -0
  64. package/src/components/docs/libraries/LibrariesDataViewsPage.tsx +278 -54
  65. package/src/components/docs/libraries/LibrariesDesignSystemPage.tsx +244 -0
  66. package/src/components/docs/libraries/LibrariesOverviewPage.tsx +13 -1
  67. package/src/components/docs/libraries/LibrariesPersonalizationPage.tsx +141 -31
  68. package/src/components/docs/libraries/LibrariesTranslationRuntimePage.content.ts +78 -0
  69. package/src/components/docs/libraries/LibrariesTranslationRuntimePage.tsx +137 -0
  70. package/src/components/docs/libraries/index.ts +2 -0
  71. package/src/components/docs/specs/SpecsDataViewsPage.tsx +278 -116
@@ -0,0 +1,186 @@
1
+ import { CodeBlock } from '@contractspec/lib.design-system';
2
+ import { HStack, VStack } from '@contractspec/lib.design-system/layout';
3
+ import { List, ListItem } from '@contractspec/lib.design-system/list';
4
+ import {
5
+ Code,
6
+ H1,
7
+ H2,
8
+ H3,
9
+ P,
10
+ Text,
11
+ } from '@contractspec/lib.design-system/typography';
12
+ import Link from '@contractspec/lib.ui-link';
13
+ import { ChevronRight } from 'lucide-react';
14
+ import {
15
+ accountImportTemplateCode,
16
+ clientReviewCode,
17
+ developerPrompt,
18
+ partnerPrompt,
19
+ serverDryRunCode,
20
+ verificationCode,
21
+ } from './GuideDataExchangeImportTemplatesPage.content';
22
+
23
+ const mappingRules = [
24
+ 'Explicit mappings win first, so existing integrations can keep their current mapping arrays.',
25
+ 'Template resolution checks exact headers, aliases, normalized labels, and SchemaModel fallback inference.',
26
+ 'Format profiles can override formats by target field or template column key without changing the template.',
27
+ 'Required template columns become visible preview issues when no source column can be matched.',
28
+ ];
29
+
30
+ const formatKinds = [
31
+ 'text trim and case normalization',
32
+ 'localized numbers with decimal and thousands separators',
33
+ 'custom true/false boolean labels',
34
+ 'dates and datetimes with accepted input formats',
35
+ 'JSON parsing, empty-as-null, and default values',
36
+ 'split/join delimiters, currency symbols, and percentages',
37
+ ];
38
+
39
+ export function GuideDataExchangeImportTemplatesPage() {
40
+ return (
41
+ <VStack className="space-y-8">
42
+ <VStack className="space-y-3">
43
+ <Text className="editorial-kicker">Build</Text>
44
+ <H1 className="font-bold text-4xl">
45
+ Import flexible files with data-exchange templates
46
+ </H1>
47
+ <P className="max-w-3xl text-lg text-muted-foreground leading-8">
48
+ Publish one recommended import shape, then let users import
49
+ CSV/JSON/XML files with partner-specific headers, skipped rows,
50
+ localized values, and alternate metadata layouts.
51
+ </P>
52
+ </VStack>
53
+
54
+ <VStack className="card-subtle space-y-4 p-6">
55
+ <H2 className="font-bold text-2xl">What you&apos;ll build</H2>
56
+ <List className="space-y-2 text-muted-foreground text-sm">
57
+ <ListItem>
58
+ <Text>
59
+ A canonical template with target fields, aliases, and formats.
60
+ </Text>
61
+ </ListItem>
62
+ <ListItem>
63
+ <Text>
64
+ A dry-run import that reports confidence, gaps, and ignored
65
+ columns.
66
+ </Text>
67
+ </ListItem>
68
+ <ListItem>
69
+ <Text>
70
+ A client review state where users remap, update formats, or accept
71
+ inferred mappings.
72
+ </Text>
73
+ </ListItem>
74
+ </List>
75
+ </VStack>
76
+
77
+ <VStack className="space-y-4">
78
+ <H2 className="font-bold text-2xl">1) Define the template</H2>
79
+ <P className="text-muted-foreground text-sm leading-7">
80
+ Use <Code>defineDataExchangeTemplate</Code> for neutral import/export
81
+ naming. <Code>defineImportTemplate</Code> and{' '}
82
+ <Code>defineExportTemplate</Code> remain available aliases.
83
+ </P>
84
+ <CodeBlock
85
+ language="typescript"
86
+ filename="src/data-exchange/accounts-import.ts"
87
+ code={accountImportTemplateCode}
88
+ />
89
+ </VStack>
90
+
91
+ <VStack className="grid gap-4 md:grid-cols-2">
92
+ <VStack className="card-subtle space-y-3 p-6">
93
+ <H3 className="font-bold text-xl">Mapping precedence</H3>
94
+ <List className="space-y-2 text-muted-foreground text-sm">
95
+ {mappingRules.map((rule) => (
96
+ <ListItem key={rule}>
97
+ <Text>{rule}</Text>
98
+ </ListItem>
99
+ ))}
100
+ </List>
101
+ </VStack>
102
+ <VStack className="card-subtle space-y-3 p-6">
103
+ <H3 className="font-bold text-xl">Supported value formats</H3>
104
+ <List className="space-y-2 text-muted-foreground text-sm">
105
+ {formatKinds.map((format) => (
106
+ <ListItem key={format}>
107
+ <Text>{format}</Text>
108
+ </ListItem>
109
+ ))}
110
+ </List>
111
+ </VStack>
112
+ </VStack>
113
+
114
+ <VStack className="space-y-4">
115
+ <H2 className="font-bold text-2xl">
116
+ 2) Dry-run partner CSV, JSON, or XML files on the server
117
+ </H2>
118
+ <P className="text-muted-foreground text-sm leading-7">
119
+ File, HTTP, and storage adapters accept codec options. CSV can set
120
+ delimiters, quotes, skipped rows, header rows, or explicit columns.
121
+ JSON can read records and metadata from custom keys. XML can use
122
+ custom root, record, metadata, and attribute fields.
123
+ </P>
124
+ <CodeBlock
125
+ language="typescript"
126
+ filename="src/server/import-accounts.ts"
127
+ code={serverDryRunCode}
128
+ />
129
+ </VStack>
130
+
131
+ <VStack className="space-y-4">
132
+ <H2 className="font-bold text-2xl">3) Let users review the mapping</H2>
133
+ <P className="text-muted-foreground text-sm leading-7">
134
+ The shared controller exposes template rows, matched source columns,
135
+ confidence, required status, formatting summaries, unmatched required
136
+ rows, and ignored source columns. Actions let users remap columns,
137
+ select aliases, update field formats, reset to the template, or accept
138
+ inferred mappings.
139
+ </P>
140
+ <CodeBlock
141
+ language="tsx"
142
+ filename="src/components/ImportMappingReview.tsx"
143
+ code={clientReviewCode}
144
+ />
145
+ </VStack>
146
+
147
+ <VStack className="space-y-4">
148
+ <H2 className="font-bold text-2xl">4) Verify the package stack</H2>
149
+ <CodeBlock
150
+ language="bash"
151
+ filename="verification"
152
+ code={verificationCode}
153
+ />
154
+ </VStack>
155
+
156
+ <VStack className="grid gap-4 md:grid-cols-2">
157
+ <VStack className="card-subtle space-y-3 p-6">
158
+ <H3 className="font-bold text-xl">Prompt: build a template</H3>
159
+ <CodeBlock
160
+ language="markdown"
161
+ filename="template-authoring.prompt.md"
162
+ code={developerPrompt}
163
+ />
164
+ </VStack>
165
+ <VStack className="card-subtle space-y-3 p-6">
166
+ <H3 className="font-bold text-xl">Prompt: inspect a partner file</H3>
167
+ <CodeBlock
168
+ language="markdown"
169
+ filename="partner-import-review.prompt.md"
170
+ code={partnerPrompt}
171
+ />
172
+ </VStack>
173
+ </VStack>
174
+
175
+ <HStack className="flex flex-wrap items-center gap-4 pt-4">
176
+ <Link href="/llms/lib.data-exchange-core" className="btn-primary">
177
+ <Text>Core package guide</Text>
178
+ <ChevronRight size={16} />
179
+ </Link>
180
+ <Link href="/llms/lib.data-exchange-server" className="btn-ghost">
181
+ <Text>Server package guide</Text>
182
+ </Link>
183
+ </HStack>
184
+ </VStack>
185
+ );
186
+ }
@@ -1,4 +1,7 @@
1
1
  import { CodeBlock } from '@contractspec/lib.design-system';
2
+ import { HStack, VStack } from '@contractspec/lib.design-system/layout';
3
+ import { List, ListItem } from '@contractspec/lib.design-system/list';
4
+ import { H1, H2, P, Text } from '@contractspec/lib.design-system/typography';
2
5
  import Link from '@contractspec/lib.ui-link';
3
6
  import { ArrowRight, CheckCircle2, GitBranch } from 'lucide-react';
4
7
 
@@ -31,6 +34,13 @@ const guides = [
31
34
  href: '/docs/guides/contract-driven-forms',
32
35
  time: '25 min',
33
36
  },
37
+ {
38
+ title: 'Flexible import templates',
39
+ description:
40
+ 'Accept partner CSV, JSON, and XML files with alternate headers and localized values while preserving a canonical import contract.',
41
+ href: '/docs/guides/data-exchange-import-templates',
42
+ time: '25 min',
43
+ },
34
44
  {
35
45
  title: 'Generate docs and clients',
36
46
  description:
@@ -84,64 +94,61 @@ const guides = [
84
94
 
85
95
  export function GuidesIndexPage() {
86
96
  return (
87
- <div className="space-y-10">
88
- <div className="space-y-3">
89
- <p className="editorial-kicker">Build</p>
90
- <h1 className="font-serif text-4xl tracking-[-0.04em] md:text-5xl">
97
+ <VStack className="space-y-10">
98
+ <VStack className="space-y-3">
99
+ <Text className="editorial-kicker">Build</Text>
100
+ <H1 className="font-serif text-4xl tracking-[-0.04em] md:text-5xl">
91
101
  Adoption guides for teams that want to keep their code.
92
- </h1>
93
- <p className="max-w-3xl text-lg text-muted-foreground leading-8">
102
+ </H1>
103
+ <P className="max-w-3xl text-lg text-muted-foreground leading-8">
94
104
  These guides assume you are introducing ContractSpec into a real code
95
105
  base. Start with a narrow surface, verify the generated outputs, and
96
106
  expand only after the contract loop feels trustworthy.
97
- </p>
98
- </div>
107
+ </P>
108
+ </VStack>
99
109
 
100
- <div className="grid gap-4 md:grid-cols-2">
110
+ <VStack className="grid gap-4 md:grid-cols-2">
101
111
  {guides.map((guide) => (
102
112
  <Link key={guide.href} href={guide.href} className="editorial-panel">
103
- <div className="flex items-start justify-between gap-4">
104
- <div>
105
- <h2 className="font-semibold text-xl">{guide.title}</h2>
106
- <p className="mt-2 text-muted-foreground text-sm leading-7">
113
+ <HStack className="flex items-start justify-between gap-4">
114
+ <VStack>
115
+ <H2 className="font-semibold text-xl">{guide.title}</H2>
116
+ <P className="mt-2 text-muted-foreground text-sm leading-7">
107
117
  {guide.description}
108
- </p>
109
- </div>
118
+ </P>
119
+ </VStack>
110
120
  <ArrowRight className="mt-1 shrink-0" size={18} />
111
- </div>
112
- <div className="mt-4 flex items-center gap-2 text-muted-foreground text-xs">
121
+ </HStack>
122
+ <HStack className="mt-4 flex items-center gap-2 text-muted-foreground text-xs">
113
123
  <CheckCircle2 size={14} />
114
- <span>Target time: {guide.time}</span>
115
- </div>
124
+ <Text>Target time: {guide.time}</Text>
125
+ </HStack>
116
126
  </Link>
117
127
  ))}
118
- </div>
128
+ </VStack>
119
129
 
120
- <div className="editorial-panel space-y-4">
121
- <div className="flex items-center gap-2 font-semibold text-[color:var(--rust)] text-sm uppercase tracking-[0.2em]">
130
+ <VStack className="editorial-panel space-y-4">
131
+ <HStack className="flex items-center gap-2 font-semibold text-[color:var(--rust)] text-sm uppercase tracking-[0.2em]">
122
132
  <GitBranch size={16} />
123
- Working style
124
- </div>
125
- <ul className="editorial-list">
126
- <li>
127
- <span className="editorial-list-marker" />
128
- <span>Run each guide in a branch or sandboxed workspace.</span>
129
- </li>
130
- <li>
131
- <span className="editorial-list-marker" />
132
- <span>
133
+ <Text>Working style</Text>
134
+ </HStack>
135
+ <List className="editorial-list">
136
+ <ListItem>
137
+ <Text>Run each guide in a branch or sandboxed workspace.</Text>
138
+ </ListItem>
139
+ <ListItem>
140
+ <Text>
133
141
  Prefer one bounded surface at a time: one endpoint, one workflow,
134
142
  one integration, one unsafe module.
135
- </span>
136
- </li>
137
- <li>
138
- <span className="editorial-list-marker" />
139
- <span>
143
+ </Text>
144
+ </ListItem>
145
+ <ListItem>
146
+ <Text>
140
147
  Use the example and reference outputs to verify what changed, not
141
148
  just the narrative page.
142
- </span>
143
- </li>
144
- </ul>
149
+ </Text>
150
+ </ListItem>
151
+ </List>
145
152
  <CodeBlock
146
153
  language="bash"
147
154
  filename="guides-quickstart"
@@ -151,7 +158,7 @@ contractspec examples list
151
158
  # validate the examples in this workspace
152
159
  contractspec examples validate --repo-root .`}
153
160
  />
154
- </div>
155
- </div>
161
+ </VStack>
162
+ </VStack>
156
163
  );
157
164
  }
@@ -4,6 +4,7 @@ export { GuideCIDiffGatingPage } from './GuideCIDiffGatingPage';
4
4
  export { GuideConnectInRepoPage } from './GuideConnectInRepoPage';
5
5
  export { GuideContractDrivenFormsPage } from './GuideContractDrivenFormsPage';
6
6
  export { GuideContractTypesPage } from './GuideContractTypesPage';
7
+ export { GuideDataExchangeImportTemplatesPage } from './GuideDataExchangeImportTemplatesPage';
7
8
  export { GuideDocsPipelinePage } from './GuideDocsPipelinePage';
8
9
  export { GuideFirstModuleBundlePage } from './GuideFirstModuleBundlePage';
9
10
  export { GuideGenerateDocsClientsSchemasPage } from './GuideGenerateDocsClientsSchemasPage';
@@ -0,0 +1,283 @@
1
+ export const shellUsageExample = `import {
2
+ AppShell,
3
+ type ShellCommandGroup,
4
+ type ShellNavSection,
5
+ type ShellNotificationCenter,
6
+ type PageOutlineItem,
7
+ } from "@contractspec/lib.design-system/shell";
8
+
9
+ const navigation: ShellNavSection[] = [
10
+ {
11
+ title: "Workspace",
12
+ items: [
13
+ { label: "Dashboard", href: "/dashboard" },
14
+ {
15
+ label: "Contracts",
16
+ href: "/contracts",
17
+ children: [
18
+ { label: "Operations", href: "/contracts/operations" },
19
+ { label: "Events", href: "/contracts/events" },
20
+ ],
21
+ },
22
+ ],
23
+ },
24
+ ];
25
+
26
+ const commands: ShellCommandGroup[] = [
27
+ {
28
+ heading: "Quick actions",
29
+ items: [
30
+ { id: "new-contract", label: "New contract", shortcut: "N" },
31
+ { id: "import", label: "Import existing app" },
32
+ ],
33
+ },
34
+ ];
35
+
36
+ const outline: PageOutlineItem[] = [
37
+ {
38
+ id: "architecture",
39
+ label: "Architecture",
40
+ level: 1,
41
+ children: [
42
+ { id: "desktop", label: "Desktop shell", level: 2 },
43
+ { id: "mobile", label: "Mobile adaptation", level: 2 },
44
+ ],
45
+ },
46
+ ];
47
+
48
+ const notifications: ShellNotificationCenter = {
49
+ label: "Notifications",
50
+ loading: false,
51
+ unreadCount: 2,
52
+ items: [
53
+ {
54
+ id: "contract-approved",
55
+ title: "Contract approved",
56
+ body: "Billing.create is ready to publish.",
57
+ status: "unread",
58
+ createdAt: "2026-04-29T09:30:00Z",
59
+ actionUrl: "/contracts/billing.create",
60
+ category: "Review",
61
+ },
62
+ ],
63
+ onSelect: (item) => openNotificationTarget(item),
64
+ onMarkRead: (item) => markNotificationRead(item.id),
65
+ onMarkAllRead: () => markAllNotificationsRead(),
66
+ };
67
+
68
+ export function WorkspacePage() {
69
+ return (
70
+ <AppShell
71
+ title="ContractSpec"
72
+ homeHref="/dashboard"
73
+ navigation={navigation}
74
+ commands={commands}
75
+ breadcrumbs={[
76
+ { label: "Workspace", href: "/dashboard" },
77
+ { label: "Contracts" },
78
+ ]}
79
+ notifications={notifications}
80
+ pageOutline={outline}
81
+ activeHref="/contracts"
82
+ activeOutlineId="desktop"
83
+ userMenu={<UserMenu onSignOut={() => signOut()} />}
84
+ >
85
+ <main>{/* route content */}</main>
86
+ </AppShell>
87
+ );
88
+ }`;
89
+
90
+ export const notificationCenterExample = `import {
91
+ ListNotificationsOutputModel,
92
+ MarkNotificationReadInputModel,
93
+ } from "@contractspec/lib.contracts-spec/notifications";
94
+ import {
95
+ notificationsSchemaContribution,
96
+ renderNotificationTemplate,
97
+ } from "@contractspec/lib.notification";
98
+ import type { ShellNotificationCenter } from "@contractspec/lib.design-system/shell";
99
+
100
+ type NotificationListResult = {
101
+ unreadCount: number;
102
+ notifications: Array<{
103
+ id: string;
104
+ title: string;
105
+ body: string;
106
+ type: string;
107
+ status: string;
108
+ readAt?: string | Date | null;
109
+ createdAt: string | Date;
110
+ actionUrl?: string;
111
+ metadata?: Record<string, unknown>;
112
+ }>;
113
+ };
114
+
115
+ export function toShellNotifications(
116
+ data: NotificationListResult,
117
+ actions: {
118
+ open: (id: string) => void;
119
+ markRead: (input: { notificationId: string }) => void;
120
+ markAllRead: () => void;
121
+ }
122
+ ): ShellNotificationCenter {
123
+ return {
124
+ unreadCount: data.unreadCount,
125
+ items: data.notifications.map((notification) => ({
126
+ id: notification.id,
127
+ title: notification.title,
128
+ body: notification.body,
129
+ status: notification.status,
130
+ createdAt: notification.createdAt,
131
+ actionUrl: notification.actionUrl,
132
+ category: notification.type,
133
+ metadata: notification.metadata,
134
+ })),
135
+ onSelect: (item) => actions.open(item.id),
136
+ onMarkRead: (item) => actions.markRead({ notificationId: item.id }),
137
+ onMarkAllRead: actions.markAllRead,
138
+ };
139
+ }
140
+
141
+ void ListNotificationsOutputModel;
142
+ void MarkNotificationReadInputModel;
143
+ void notificationsSchemaContribution;
144
+ void renderNotificationTemplate;`;
145
+
146
+ export const scratchPrompt = `You are implementing a modern application shell from scratch.
147
+
148
+ Goal:
149
+ Build a reusable application shell for a React/Next.js web app and an Expo React Native app. The shell must provide a desktop sidebar, desktop topbar, command search, breadcrumbs, nested navigation, user/auth actions, in-app notifications, and an in-page section navigator called PageOutline.
150
+
151
+ Use this architecture:
152
+ - Keep route content independent from navigation chrome.
153
+ - Create a typed navigation model with sections, items, active state, optional children, badges, icons, disabled items, and href/onSelect support.
154
+ - Create a command model with search input, grouped suggestions, quick actions, keyboard shortcut labels, empty state, and loading state.
155
+ - Create a breadcrumb model for the topbar.
156
+ - Create a PageOutline model for right-side in-page navigation with exactly three supported levels. It should render anchors, support active section state, and degrade gracefully when no sections exist.
157
+ - Create a ShellNotificationCenter model with render-ready items, unread count, loading and empty states, onSelect, onMarkRead, onMarkAllRead, and optional custom item rendering.
158
+ - Expose the system from the design system or a dedicated shell module, not from a single app route.
159
+
160
+ Notification boundary:
161
+ - Use @contractspec/lib.contracts-spec/notifications as the canonical source for notification contracts, operation models, and feature metadata.
162
+ - Use @contractspec/lib.notification for reusable notification entities, schema contribution, channels, templates, and i18n helpers.
163
+ - Keep persistence, polling/subscriptions, delivery providers, and optimistic mutations in the host application or notification runtime layer.
164
+ - Pass only render-ready ShellNotificationCenter state into AppShell so the design system does not import or own notification runtime behavior.
165
+
166
+ Desktop behavior:
167
+ - Persistent left sidebar with app logo/title, command trigger, grouped navigation, nested submenus, and current user/auth/logout area.
168
+ - Topbar with breadcrumbs and an optional command trigger.
169
+ - Topbar notification trigger with unread badge, loading/empty states, mark-read actions, and item selection.
170
+ - Content area with optional right PageOutline.
171
+ - Keep dimensions stable. Navigation labels must not resize layout on hover or active state.
172
+
173
+ Mobile web behavior:
174
+ - Use bottom navigation for the primary destinations.
175
+ - Put deeper navigation, command search, notifications, auth actions, and secondary actions behind a menu or drawer when the topbar cannot safely hold them.
176
+ - Keep route content first and make the shell controls reachable without covering important content.
177
+
178
+ Native behavior:
179
+ - Add .native.tsx entrypoints for Expo/React Native.
180
+ - Prefer bottom tabs for primary destinations and a menu/sheet for deeper navigation, notifications, and account actions.
181
+ - Keep the same typed navigation, command, breadcrumb, notification, and PageOutline data contracts across web and native.
182
+
183
+ Implementation constraints:
184
+ - Reuse the existing design-system primitives, tokens, icons, and accessibility patterns.
185
+ - Do not hardcode app-specific routes in the shell component.
186
+ - Do not introduce a new dependency unless the repo already uses it for dialogs, menus, icons, or navigation.
187
+ - Include tests for navigation rendering, nested items, command filtering, breadcrumbs, notification unread badge/loading/empty/callback behavior, PageOutline level handling, active section state, and mobile/native adaptation contracts.
188
+ - Update docs and exports so developers can import the shell from a stable public API.
189
+
190
+ Deliverables:
191
+ - Typed shell models.
192
+ - Web shell components.
193
+ - Native shell components or adapters.
194
+ - PageOutline component with three-level support.
195
+ - ShellNotifications or equivalent notification center component for web and native shell placement.
196
+ - Usage example.
197
+ - Focused tests and typecheck/build evidence.`;
198
+
199
+ export const refactorPrompt = `You are refactoring an existing application to use the shared application shell system.
200
+
201
+ Goal:
202
+ Replace app-specific sidebar, topbar, breadcrumb, command palette, notification badge/inbox, account menu, mobile navigation, and in-page table-of-contents code with the shared AppShell, ShellNotifications, and PageOutline system.
203
+
204
+ Start by auditing:
205
+ - Current layout wrappers and route groups.
206
+ - Sidebar, topbar, breadcrumb, command/search, auth menu, and mobile navigation implementations.
207
+ - Existing notification badges, inbox panels, toasts that represent durable in-app items, unread count queries, mark-read actions, and delivery modules.
208
+ - Imports from @contractspec/module.notifications that should migrate to @contractspec/lib.contracts-spec/notifications or @contractspec/lib.notification.
209
+ - Any duplicated navigation arrays, route labels, icon maps, access-control checks, and active-state logic.
210
+ - Any in-page summary/table-of-contents components that should become PageOutline data.
211
+ - Web-only assumptions that would block Expo/React Native adaptation.
212
+
213
+ Refactor plan:
214
+ 1. Define a single typed navigation source for primary nav, grouped sidebar nav, nested children, labels, icons, badges, disabled states, and permissions.
215
+ 2. Map existing command/search behavior into grouped command actions with search text and quick actions.
216
+ 3. Map existing route metadata into breadcrumbs.
217
+ 4. Move canonical notification contracts to @contractspec/lib.contracts-spec/notifications and reusable helpers to @contractspec/lib.notification; keep the old module shim only for compatibility imports that still need the legacy module id.
218
+ 5. Convert notification query results into ShellNotificationCenter items with unreadCount, loading, empty state, onSelect, onMarkRead, and onMarkAllRead callbacks.
219
+ 6. Convert page table-of-contents or section summary data into PageOutline items with a maximum of three levels.
220
+ 7. Wrap app routes in AppShell while keeping page content components route-local.
221
+ 8. Move primary mobile destinations into bottom navigation and deeper/account/notification actions into a menu or drawer.
222
+ 9. Add or preserve .native.tsx adapters when the app targets Expo.
223
+
224
+ Preserve behavior:
225
+ - Existing route URLs and access rules.
226
+ - Existing keyboard shortcuts where they are public behavior.
227
+ - Existing analytics or telemetry events on navigation and command actions.
228
+ - Existing notification delivery semantics, unread count semantics, deep links, and mark-read behavior.
229
+ - Existing auth/logout behavior.
230
+ - Existing responsive breakpoints unless there is a documented design-system breakpoint to adopt.
231
+
232
+ Quality gates:
233
+ - Add regression tests around current visible navigation before removing old shell code when coverage is missing.
234
+ - Test active nav state, nested nav expansion, command search/action invocation, breadcrumbs, notification unread badge/loading/empty/callback behavior, auth menu, mobile bottom navigation, and PageOutline anchor behavior.
235
+ - Run lint, typecheck, and the app's relevant test/build command.
236
+ - Remove dead app-specific shell components only after the shared shell path is verified.
237
+
238
+ Output:
239
+ - List old shell files removed or simplified.
240
+ - List new shared shell integration points.
241
+ - Include before/after route coverage and verification commands.`;
242
+
243
+ export const notificationGuide = [
244
+ {
245
+ title: 'Contracts stay canonical',
246
+ body: 'Use @contractspec/lib.contracts-spec/notifications for operation models, feature metadata, and contract-level compatibility.',
247
+ },
248
+ {
249
+ title: 'Runtime helpers stay reusable',
250
+ body: 'Use @contractspec/lib.notification for schema contribution, channel adapters, templates, and i18n without importing the deprecated module shim in new code.',
251
+ },
252
+ {
253
+ title: 'Apps own live state',
254
+ body: 'Fetch, subscribe, persist, mutate, and reconcile notification state in the host app or runtime layer where auth and tenancy are known.',
255
+ },
256
+ {
257
+ title: 'Shell receives view state',
258
+ body: 'Pass AppShell a ShellNotificationCenter with render-ready items, counts, loading state, and callbacks; the design system only renders affordances.',
259
+ },
260
+ ] as const;
261
+
262
+ export const shellParts = [
263
+ {
264
+ title: 'Sidebar',
265
+ body: 'Desktop owns brand, command entry, grouped navigation, nested items, and account actions in one persistent scanning area.',
266
+ },
267
+ {
268
+ title: 'Topbar',
269
+ body: 'Breadcrumbs stay visible while the current route changes. Command search and notification affordances can live here when the sidebar is collapsed or hidden.',
270
+ },
271
+ {
272
+ title: 'PageOutline',
273
+ body: 'The right-side in-page navigator replaces ad hoc tables of contents. It supports three levels of section anchors and active state.',
274
+ },
275
+ {
276
+ title: 'Notifications',
277
+ body: 'The shell renders unread badges, item lists, loading/empty states, mark-read actions, and deep-link selection from host-owned notification state.',
278
+ },
279
+ {
280
+ title: 'Mobile adapters',
281
+ body: 'Small web and native surfaces move primary destinations to bottom navigation and reserve drawers or menus for deep navigation, notifications, and account actions.',
282
+ },
283
+ ] as const;