Skip to content

Commit 8663dfb

Browse files
committed
feat: trim docs bundle to coding-essential sections
Exclude community/, tutorials/ and plugin/ from the bundled docs — agents rarely need them while coding and llms.txt covers them online. Bundle: 356 -> 323 files, 0.79MB -> 0.67MB unpacked (~205KB gzipped transfer). Size limit tightened to 2MB.
1 parent 1f4324a commit 8663dfb

2 files changed

Lines changed: 26 additions & 3 deletions

File tree

packages/solutions/app-tools/scripts/copy-main-doc.mjs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,27 @@ const source = path.resolve(pkgRoot, '../../document/docs/en');
1313
const bundleRoot = path.resolve(pkgRoot, 'main-doc');
1414
const target = path.join(bundleRoot, 'docs/en');
1515

16+
// Top-level doc sections excluded from the bundle to keep it small.
17+
// Agents rarely need these while coding (blog/showcase, narrative
18+
// tutorials, framework-plugin authoring); llms.txt covers them online.
19+
// Keep this list in sync with scripts/check-doc-bundle.mjs.
20+
export const EXCLUDED_SECTIONS = ['community', 'tutorials', 'plugin'];
21+
1622
if (!fs.existsSync(source)) {
1723
console.error(`[copy-main-doc] source docs not found: ${source}`);
1824
process.exit(1);
1925
}
2026

2127
fs.rmSync(bundleRoot, { recursive: true, force: true });
2228
fs.mkdirSync(path.dirname(target), { recursive: true });
23-
fs.cpSync(source, target, { recursive: true });
29+
fs.cpSync(source, target, {
30+
recursive: true,
31+
filter: src => {
32+
const rel = path.relative(source, src);
33+
const top = rel.split(path.sep)[0];
34+
return rel === '' || !EXCLUDED_SECTIONS.includes(top);
35+
},
36+
});
2437

2538
const count = fs
2639
.readdirSync(target, { recursive: true, withFileTypes: true })

scripts/check-doc-bundle.mjs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,22 @@ const repoRoot = path.resolve(__dirname, '..');
1616
const docsSource = path.join(repoRoot, 'packages/document/docs/en');
1717
const appTools = path.join(repoRoot, 'packages/solutions/app-tools');
1818

19-
const SIZE_LIMIT = 3 * 1024 * 1024;
19+
const SIZE_LIMIT = 2 * 1024 * 1024;
2020
const OUTSIDE_DOCS_WHITELIST = [/\.\.\/.*src\/sandbox\//];
21+
// must stay in sync with EXCLUDED_SECTIONS in
22+
// packages/solutions/app-tools/scripts/copy-main-doc.mjs
23+
const EXCLUDED_SECTIONS = ['community', 'tutorials', 'plugin'];
2124

2225
const sourceFiles = fs
2326
.readdirSync(docsSource, { recursive: true, withFileTypes: true })
24-
.filter(entry => entry.isFile());
27+
.filter(entry => entry.isFile())
28+
.filter(entry => {
29+
const rel = path.relative(
30+
docsSource,
31+
path.join(entry.parentPath ?? entry.path, entry.name),
32+
);
33+
return !EXCLUDED_SECTIONS.includes(rel.split(path.sep)[0]);
34+
});
2535

2636
// 1 & 3: inspect the tarball file list
2737
execSync('node ./scripts/copy-main-doc.mjs', {

0 commit comments

Comments
 (0)