@nkzw/codiff-core 1.8.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.
Files changed (72) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +15 -0
  3. package/dist/SharedPlanApp.d.ts +32 -0
  4. package/dist/SharedWalkthroughApp.d.ts +40 -0
  5. package/dist/app/components/Avatar.d.ts +6 -0
  6. package/dist/app/components/Button.d.ts +12 -0
  7. package/dist/app/components/CommandBar.d.ts +8 -0
  8. package/dist/app/components/FileTree.d.ts +10 -0
  9. package/dist/app/components/KeyboardShortcutsHelp.d.ts +5 -0
  10. package/dist/app/components/MarkdownDocumentEditor.d.ts +26 -0
  11. package/dist/app/components/Panels.d.ts +71 -0
  12. package/dist/app/components/PlanEditorView.d.ts +18 -0
  13. package/dist/app/components/ReadOnlyMarkdownView.d.ts +16 -0
  14. package/dist/app/components/ReviewCodeView.d.ts +103 -0
  15. package/dist/app/components/Sidebar.d.ts +48 -0
  16. package/dist/app/components/WalkthroughFileError.d.ts +4 -0
  17. package/dist/app/components/merge-request/GeneralComments.d.ts +49 -0
  18. package/dist/app/components/useCopiedState.d.ts +1 -0
  19. package/dist/app/components/walkthrough/CommitView.d.ts +23 -0
  20. package/dist/app/components/walkthrough/NarrativeSidebar.d.ts +12 -0
  21. package/dist/app/components/walkthrough/NarrativeWalkthroughView.d.ts +44 -0
  22. package/dist/app/components/walkthrough/WalkthroughDiffSurface.d.ts +16 -0
  23. package/dist/app/components/walkthrough/WalkthroughProgress.d.ts +8 -0
  24. package/dist/app/components/walkthrough/parts.d.ts +15 -0
  25. package/dist/app/components/walkthrough/useNarrativeNavigation.d.ts +34 -0
  26. package/dist/app/hooks/useAppCommands.d.ts +22 -0
  27. package/dist/app/hooks/useAppKeyboardShortcuts.d.ts +18 -0
  28. package/dist/app/hooks/useAppReviewComments.d.ts +38 -0
  29. package/dist/app/hooks/useAppWalkthrough.d.ts +96 -0
  30. package/dist/app/hooks/useDiffSearch.d.ts +24 -0
  31. package/dist/app/hooks/useDocumentAppearance.d.ts +10 -0
  32. package/dist/app/hooks/useResizableSidebar.d.ts +12 -0
  33. package/dist/app/hooks/useReviewCommentDrafts.d.ts +23 -0
  34. package/dist/app/hooks/useReviewState.d.ts +22 -0
  35. package/dist/config/defaults.d.ts +4 -0
  36. package/dist/config/keymap.d.ts +3 -0
  37. package/dist/config/types.d.ts +44 -0
  38. package/dist/defaults.d.ts +2 -0
  39. package/dist/fonts/firacode/FiraCode-Regular.woff2 +0 -0
  40. package/dist/fonts/firacode/FiraCode-SemiBold.woff2 +0 -0
  41. package/dist/index.d.ts +3 -0
  42. package/dist/index.mjs +12 -0
  43. package/dist/lib/app-constants.d.ts +7 -0
  44. package/dist/lib/app-types.d.ts +137 -0
  45. package/dist/lib/code-view-options.d.ts +26 -0
  46. package/dist/lib/command-registry.d.ts +14 -0
  47. package/dist/lib/diff-search.d.ts +3 -0
  48. package/dist/lib/diff.d.ts +35 -0
  49. package/dist/lib/files.d.ts +14 -0
  50. package/dist/lib/item-version.d.ts +1 -0
  51. package/dist/lib/keyboard.d.ts +2 -0
  52. package/dist/lib/markdown.d.ts +3 -0
  53. package/dist/lib/narrative-walkthrough-diff.d.ts +113 -0
  54. package/dist/lib/narrative-walkthrough-diff.mjs +257 -0
  55. package/dist/lib/narrative-walkthrough.d.ts +108 -0
  56. package/dist/lib/reload-selection.d.ts +23 -0
  57. package/dist/lib/review-command-target.d.ts +15 -0
  58. package/dist/lib/review-comments.d.ts +29 -0
  59. package/dist/lib/review-identity.d.ts +7 -0
  60. package/dist/lib/review-scroll.d.ts +5 -0
  61. package/dist/lib/search-highlights.d.ts +5 -0
  62. package/dist/lib/sidebar-width.d.ts +9 -0
  63. package/dist/lib/source.d.ts +18 -0
  64. package/dist/lib/viewed.d.ts +2 -0
  65. package/dist/react.d.ts +3 -0
  66. package/dist/react.mjs +9355 -0
  67. package/dist/share.d.ts +301 -0
  68. package/dist/share.mjs +103 -0
  69. package/dist/style.css +9142 -0
  70. package/dist/styles.css.d.ts +2 -0
  71. package/dist/types.d.ts +702 -0
  72. package/package.json +71 -0
