MCPcopy Create free account
hub / github.com/TraderAlice/OpenAlice / writeWorkspaceFile

Function writeWorkspaceFile

src/workspaces/file-service.ts:124–142  ·  view source on GitHub ↗
(
  workspaceDir: string,
  relPath: string,
  content: string,
)

Source from the content-addressed store, hash-verified

122 * workspace-local real file).
123 */
124export async function writeWorkspaceFile(
125 workspaceDir: string,
126 relPath: string,
127 content: string,
128): Promise<void> {
129 const abs = resolveInside(workspaceDir, relPath);
130 await mkdir(dirname(abs), { recursive: true });
131
132 // If the existing entry is a symlink, unlink before write so we don't
133 // mutate the link target.
134 try {
135 const ls = await nodeLstat(abs);
136 if (ls.isSymbolicLink()) await unlink(abs);
137 } catch (err) {
138 if (!isENOENT(err)) throw err;
139 }
140
141 await nodeWriteFile(abs, content, 'utf8');
142}
143
144function isENOENT(err: unknown): boolean {
145 return typeof err === 'object' && err !== null && (err as { code?: string }).code === 'ENOENT';

Callers 9

writeWorkspaceMetadataFunction · 0.85
injectWorkspaceContextFunction · 0.85
writeAiConfigFunction · 0.85
writeAiConfigFunction · 0.85
writeAiConfigFunction · 0.85
writeAiConfigFunction · 0.85
updateIssueFieldsFunction · 0.85
appendIssueCommentFunction · 0.85
createIssueFunction · 0.85

Calls 2

resolveInsideFunction · 0.85
isENOENTFunction · 0.70

Tested by

no test coverage detected