Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

project.ts

617 lines20.7 KB

1import * as Schema from "effect/Schema";
2import * as SchemaTransformation from "effect/SchemaTransformation";
3import * as Struct from "effect/Struct";
4import { RepositoryIdentity, ThreadEnvMode } from "./environment.ts";
5import { ModelSelection } from "./modelSelection.ts";
6import {
7 CommandId,
8 ForwardCompatibleUnion,
9 isUnknownUnionMember,
10 IsoDateTime,
11 NonNegativeInt,
12 PositiveInt,
13 ProjectId,
14 ThreadId,
15 TrimmedNonEmptyString,
16 TrimmedString,
17 type UnknownUnionMember,
18} from "./baseSchemas.ts";
19​
20const PROJECT_SEARCH_ENTRIES_MAX_LIMIT = 200;
21const PROJECT_SEARCH_CONTENTS_MAX_LIMIT = 500;
22export const PROJECT_SEARCH_CONTENTS_QUERY_MAX_LENGTH = 256;
23const PROJECT_WRITE_FILE_PATH_MAX_LENGTH = 512;
24const PROJECT_READ_FILE_PATH_MAX_LENGTH = 512;
25​
26export const ProjectScriptIcon = Schema.Literals([
27 "play",
28 "test",
29 "lint",
30 "configure",
31 "build",
32 "debug",
33]);
34export type ProjectScriptIcon = typeof ProjectScriptIcon.Type;
35​
36export const ProjectScript = Schema.Struct({
37 id: TrimmedNonEmptyString,
38 name: TrimmedNonEmptyString,
39 command: TrimmedNonEmptyString,
40 icon: ProjectScriptIcon,
41 runOnWorktreeCreate: Schema.Boolean,
42 runOnSettle: Schema.optional(Schema.Boolean),
43 stopOnSettle: Schema.optional(Schema.Boolean),
44 async: Schema.optional(Schema.Boolean),
45 previewUrl: Schema.optional(TrimmedNonEmptyString),
46 autoOpenPreview: Schema.optional(Schema.Boolean),
47});
48export type ProjectScript = typeof ProjectScript.Type;
49​
50export const PROJECT_TRACKED_FOLDERS_MAX = 128;
51​
52/**
53 * A folder the project works in besides its home folder. Paths are absolute and only mean
54 * something on the project's own environment. Git folders get their own history and review.
55 */
56export const ProjectTrackedFolder = Schema.Struct({
57 path: TrimmedNonEmptyString,
58 name: TrimmedNonEmptyString.check(Schema.isMaxLength(128)),
59 /**
60 * The server found this repository inside the project folder and keeps the entry in step with
61 * the disk. Absent on a folder someone added.
62 */
63 discovered: Schema.optional(Schema.Boolean),
64});
65export type ProjectTrackedFolder = typeof ProjectTrackedFolder.Type;
66​
67/** The folders a caller adds to a project. Which repositories sit inside it is the server's to say. */
68export const ProjectAddedFolders = Schema.Array(
69 ProjectTrackedFolder.mapFields(Struct.omit(["discovered"])),
70).check(Schema.isMaxLength(PROJECT_TRACKED_FOLDERS_MAX));
71​
72export const ProjectTrackedFolders = Schema.Array(ProjectTrackedFolder).check(
73 Schema.isMaxLength(PROJECT_TRACKED_FOLDERS_MAX),
74);
75​
76export const ProjectIconColor = Schema.Literals([
77 "gray",
78 "red",
79 "orange",
80 "amber",
81 "yellow",
82 "lime",
83 "green",
84 "emerald",
85 "teal",
86 "cyan",
87 "sky",
88 "blue",
89 "indigo",
90 "violet",
91 "purple",
92 "fuchsia",
93 "pink",
94 "rose",
95]);
96export type ProjectIconColor = typeof ProjectIconColor.Type;
97​
98const ProjectLucideIconName = TrimmedNonEmptyString.check(
99 Schema.isMaxLength(64),
100 Schema.isPattern(/^[a-z0-9]+(?:-[a-z0-9]+)*$/),
101);
102​
103const ProjectEmoji = TrimmedNonEmptyString.check(Schema.isMaxLength(32));
104​
105// Grapheme-count validation belongs to the server command boundary, not snapshot decoding.
106export const ProjectMonogramText = TrimmedNonEmptyString.check(
107 Schema.isMaxLength(32),
108 Schema.isPattern(/^[\p{L}\p{N}][\p{L}\p{N}\p{M}\u200c\u200d]*$/u),
109);
110​
111const ProjectLucideIcon = Schema.Struct({
112 kind: Schema.Literal("lucide"),
113 name: ProjectLucideIconName,
114 color: ProjectIconColor,
115});
116const ProjectEmojiIcon = Schema.Struct({
117 kind: Schema.Literal("emoji"),
118 emoji: ProjectEmoji,
119});
120const ProjectMonogramIcon = Schema.Struct({
121 kind: Schema.Literal("monogram"),
122 text: ProjectMonogramText,
123 color: ProjectIconColor,
124});
125export const ProjectFaviconPath = TrimmedNonEmptyString.check(
126 Schema.isMaxLength(1024),
127 Schema.isPattern(/\.(?:avif|gif|icns|ico|jpe?g|png|svg|webp)$/i),
128);
129export type ProjectFaviconPath = typeof ProjectFaviconPath.Type;
130​
131export const ProjectIconOverride = Schema.Union([
132 ProjectLucideIcon,
133 ProjectEmojiIcon,
134 ProjectMonogramIcon,
135]);
136export type ProjectIconOverride = typeof ProjectIconOverride.Type;
137​
138const ProjectLucideIconWithLegacyMonogram = Schema.Struct({
139 ...ProjectLucideIcon.fields,
140 monogramText: Schema.optional(ProjectMonogramText),
141 monogram: Schema.optional(ProjectMonogramText),
142});
143const projectIconMembers = [
144 ProjectLucideIconWithLegacyMonogram,
145 ProjectEmojiIcon,
146 ProjectMonogramIcon,
147] as const;
148type ProjectIconMember = (typeof projectIconMembers)[number]["Type"];
149​
150const fromLegacyMonogram = (icon: ProjectIconMember): ProjectIconOverride => {
151 if (icon.kind !== "lucide") return icon;
152 const text = icon.monogramText ?? icon.monogram;
153 return text === undefined
154 ? { kind: "lucide", name: icon.name, color: icon.color }
155 : { kind: "monogram", text, color: icon.color };
156};
157​
158export const StoredProjectIcon = Schema.Union(projectIconMembers).pipe(
159 Schema.decodeTo(
160 Schema.toType(ProjectIconOverride),
161 SchemaTransformation.transform<ProjectIconOverride, ProjectIconMember>({
162 decode: fromLegacyMonogram,
163 encode: (icon) => icon,
164 }),
165 ),
166);
167​
168export const ReceivedProjectIcon = ForwardCompatibleUnion(projectIconMembers, "kind").pipe(
169 Schema.decodeTo(
170 Schema.NullOr(Schema.toType(ProjectIconOverride)),
171 SchemaTransformation.transform<
172 ProjectIconOverride | null,
173 ProjectIconMember | UnknownUnionMember<"kind">
174 >({
175 decode: (icon) => (isUnknownUnionMember(icon) ? null : fromLegacyMonogram(icon)),
176 encode: (icon) => icon as ProjectIconMember,
177 }),
178 ),
179);
180​
181export const Project = Schema.Struct({
182 id: ProjectId,
183 title: TrimmedNonEmptyString,
184 workspaceRoot: TrimmedNonEmptyString,
185 repositoryIdentity: Schema.optional(Schema.NullOr(RepositoryIdentity)),
186 faviconPath: Schema.optional(Schema.NullOr(TrimmedNonEmptyString)),
187 projectIcon: Schema.optional(Schema.NullOr(ReceivedProjectIcon)),
188 defaultModelSelection: Schema.NullOr(ModelSelection),
189 defaultThreadEnvMode: Schema.optional(Schema.NullOr(ThreadEnvMode)),
190 // Opt-in because background sync performs network I/O and may move the checkout.
191 autoPull: Schema.optional(Schema.Boolean),
192 scripts: Schema.Array(ProjectScript),
193 // Absent from older servers; that means a single-folder project.
194 trackedFolders: Schema.optional(ProjectTrackedFolders),
195 pinnedAt: Schema.optional(Schema.NullOr(IsoDateTime)),
196 archivedAt: Schema.optional(Schema.NullOr(IsoDateTime)),
197 createdAt: IsoDateTime,
198 updatedAt: IsoDateTime,
199 deletedAt: Schema.NullOr(IsoDateTime),
200});
201export type Project = typeof Project.Type;
202​
203export const ProjectSnapshot = Schema.Struct({
204 projects: Schema.Array(Project),
205 updatedAt: IsoDateTime,
206});
207export type ProjectSnapshot = typeof ProjectSnapshot.Type;
208​
209export const ProjectCreatePayload = Schema.Struct({
210 title: TrimmedNonEmptyString,
211 workspaceRoot: TrimmedNonEmptyString,
212 createWorkspaceRootIfMissing: Schema.optional(Schema.Boolean),
213 defaultModelSelection: Schema.optional(Schema.NullOr(ModelSelection)),
214 scripts: Schema.optional(Schema.Array(ProjectScript)),
215 trackedFolders: Schema.optional(ProjectAddedFolders),
216});
217export type ProjectCreatePayload = typeof ProjectCreatePayload.Type;
218​
219export const ProjectUpdatePayload = Schema.Struct({
220 title: Schema.optional(TrimmedNonEmptyString),
221 workspaceRoot: Schema.optional(TrimmedNonEmptyString),
222 defaultModelSelection: Schema.optional(Schema.NullOr(ModelSelection)),
223 autoPull: Schema.optional(Schema.Boolean),
224 projectIcon: Schema.optional(Schema.NullOr(ProjectIconOverride)),
225 faviconPath: Schema.optional(Schema.NullOr(TrimmedNonEmptyString)),
226 defaultThreadEnvMode: Schema.optional(Schema.NullOr(ThreadEnvMode)),
227 scripts: Schema.optional(Schema.Array(ProjectScript)),
228 trackedFolders: Schema.optional(
229 ProjectAddedFolders.annotate({
230 description: "Extra folders by absolute path. Replaces the whole list.",
231 }),
232 ),
233 pinned: Schema.optional(Schema.Boolean),
234 archived: Schema.optional(
235 Schema.Boolean.annotate({
236 description: "Threads and files are kept.",
237 }),
238 ),
239});
240export type ProjectUpdatePayload = typeof ProjectUpdatePayload.Type;
241​
242export const ProjectMutation = Schema.Union([
243 Schema.Struct({
244 type: Schema.Literal("project.create"),
245 commandId: CommandId,
246 projectId: ProjectId,
247 ...ProjectCreatePayload.fields,
248 }),
249 Schema.Struct({
250 type: Schema.Literal("project.update"),
251 commandId: CommandId,
252 projectId: ProjectId,
253 ...ProjectUpdatePayload.fields,
254 // Applied to the list as the server has it, so two clients' edits do not undo each other.
255 trackFolders: Schema.optional(ProjectAddedFolders),
256 untrackFolders: Schema.optional(Schema.Array(TrimmedNonEmptyString)),
257 }),
258 Schema.Struct({
259 type: Schema.Literal("project.delete"),
260 commandId: CommandId,
261 projectId: ProjectId,
262 force: Schema.optional(Schema.Boolean),
263 }),
264]);
265export type ProjectMutation = typeof ProjectMutation.Type;
266​
267export class ProjectMutationError extends Schema.TaggedError<ProjectMutationError>()(
268 "ProjectMutationError",
269 {
270 commandId: CommandId,
271 message: Schema.String,
272 cause: Schema.optional(Schema.Defect()),
273 },
274) {}
275​
276export const ProjectEntryKind = Schema.Literals(["file", "directory"]);
277export type ProjectEntryKind = typeof ProjectEntryKind.Type;
278​
279export const ProjectSearchEntriesInput = Schema.Struct({
280 cwd: TrimmedNonEmptyString,
281 query: TrimmedString.check(Schema.isMaxLength(256)),
282 limit: PositiveInt.check(Schema.isLessThanOrEqualTo(PROJECT_SEARCH_ENTRIES_MAX_LIMIT)),
283 kind: Schema.optional(ProjectEntryKind),
284 imageOnly: Schema.optional(Schema.Boolean),
285});
286export type ProjectSearchEntriesInput = typeof ProjectSearchEntriesInput.Type;
287​
288export const ProjectEntry = Schema.Struct({
289 path: TrimmedNonEmptyString,
290 kind: ProjectEntryKind,
291 ignored: Schema.optional(Schema.Boolean),
292});
293export type ProjectEntry = typeof ProjectEntry.Type;
294​
295export const ProjectSearchEntriesResult = Schema.Struct({
296 entries: Schema.Array(ProjectEntry),
297 truncated: Schema.Boolean,
298});
299export type ProjectSearchEntriesResult = typeof ProjectSearchEntriesResult.Type;
300​
301export const ProjectSearchContentsInput = Schema.Struct({
302 cwd: TrimmedNonEmptyString,
303 // Preserve whitespace because it is significant in content queries.
304 query: Schema.String.check(
305 Schema.isNonEmpty(),
306 Schema.isMaxLength(PROJECT_SEARCH_CONTENTS_QUERY_MAX_LENGTH),
307 ),
308 limit: PositiveInt.check(Schema.isLessThanOrEqualTo(PROJECT_SEARCH_CONTENTS_MAX_LIMIT)),
309 caseSensitive: Schema.Boolean,
310 wholeWord: Schema.Boolean,
311 useRegex: Schema.Boolean,
312});
313export type ProjectSearchContentsInput = typeof ProjectSearchContentsInput.Type;
314​
315export const ProjectContentMatchRange = Schema.Struct({
316 start: NonNegativeInt,
317 end: NonNegativeInt,
318});
319export type ProjectContentMatchRange = typeof ProjectContentMatchRange.Type;
320​
321export const ProjectContentMatch = Schema.Struct({
322 path: TrimmedNonEmptyString,
323 lineNumber: PositiveInt,
324 lineContent: Schema.String,
325 matchRanges: Schema.Array(ProjectContentMatchRange),
326});
327export type ProjectContentMatch = typeof ProjectContentMatch.Type;
328​
329export const ProjectSearchContentsResult = Schema.Struct({
330 matches: Schema.Array(ProjectContentMatch),
331 truncated: Schema.Boolean,
332 regexFallbackError: Schema.optional(Schema.String),
333});
334export type ProjectSearchContentsResult = typeof ProjectSearchContentsResult.Type;
335​
336export const ProjectListEntriesInput = Schema.Struct({
337 cwd: TrimmedNonEmptyString,
338 directoryPath: Schema.optional(TrimmedString),
339});
340export type ProjectListEntriesInput = typeof ProjectListEntriesInput.Type;
341​
342export const ProjectListEntriesResult = Schema.Struct({
343 entries: Schema.Array(ProjectEntry),
344 truncated: Schema.Boolean,
345});
346export type ProjectListEntriesResult = typeof ProjectListEntriesResult.Type;
347​
348// Untracked files git ignores. Wholly ignored folders such as `node_modules`
349// are left out, so the list stays small enough to pick from.
350export const ProjectListIgnoredFilesInput = Schema.Struct({
351 cwd: TrimmedNonEmptyString,
352 /** Case-insensitive path substring, applied before the listing cap. */
353 query: Schema.optionalKey(TrimmedString.check(Schema.isMaxLength(256))),
354});
355export type ProjectListIgnoredFilesInput = typeof ProjectListIgnoredFilesInput.Type;
356​
357export const ProjectIgnoredFile = Schema.Struct({
358 path: TrimmedNonEmptyString,
359 byteLength: NonNegativeInt,
360});
361export type ProjectIgnoredFile = typeof ProjectIgnoredFile.Type;
362​
363export const ProjectListIgnoredFilesResult = Schema.Struct({
364 files: Schema.Array(ProjectIgnoredFile),
365 truncated: Schema.Boolean,
366});
367export type ProjectListIgnoredFilesResult = typeof ProjectListIgnoredFilesResult.Type;
368​
369export const ProjectEntriesFailure = Schema.Literals([
370 "workspace_root_not_found",
371 "workspace_root_create_failed",
372 "workspace_root_stat_failed",
373 "workspace_root_not_directory",
374 "search_index_create_failed",
375 "search_index_scan_timed_out",
376 "search_index_search_failed",
377 "directory_list_failed",
378]);
379export type ProjectEntriesFailure = typeof ProjectEntriesFailure.Type;
380​
381type ProjectEntriesFailureContext = {
382 readonly failure: ProjectEntriesFailure;
383 readonly normalizedCwd?: string;
384 readonly timeout?: string;
385 readonly detail?: string;
386 readonly cause?: unknown;
387};
388​
389function decodedProjectErrorMessage(props: object): string | undefined {
390 if (!("message" in props)) return undefined;
391 return typeof props.message === "string" ? props.message : undefined;
393​
394export class ProjectSearchEntriesError extends Schema.TaggedError<ProjectSearchEntriesError>()(
395 "ProjectSearchEntriesError",
396 {
397 cwd: Schema.optional(TrimmedNonEmptyString),
398 queryLength: Schema.optional(NonNegativeInt),
399 limit: Schema.optional(PositiveInt),
400 failure: Schema.optional(ProjectEntriesFailure),
401 normalizedCwd: Schema.optional(TrimmedNonEmptyString),
402 timeout: Schema.optional(TrimmedNonEmptyString),
403 detail: Schema.optional(TrimmedNonEmptyString),
404 message: TrimmedNonEmptyString,
405 cause: Schema.optional(Schema.Defect()),
406 },
407) {
408 // @effect-diagnostics-next-line overriddenSchemaConstructor:off
409 constructor(
410 props: ProjectEntriesFailureContext & {
411 readonly cwd: string;
412 readonly queryLength: number;
413 readonly limit: number;
414 },
415 ) {
416 super({
417 ...props,
418 message:
419 decodedProjectErrorMessage(props) ??
420 `Failed to search workspace entries in '${props.cwd}'.`,
421 } as any);
422 }
424​
425export class ProjectSearchContentsError extends Schema.TaggedError<ProjectSearchContentsError>()(
426 "ProjectSearchContentsError",
427 {
428 cwd: Schema.optional(TrimmedNonEmptyString),
429 queryLength: Schema.optional(NonNegativeInt),
430 limit: Schema.optional(PositiveInt),
431 failure: Schema.optional(ProjectEntriesFailure),
432 normalizedCwd: Schema.optional(TrimmedNonEmptyString),
433 timeout: Schema.optional(TrimmedNonEmptyString),
434 detail: Schema.optional(TrimmedNonEmptyString),
435 message: TrimmedNonEmptyString,
436 cause: Schema.optional(Schema.Defect()),
437 },
438) {
439 // @effect-diagnostics-next-line overriddenSchemaConstructor:off
440 constructor(
441 props: ProjectEntriesFailureContext & {
442 readonly cwd: string;
443 readonly queryLength: number;
444 readonly limit: number;
445 },
446 ) {
447 super({
448 ...props,
449 message:
450 decodedProjectErrorMessage(props) ??
451 `Failed to search workspace contents in '${props.cwd}'.`,
452 } as any);
453 }
455​
456export class ProjectListEntriesError extends Schema.TaggedError<ProjectListEntriesError>()(
457 "ProjectListEntriesError",
458 {
459 cwd: Schema.optional(TrimmedNonEmptyString),
460 failure: Schema.optional(ProjectEntriesFailure),
461 normalizedCwd: Schema.optional(TrimmedNonEmptyString),
462 timeout: Schema.optional(TrimmedNonEmptyString),
463 detail: Schema.optional(TrimmedNonEmptyString),
464 message: TrimmedNonEmptyString,
465 cause: Schema.optional(Schema.Defect()),
466 },
467) {
468 // @effect-diagnostics-next-line overriddenSchemaConstructor:off
469 constructor(props: ProjectEntriesFailureContext & { readonly cwd: string }) {
470 super({
471 ...props,
472 message:
473 decodedProjectErrorMessage(props) ?? `Failed to list workspace entries in '${props.cwd}'.`,
474 } as any);
475 }
477​
478export const ProjectReadFileInput = Schema.Struct({
479 cwd: TrimmedNonEmptyString,
480 // Workspace-relative or absolute host path; only workspace-relative paths are writable.
481 relativePath: Schema.NonEmptyString.check(Schema.isMaxLength(PROJECT_READ_FILE_PATH_MAX_LENGTH)),
482 // Optional files can be absent without failing the read.
483 allowMissing: Schema.optional(Schema.Boolean),
484});
485export type ProjectReadFileInput = typeof ProjectReadFileInput.Type;
486​
487export const ProjectReadFileResult = Schema.Struct({
488 relativePath: Schema.NonEmptyString,
489 contents: Schema.String,
490 byteLength: NonNegativeInt,
491 truncated: Schema.Boolean,
492 // Omitted by older servers; false only for an absent optional file.
493 exists: Schema.optional(Schema.Boolean),
494});
495export type ProjectReadFileResult = typeof ProjectReadFileResult.Type;
496​
497export const ProjectFileFailure = Schema.Literals([
498 "workspace_path_outside_root",
499 "resolved_path_outside_root",
500 "path_not_file",
501 "binary_file",
502 "operation_failed",
503]);
504export type ProjectFileFailure = typeof ProjectFileFailure.Type;
505​
506export const ProjectFileOperation = Schema.Literals([
507 "realpath-workspace-root",
508 "realpath-target",
509 "open",
510 "stat",
511 "read",
512 "close",
513 "make-directory",
514 "write-file",
515]);
516export type ProjectFileOperation = typeof ProjectFileOperation.Type;
517​
518type ProjectFileFailureContext = {
519 readonly cwd: string;
520 readonly relativePath: string;
521 readonly failure: ProjectFileFailure;
522 readonly resolvedPath?: string;
523 readonly resolvedWorkspaceRoot?: string;
524 readonly operation?: ProjectFileOperation;
525 readonly operationPath?: string;
526 readonly cause?: unknown;
527};
528​
529export class ProjectReadFileError extends Schema.TaggedError<ProjectReadFileError>()(
530 "ProjectReadFileError",
531 {
532 cwd: Schema.optional(TrimmedNonEmptyString),
533 relativePath: Schema.optional(Schema.NonEmptyString),
534 failure: Schema.optional(ProjectFileFailure),
535 resolvedPath: Schema.optional(Schema.NonEmptyString),
536 resolvedWorkspaceRoot: Schema.optional(TrimmedNonEmptyString),
537 operation: Schema.optional(ProjectFileOperation),
538 operationPath: Schema.optional(Schema.NonEmptyString),
539 message: TrimmedNonEmptyString,
540 cause: Schema.optional(Schema.Defect()),
541 },
542) {
543 // @effect-diagnostics-next-line overriddenSchemaConstructor:off
544 constructor(props: ProjectFileFailureContext) {
545 super({
546 ...props,
547 message:
548 decodedProjectErrorMessage(props) ??
549 `Failed to read workspace file '${props.relativePath}' in '${props.cwd}'.`,
550 } as any);
551 }
553​
554export const ProjectWriteFileInput = Schema.Struct({
555 cwd: TrimmedNonEmptyString,
556 relativePath: Schema.NonEmptyString.check(Schema.isMaxLength(PROJECT_WRITE_FILE_PATH_MAX_LENGTH)),
557 contents: Schema.String,
558});
559export type ProjectWriteFileInput = typeof ProjectWriteFileInput.Type;
560​
561export const ProjectWriteFileResult = Schema.Struct({
562 relativePath: Schema.NonEmptyString,
563});
564export type ProjectWriteFileResult = typeof ProjectWriteFileResult.Type;
565​
566export const ProjectEnsureScratchResult = Schema.Struct({
567 projectId: ProjectId,
568});
569export type ProjectEnsureScratchResult = typeof ProjectEnsureScratchResult.Type;
570​
571export const ProjectCreateNewInput = Schema.Struct({
572 name: TrimmedNonEmptyString.check(Schema.isMaxLength(200)),
573});
574export type ProjectCreateNewInput = typeof ProjectCreateNewInput.Type;
575​
576export const ProjectCreateNewResult = Schema.Struct({
577 projectId: ProjectId,
578 workspaceRoot: TrimmedNonEmptyString,
579 /** The project and its files exist either way. */
580 commitError: Schema.optionalKey(TrimmedNonEmptyString),
581});
582export type ProjectCreateNewResult = typeof ProjectCreateNewResult.Type;
583​
584export const ProjectCreateFromThreadInput = Schema.Struct({
585 threadId: ThreadId,
586});
587export type ProjectCreateFromThreadInput = typeof ProjectCreateFromThreadInput.Type;
588​
589export const ProjectCreateFromThreadResult = Schema.Struct({
590 projectId: ProjectId,
591});
592export type ProjectCreateFromThreadResult = typeof ProjectCreateFromThreadResult.Type;
593​
594export class ProjectWriteFileError extends Schema.TaggedError<ProjectWriteFileError>()(
595 "ProjectWriteFileError",
596 {
597 cwd: Schema.optional(TrimmedNonEmptyString),
598 relativePath: Schema.optional(Schema.NonEmptyString),
599 failure: Schema.optional(ProjectFileFailure),
600 resolvedPath: Schema.optional(Schema.NonEmptyString),
601 resolvedWorkspaceRoot: Schema.optional(TrimmedNonEmptyString),
602 operation: Schema.optional(ProjectFileOperation),
603 operationPath: Schema.optional(Schema.NonEmptyString),
604 message: TrimmedNonEmptyString,
605 cause: Schema.optional(Schema.Defect()),
606 },
607) {
608 // @effect-diagnostics-next-line overriddenSchemaConstructor:off
609 constructor(props: ProjectFileFailureContext) {
610 super({
611 ...props,
612 message:
613 decodedProjectErrorMessage(props) ??
614 `Failed to write workspace file '${props.relativePath}' in '${props.cwd}'.`,
615 } as any);
616 }