@@ -0,0 +1,301 @@
1
+ import { type InferOutput } from 'valibot';
2
+ export declare const planShareManifestV1Schema: import("valibot").LooseObjectSchema<{
3
+ readonly codiffVersion: import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").MinLengthAction<string, 1, undefined>, import("valibot").MaxLengthAction<string, number, undefined>]>;
4
+ readonly document: import("valibot").LooseObjectSchema<{
5
+ readonly content: import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").MaxLengthAction<string, number, undefined>]>;
6
+ readonly name: import("valibot").SchemaWithPipe<readonly [import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").MinLengthAction<string, 1, undefined>, import("valibot").MaxLengthAction<string, number, undefined>]>, import("valibot").CheckAction<string, "Invalid plan file name.">]>;
7
+ readonly title: import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").MinLengthAction<string, 1, undefined>, import("valibot").MaxLengthAction<string, number, undefined>]>;
8
+ }, undefined>;
9
+ readonly exportedAt: import("valibot").SchemaWithPipe<readonly [import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").MinLengthAction<string, 1, undefined>, import("valibot").MaxLengthAction<string, number, undefined>]>, import("valibot").CheckAction<string, "Invalid timestamp.">]>;
10
+ readonly kind: import("valibot").LiteralSchema<"codiff-plan-share", undefined>;
11
+ readonly preferences: import("valibot").LooseObjectSchema<{
12
+ readonly theme: import("valibot").PicklistSchema<["dark", "light", "system"], undefined>;
13
+ }, undefined>;
14
+ readonly review: import("valibot").LooseObjectSchema<{
15
+ readonly threads: import("valibot").SchemaWithPipe<readonly [import("valibot").ArraySchema<import("valibot").LooseObjectSchema<{
16
+ readonly anchor: import("valibot").UnionSchema<[import("valibot").LooseObjectSchema<{
17
+ readonly block: import("valibot").LooseObjectSchema<{
18
+ readonly fingerprint: import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").MinLengthAction<string, 1, undefined>, import("valibot").MaxLengthAction<string, number, undefined>]>;
19
+ readonly path: import("valibot").SchemaWithPipe<readonly [import("valibot").ArraySchema<import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<undefined>, import("valibot").IntegerAction<number, undefined>, import("valibot").MinValueAction<number, 0, undefined>, import("valibot").MaxValueAction<number, 1000000, undefined>]>, undefined>, import("valibot").MaxLengthAction<number[], 64, undefined>]>;
20
+ readonly runtimeKey: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").MaxLengthAction<string, number, undefined>]>, undefined>;
21
+ readonly text: import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").MaxLengthAction<string, number, undefined>]>;
22
+ readonly type: import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").MinLengthAction<string, 1, undefined>, import("valibot").MaxLengthAction<string, number, undefined>]>;
23
+ }, undefined>;
24
+ readonly kind: import("valibot").LiteralSchema<"block", undefined>;
25
+ readonly version: import("valibot").LiteralSchema<1, undefined>;
26
+ }, undefined>, import("valibot").SchemaWithPipe<readonly [import("valibot").LooseObjectSchema<{
27
+ readonly block: import("valibot").LooseObjectSchema<{
28
+ readonly fingerprint: import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").MinLengthAction<string, 1, undefined>, import("valibot").MaxLengthAction<string, number, undefined>]>;
29
+ readonly path: import("valibot").SchemaWithPipe<readonly [import("valibot").ArraySchema<import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<undefined>, import("valibot").IntegerAction<number, undefined>, import("valibot").MinValueAction<number, 0, undefined>, import("valibot").MaxValueAction<number, 1000000, undefined>]>, undefined>, import("valibot").MaxLengthAction<number[], 64, undefined>]>;
30
+ readonly runtimeKey: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").MaxLengthAction<string, number, undefined>]>, undefined>;
31
+ readonly text: import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").MaxLengthAction<string, number, undefined>]>;
32
+ readonly type: import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").MinLengthAction<string, 1, undefined>, import("valibot").MaxLengthAction<string, number, undefined>]>;
33
+ }, undefined>;
34
+ readonly kind: import("valibot").LiteralSchema<"text", undefined>;
35
+ readonly quote: import("valibot").LooseObjectSchema<{
36
+ readonly end: import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<undefined>, import("valibot").IntegerAction<number, undefined>, import("valibot").MinValueAction<number, 0, undefined>, import("valibot").MaxValueAction<number, 1000000, undefined>]>;
37
+ readonly exact: import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").MaxLengthAction<string, number, undefined>]>;
38
+ readonly prefix: import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").MaxLengthAction<string, number, undefined>]>;
39
+ readonly start: import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<undefined>, import("valibot").IntegerAction<number, undefined>, import("valibot").MinValueAction<number, 0, undefined>, import("valibot").MaxValueAction<number, 1000000, undefined>]>;
40
+ readonly suffix: import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").MaxLengthAction<string, number, undefined>]>;
41
+ }, undefined>;
42
+ readonly version: import("valibot").LiteralSchema<1, undefined>;
43
+ }, undefined>, import("valibot").CheckAction<{
44
+ block: {
45
+ fingerprint: string;
46
+ path: number[];
47
+ runtimeKey?: string | undefined;
48
+ text: string;
49
+ type: string;
50
+ } & {
51
+ [key: string]: unknown;
52
+ };
53
+ kind: "text";
54
+ quote: {
55
+ end: number;
56
+ exact: string;
57
+ prefix: string;
58
+ start: number;
59
+ suffix: string;
60
+ } & {
61
+ [key: string]: unknown;
62
+ };
63
+ version: 1;
64
+ } & {
65
+ [key: string]: unknown;
66
+ }, "Invalid quote range.">]>], undefined>;
67
+ readonly createdAt: import("valibot").SchemaWithPipe<readonly [import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").MinLengthAction<string, 1, undefined>, import("valibot").MaxLengthAction<string, number, undefined>]>, import("valibot").CheckAction<string, "Invalid timestamp.">]>;
68
+ readonly createdBy: import("valibot").LooseObjectSchema<{
69
+ readonly avatarUrl: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").MaxLengthAction<string, number, undefined>]>, undefined>;
70
+ readonly email: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").MaxLengthAction<string, number, undefined>]>, undefined>;
71
+ readonly id: import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").MinLengthAction<string, 1, undefined>, import("valibot").MaxLengthAction<string, number, undefined>]>;
72
+ readonly name: import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").MinLengthAction<string, 1, undefined>, import("valibot").MaxLengthAction<string, number, undefined>]>;
73
+ readonly username: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").MaxLengthAction<string, number, undefined>]>, undefined>;
74
+ }, undefined>;
75
+ readonly id: import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").MinLengthAction<string, 1, undefined>, import("valibot").MaxLengthAction<string, number, undefined>]>;
76
+ readonly messages: import("valibot").SchemaWithPipe<readonly [import("valibot").ArraySchema<import("valibot").LooseObjectSchema<{
77
+ readonly author: import("valibot").LooseObjectSchema<{
78
+ readonly avatarUrl: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").MaxLengthAction<string, number, undefined>]>, undefined>;
79
+ readonly email: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").MaxLengthAction<string, number, undefined>]>, undefined>;
80
+ readonly id: import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").MinLengthAction<string, 1, undefined>, import("valibot").MaxLengthAction<string, number, undefined>]>;
81
+ readonly name: import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").MinLengthAction<string, 1, undefined>, import("valibot").MaxLengthAction<string, number, undefined>]>;
82
+ readonly username: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").MaxLengthAction<string, number, undefined>]>, undefined>;
83
+ }, undefined>;
84
+ readonly body: import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").MaxLengthAction<string, number, undefined>]>;
85
+ readonly createdAt: import("valibot").SchemaWithPipe<readonly [import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").MinLengthAction<string, 1, undefined>, import("valibot").MaxLengthAction<string, number, undefined>]>, import("valibot").CheckAction<string, "Invalid timestamp.">]>;
86
+ readonly id: import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").MinLengthAction<string, 1, undefined>, import("valibot").MaxLengthAction<string, number, undefined>]>;
87
+ readonly updatedAt: import("valibot").SchemaWithPipe<readonly [import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").MinLengthAction<string, 1, undefined>, import("valibot").MaxLengthAction<string, number, undefined>]>, import("valibot").CheckAction<string, "Invalid timestamp.">]>;
88
+ }, undefined>, undefined>, import("valibot").MinLengthAction<({
89
+ author: {
90
+ avatarUrl?: string | undefined;
91
+ email?: string | undefined;
92
+ id: string;
93
+ name: string;
94
+ username?: string | undefined;
95
+ } & {
96
+ [key: string]: unknown;
97
+ };
98
+ body: string;
99
+ createdAt: string;
100
+ id: string;
101
+ updatedAt: string;
102
+ } & {
103
+ [key: string]: unknown;
104
+ })[], 1, undefined>, import("valibot").MaxLengthAction<({
105
+ author: {
106
+ avatarUrl?: string | undefined;
107
+ email?: string | undefined;
108
+ id: string;
109
+ name: string;
110
+ username?: string | undefined;
111
+ } & {
112
+ [key: string]: unknown;
113
+ };
114
+ body: string;
115
+ createdAt: string;
116
+ id: string;
117
+ updatedAt: string;
118
+ } & {
119
+ [key: string]: unknown;
120
+ })[], 100, undefined>, import("valibot").CheckAction<({
121
+ author: {
122
+ avatarUrl?: string | undefined;
123
+ email?: string | undefined;
124
+ id: string;
125
+ name: string;
126
+ username?: string | undefined;
127
+ } & {
128
+ [key: string]: unknown;
129
+ };
130
+ body: string;
131
+ createdAt: string;
132
+ id: string;
133
+ updatedAt: string;
134
+ } & {
135
+ [key: string]: unknown;
136
+ })[], "Duplicate message ID.">]>;
137
+ readonly status: import("valibot").PicklistSchema<["open", "resolved"], undefined>;
138
+ readonly updatedAt: import("valibot").SchemaWithPipe<readonly [import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").MinLengthAction<string, 1, undefined>, import("valibot").MaxLengthAction<string, number, undefined>]>, import("valibot").CheckAction<string, "Invalid timestamp.">]>;
139
+ }, undefined>, undefined>, import("valibot").MaxLengthAction<({
140
+ anchor: ({
141
+ block: {
142
+ fingerprint: string;
143
+ path: number[];
144
+ runtimeKey?: string | undefined;
145
+ text: string;
146
+ type: string;
147
+ } & {
148
+ [key: string]: unknown;
149
+ };
150
+ kind: "text";
151
+ quote: {
152
+ end: number;
153
+ exact: string;
154
+ prefix: string;
155
+ start: number;
156
+ suffix: string;
157
+ } & {
158
+ [key: string]: unknown;
159
+ };
160
+ version: 1;
161
+ } & {
162
+ [key: string]: unknown;
163
+ }) | ({
164
+ block: {
165
+ fingerprint: string;
166
+ path: number[];
167
+ runtimeKey?: string | undefined;
168
+ text: string;
169
+ type: string;
170
+ } & {
171
+ [key: string]: unknown;
172
+ };
173
+ kind: "block";
174
+ version: 1;
175
+ } & {
176
+ [key: string]: unknown;
177
+ });
178
+ createdAt: string;
179
+ createdBy: {
180
+ avatarUrl?: string | undefined;
181
+ email?: string | undefined;
182
+ id: string;
183
+ name: string;
184
+ username?: string | undefined;
185
+ } & {
186
+ [key: string]: unknown;
187
+ };
188
+ id: string;
189
+ messages: ({
190
+ author: {
191
+ avatarUrl?: string | undefined;
192
+ email?: string | undefined;
193
+ id: string;
194
+ name: string;
195
+ username?: string | undefined;
196
+ } & {
197
+ [key: string]: unknown;
198
+ };
199
+ body: string;
200
+ createdAt: string;
201
+ id: string;
202
+ updatedAt: string;
203
+ } & {
204
+ [key: string]: unknown;
205
+ })[];
206
+ status: "open" | "resolved";
207
+ updatedAt: string;
208
+ } & {
209
+ [key: string]: unknown;
210
+ })[], 1000, undefined>, import("valibot").CheckAction<({
211
+ anchor: ({
212
+ block: {
213
+ fingerprint: string;
214
+ path: number[];
215
+ runtimeKey?: string | undefined;
216
+ text: string;
217
+ type: string;
218
+ } & {
219
+ [key: string]: unknown;
220
+ };
221
+ kind: "text";
222
+ quote: {
223
+ end: number;
224
+ exact: string;
225
+ prefix: string;
226
+ start: number;
227
+ suffix: string;
228
+ } & {
229
+ [key: string]: unknown;
230
+ };
231
+ version: 1;
232
+ } & {
233
+ [key: string]: unknown;
234
+ }) | ({
235
+ block: {
236
+ fingerprint: string;
237
+ path: number[];
238
+ runtimeKey?: string | undefined;
239
+ text: string;
240
+ type: string;
241
+ } & {
242
+ [key: string]: unknown;
243
+ };
244
+ kind: "block";
245
+ version: 1;
246
+ } & {
247
+ [key: string]: unknown;
248
+ });
249
+ createdAt: string;
250
+ createdBy: {
251
+ avatarUrl?: string | undefined;
252
+ email?: string | undefined;
253
+ id: string;
254
+ name: string;
255
+ username?: string | undefined;
256
+ } & {
257
+ [key: string]: unknown;
258
+ };
259
+ id: string;
260
+ messages: ({
261
+ author: {
262
+ avatarUrl?: string | undefined;
263
+ email?: string | undefined;
264
+ id: string;
265
+ name: string;
266
+ username?: string | undefined;
267
+ } & {
268
+ [key: string]: unknown;
269
+ };
270
+ body: string;
271
+ createdAt: string;
272
+ id: string;
273
+ updatedAt: string;
274
+ } & {
275
+ [key: string]: unknown;
276
+ })[];
277
+ status: "open" | "resolved";
278
+ updatedAt: string;
279
+ } & {
280
+ [key: string]: unknown;
281
+ })[], "Duplicate thread ID.">]>;
282
+ readonly version: import("valibot").LiteralSchema<1, undefined>;
283
+ }, undefined>;
284
+ readonly source: import("valibot").OptionalSchema<import("valibot").LooseObjectSchema<{
285
+ readonly agent: import("valibot").OptionalSchema<import("valibot").PicklistSchema<["claude", "codex", "opencode", "pi"], undefined>, undefined>;
286
+ readonly sessionId: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").MaxLengthAction<string, number, undefined>]>, undefined>;
287
+ }, undefined>, undefined>;
288
+ readonly version: import("valibot").LiteralSchema<1, undefined>;
289
+ }, undefined>;
290
+ declare const uploaderSchema: import("valibot").LooseObjectSchema<{
291
+ readonly email: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").MaxLengthAction<string, number, undefined>]>, undefined>;
292
+ readonly name: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").MaxLengthAction<string, number, undefined>]>, undefined>;
293
+ }, undefined>;
294
+ export type PlanShareManifestV1 = InferOutput<typeof planShareManifestV1Schema>;
295
+ export type ShareUploader = InferOutput<typeof uploaderSchema>;
296
+ export declare const parsePlanShareManifest: (value: unknown) => PlanShareManifestV1;
297
+ export declare const parsePlanShareUpload: (value: unknown) => {
298
+ snapshot: PlanShareManifestV1;
299
+ uploader?: ShareUploader;
300
+ };
301
+ export {};
package/dist/share.mjs ADDED
@@ -0,0 +1,103 @@
1
+ import { array, check, integer, literal, looseObject, maxLength, maxValue, minLength, minValue, number, optional, parse, picklist, pipe, safeParse, string, union } from "valibot";
2
+ //#region share.ts
3
+ const maxDocumentLength = 2 * 1024 * 1024;
4
+ const maxCommentLength = 128 * 1024;
5
+ const maxAnchorTextLength = 64 * 1024;
6
+ const boundedString = (maximum) => pipe(string(), maxLength(maximum));
7
+ const nonEmptyString = (maximum) => pipe(string(), minLength(1), maxLength(maximum));
8
+ const timestamp = pipe(nonEmptyString(64), check((value) => Number.isFinite(Date.parse(value)), "Invalid timestamp."));
9
+ const index = pipe(number(), integer(), minValue(0), maxValue(1e6));
10
+ const authorSchema = looseObject({
11
+ avatarUrl: optional(boundedString(2048)),
12
+ email: optional(boundedString(320)),
13
+ id: nonEmptyString(200),
14
+ name: nonEmptyString(200),
15
+ username: optional(boundedString(200))
16
+ });
17
+ const blockSchema = looseObject({
18
+ fingerprint: nonEmptyString(256),
19
+ path: pipe(array(index), maxLength(64)),
20
+ runtimeKey: optional(boundedString(256)),
21
+ text: boundedString(maxAnchorTextLength),
22
+ type: nonEmptyString(64)
23
+ });
24
+ const blockAnchorSchema = looseObject({
25
+ block: blockSchema,
26
+ kind: literal("block"),
27
+ version: literal(1)
28
+ });
29
+ const textAnchorSchema = pipe(looseObject({
30
+ block: blockSchema,
31
+ kind: literal("text"),
32
+ quote: looseObject({
33
+ end: index,
34
+ exact: boundedString(maxAnchorTextLength),
35
+ prefix: boundedString(1024),
36
+ start: index,
37
+ suffix: boundedString(1024)
38
+ }),
39
+ version: literal(1)
40
+ }), check(({ quote }) => quote.end >= quote.start, "Invalid quote range."));
41
+ const messageSchema = looseObject({
42
+ author: authorSchema,
43
+ body: boundedString(maxCommentLength),
44
+ createdAt: timestamp,
45
+ id: nonEmptyString(200),
46
+ updatedAt: timestamp
47
+ });
48
+ const threadSchema = looseObject({
49
+ anchor: union([blockAnchorSchema, textAnchorSchema]),
50
+ createdAt: timestamp,
51
+ createdBy: authorSchema,
52
+ id: nonEmptyString(200),
53
+ messages: pipe(array(messageSchema), minLength(1), maxLength(100), check((messages) => new Set(messages.map(({ id }) => id)).size === messages.length, "Duplicate message ID.")),
54
+ status: picklist(["open", "resolved"]),
55
+ updatedAt: timestamp
56
+ });
57
+ const planShareManifestV1Schema = looseObject({
58
+ codiffVersion: nonEmptyString(100),
59
+ document: looseObject({
60
+ content: boundedString(maxDocumentLength),
61
+ name: pipe(nonEmptyString(300), check((value) => !value.includes("/") && !value.includes("\\") && /\.md$/i.test(value), "Invalid plan file name.")),
62
+ title: nonEmptyString(300)
63
+ }),
64
+ exportedAt: timestamp,
65
+ kind: literal("codiff-plan-share"),
66
+ preferences: looseObject({ theme: picklist([
67
+ "dark",
68
+ "light",
69
+ "system"
70
+ ]) }),
71
+ review: looseObject({
72
+ threads: pipe(array(threadSchema), maxLength(1e3), check((threads) => new Set(threads.map(({ id }) => id)).size === threads.length, "Duplicate thread ID.")),
73
+ version: literal(1)
74
+ }),
75
+ source: optional(looseObject({
76
+ agent: optional(picklist([
77
+ "claude",
78
+ "codex",
79
+ "opencode",
80
+ "pi"
81
+ ])),
82
+ sessionId: optional(boundedString(200))
83
+ })),
84
+ version: literal(1)
85
+ });
86
+ const planShareUploadEnvelopeSchema = looseObject({
87
+ snapshot: planShareManifestV1Schema,
88
+ uploader: optional(looseObject({
89
+ email: optional(boundedString(320)),
90
+ name: optional(boundedString(200))
91
+ }))
92
+ });
93
+ const parsePlanShareManifest = (value) => parse(planShareManifestV1Schema, value);
94
+ const parsePlanShareUpload = (value) => {
95
+ const envelope = safeParse(planShareUploadEnvelopeSchema, value);
96
+ if (envelope.success) return {
97
+ snapshot: envelope.output.snapshot,
98
+ ...envelope.output.uploader ? { uploader: envelope.output.uploader } : {}
99
+ };
100
+ return { snapshot: parsePlanShareManifest(value) };
101
+ };
102
+ //#endregion
103
+ export { parsePlanShareManifest, parsePlanShareUpload, planShareManifestV1Schema };