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

Function sourceCandidates

packages/core/src/agent.ts:814–838  ·  view source on GitHub ↗
(
  files: readonly string[],
  fs: TextEditorFsCallbacks | undefined,
)

Source from the content-addressed store, hash-verified

812}
813
814function sourceCandidates(
815 files: readonly string[],
816 fs: TextEditorFsCallbacks | undefined,
817): string[] {
818 if (!fs) return [];
819 const candidates = files.filter((file) => {
820 if (isVirtualTemplatePath(file)) return false;
821 if (!/\.(?:jsx|tsx|html?)$/i.test(file)) return false;
822 const viewed = fs.view(file);
823 return viewed !== null && viewed.content.trim().length > 0;
824 });
825 return candidates
826 .sort((a, b) => {
827 const score = (file: string): number => {
828 const lower = file.toLowerCase();
829 if (lower === DEFAULT_SOURCE_ENTRY.toLowerCase()) return 0;
830 if (lower === LEGACY_SOURCE_ENTRY.toLowerCase()) return 1;
831 if (lower.endsWith('/app.jsx') || lower.endsWith('/app.tsx')) return 2;
832 if (lower.endsWith('/index.html')) return 3;
833 return 10;
834 };
835 return score(a) - score(b) || a.localeCompare(b);
836 })
837 .slice(0, 8);
838}
839
840function buildWorkspaceBrief(
841 input: GenerateInput,

Callers 2

buildWorkspaceBriefFunction · 0.85
generateViaAgentFunction · 0.85

Calls 3

isVirtualTemplatePathFunction · 0.85
scoreFunction · 0.85
viewMethod · 0.80

Tested by

no test coverage detected