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

Method readFileWithSha

src/node/services/memoryService.ts:920–940  ·  view source on GitHub ↗
(
    ctx: MemoryScopeContext,
    virtualPath: string
  )

Source from the content-addressed store, hash-verified

918 // -------------------------------------------------------------------------
919
920 async readFileWithSha(
921 ctx: MemoryScopeContext,
922 virtualPath: string
923 ): Promise<MemoryReadFileResult> {
924 try {
925 const parsed = parseMemoryPath(virtualPath);
926 const scope = this.requireFilePath(parsed, virtualPath);
927 const store = await this.resolveStore(ctx, scope, parsed.relPath);
928 const content = await this.readTextFileForEdit(store, parsed.relPath, virtualPath);
929 // Deliberately NOT recorded as a use: this is a human browsing the
930 // Memory tab/settings, and usage stats must reflect agent reads only so
931 // UI browsing never inflates hot-set ranking. (UI saves still count —
932 // an edit is an explicit signal the file matters, like pinning.)
933 return { success: true, data: { content, sha256: sha256Hex(content) } };
934 } catch (error) {
935 if (error instanceof MemoryCommandError) {
936 return { success: false, error: error.message };
937 }
938 return { success: false, error: `Memory operation failed: ${getErrorMessage(error)}` };
939 }
940 }
941
942 /**
943 * Whole-file save from the Memory tab. expectedSha256 is the sha captured at

Callers 6

writeInboxFunction · 0.80
deleteInboxIfPresentFunction · 0.80
routerFunction · 0.80

Calls 6

requireFilePathMethod · 0.95
resolveStoreMethod · 0.95
readTextFileForEditMethod · 0.95
getErrorMessageFunction · 0.90
parseMemoryPathFunction · 0.85
sha256HexFunction · 0.85

Tested by

no test coverage detected