feat: refine codex live chat context flows
This commit is contained in:
@@ -10,26 +10,48 @@ const featureMarkdownModules = import.meta.glob('../../features/**/*.md', {
|
||||
import: 'default',
|
||||
}) as Record<string, () => Promise<string>>;
|
||||
|
||||
function createMarkdownEntries(
|
||||
const DOCS_ENTRY_DEFINITIONS: Array<Pick<MarkdownDocumentEntry, 'path' | 'folder' | 'title'>> = [
|
||||
{
|
||||
path: '/docs/README.md',
|
||||
folder: 'project',
|
||||
title: '프로젝트 구조',
|
||||
},
|
||||
];
|
||||
|
||||
const FEATURE_ENTRY_PATTERNS = [/\/overview\.md$/i, /\/README\.md$/i];
|
||||
|
||||
function createExplicitMarkdownEntries(
|
||||
modules: Record<string, () => Promise<string>>,
|
||||
entries: Array<Pick<MarkdownDocumentEntry, 'path' | 'folder' | 'title'>>,
|
||||
): MarkdownDocumentEntry[] {
|
||||
const sortedPaths = Object.keys(modules).sort((left, right) => {
|
||||
const isLeftWorklog = left.includes('/docs/worklogs/');
|
||||
const isRightWorklog = right.includes('/docs/worklogs/');
|
||||
|
||||
if (isLeftWorklog && isRightWorklog) {
|
||||
return right.localeCompare(left);
|
||||
}
|
||||
|
||||
return left.localeCompare(right);
|
||||
});
|
||||
|
||||
return sortedPaths.map((path, index) => ({
|
||||
path,
|
||||
load: modules[path],
|
||||
order: index,
|
||||
}));
|
||||
return entries
|
||||
.filter((entry) => typeof modules[entry.path] === 'function')
|
||||
.map((entry, index) => ({
|
||||
...entry,
|
||||
load: modules[entry.path],
|
||||
order: index,
|
||||
}));
|
||||
}
|
||||
|
||||
export const docsMarkdownEntries = createMarkdownEntries(docsMarkdownModules);
|
||||
export const featureMarkdownEntries = createMarkdownEntries(featureMarkdownModules);
|
||||
function createFilteredMarkdownEntries(
|
||||
modules: Record<string, () => Promise<string>>,
|
||||
includePatterns: RegExp[],
|
||||
): MarkdownDocumentEntry[] {
|
||||
return Object.keys(modules)
|
||||
.filter((path) => includePatterns.some((pattern) => pattern.test(path)))
|
||||
.sort((left, right) => left.localeCompare(right))
|
||||
.map((path, index) => ({
|
||||
path,
|
||||
load: modules[path],
|
||||
order: index,
|
||||
}));
|
||||
}
|
||||
|
||||
export const docsMarkdownEntries = createExplicitMarkdownEntries(
|
||||
docsMarkdownModules,
|
||||
DOCS_ENTRY_DEFINITIONS,
|
||||
);
|
||||
export const featureMarkdownEntries = createFilteredMarkdownEntries(
|
||||
featureMarkdownModules,
|
||||
FEATURE_ENTRY_PATTERNS,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user