MCPcopy
hub / github.com/OpenCoworkAI/open-codesign / preparePromptContext

Function preparePromptContext

apps/desktop/src/main/prompt-context.ts:859–886  ·  view source on GitHub ↗
(input: {
  attachments?: LocalInputFile[] | undefined;
  referenceUrl?: string | undefined;
  designSystem?: StoredDesignSystem | null | undefined;
  resolveReferenceHost?: ReferenceHostResolver | undefined;
  fetchReference?: ReferenceFetcher | undefined;
  workspaceRoot?: string | undefined;
})

Source from the content-addressed store, hash-verified

857}
858
859export async function preparePromptContext(input: {
860 attachments?: LocalInputFile[] | undefined;
861 referenceUrl?: string | undefined;
862 designSystem?: StoredDesignSystem | null | undefined;
863 resolveReferenceHost?: ReferenceHostResolver | undefined;
864 fetchReference?: ReferenceFetcher | undefined;
865 workspaceRoot?: string | undefined;
866}): Promise<PreparedPromptContext> {
867 const attachments = await Promise.all(
868 (input.attachments ?? []).map((file) => readAttachment(file, input.workspaceRoot)),
869 );
870 const referenceUrl =
871 typeof input.referenceUrl === 'string' && input.referenceUrl.trim().length > 0
872 ? await inspectReferenceUrl(
873 input.referenceUrl.trim(),
874 input.resolveReferenceHost ?? defaultResolveReferenceHost,
875 input.fetchReference ?? defaultFetchReference,
876 )
877 : null;
878 const projectContext = await readProjectContext(input.workspaceRoot);
879
880 return {
881 designSystem: input.designSystem ?? null,
882 attachments,
883 referenceUrl,
884 projectContext,
885 };
886}

Callers 2

registerGenerateIpcFunction · 0.90

Calls 3

readAttachmentFunction · 0.85
inspectReferenceUrlFunction · 0.85
readProjectContextFunction · 0.85

Tested by

no test coverage detected