MCPcopy Index your code
hub / github.com/coder/mux / readTextFileForEdit

Method readTextFileForEdit

src/node/services/memoryService.ts:897–914  ·  view source on GitHub ↗
(
    store: MemoryStore,
    relPath: string,
    virtualPath: string
  )

Source from the content-addressed store, hash-verified

895 }
896
897 private async readTextFileForEdit(
898 store: MemoryStore,
899 relPath: string,
900 virtualPath: string
901 ): Promise<string> {
902 const kind = await store.kind(relPath);
903 if (kind === null) {
904 throw new MemoryCommandError(`No memory file at ${virtualPath}`);
905 }
906 if (kind === "dir") {
907 throw new MemoryCommandError(`${virtualPath} is a directory, not a file`);
908 }
909 const content = await this.readBoundedTextFile(store, relPath, virtualPath);
910 if (content.includes("\u0000")) {
911 throw new MemoryCommandError(`${virtualPath} is not a UTF-8 text file; cannot edit it`);
912 }
913 return content;
914 }
915
916 // -------------------------------------------------------------------------
917 // UI commands (Memory tab): whole-file read/save with sha256 preconditions

Callers 3

strReplaceMethod · 0.95
insertMethod · 0.95
readFileWithShaMethod · 0.95

Calls 2

readBoundedTextFileMethod · 0.95
kindMethod · 0.65

Tested by

no test coverage detected