MCPcopy
hub / github.com/inkeep/open-knowledge / formatPreviewBlock

Function formatPreviewBlock

packages/cli/src/content/preview.ts:119–152  ·  view source on GitHub ↗
(result: PreviewResult, cwd: string)

Source from the content-addressed store, hash-verified

117}
118
119export function formatPreviewBlock(result: PreviewResult, cwd: string): string {
120 const lines: string[] = [];
121 const rel = relative(cwd, result.contentDir);
122 const displayDir = rel === '' ? './' : `./${rel}`;
123
124 lines.push('Content:');
125 lines.push(` Found ${result.totalCount} markdown files in ${displayDir}`);
126
127 if (result.sample.length > 0) {
128 const sampleStr = result.sample.join(', ');
129 const suffix = result.totalCount > result.sample.length ? ', \u2026' : '';
130 lines.push(` Sample: ${sampleStr}${suffix}`);
131 }
132
133 if (result.warnings.length > 0) {
134 for (const w of result.warnings) {
135 lines.push(` Warning: ${w}`);
136 }
137 }
138
139 lines.push('');
140 const configPath = join(cwd, OK_DIR, 'config.yml');
141 if (existsSync(configPath)) {
142 lines.push(' To adjust scope, add patterns to .okignore at the project root.');
143 lines.push(` To change the content root, edit ${OK_DIR}/config.yml → content.dir.`);
144 } else {
145 lines.push(' Run `open-knowledge init` to scaffold config + .okignore.');
146 }
147
148 lines.push('');
149 lines.push(' Re-check anytime: open-knowledge preview');
150
151 return lines.join('\n');
152}

Callers 3

preview.test.tsFile · 0.90
formatInitResultFunction · 0.90
previewCommandFunction · 0.85

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected