MCPcopy Create free account
hub / github.com/Gan-Xing/CodexBridge / parseReviewTargetFromSkill

Function parseReviewTargetFromSkill

src/core/bridge_coordinator.ts:12931–12981  ·  view source on GitHub ↗
(value: unknown)

Source from the content-addressed store, hash-verified

12929}
12930
12931function parseReviewTargetFromSkill(value: unknown): ProviderReviewTarget | null {
12932 const parsed = value && typeof value === 'object' && !Array.isArray(value)
12933 ? value as Record<string, unknown>
12934 : {};
12935 const type = compactWhitespace(parsed.type).toLowerCase();
12936 if (type === 'uncommittedchanges' || type === 'uncommitted_changes' || type === 'uncommitted') {
12937 return {
12938 type: 'uncommittedChanges',
12939 };
12940 }
12941 if (!type) {
12942 return null;
12943 }
12944 if (type === 'basebranch' || type === 'base_branch' || type === 'base') {
12945 const branch = compactWhitespace(parsed.branch ?? parsed.baseBranch ?? parsed.base_branch ?? '');
12946 return branch
12947 ? {
12948 type: 'baseBranch',
12949 branch,
12950 }
12951 : null;
12952 }
12953 if (type === 'commit') {
12954 const sha = compactWhitespace(parsed.sha ?? parsed.commit ?? parsed.commitSha ?? parsed.commit_sha ?? '');
12955 const title = normalizeNullableText(parsed.title);
12956 return sha
12957 ? {
12958 type: 'commit',
12959 sha,
12960 title,
12961 }
12962 : null;
12963 }
12964 if (type === 'custom') {
12965 const instructions = compactWhitespace(parsed.instructions ?? parsed.prompt ?? parsed.request ?? '');
12966 if (!instructions) {
12967 return null;
12968 }
12969 const focus = normalizeStringArray(parsed.focus);
12970 const includePaths = normalizeStringArray(parsed.includePaths ?? parsed.include_paths ?? parsed.paths);
12971 const excludePaths = normalizeStringArray(parsed.excludePaths ?? parsed.exclude_paths ?? parsed.ignoredPaths ?? parsed.ignored_paths);
12972 return {
12973 type: 'custom',
12974 instructions,
12975 ...(focus.length > 0 ? { focus } : {}),
12976 ...(includePaths.length > 0 ? { includePaths } : {}),
12977 ...(excludePaths.length > 0 ? { excludePaths } : {}),
12978 };
12979 }
12980 return null;
12981}
12982
12983function normalizeInstructionsDocumentContent(value: unknown): string {
12984 return String(value ?? '').replace(/\r\n/g, '\n').trim();

Callers 1

Calls 3

normalizeNullableTextFunction · 0.85
compactWhitespaceFunction · 0.70
normalizeStringArrayFunction · 0.70

Tested by

no test coverage detected