@orkestrel/workspace 0.0.13 → 0.0.14

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.
@@ -124,10 +124,10 @@ function inferLanguage(path) {
124
124
  *
125
125
  * @example
126
126
  * ```ts
127
- * isText({ text: 'hello', language: 'text' }) // true
127
+ * isTextContent({ text: 'hello', language: 'text' }) // true
128
128
  * ```
129
129
  */
130
- function isText(content) {
130
+ function isTextContent(content) {
131
131
  return "text" in content;
132
132
  }
133
133
  /**
@@ -156,7 +156,7 @@ function isBinary(content) {
156
156
  * ```
157
157
  */
158
158
  function computeSize(content) {
159
- if (isText(content)) return new TextEncoder().encode(content.text).length;
159
+ if (isTextContent(content)) return new TextEncoder().encode(content.text).length;
160
160
  return computeDecodedSize(content.base64);
161
161
  }
162
162
  /**
@@ -171,7 +171,7 @@ function computeSize(content) {
171
171
  * ```
172
172
  */
173
173
  function countLines(content) {
174
- if (!isText(content)) return 0;
174
+ if (!isTextContent(content)) return 0;
175
175
  if (content.text.length === 0) return 0;
176
176
  return content.text.split(/\r\n|\n/).length;
177
177
  }
@@ -194,7 +194,7 @@ function computeDecodedSize(base64) {
194
194
  * Determines whether a 1-based range is structurally valid.
195
195
  *
196
196
  * @param range - The range to inspect
197
- * @returns True if both positions are positive and ordered; false otherwise
197
+ * @returns True if both carets are positive and ordered; false otherwise
198
198
  *
199
199
  * @example
200
200
  * ```ts
@@ -208,28 +208,28 @@ function isValidRange(range) {
208
208
  return !(range.start.line === range.end.line && range.start.column > range.end.column);
209
209
  }
210
210
  /**
211
- * Clamps a position to text bounds.
211
+ * Clamps a caret to text bounds.
212
212
  *
213
213
  * @param text - The addressed text
214
- * @param position - The requested position
215
- * @returns The clamped position
214
+ * @param caret - The requested caret
215
+ * @returns The clamped caret
216
216
  *
217
217
  * @example
218
218
  * ```ts
219
- * clampPosition('ab', { line: 9, column: 9 }) // { line: 1, column: 3 }
219
+ * clampCaret('ab', { line: 9, column: 9 }) // { line: 1, column: 3 }
220
220
  * ```
221
221
  */
222
- function clampPosition(text, position) {
222
+ function clampCaret(text, caret) {
223
223
  const lines = text.split("\n");
224
- const line = Math.max(1, Math.min(position.line, lines.length));
224
+ const line = Math.max(1, Math.min(caret.line, lines.length));
225
225
  const lineText = lines[line - 1] ?? "";
226
226
  return {
227
227
  line,
228
- column: Math.max(1, Math.min(position.column, lineText.length + 1))
228
+ column: Math.max(1, Math.min(caret.column, lineText.length + 1))
229
229
  };
230
230
  }
231
231
  /**
232
- * Clamps both positions in a range to text bounds.
232
+ * Clamps both carets in a range to text bounds.
233
233
  *
234
234
  * @param text - The addressed text
235
235
  * @param range - The requested range
@@ -242,15 +242,15 @@ function clampPosition(text, position) {
242
242
  */
243
243
  function clampRange(text, range) {
244
244
  return {
245
- start: clampPosition(text, range.start),
246
- end: clampPosition(text, range.end)
245
+ start: clampCaret(text, range.start),
246
+ end: clampCaret(text, range.end)
247
247
  };
248
248
  }
249
249
  /**
250
- * Converts a 1-based position to a zero-based string offset.
250
+ * Converts a 1-based caret to a zero-based string offset.
251
251
  *
252
252
  * @param text - The addressed text
253
- * @param position - The requested position
253
+ * @param caret - The requested caret
254
254
  * @returns The bounded string offset
255
255
  *
256
256
  * @example
@@ -258,9 +258,9 @@ function clampRange(text, range) {
258
258
  * offsetAt('ab\ncd', { line: 2, column: 1 }) // 3
259
259
  * ```
260
260
  */
261
- function offsetAt(text, position) {
262
- const offset = text.split("\n").filter((_, index) => index < position.line - 1).reduce((total, line) => total + line.length + 1, 0);
263
- return Math.min(offset + (position.column - 1), text.length);
261
+ function offsetAt(text, caret) {
262
+ const offset = text.split("\n").filter((_, index) => index < caret.line - 1).reduce((total, line) => total + line.length + 1, 0);
263
+ return Math.min(offset + (caret.column - 1), text.length);
264
264
  }
265
265
  /**
266
266
  * Slices a clamped half-open text range.
@@ -323,20 +323,6 @@ function rangeOf(fromLine, fromColumn, toLine, toColumn) {
323
323
  }
324
324
  };
325
325
  }
326
- /**
327
- * Escapes regular-expression metacharacters for literal matching.
328
- *
329
- * @param value - The literal text
330
- * @returns The escaped regular-expression source
331
- *
332
- * @example
333
- * ```ts
334
- * escapeRegExp('a.b') // 'a\\.b'
335
- * ```
336
- */
337
- function escapeRegExp(value) {
338
- return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
339
- }
340
326
  // src/core/validators.ts
341
327
  /**
342
328
  * Narrows an unknown value to an immutable file record.
@@ -430,14 +416,14 @@ var Workspace = class {
430
416
  const result = {};
431
417
  for (const one of path) {
432
418
  const file = this.#files.get(one);
433
- if (file && isText(file.content)) result[one] = file.content.text;
419
+ if (file && isTextContent(file.content)) result[one] = file.content.text;
434
420
  }
435
421
  return result;
436
422
  }
437
423
  const file = this.#files.get(path);
438
424
  if (!file) return void 0;
439
- if (!range) return isText(file.content) ? file.content.text : void 0;
440
- if (!isText(file.content)) throw new WorkspaceError("MODALITY", `Cannot read a range of a binary file: ${path}`, { path });
425
+ if (!range) return isTextContent(file.content) ? file.content.text : void 0;
426
+ if (!isTextContent(file.content)) throw new WorkspaceError("MODALITY", `Cannot read a range of a binary file: ${path}`, { path });
441
427
  return {
442
428
  content: sliceRange(file.content.text, range),
443
429
  range: clampRange(file.content.text, range)
@@ -453,7 +439,7 @@ var Workspace = class {
453
439
  const matches = [];
454
440
  for (const file of this.#files.values()) {
455
441
  if (limit !== void 0 && matches.length >= limit) break;
456
- if (!isText(file.content)) continue;
442
+ if (!isTextContent(file.content)) continue;
457
443
  const lines = file.content.text.split(/\r\n|\n/);
458
444
  for (const [index, lineText] of lines.entries()) {
459
445
  if (limit !== void 0 && matches.length >= limit) break;
@@ -479,7 +465,7 @@ var Workspace = class {
479
465
  for (const [path, file] of this.#files) {
480
466
  const occurrences = changes.reduce((total, count) => total + count, 0);
481
467
  if (limit !== void 0 && occurrences >= limit) break;
482
- if (!isText(file.content)) continue;
468
+ if (!isTextContent(file.content)) continue;
483
469
  const remaining = limit === void 0 ? void 0 : limit - occurrences;
484
470
  pattern.lastIndex = 0;
485
471
  const text = file.content.text;
@@ -553,7 +539,7 @@ var Workspace = class {
553
539
  path,
554
540
  content: {
555
541
  text: content,
556
- language: existing && isText(existing.content) ? existing.content.language : inferLanguage(path)
542
+ language: existing && isTextContent(existing.content) ? existing.content.language : inferLanguage(path)
557
543
  },
558
544
  state: existing ? "modified" : "created"
559
545
  });
@@ -563,7 +549,7 @@ var Workspace = class {
563
549
  #splice(path, content, range) {
564
550
  const existing = this.#files.get(path);
565
551
  if (!existing) throw new WorkspaceError("MISSING", `Cannot splice a range of a missing file: ${path}`, { path });
566
- if (!isText(existing.content)) throw new WorkspaceError("MODALITY", `Cannot splice a range of a binary file: ${path}`, { path });
552
+ if (!isTextContent(existing.content)) throw new WorkspaceError("MODALITY", `Cannot splice a range of a binary file: ${path}`, { path });
567
553
  if (!isValidRange(range)) throw new WorkspaceError("RANGE", `Invalid range for file: ${path}`, {
568
554
  path,
569
555
  range
@@ -585,7 +571,7 @@ var Workspace = class {
585
571
  this.#write(path, content);
586
572
  return;
587
573
  }
588
- if (!isText(existing.content)) throw new WorkspaceError("MODALITY", `Cannot prepend text to a binary file: ${path}`, { path });
574
+ if (!isTextContent(existing.content)) throw new WorkspaceError("MODALITY", `Cannot prepend text to a binary file: ${path}`, { path });
589
575
  this.#write(path, content + existing.content.text);
590
576
  }
591
577
  #append(path, content) {
@@ -594,7 +580,7 @@ var Workspace = class {
594
580
  this.#write(path, content);
595
581
  return;
596
582
  }
597
- if (!isText(existing.content)) throw new WorkspaceError("MODALITY", `Cannot append text to a binary file: ${path}`, { path });
583
+ if (!isTextContent(existing.content)) throw new WorkspaceError("MODALITY", `Cannot append text to a binary file: ${path}`, { path });
598
584
  this.#write(path, existing.content.text + content);
599
585
  }
600
586
  #move(from, to) {
@@ -619,7 +605,7 @@ var Workspace = class {
619
605
  return removed;
620
606
  }
621
607
  #pattern(query, options) {
622
- const source = options?.regex === true ? query : escapeRegExp(query);
608
+ const source = options?.regex === true ? query : (0, _orkestrel_contract.escapeRegExp)(query);
623
609
  const flags = options?.sensitive === false ? "gi" : "g";
624
610
  try {
625
611
  return new RegExp(source, flags);
@@ -818,7 +804,7 @@ var MemoryWorkspaceStore = class {
818
804
  * createTextContent,
819
805
  * inferLanguage,
820
806
  * isBinary,
821
- * isText,
807
+ * isTextContent,
822
808
  * } from '@orkestrel/workspace'
823
809
  *
824
810
  * const note = createFile({
@@ -829,7 +815,7 @@ var MemoryWorkspaceStore = class {
829
815
  * note.size // 12 — UTF-8 bytes, through computeSize
830
816
  * note.lines // 2 — through countLines
831
817
  * note.state // 'created'
832
- * isText(note.content) // true
818
+ * isTextContent(note.content) // true
833
819
  *
834
820
  * const icon = createFile({ path: 'icon.png', content: createBinaryContent('AAAA', 'image/png') })
835
821
  * isBinary(icon.content) // true
@@ -966,7 +952,7 @@ exports.MemoryWorkspaceStore = MemoryWorkspaceStore;
966
952
  exports.Workspace = Workspace;
967
953
  exports.WorkspaceError = WorkspaceError;
968
954
  exports.WorkspaceManager = WorkspaceManager;
969
- exports.clampPosition = clampPosition;
955
+ exports.clampCaret = clampCaret;
970
956
  exports.clampRange = clampRange;
971
957
  exports.computeDecodedSize = computeDecodedSize;
972
958
  exports.computeSize = computeSize;
@@ -978,11 +964,10 @@ exports.createMemoryWorkspaceStore = createMemoryWorkspaceStore;
978
964
  exports.createTextContent = createTextContent;
979
965
  exports.createWorkspace = createWorkspace;
980
966
  exports.createWorkspaceManager = createWorkspaceManager;
981
- exports.escapeRegExp = escapeRegExp;
982
967
  exports.inferLanguage = inferLanguage;
983
968
  exports.isBinary = isBinary;
984
969
  exports.isFile = isFile;
985
- exports.isText = isText;
970
+ exports.isTextContent = isTextContent;
986
971
  exports.isValidRange = isValidRange;
987
972
  exports.isWorkspaceError = isWorkspaceError;
988
973
  exports.isWorkspaceSnapshot = isWorkspaceSnapshot;
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["holds","INTRINSICS","isObject","isFunction","holds","isRecord","isString","literalOf","isNumber","arrayOf","Emitter","isArray","isRecord","isArray","createMemoryDriver","stringShape","rawShape","createDatabase"],"sources":["../../../src/core/constants.ts","../../../src/core/errors.ts","../../../src/core/helpers.ts","../../../src/core/validators.ts","../../../src/core/workspaces/Workspace.ts","../../../src/core/workspaces/WorkspaceManager.ts","../../../src/core/workspaces/stores/DatabaseWorkspaceStore.ts","../../../src/core/workspaces/stores/MemoryWorkspaceStore.ts","../../../src/core/factories.ts"],"sourcesContent":["/**\n * Maps file extensions to language tags for text content.\n *\n * The table is frozen, and an extension it does not list falls back to `text` in\n * {@link import('./helpers.js').inferLanguage}.\n */\nexport const EXTENSION_LANGUAGES: Readonly<Record<string, string>> = Object.freeze({\n\tts: 'typescript',\n\ttsx: 'typescript',\n\tjs: 'javascript',\n\tjsx: 'javascript',\n\tmjs: 'javascript',\n\tcjs: 'javascript',\n\tjson: 'json',\n\tmd: 'markdown',\n\thtml: 'html',\n\thtm: 'html',\n\tcss: 'css',\n\tscss: 'scss',\n\tsass: 'sass',\n\tless: 'less',\n\tvue: 'vue',\n\tsvelte: 'svelte',\n\tpy: 'python',\n\trb: 'ruby',\n\trs: 'rust',\n\tgo: 'go',\n\tjava: 'java',\n\tkt: 'kotlin',\n\tswift: 'swift',\n\tc: 'c',\n\tcpp: 'cpp',\n\th: 'c',\n\thpp: 'cpp',\n\tcs: 'csharp',\n\tphp: 'php',\n\tsql: 'sql',\n\tsh: 'bash',\n\tbash: 'bash',\n\tzsh: 'bash',\n\tps1: 'powershell',\n\tyaml: 'yaml',\n\tyml: 'yaml',\n\ttoml: 'toml',\n\txml: 'xml',\n\tsvg: 'xml',\n\ttxt: 'text',\n})\n","import type { WorkspaceErrorCode } from './types.js'\nimport { holds, INTRINSICS, isFunction, isObject } from '@orkestrel/contract'\n\n/**\n * Reports an invalid workspace edit or search operation, carrying a {@link WorkspaceErrorCode}\n * and, when the operation had one, the context it ran under.\n */\nexport class WorkspaceError extends Error {\n\treadonly code: WorkspaceErrorCode\n\treadonly context?: Readonly<Record<string, unknown>>\n\n\t/**\n\t * Creates a workspace error.\n\t *\n\t * @param code - The machine-readable failure code\n\t * @param message - The human-readable failure message\n\t * @param context - Optional values associated with the failed operation\n\t */\n\tconstructor(\n\t\tcode: WorkspaceErrorCode,\n\t\tmessage: string,\n\t\tcontext?: Readonly<Record<string, unknown>>,\n\t) {\n\t\tsuper(message)\n\t\tINTRINSICS.define(this, Symbol.for('@orkestrel/workspace.WorkspaceError'), { value: this })\n\t\tthis.name = 'WorkspaceError'\n\t\tthis.code = code\n\t\tif (context !== undefined) this.context = context\n\t}\n}\n\n/**\n * Narrows a caught value to a {@link WorkspaceError}.\n *\n * @remarks\n * Checks the identity brand and declared members across package copies, accepting subclasses\n * and refusing transparent proxies. Inspection failures return false.\n *\n * @param value - The caught value\n * @returns True if the value is a workspace error; false otherwise\n *\n * @example\n * ```ts\n * if (isWorkspaceError(error)) error.code\n * ```\n */\nexport function isWorkspaceError(value: unknown): value is WorkspaceError {\n\treturn holds(() => {\n\t\tif (!(value instanceof Error) || INTRINSICS.prototype(value) === Error.prototype) return false\n\t\tconst brand = INTRINSICS.describe(value, Symbol.for('@orkestrel/workspace.WorkspaceError'))\n\t\tif (brand?.value !== value) return false\n\t\tconst code: unknown = INTRINSICS.reflect.read(value, 'code')\n\t\tif (code !== 'MISSING' && code !== 'MODALITY' && code !== 'PATTERN' && code !== 'RANGE')\n\t\t\treturn false\n\t\tconst context: unknown = INTRINSICS.reflect.read(value, 'context')\n\t\treturn context === undefined || isObject(context) || isFunction(context)\n\t})\n}\n","import type { BinaryContent, FileContent, Position, Range, TextContent } from './types.js'\nimport { EXTENSION_LANGUAGES } from './constants.js'\n\n/**\n * Infers a language tag from the final file extension.\n *\n * @param path - The file path\n * @returns The mapped language, or `text` when the extension is absent or unknown\n *\n * @example\n * ```ts\n * inferLanguage('src/main.ts') // 'typescript'\n * ```\n */\nexport function inferLanguage(path: string): string {\n\tconst dot = path.lastIndexOf('.')\n\tif (dot === -1) return 'text'\n\tconst extension = path.slice(dot + 1).toLowerCase()\n\treturn EXTENSION_LANGUAGES[extension] ?? 'text'\n}\n\n/**\n * Determines whether content is the text arm.\n *\n * @param content - The file content\n * @returns True if the content carries text and a language; false otherwise\n *\n * @example\n * ```ts\n * isText({ text: 'hello', language: 'text' }) // true\n * ```\n */\nexport function isText(content: FileContent): content is TextContent {\n\treturn 'text' in content\n}\n\n/**\n * Determines whether content is the binary arm.\n *\n * @param content - The file content\n * @returns True if the content carries a base64 string and a MIME; false otherwise\n *\n * @example\n * ```ts\n * isBinary({ base64: 'AAAA', mime: 'image/png' }) // true\n * ```\n */\nexport function isBinary(content: FileContent): content is BinaryContent {\n\treturn 'base64' in content\n}\n\n/**\n * Computes the byte size of file content.\n *\n * @param content - The content to measure\n * @returns UTF-8 bytes for text or decoded bytes for binary content\n *\n * @example\n * ```ts\n * computeSize({ text: 'café', language: 'text' }) // 5\n * ```\n */\nexport function computeSize(content: FileContent): number {\n\tif (isText(content)) return new TextEncoder().encode(content.text).length\n\treturn computeDecodedSize(content.base64)\n}\n\n/**\n * Counts the lines in file content.\n *\n * @param content - The content to inspect\n * @returns The text line count, or zero for empty text and binary content\n *\n * @example\n * ```ts\n * countLines({ text: 'a\\nb', language: 'text' }) // 2\n * ```\n */\nexport function countLines(content: FileContent): number {\n\tif (!isText(content)) return 0\n\tif (content.text.length === 0) return 0\n\treturn content.text.split(/\\r\\n|\\n/).length\n}\n\n/**\n * Computes the decoded byte length of a base64 string, arithmetically rather than by decoding it.\n *\n * @param base64 - The base64 string\n * @returns The decoded byte count\n *\n * @example\n * ```ts\n * computeDecodedSize('AAAA') // 3\n * ```\n */\nexport function computeDecodedSize(base64: string): number {\n\tconst padding = base64.endsWith('==') ? 2 : base64.endsWith('=') ? 1 : 0\n\treturn Math.floor((base64.length * 3) / 4) - padding\n}\n\n/**\n * Determines whether a 1-based range is structurally valid.\n *\n * @param range - The range to inspect\n * @returns True if both positions are positive and ordered; false otherwise\n *\n * @example\n * ```ts\n * isValidRange({ start: { line: 1, column: 1 }, end: { line: 1, column: 2 } }) // true\n * ```\n */\nexport function isValidRange(range: Range): boolean {\n\tif (range.start.line < 1 || range.start.column < 1) return false\n\tif (range.end.line < 1 || range.end.column < 1) return false\n\tif (range.start.line > range.end.line) return false\n\treturn !(range.start.line === range.end.line && range.start.column > range.end.column)\n}\n\n/**\n * Clamps a position to text bounds.\n *\n * @param text - The addressed text\n * @param position - The requested position\n * @returns The clamped position\n *\n * @example\n * ```ts\n * clampPosition('ab', { line: 9, column: 9 }) // { line: 1, column: 3 }\n * ```\n */\nexport function clampPosition(text: string, position: Position): Position {\n\tconst lines = text.split('\\n')\n\tconst line = Math.max(1, Math.min(position.line, lines.length))\n\tconst lineText = lines[line - 1] ?? ''\n\tconst column = Math.max(1, Math.min(position.column, lineText.length + 1))\n\treturn { line, column }\n}\n\n/**\n * Clamps both positions in a range to text bounds.\n *\n * @param text - The addressed text\n * @param range - The requested range\n * @returns The clamped range\n *\n * @example\n * ```ts\n * clampRange('ab', { start: { line: 1, column: 1 }, end: { line: 9, column: 9 } })\n * ```\n */\nexport function clampRange(text: string, range: Range): Range {\n\treturn { start: clampPosition(text, range.start), end: clampPosition(text, range.end) }\n}\n\n/**\n * Converts a 1-based position to a zero-based string offset.\n *\n * @param text - The addressed text\n * @param position - The requested position\n * @returns The bounded string offset\n *\n * @example\n * ```ts\n * offsetAt('ab\\ncd', { line: 2, column: 1 }) // 3\n * ```\n */\nexport function offsetAt(text: string, position: Position): number {\n\tconst lines = text.split('\\n')\n\tconst offset = lines\n\t\t.filter((_, index) => index < position.line - 1)\n\t\t.reduce((total, line) => total + line.length + 1, 0)\n\treturn Math.min(offset + (position.column - 1), text.length)\n}\n\n/**\n * Slices a clamped half-open text range.\n *\n * @param text - The source text\n * @param range - The requested range\n * @returns The ranged substring\n *\n * @example\n * ```ts\n * sliceRange('hello', { start: { line: 1, column: 1 }, end: { line: 1, column: 6 } }) // 'hello'\n * ```\n */\nexport function sliceRange(text: string, range: Range): string {\n\tconst clamped = clampRange(text, range)\n\treturn text.slice(offsetAt(text, clamped.start), offsetAt(text, clamped.end))\n}\n\n/**\n * Replaces a clamped half-open text range.\n *\n * @param text - The source text\n * @param range - The requested range\n * @param replacement - The replacement text\n * @returns The spliced text\n *\n * @example\n * ```ts\n * spliceRange('hello', { start: { line: 1, column: 1 }, end: { line: 1, column: 6 } }, 'bye')\n * ```\n */\nexport function spliceRange(text: string, range: Range, replacement: string): string {\n\tconst clamped = clampRange(text, range)\n\tconst start = offsetAt(text, clamped.start)\n\tconst end = offsetAt(text, clamped.end)\n\treturn text.slice(0, start) + replacement + text.slice(end)\n}\n\n/**\n * Assembles a nested range from four 1-based coordinates.\n *\n * @param fromLine - The start line\n * @param fromColumn - The start column\n * @param toLine - The end line\n * @param toColumn - The end column\n * @returns The assembled range without validation\n *\n * @example\n * ```ts\n * rangeOf(1, 1, 1, 2)\n * ```\n */\nexport function rangeOf(\n\tfromLine: number,\n\tfromColumn: number,\n\ttoLine: number,\n\ttoColumn: number,\n): Range {\n\treturn { start: { line: fromLine, column: fromColumn }, end: { line: toLine, column: toColumn } }\n}\n\n/**\n * Escapes regular-expression metacharacters for literal matching.\n *\n * @param value - The literal text\n * @returns The escaped regular-expression source\n *\n * @example\n * ```ts\n * escapeRegExp('a.b') // 'a\\\\.b'\n * ```\n */\nexport function escapeRegExp(value: string): string {\n\treturn value.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')\n}\n","import type { FileInterface, WorkspaceSnapshot } from './types.js'\nimport { arrayOf, holds, isNumber, isRecord, isString, literalOf } from '@orkestrel/contract'\n\n/**\n * Narrows an unknown value to an immutable file record.\n *\n * @param value - The value to inspect\n * @returns True if the value has the file shape; false otherwise\n *\n * @example\n * ```ts\n * isFile({ path: 'a.txt', content: { text: 'a', language: 'text' }, state: 'created', size: 1, lines: 1 })\n * ```\n */\nexport function isFile(value: unknown): value is FileInterface {\n\treturn holds(() => {\n\t\tif (!isRecord(value)) return false\n\t\tif (!isString(value.path) || !literalOf('created', 'modified')(value.state)) return false\n\t\tif (!isNumber(value.size) || !isNumber(value.lines)) return false\n\t\tif (!isRecord(value.content)) return false\n\t\tconst text = isString(value.content.text) && isString(value.content.language)\n\t\tconst binary =\n\t\t\tisString(value.content.base64) &&\n\t\t\tliteralOf('image/png', 'image/jpeg', 'image/gif', 'image/webp')(value.content.mime)\n\t\treturn text || binary\n\t})\n}\n\n/**\n * Narrows an unknown value to a workspace snapshot.\n *\n * @param value - The value read from a persistence boundary\n * @returns True if the value has the workspace snapshot shape; false otherwise\n *\n * @example\n * ```ts\n * isWorkspaceSnapshot({ id: 'work', files: [] }) // true\n * ```\n */\nexport function isWorkspaceSnapshot(value: unknown): value is WorkspaceSnapshot {\n\treturn holds(() => isRecord(value) && isString(value.id) && arrayOf(isFile)(value.files))\n}\n","import type { EmitterInterface } from '@orkestrel/emitter'\nimport type {\n\tFileInterface,\n\tRange,\n\tReadResult,\n\tReplaceResult,\n\tSearchMatch,\n\tSearchOptions,\n\tWorkspaceEventMap,\n\tWorkspaceInterface,\n\tWorkspaceOptions,\n\tWorkspaceSnapshot,\n} from '../types.js'\nimport { isArray, isRecord } from '@orkestrel/contract'\nimport { Emitter } from '@orkestrel/emitter'\nimport { WorkspaceError } from '../errors.js'\nimport { createFile } from '../factories.js'\nimport {\n\tclampRange,\n\tescapeRegExp,\n\tinferLanguage,\n\tisText,\n\tisValidRange,\n\tsliceRange,\n\tspliceRange,\n} from '../helpers.js'\n\n/**\n * Implements `WorkspaceInterface` over one insertion-ordered path map the instance owns,\n * projecting fresh arrays on every read.\n *\n * Whole-file edits create text files, ranged edits operate only on existing text files, and\n * binary files remain available through construction-time hydration. Mutations emit after the\n * file map has changed.\n *\n * @example\n * ```ts\n * import { Workspace } from '@orkestrel/workspace'\n *\n * const workspace = new Workspace()\n * workspace.write('notes.txt', 'hello')\n * workspace.append('notes.txt', ' world')\n * workspace.read('notes.txt') // 'hello world'\n * ```\n */\nexport class Workspace implements WorkspaceInterface {\n\treadonly #id: string\n\treadonly #files = new Map<string, FileInterface>()\n\treadonly #emitter: Emitter<WorkspaceEventMap>\n\n\t/**\n\t * Creates a workspace.\n\t *\n\t * @param options - Optional identity, emitter configuration, and initial files\n\t */\n\tconstructor(options?: WorkspaceOptions) {\n\t\tthis.#id = options?.id ?? crypto.randomUUID()\n\t\tthis.#emitter = new Emitter<WorkspaceEventMap>({\n\t\t\t...(options?.on === undefined ? {} : { on: options.on }),\n\t\t\t...(options?.error === undefined ? {} : { error: options.error }),\n\t\t})\n\t\tif (options?.seed) for (const file of options.seed) this.#files.set(file.path, file)\n\t}\n\n\tget id(): string {\n\t\treturn this.#id\n\t}\n\n\tget emitter(): EmitterInterface<WorkspaceEventMap> {\n\t\treturn this.#emitter\n\t}\n\n\tget count(): number {\n\t\treturn this.#files.size\n\t}\n\n\tfile(path: string): FileInterface | undefined {\n\t\treturn this.#files.get(path)\n\t}\n\n\tfiles(): readonly FileInterface[] {\n\t\treturn [...this.#files.values()]\n\t}\n\n\tread(path: string): string | undefined\n\tread(path: string, range: Range): ReadResult | undefined\n\tread(paths: readonly string[]): Readonly<Record<string, string>>\n\tread(\n\t\tpath: string | readonly string[],\n\t\trange?: Range,\n\t): string | ReadResult | undefined | Readonly<Record<string, string>> {\n\t\tif (isArray(path)) {\n\t\t\tconst result: Record<string, string> = {}\n\t\t\tfor (const one of path) {\n\t\t\t\tconst file = this.#files.get(one)\n\t\t\t\tif (file && isText(file.content)) result[one] = file.content.text\n\t\t\t}\n\t\t\treturn result\n\t\t}\n\t\tconst file = this.#files.get(path)\n\t\tif (!file) return undefined\n\t\tif (!range) return isText(file.content) ? file.content.text : undefined\n\t\tif (!isText(file.content)) {\n\t\t\tthrow new WorkspaceError('MODALITY', `Cannot read a range of a binary file: ${path}`, {\n\t\t\t\tpath,\n\t\t\t})\n\t\t}\n\t\treturn {\n\t\t\tcontent: sliceRange(file.content.text, range),\n\t\t\trange: clampRange(file.content.text, range),\n\t\t}\n\t}\n\n\thas(path: string): boolean\n\thas(paths: readonly string[]): boolean\n\thas(path: string | readonly string[]): boolean {\n\t\tif (isArray(path)) return path.every((one) => this.#files.has(one))\n\t\treturn this.#files.has(path)\n\t}\n\n\tsearch(query: string, options?: SearchOptions): readonly SearchMatch[] {\n\t\tconst pattern = this.#pattern(query, options)\n\t\tconst limit = options?.limit\n\t\tconst matches: SearchMatch[] = []\n\t\tfor (const file of this.#files.values()) {\n\t\t\tif (limit !== undefined && matches.length >= limit) break\n\t\t\tif (!isText(file.content)) continue\n\t\t\tconst lines = file.content.text.split(/\\r\\n|\\n/)\n\t\t\tfor (const [index, lineText] of lines.entries()) {\n\t\t\t\tif (limit !== undefined && matches.length >= limit) break\n\t\t\t\tpattern.lastIndex = 0\n\t\t\t\tfor (const hit of lineText.matchAll(pattern)) {\n\t\t\t\t\tif (limit !== undefined && matches.length >= limit) break\n\t\t\t\t\tmatches.push({\n\t\t\t\t\t\tpath: file.path,\n\t\t\t\t\t\tline: index + 1,\n\t\t\t\t\t\tcolumn: hit.index + 1,\n\t\t\t\t\t\tlength: hit[0].length,\n\t\t\t\t\t\tcontent: lineText,\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn matches\n\t}\n\n\treplace(query: string, replacement: string, options?: SearchOptions): ReplaceResult {\n\t\tconst pattern = this.#pattern(query, options)\n\t\tconst limit = options?.limit\n\t\tconst changes: number[] = []\n\t\tfor (const [path, file] of this.#files) {\n\t\t\tconst occurrences = changes.reduce((total, count) => total + count, 0)\n\t\t\tif (limit !== undefined && occurrences >= limit) break\n\t\t\tif (!isText(file.content)) continue\n\t\t\tconst remaining = limit === undefined ? undefined : limit - occurrences\n\t\t\tpattern.lastIndex = 0\n\t\t\tconst text = file.content.text\n\t\t\tconst matches = Array.from(text.matchAll(pattern))\n\t\t\tconst count = matches.filter(\n\t\t\t\t(_, index) => remaining === undefined || !(index >= remaining),\n\t\t\t).length\n\t\t\tconst positions = matches.keys()\n\t\t\tconst next = text.replace(pattern, (match) =>\n\t\t\t\t(positions.next().value ?? Number.POSITIVE_INFINITY) < count ? replacement : match,\n\t\t\t)\n\t\t\tif (count > 0) {\n\t\t\t\tchanges.push(count)\n\t\t\t\tthis.write(path, next)\n\t\t\t}\n\t\t}\n\t\treturn {\n\t\t\toccurrences: changes.reduce((total, count) => total + count, 0),\n\t\t\tfiles: changes.length,\n\t\t}\n\t}\n\n\twrite(path: string, content: string): void\n\twrite(path: string, content: string, range: Range): void\n\twrite(files: Readonly<Record<string, string>>): void\n\twrite(path: string | Readonly<Record<string, string>>, content?: string, range?: Range): void {\n\t\tif (isRecord(path)) {\n\t\t\tfor (const [one, text] of Object.entries(path)) this.#write(one, text)\n\t\t\treturn\n\t\t}\n\t\tif (content === undefined) return\n\t\tif (!range) {\n\t\t\tthis.#write(path, content)\n\t\t\treturn\n\t\t}\n\t\tthis.#splice(path, content, range)\n\t}\n\n\tprepend(path: string, content: string): void\n\tprepend(files: Readonly<Record<string, string>>): void\n\tprepend(path: string | Readonly<Record<string, string>>, content?: string): void {\n\t\tif (isRecord(path)) {\n\t\t\tfor (const [one, text] of Object.entries(path)) this.#prepend(one, text)\n\t\t\treturn\n\t\t}\n\t\tif (content === undefined) return\n\t\tthis.#prepend(path, content)\n\t}\n\n\tappend(path: string, content: string): void\n\tappend(files: Readonly<Record<string, string>>): void\n\tappend(path: string | Readonly<Record<string, string>>, content?: string): void {\n\t\tif (isRecord(path)) {\n\t\t\tfor (const [one, text] of Object.entries(path)) this.#append(one, text)\n\t\t\treturn\n\t\t}\n\t\tif (content === undefined) return\n\t\tthis.#append(path, content)\n\t}\n\n\tmove(from: string, to: string): boolean\n\tmove(mapping: Readonly<Record<string, string>>): boolean\n\tmove(from: string | Readonly<Record<string, string>>, to?: string): boolean {\n\t\tif (isRecord(from)) {\n\t\t\treturn Object.entries(from).reduce(\n\t\t\t\t(moved, [one, target]) => this.#move(one, target) && moved,\n\t\t\t\ttrue,\n\t\t\t)\n\t\t}\n\t\tif (to === undefined) return false\n\t\treturn this.#move(from, to)\n\t}\n\n\tremove(path: string): boolean\n\tremove(paths: readonly string[]): boolean\n\tremove(path: string | readonly string[]): boolean {\n\t\tif (isArray(path)) {\n\t\t\treturn Iterator.from(path).reduce((removed, one) => this.#remove(one) && removed, true)\n\t\t}\n\t\treturn this.#remove(path)\n\t}\n\n\tclear(): void {\n\t\tthis.#files.clear()\n\t\tthis.#emitter.emit('clear')\n\t}\n\n\tsnapshot(): WorkspaceSnapshot {\n\t\treturn { id: this.#id, files: this.files() }\n\t}\n\n\tdestroy(): void {\n\t\tthis.#emitter.destroy()\n\t}\n\n\t#write(path: string, content: string): void {\n\t\tconst existing = this.#files.get(path)\n\t\tconst language =\n\t\t\texisting && isText(existing.content) ? existing.content.language : inferLanguage(path)\n\t\tconst file = createFile({\n\t\t\tpath,\n\t\t\tcontent: { text: content, language },\n\t\t\tstate: existing ? 'modified' : 'created',\n\t\t})\n\t\tthis.#files.set(path, file)\n\t\tthis.#emitter.emit('write', file)\n\t}\n\n\t#splice(path: string, content: string, range: Range): void {\n\t\tconst existing = this.#files.get(path)\n\t\tif (!existing) {\n\t\t\tthrow new WorkspaceError('MISSING', `Cannot splice a range of a missing file: ${path}`, {\n\t\t\t\tpath,\n\t\t\t})\n\t\t}\n\t\tif (!isText(existing.content)) {\n\t\t\tthrow new WorkspaceError('MODALITY', `Cannot splice a range of a binary file: ${path}`, {\n\t\t\t\tpath,\n\t\t\t})\n\t\t}\n\t\tif (!isValidRange(range)) {\n\t\t\tthrow new WorkspaceError('RANGE', `Invalid range for file: ${path}`, { path, range })\n\t\t}\n\t\tconst file = createFile({\n\t\t\tpath,\n\t\t\tcontent: {\n\t\t\t\ttext: spliceRange(existing.content.text, range, content),\n\t\t\t\tlanguage: existing.content.language,\n\t\t\t},\n\t\t\tstate: 'modified',\n\t\t})\n\t\tthis.#files.set(path, file)\n\t\tthis.#emitter.emit('write', file)\n\t}\n\n\t#prepend(path: string, content: string): void {\n\t\tconst existing = this.#files.get(path)\n\t\tif (existing === undefined) {\n\t\t\tthis.#write(path, content)\n\t\t\treturn\n\t\t}\n\t\tif (!isText(existing.content)) {\n\t\t\tthrow new WorkspaceError('MODALITY', `Cannot prepend text to a binary file: ${path}`, {\n\t\t\t\tpath,\n\t\t\t})\n\t\t}\n\t\tthis.#write(path, content + existing.content.text)\n\t}\n\n\t#append(path: string, content: string): void {\n\t\tconst existing = this.#files.get(path)\n\t\tif (existing === undefined) {\n\t\t\tthis.#write(path, content)\n\t\t\treturn\n\t\t}\n\t\tif (!isText(existing.content)) {\n\t\t\tthrow new WorkspaceError('MODALITY', `Cannot append text to a binary file: ${path}`, {\n\t\t\t\tpath,\n\t\t\t})\n\t\t}\n\t\tthis.#write(path, existing.content.text + content)\n\t}\n\n\t#move(from: string, to: string): boolean {\n\t\tif (from === to) return false\n\t\tconst file = this.#files.get(from)\n\t\tif (!file) return false\n\t\tconst moved = createFile({ path: to, content: file.content, state: 'modified' })\n\t\tconst entries = [...this.#files]\n\t\tthis.#files.clear()\n\t\tfor (const [path, current] of entries) {\n\t\t\tif (path === from) this.#files.set(to, moved)\n\t\t\telse if (path !== to) this.#files.set(path, current)\n\t\t}\n\t\tthis.#emitter.emit('move', from, to)\n\t\treturn true\n\t}\n\n\t#remove(path: string): boolean {\n\t\tconst removed = this.#files.delete(path)\n\t\tif (removed) this.#emitter.emit('remove', path)\n\t\treturn removed\n\t}\n\n\t#pattern(query: string, options?: SearchOptions): RegExp {\n\t\tconst source = options?.regex === true ? query : escapeRegExp(query)\n\t\tconst flags = options?.sensitive === false ? 'gi' : 'g'\n\t\ttry {\n\t\t\treturn new RegExp(source, flags)\n\t\t} catch {\n\t\t\tthrow new WorkspaceError('PATTERN', `Invalid search pattern: ${query}`, { query })\n\t\t}\n\t}\n}\n","import type { EmitterErrorHandler, EmitterHooks } from '@orkestrel/emitter'\nimport type {\n\tWorkspaceEventMap,\n\tWorkspaceInterface,\n\tWorkspaceManagerInterface,\n\tWorkspaceManagerOptions,\n\tWorkspaceOptions,\n\tWorkspaceStoreInterface,\n} from '../types.js'\nimport { isArray } from '@orkestrel/contract'\nimport { Workspace } from './Workspace.js'\n\n/**\n * Implements `WorkspaceManagerInterface` over an insertion-ordered id map and one active id\n * the instance owns, resolving `active` through that map on every read and holding no emitter.\n *\n * A supplied store adds lenient snapshot `open` and `save` operations. Event defaults flow into\n * workspaces created through the registry, while observability remains owned by each workspace.\n *\n * @example\n * ```ts\n * import { WorkspaceManager } from '@orkestrel/workspace'\n *\n * const manager = new WorkspaceManager()\n * const workspace = manager.add({ id: 'scratch' })\n * manager.active === workspace\n * ```\n */\nexport class WorkspaceManager implements WorkspaceManagerInterface {\n\treadonly #workspaces = new Map<string, WorkspaceInterface>()\n\t#active: string | undefined\n\treadonly #on: EmitterHooks<WorkspaceEventMap> | undefined\n\treadonly #error: EmitterErrorHandler | undefined\n\treadonly #store: WorkspaceStoreInterface | undefined\n\n\t/**\n\t * Creates a registry.\n\t *\n\t * @param options - Default event hooks and optional snapshot store\n\t */\n\tconstructor(options?: WorkspaceManagerOptions) {\n\t\tthis.#on = options?.on\n\t\tthis.#error = options?.error\n\t\tthis.#store = options?.store\n\t}\n\n\tget count(): number {\n\t\treturn this.#workspaces.size\n\t}\n\n\tget active(): WorkspaceInterface | undefined {\n\t\treturn this.#active === undefined ? undefined : this.#workspaces.get(this.#active)\n\t}\n\n\tworkspace(id: string): WorkspaceInterface | undefined {\n\t\treturn this.#workspaces.get(id)\n\t}\n\n\tworkspaces(): readonly WorkspaceInterface[] {\n\t\treturn [...this.#workspaces.values()]\n\t}\n\n\tadd(options?: WorkspaceOptions): WorkspaceInterface {\n\t\tconst on = options?.on ?? this.#on\n\t\tconst error = options?.error ?? this.#error\n\t\tconst workspace = new Workspace({\n\t\t\t...(options?.id === undefined ? {} : { id: options.id }),\n\t\t\t...(on === undefined ? {} : { on }),\n\t\t\t...(error === undefined ? {} : { error }),\n\t\t\t...(options?.seed === undefined ? {} : { seed: options.seed }),\n\t\t})\n\t\tthis.#workspaces.set(workspace.id, workspace)\n\t\tif (this.#active === undefined) this.#active = workspace.id\n\t\treturn workspace\n\t}\n\n\tswitch(id: string): WorkspaceInterface | undefined {\n\t\tconst workspace = this.#workspaces.get(id)\n\t\tif (workspace === undefined) return undefined\n\t\tthis.#active = id\n\t\treturn workspace\n\t}\n\n\tasync open(id: string): Promise<WorkspaceInterface | undefined> {\n\t\tconst existing = this.#workspaces.get(id)\n\t\tif (existing !== undefined) {\n\t\t\tthis.#active = id\n\t\t\treturn existing\n\t\t}\n\t\tif (this.#store === undefined) return undefined\n\t\tconst snapshot = await this.#store.get(id)\n\t\tif (snapshot === undefined) return undefined\n\t\tconst workspace = this.add({ id, seed: snapshot.files })\n\t\tthis.#active = workspace.id\n\t\treturn workspace\n\t}\n\n\tasync save(id: string): Promise<boolean> {\n\t\tconst workspace = this.#workspaces.get(id)\n\t\tif (this.#store === undefined || workspace === undefined) return false\n\t\tawait this.#store.set(workspace.snapshot())\n\t\treturn true\n\t}\n\n\tremove(id: string): boolean\n\tremove(ids: readonly string[]): boolean\n\tremove(ids: string | readonly string[]): boolean {\n\t\tif (isArray(ids)) {\n\t\t\treturn Iterator.from(ids).reduce((removed, id) => this.#drop(id) && removed, true)\n\t\t}\n\t\treturn this.#drop(ids)\n\t}\n\n\tclear(): void {\n\t\tfor (const workspace of this.#workspaces.values()) workspace.destroy()\n\t\tthis.#workspaces.clear()\n\t\tthis.#active = undefined\n\t}\n\n\t#drop(id: string): boolean {\n\t\tconst workspace = this.#workspaces.get(id)\n\t\tif (workspace === undefined) return false\n\t\tthis.#workspaces.delete(id)\n\t\tworkspace.destroy()\n\t\tif (this.#active === id) this.#active = undefined\n\t\treturn true\n\t}\n}\n","import type {\n\tWorkspaceSnapshot,\n\tWorkspaceSnapshotRow,\n\tWorkspaceStoreInterface,\n} from '../../types.js'\nimport type { TableInterface } from '@orkestrel/database'\nimport { isWorkspaceSnapshot } from '../../validators.js'\n\n/**\n * Persists workspace snapshots in a database table.\n *\n * Snapshots occupy one opaque column and are narrowed when read back from the storage boundary.\n *\n * @example\n * ```ts\n * import { rawShape, stringShape } from '@orkestrel/contract'\n * import { createDatabase, createMemoryDriver } from '@orkestrel/database'\n * import { DatabaseWorkspaceStore } from '@orkestrel/workspace'\n *\n * const database = createDatabase({\n * \tdriver: createMemoryDriver(),\n * \ttables: { workspaces: { id: stringShape(), snapshot: rawShape({}) } },\n * })\n * const store = new DatabaseWorkspaceStore(database.table('workspaces'))\n * ```\n */\nexport class DatabaseWorkspaceStore implements WorkspaceStoreInterface {\n\treadonly #table: TableInterface<WorkspaceSnapshotRow>\n\n\t/**\n\t * Wraps a workspace snapshot table.\n\t *\n\t * @param table - The table keyed by workspace identifier\n\t */\n\tconstructor(table: TableInterface<WorkspaceSnapshotRow>) {\n\t\tthis.#table = table\n\t}\n\n\tasync get(id: string): Promise<WorkspaceSnapshot | undefined> {\n\t\tconst row = await this.#table.get(id)\n\t\tif (row === undefined) return undefined\n\t\treturn isWorkspaceSnapshot(row.snapshot) ? row.snapshot : undefined\n\t}\n\n\tasync set(snapshot: WorkspaceSnapshot): Promise<void> {\n\t\tawait this.#table.set({ id: snapshot.id, snapshot })\n\t}\n\n\tasync delete(id: string): Promise<void> {\n\t\tawait this.#table.remove(id)\n\t}\n}\n","import type { WorkspaceSnapshot, WorkspaceStoreInterface } from '../../types.js'\n\n/**\n * Holds workspace snapshots in the current process.\n *\n * @example\n * ```ts\n * import { MemoryWorkspaceStore } from '@orkestrel/workspace'\n *\n * const store = new MemoryWorkspaceStore()\n * ```\n */\nexport class MemoryWorkspaceStore implements WorkspaceStoreInterface {\n\treadonly #snapshots = new Map<string, WorkspaceSnapshot>()\n\n\tget(id: string): Promise<WorkspaceSnapshot | undefined> {\n\t\treturn Promise.resolve(this.#snapshots.get(id))\n\t}\n\n\tset(snapshot: WorkspaceSnapshot): Promise<void> {\n\t\tthis.#snapshots.set(snapshot.id, snapshot)\n\t\treturn Promise.resolve()\n\t}\n\n\tdelete(id: string): Promise<void> {\n\t\tthis.#snapshots.delete(id)\n\t\treturn Promise.resolve()\n\t}\n}\n","import type {\n\tBinaryContent,\n\tBinaryMIME,\n\tFileInput,\n\tFileInterface,\n\tTextContent,\n\tWorkspaceInterface,\n\tWorkspaceManagerInterface,\n\tWorkspaceManagerOptions,\n\tWorkspaceOptions,\n\tWorkspaceSnapshotRow,\n\tWorkspaceStoreInterface,\n} from './types.js'\nimport type { DriverInterface, TableInterface } from '@orkestrel/database'\nimport { rawShape, stringShape } from '@orkestrel/contract'\nimport { createDatabase, createMemoryDriver } from '@orkestrel/database'\nimport { computeSize, countLines } from './helpers.js'\nimport { Workspace } from './workspaces/Workspace.js'\nimport { WorkspaceManager } from './workspaces/WorkspaceManager.js'\nimport { DatabaseWorkspaceStore } from './workspaces/stores/DatabaseWorkspaceStore.js'\nimport { MemoryWorkspaceStore } from './workspaces/stores/MemoryWorkspaceStore.js'\n\n/**\n * Creates an immutable file with derived size and line counts.\n *\n * @param input - The file path, content, and optional state\n * @returns A frozen file record\n *\n * @example Files and content\n * ```ts\n * import {\n * \tcomputeSize,\n * \tcountLines,\n * \tcreateBinaryContent,\n * \tcreateFile,\n * \tcreateTextContent,\n * \tinferLanguage,\n * \tisBinary,\n * \tisText,\n * } from '@orkestrel/workspace'\n *\n * const note = createFile({\n * \tpath: 'notes.md',\n * \tcontent: createTextContent('# Title\\nBody', inferLanguage('notes.md')), // 'markdown'\n * })\n *\n * note.size // 12 — UTF-8 bytes, through computeSize\n * note.lines // 2 — through countLines\n * note.state // 'created'\n * isText(note.content) // true\n *\n * const icon = createFile({ path: 'icon.png', content: createBinaryContent('AAAA', 'image/png') })\n * isBinary(icon.content) // true\n * icon.size // 3 — decoded base64 bytes, through computeDecodedSize\n * ```\n */\nexport function createFile(input: FileInput): FileInterface {\n\treturn Object.freeze({\n\t\tpath: input.path,\n\t\tcontent: input.content,\n\t\tstate: input.state ?? 'created',\n\t\tsize: computeSize(input.content),\n\t\tlines: countLines(input.content),\n\t})\n}\n\n/**\n * Creates the text arm of {@link FileContent}, returned as {@link TextContent} rather than as\n * the whole union.\n *\n * @param text - The text body\n * @param language - The language tag\n * @returns Text file content\n *\n * @example\n * ```ts\n * import { createTextContent } from '@orkestrel/workspace'\n *\n * createTextContent('hello', 'text')\n * ```\n */\nexport function createTextContent(text: string, language: string): TextContent {\n\treturn { text, language }\n}\n\n/**\n * Creates the binary arm of {@link FileContent}, returned as {@link BinaryContent} rather than\n * as the whole union.\n *\n * @param base64 - The base64 payload\n * @param mime - The binary MIME\n * @returns Binary file content\n *\n * @example\n * ```ts\n * import { createBinaryContent } from '@orkestrel/workspace'\n *\n * createBinaryContent('AAAA', 'image/png')\n * ```\n */\nexport function createBinaryContent(base64: string, mime: BinaryMIME): BinaryContent {\n\treturn { base64, mime }\n}\n\n/**\n * Creates a workspace with the same identity, emitter, and seed options the constructor takes.\n *\n * @param options - Optional identity, emitter configuration, and initial files\n * @returns A working workspace\n *\n * @example\n * ```ts\n * import { createWorkspace } from '@orkestrel/workspace'\n *\n * const workspace = createWorkspace()\n * workspace.write('a.txt', 'hello')\n * ```\n */\nexport function createWorkspace(options?: WorkspaceOptions): WorkspaceInterface {\n\treturn new Workspace(options)\n}\n\n/**\n * Creates an in-memory workspace snapshot store.\n *\n * @returns A process-local workspace store\n *\n * @example\n * ```ts\n * import { createMemoryWorkspaceStore } from '@orkestrel/workspace'\n *\n * const store = createMemoryWorkspaceStore()\n * ```\n */\nexport function createMemoryWorkspaceStore(): WorkspaceStoreInterface {\n\treturn new MemoryWorkspaceStore()\n}\n\n/**\n * Creates a database-backed workspace snapshot store, over an in-memory driver when the caller\n * supplies none.\n *\n * @param driver - The database driver. Default: an in-memory driver.\n * @returns A workspace store backed by the supplied driver\n *\n * @example\n * ```ts\n * import { createDatabaseWorkspaceStore } from '@orkestrel/workspace'\n *\n * const store = createDatabaseWorkspaceStore()\n * ```\n */\nexport function createDatabaseWorkspaceStore(\n\tdriver: DriverInterface = createMemoryDriver(),\n): WorkspaceStoreInterface {\n\tconst columns = { id: stringShape(), snapshot: rawShape({}) }\n\tconst database = createDatabase({ driver, tables: { workspaces: columns } })\n\tconst table: TableInterface<WorkspaceSnapshotRow> = database.table('workspaces')\n\treturn new DatabaseWorkspaceStore(table)\n}\n\n/**\n * Creates an empty workspace registry.\n *\n * @param options - Default event hooks and optional durability\n * @returns A workspace manager\n *\n * @example\n * ```ts\n * import { createWorkspaceManager } from '@orkestrel/workspace'\n *\n * const manager = createWorkspaceManager()\n * manager.add()\n * ```\n */\nexport function createWorkspaceManager(\n\toptions?: WorkspaceManagerOptions,\n): WorkspaceManagerInterface {\n\treturn new WorkspaceManager(options)\n}\n"],"mappings":";;;;;;;;;;;AAMA,IAAa,sBAAwD,OAAO,OAAO;CAClF,IAAI;CACJ,KAAK;CACL,IAAI;CACJ,KAAK;CACL,KAAK;CACL,KAAK;CACL,MAAM;CACN,IAAI;CACJ,MAAM;CACN,KAAK;CACL,KAAK;CACL,MAAM;CACN,MAAM;CACN,MAAM;CACN,KAAK;CACL,QAAQ;CACR,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,MAAM;CACN,IAAI;CACJ,OAAO;CACP,GAAG;CACH,KAAK;CACL,GAAG;CACH,KAAK;CACL,IAAI;CACJ,KAAK;CACL,KAAK;CACL,IAAI;CACJ,MAAM;CACN,KAAK;CACL,KAAK;CACL,MAAM;CACN,KAAK;CACL,MAAM;CACN,KAAK;CACL,KAAK;CACL,KAAK;AACN,CAAC;;;;;;ACxCD,IAAa,iBAAb,cAAoC,MAAM;CACzC;CACA;;;;;;;;CASA,YACC,MACA,SACA,SACC;EACD,MAAM,OAAO;EACb,oBAAA,WAAW,OAAO,MAAM,OAAO,IAAI,qCAAqC,GAAG,EAAE,OAAO,KAAK,CAAC;EAC1F,KAAK,OAAO;EACZ,KAAK,OAAO;EACZ,IAAI,YAAY,KAAA,GAAW,KAAK,UAAU;CAC3C;AACD;;;;;;;;;;;;;;;;AAiBA,SAA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SAAgB,6BACf,UAAA,GAA0BC,oBAAAA,mBAAAA,CAAmB,GACnB;CAC1B,MAAM,UAAU;EAAE,KAAA,GAAIC,oBAAAA,YAAAA,CAAY;EAAG,WAAA,GAAUC,oBAAAA,SAAAA,CAAS,CAAC,CAAC;CAAE;CAG5D,OAAO,IAAI,wBADL,GADWC,oBAAAA,eAAAA,CAAe;EAAE;EAAQ,QAAQ,EAAE,YAAY,QAAQ;CAAE,CACtB,CAAA,CAAS,MAAM,YACjC,CAAK;AACxC;;;;;;;;;;;;;;;AAgBA,SAAgB,uBACf,SAC4B;CAC5B,OAAO,IAAI,iBAAiB,OAAO;AACpC"}
1
+ {"version":3,"file":"index.cjs","names":["holds","INTRINSICS","isObject","isFunction","holds","isRecord","isString","literalOf","isNumber","arrayOf","Emitter","isArray","isRecord","escapeRegExp","isArray","createMemoryDriver","stringShape","rawShape","createDatabase"],"sources":["../../../src/core/constants.ts","../../../src/core/errors.ts","../../../src/core/helpers.ts","../../../src/core/validators.ts","../../../src/core/workspaces/Workspace.ts","../../../src/core/workspaces/WorkspaceManager.ts","../../../src/core/workspaces/stores/DatabaseWorkspaceStore.ts","../../../src/core/workspaces/stores/MemoryWorkspaceStore.ts","../../../src/core/factories.ts"],"sourcesContent":["/**\n * Maps file extensions to language tags for text content.\n *\n * The table is frozen, and an extension it does not list falls back to `text` in\n * {@link import('./helpers.js').inferLanguage}.\n */\nexport const EXTENSION_LANGUAGES: Readonly<Record<string, string>> = Object.freeze({\n\tts: 'typescript',\n\ttsx: 'typescript',\n\tjs: 'javascript',\n\tjsx: 'javascript',\n\tmjs: 'javascript',\n\tcjs: 'javascript',\n\tjson: 'json',\n\tmd: 'markdown',\n\thtml: 'html',\n\thtm: 'html',\n\tcss: 'css',\n\tscss: 'scss',\n\tsass: 'sass',\n\tless: 'less',\n\tvue: 'vue',\n\tsvelte: 'svelte',\n\tpy: 'python',\n\trb: 'ruby',\n\trs: 'rust',\n\tgo: 'go',\n\tjava: 'java',\n\tkt: 'kotlin',\n\tswift: 'swift',\n\tc: 'c',\n\tcpp: 'cpp',\n\th: 'c',\n\thpp: 'cpp',\n\tcs: 'csharp',\n\tphp: 'php',\n\tsql: 'sql',\n\tsh: 'bash',\n\tbash: 'bash',\n\tzsh: 'bash',\n\tps1: 'powershell',\n\tyaml: 'yaml',\n\tyml: 'yaml',\n\ttoml: 'toml',\n\txml: 'xml',\n\tsvg: 'xml',\n\ttxt: 'text',\n})\n","import type { WorkspaceErrorCode } from './types.js'\nimport { holds, INTRINSICS, isFunction, isObject } from '@orkestrel/contract'\n\n/**\n * Reports an invalid workspace edit or search operation, carrying a {@link WorkspaceErrorCode}\n * and, when the operation had one, the context it ran under.\n */\nexport class WorkspaceError extends Error {\n\treadonly code: WorkspaceErrorCode\n\treadonly context?: Readonly<Record<string, unknown>>\n\n\t/**\n\t * Creates a workspace error.\n\t *\n\t * @param code - The machine-readable failure code\n\t * @param message - The human-readable failure message\n\t * @param context - Optional values associated with the failed operation\n\t */\n\tconstructor(\n\t\tcode: WorkspaceErrorCode,\n\t\tmessage: string,\n\t\tcontext?: Readonly<Record<string, unknown>>,\n\t) {\n\t\tsuper(message)\n\t\tINTRINSICS.define(this, Symbol.for('@orkestrel/workspace.WorkspaceError'), { value: this })\n\t\tthis.name = 'WorkspaceError'\n\t\tthis.code = code\n\t\tif (context !== undefined) this.context = context\n\t}\n}\n\n/**\n * Narrows a caught value to a {@link WorkspaceError}.\n *\n * @remarks\n * Checks the identity brand and declared members across package copies, accepting subclasses\n * and refusing transparent proxies. Inspection failures return false.\n *\n * @param value - The caught value\n * @returns True if the value is a workspace error; false otherwise\n *\n * @example\n * ```ts\n * if (isWorkspaceError(error)) error.code\n * ```\n */\nexport function isWorkspaceError(value: unknown): value is WorkspaceError {\n\treturn holds(() => {\n\t\tif (!(value instanceof Error) || INTRINSICS.prototype(value) === Error.prototype) return false\n\t\tconst brand = INTRINSICS.describe(value, Symbol.for('@orkestrel/workspace.WorkspaceError'))\n\t\tif (brand?.value !== value) return false\n\t\tconst code: unknown = INTRINSICS.reflect.read(value, 'code')\n\t\tif (code !== 'MISSING' && code !== 'MODALITY' && code !== 'PATTERN' && code !== 'RANGE')\n\t\t\treturn false\n\t\tconst context: unknown = INTRINSICS.reflect.read(value, 'context')\n\t\treturn context === undefined || isObject(context) || isFunction(context)\n\t})\n}\n","import type { BinaryContent, Caret, FileContent, Range, TextContent } from './types.js'\nimport { EXTENSION_LANGUAGES } from './constants.js'\n\n/**\n * Infers a language tag from the final file extension.\n *\n * @param path - The file path\n * @returns The mapped language, or `text` when the extension is absent or unknown\n *\n * @example\n * ```ts\n * inferLanguage('src/main.ts') // 'typescript'\n * ```\n */\nexport function inferLanguage(path: string): string {\n\tconst dot = path.lastIndexOf('.')\n\tif (dot === -1) return 'text'\n\tconst extension = path.slice(dot + 1).toLowerCase()\n\treturn EXTENSION_LANGUAGES[extension] ?? 'text'\n}\n\n/**\n * Determines whether content is the text arm.\n *\n * @param content - The file content\n * @returns True if the content carries text and a language; false otherwise\n *\n * @example\n * ```ts\n * isTextContent({ text: 'hello', language: 'text' }) // true\n * ```\n */\nexport function isTextContent(content: FileContent): content is TextContent {\n\treturn 'text' in content\n}\n\n/**\n * Determines whether content is the binary arm.\n *\n * @param content - The file content\n * @returns True if the content carries a base64 string and a MIME; false otherwise\n *\n * @example\n * ```ts\n * isBinary({ base64: 'AAAA', mime: 'image/png' }) // true\n * ```\n */\nexport function isBinary(content: FileContent): content is BinaryContent {\n\treturn 'base64' in content\n}\n\n/**\n * Computes the byte size of file content.\n *\n * @param content - The content to measure\n * @returns UTF-8 bytes for text or decoded bytes for binary content\n *\n * @example\n * ```ts\n * computeSize({ text: 'café', language: 'text' }) // 5\n * ```\n */\nexport function computeSize(content: FileContent): number {\n\tif (isTextContent(content)) return new TextEncoder().encode(content.text).length\n\treturn computeDecodedSize(content.base64)\n}\n\n/**\n * Counts the lines in file content.\n *\n * @param content - The content to inspect\n * @returns The text line count, or zero for empty text and binary content\n *\n * @example\n * ```ts\n * countLines({ text: 'a\\nb', language: 'text' }) // 2\n * ```\n */\nexport function countLines(content: FileContent): number {\n\tif (!isTextContent(content)) return 0\n\tif (content.text.length === 0) return 0\n\treturn content.text.split(/\\r\\n|\\n/).length\n}\n\n/**\n * Computes the decoded byte length of a base64 string, arithmetically rather than by decoding it.\n *\n * @param base64 - The base64 string\n * @returns The decoded byte count\n *\n * @example\n * ```ts\n * computeDecodedSize('AAAA') // 3\n * ```\n */\nexport function computeDecodedSize(base64: string): number {\n\tconst padding = base64.endsWith('==') ? 2 : base64.endsWith('=') ? 1 : 0\n\treturn Math.floor((base64.length * 3) / 4) - padding\n}\n\n/**\n * Determines whether a 1-based range is structurally valid.\n *\n * @param range - The range to inspect\n * @returns True if both carets are positive and ordered; false otherwise\n *\n * @example\n * ```ts\n * isValidRange({ start: { line: 1, column: 1 }, end: { line: 1, column: 2 } }) // true\n * ```\n */\nexport function isValidRange(range: Range): boolean {\n\tif (range.start.line < 1 || range.start.column < 1) return false\n\tif (range.end.line < 1 || range.end.column < 1) return false\n\tif (range.start.line > range.end.line) return false\n\treturn !(range.start.line === range.end.line && range.start.column > range.end.column)\n}\n\n/**\n * Clamps a caret to text bounds.\n *\n * @param text - The addressed text\n * @param caret - The requested caret\n * @returns The clamped caret\n *\n * @example\n * ```ts\n * clampCaret('ab', { line: 9, column: 9 }) // { line: 1, column: 3 }\n * ```\n */\nexport function clampCaret(text: string, caret: Caret): Caret {\n\tconst lines = text.split('\\n')\n\tconst line = Math.max(1, Math.min(caret.line, lines.length))\n\tconst lineText = lines[line - 1] ?? ''\n\tconst column = Math.max(1, Math.min(caret.column, lineText.length + 1))\n\treturn { line, column }\n}\n\n/**\n * Clamps both carets in a range to text bounds.\n *\n * @param text - The addressed text\n * @param range - The requested range\n * @returns The clamped range\n *\n * @example\n * ```ts\n * clampRange('ab', { start: { line: 1, column: 1 }, end: { line: 9, column: 9 } })\n * ```\n */\nexport function clampRange(text: string, range: Range): Range {\n\treturn { start: clampCaret(text, range.start), end: clampCaret(text, range.end) }\n}\n\n/**\n * Converts a 1-based caret to a zero-based string offset.\n *\n * @param text - The addressed text\n * @param caret - The requested caret\n * @returns The bounded string offset\n *\n * @example\n * ```ts\n * offsetAt('ab\\ncd', { line: 2, column: 1 }) // 3\n * ```\n */\nexport function offsetAt(text: string, caret: Caret): number {\n\tconst lines = text.split('\\n')\n\tconst offset = lines\n\t\t.filter((_, index) => index < caret.line - 1)\n\t\t.reduce((total, line) => total + line.length + 1, 0)\n\treturn Math.min(offset + (caret.column - 1), text.length)\n}\n\n/**\n * Slices a clamped half-open text range.\n *\n * @param text - The source text\n * @param range - The requested range\n * @returns The ranged substring\n *\n * @example\n * ```ts\n * sliceRange('hello', { start: { line: 1, column: 1 }, end: { line: 1, column: 6 } }) // 'hello'\n * ```\n */\nexport function sliceRange(text: string, range: Range): string {\n\tconst clamped = clampRange(text, range)\n\treturn text.slice(offsetAt(text, clamped.start), offsetAt(text, clamped.end))\n}\n\n/**\n * Replaces a clamped half-open text range.\n *\n * @param text - The source text\n * @param range - The requested range\n * @param replacement - The replacement text\n * @returns The spliced text\n *\n * @example\n * ```ts\n * spliceRange('hello', { start: { line: 1, column: 1 }, end: { line: 1, column: 6 } }, 'bye')\n * ```\n */\nexport function spliceRange(text: string, range: Range, replacement: string): string {\n\tconst clamped = clampRange(text, range)\n\tconst start = offsetAt(text, clamped.start)\n\tconst end = offsetAt(text, clamped.end)\n\treturn text.slice(0, start) + replacement + text.slice(end)\n}\n\n/**\n * Assembles a nested range from four 1-based coordinates.\n *\n * @param fromLine - The start line\n * @param fromColumn - The start column\n * @param toLine - The end line\n * @param toColumn - The end column\n * @returns The assembled range without validation\n *\n * @example\n * ```ts\n * rangeOf(1, 1, 1, 2)\n * ```\n */\nexport function rangeOf(\n\tfromLine: number,\n\tfromColumn: number,\n\ttoLine: number,\n\ttoColumn: number,\n): Range {\n\treturn { start: { line: fromLine, column: fromColumn }, end: { line: toLine, column: toColumn } }\n}\n","import type { FileInterface, WorkspaceSnapshot } from './types.js'\nimport { arrayOf, holds, isNumber, isRecord, isString, literalOf } from '@orkestrel/contract'\n\n/**\n * Narrows an unknown value to an immutable file record.\n *\n * @param value - The value to inspect\n * @returns True if the value has the file shape; false otherwise\n *\n * @example\n * ```ts\n * isFile({ path: 'a.txt', content: { text: 'a', language: 'text' }, state: 'created', size: 1, lines: 1 })\n * ```\n */\nexport function isFile(value: unknown): value is FileInterface {\n\treturn holds(() => {\n\t\tif (!isRecord(value)) return false\n\t\tif (!isString(value.path) || !literalOf('created', 'modified')(value.state)) return false\n\t\tif (!isNumber(value.size) || !isNumber(value.lines)) return false\n\t\tif (!isRecord(value.content)) return false\n\t\tconst text = isString(value.content.text) && isString(value.content.language)\n\t\tconst binary =\n\t\t\tisString(value.content.base64) &&\n\t\t\tliteralOf('image/png', 'image/jpeg', 'image/gif', 'image/webp')(value.content.mime)\n\t\treturn text || binary\n\t})\n}\n\n/**\n * Narrows an unknown value to a workspace snapshot.\n *\n * @param value - The value read from a persistence boundary\n * @returns True if the value has the workspace snapshot shape; false otherwise\n *\n * @example\n * ```ts\n * isWorkspaceSnapshot({ id: 'work', files: [] }) // true\n * ```\n */\nexport function isWorkspaceSnapshot(value: unknown): value is WorkspaceSnapshot {\n\treturn holds(() => isRecord(value) && isString(value.id) && arrayOf(isFile)(value.files))\n}\n","import type { EmitterInterface } from '@orkestrel/emitter'\nimport type {\n\tFileInterface,\n\tRange,\n\tReadResult,\n\tReplaceResult,\n\tSearchMatch,\n\tSearchOptions,\n\tWorkspaceEventMap,\n\tWorkspaceInterface,\n\tWorkspaceOptions,\n\tWorkspaceSnapshot,\n} from '../types.js'\nimport { escapeRegExp, isArray, isRecord } from '@orkestrel/contract'\nimport { Emitter } from '@orkestrel/emitter'\nimport { WorkspaceError } from '../errors.js'\nimport { createFile } from '../factories.js'\nimport {\n\tclampRange,\n\tinferLanguage,\n\tisTextContent,\n\tisValidRange,\n\tsliceRange,\n\tspliceRange,\n} from '../helpers.js'\n\n/**\n * Implements `WorkspaceInterface` over one insertion-ordered path map the instance owns,\n * projecting fresh arrays on every read.\n *\n * Whole-file edits create text files, ranged edits operate only on existing text files, and\n * binary files remain available through construction-time hydration. Mutations emit after the\n * file map has changed.\n *\n * @example\n * ```ts\n * import { Workspace } from '@orkestrel/workspace'\n *\n * const workspace = new Workspace()\n * workspace.write('notes.txt', 'hello')\n * workspace.append('notes.txt', ' world')\n * workspace.read('notes.txt') // 'hello world'\n * ```\n */\nexport class Workspace implements WorkspaceInterface {\n\treadonly #id: string\n\treadonly #files = new Map<string, FileInterface>()\n\treadonly #emitter: Emitter<WorkspaceEventMap>\n\n\t/**\n\t * Creates a workspace.\n\t *\n\t * @param options - Optional identity, emitter configuration, and initial files\n\t */\n\tconstructor(options?: WorkspaceOptions) {\n\t\tthis.#id = options?.id ?? crypto.randomUUID()\n\t\tthis.#emitter = new Emitter<WorkspaceEventMap>({\n\t\t\t...(options?.on === undefined ? {} : { on: options.on }),\n\t\t\t...(options?.error === undefined ? {} : { error: options.error }),\n\t\t})\n\t\tif (options?.seed) for (const file of options.seed) this.#files.set(file.path, file)\n\t}\n\n\tget id(): string {\n\t\treturn this.#id\n\t}\n\n\tget emitter(): EmitterInterface<WorkspaceEventMap> {\n\t\treturn this.#emitter\n\t}\n\n\tget count(): number {\n\t\treturn this.#files.size\n\t}\n\n\tfile(path: string): FileInterface | undefined {\n\t\treturn this.#files.get(path)\n\t}\n\n\tfiles(): readonly FileInterface[] {\n\t\treturn [...this.#files.values()]\n\t}\n\n\tread(path: string): string | undefined\n\tread(path: string, range: Range): ReadResult | undefined\n\tread(paths: readonly string[]): Readonly<Record<string, string>>\n\tread(\n\t\tpath: string | readonly string[],\n\t\trange?: Range,\n\t): string | ReadResult | undefined | Readonly<Record<string, string>> {\n\t\tif (isArray(path)) {\n\t\t\tconst result: Record<string, string> = {}\n\t\t\tfor (const one of path) {\n\t\t\t\tconst file = this.#files.get(one)\n\t\t\t\tif (file && isTextContent(file.content)) result[one] = file.content.text\n\t\t\t}\n\t\t\treturn result\n\t\t}\n\t\tconst file = this.#files.get(path)\n\t\tif (!file) return undefined\n\t\tif (!range) return isTextContent(file.content) ? file.content.text : undefined\n\t\tif (!isTextContent(file.content)) {\n\t\t\tthrow new WorkspaceError('MODALITY', `Cannot read a range of a binary file: ${path}`, {\n\t\t\t\tpath,\n\t\t\t})\n\t\t}\n\t\treturn {\n\t\t\tcontent: sliceRange(file.content.text, range),\n\t\t\trange: clampRange(file.content.text, range),\n\t\t}\n\t}\n\n\thas(path: string): boolean\n\thas(paths: readonly string[]): boolean\n\thas(path: string | readonly string[]): boolean {\n\t\tif (isArray(path)) return path.every((one) => this.#files.has(one))\n\t\treturn this.#files.has(path)\n\t}\n\n\tsearch(query: string, options?: SearchOptions): readonly SearchMatch[] {\n\t\tconst pattern = this.#pattern(query, options)\n\t\tconst limit = options?.limit\n\t\tconst matches: SearchMatch[] = []\n\t\tfor (const file of this.#files.values()) {\n\t\t\tif (limit !== undefined && matches.length >= limit) break\n\t\t\tif (!isTextContent(file.content)) continue\n\t\t\tconst lines = file.content.text.split(/\\r\\n|\\n/)\n\t\t\tfor (const [index, lineText] of lines.entries()) {\n\t\t\t\tif (limit !== undefined && matches.length >= limit) break\n\t\t\t\tpattern.lastIndex = 0\n\t\t\t\tfor (const hit of lineText.matchAll(pattern)) {\n\t\t\t\t\tif (limit !== undefined && matches.length >= limit) break\n\t\t\t\t\tmatches.push({\n\t\t\t\t\t\tpath: file.path,\n\t\t\t\t\t\tline: index + 1,\n\t\t\t\t\t\tcolumn: hit.index + 1,\n\t\t\t\t\t\tlength: hit[0].length,\n\t\t\t\t\t\tcontent: lineText,\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn matches\n\t}\n\n\treplace(query: string, replacement: string, options?: SearchOptions): ReplaceResult {\n\t\tconst pattern = this.#pattern(query, options)\n\t\tconst limit = options?.limit\n\t\tconst changes: number[] = []\n\t\tfor (const [path, file] of this.#files) {\n\t\t\tconst occurrences = changes.reduce((total, count) => total + count, 0)\n\t\t\tif (limit !== undefined && occurrences >= limit) break\n\t\t\tif (!isTextContent(file.content)) continue\n\t\t\tconst remaining = limit === undefined ? undefined : limit - occurrences\n\t\t\tpattern.lastIndex = 0\n\t\t\tconst text = file.content.text\n\t\t\tconst matches = Array.from(text.matchAll(pattern))\n\t\t\tconst count = matches.filter(\n\t\t\t\t(_, index) => remaining === undefined || !(index >= remaining),\n\t\t\t).length\n\t\t\tconst positions = matches.keys()\n\t\t\tconst next = text.replace(pattern, (match) =>\n\t\t\t\t(positions.next().value ?? Number.POSITIVE_INFINITY) < count ? replacement : match,\n\t\t\t)\n\t\t\tif (count > 0) {\n\t\t\t\tchanges.push(count)\n\t\t\t\tthis.write(path, next)\n\t\t\t}\n\t\t}\n\t\treturn {\n\t\t\toccurrences: changes.reduce((total, count) => total + count, 0),\n\t\t\tfiles: changes.length,\n\t\t}\n\t}\n\n\twrite(path: string, content: string): void\n\twrite(path: string, content: string, range: Range): void\n\twrite(files: Readonly<Record<string, string>>): void\n\twrite(path: string | Readonly<Record<string, string>>, content?: string, range?: Range): void {\n\t\tif (isRecord(path)) {\n\t\t\tfor (const [one, text] of Object.entries(path)) this.#write(one, text)\n\t\t\treturn\n\t\t}\n\t\tif (content === undefined) return\n\t\tif (!range) {\n\t\t\tthis.#write(path, content)\n\t\t\treturn\n\t\t}\n\t\tthis.#splice(path, content, range)\n\t}\n\n\tprepend(path: string, content: string): void\n\tprepend(files: Readonly<Record<string, string>>): void\n\tprepend(path: string | Readonly<Record<string, string>>, content?: string): void {\n\t\tif (isRecord(path)) {\n\t\t\tfor (const [one, text] of Object.entries(path)) this.#prepend(one, text)\n\t\t\treturn\n\t\t}\n\t\tif (content === undefined) return\n\t\tthis.#prepend(path, content)\n\t}\n\n\tappend(path: string, content: string): void\n\tappend(files: Readonly<Record<string, string>>): void\n\tappend(path: string | Readonly<Record<string, string>>, content?: string): void {\n\t\tif (isRecord(path)) {\n\t\t\tfor (const [one, text] of Object.entries(path)) this.#append(one, text)\n\t\t\treturn\n\t\t}\n\t\tif (content === undefined) return\n\t\tthis.#append(path, content)\n\t}\n\n\tmove(from: string, to: string): boolean\n\tmove(mapping: Readonly<Record<string, string>>): boolean\n\tmove(from: string | Readonly<Record<string, string>>, to?: string): boolean {\n\t\tif (isRecord(from)) {\n\t\t\treturn Object.entries(from).reduce(\n\t\t\t\t(moved, [one, target]) => this.#move(one, target) && moved,\n\t\t\t\ttrue,\n\t\t\t)\n\t\t}\n\t\tif (to === undefined) return false\n\t\treturn this.#move(from, to)\n\t}\n\n\tremove(path: string): boolean\n\tremove(paths: readonly string[]): boolean\n\tremove(path: string | readonly string[]): boolean {\n\t\tif (isArray(path)) {\n\t\t\treturn Iterator.from(path).reduce((removed, one) => this.#remove(one) && removed, true)\n\t\t}\n\t\treturn this.#remove(path)\n\t}\n\n\tclear(): void {\n\t\tthis.#files.clear()\n\t\tthis.#emitter.emit('clear')\n\t}\n\n\tsnapshot(): WorkspaceSnapshot {\n\t\treturn { id: this.#id, files: this.files() }\n\t}\n\n\tdestroy(): void {\n\t\tthis.#emitter.destroy()\n\t}\n\n\t#write(path: string, content: string): void {\n\t\tconst existing = this.#files.get(path)\n\t\tconst language =\n\t\t\texisting && isTextContent(existing.content) ? existing.content.language : inferLanguage(path)\n\t\tconst file = createFile({\n\t\t\tpath,\n\t\t\tcontent: { text: content, language },\n\t\t\tstate: existing ? 'modified' : 'created',\n\t\t})\n\t\tthis.#files.set(path, file)\n\t\tthis.#emitter.emit('write', file)\n\t}\n\n\t#splice(path: string, content: string, range: Range): void {\n\t\tconst existing = this.#files.get(path)\n\t\tif (!existing) {\n\t\t\tthrow new WorkspaceError('MISSING', `Cannot splice a range of a missing file: ${path}`, {\n\t\t\t\tpath,\n\t\t\t})\n\t\t}\n\t\tif (!isTextContent(existing.content)) {\n\t\t\tthrow new WorkspaceError('MODALITY', `Cannot splice a range of a binary file: ${path}`, {\n\t\t\t\tpath,\n\t\t\t})\n\t\t}\n\t\tif (!isValidRange(range)) {\n\t\t\tthrow new WorkspaceError('RANGE', `Invalid range for file: ${path}`, { path, range })\n\t\t}\n\t\tconst file = createFile({\n\t\t\tpath,\n\t\t\tcontent: {\n\t\t\t\ttext: spliceRange(existing.content.text, range, content),\n\t\t\t\tlanguage: existing.content.language,\n\t\t\t},\n\t\t\tstate: 'modified',\n\t\t})\n\t\tthis.#files.set(path, file)\n\t\tthis.#emitter.emit('write', file)\n\t}\n\n\t#prepend(path: string, content: string): void {\n\t\tconst existing = this.#files.get(path)\n\t\tif (existing === undefined) {\n\t\t\tthis.#write(path, content)\n\t\t\treturn\n\t\t}\n\t\tif (!isTextContent(existing.content)) {\n\t\t\tthrow new WorkspaceError('MODALITY', `Cannot prepend text to a binary file: ${path}`, {\n\t\t\t\tpath,\n\t\t\t})\n\t\t}\n\t\tthis.#write(path, content + existing.content.text)\n\t}\n\n\t#append(path: string, content: string): void {\n\t\tconst existing = this.#files.get(path)\n\t\tif (existing === undefined) {\n\t\t\tthis.#write(path, content)\n\t\t\treturn\n\t\t}\n\t\tif (!isTextContent(existing.content)) {\n\t\t\tthrow new WorkspaceError('MODALITY', `Cannot append text to a binary file: ${path}`, {\n\t\t\t\tpath,\n\t\t\t})\n\t\t}\n\t\tthis.#write(path, existing.content.text + content)\n\t}\n\n\t#move(from: string, to: string): boolean {\n\t\tif (from === to) return false\n\t\tconst file = this.#files.get(from)\n\t\tif (!file) return false\n\t\tconst moved = createFile({ path: to, content: file.content, state: 'modified' })\n\t\tconst entries = [...this.#files]\n\t\tthis.#files.clear()\n\t\tfor (const [path, current] of entries) {\n\t\t\tif (path === from) this.#files.set(to, moved)\n\t\t\telse if (path !== to) this.#files.set(path, current)\n\t\t}\n\t\tthis.#emitter.emit('move', from, to)\n\t\treturn true\n\t}\n\n\t#remove(path: string): boolean {\n\t\tconst removed = this.#files.delete(path)\n\t\tif (removed) this.#emitter.emit('remove', path)\n\t\treturn removed\n\t}\n\n\t#pattern(query: string, options?: SearchOptions): RegExp {\n\t\tconst source = options?.regex === true ? query : escapeRegExp(query)\n\t\tconst flags = options?.sensitive === false ? 'gi' : 'g'\n\t\ttry {\n\t\t\treturn new RegExp(source, flags)\n\t\t} catch {\n\t\t\tthrow new WorkspaceError('PATTERN', `Invalid search pattern: ${query}`, { query })\n\t\t}\n\t}\n}\n","import type { EmitterErrorHandler, EmitterHooks } from '@orkestrel/emitter'\nimport type {\n\tWorkspaceEventMap,\n\tWorkspaceInterface,\n\tWorkspaceManagerInterface,\n\tWorkspaceManagerOptions,\n\tWorkspaceOptions,\n\tWorkspaceStoreInterface,\n} from '../types.js'\nimport { isArray } from '@orkestrel/contract'\nimport { Workspace } from './Workspace.js'\n\n/**\n * Implements `WorkspaceManagerInterface` over an insertion-ordered id map and one active id\n * the instance owns, resolving `active` through that map on every read and holding no emitter.\n *\n * A supplied store adds lenient snapshot `open` and `save` operations. Event defaults flow into\n * workspaces created through the registry, while observability remains owned by each workspace.\n *\n * @example\n * ```ts\n * import { WorkspaceManager } from '@orkestrel/workspace'\n *\n * const manager = new WorkspaceManager()\n * const workspace = manager.add({ id: 'scratch' })\n * manager.active === workspace\n * ```\n */\nexport class WorkspaceManager implements WorkspaceManagerInterface {\n\treadonly #workspaces = new Map<string, WorkspaceInterface>()\n\t#active: string | undefined\n\treadonly #on: EmitterHooks<WorkspaceEventMap> | undefined\n\treadonly #error: EmitterErrorHandler | undefined\n\treadonly #store: WorkspaceStoreInterface | undefined\n\n\t/**\n\t * Creates a registry.\n\t *\n\t * @param options - Default event hooks and optional snapshot store\n\t */\n\tconstructor(options?: WorkspaceManagerOptions) {\n\t\tthis.#on = options?.on\n\t\tthis.#error = options?.error\n\t\tthis.#store = options?.store\n\t}\n\n\tget count(): number {\n\t\treturn this.#workspaces.size\n\t}\n\n\tget active(): WorkspaceInterface | undefined {\n\t\treturn this.#active === undefined ? undefined : this.#workspaces.get(this.#active)\n\t}\n\n\tworkspace(id: string): WorkspaceInterface | undefined {\n\t\treturn this.#workspaces.get(id)\n\t}\n\n\tworkspaces(): readonly WorkspaceInterface[] {\n\t\treturn [...this.#workspaces.values()]\n\t}\n\n\tadd(options?: WorkspaceOptions): WorkspaceInterface {\n\t\tconst on = options?.on ?? this.#on\n\t\tconst error = options?.error ?? this.#error\n\t\tconst workspace = new Workspace({\n\t\t\t...(options?.id === undefined ? {} : { id: options.id }),\n\t\t\t...(on === undefined ? {} : { on }),\n\t\t\t...(error === undefined ? {} : { error }),\n\t\t\t...(options?.seed === undefined ? {} : { seed: options.seed }),\n\t\t})\n\t\tthis.#workspaces.set(workspace.id, workspace)\n\t\tif (this.#active === undefined) this.#active = workspace.id\n\t\treturn workspace\n\t}\n\n\tswitch(id: string): WorkspaceInterface | undefined {\n\t\tconst workspace = this.#workspaces.get(id)\n\t\tif (workspace === undefined) return undefined\n\t\tthis.#active = id\n\t\treturn workspace\n\t}\n\n\tasync open(id: string): Promise<WorkspaceInterface | undefined> {\n\t\tconst existing = this.#workspaces.get(id)\n\t\tif (existing !== undefined) {\n\t\t\tthis.#active = id\n\t\t\treturn existing\n\t\t}\n\t\tif (this.#store === undefined) return undefined\n\t\tconst snapshot = await this.#store.get(id)\n\t\tif (snapshot === undefined) return undefined\n\t\tconst workspace = this.add({ id, seed: snapshot.files })\n\t\tthis.#active = workspace.id\n\t\treturn workspace\n\t}\n\n\tasync save(id: string): Promise<boolean> {\n\t\tconst workspace = this.#workspaces.get(id)\n\t\tif (this.#store === undefined || workspace === undefined) return false\n\t\tawait this.#store.set(workspace.snapshot())\n\t\treturn true\n\t}\n\n\tremove(id: string): boolean\n\tremove(ids: readonly string[]): boolean\n\tremove(ids: string | readonly string[]): boolean {\n\t\tif (isArray(ids)) {\n\t\t\treturn Iterator.from(ids).reduce((removed, id) => this.#drop(id) && removed, true)\n\t\t}\n\t\treturn this.#drop(ids)\n\t}\n\n\tclear(): void {\n\t\tfor (const workspace of this.#workspaces.values()) workspace.destroy()\n\t\tthis.#workspaces.clear()\n\t\tthis.#active = undefined\n\t}\n\n\t#drop(id: string): boolean {\n\t\tconst workspace = this.#workspaces.get(id)\n\t\tif (workspace === undefined) return false\n\t\tthis.#workspaces.delete(id)\n\t\tworkspace.destroy()\n\t\tif (this.#active === id) this.#active = undefined\n\t\treturn true\n\t}\n}\n","import type {\n\tWorkspaceSnapshot,\n\tWorkspaceSnapshotRow,\n\tWorkspaceStoreInterface,\n} from '../../types.js'\nimport type { TableInterface } from '@orkestrel/database'\nimport { isWorkspaceSnapshot } from '../../validators.js'\n\n/**\n * Persists workspace snapshots in a database table.\n *\n * Snapshots occupy one opaque column and are narrowed when read back from the storage boundary.\n *\n * @example\n * ```ts\n * import { rawShape, stringShape } from '@orkestrel/contract'\n * import { createDatabase, createMemoryDriver } from '@orkestrel/database'\n * import { DatabaseWorkspaceStore } from '@orkestrel/workspace'\n *\n * const database = createDatabase({\n * \tdriver: createMemoryDriver(),\n * \ttables: { workspaces: { id: stringShape(), snapshot: rawShape({}) } },\n * })\n * const store = new DatabaseWorkspaceStore(database.table('workspaces'))\n * ```\n */\nexport class DatabaseWorkspaceStore implements WorkspaceStoreInterface {\n\treadonly #table: TableInterface<WorkspaceSnapshotRow>\n\n\t/**\n\t * Wraps a workspace snapshot table.\n\t *\n\t * @param table - The table keyed by workspace identifier\n\t */\n\tconstructor(table: TableInterface<WorkspaceSnapshotRow>) {\n\t\tthis.#table = table\n\t}\n\n\tasync get(id: string): Promise<WorkspaceSnapshot | undefined> {\n\t\tconst row = await this.#table.get(id)\n\t\tif (row === undefined) return undefined\n\t\treturn isWorkspaceSnapshot(row.snapshot) ? row.snapshot : undefined\n\t}\n\n\tasync set(snapshot: WorkspaceSnapshot): Promise<void> {\n\t\tawait this.#table.set({ id: snapshot.id, snapshot })\n\t}\n\n\tasync delete(id: string): Promise<void> {\n\t\tawait this.#table.remove(id)\n\t}\n}\n","import type { WorkspaceSnapshot, WorkspaceStoreInterface } from '../../types.js'\n\n/**\n * Holds workspace snapshots in the current process.\n *\n * @example\n * ```ts\n * import { MemoryWorkspaceStore } from '@orkestrel/workspace'\n *\n * const store = new MemoryWorkspaceStore()\n * ```\n */\nexport class MemoryWorkspaceStore implements WorkspaceStoreInterface {\n\treadonly #snapshots = new Map<string, WorkspaceSnapshot>()\n\n\tget(id: string): Promise<WorkspaceSnapshot | undefined> {\n\t\treturn Promise.resolve(this.#snapshots.get(id))\n\t}\n\n\tset(snapshot: WorkspaceSnapshot): Promise<void> {\n\t\tthis.#snapshots.set(snapshot.id, snapshot)\n\t\treturn Promise.resolve()\n\t}\n\n\tdelete(id: string): Promise<void> {\n\t\tthis.#snapshots.delete(id)\n\t\treturn Promise.resolve()\n\t}\n}\n","import type {\n\tBinaryContent,\n\tBinaryMIME,\n\tFileInput,\n\tFileInterface,\n\tTextContent,\n\tWorkspaceInterface,\n\tWorkspaceManagerInterface,\n\tWorkspaceManagerOptions,\n\tWorkspaceOptions,\n\tWorkspaceSnapshotRow,\n\tWorkspaceStoreInterface,\n} from './types.js'\nimport type { DriverInterface, TableInterface } from '@orkestrel/database'\nimport { rawShape, stringShape } from '@orkestrel/contract'\nimport { createDatabase, createMemoryDriver } from '@orkestrel/database'\nimport { computeSize, countLines } from './helpers.js'\nimport { Workspace } from './workspaces/Workspace.js'\nimport { WorkspaceManager } from './workspaces/WorkspaceManager.js'\nimport { DatabaseWorkspaceStore } from './workspaces/stores/DatabaseWorkspaceStore.js'\nimport { MemoryWorkspaceStore } from './workspaces/stores/MemoryWorkspaceStore.js'\n\n/**\n * Creates an immutable file with derived size and line counts.\n *\n * @param input - The file path, content, and optional state\n * @returns A frozen file record\n *\n * @example Files and content\n * ```ts\n * import {\n * \tcomputeSize,\n * \tcountLines,\n * \tcreateBinaryContent,\n * \tcreateFile,\n * \tcreateTextContent,\n * \tinferLanguage,\n * \tisBinary,\n * \tisTextContent,\n * } from '@orkestrel/workspace'\n *\n * const note = createFile({\n * \tpath: 'notes.md',\n * \tcontent: createTextContent('# Title\\nBody', inferLanguage('notes.md')), // 'markdown'\n * })\n *\n * note.size // 12 — UTF-8 bytes, through computeSize\n * note.lines // 2 — through countLines\n * note.state // 'created'\n * isTextContent(note.content) // true\n *\n * const icon = createFile({ path: 'icon.png', content: createBinaryContent('AAAA', 'image/png') })\n * isBinary(icon.content) // true\n * icon.size // 3 — decoded base64 bytes, through computeDecodedSize\n * ```\n */\nexport function createFile(input: FileInput): FileInterface {\n\treturn Object.freeze({\n\t\tpath: input.path,\n\t\tcontent: input.content,\n\t\tstate: input.state ?? 'created',\n\t\tsize: computeSize(input.content),\n\t\tlines: countLines(input.content),\n\t})\n}\n\n/**\n * Creates the text arm of {@link FileContent}, returned as {@link TextContent} rather than as\n * the whole union.\n *\n * @param text - The text body\n * @param language - The language tag\n * @returns Text file content\n *\n * @example\n * ```ts\n * import { createTextContent } from '@orkestrel/workspace'\n *\n * createTextContent('hello', 'text')\n * ```\n */\nexport function createTextContent(text: string, language: string): TextContent {\n\treturn { text, language }\n}\n\n/**\n * Creates the binary arm of {@link FileContent}, returned as {@link BinaryContent} rather than\n * as the whole union.\n *\n * @param base64 - The base64 payload\n * @param mime - The binary MIME\n * @returns Binary file content\n *\n * @example\n * ```ts\n * import { createBinaryContent } from '@orkestrel/workspace'\n *\n * createBinaryContent('AAAA', 'image/png')\n * ```\n */\nexport function createBinaryContent(base64: string, mime: BinaryMIME): BinaryContent {\n\treturn { base64, mime }\n}\n\n/**\n * Creates a workspace with the same identity, emitter, and seed options the constructor takes.\n *\n * @param options - Optional identity, emitter configuration, and initial files\n * @returns A working workspace\n *\n * @example\n * ```ts\n * import { createWorkspace } from '@orkestrel/workspace'\n *\n * const workspace = createWorkspace()\n * workspace.write('a.txt', 'hello')\n * ```\n */\nexport function createWorkspace(options?: WorkspaceOptions): WorkspaceInterface {\n\treturn new Workspace(options)\n}\n\n/**\n * Creates an in-memory workspace snapshot store.\n *\n * @returns A process-local workspace store\n *\n * @example\n * ```ts\n * import { createMemoryWorkspaceStore } from '@orkestrel/workspace'\n *\n * const store = createMemoryWorkspaceStore()\n * ```\n */\nexport function createMemoryWorkspaceStore(): WorkspaceStoreInterface {\n\treturn new MemoryWorkspaceStore()\n}\n\n/**\n * Creates a database-backed workspace snapshot store, over an in-memory driver when the caller\n * supplies none.\n *\n * @param driver - The database driver. Default: an in-memory driver.\n * @returns A workspace store backed by the supplied driver\n *\n * @example\n * ```ts\n * import { createDatabaseWorkspaceStore } from '@orkestrel/workspace'\n *\n * const store = createDatabaseWorkspaceStore()\n * ```\n */\nexport function createDatabaseWorkspaceStore(\n\tdriver: DriverInterface = createMemoryDriver(),\n): WorkspaceStoreInterface {\n\tconst columns = { id: stringShape(), snapshot: rawShape({}) }\n\tconst database = createDatabase({ driver, tables: { workspaces: columns } })\n\tconst table: TableInterface<WorkspaceSnapshotRow> = database.table('workspaces')\n\treturn new DatabaseWorkspaceStore(table)\n}\n\n/**\n * Creates an empty workspace registry.\n *\n * @param options - Default event hooks and optional durability\n * @returns A workspace manager\n *\n * @example\n * ```ts\n * import { createWorkspaceManager } from '@orkestrel/workspace'\n *\n * const manager = createWorkspaceManager()\n * manager.add()\n * ```\n */\nexport function createWorkspaceManager(\n\toptions?: WorkspaceManagerOptions,\n): WorkspaceManagerInterface {\n\treturn new WorkspaceManager(options)\n}\n"],"mappings":";;;;;;;;;;;AAMA,IAAa,sBAAwD,OAAO,OAAO;CAClF,IAAI;CACJ,KAAK;CACL,IAAI;CACJ,KAAK;CACL,KAAK;CACL,KAAK;CACL,MAAM;CACN,IAAI;CACJ,MAAM;CACN,KAAK;CACL,KAAK;CACL,MAAM;CACN,MAAM;CACN,MAAM;CACN,KAAK;CACL,QAAQ;CACR,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,MAAM;CACN,IAAI;CACJ,OAAO;CACP,GAAG;CACH,KAAK;CACL,GAAG;CACH,KAAK;CACL,IAAI;CACJ,KAAK;CACL,KAAK;CACL,IAAI;CACJ,MAAM;CACN,KAAK;CACL,KAAK;CACL,MAAM;CACN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AAE;EAAM;CAAS;AACzB;;;;;;;;;;;;;;;;AAiBA,SAAgB,oBAAoB,QAAgB,MAAiC;CACpF,OAAO;EAAE;EAAQ;CAAK;AACvB;;;;;;;;;;;;;;;AAgBA,SAAgB,gBAAgB,SAAgD;CAC/E,OAAO,IAAI,UAAU,OAAO;AAC7B;;;;;;;;;;;;;AAcA,SAAgB,6BAAsD;CACrE,OAAO,IAAI,qBAAqB;AACjC;;;;;;;;;;;;;;;AAgBA,SAAgB,6BACf,UAAA,GAA0BC,oBAAAA,mBAAAA,CAAmB,GACnB;CAC1B,MAAM,UAAU;EAAE,KAAA,GAAIC,oBAAAA,YAAAA,CAAY;EAAG,WAAA,GAAUC,oBAAAA,SAAAA,CAAS,CAAC,CAAC;CAAE;CAG5D,OAAO,IAAI,wBADL,GADWC,oBAAAA,eAAAA,CAAe;EAAE;EAAQ,QAAQ,EAAE,YAAY,QAAQ;CAAE,CACtB,CAAA,CAAS,MAAM,YACjC,CAAK;AACxC;;;;;;;;;;;;;;;AAgBA,SAAgB,uBACf,SAC4B;CAC5B,OAAO,IAAI,iBAAiB,OAAO;AACpC"}
@@ -13,22 +13,28 @@ export declare interface BinaryContent {
13
13
  /** Names the MIME labels a binary {@link FileContent} arm supports. */
14
14
  export declare type BinaryMIME = 'image/png' | 'image/jpeg' | 'image/gif' | 'image/webp';
15
15
 
16
+ /** Locates a 1-based caret inside text. */
17
+ export declare interface Caret {
18
+ readonly line: number;
19
+ readonly column: number;
20
+ }
21
+
16
22
  /**
17
- * Clamps a position to text bounds.
23
+ * Clamps a caret to text bounds.
18
24
  *
19
25
  * @param text - The addressed text
20
- * @param position - The requested position
21
- * @returns The clamped position
26
+ * @param caret - The requested caret
27
+ * @returns The clamped caret
22
28
  *
23
29
  * @example
24
30
  * ```ts
25
- * clampPosition('ab', { line: 9, column: 9 }) // { line: 1, column: 3 }
31
+ * clampCaret('ab', { line: 9, column: 9 }) // { line: 1, column: 3 }
26
32
  * ```
27
33
  */
28
- export declare function clampPosition(text: string, position: Position): Position;
34
+ export declare function clampCaret(text: string, caret: Caret): Caret;
29
35
 
30
36
  /**
31
- * Clamps both positions in a range to text bounds.
37
+ * Clamps both carets in a range to text bounds.
32
38
  *
33
39
  * @param text - The addressed text
34
40
  * @param range - The requested range
@@ -129,7 +135,7 @@ export declare function createDatabaseWorkspaceStore(driver?: DriverInterface):
129
135
  * createTextContent,
130
136
  * inferLanguage,
131
137
  * isBinary,
132
- * isText,
138
+ * isTextContent,
133
139
  * } from '@orkestrel/workspace'
134
140
  *
135
141
  * const note = createFile({
@@ -140,7 +146,7 @@ export declare function createDatabaseWorkspaceStore(driver?: DriverInterface):
140
146
  * note.size // 12 — UTF-8 bytes, through computeSize
141
147
  * note.lines // 2 — through countLines
142
148
  * note.state // 'created'
143
- * isText(note.content) // true
149
+ * isTextContent(note.content) // true
144
150
  *
145
151
  * const icon = createFile({ path: 'icon.png', content: createBinaryContent('AAAA', 'image/png') })
146
152
  * isBinary(icon.content) // true
@@ -243,19 +249,6 @@ export declare class DatabaseWorkspaceStore implements WorkspaceStoreInterface {
243
249
  delete(id: string): Promise<void>;
244
250
  }
245
251
 
246
- /**
247
- * Escapes regular-expression metacharacters for literal matching.
248
- *
249
- * @param value - The literal text
250
- * @returns The escaped regular-expression source
251
- *
252
- * @example
253
- * ```ts
254
- * escapeRegExp('a.b') // 'a\\.b'
255
- * ```
256
- */
257
- export declare function escapeRegExp(value: string): string;
258
-
259
252
  /**
260
253
  * Maps file extensions to language tags for text content.
261
254
  *
@@ -342,16 +335,16 @@ export declare function isFile(value: unknown): value is FileInterface;
342
335
  *
343
336
  * @example
344
337
  * ```ts
345
- * isText({ text: 'hello', language: 'text' }) // true
338
+ * isTextContent({ text: 'hello', language: 'text' }) // true
346
339
  * ```
347
340
  */
348
- export declare function isText(content: FileContent): content is TextContent;
341
+ export declare function isTextContent(content: FileContent): content is TextContent;
349
342
 
350
343
  /**
351
344
  * Determines whether a 1-based range is structurally valid.
352
345
  *
353
346
  * @param range - The range to inspect
354
- * @returns True if both positions are positive and ordered; false otherwise
347
+ * @returns True if both carets are positive and ordered; false otherwise
355
348
  *
356
349
  * @example
357
350
  * ```ts
@@ -408,10 +401,10 @@ export declare class MemoryWorkspaceStore implements WorkspaceStoreInterface {
408
401
  }
409
402
 
410
403
  /**
411
- * Converts a 1-based position to a zero-based string offset.
404
+ * Converts a 1-based caret to a zero-based string offset.
412
405
  *
413
406
  * @param text - The addressed text
414
- * @param position - The requested position
407
+ * @param caret - The requested caret
415
408
  * @returns The bounded string offset
416
409
  *
417
410
  * @example
@@ -419,18 +412,12 @@ export declare class MemoryWorkspaceStore implements WorkspaceStoreInterface {
419
412
  * offsetAt('ab\ncd', { line: 2, column: 1 }) // 3
420
413
  * ```
421
414
  */
422
- export declare function offsetAt(text: string, position: Position): number;
423
-
424
- /** Locates a 1-based caret inside text. */
425
- export declare interface Position {
426
- readonly line: number;
427
- readonly column: number;
428
- }
415
+ export declare function offsetAt(text: string, caret: Caret): number;
429
416
 
430
417
  /** Represents a half-open text span whose start is inclusive and end is exclusive. */
431
418
  export declare interface Range {
432
- readonly start: Position;
433
- readonly end: Position;
419
+ readonly start: Caret;
420
+ readonly end: Caret;
434
421
  }
435
422
 
436
423
  /**
@@ -13,22 +13,28 @@ export declare interface BinaryContent {
13
13
  /** Names the MIME labels a binary {@link FileContent} arm supports. */
14
14
  export declare type BinaryMIME = 'image/png' | 'image/jpeg' | 'image/gif' | 'image/webp';
15
15
 
16
+ /** Locates a 1-based caret inside text. */
17
+ export declare interface Caret {
18
+ readonly line: number;
19
+ readonly column: number;
20
+ }
21
+
16
22
  /**
17
- * Clamps a position to text bounds.
23
+ * Clamps a caret to text bounds.
18
24
  *
19
25
  * @param text - The addressed text
20
- * @param position - The requested position
21
- * @returns The clamped position
26
+ * @param caret - The requested caret
27
+ * @returns The clamped caret
22
28
  *
23
29
  * @example
24
30
  * ```ts
25
- * clampPosition('ab', { line: 9, column: 9 }) // { line: 1, column: 3 }
31
+ * clampCaret('ab', { line: 9, column: 9 }) // { line: 1, column: 3 }
26
32
  * ```
27
33
  */
28
- export declare function clampPosition(text: string, position: Position): Position;
34
+ export declare function clampCaret(text: string, caret: Caret): Caret;
29
35
 
30
36
  /**
31
- * Clamps both positions in a range to text bounds.
37
+ * Clamps both carets in a range to text bounds.
32
38
  *
33
39
  * @param text - The addressed text
34
40
  * @param range - The requested range
@@ -129,7 +135,7 @@ export declare function createDatabaseWorkspaceStore(driver?: DriverInterface):
129
135
  * createTextContent,
130
136
  * inferLanguage,
131
137
  * isBinary,
132
- * isText,
138
+ * isTextContent,
133
139
  * } from '@orkestrel/workspace'
134
140
  *
135
141
  * const note = createFile({
@@ -140,7 +146,7 @@ export declare function createDatabaseWorkspaceStore(driver?: DriverInterface):
140
146
  * note.size // 12 — UTF-8 bytes, through computeSize
141
147
  * note.lines // 2 — through countLines
142
148
  * note.state // 'created'
143
- * isText(note.content) // true
149
+ * isTextContent(note.content) // true
144
150
  *
145
151
  * const icon = createFile({ path: 'icon.png', content: createBinaryContent('AAAA', 'image/png') })
146
152
  * isBinary(icon.content) // true
@@ -243,19 +249,6 @@ export declare class DatabaseWorkspaceStore implements WorkspaceStoreInterface {
243
249
  delete(id: string): Promise<void>;
244
250
  }
245
251
 
246
- /**
247
- * Escapes regular-expression metacharacters for literal matching.
248
- *
249
- * @param value - The literal text
250
- * @returns The escaped regular-expression source
251
- *
252
- * @example
253
- * ```ts
254
- * escapeRegExp('a.b') // 'a\\.b'
255
- * ```
256
- */
257
- export declare function escapeRegExp(value: string): string;
258
-
259
252
  /**
260
253
  * Maps file extensions to language tags for text content.
261
254
  *
@@ -342,16 +335,16 @@ export declare function isFile(value: unknown): value is FileInterface;
342
335
  *
343
336
  * @example
344
337
  * ```ts
345
- * isText({ text: 'hello', language: 'text' }) // true
338
+ * isTextContent({ text: 'hello', language: 'text' }) // true
346
339
  * ```
347
340
  */
348
- export declare function isText(content: FileContent): content is TextContent;
341
+ export declare function isTextContent(content: FileContent): content is TextContent;
349
342
 
350
343
  /**
351
344
  * Determines whether a 1-based range is structurally valid.
352
345
  *
353
346
  * @param range - The range to inspect
354
- * @returns True if both positions are positive and ordered; false otherwise
347
+ * @returns True if both carets are positive and ordered; false otherwise
355
348
  *
356
349
  * @example
357
350
  * ```ts
@@ -408,10 +401,10 @@ export declare class MemoryWorkspaceStore implements WorkspaceStoreInterface {
408
401
  }
409
402
 
410
403
  /**
411
- * Converts a 1-based position to a zero-based string offset.
404
+ * Converts a 1-based caret to a zero-based string offset.
412
405
  *
413
406
  * @param text - The addressed text
414
- * @param position - The requested position
407
+ * @param caret - The requested caret
415
408
  * @returns The bounded string offset
416
409
  *
417
410
  * @example
@@ -419,18 +412,12 @@ export declare class MemoryWorkspaceStore implements WorkspaceStoreInterface {
419
412
  * offsetAt('ab\ncd', { line: 2, column: 1 }) // 3
420
413
  * ```
421
414
  */
422
- export declare function offsetAt(text: string, position: Position): number;
423
-
424
- /** Locates a 1-based caret inside text. */
425
- export declare interface Position {
426
- readonly line: number;
427
- readonly column: number;
428
- }
415
+ export declare function offsetAt(text: string, caret: Caret): number;
429
416
 
430
417
  /** Represents a half-open text span whose start is inclusive and end is exclusive. */
431
418
  export declare interface Range {
432
- readonly start: Position;
433
- readonly end: Position;
419
+ readonly start: Caret;
420
+ readonly end: Caret;
434
421
  }
435
422
 
436
423
  /**
@@ -1,4 +1,4 @@
1
- import { INTRINSICS, arrayOf, holds, isArray, isFunction, isNumber, isObject, isRecord, isString, literalOf, rawShape, stringShape } from "@orkestrel/contract";
1
+ import { INTRINSICS, arrayOf, escapeRegExp, holds, isArray, isFunction, isNumber, isObject, isRecord, isString, literalOf, rawShape, stringShape } from "@orkestrel/contract";
2
2
  import { createDatabase, createMemoryDriver } from "@orkestrel/database";
3
3
  import { Emitter } from "@orkestrel/emitter";
4
4
  // src/core/constants.ts
@@ -123,10 +123,10 @@ function inferLanguage(path) {
123
123
  *
124
124
  * @example
125
125
  * ```ts
126
- * isText({ text: 'hello', language: 'text' }) // true
126
+ * isTextContent({ text: 'hello', language: 'text' }) // true
127
127
  * ```
128
128
  */
129
- function isText(content) {
129
+ function isTextContent(content) {
130
130
  return "text" in content;
131
131
  }
132
132
  /**
@@ -155,7 +155,7 @@ function isBinary(content) {
155
155
  * ```
156
156
  */
157
157
  function computeSize(content) {
158
- if (isText(content)) return new TextEncoder().encode(content.text).length;
158
+ if (isTextContent(content)) return new TextEncoder().encode(content.text).length;
159
159
  return computeDecodedSize(content.base64);
160
160
  }
161
161
  /**
@@ -170,7 +170,7 @@ function computeSize(content) {
170
170
  * ```
171
171
  */
172
172
  function countLines(content) {
173
- if (!isText(content)) return 0;
173
+ if (!isTextContent(content)) return 0;
174
174
  if (content.text.length === 0) return 0;
175
175
  return content.text.split(/\r\n|\n/).length;
176
176
  }
@@ -193,7 +193,7 @@ function computeDecodedSize(base64) {
193
193
  * Determines whether a 1-based range is structurally valid.
194
194
  *
195
195
  * @param range - The range to inspect
196
- * @returns True if both positions are positive and ordered; false otherwise
196
+ * @returns True if both carets are positive and ordered; false otherwise
197
197
  *
198
198
  * @example
199
199
  * ```ts
@@ -207,28 +207,28 @@ function isValidRange(range) {
207
207
  return !(range.start.line === range.end.line && range.start.column > range.end.column);
208
208
  }
209
209
  /**
210
- * Clamps a position to text bounds.
210
+ * Clamps a caret to text bounds.
211
211
  *
212
212
  * @param text - The addressed text
213
- * @param position - The requested position
214
- * @returns The clamped position
213
+ * @param caret - The requested caret
214
+ * @returns The clamped caret
215
215
  *
216
216
  * @example
217
217
  * ```ts
218
- * clampPosition('ab', { line: 9, column: 9 }) // { line: 1, column: 3 }
218
+ * clampCaret('ab', { line: 9, column: 9 }) // { line: 1, column: 3 }
219
219
  * ```
220
220
  */
221
- function clampPosition(text, position) {
221
+ function clampCaret(text, caret) {
222
222
  const lines = text.split("\n");
223
- const line = Math.max(1, Math.min(position.line, lines.length));
223
+ const line = Math.max(1, Math.min(caret.line, lines.length));
224
224
  const lineText = lines[line - 1] ?? "";
225
225
  return {
226
226
  line,
227
- column: Math.max(1, Math.min(position.column, lineText.length + 1))
227
+ column: Math.max(1, Math.min(caret.column, lineText.length + 1))
228
228
  };
229
229
  }
230
230
  /**
231
- * Clamps both positions in a range to text bounds.
231
+ * Clamps both carets in a range to text bounds.
232
232
  *
233
233
  * @param text - The addressed text
234
234
  * @param range - The requested range
@@ -241,15 +241,15 @@ function clampPosition(text, position) {
241
241
  */
242
242
  function clampRange(text, range) {
243
243
  return {
244
- start: clampPosition(text, range.start),
245
- end: clampPosition(text, range.end)
244
+ start: clampCaret(text, range.start),
245
+ end: clampCaret(text, range.end)
246
246
  };
247
247
  }
248
248
  /**
249
- * Converts a 1-based position to a zero-based string offset.
249
+ * Converts a 1-based caret to a zero-based string offset.
250
250
  *
251
251
  * @param text - The addressed text
252
- * @param position - The requested position
252
+ * @param caret - The requested caret
253
253
  * @returns The bounded string offset
254
254
  *
255
255
  * @example
@@ -257,9 +257,9 @@ function clampRange(text, range) {
257
257
  * offsetAt('ab\ncd', { line: 2, column: 1 }) // 3
258
258
  * ```
259
259
  */
260
- function offsetAt(text, position) {
261
- const offset = text.split("\n").filter((_, index) => index < position.line - 1).reduce((total, line) => total + line.length + 1, 0);
262
- return Math.min(offset + (position.column - 1), text.length);
260
+ function offsetAt(text, caret) {
261
+ const offset = text.split("\n").filter((_, index) => index < caret.line - 1).reduce((total, line) => total + line.length + 1, 0);
262
+ return Math.min(offset + (caret.column - 1), text.length);
263
263
  }
264
264
  /**
265
265
  * Slices a clamped half-open text range.
@@ -322,20 +322,6 @@ function rangeOf(fromLine, fromColumn, toLine, toColumn) {
322
322
  }
323
323
  };
324
324
  }
325
- /**
326
- * Escapes regular-expression metacharacters for literal matching.
327
- *
328
- * @param value - The literal text
329
- * @returns The escaped regular-expression source
330
- *
331
- * @example
332
- * ```ts
333
- * escapeRegExp('a.b') // 'a\\.b'
334
- * ```
335
- */
336
- function escapeRegExp(value) {
337
- return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
338
- }
339
325
  // src/core/validators.ts
340
326
  /**
341
327
  * Narrows an unknown value to an immutable file record.
@@ -429,14 +415,14 @@ var Workspace = class {
429
415
  const result = {};
430
416
  for (const one of path) {
431
417
  const file = this.#files.get(one);
432
- if (file && isText(file.content)) result[one] = file.content.text;
418
+ if (file && isTextContent(file.content)) result[one] = file.content.text;
433
419
  }
434
420
  return result;
435
421
  }
436
422
  const file = this.#files.get(path);
437
423
  if (!file) return void 0;
438
- if (!range) return isText(file.content) ? file.content.text : void 0;
439
- if (!isText(file.content)) throw new WorkspaceError("MODALITY", `Cannot read a range of a binary file: ${path}`, { path });
424
+ if (!range) return isTextContent(file.content) ? file.content.text : void 0;
425
+ if (!isTextContent(file.content)) throw new WorkspaceError("MODALITY", `Cannot read a range of a binary file: ${path}`, { path });
440
426
  return {
441
427
  content: sliceRange(file.content.text, range),
442
428
  range: clampRange(file.content.text, range)
@@ -452,7 +438,7 @@ var Workspace = class {
452
438
  const matches = [];
453
439
  for (const file of this.#files.values()) {
454
440
  if (limit !== void 0 && matches.length >= limit) break;
455
- if (!isText(file.content)) continue;
441
+ if (!isTextContent(file.content)) continue;
456
442
  const lines = file.content.text.split(/\r\n|\n/);
457
443
  for (const [index, lineText] of lines.entries()) {
458
444
  if (limit !== void 0 && matches.length >= limit) break;
@@ -478,7 +464,7 @@ var Workspace = class {
478
464
  for (const [path, file] of this.#files) {
479
465
  const occurrences = changes.reduce((total, count) => total + count, 0);
480
466
  if (limit !== void 0 && occurrences >= limit) break;
481
- if (!isText(file.content)) continue;
467
+ if (!isTextContent(file.content)) continue;
482
468
  const remaining = limit === void 0 ? void 0 : limit - occurrences;
483
469
  pattern.lastIndex = 0;
484
470
  const text = file.content.text;
@@ -552,7 +538,7 @@ var Workspace = class {
552
538
  path,
553
539
  content: {
554
540
  text: content,
555
- language: existing && isText(existing.content) ? existing.content.language : inferLanguage(path)
541
+ language: existing && isTextContent(existing.content) ? existing.content.language : inferLanguage(path)
556
542
  },
557
543
  state: existing ? "modified" : "created"
558
544
  });
@@ -562,7 +548,7 @@ var Workspace = class {
562
548
  #splice(path, content, range) {
563
549
  const existing = this.#files.get(path);
564
550
  if (!existing) throw new WorkspaceError("MISSING", `Cannot splice a range of a missing file: ${path}`, { path });
565
- if (!isText(existing.content)) throw new WorkspaceError("MODALITY", `Cannot splice a range of a binary file: ${path}`, { path });
551
+ if (!isTextContent(existing.content)) throw new WorkspaceError("MODALITY", `Cannot splice a range of a binary file: ${path}`, { path });
566
552
  if (!isValidRange(range)) throw new WorkspaceError("RANGE", `Invalid range for file: ${path}`, {
567
553
  path,
568
554
  range
@@ -584,7 +570,7 @@ var Workspace = class {
584
570
  this.#write(path, content);
585
571
  return;
586
572
  }
587
- if (!isText(existing.content)) throw new WorkspaceError("MODALITY", `Cannot prepend text to a binary file: ${path}`, { path });
573
+ if (!isTextContent(existing.content)) throw new WorkspaceError("MODALITY", `Cannot prepend text to a binary file: ${path}`, { path });
588
574
  this.#write(path, content + existing.content.text);
589
575
  }
590
576
  #append(path, content) {
@@ -593,7 +579,7 @@ var Workspace = class {
593
579
  this.#write(path, content);
594
580
  return;
595
581
  }
596
- if (!isText(existing.content)) throw new WorkspaceError("MODALITY", `Cannot append text to a binary file: ${path}`, { path });
582
+ if (!isTextContent(existing.content)) throw new WorkspaceError("MODALITY", `Cannot append text to a binary file: ${path}`, { path });
597
583
  this.#write(path, existing.content.text + content);
598
584
  }
599
585
  #move(from, to) {
@@ -817,7 +803,7 @@ var MemoryWorkspaceStore = class {
817
803
  * createTextContent,
818
804
  * inferLanguage,
819
805
  * isBinary,
820
- * isText,
806
+ * isTextContent,
821
807
  * } from '@orkestrel/workspace'
822
808
  *
823
809
  * const note = createFile({
@@ -828,7 +814,7 @@ var MemoryWorkspaceStore = class {
828
814
  * note.size // 12 — UTF-8 bytes, through computeSize
829
815
  * note.lines // 2 — through countLines
830
816
  * note.state // 'created'
831
- * isText(note.content) // true
817
+ * isTextContent(note.content) // true
832
818
  *
833
819
  * const icon = createFile({ path: 'icon.png', content: createBinaryContent('AAAA', 'image/png') })
834
820
  * isBinary(icon.content) // true
@@ -959,6 +945,6 @@ function createDatabaseWorkspaceStore(driver = createMemoryDriver()) {
959
945
  function createWorkspaceManager(options) {
960
946
  return new WorkspaceManager(options);
961
947
  }
962
- export { DatabaseWorkspaceStore, EXTENSION_LANGUAGES, MemoryWorkspaceStore, Workspace, WorkspaceError, WorkspaceManager, clampPosition, clampRange, computeDecodedSize, computeSize, countLines, createBinaryContent, createDatabaseWorkspaceStore, createFile, createMemoryWorkspaceStore, createTextContent, createWorkspace, createWorkspaceManager, escapeRegExp, inferLanguage, isBinary, isFile, isText, isValidRange, isWorkspaceError, isWorkspaceSnapshot, offsetAt, rangeOf, sliceRange, spliceRange };
948
+ export { DatabaseWorkspaceStore, EXTENSION_LANGUAGES, MemoryWorkspaceStore, Workspace, WorkspaceError, WorkspaceManager, clampCaret, clampRange, computeDecodedSize, computeSize, countLines, createBinaryContent, createDatabaseWorkspaceStore, createFile, createMemoryWorkspaceStore, createTextContent, createWorkspace, createWorkspaceManager, inferLanguage, isBinary, isFile, isTextContent, isValidRange, isWorkspaceError, isWorkspaceSnapshot, offsetAt, rangeOf, sliceRange, spliceRange };
963
949
 
964
950
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../../src/core/constants.ts","../../../src/core/errors.ts","../../../src/core/helpers.ts","../../../src/core/validators.ts","../../../src/core/workspaces/Workspace.ts","../../../src/core/workspaces/WorkspaceManager.ts","../../../src/core/workspaces/stores/DatabaseWorkspaceStore.ts","../../../src/core/workspaces/stores/MemoryWorkspaceStore.ts","../../../src/core/factories.ts"],"sourcesContent":["/**\n * Maps file extensions to language tags for text content.\n *\n * The table is frozen, and an extension it does not list falls back to `text` in\n * {@link import('./helpers.js').inferLanguage}.\n */\nexport const EXTENSION_LANGUAGES: Readonly<Record<string, string>> = Object.freeze({\n\tts: 'typescript',\n\ttsx: 'typescript',\n\tjs: 'javascript',\n\tjsx: 'javascript',\n\tmjs: 'javascript',\n\tcjs: 'javascript',\n\tjson: 'json',\n\tmd: 'markdown',\n\thtml: 'html',\n\thtm: 'html',\n\tcss: 'css',\n\tscss: 'scss',\n\tsass: 'sass',\n\tless: 'less',\n\tvue: 'vue',\n\tsvelte: 'svelte',\n\tpy: 'python',\n\trb: 'ruby',\n\trs: 'rust',\n\tgo: 'go',\n\tjava: 'java',\n\tkt: 'kotlin',\n\tswift: 'swift',\n\tc: 'c',\n\tcpp: 'cpp',\n\th: 'c',\n\thpp: 'cpp',\n\tcs: 'csharp',\n\tphp: 'php',\n\tsql: 'sql',\n\tsh: 'bash',\n\tbash: 'bash',\n\tzsh: 'bash',\n\tps1: 'powershell',\n\tyaml: 'yaml',\n\tyml: 'yaml',\n\ttoml: 'toml',\n\txml: 'xml',\n\tsvg: 'xml',\n\ttxt: 'text',\n})\n","import type { WorkspaceErrorCode } from './types.js'\nimport { holds, INTRINSICS, isFunction, isObject } from '@orkestrel/contract'\n\n/**\n * Reports an invalid workspace edit or search operation, carrying a {@link WorkspaceErrorCode}\n * and, when the operation had one, the context it ran under.\n */\nexport class WorkspaceError extends Error {\n\treadonly code: WorkspaceErrorCode\n\treadonly context?: Readonly<Record<string, unknown>>\n\n\t/**\n\t * Creates a workspace error.\n\t *\n\t * @param code - The machine-readable failure code\n\t * @param message - The human-readable failure message\n\t * @param context - Optional values associated with the failed operation\n\t */\n\tconstructor(\n\t\tcode: WorkspaceErrorCode,\n\t\tmessage: string,\n\t\tcontext?: Readonly<Record<string, unknown>>,\n\t) {\n\t\tsuper(message)\n\t\tINTRINSICS.define(this, Symbol.for('@orkestrel/workspace.WorkspaceError'), { value: this })\n\t\tthis.name = 'WorkspaceError'\n\t\tthis.code = code\n\t\tif (context !== undefined) this.context = context\n\t}\n}\n\n/**\n * Narrows a caught value to a {@link WorkspaceError}.\n *\n * @remarks\n * Checks the identity brand and declared members across package copies, accepting subclasses\n * and refusing transparent proxies. Inspection failures return false.\n *\n * @param value - The caught value\n * @returns True if the value is a workspace error; false otherwise\n *\n * @example\n * ```ts\n * if (isWorkspaceError(error)) error.code\n * ```\n */\nexport function isWorkspaceError(value: unknown): value is WorkspaceError {\n\treturn holds(() => {\n\t\tif (!(value instanceof Error) || INTRINSICS.prototype(value) === Error.prototype) return false\n\t\tconst brand = INTRINSICS.describe(value, Symbol.for('@orkestrel/workspace.WorkspaceError'))\n\t\tif (brand?.value !== value) return false\n\t\tconst code: unknown = INTRINSICS.reflect.read(value, 'code')\n\t\tif (code !== 'MISSING' && code !== 'MODALITY' && code !== 'PATTERN' && code !== 'RANGE')\n\t\t\treturn false\n\t\tconst context: unknown = INTRINSICS.reflect.read(value, 'context')\n\t\treturn context === undefined || isObject(context) || isFunction(context)\n\t})\n}\n","import type { BinaryContent, FileContent, Position, Range, TextContent } from './types.js'\nimport { EXTENSION_LANGUAGES } from './constants.js'\n\n/**\n * Infers a language tag from the final file extension.\n *\n * @param path - The file path\n * @returns The mapped language, or `text` when the extension is absent or unknown\n *\n * @example\n * ```ts\n * inferLanguage('src/main.ts') // 'typescript'\n * ```\n */\nexport function inferLanguage(path: string): string {\n\tconst dot = path.lastIndexOf('.')\n\tif (dot === -1) return 'text'\n\tconst extension = path.slice(dot + 1).toLowerCase()\n\treturn EXTENSION_LANGUAGES[extension] ?? 'text'\n}\n\n/**\n * Determines whether content is the text arm.\n *\n * @param content - The file content\n * @returns True if the content carries text and a language; false otherwise\n *\n * @example\n * ```ts\n * isText({ text: 'hello', language: 'text' }) // true\n * ```\n */\nexport function isText(content: FileContent): content is TextContent {\n\treturn 'text' in content\n}\n\n/**\n * Determines whether content is the binary arm.\n *\n * @param content - The file content\n * @returns True if the content carries a base64 string and a MIME; false otherwise\n *\n * @example\n * ```ts\n * isBinary({ base64: 'AAAA', mime: 'image/png' }) // true\n * ```\n */\nexport function isBinary(content: FileContent): content is BinaryContent {\n\treturn 'base64' in content\n}\n\n/**\n * Computes the byte size of file content.\n *\n * @param content - The content to measure\n * @returns UTF-8 bytes for text or decoded bytes for binary content\n *\n * @example\n * ```ts\n * computeSize({ text: 'café', language: 'text' }) // 5\n * ```\n */\nexport function computeSize(content: FileContent): number {\n\tif (isText(content)) return new TextEncoder().encode(content.text).length\n\treturn computeDecodedSize(content.base64)\n}\n\n/**\n * Counts the lines in file content.\n *\n * @param content - The content to inspect\n * @returns The text line count, or zero for empty text and binary content\n *\n * @example\n * ```ts\n * countLines({ text: 'a\\nb', language: 'text' }) // 2\n * ```\n */\nexport function countLines(content: FileContent): number {\n\tif (!isText(content)) return 0\n\tif (content.text.length === 0) return 0\n\treturn content.text.split(/\\r\\n|\\n/).length\n}\n\n/**\n * Computes the decoded byte length of a base64 string, arithmetically rather than by decoding it.\n *\n * @param base64 - The base64 string\n * @returns The decoded byte count\n *\n * @example\n * ```ts\n * computeDecodedSize('AAAA') // 3\n * ```\n */\nexport function computeDecodedSize(base64: string): number {\n\tconst padding = base64.endsWith('==') ? 2 : base64.endsWith('=') ? 1 : 0\n\treturn Math.floor((base64.length * 3) / 4) - padding\n}\n\n/**\n * Determines whether a 1-based range is structurally valid.\n *\n * @param range - The range to inspect\n * @returns True if both positions are positive and ordered; false otherwise\n *\n * @example\n * ```ts\n * isValidRange({ start: { line: 1, column: 1 }, end: { line: 1, column: 2 } }) // true\n * ```\n */\nexport function isValidRange(range: Range): boolean {\n\tif (range.start.line < 1 || range.start.column < 1) return false\n\tif (range.end.line < 1 || range.end.column < 1) return false\n\tif (range.start.line > range.end.line) return false\n\treturn !(range.start.line === range.end.line && range.start.column > range.end.column)\n}\n\n/**\n * Clamps a position to text bounds.\n *\n * @param text - The addressed text\n * @param position - The requested position\n * @returns The clamped position\n *\n * @example\n * ```ts\n * clampPosition('ab', { line: 9, column: 9 }) // { line: 1, column: 3 }\n * ```\n */\nexport function clampPosition(text: string, position: Position): Position {\n\tconst lines = text.split('\\n')\n\tconst line = Math.max(1, Math.min(position.line, lines.length))\n\tconst lineText = lines[line - 1] ?? ''\n\tconst column = Math.max(1, Math.min(position.column, lineText.length + 1))\n\treturn { line, column }\n}\n\n/**\n * Clamps both positions in a range to text bounds.\n *\n * @param text - The addressed text\n * @param range - The requested range\n * @returns The clamped range\n *\n * @example\n * ```ts\n * clampRange('ab', { start: { line: 1, column: 1 }, end: { line: 9, column: 9 } })\n * ```\n */\nexport function clampRange(text: string, range: Range): Range {\n\treturn { start: clampPosition(text, range.start), end: clampPosition(text, range.end) }\n}\n\n/**\n * Converts a 1-based position to a zero-based string offset.\n *\n * @param text - The addressed text\n * @param position - The requested position\n * @returns The bounded string offset\n *\n * @example\n * ```ts\n * offsetAt('ab\\ncd', { line: 2, column: 1 }) // 3\n * ```\n */\nexport function offsetAt(text: string, position: Position): number {\n\tconst lines = text.split('\\n')\n\tconst offset = lines\n\t\t.filter((_, index) => index < position.line - 1)\n\t\t.reduce((total, line) => total + line.length + 1, 0)\n\treturn Math.min(offset + (position.column - 1), text.length)\n}\n\n/**\n * Slices a clamped half-open text range.\n *\n * @param text - The source text\n * @param range - The requested range\n * @returns The ranged substring\n *\n * @example\n * ```ts\n * sliceRange('hello', { start: { line: 1, column: 1 }, end: { line: 1, column: 6 } }) // 'hello'\n * ```\n */\nexport function sliceRange(text: string, range: Range): string {\n\tconst clamped = clampRange(text, range)\n\treturn text.slice(offsetAt(text, clamped.start), offsetAt(text, clamped.end))\n}\n\n/**\n * Replaces a clamped half-open text range.\n *\n * @param text - The source text\n * @param range - The requested range\n * @param replacement - The replacement text\n * @returns The spliced text\n *\n * @example\n * ```ts\n * spliceRange('hello', { start: { line: 1, column: 1 }, end: { line: 1, column: 6 } }, 'bye')\n * ```\n */\nexport function spliceRange(text: string, range: Range, replacement: string): string {\n\tconst clamped = clampRange(text, range)\n\tconst start = offsetAt(text, clamped.start)\n\tconst end = offsetAt(text, clamped.end)\n\treturn text.slice(0, start) + replacement + text.slice(end)\n}\n\n/**\n * Assembles a nested range from four 1-based coordinates.\n *\n * @param fromLine - The start line\n * @param fromColumn - The start column\n * @param toLine - The end line\n * @param toColumn - The end column\n * @returns The assembled range without validation\n *\n * @example\n * ```ts\n * rangeOf(1, 1, 1, 2)\n * ```\n */\nexport function rangeOf(\n\tfromLine: number,\n\tfromColumn: number,\n\ttoLine: number,\n\ttoColumn: number,\n): Range {\n\treturn { start: { line: fromLine, column: fromColumn }, end: { line: toLine, column: toColumn } }\n}\n\n/**\n * Escapes regular-expression metacharacters for literal matching.\n *\n * @param value - The literal text\n * @returns The escaped regular-expression source\n *\n * @example\n * ```ts\n * escapeRegExp('a.b') // 'a\\\\.b'\n * ```\n */\nexport function escapeRegExp(value: string): string {\n\treturn value.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')\n}\n","import type { FileInterface, WorkspaceSnapshot } from './types.js'\nimport { arrayOf, holds, isNumber, isRecord, isString, literalOf } from '@orkestrel/contract'\n\n/**\n * Narrows an unknown value to an immutable file record.\n *\n * @param value - The value to inspect\n * @returns True if the value has the file shape; false otherwise\n *\n * @example\n * ```ts\n * isFile({ path: 'a.txt', content: { text: 'a', language: 'text' }, state: 'created', size: 1, lines: 1 })\n * ```\n */\nexport function isFile(value: unknown): value is FileInterface {\n\treturn holds(() => {\n\t\tif (!isRecord(value)) return false\n\t\tif (!isString(value.path) || !literalOf('created', 'modified')(value.state)) return false\n\t\tif (!isNumber(value.size) || !isNumber(value.lines)) return false\n\t\tif (!isRecord(value.content)) return false\n\t\tconst text = isString(value.content.text) && isString(value.content.language)\n\t\tconst binary =\n\t\t\tisString(value.content.base64) &&\n\t\t\tliteralOf('image/png', 'image/jpeg', 'image/gif', 'image/webp')(value.content.mime)\n\t\treturn text || binary\n\t})\n}\n\n/**\n * Narrows an unknown value to a workspace snapshot.\n *\n * @param value - The value read from a persistence boundary\n * @returns True if the value has the workspace snapshot shape; false otherwise\n *\n * @example\n * ```ts\n * isWorkspaceSnapshot({ id: 'work', files: [] }) // true\n * ```\n */\nexport function isWorkspaceSnapshot(value: unknown): value is WorkspaceSnapshot {\n\treturn holds(() => isRecord(value) && isString(value.id) && arrayOf(isFile)(value.files))\n}\n","import type { EmitterInterface } from '@orkestrel/emitter'\nimport type {\n\tFileInterface,\n\tRange,\n\tReadResult,\n\tReplaceResult,\n\tSearchMatch,\n\tSearchOptions,\n\tWorkspaceEventMap,\n\tWorkspaceInterface,\n\tWorkspaceOptions,\n\tWorkspaceSnapshot,\n} from '../types.js'\nimport { isArray, isRecord } from '@orkestrel/contract'\nimport { Emitter } from '@orkestrel/emitter'\nimport { WorkspaceError } from '../errors.js'\nimport { createFile } from '../factories.js'\nimport {\n\tclampRange,\n\tescapeRegExp,\n\tinferLanguage,\n\tisText,\n\tisValidRange,\n\tsliceRange,\n\tspliceRange,\n} from '../helpers.js'\n\n/**\n * Implements `WorkspaceInterface` over one insertion-ordered path map the instance owns,\n * projecting fresh arrays on every read.\n *\n * Whole-file edits create text files, ranged edits operate only on existing text files, and\n * binary files remain available through construction-time hydration. Mutations emit after the\n * file map has changed.\n *\n * @example\n * ```ts\n * import { Workspace } from '@orkestrel/workspace'\n *\n * const workspace = new Workspace()\n * workspace.write('notes.txt', 'hello')\n * workspace.append('notes.txt', ' world')\n * workspace.read('notes.txt') // 'hello world'\n * ```\n */\nexport class Workspace implements WorkspaceInterface {\n\treadonly #id: string\n\treadonly #files = new Map<string, FileInterface>()\n\treadonly #emitter: Emitter<WorkspaceEventMap>\n\n\t/**\n\t * Creates a workspace.\n\t *\n\t * @param options - Optional identity, emitter configuration, and initial files\n\t */\n\tconstructor(options?: WorkspaceOptions) {\n\t\tthis.#id = options?.id ?? crypto.randomUUID()\n\t\tthis.#emitter = new Emitter<WorkspaceEventMap>({\n\t\t\t...(options?.on === undefined ? {} : { on: options.on }),\n\t\t\t...(options?.error === undefined ? {} : { error: options.error }),\n\t\t})\n\t\tif (options?.seed) for (const file of options.seed) this.#files.set(file.path, file)\n\t}\n\n\tget id(): string {\n\t\treturn this.#id\n\t}\n\n\tget emitter(): EmitterInterface<WorkspaceEventMap> {\n\t\treturn this.#emitter\n\t}\n\n\tget count(): number {\n\t\treturn this.#files.size\n\t}\n\n\tfile(path: string): FileInterface | undefined {\n\t\treturn this.#files.get(path)\n\t}\n\n\tfiles(): readonly FileInterface[] {\n\t\treturn [...this.#files.values()]\n\t}\n\n\tread(path: string): string | undefined\n\tread(path: string, range: Range): ReadResult | undefined\n\tread(paths: readonly string[]): Readonly<Record<string, string>>\n\tread(\n\t\tpath: string | readonly string[],\n\t\trange?: Range,\n\t): string | ReadResult | undefined | Readonly<Record<string, string>> {\n\t\tif (isArray(path)) {\n\t\t\tconst result: Record<string, string> = {}\n\t\t\tfor (const one of path) {\n\t\t\t\tconst file = this.#files.get(one)\n\t\t\t\tif (file && isText(file.content)) result[one] = file.content.text\n\t\t\t}\n\t\t\treturn result\n\t\t}\n\t\tconst file = this.#files.get(path)\n\t\tif (!file) return undefined\n\t\tif (!range) return isText(file.content) ? file.content.text : undefined\n\t\tif (!isText(file.content)) {\n\t\t\tthrow new WorkspaceError('MODALITY', `Cannot read a range of a binary file: ${path}`, {\n\t\t\t\tpath,\n\t\t\t})\n\t\t}\n\t\treturn {\n\t\t\tcontent: sliceRange(file.content.text, range),\n\t\t\trange: clampRange(file.content.text, range),\n\t\t}\n\t}\n\n\thas(path: string): boolean\n\thas(paths: readonly string[]): boolean\n\thas(path: string | readonly string[]): boolean {\n\t\tif (isArray(path)) return path.every((one) => this.#files.has(one))\n\t\treturn this.#files.has(path)\n\t}\n\n\tsearch(query: string, options?: SearchOptions): readonly SearchMatch[] {\n\t\tconst pattern = this.#pattern(query, options)\n\t\tconst limit = options?.limit\n\t\tconst matches: SearchMatch[] = []\n\t\tfor (const file of this.#files.values()) {\n\t\t\tif (limit !== undefined && matches.length >= limit) break\n\t\t\tif (!isText(file.content)) continue\n\t\t\tconst lines = file.content.text.split(/\\r\\n|\\n/)\n\t\t\tfor (const [index, lineText] of lines.entries()) {\n\t\t\t\tif (limit !== undefined && matches.length >= limit) break\n\t\t\t\tpattern.lastIndex = 0\n\t\t\t\tfor (const hit of lineText.matchAll(pattern)) {\n\t\t\t\t\tif (limit !== undefined && matches.length >= limit) break\n\t\t\t\t\tmatches.push({\n\t\t\t\t\t\tpath: file.path,\n\t\t\t\t\t\tline: index + 1,\n\t\t\t\t\t\tcolumn: hit.index + 1,\n\t\t\t\t\t\tlength: hit[0].length,\n\t\t\t\t\t\tcontent: lineText,\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn matches\n\t}\n\n\treplace(query: string, replacement: string, options?: SearchOptions): ReplaceResult {\n\t\tconst pattern = this.#pattern(query, options)\n\t\tconst limit = options?.limit\n\t\tconst changes: number[] = []\n\t\tfor (const [path, file] of this.#files) {\n\t\t\tconst occurrences = changes.reduce((total, count) => total + count, 0)\n\t\t\tif (limit !== undefined && occurrences >= limit) break\n\t\t\tif (!isText(file.content)) continue\n\t\t\tconst remaining = limit === undefined ? undefined : limit - occurrences\n\t\t\tpattern.lastIndex = 0\n\t\t\tconst text = file.content.text\n\t\t\tconst matches = Array.from(text.matchAll(pattern))\n\t\t\tconst count = matches.filter(\n\t\t\t\t(_, index) => remaining === undefined || !(index >= remaining),\n\t\t\t).length\n\t\t\tconst positions = matches.keys()\n\t\t\tconst next = text.replace(pattern, (match) =>\n\t\t\t\t(positions.next().value ?? Number.POSITIVE_INFINITY) < count ? replacement : match,\n\t\t\t)\n\t\t\tif (count > 0) {\n\t\t\t\tchanges.push(count)\n\t\t\t\tthis.write(path, next)\n\t\t\t}\n\t\t}\n\t\treturn {\n\t\t\toccurrences: changes.reduce((total, count) => total + count, 0),\n\t\t\tfiles: changes.length,\n\t\t}\n\t}\n\n\twrite(path: string, content: string): void\n\twrite(path: string, content: string, range: Range): void\n\twrite(files: Readonly<Record<string, string>>): void\n\twrite(path: string | Readonly<Record<string, string>>, content?: string, range?: Range): void {\n\t\tif (isRecord(path)) {\n\t\t\tfor (const [one, text] of Object.entries(path)) this.#write(one, text)\n\t\t\treturn\n\t\t}\n\t\tif (content === undefined) return\n\t\tif (!range) {\n\t\t\tthis.#write(path, content)\n\t\t\treturn\n\t\t}\n\t\tthis.#splice(path, content, range)\n\t}\n\n\tprepend(path: string, content: string): void\n\tprepend(files: Readonly<Record<string, string>>): void\n\tprepend(path: string | Readonly<Record<string, string>>, content?: string): void {\n\t\tif (isRecord(path)) {\n\t\t\tfor (const [one, text] of Object.entries(path)) this.#prepend(one, text)\n\t\t\treturn\n\t\t}\n\t\tif (content === undefined) return\n\t\tthis.#prepend(path, content)\n\t}\n\n\tappend(path: string, content: string): void\n\tappend(files: Readonly<Record<string, string>>): void\n\tappend(path: string | Readonly<Record<string, string>>, content?: string): void {\n\t\tif (isRecord(path)) {\n\t\t\tfor (const [one, text] of Object.entries(path)) this.#append(one, text)\n\t\t\treturn\n\t\t}\n\t\tif (content === undefined) return\n\t\tthis.#append(path, content)\n\t}\n\n\tmove(from: string, to: string): boolean\n\tmove(mapping: Readonly<Record<string, string>>): boolean\n\tmove(from: string | Readonly<Record<string, string>>, to?: string): boolean {\n\t\tif (isRecord(from)) {\n\t\t\treturn Object.entries(from).reduce(\n\t\t\t\t(moved, [one, target]) => this.#move(one, target) && moved,\n\t\t\t\ttrue,\n\t\t\t)\n\t\t}\n\t\tif (to === undefined) return false\n\t\treturn this.#move(from, to)\n\t}\n\n\tremove(path: string): boolean\n\tremove(paths: readonly string[]): boolean\n\tremove(path: string | readonly string[]): boolean {\n\t\tif (isArray(path)) {\n\t\t\treturn Iterator.from(path).reduce((removed, one) => this.#remove(one) && removed, true)\n\t\t}\n\t\treturn this.#remove(path)\n\t}\n\n\tclear(): void {\n\t\tthis.#files.clear()\n\t\tthis.#emitter.emit('clear')\n\t}\n\n\tsnapshot(): WorkspaceSnapshot {\n\t\treturn { id: this.#id, files: this.files() }\n\t}\n\n\tdestroy(): void {\n\t\tthis.#emitter.destroy()\n\t}\n\n\t#write(path: string, content: string): void {\n\t\tconst existing = this.#files.get(path)\n\t\tconst language =\n\t\t\texisting && isText(existing.content) ? existing.content.language : inferLanguage(path)\n\t\tconst file = createFile({\n\t\t\tpath,\n\t\t\tcontent: { text: content, language },\n\t\t\tstate: existing ? 'modified' : 'created',\n\t\t})\n\t\tthis.#files.set(path, file)\n\t\tthis.#emitter.emit('write', file)\n\t}\n\n\t#splice(path: string, content: string, range: Range): void {\n\t\tconst existing = this.#files.get(path)\n\t\tif (!existing) {\n\t\t\tthrow new WorkspaceError('MISSING', `Cannot splice a range of a missing file: ${path}`, {\n\t\t\t\tpath,\n\t\t\t})\n\t\t}\n\t\tif (!isText(existing.content)) {\n\t\t\tthrow new WorkspaceError('MODALITY', `Cannot splice a range of a binary file: ${path}`, {\n\t\t\t\tpath,\n\t\t\t})\n\t\t}\n\t\tif (!isValidRange(range)) {\n\t\t\tthrow new WorkspaceError('RANGE', `Invalid range for file: ${path}`, { path, range })\n\t\t}\n\t\tconst file = createFile({\n\t\t\tpath,\n\t\t\tcontent: {\n\t\t\t\ttext: spliceRange(existing.content.text, range, content),\n\t\t\t\tlanguage: existing.content.language,\n\t\t\t},\n\t\t\tstate: 'modified',\n\t\t})\n\t\tthis.#files.set(path, file)\n\t\tthis.#emitter.emit('write', file)\n\t}\n\n\t#prepend(path: string, content: string): void {\n\t\tconst existing = this.#files.get(path)\n\t\tif (existing === undefined) {\n\t\t\tthis.#write(path, content)\n\t\t\treturn\n\t\t}\n\t\tif (!isText(existing.content)) {\n\t\t\tthrow new WorkspaceError('MODALITY', `Cannot prepend text to a binary file: ${path}`, {\n\t\t\t\tpath,\n\t\t\t})\n\t\t}\n\t\tthis.#write(path, content + existing.content.text)\n\t}\n\n\t#append(path: string, content: string): void {\n\t\tconst existing = this.#files.get(path)\n\t\tif (existing === undefined) {\n\t\t\tthis.#write(path, content)\n\t\t\treturn\n\t\t}\n\t\tif (!isText(existing.content)) {\n\t\t\tthrow new WorkspaceError('MODALITY', `Cannot append text to a binary file: ${path}`, {\n\t\t\t\tpath,\n\t\t\t})\n\t\t}\n\t\tthis.#write(path, existing.content.text + content)\n\t}\n\n\t#move(from: string, to: string): boolean {\n\t\tif (from === to) return false\n\t\tconst file = this.#files.get(from)\n\t\tif (!file) return false\n\t\tconst moved = createFile({ path: to, content: file.content, state: 'modified' })\n\t\tconst entries = [...this.#files]\n\t\tthis.#files.clear()\n\t\tfor (const [path, current] of entries) {\n\t\t\tif (path === from) this.#files.set(to, moved)\n\t\t\telse if (path !== to) this.#files.set(path, current)\n\t\t}\n\t\tthis.#emitter.emit('move', from, to)\n\t\treturn true\n\t}\n\n\t#remove(path: string): boolean {\n\t\tconst removed = this.#files.delete(path)\n\t\tif (removed) this.#emitter.emit('remove', path)\n\t\treturn removed\n\t}\n\n\t#pattern(query: string, options?: SearchOptions): RegExp {\n\t\tconst source = options?.regex === true ? query : escapeRegExp(query)\n\t\tconst flags = options?.sensitive === false ? 'gi' : 'g'\n\t\ttry {\n\t\t\treturn new RegExp(source, flags)\n\t\t} catch {\n\t\t\tthrow new WorkspaceError('PATTERN', `Invalid search pattern: ${query}`, { query })\n\t\t}\n\t}\n}\n","import type { EmitterErrorHandler, EmitterHooks } from '@orkestrel/emitter'\nimport type {\n\tWorkspaceEventMap,\n\tWorkspaceInterface,\n\tWorkspaceManagerInterface,\n\tWorkspaceManagerOptions,\n\tWorkspaceOptions,\n\tWorkspaceStoreInterface,\n} from '../types.js'\nimport { isArray } from '@orkestrel/contract'\nimport { Workspace } from './Workspace.js'\n\n/**\n * Implements `WorkspaceManagerInterface` over an insertion-ordered id map and one active id\n * the instance owns, resolving `active` through that map on every read and holding no emitter.\n *\n * A supplied store adds lenient snapshot `open` and `save` operations. Event defaults flow into\n * workspaces created through the registry, while observability remains owned by each workspace.\n *\n * @example\n * ```ts\n * import { WorkspaceManager } from '@orkestrel/workspace'\n *\n * const manager = new WorkspaceManager()\n * const workspace = manager.add({ id: 'scratch' })\n * manager.active === workspace\n * ```\n */\nexport class WorkspaceManager implements WorkspaceManagerInterface {\n\treadonly #workspaces = new Map<string, WorkspaceInterface>()\n\t#active: string | undefined\n\treadonly #on: EmitterHooks<WorkspaceEventMap> | undefined\n\treadonly #error: EmitterErrorHandler | undefined\n\treadonly #store: WorkspaceStoreInterface | undefined\n\n\t/**\n\t * Creates a registry.\n\t *\n\t * @param options - Default event hooks and optional snapshot store\n\t */\n\tconstructor(options?: WorkspaceManagerOptions) {\n\t\tthis.#on = options?.on\n\t\tthis.#error = options?.error\n\t\tthis.#store = options?.store\n\t}\n\n\tget count(): number {\n\t\treturn this.#workspaces.size\n\t}\n\n\tget active(): WorkspaceInterface | undefined {\n\t\treturn this.#active === undefined ? undefined : this.#workspaces.get(this.#active)\n\t}\n\n\tworkspace(id: string): WorkspaceInterface | undefined {\n\t\treturn this.#workspaces.get(id)\n\t}\n\n\tworkspaces(): readonly WorkspaceInterface[] {\n\t\treturn [...this.#workspaces.values()]\n\t}\n\n\tadd(options?: WorkspaceOptions): WorkspaceInterface {\n\t\tconst on = options?.on ?? this.#on\n\t\tconst error = options?.error ?? this.#error\n\t\tconst workspace = new Workspace({\n\t\t\t...(options?.id === undefined ? {} : { id: options.id }),\n\t\t\t...(on === undefined ? {} : { on }),\n\t\t\t...(error === undefined ? {} : { error }),\n\t\t\t...(options?.seed === undefined ? {} : { seed: options.seed }),\n\t\t})\n\t\tthis.#workspaces.set(workspace.id, workspace)\n\t\tif (this.#active === undefined) this.#active = workspace.id\n\t\treturn workspace\n\t}\n\n\tswitch(id: string): WorkspaceInterface | undefined {\n\t\tconst workspace = this.#workspaces.get(id)\n\t\tif (workspace === undefined) return undefined\n\t\tthis.#active = id\n\t\treturn workspace\n\t}\n\n\tasync open(id: string): Promise<WorkspaceInterface | undefined> {\n\t\tconst existing = this.#workspaces.get(id)\n\t\tif (existing !== undefined) {\n\t\t\tthis.#active = id\n\t\t\treturn existing\n\t\t}\n\t\tif (this.#store === undefined) return undefined\n\t\tconst snapshot = await this.#store.get(id)\n\t\tif (snapshot === undefined) return undefined\n\t\tconst workspace = this.add({ id, seed: snapshot.files })\n\t\tthis.#active = workspace.id\n\t\treturn workspace\n\t}\n\n\tasync save(id: string): Promise<boolean> {\n\t\tconst workspace = this.#workspaces.get(id)\n\t\tif (this.#store === undefined || workspace === undefined) return false\n\t\tawait this.#store.set(workspace.snapshot())\n\t\treturn true\n\t}\n\n\tremove(id: string): boolean\n\tremove(ids: readonly string[]): boolean\n\tremove(ids: string | readonly string[]): boolean {\n\t\tif (isArray(ids)) {\n\t\t\treturn Iterator.from(ids).reduce((removed, id) => this.#drop(id) && removed, true)\n\t\t}\n\t\treturn this.#drop(ids)\n\t}\n\n\tclear(): void {\n\t\tfor (const workspace of this.#workspaces.values()) workspace.destroy()\n\t\tthis.#workspaces.clear()\n\t\tthis.#active = undefined\n\t}\n\n\t#drop(id: string): boolean {\n\t\tconst workspace = this.#workspaces.get(id)\n\t\tif (workspace === undefined) return false\n\t\tthis.#workspaces.delete(id)\n\t\tworkspace.destroy()\n\t\tif (this.#active === id) this.#active = undefined\n\t\treturn true\n\t}\n}\n","import type {\n\tWorkspaceSnapshot,\n\tWorkspaceSnapshotRow,\n\tWorkspaceStoreInterface,\n} from '../../types.js'\nimport type { TableInterface } from '@orkestrel/database'\nimport { isWorkspaceSnapshot } from '../../validators.js'\n\n/**\n * Persists workspace snapshots in a database table.\n *\n * Snapshots occupy one opaque column and are narrowed when read back from the storage boundary.\n *\n * @example\n * ```ts\n * import { rawShape, stringShape } from '@orkestrel/contract'\n * import { createDatabase, createMemoryDriver } from '@orkestrel/database'\n * import { DatabaseWorkspaceStore } from '@orkestrel/workspace'\n *\n * const database = createDatabase({\n * \tdriver: createMemoryDriver(),\n * \ttables: { workspaces: { id: stringShape(), snapshot: rawShape({}) } },\n * })\n * const store = new DatabaseWorkspaceStore(database.table('workspaces'))\n * ```\n */\nexport class DatabaseWorkspaceStore implements WorkspaceStoreInterface {\n\treadonly #table: TableInterface<WorkspaceSnapshotRow>\n\n\t/**\n\t * Wraps a workspace snapshot table.\n\t *\n\t * @param table - The table keyed by workspace identifier\n\t */\n\tconstructor(table: TableInterface<WorkspaceSnapshotRow>) {\n\t\tthis.#table = table\n\t}\n\n\tasync get(id: string): Promise<WorkspaceSnapshot | undefined> {\n\t\tconst row = await this.#table.get(id)\n\t\tif (row === undefined) return undefined\n\t\treturn isWorkspaceSnapshot(row.snapshot) ? row.snapshot : undefined\n\t}\n\n\tasync set(snapshot: WorkspaceSnapshot): Promise<void> {\n\t\tawait this.#table.set({ id: snapshot.id, snapshot })\n\t}\n\n\tasync delete(id: string): Promise<void> {\n\t\tawait this.#table.remove(id)\n\t}\n}\n","import type { WorkspaceSnapshot, WorkspaceStoreInterface } from '../../types.js'\n\n/**\n * Holds workspace snapshots in the current process.\n *\n * @example\n * ```ts\n * import { MemoryWorkspaceStore } from '@orkestrel/workspace'\n *\n * const store = new MemoryWorkspaceStore()\n * ```\n */\nexport class MemoryWorkspaceStore implements WorkspaceStoreInterface {\n\treadonly #snapshots = new Map<string, WorkspaceSnapshot>()\n\n\tget(id: string): Promise<WorkspaceSnapshot | undefined> {\n\t\treturn Promise.resolve(this.#snapshots.get(id))\n\t}\n\n\tset(snapshot: WorkspaceSnapshot): Promise<void> {\n\t\tthis.#snapshots.set(snapshot.id, snapshot)\n\t\treturn Promise.resolve()\n\t}\n\n\tdelete(id: string): Promise<void> {\n\t\tthis.#snapshots.delete(id)\n\t\treturn Promise.resolve()\n\t}\n}\n","import type {\n\tBinaryContent,\n\tBinaryMIME,\n\tFileInput,\n\tFileInterface,\n\tTextContent,\n\tWorkspaceInterface,\n\tWorkspaceManagerInterface,\n\tWorkspaceManagerOptions,\n\tWorkspaceOptions,\n\tWorkspaceSnapshotRow,\n\tWorkspaceStoreInterface,\n} from './types.js'\nimport type { DriverInterface, TableInterface } from '@orkestrel/database'\nimport { rawShape, stringShape } from '@orkestrel/contract'\nimport { createDatabase, createMemoryDriver } from '@orkestrel/database'\nimport { computeSize, countLines } from './helpers.js'\nimport { Workspace } from './workspaces/Workspace.js'\nimport { WorkspaceManager } from './workspaces/WorkspaceManager.js'\nimport { DatabaseWorkspaceStore } from './workspaces/stores/DatabaseWorkspaceStore.js'\nimport { MemoryWorkspaceStore } from './workspaces/stores/MemoryWorkspaceStore.js'\n\n/**\n * Creates an immutable file with derived size and line counts.\n *\n * @param input - The file path, content, and optional state\n * @returns A frozen file record\n *\n * @example Files and content\n * ```ts\n * import {\n * \tcomputeSize,\n * \tcountLines,\n * \tcreateBinaryContent,\n * \tcreateFile,\n * \tcreateTextContent,\n * \tinferLanguage,\n * \tisBinary,\n * \tisText,\n * } from '@orkestrel/workspace'\n *\n * const note = createFile({\n * \tpath: 'notes.md',\n * \tcontent: createTextContent('# Title\\nBody', inferLanguage('notes.md')), // 'markdown'\n * })\n *\n * note.size // 12 — UTF-8 bytes, through computeSize\n * note.lines // 2 — through countLines\n * note.state // 'created'\n * isText(note.content) // true\n *\n * const icon = createFile({ path: 'icon.png', content: createBinaryContent('AAAA', 'image/png') })\n * isBinary(icon.content) // true\n * icon.size // 3 — decoded base64 bytes, through computeDecodedSize\n * ```\n */\nexport function createFile(input: FileInput): FileInterface {\n\treturn Object.freeze({\n\t\tpath: input.path,\n\t\tcontent: input.content,\n\t\tstate: input.state ?? 'created',\n\t\tsize: computeSize(input.content),\n\t\tlines: countLines(input.content),\n\t})\n}\n\n/**\n * Creates the text arm of {@link FileContent}, returned as {@link TextContent} rather than as\n * the whole union.\n *\n * @param text - The text body\n * @param language - The language tag\n * @returns Text file content\n *\n * @example\n * ```ts\n * import { createTextContent } from '@orkestrel/workspace'\n *\n * createTextContent('hello', 'text')\n * ```\n */\nexport function createTextContent(text: string, language: string): TextContent {\n\treturn { text, language }\n}\n\n/**\n * Creates the binary arm of {@link FileContent}, returned as {@link BinaryContent} rather than\n * as the whole union.\n *\n * @param base64 - The base64 payload\n * @param mime - The binary MIME\n * @returns Binary file content\n *\n * @example\n * ```ts\n * import { createBinaryContent } from '@orkestrel/workspace'\n *\n * createBinaryContent('AAAA', 'image/png')\n * ```\n */\nexport function createBinaryContent(base64: string, mime: BinaryMIME): BinaryContent {\n\treturn { base64, mime }\n}\n\n/**\n * Creates a workspace with the same identity, emitter, and seed options the constructor takes.\n *\n * @param options - Optional identity, emitter configuration, and initial files\n * @returns A working workspace\n *\n * @example\n * ```ts\n * import { createWorkspace } from '@orkestrel/workspace'\n *\n * const workspace = createWorkspace()\n * workspace.write('a.txt', 'hello')\n * ```\n */\nexport function createWorkspace(options?: WorkspaceOptions): WorkspaceInterface {\n\treturn new Workspace(options)\n}\n\n/**\n * Creates an in-memory workspace snapshot store.\n *\n * @returns A process-local workspace store\n *\n * @example\n * ```ts\n * import { createMemoryWorkspaceStore } from '@orkestrel/workspace'\n *\n * const store = createMemoryWorkspaceStore()\n * ```\n */\nexport function createMemoryWorkspaceStore(): WorkspaceStoreInterface {\n\treturn new MemoryWorkspaceStore()\n}\n\n/**\n * Creates a database-backed workspace snapshot store, over an in-memory driver when the caller\n * supplies none.\n *\n * @param driver - The database driver. Default: an in-memory driver.\n * @returns A workspace store backed by the supplied driver\n *\n * @example\n * ```ts\n * import { createDatabaseWorkspaceStore } from '@orkestrel/workspace'\n *\n * const store = createDatabaseWorkspaceStore()\n * ```\n */\nexport function createDatabaseWorkspaceStore(\n\tdriver: DriverInterface = createMemoryDriver(),\n): WorkspaceStoreInterface {\n\tconst columns = { id: stringShape(), snapshot: rawShape({}) }\n\tconst database = createDatabase({ driver, tables: { workspaces: columns } })\n\tconst table: TableInterface<WorkspaceSnapshotRow> = database.table('workspaces')\n\treturn new DatabaseWorkspaceStore(table)\n}\n\n/**\n * Creates an empty workspace registry.\n *\n * @param options - Default event hooks and optional durability\n * @returns A workspace manager\n *\n * @example\n * ```ts\n * import { createWorkspaceManager } from '@orkestrel/workspace'\n *\n * const manager = createWorkspaceManager()\n * manager.add()\n * ```\n */\nexport function createWorkspaceManager(\n\toptions?: WorkspaceManagerOptions,\n): WorkspaceManagerInterface {\n\treturn new WorkspaceManager(options)\n}\n"],"mappings":";;;;;;;;;;AAMA,IAAa,sBAAwD,OA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E,OAAO,IAAI,UAAU,OAAO;AAC7B;;;;;;;;;;;;;AAcA,SAAgB,6BAAsD;CACrE,OAAO,IAAI,qBAAqB;AACjC;;;;;;;;;;;;;;;AAgBA,SAAgB,6BACf,SAA0B,mBAAmB,GACnB;CAC1B,MAAM,UAAU;EAAE,IAAI,YAAY;EAAG,UAAU,SAAS,CAAC,CAAC;CAAE;CAG5D,OAAO,IAAI,uBAFM,eAAe;EAAE;EAAQ,QAAQ,EAAE,YAAY,QAAQ;CAAE,CACtB,CAAA,CAAS,MAAM,YACjC,CAAK;AACxC;;;;;;;;;;;;;;;AAgBA,SAAgB,uBACf,SAC4B;CAC5B,OAAO,IAAI,iBAAiB,OAAO;AACpC"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../src/core/constants.ts","../../../src/core/errors.ts","../../../src/core/helpers.ts","../../../src/core/validators.ts","../../../src/core/workspaces/Workspace.ts","../../../src/core/workspaces/WorkspaceManager.ts","../../../src/core/workspaces/stores/DatabaseWorkspaceStore.ts","../../../src/core/workspaces/stores/MemoryWorkspaceStore.ts","../../../src/core/factories.ts"],"sourcesContent":["/**\n * Maps file extensions to language tags for text content.\n *\n * The table is frozen, and an extension it does not list falls back to `text` in\n * {@link import('./helpers.js').inferLanguage}.\n */\nexport const EXTENSION_LANGUAGES: Readonly<Record<string, string>> = Object.freeze({\n\tts: 'typescript',\n\ttsx: 'typescript',\n\tjs: 'javascript',\n\tjsx: 'javascript',\n\tmjs: 'javascript',\n\tcjs: 'javascript',\n\tjson: 'json',\n\tmd: 'markdown',\n\thtml: 'html',\n\thtm: 'html',\n\tcss: 'css',\n\tscss: 'scss',\n\tsass: 'sass',\n\tless: 'less',\n\tvue: 'vue',\n\tsvelte: 'svelte',\n\tpy: 'python',\n\trb: 'ruby',\n\trs: 'rust',\n\tgo: 'go',\n\tjava: 'java',\n\tkt: 'kotlin',\n\tswift: 'swift',\n\tc: 'c',\n\tcpp: 'cpp',\n\th: 'c',\n\thpp: 'cpp',\n\tcs: 'csharp',\n\tphp: 'php',\n\tsql: 'sql',\n\tsh: 'bash',\n\tbash: 'bash',\n\tzsh: 'bash',\n\tps1: 'powershell',\n\tyaml: 'yaml',\n\tyml: 'yaml',\n\ttoml: 'toml',\n\txml: 'xml',\n\tsvg: 'xml',\n\ttxt: 'text',\n})\n","import type { WorkspaceErrorCode } from './types.js'\nimport { holds, INTRINSICS, isFunction, isObject } from '@orkestrel/contract'\n\n/**\n * Reports an invalid workspace edit or search operation, carrying a {@link WorkspaceErrorCode}\n * and, when the operation had one, the context it ran under.\n */\nexport class WorkspaceError extends Error {\n\treadonly code: WorkspaceErrorCode\n\treadonly context?: Readonly<Record<string, unknown>>\n\n\t/**\n\t * Creates a workspace error.\n\t *\n\t * @param code - The machine-readable failure code\n\t * @param message - The human-readable failure message\n\t * @param context - Optional values associated with the failed operation\n\t */\n\tconstructor(\n\t\tcode: WorkspaceErrorCode,\n\t\tmessage: string,\n\t\tcontext?: Readonly<Record<string, unknown>>,\n\t) {\n\t\tsuper(message)\n\t\tINTRINSICS.define(this, Symbol.for('@orkestrel/workspace.WorkspaceError'), { value: this })\n\t\tthis.name = 'WorkspaceError'\n\t\tthis.code = code\n\t\tif (context !== undefined) this.context = context\n\t}\n}\n\n/**\n * Narrows a caught value to a {@link WorkspaceError}.\n *\n * @remarks\n * Checks the identity brand and declared members across package copies, accepting subclasses\n * and refusing transparent proxies. Inspection failures return false.\n *\n * @param value - The caught value\n * @returns True if the value is a workspace error; false otherwise\n *\n * @example\n * ```ts\n * if (isWorkspaceError(error)) error.code\n * ```\n */\nexport function isWorkspaceError(value: unknown): value is WorkspaceError {\n\treturn holds(() => {\n\t\tif (!(value instanceof Error) || INTRINSICS.prototype(value) === Error.prototype) return false\n\t\tconst brand = INTRINSICS.describe(value, Symbol.for('@orkestrel/workspace.WorkspaceError'))\n\t\tif (brand?.value !== value) return false\n\t\tconst code: unknown = INTRINSICS.reflect.read(value, 'code')\n\t\tif (code !== 'MISSING' && code !== 'MODALITY' && code !== 'PATTERN' && code !== 'RANGE')\n\t\t\treturn false\n\t\tconst context: unknown = INTRINSICS.reflect.read(value, 'context')\n\t\treturn context === undefined || isObject(context) || isFunction(context)\n\t})\n}\n","import type { BinaryContent, Caret, FileContent, Range, TextContent } from './types.js'\nimport { EXTENSION_LANGUAGES } from './constants.js'\n\n/**\n * Infers a language tag from the final file extension.\n *\n * @param path - The file path\n * @returns The mapped language, or `text` when the extension is absent or unknown\n *\n * @example\n * ```ts\n * inferLanguage('src/main.ts') // 'typescript'\n * ```\n */\nexport function inferLanguage(path: string): string {\n\tconst dot = path.lastIndexOf('.')\n\tif (dot === -1) return 'text'\n\tconst extension = path.slice(dot + 1).toLowerCase()\n\treturn EXTENSION_LANGUAGES[extension] ?? 'text'\n}\n\n/**\n * Determines whether content is the text arm.\n *\n * @param content - The file content\n * @returns True if the content carries text and a language; false otherwise\n *\n * @example\n * ```ts\n * isTextContent({ text: 'hello', language: 'text' }) // true\n * ```\n */\nexport function isTextContent(content: FileContent): content is TextContent {\n\treturn 'text' in content\n}\n\n/**\n * Determines whether content is the binary arm.\n *\n * @param content - The file content\n * @returns True if the content carries a base64 string and a MIME; false otherwise\n *\n * @example\n * ```ts\n * isBinary({ base64: 'AAAA', mime: 'image/png' }) // true\n * ```\n */\nexport function isBinary(content: FileContent): content is BinaryContent {\n\treturn 'base64' in content\n}\n\n/**\n * Computes the byte size of file content.\n *\n * @param content - The content to measure\n * @returns UTF-8 bytes for text or decoded bytes for binary content\n *\n * @example\n * ```ts\n * computeSize({ text: 'café', language: 'text' }) // 5\n * ```\n */\nexport function computeSize(content: FileContent): number {\n\tif (isTextContent(content)) return new TextEncoder().encode(content.text).length\n\treturn computeDecodedSize(content.base64)\n}\n\n/**\n * Counts the lines in file content.\n *\n * @param content - The content to inspect\n * @returns The text line count, or zero for empty text and binary content\n *\n * @example\n * ```ts\n * countLines({ text: 'a\\nb', language: 'text' }) // 2\n * ```\n */\nexport function countLines(content: FileContent): number {\n\tif (!isTextContent(content)) return 0\n\tif (content.text.length === 0) return 0\n\treturn content.text.split(/\\r\\n|\\n/).length\n}\n\n/**\n * Computes the decoded byte length of a base64 string, arithmetically rather than by decoding it.\n *\n * @param base64 - The base64 string\n * @returns The decoded byte count\n *\n * @example\n * ```ts\n * computeDecodedSize('AAAA') // 3\n * ```\n */\nexport function computeDecodedSize(base64: string): number {\n\tconst padding = base64.endsWith('==') ? 2 : base64.endsWith('=') ? 1 : 0\n\treturn Math.floor((base64.length * 3) / 4) - padding\n}\n\n/**\n * Determines whether a 1-based range is structurally valid.\n *\n * @param range - The range to inspect\n * @returns True if both carets are positive and ordered; false otherwise\n *\n * @example\n * ```ts\n * isValidRange({ start: { line: 1, column: 1 }, end: { line: 1, column: 2 } }) // true\n * ```\n */\nexport function isValidRange(range: Range): boolean {\n\tif (range.start.line < 1 || range.start.column < 1) return false\n\tif (range.end.line < 1 || range.end.column < 1) return false\n\tif (range.start.line > range.end.line) return false\n\treturn !(range.start.line === range.end.line && range.start.column > range.end.column)\n}\n\n/**\n * Clamps a caret to text bounds.\n *\n * @param text - The addressed text\n * @param caret - The requested caret\n * @returns The clamped caret\n *\n * @example\n * ```ts\n * clampCaret('ab', { line: 9, column: 9 }) // { line: 1, column: 3 }\n * ```\n */\nexport function clampCaret(text: string, caret: Caret): Caret {\n\tconst lines = text.split('\\n')\n\tconst line = Math.max(1, Math.min(caret.line, lines.length))\n\tconst lineText = lines[line - 1] ?? ''\n\tconst column = Math.max(1, Math.min(caret.column, lineText.length + 1))\n\treturn { line, column }\n}\n\n/**\n * Clamps both carets in a range to text bounds.\n *\n * @param text - The addressed text\n * @param range - The requested range\n * @returns The clamped range\n *\n * @example\n * ```ts\n * clampRange('ab', { start: { line: 1, column: 1 }, end: { line: 9, column: 9 } })\n * ```\n */\nexport function clampRange(text: string, range: Range): Range {\n\treturn { start: clampCaret(text, range.start), end: clampCaret(text, range.end) }\n}\n\n/**\n * Converts a 1-based caret to a zero-based string offset.\n *\n * @param text - The addressed text\n * @param caret - The requested caret\n * @returns The bounded string offset\n *\n * @example\n * ```ts\n * offsetAt('ab\\ncd', { line: 2, column: 1 }) // 3\n * ```\n */\nexport function offsetAt(text: string, caret: Caret): number {\n\tconst lines = text.split('\\n')\n\tconst offset = lines\n\t\t.filter((_, index) => index < caret.line - 1)\n\t\t.reduce((total, line) => total + line.length + 1, 0)\n\treturn Math.min(offset + (caret.column - 1), text.length)\n}\n\n/**\n * Slices a clamped half-open text range.\n *\n * @param text - The source text\n * @param range - The requested range\n * @returns The ranged substring\n *\n * @example\n * ```ts\n * sliceRange('hello', { start: { line: 1, column: 1 }, end: { line: 1, column: 6 } }) // 'hello'\n * ```\n */\nexport function sliceRange(text: string, range: Range): string {\n\tconst clamped = clampRange(text, range)\n\treturn text.slice(offsetAt(text, clamped.start), offsetAt(text, clamped.end))\n}\n\n/**\n * Replaces a clamped half-open text range.\n *\n * @param text - The source text\n * @param range - The requested range\n * @param replacement - The replacement text\n * @returns The spliced text\n *\n * @example\n * ```ts\n * spliceRange('hello', { start: { line: 1, column: 1 }, end: { line: 1, column: 6 } }, 'bye')\n * ```\n */\nexport function spliceRange(text: string, range: Range, replacement: string): string {\n\tconst clamped = clampRange(text, range)\n\tconst start = offsetAt(text, clamped.start)\n\tconst end = offsetAt(text, clamped.end)\n\treturn text.slice(0, start) + replacement + text.slice(end)\n}\n\n/**\n * Assembles a nested range from four 1-based coordinates.\n *\n * @param fromLine - The start line\n * @param fromColumn - The start column\n * @param toLine - The end line\n * @param toColumn - The end column\n * @returns The assembled range without validation\n *\n * @example\n * ```ts\n * rangeOf(1, 1, 1, 2)\n * ```\n */\nexport function rangeOf(\n\tfromLine: number,\n\tfromColumn: number,\n\ttoLine: number,\n\ttoColumn: number,\n): Range {\n\treturn { start: { line: fromLine, column: fromColumn }, end: { line: toLine, column: toColumn } }\n}\n","import type { FileInterface, WorkspaceSnapshot } from './types.js'\nimport { arrayOf, holds, isNumber, isRecord, isString, literalOf } from '@orkestrel/contract'\n\n/**\n * Narrows an unknown value to an immutable file record.\n *\n * @param value - The value to inspect\n * @returns True if the value has the file shape; false otherwise\n *\n * @example\n * ```ts\n * isFile({ path: 'a.txt', content: { text: 'a', language: 'text' }, state: 'created', size: 1, lines: 1 })\n * ```\n */\nexport function isFile(value: unknown): value is FileInterface {\n\treturn holds(() => {\n\t\tif (!isRecord(value)) return false\n\t\tif (!isString(value.path) || !literalOf('created', 'modified')(value.state)) return false\n\t\tif (!isNumber(value.size) || !isNumber(value.lines)) return false\n\t\tif (!isRecord(value.content)) return false\n\t\tconst text = isString(value.content.text) && isString(value.content.language)\n\t\tconst binary =\n\t\t\tisString(value.content.base64) &&\n\t\t\tliteralOf('image/png', 'image/jpeg', 'image/gif', 'image/webp')(value.content.mime)\n\t\treturn text || binary\n\t})\n}\n\n/**\n * Narrows an unknown value to a workspace snapshot.\n *\n * @param value - The value read from a persistence boundary\n * @returns True if the value has the workspace snapshot shape; false otherwise\n *\n * @example\n * ```ts\n * isWorkspaceSnapshot({ id: 'work', files: [] }) // true\n * ```\n */\nexport function isWorkspaceSnapshot(value: unknown): value is WorkspaceSnapshot {\n\treturn holds(() => isRecord(value) && isString(value.id) && arrayOf(isFile)(value.files))\n}\n","import type { EmitterInterface } from '@orkestrel/emitter'\nimport type {\n\tFileInterface,\n\tRange,\n\tReadResult,\n\tReplaceResult,\n\tSearchMatch,\n\tSearchOptions,\n\tWorkspaceEventMap,\n\tWorkspaceInterface,\n\tWorkspaceOptions,\n\tWorkspaceSnapshot,\n} from '../types.js'\nimport { escapeRegExp, isArray, isRecord } from '@orkestrel/contract'\nimport { Emitter } from '@orkestrel/emitter'\nimport { WorkspaceError } from '../errors.js'\nimport { createFile } from '../factories.js'\nimport {\n\tclampRange,\n\tinferLanguage,\n\tisTextContent,\n\tisValidRange,\n\tsliceRange,\n\tspliceRange,\n} from '../helpers.js'\n\n/**\n * Implements `WorkspaceInterface` over one insertion-ordered path map the instance owns,\n * projecting fresh arrays on every read.\n *\n * Whole-file edits create text files, ranged edits operate only on existing text files, and\n * binary files remain available through construction-time hydration. Mutations emit after the\n * file map has changed.\n *\n * @example\n * ```ts\n * import { Workspace } from '@orkestrel/workspace'\n *\n * const workspace = new Workspace()\n * workspace.write('notes.txt', 'hello')\n * workspace.append('notes.txt', ' world')\n * workspace.read('notes.txt') // 'hello world'\n * ```\n */\nexport class Workspace implements WorkspaceInterface {\n\treadonly #id: string\n\treadonly #files = new Map<string, FileInterface>()\n\treadonly #emitter: Emitter<WorkspaceEventMap>\n\n\t/**\n\t * Creates a workspace.\n\t *\n\t * @param options - Optional identity, emitter configuration, and initial files\n\t */\n\tconstructor(options?: WorkspaceOptions) {\n\t\tthis.#id = options?.id ?? crypto.randomUUID()\n\t\tthis.#emitter = new Emitter<WorkspaceEventMap>({\n\t\t\t...(options?.on === undefined ? {} : { on: options.on }),\n\t\t\t...(options?.error === undefined ? {} : { error: options.error }),\n\t\t})\n\t\tif (options?.seed) for (const file of options.seed) this.#files.set(file.path, file)\n\t}\n\n\tget id(): string {\n\t\treturn this.#id\n\t}\n\n\tget emitter(): EmitterInterface<WorkspaceEventMap> {\n\t\treturn this.#emitter\n\t}\n\n\tget count(): number {\n\t\treturn this.#files.size\n\t}\n\n\tfile(path: string): FileInterface | undefined {\n\t\treturn this.#files.get(path)\n\t}\n\n\tfiles(): readonly FileInterface[] {\n\t\treturn [...this.#files.values()]\n\t}\n\n\tread(path: string): string | undefined\n\tread(path: string, range: Range): ReadResult | undefined\n\tread(paths: readonly string[]): Readonly<Record<string, string>>\n\tread(\n\t\tpath: string | readonly string[],\n\t\trange?: Range,\n\t): string | ReadResult | undefined | Readonly<Record<string, string>> {\n\t\tif (isArray(path)) {\n\t\t\tconst result: Record<string, string> = {}\n\t\t\tfor (const one of path) {\n\t\t\t\tconst file = this.#files.get(one)\n\t\t\t\tif (file && isTextContent(file.content)) result[one] = file.content.text\n\t\t\t}\n\t\t\treturn result\n\t\t}\n\t\tconst file = this.#files.get(path)\n\t\tif (!file) return undefined\n\t\tif (!range) return isTextContent(file.content) ? file.content.text : undefined\n\t\tif (!isTextContent(file.content)) {\n\t\t\tthrow new WorkspaceError('MODALITY', `Cannot read a range of a binary file: ${path}`, {\n\t\t\t\tpath,\n\t\t\t})\n\t\t}\n\t\treturn {\n\t\t\tcontent: sliceRange(file.content.text, range),\n\t\t\trange: clampRange(file.content.text, range),\n\t\t}\n\t}\n\n\thas(path: string): boolean\n\thas(paths: readonly string[]): boolean\n\thas(path: string | readonly string[]): boolean {\n\t\tif (isArray(path)) return path.every((one) => this.#files.has(one))\n\t\treturn this.#files.has(path)\n\t}\n\n\tsearch(query: string, options?: SearchOptions): readonly SearchMatch[] {\n\t\tconst pattern = this.#pattern(query, options)\n\t\tconst limit = options?.limit\n\t\tconst matches: SearchMatch[] = []\n\t\tfor (const file of this.#files.values()) {\n\t\t\tif (limit !== undefined && matches.length >= limit) break\n\t\t\tif (!isTextContent(file.content)) continue\n\t\t\tconst lines = file.content.text.split(/\\r\\n|\\n/)\n\t\t\tfor (const [index, lineText] of lines.entries()) {\n\t\t\t\tif (limit !== undefined && matches.length >= limit) break\n\t\t\t\tpattern.lastIndex = 0\n\t\t\t\tfor (const hit of lineText.matchAll(pattern)) {\n\t\t\t\t\tif (limit !== undefined && matches.length >= limit) break\n\t\t\t\t\tmatches.push({\n\t\t\t\t\t\tpath: file.path,\n\t\t\t\t\t\tline: index + 1,\n\t\t\t\t\t\tcolumn: hit.index + 1,\n\t\t\t\t\t\tlength: hit[0].length,\n\t\t\t\t\t\tcontent: lineText,\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn matches\n\t}\n\n\treplace(query: string, replacement: string, options?: SearchOptions): ReplaceResult {\n\t\tconst pattern = this.#pattern(query, options)\n\t\tconst limit = options?.limit\n\t\tconst changes: number[] = []\n\t\tfor (const [path, file] of this.#files) {\n\t\t\tconst occurrences = changes.reduce((total, count) => total + count, 0)\n\t\t\tif (limit !== undefined && occurrences >= limit) break\n\t\t\tif (!isTextContent(file.content)) continue\n\t\t\tconst remaining = limit === undefined ? undefined : limit - occurrences\n\t\t\tpattern.lastIndex = 0\n\t\t\tconst text = file.content.text\n\t\t\tconst matches = Array.from(text.matchAll(pattern))\n\t\t\tconst count = matches.filter(\n\t\t\t\t(_, index) => remaining === undefined || !(index >= remaining),\n\t\t\t).length\n\t\t\tconst positions = matches.keys()\n\t\t\tconst next = text.replace(pattern, (match) =>\n\t\t\t\t(positions.next().value ?? Number.POSITIVE_INFINITY) < count ? replacement : match,\n\t\t\t)\n\t\t\tif (count > 0) {\n\t\t\t\tchanges.push(count)\n\t\t\t\tthis.write(path, next)\n\t\t\t}\n\t\t}\n\t\treturn {\n\t\t\toccurrences: changes.reduce((total, count) => total + count, 0),\n\t\t\tfiles: changes.length,\n\t\t}\n\t}\n\n\twrite(path: string, content: string): void\n\twrite(path: string, content: string, range: Range): void\n\twrite(files: Readonly<Record<string, string>>): void\n\twrite(path: string | Readonly<Record<string, string>>, content?: string, range?: Range): void {\n\t\tif (isRecord(path)) {\n\t\t\tfor (const [one, text] of Object.entries(path)) this.#write(one, text)\n\t\t\treturn\n\t\t}\n\t\tif (content === undefined) return\n\t\tif (!range) {\n\t\t\tthis.#write(path, content)\n\t\t\treturn\n\t\t}\n\t\tthis.#splice(path, content, range)\n\t}\n\n\tprepend(path: string, content: string): void\n\tprepend(files: Readonly<Record<string, string>>): void\n\tprepend(path: string | Readonly<Record<string, string>>, content?: string): void {\n\t\tif (isRecord(path)) {\n\t\t\tfor (const [one, text] of Object.entries(path)) this.#prepend(one, text)\n\t\t\treturn\n\t\t}\n\t\tif (content === undefined) return\n\t\tthis.#prepend(path, content)\n\t}\n\n\tappend(path: string, content: string): void\n\tappend(files: Readonly<Record<string, string>>): void\n\tappend(path: string | Readonly<Record<string, string>>, content?: string): void {\n\t\tif (isRecord(path)) {\n\t\t\tfor (const [one, text] of Object.entries(path)) this.#append(one, text)\n\t\t\treturn\n\t\t}\n\t\tif (content === undefined) return\n\t\tthis.#append(path, content)\n\t}\n\n\tmove(from: string, to: string): boolean\n\tmove(mapping: Readonly<Record<string, string>>): boolean\n\tmove(from: string | Readonly<Record<string, string>>, to?: string): boolean {\n\t\tif (isRecord(from)) {\n\t\t\treturn Object.entries(from).reduce(\n\t\t\t\t(moved, [one, target]) => this.#move(one, target) && moved,\n\t\t\t\ttrue,\n\t\t\t)\n\t\t}\n\t\tif (to === undefined) return false\n\t\treturn this.#move(from, to)\n\t}\n\n\tremove(path: string): boolean\n\tremove(paths: readonly string[]): boolean\n\tremove(path: string | readonly string[]): boolean {\n\t\tif (isArray(path)) {\n\t\t\treturn Iterator.from(path).reduce((removed, one) => this.#remove(one) && removed, true)\n\t\t}\n\t\treturn this.#remove(path)\n\t}\n\n\tclear(): void {\n\t\tthis.#files.clear()\n\t\tthis.#emitter.emit('clear')\n\t}\n\n\tsnapshot(): WorkspaceSnapshot {\n\t\treturn { id: this.#id, files: this.files() }\n\t}\n\n\tdestroy(): void {\n\t\tthis.#emitter.destroy()\n\t}\n\n\t#write(path: string, content: string): void {\n\t\tconst existing = this.#files.get(path)\n\t\tconst language =\n\t\t\texisting && isTextContent(existing.content) ? existing.content.language : inferLanguage(path)\n\t\tconst file = createFile({\n\t\t\tpath,\n\t\t\tcontent: { text: content, language },\n\t\t\tstate: existing ? 'modified' : 'created',\n\t\t})\n\t\tthis.#files.set(path, file)\n\t\tthis.#emitter.emit('write', file)\n\t}\n\n\t#splice(path: string, content: string, range: Range): void {\n\t\tconst existing = this.#files.get(path)\n\t\tif (!existing) {\n\t\t\tthrow new WorkspaceError('MISSING', `Cannot splice a range of a missing file: ${path}`, {\n\t\t\t\tpath,\n\t\t\t})\n\t\t}\n\t\tif (!isTextContent(existing.content)) {\n\t\t\tthrow new WorkspaceError('MODALITY', `Cannot splice a range of a binary file: ${path}`, {\n\t\t\t\tpath,\n\t\t\t})\n\t\t}\n\t\tif (!isValidRange(range)) {\n\t\t\tthrow new WorkspaceError('RANGE', `Invalid range for file: ${path}`, { path, range })\n\t\t}\n\t\tconst file = createFile({\n\t\t\tpath,\n\t\t\tcontent: {\n\t\t\t\ttext: spliceRange(existing.content.text, range, content),\n\t\t\t\tlanguage: existing.content.language,\n\t\t\t},\n\t\t\tstate: 'modified',\n\t\t})\n\t\tthis.#files.set(path, file)\n\t\tthis.#emitter.emit('write', file)\n\t}\n\n\t#prepend(path: string, content: string): void {\n\t\tconst existing = this.#files.get(path)\n\t\tif (existing === undefined) {\n\t\t\tthis.#write(path, content)\n\t\t\treturn\n\t\t}\n\t\tif (!isTextContent(existing.content)) {\n\t\t\tthrow new WorkspaceError('MODALITY', `Cannot prepend text to a binary file: ${path}`, {\n\t\t\t\tpath,\n\t\t\t})\n\t\t}\n\t\tthis.#write(path, content + existing.content.text)\n\t}\n\n\t#append(path: string, content: string): void {\n\t\tconst existing = this.#files.get(path)\n\t\tif (existing === undefined) {\n\t\t\tthis.#write(path, content)\n\t\t\treturn\n\t\t}\n\t\tif (!isTextContent(existing.content)) {\n\t\t\tthrow new WorkspaceError('MODALITY', `Cannot append text to a binary file: ${path}`, {\n\t\t\t\tpath,\n\t\t\t})\n\t\t}\n\t\tthis.#write(path, existing.content.text + content)\n\t}\n\n\t#move(from: string, to: string): boolean {\n\t\tif (from === to) return false\n\t\tconst file = this.#files.get(from)\n\t\tif (!file) return false\n\t\tconst moved = createFile({ path: to, content: file.content, state: 'modified' })\n\t\tconst entries = [...this.#files]\n\t\tthis.#files.clear()\n\t\tfor (const [path, current] of entries) {\n\t\t\tif (path === from) this.#files.set(to, moved)\n\t\t\telse if (path !== to) this.#files.set(path, current)\n\t\t}\n\t\tthis.#emitter.emit('move', from, to)\n\t\treturn true\n\t}\n\n\t#remove(path: string): boolean {\n\t\tconst removed = this.#files.delete(path)\n\t\tif (removed) this.#emitter.emit('remove', path)\n\t\treturn removed\n\t}\n\n\t#pattern(query: string, options?: SearchOptions): RegExp {\n\t\tconst source = options?.regex === true ? query : escapeRegExp(query)\n\t\tconst flags = options?.sensitive === false ? 'gi' : 'g'\n\t\ttry {\n\t\t\treturn new RegExp(source, flags)\n\t\t} catch {\n\t\t\tthrow new WorkspaceError('PATTERN', `Invalid search pattern: ${query}`, { query })\n\t\t}\n\t}\n}\n","import type { EmitterErrorHandler, EmitterHooks } from '@orkestrel/emitter'\nimport type {\n\tWorkspaceEventMap,\n\tWorkspaceInterface,\n\tWorkspaceManagerInterface,\n\tWorkspaceManagerOptions,\n\tWorkspaceOptions,\n\tWorkspaceStoreInterface,\n} from '../types.js'\nimport { isArray } from '@orkestrel/contract'\nimport { Workspace } from './Workspace.js'\n\n/**\n * Implements `WorkspaceManagerInterface` over an insertion-ordered id map and one active id\n * the instance owns, resolving `active` through that map on every read and holding no emitter.\n *\n * A supplied store adds lenient snapshot `open` and `save` operations. Event defaults flow into\n * workspaces created through the registry, while observability remains owned by each workspace.\n *\n * @example\n * ```ts\n * import { WorkspaceManager } from '@orkestrel/workspace'\n *\n * const manager = new WorkspaceManager()\n * const workspace = manager.add({ id: 'scratch' })\n * manager.active === workspace\n * ```\n */\nexport class WorkspaceManager implements WorkspaceManagerInterface {\n\treadonly #workspaces = new Map<string, WorkspaceInterface>()\n\t#active: string | undefined\n\treadonly #on: EmitterHooks<WorkspaceEventMap> | undefined\n\treadonly #error: EmitterErrorHandler | undefined\n\treadonly #store: WorkspaceStoreInterface | undefined\n\n\t/**\n\t * Creates a registry.\n\t *\n\t * @param options - Default event hooks and optional snapshot store\n\t */\n\tconstructor(options?: WorkspaceManagerOptions) {\n\t\tthis.#on = options?.on\n\t\tthis.#error = options?.error\n\t\tthis.#store = options?.store\n\t}\n\n\tget count(): number {\n\t\treturn this.#workspaces.size\n\t}\n\n\tget active(): WorkspaceInterface | undefined {\n\t\treturn this.#active === undefined ? undefined : this.#workspaces.get(this.#active)\n\t}\n\n\tworkspace(id: string): WorkspaceInterface | undefined {\n\t\treturn this.#workspaces.get(id)\n\t}\n\n\tworkspaces(): readonly WorkspaceInterface[] {\n\t\treturn [...this.#workspaces.values()]\n\t}\n\n\tadd(options?: WorkspaceOptions): WorkspaceInterface {\n\t\tconst on = options?.on ?? this.#on\n\t\tconst error = options?.error ?? this.#error\n\t\tconst workspace = new Workspace({\n\t\t\t...(options?.id === undefined ? {} : { id: options.id }),\n\t\t\t...(on === undefined ? {} : { on }),\n\t\t\t...(error === undefined ? {} : { error }),\n\t\t\t...(options?.seed === undefined ? {} : { seed: options.seed }),\n\t\t})\n\t\tthis.#workspaces.set(workspace.id, workspace)\n\t\tif (this.#active === undefined) this.#active = workspace.id\n\t\treturn workspace\n\t}\n\n\tswitch(id: string): WorkspaceInterface | undefined {\n\t\tconst workspace = this.#workspaces.get(id)\n\t\tif (workspace === undefined) return undefined\n\t\tthis.#active = id\n\t\treturn workspace\n\t}\n\n\tasync open(id: string): Promise<WorkspaceInterface | undefined> {\n\t\tconst existing = this.#workspaces.get(id)\n\t\tif (existing !== undefined) {\n\t\t\tthis.#active = id\n\t\t\treturn existing\n\t\t}\n\t\tif (this.#store === undefined) return undefined\n\t\tconst snapshot = await this.#store.get(id)\n\t\tif (snapshot === undefined) return undefined\n\t\tconst workspace = this.add({ id, seed: snapshot.files })\n\t\tthis.#active = workspace.id\n\t\treturn workspace\n\t}\n\n\tasync save(id: string): Promise<boolean> {\n\t\tconst workspace = this.#workspaces.get(id)\n\t\tif (this.#store === undefined || workspace === undefined) return false\n\t\tawait this.#store.set(workspace.snapshot())\n\t\treturn true\n\t}\n\n\tremove(id: string): boolean\n\tremove(ids: readonly string[]): boolean\n\tremove(ids: string | readonly string[]): boolean {\n\t\tif (isArray(ids)) {\n\t\t\treturn Iterator.from(ids).reduce((removed, id) => this.#drop(id) && removed, true)\n\t\t}\n\t\treturn this.#drop(ids)\n\t}\n\n\tclear(): void {\n\t\tfor (const workspace of this.#workspaces.values()) workspace.destroy()\n\t\tthis.#workspaces.clear()\n\t\tthis.#active = undefined\n\t}\n\n\t#drop(id: string): boolean {\n\t\tconst workspace = this.#workspaces.get(id)\n\t\tif (workspace === undefined) return false\n\t\tthis.#workspaces.delete(id)\n\t\tworkspace.destroy()\n\t\tif (this.#active === id) this.#active = undefined\n\t\treturn true\n\t}\n}\n","import type {\n\tWorkspaceSnapshot,\n\tWorkspaceSnapshotRow,\n\tWorkspaceStoreInterface,\n} from '../../types.js'\nimport type { TableInterface } from '@orkestrel/database'\nimport { isWorkspaceSnapshot } from '../../validators.js'\n\n/**\n * Persists workspace snapshots in a database table.\n *\n * Snapshots occupy one opaque column and are narrowed when read back from the storage boundary.\n *\n * @example\n * ```ts\n * import { rawShape, stringShape } from '@orkestrel/contract'\n * import { createDatabase, createMemoryDriver } from '@orkestrel/database'\n * import { DatabaseWorkspaceStore } from '@orkestrel/workspace'\n *\n * const database = createDatabase({\n * \tdriver: createMemoryDriver(),\n * \ttables: { workspaces: { id: stringShape(), snapshot: rawShape({}) } },\n * })\n * const store = new DatabaseWorkspaceStore(database.table('workspaces'))\n * ```\n */\nexport class DatabaseWorkspaceStore implements WorkspaceStoreInterface {\n\treadonly #table: TableInterface<WorkspaceSnapshotRow>\n\n\t/**\n\t * Wraps a workspace snapshot table.\n\t *\n\t * @param table - The table keyed by workspace identifier\n\t */\n\tconstructor(table: TableInterface<WorkspaceSnapshotRow>) {\n\t\tthis.#table = table\n\t}\n\n\tasync get(id: string): Promise<WorkspaceSnapshot | undefined> {\n\t\tconst row = await this.#table.get(id)\n\t\tif (row === undefined) return undefined\n\t\treturn isWorkspaceSnapshot(row.snapshot) ? row.snapshot : undefined\n\t}\n\n\tasync set(snapshot: WorkspaceSnapshot): Promise<void> {\n\t\tawait this.#table.set({ id: snapshot.id, snapshot })\n\t}\n\n\tasync delete(id: string): Promise<void> {\n\t\tawait this.#table.remove(id)\n\t}\n}\n","import type { WorkspaceSnapshot, WorkspaceStoreInterface } from '../../types.js'\n\n/**\n * Holds workspace snapshots in the current process.\n *\n * @example\n * ```ts\n * import { MemoryWorkspaceStore } from '@orkestrel/workspace'\n *\n * const store = new MemoryWorkspaceStore()\n * ```\n */\nexport class MemoryWorkspaceStore implements WorkspaceStoreInterface {\n\treadonly #snapshots = new Map<string, WorkspaceSnapshot>()\n\n\tget(id: string): Promise<WorkspaceSnapshot | undefined> {\n\t\treturn Promise.resolve(this.#snapshots.get(id))\n\t}\n\n\tset(snapshot: WorkspaceSnapshot): Promise<void> {\n\t\tthis.#snapshots.set(snapshot.id, snapshot)\n\t\treturn Promise.resolve()\n\t}\n\n\tdelete(id: string): Promise<void> {\n\t\tthis.#snapshots.delete(id)\n\t\treturn Promise.resolve()\n\t}\n}\n","import type {\n\tBinaryContent,\n\tBinaryMIME,\n\tFileInput,\n\tFileInterface,\n\tTextContent,\n\tWorkspaceInterface,\n\tWorkspaceManagerInterface,\n\tWorkspaceManagerOptions,\n\tWorkspaceOptions,\n\tWorkspaceSnapshotRow,\n\tWorkspaceStoreInterface,\n} from './types.js'\nimport type { DriverInterface, TableInterface } from '@orkestrel/database'\nimport { rawShape, stringShape } from '@orkestrel/contract'\nimport { createDatabase, createMemoryDriver } from '@orkestrel/database'\nimport { computeSize, countLines } from './helpers.js'\nimport { Workspace } from './workspaces/Workspace.js'\nimport { WorkspaceManager } from './workspaces/WorkspaceManager.js'\nimport { DatabaseWorkspaceStore } from './workspaces/stores/DatabaseWorkspaceStore.js'\nimport { MemoryWorkspaceStore } from './workspaces/stores/MemoryWorkspaceStore.js'\n\n/**\n * Creates an immutable file with derived size and line counts.\n *\n * @param input - The file path, content, and optional state\n * @returns A frozen file record\n *\n * @example Files and content\n * ```ts\n * import {\n * \tcomputeSize,\n * \tcountLines,\n * \tcreateBinaryContent,\n * \tcreateFile,\n * \tcreateTextContent,\n * \tinferLanguage,\n * \tisBinary,\n * \tisTextContent,\n * } from '@orkestrel/workspace'\n *\n * const note = createFile({\n * \tpath: 'notes.md',\n * \tcontent: createTextContent('# Title\\nBody', inferLanguage('notes.md')), // 'markdown'\n * })\n *\n * note.size // 12 — UTF-8 bytes, through computeSize\n * note.lines // 2 — through countLines\n * note.state // 'created'\n * isTextContent(note.content) // true\n *\n * const icon = createFile({ path: 'icon.png', content: createBinaryContent('AAAA', 'image/png') })\n * isBinary(icon.content) // true\n * icon.size // 3 — decoded base64 bytes, through computeDecodedSize\n * ```\n */\nexport function createFile(input: FileInput): FileInterface {\n\treturn Object.freeze({\n\t\tpath: input.path,\n\t\tcontent: input.content,\n\t\tstate: input.state ?? 'created',\n\t\tsize: computeSize(input.content),\n\t\tlines: countLines(input.content),\n\t})\n}\n\n/**\n * Creates the text arm of {@link FileContent}, returned as {@link TextContent} rather than as\n * the whole union.\n *\n * @param text - The text body\n * @param language - The language tag\n * @returns Text file content\n *\n * @example\n * ```ts\n * import { createTextContent } from '@orkestrel/workspace'\n *\n * createTextContent('hello', 'text')\n * ```\n */\nexport function createTextContent(text: string, language: string): TextContent {\n\treturn { text, language }\n}\n\n/**\n * Creates the binary arm of {@link FileContent}, returned as {@link BinaryContent} rather than\n * as the whole union.\n *\n * @param base64 - The base64 payload\n * @param mime - The binary MIME\n * @returns Binary file content\n *\n * @example\n * ```ts\n * import { createBinaryContent } from '@orkestrel/workspace'\n *\n * createBinaryContent('AAAA', 'image/png')\n * ```\n */\nexport function createBinaryContent(base64: string, mime: BinaryMIME): BinaryContent {\n\treturn { base64, mime }\n}\n\n/**\n * Creates a workspace with the same identity, emitter, and seed options the constructor takes.\n *\n * @param options - Optional identity, emitter configuration, and initial files\n * @returns A working workspace\n *\n * @example\n * ```ts\n * import { createWorkspace } from '@orkestrel/workspace'\n *\n * const workspace = createWorkspace()\n * workspace.write('a.txt', 'hello')\n * ```\n */\nexport function createWorkspace(options?: WorkspaceOptions): WorkspaceInterface {\n\treturn new Workspace(options)\n}\n\n/**\n * Creates an in-memory workspace snapshot store.\n *\n * @returns A process-local workspace store\n *\n * @example\n * ```ts\n * import { createMemoryWorkspaceStore } from '@orkestrel/workspace'\n *\n * const store = createMemoryWorkspaceStore()\n * ```\n */\nexport function createMemoryWorkspaceStore(): WorkspaceStoreInterface {\n\treturn new MemoryWorkspaceStore()\n}\n\n/**\n * Creates a database-backed workspace snapshot store, over an in-memory driver when the caller\n * supplies none.\n *\n * @param driver - The database driver. Default: an in-memory driver.\n * @returns A workspace store backed by the supplied driver\n *\n * @example\n * ```ts\n * import { createDatabaseWorkspaceStore } from '@orkestrel/workspace'\n *\n * const store = createDatabaseWorkspaceStore()\n * ```\n */\nexport function createDatabaseWorkspaceStore(\n\tdriver: DriverInterface = createMemoryDriver(),\n): WorkspaceStoreInterface {\n\tconst columns = { id: stringShape(), snapshot: rawShape({}) }\n\tconst database = createDatabase({ driver, tables: { workspaces: columns } })\n\tconst table: TableInterface<WorkspaceSnapshotRow> = database.table('workspaces')\n\treturn new DatabaseWorkspaceStore(table)\n}\n\n/**\n * Creates an empty workspace registry.\n *\n * @param options - Default event hooks and optional durability\n * @returns A workspace manager\n *\n * @example\n * ```ts\n * import { createWorkspaceManager } from '@orkestrel/workspace'\n *\n * const manager = createWorkspaceManager()\n * manager.add()\n * ```\n */\nexport function createWorkspaceManager(\n\toptions?: WorkspaceManagerOptions,\n): WorkspaceManagerInterface {\n\treturn new WorkspaceManager(options)\n}\n"],"mappings":";;;;;;;;;;AAMA,IAAa,sBAAwD,OAAO,OAAO;CAClF,IAAI;CACJ,KAAK;CACL,IAAI;CACJ,KAAK;CACL,KAAK;CACL,KAAK;CACL,MAAM;CACN,IAAI;CACJ,MAAM;CACN,KAAK;CACL,KAAK;CACL,MAAM;CACN,MAAM;CACN,MAAM;CACN,KAAK;CACL,QAAQ;CACR,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,MAAM;CACN,IAAI;CACJ,OAAO;CACP,GAAG;CACH,KAAK;CACL,GAAG;CACH,KAAK;CACL,IAAI;CACJ,KAAK;CACL,KAAK;CACL,IAAI;CACJ,MAAM;CACN,KAAK;CACL,KAAK;CACL,MAAM;CACN,KAAK;CACL,MAAM;CACN,KAAK;CACL,KAAK;CACL,KAAK;AACN,CAAC;;;;;;ACxCD,IAAa,iBA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CAEA,IAAI,UAA4C;EAC/C,KAAK,WAAW,IAAI,SAAS,IAAI,QAAQ;EACzC,OAAO,QAAQ,QAAQ;CACxB;CAEA,OAAO,IAA2B;EACjC,KAAK,WAAW,OAAO,EAAE;EACzB,OAAO,QAAQ,QAAQ;CACxB;AACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AC4BA,SAAgB,WAAW,OAAiC;CAC3D,OAAO,OAAO,OAAO;EACpB,MAAM,MAAM;EACZ,SAAS,MAAM;EACf,OAAO,MAAM,SAAS;EACtB,MAAM,YAAY,MAAM,OAAO;EAC/B,OAAO,WAAW,MAAM,OAAO;CAChC,CAAC;AACF;;;;;;;;;;;;;;;;AAiBA,SAAgB,kBAAkB,MAAc,UAA+B;CAC9E,OAAO;EAAE;EAAM;CAAS;AACzB;;;;;;;;;;;;;;;;AAiBA,SAAgB,oBAAoB,QAAgB,MAAiC;CACpF,OAAO;EAAE;EAAQ;CAAK;AACvB;;;;;;;;;;;;;;;AAgBA,SAAgB,gBAAgB,SAAgD;CAC/E,OAAO,IAAI,UAAU,OAAO;AAC7B;;;;;;;;;;;;;AAcA,SAAgB,6BAAsD;CACrE,OAAO,IAAI,qBAAqB;AACjC;;;;;;;;;;;;;;;AAgBA,SAAgB,6BACf,SAA0B,mBAAmB,GACnB;CAC1B,MAAM,UAAU;EAAE,IAAI,YAAY;EAAG,UAAU,SAAS,CAAC,CAAC;CAAE;CAG5D,OAAO,IAAI,uBAFM,eAAe;EAAE;EAAQ,QAAQ,EAAE,YAAY,QAAQ;CAAE,CACtB,CAAA,CAAS,MAAM,YACjC,CAAK;AACxC;;;;;;;;;;;;;;;AAgBA,SAAgB,uBACf,SAC4B;CAC5B,OAAO,IAAI,iBAAiB,OAAO;AACpC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orkestrel/workspace",
3
- "version": "0.0.13",
3
+ "version": "0.0.14",
4
4
  "description": "A virtual file workspace for the @orkestrel line — path-keyed immutable files, an edit and search surface, registries with an active pointer, and pluggable snapshot stores. Part of the @orkestrel line.",
5
5
  "keywords": [
6
6
  "edit",
@@ -69,16 +69,16 @@
69
69
  "test:setup": "vitest run --config vite.config.ts --no-cache --reporter=dot --project setup"
70
70
  },
71
71
  "dependencies": {
72
- "@orkestrel/contract": "^0.0.20",
73
- "@orkestrel/database": "^0.0.19",
74
- "@orkestrel/emitter": "^0.0.13"
72
+ "@orkestrel/contract": "^0.0.21",
73
+ "@orkestrel/database": "^0.0.20",
74
+ "@orkestrel/emitter": "^0.0.14"
75
75
  },
76
76
  "devDependencies": {
77
- "@microsoft/api-extractor": "^7.60.0",
78
- "@orkestrel/guide": "^0.0.25",
79
- "@orkestrel/probe": "^0.0.25",
80
- "@orkestrel/scaffold": "^0.0.113",
81
- "@orkestrel/test": "^0.0.31",
77
+ "@microsoft/api-extractor": "^7.60.1",
78
+ "@orkestrel/guide": "^0.0.28",
79
+ "@orkestrel/probe": "^0.0.26",
80
+ "@orkestrel/scaffold": "^0.0.119",
81
+ "@orkestrel/test": "^0.0.32",
82
82
  "@types/node": "^26.6.6",
83
83
  "oxfmt": "^0.75.0",
84
84
  "oxlint": "^1.90.0",