Open History to see the last commit
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 NonBlankString,
12 NonNegativeInt,
13 PositiveInt,
14 ProjectId,
15 ThreadId,
16 TrimmedNonEmptyString,
17 TrimmedString,
18 type UnknownUnionMember,
19} from "./baseSchemas.ts";
20
21const PROJECT_SEARCH_ENTRIES_MAX_LIMIT = 200;
22const PROJECT_SEARCH_CONTENTS_MAX_LIMIT = 500;
23export const PROJECT_SEARCH_CONTENTS_QUERY_MAX_LENGTH = 256;
24const PROJECT_FILE_PATH_MAX_LENGTH = 4096;
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: NonBlankString,
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(NonBlankString)),
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
288// Paths keep the spaces a file name has, as in the file read and write results.
289export const ProjectEntry = Schema.Struct({
290 path: Schema.NonEmptyString,
291 kind: ProjectEntryKind,
292 ignored: Schema.optional(Schema.Boolean),
293});
294export type ProjectEntry = typeof ProjectEntry.Type;
295
296export const ProjectSearchEntriesResult = Schema.Struct({
297 entries: Schema.Array(ProjectEntry),
298 truncated: Schema.Boolean,
299});
300export type ProjectSearchEntriesResult = typeof ProjectSearchEntriesResult.Type;
301
302export const ProjectSearchContentsInput = Schema.Struct({
303 cwd: TrimmedNonEmptyString,
304 // Preserve whitespace because it is significant in content queries.
305 query: Schema.String.check(
306 Schema.isNonEmpty(),
307 Schema.isMaxLength(PROJECT_SEARCH_CONTENTS_QUERY_MAX_LENGTH),
308 ),
309 limit: PositiveInt.check(Schema.isLessThanOrEqualTo(PROJECT_SEARCH_CONTENTS_MAX_LIMIT)),
310 caseSensitive: Schema.Boolean,
311 wholeWord: Schema.Boolean,
312 useRegex: Schema.Boolean,
313});
314export type ProjectSearchContentsInput = typeof ProjectSearchContentsInput.Type;
315
316export const ProjectContentMatchRange = Schema.Struct({
317 start: NonNegativeInt,
318 end: NonNegativeInt,
319});
320export type ProjectContentMatchRange = typeof ProjectContentMatchRange.Type;
321
322export const ProjectContentMatch = Schema.Struct({
323 path: Schema.NonEmptyString,
324 lineNumber: PositiveInt,
325 lineContent: Schema.String,
326 matchRanges: Schema.Array(ProjectContentMatchRange),
327});
328export type ProjectContentMatch = typeof ProjectContentMatch.Type;
329
330export const ProjectSearchContentsResult = Schema.Struct({
331 matches: Schema.Array(ProjectContentMatch),
332 truncated: Schema.Boolean,
333 regexFallbackError: Schema.optional(Schema.String),
334});
335export type ProjectSearchContentsResult = typeof ProjectSearchContentsResult.Type;
336
337export const ProjectListEntriesInput = Schema.Struct({
338 cwd: TrimmedNonEmptyString,
339 directoryPath: Schema.optional(Schema.String),
340});
341export type ProjectListEntriesInput = typeof ProjectListEntriesInput.Type;
342
343export const ProjectListEntriesResult = Schema.Struct({
344 entries: Schema.Array(ProjectEntry),
345 truncated: Schema.Boolean,
346});
347export type ProjectListEntriesResult = typeof ProjectListEntriesResult.Type;
348
349// Untracked files git ignores. Wholly ignored folders such as `node_modules`
350// are left out, so the list stays small enough to pick from.
351export const ProjectListIgnoredFilesInput = Schema.Struct({
352 cwd: TrimmedNonEmptyString,
353 /** Case-insensitive path substring, applied before the listing cap. */
354 query: Schema.optionalKey(TrimmedString.check(Schema.isMaxLength(256))),
355});
356export type ProjectListIgnoredFilesInput = typeof ProjectListIgnoredFilesInput.Type;
357
358export const ProjectIgnoredFile = Schema.Struct({
359 path: Schema.NonEmptyString,
360 byteLength: NonNegativeInt,
361});
362export type ProjectIgnoredFile = typeof ProjectIgnoredFile.Type;
363
364export const ProjectListIgnoredFilesResult = Schema.Struct({
365 files: Schema.Array(ProjectIgnoredFile),
366 truncated: Schema.Boolean,
367});
368export type ProjectListIgnoredFilesResult = typeof ProjectListIgnoredFilesResult.Type;
369
370export const ProjectEntriesFailure = Schema.Literals([
371 "workspace_root_not_found",
372 "workspace_root_create_failed",
373 "workspace_root_stat_failed",
374 "workspace_root_not_directory",
375 "search_index_create_failed",
376 "search_index_scan_timed_out",
377 "search_index_search_failed",
378 "directory_list_failed",
379]);
380export type ProjectEntriesFailure = typeof ProjectEntriesFailure.Type;
381
382type ProjectEntriesFailureContext = {
383 readonly failure: ProjectEntriesFailure;
384 readonly normalizedCwd?: string;
385 readonly timeout?: string;
386 readonly detail?: string;
387 readonly cause?: unknown;
388};
389
390function decodedProjectErrorMessage(props: object): string | undefined {
391 if (!("message" in props)) return undefined;
392 return typeof props.message === "string" ? props.message : undefined;
393}
394
395export class ProjectSearchEntriesError extends Schema.TaggedError<ProjectSearchEntriesError>()(
396 "ProjectSearchEntriesError",
397 {
398 cwd: Schema.optional(TrimmedNonEmptyString),
399 queryLength: Schema.optional(NonNegativeInt),
400 limit: Schema.optional(PositiveInt),
401 failure: Schema.optional(ProjectEntriesFailure),
402 normalizedCwd: Schema.optional(TrimmedNonEmptyString),
403 timeout: Schema.optional(TrimmedNonEmptyString),
404 detail: Schema.optional(TrimmedNonEmptyString),
405 message: TrimmedNonEmptyString,
406 cause: Schema.optional(Schema.Defect()),
407 },
408) {
409 // @effect-diagnostics-next-line overriddenSchemaConstructor:off
410 constructor(
411 props: ProjectEntriesFailureContext & {
412 readonly cwd: string;
413 readonly queryLength: number;
414 readonly limit: number;
415 },
416 ) {
417 super({
418 ...props,
419 message:
420 decodedProjectErrorMessage(props) ??
421 `Failed to search workspace entries in '${props.cwd}'.`,
422 } as any);
423 }
424}
425
426export class ProjectSearchContentsError extends Schema.TaggedError<ProjectSearchContentsError>()(
427 "ProjectSearchContentsError",
428 {
429 cwd: Schema.optional(TrimmedNonEmptyString),
430 queryLength: Schema.optional(NonNegativeInt),
431 limit: Schema.optional(PositiveInt),
432 failure: Schema.optional(ProjectEntriesFailure),
433 normalizedCwd: Schema.optional(TrimmedNonEmptyString),
434 timeout: Schema.optional(TrimmedNonEmptyString),
435 detail: Schema.optional(TrimmedNonEmptyString),
436 message: TrimmedNonEmptyString,
437 cause: Schema.optional(Schema.Defect()),
438 },
439) {
440 // @effect-diagnostics-next-line overriddenSchemaConstructor:off
441 constructor(
442 props: ProjectEntriesFailureContext & {
443 readonly cwd: string;
444 readonly queryLength: number;
445 readonly limit: number;
446 },
447 ) {
448 super({
449 ...props,
450 message:
451 decodedProjectErrorMessage(props) ??
452 `Failed to search workspace contents in '${props.cwd}'.`,
453 } as any);
454 }
455}
456
457export class ProjectListEntriesError extends Schema.TaggedError<ProjectListEntriesError>()(
458 "ProjectListEntriesError",
459 {
460 cwd: Schema.optional(TrimmedNonEmptyString),
461 failure: Schema.optional(ProjectEntriesFailure),
462 normalizedCwd: Schema.optional(TrimmedNonEmptyString),
463 timeout: Schema.optional(TrimmedNonEmptyString),
464 detail: Schema.optional(TrimmedNonEmptyString),
465 message: TrimmedNonEmptyString,
466 cause: Schema.optional(Schema.Defect()),
467 },
468) {
469 // @effect-diagnostics-next-line overriddenSchemaConstructor:off
470 constructor(props: ProjectEntriesFailureContext & { readonly cwd: string }) {
471 super({
472 ...props,
473 message:
474 decodedProjectErrorMessage(props) ?? `Failed to list workspace entries in '${props.cwd}'.`,
475 } as any);
476 }
477}
478
479export const ProjectReadFileInput = Schema.Struct({
480 cwd: TrimmedNonEmptyString,
481 // Workspace-relative or absolute host path; only workspace-relative paths are writable.
482 relativePath: Schema.NonEmptyString.check(Schema.isMaxLength(PROJECT_FILE_PATH_MAX_LENGTH)),
483 // Optional files can be absent without failing the read.
484 allowMissing: Schema.optional(Schema.Boolean),
485});
486export type ProjectReadFileInput = typeof ProjectReadFileInput.Type;
487
488export const ProjectReadFileResult = Schema.Struct({
489 relativePath: Schema.NonEmptyString,
490 contents: Schema.String,
491 byteLength: NonNegativeInt,
492 truncated: Schema.Boolean,
493 // Omitted by older servers; false only for an absent optional file.
494 exists: Schema.optional(Schema.Boolean),
495 // True when a link takes a workspace path outside the root, where writes are refused.
496 readOnly: Schema.optional(Schema.Boolean),
497});
498export type ProjectReadFileResult = typeof ProjectReadFileResult.Type;
499
500export const ProjectFileFailure = Schema.Literals([
501 "workspace_path_outside_root",
502 "resolved_path_outside_root",
503 "path_not_file",
504 "binary_file",
505 "operation_failed",
506]);
507export type ProjectFileFailure = typeof ProjectFileFailure.Type;
508
509export const ProjectFileOperation = Schema.Literals([
510 "realpath-workspace-root",
511 "realpath-target",
512 "open",
513 "stat",
514 "read",
515 "close",
516 "make-directory",
517 "write-file",
518]);
519export type ProjectFileOperation = typeof ProjectFileOperation.Type;
520
521type ProjectFileFailureContext = {
522 readonly cwd: string;
523 readonly relativePath: string;
524 readonly failure: ProjectFileFailure;
525 readonly resolvedPath?: string;
526 readonly resolvedWorkspaceRoot?: string;
527 readonly operation?: ProjectFileOperation;
528 readonly operationPath?: string;
529 readonly cause?: unknown;
530};
531
532export class ProjectReadFileError extends Schema.TaggedError<ProjectReadFileError>()(
533 "ProjectReadFileError",
534 {
535 cwd: Schema.optional(TrimmedNonEmptyString),
536 relativePath: Schema.optional(Schema.NonEmptyString),
537 failure: Schema.optional(ProjectFileFailure),
538 resolvedPath: Schema.optional(Schema.NonEmptyString),
539 resolvedWorkspaceRoot: Schema.optional(TrimmedNonEmptyString),
540 operation: Schema.optional(ProjectFileOperation),
541 operationPath: Schema.optional(Schema.NonEmptyString),
542 message: TrimmedNonEmptyString,
543 cause: Schema.optional(Schema.Defect()),
544 },
545) {
546 // @effect-diagnostics-next-line overriddenSchemaConstructor:off
547 constructor(props: ProjectFileFailureContext) {
548 super({
549 ...props,
550 message:
551 decodedProjectErrorMessage(props) ??
552 `Failed to read workspace file '${props.relativePath}' in '${props.cwd}'.`,
553 } as any);
554 }
555}
556
557export const ProjectWriteFileInput = Schema.Struct({
558 cwd: TrimmedNonEmptyString,
559 relativePath: Schema.NonEmptyString.check(Schema.isMaxLength(PROJECT_FILE_PATH_MAX_LENGTH)),
560 contents: Schema.String,
561});
562export type ProjectWriteFileInput = typeof ProjectWriteFileInput.Type;
563
564export const ProjectWriteFileResult = Schema.Struct({
565 relativePath: Schema.NonEmptyString,
566});
567export type ProjectWriteFileResult = typeof ProjectWriteFileResult.Type;
568
569export const ProjectEnsureScratchResult = Schema.Struct({
570 projectId: ProjectId,
571});
572export type ProjectEnsureScratchResult = typeof ProjectEnsureScratchResult.Type;
573
574export const ProjectCreateNewInput = Schema.Struct({
575 name: TrimmedNonEmptyString.check(Schema.isMaxLength(200)),
576});
577export type ProjectCreateNewInput = typeof ProjectCreateNewInput.Type;
578
579export const ProjectCreateNewResult = Schema.Struct({
580 projectId: ProjectId,
581 workspaceRoot: TrimmedNonEmptyString,
582 /** The project and its files exist either way. */
583 commitError: Schema.optionalKey(TrimmedNonEmptyString),
584});
585export type ProjectCreateNewResult = typeof ProjectCreateNewResult.Type;
586
587export const ProjectCreateFromThreadInput = Schema.Struct({
588 threadId: ThreadId,
589});
590export type ProjectCreateFromThreadInput = typeof ProjectCreateFromThreadInput.Type;
591
592export const ProjectCreateFromThreadResult = Schema.Struct({
593 projectId: ProjectId,
594});
595export type ProjectCreateFromThreadResult = typeof ProjectCreateFromThreadResult.Type;
596
597export class ProjectWriteFileError extends Schema.TaggedError<ProjectWriteFileError>()(
598 "ProjectWriteFileError",
599 {
600 cwd: Schema.optional(TrimmedNonEmptyString),
601 relativePath: Schema.optional(Schema.NonEmptyString),
602 failure: Schema.optional(ProjectFileFailure),
603 resolvedPath: Schema.optional(Schema.NonEmptyString),
604 resolvedWorkspaceRoot: Schema.optional(TrimmedNonEmptyString),
605 operation: Schema.optional(ProjectFileOperation),
606 operationPath: Schema.optional(Schema.NonEmptyString),
607 message: TrimmedNonEmptyString,
608 cause: Schema.optional(Schema.Defect()),
609 },
610) {
611 // @effect-diagnostics-next-line overriddenSchemaConstructor:off
612 constructor(props: ProjectFileFailureContext) {
613 super({
614 ...props,
615 message:
616 decodedProjectErrorMessage(props) ??
617 `Failed to write workspace file '${props.relativePath}' in '${props.cwd}'.`,
618 } as any);
619 }
620}