bmad-game-dev-studio 0.1.4 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CNAME ADDED
@@ -0,0 +1 @@
1
+ game-dev-studio-docs.bmad-method.org
package/README.md CHANGED
@@ -70,7 +70,7 @@ Select **Game Dev Studio** from the modules list.
70
70
  After installing, run from your project root:
71
71
 
72
72
  ```
73
- /bmgd-help # Get guided help for game development
73
+ /bmad-help # Get guided help for game development
74
74
  /bmgd-quick-dev # Jump straight into prototyping
75
75
  /bmgd-gdd # Create a Game Design Document
76
76
  /bmgd-narrative # Design your game's story
@@ -81,12 +81,12 @@ After installing, run from your project root:
81
81
  | Approach | When to Use | Workflow |
82
82
  |----------|-------------|----------|
83
83
  | **Quick Flow** | Rapid prototyping, small projects | `/bmgd-quick-dev` |
84
- | **Full Production** | Full games, teams, long-term | `/bmgd-help` for guided path |
84
+ | **Full Production** | Full games, teams, long-term | `/bmad-help` for guided path |
85
85
 
86
86
  ## Example: Starting a New Game
87
87
 
88
88
  ```
89
- You: /bmgd-help
89
+ You: /bmad-help
90
90
  BMGD: What kind of game are you making?
91
91
  You: A tactical sci-fi RPG
92
92
  BMGD: Great choice! Here's what I recommend...
@@ -96,8 +96,10 @@ BMGD: Great choice! Here's what I recommend...
96
96
 
97
97
  ## Documentation
98
98
 
99
- - [BMad Method Docs](http://docs.bmad-method.org)
100
- - [BMGD Guide](http://docs.bmad-method.org/bmgd/)
99
+ **[BMad Game Dev Studio Documentation](http://game-dev-studio-docs.bmad-method.org)** — Tutorials, how-to guides, and reference
100
+
101
+ - [Getting Started](http://game-dev-studio-docs.bmad-method.org/tutorials/)
102
+ - [BMad Method Docs](http://docs.bmad-method.org) — Core framework documentation
101
103
 
102
104
  ## Community
103
105
 
package/eslint.config.mjs CHANGED
@@ -114,17 +114,6 @@ export default [
114
114
  },
115
115
  },
116
116
 
117
- // Module installer scripts use CommonJS for compatibility
118
- {
119
- files: ['**/_module-installer/**/*.js'],
120
- rules: {
121
- // Allow CommonJS patterns for installer scripts
122
- 'unicorn/prefer-module': 'off',
123
- 'n/no-missing-require': 'off',
124
- 'n/no-unpublished-require': 'off',
125
- },
126
- },
127
-
128
117
  // ESLint config file should not be checked for publish-related Node rules
129
118
  {
130
119
  files: ['eslint.config.mjs'],
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "bmad-game-dev-studio",
4
- "version": "0.1.4",
4
+ "version": "0.1.6",
5
5
  "description": "A BMad MEthod Core Module that offers a substantial stand alone module for Game Development across multiple supported platforms",
6
6
  "keywords": [
7
7
  "bmad",
@@ -13,8 +13,12 @@
13
13
  },
14
14
  "license": "MIT",
15
15
  "author": "Brian (BMad) Madison",
16
+ "type": "module",
16
17
  "main": "",
17
18
  "scripts": {
19
+ "docs:build": "node tools/build-docs.mjs",
20
+ "docs:dev": "astro dev --root website",
21
+ "docs:preview": "astro preview --root website",
18
22
  "format:check": "prettier --check \"**/*.{js,cjs,mjs,json,yaml}\"",
19
23
  "format:fix": "prettier --write \"**/*.{js,cjs,mjs,json,yaml}\"",
20
24
  "lint": "eslint . --ext .js,.cjs,.mjs,.yaml --max-warnings=0",
@@ -46,10 +50,6 @@
46
50
  "markdownlint-cli2"
47
51
  ]
48
52
  },
49
- "dependencies": {
50
- "chalk": "^4.1.2",
51
- "fs-extra": "^11.3.0"
52
- },
53
53
  "devDependencies": {
54
54
  "@astrojs/sitemap": "^3.6.0",
55
55
  "@astrojs/starlight": "^0.37.0",
@@ -1,26 +1,26 @@
1
1
  module,phase,name,code,sequence,workflow-file,command,required,agent,options,description,output-location,outputs,
2
- gds,anytime,Document Project,DP,20,_bmad/gds/workflows/document-project/workflow.yaml,bmad-gds-document-project,false,tech-writer,Create Mode,"Analyze an existing game project to produce useful documentation",project_knowledge,"project documentation",
3
- gds,anytime,Quick Prototype,QP,30,_bmad/gds/workflows/gds-quick-flow/quick-prototype/workflow.yaml,bmad-gds-quick-prototype,false,game-solo-dev,Create Mode,"Rapid game prototyping - test mechanics and ideas quickly",,,
4
- gds,anytime,Quick Spec,TS,35,_bmad/gds/workflows/gds-quick-flow/quick-spec/workflow.yaml,bmad-gds-quick-spec,false,game-solo-dev,Create Mode,"Quick one-off tasks small changes simple apps utilities without extensive planning",planning_artifacts,"tech spec",
5
- gds,anytime,Quick Dev,QD,40,_bmad/gds/workflows/gds-quick-flow/quick-dev/workflow.yaml,bmad-gds-quick-dev,false,game-solo-dev,Create Mode,"Flexible game development - implement features with game-specific considerations",,,
6
- gds,anytime,Correct Course,CC,50,_bmad/gds/workflows/4-production/correct-course/workflow.yaml,bmad-gds-correct-course,false,game-scrum-master,Create Mode,"Navigate significant changes during game dev sprint when implementation is off-track",planning_artifacts,"change proposal",
7
- gds,1-preproduction,Brainstorm Game,BG,10,_bmad/gds/workflows/1-preproduction/brainstorm-game/workflow.yaml,bmad-gds-brainstorm-game,false,game-designer,Create Mode,"Facilitate game brainstorming sessions with game-specific context and techniques",output_folder,"brainstorming session",
8
- gds,1-preproduction,Game Brief,GB,20,_bmad/gds/workflows/1-preproduction/game-brief/workflow.yaml,bmad-gds-game-brief,false,game-designer,Create Mode,"Interactive game brief creation workflow that guides users through defining their game vision",output_folder,"game brief",
9
- gds,2-design,Game Design Document,GDD,10,_bmad/gds/workflows/2-design/gdd/workflow.yaml,bmad-gds-gdd,false,game-designer,Create Mode,"Create a Game Design Document with mechanics, systems, progression, and implementation guidance",planning_artifacts,"gdd",
10
- gds,2-design,Narrative Design,ND,20,_bmad/gds/workflows/2-design/narrative/workflow.yaml,bmad-gds-narrative,false,game-designer,Create Mode,"Create comprehensive narrative documentation including story structure, character arcs, and world-building",planning_artifacts,"narrative design",
11
- gds,3-technical,Project Context,PC,10,_bmad/gds/workflows/3-technical/generate-project-context/workflow.md,bmad-gds-project-context,false,game-architect,Create Mode,"Create optimized project-context.md for AI agent consistency",,,
12
- gds,3-technical,Game Architecture,GA,20,_bmad/gds/workflows/3-technical/game-architecture/workflow.yaml,bmad-gds-game-architecture,true,game-architect,Create Mode,"Produce a scale adaptive game architecture with engine, systems, networking, and technical design",planning_artifacts,"game architecture",
13
- gds,3-technical,Test Framework,TF,30,_bmad/gds/workflows/gametest/test-framework/workflow.yaml,bmad-gds-test-framework,false,game-qa,Create Mode,"Initialize game test framework architecture for Unity, Unreal Engine, or Godot projects",,,
14
- gds,3-technical,Test Design,TD,35,_bmad/gds/workflows/gametest/test-design/workflow.yaml,bmad-gds-test-design,false,game-qa,Create Mode,"Create comprehensive game test scenarios covering gameplay, progression, and quality requirements",planning_artifacts,"test design",
15
- gds,4-production,Sprint Planning,SP,10,_bmad/gds/workflows/4-production/sprint-planning/workflow.yaml,bmad-gds-sprint-planning,true,game-scrum-master,Create Mode,"Generate or update sprint-status.yaml from epic files",implementation_artifacts,"sprint status",
16
- gds,4-production,Sprint Status,SS,20,_bmad/gds/workflows/4-production/sprint-status/workflow.yaml,bmad-gds-sprint-status,false,game-scrum-master,Create Mode,"View sprint progress, surface risks, and get next action recommendation",,,
17
- gds,4-production,Create Story,CS,30,_bmad/gds/workflows/4-production/create-story/workflow.yaml,bmad-gds-create-story,true,game-scrum-master,Create Mode,"Create Story with direct ready-for-dev marking",implementation_artifacts,"story",
18
- gds,4-production,Validate Story,VS,35,_bmad/gds/workflows/4-production/create-story/workflow.yaml,bmad-gds-validate-story,false,game-scrum-master,Validate Mode,"Validate Story Draft with Independent Review",implementation_artifacts,"story validation report",
19
- gds,4-production,Dev Story,DS,40,_bmad/gds/workflows/4-production/dev-story/workflow.yaml,bmad-gds-dev-story,true,game-dev,Create Mode,"Execute Dev Story workflow implementing tasks and tests",,,
20
- gds,4-production,Code Review,CR,50,_bmad/gds/workflows/4-production/code-review/workflow.yaml,bmad-gds-code-review,false,game-dev,Create Mode,"Perform a thorough clean context QA code review on a story flagged Ready for Review",,,
21
- gds,4-production,Retrospective,ER,60,_bmad/gds/workflows/4-production/retrospective/workflow.yaml,bmad-gds-retrospective,false,game-scrum-master,Create Mode,"Facilitate team retrospective after a game development epic is completed",implementation_artifacts,"retrospective",
22
- gds,gametest,Test Automate,TA,10,_bmad/gds/workflows/gametest/automate/workflow.yaml,bmad-gds-test-automate,false,game-qa,Create Mode,"Generate automated game tests",,,
23
- gds,gametest,E2E Scaffold,ES,20,_bmad/gds/workflows/gametest/e2e-scaffold/workflow.yaml,bmad-gds-e2e-scaffold,false,game-qa,Create Mode,"Scaffold E2E testing infrastructure",,,
24
- gds,gametest,Playtest Plan,PP,30,_bmad/gds/workflows/gametest/playtest-plan/workflow.yaml,bmad-gds-playtest-plan,false,game-qa,Create Mode,"Create structured playtesting plan",planning_artifacts,"playtest plan",
25
- gds,gametest,Performance Test,PT,40,_bmad/gds/workflows/gametest/performance/workflow.yaml,bmad-gds-performance-test,false,game-qa,Create Mode,"Design performance testing strategy",planning_artifacts,"performance strategy",
26
- gds,gametest,Test Review,TR,50,_bmad/gds/workflows/gametest/test-review/workflow.yaml,bmad-gds-test-review,false,game-qa,Create Mode,"Review test quality and coverage",,,
2
+ gds,anytime,Document Project,DP,,_bmad/gds/workflows/document-project/workflow.yaml,bmad-gds-document-project,false,tech-writer,Create Mode,"Analyze an existing game project to produce useful documentation. Use when onboarding to existing projects or creating project docs.",project_knowledge,"project documentation",
3
+ gds,anytime,Quick Prototype,QP,,_bmad/gds/workflows/gds-quick-flow/quick-prototype/workflow.yaml,bmad-gds-quick-prototype,false,game-solo-dev,Create Mode,"Rapid game prototyping to test mechanics and ideas quickly. Use when experimenting with gameplay concepts or validating mechanics.",,,
4
+ gds,anytime,Quick Spec,TS,,_bmad/gds/workflows/gds-quick-flow/quick-spec/workflow.yaml,bmad-gds-quick-spec,false,game-solo-dev,Create Mode,"Quick one-off tasks, small changes, simple apps utilities without extensive planning. Use for straightforward game features or well-defined tasks.",planning_artifacts,"tech spec",
5
+ gds,anytime,Quick Dev,QD,,_bmad/gds/workflows/gds-quick-flow/quick-dev/workflow.yaml,bmad-gds-quick-dev,false,game-solo-dev,Create Mode,"Flexible game development with game-specific considerations. Use for rapid feature implementation or mechanics work.",,,
6
+ gds,1-preproduction,Brainstorm Game,BG,10,_bmad/gds/workflows/1-preproduction/brainstorm-game/workflow.yaml,bmad-gds-brainstorm-game,false,game-designer,Create Mode,"Facilitate game brainstorming sessions with game-specific context and techniques. Use early in ideation phase or when generating game concepts.",output_folder,"brainstorming session",
7
+ gds,1-preproduction,Game Brief,GB,20,_bmad/gds/workflows/1-preproduction/game-brief/workflow.yaml,bmad-gds-game-brief,false,game-designer,Create Mode,"Interactive game brief creation that guides users through defining their game vision. Use when clarifying game concept and core mechanics.",output_folder,"game brief",
8
+ gds,2-design,Game Design Document,GDD,10,_bmad/gds/workflows/2-design/gdd/workflow.yaml,bmad-gds-gdd,false,game-designer,Create Mode,"Create a Game Design Document with mechanics, systems, progression, and implementation guidance. Use when documenting comprehensive game design specifications.",planning_artifacts,"gdd",
9
+ gds,2-design,Narrative Design,ND,20,_bmad/gds/workflows/2-design/narrative/workflow.yaml,bmad-gds-narrative,false,game-designer,Create Mode,"Create comprehensive narrative documentation including story structure, character arcs, and world-building. Use for story-driven games or narrative integration.",planning_artifacts,"narrative design",
10
+ gds,3-technical,Project Context,PC,10,_bmad/gds/workflows/3-technical/generate-project-context/workflow.md,bmad-gds-project-context,false,game-architect,Create Mode,"Create optimized project-context.md for chosen agentic tool consistency. Use when setting up new projects or improving AI coordination.",,,
11
+ gds,3-technical,Game Architecture,GA,20,_bmad/gds/workflows/3-technical/game-architecture/workflow.yaml,bmad-gds-game-architecture,true,game-architect,Create Mode,"Produce a scale-adaptive game architecture with engine, systems, networking, and technical design. Use when planning technical implementation or system architecture.",planning_artifacts,"game architecture",
12
+ gds,3-technical,Test Framework,TF,30,_bmad/gds/workflows/gametest/test-framework/workflow.yaml,bmad-gds-test-framework,false,game-qa,Create Mode,"Initialize game test framework architecture for Unity, Unreal Engine, or Godot projects. Use when setting up automated testing infrastructure.",,,
13
+ gds,3-technical,Test Design,TD,35,_bmad/gds/workflows/gametest/test-design/workflow.yaml,bmad-gds-test-design,false,game-qa,Create Mode,"Create comprehensive game test scenarios covering gameplay, progression, and quality requirements. Use when planning test coverage or quality strategy.",planning_artifacts,"test design",
14
+ gds,4-production,Sprint Planning,SP,10,_bmad/gds/workflows/4-production/sprint-planning/workflow.yaml,bmad-gds-sprint-planning,true,game-scrum-master,Create Mode,"Generate or update sprint-status.yaml from epic files. Use when starting development phase or planning sprints.",implementation_artifacts,"sprint status",
15
+ gds,4-production,Sprint Status,SS,20,_bmad/gds/workflows/4-production/sprint-status/workflow.yaml,bmad-gds-sprint-status,false,game-scrum-master,Create Mode,"View sprint progress, surface risks, and get next action recommendation. Use when checking sprint health or planning next steps.",,,
16
+ gds,4-production,Create Story,CS,30,_bmad/gds/workflows/4-production/create-story/workflow.yaml,bmad-gds-create-story,true,game-scrum-master,Create Mode,"Create Story with direct ready-for-dev marking. Use when preparing stories for development.",implementation_artifacts,"story",
17
+ gds,4-production,Validate Story,VS,35,_bmad/gds/workflows/4-production/create-story/workflow.yaml,bmad-gds-validate-story,false,game-scrum-master,Validate Mode,"Validate Story Draft with independent review. Use for quality assurance before development begins.",implementation_artifacts,"story validation report",
18
+ gds,4-production,Dev Story,DS,40,_bmad/gds/workflows/4-production/dev-story/workflow.yaml,bmad-gds-dev-story,true,game-dev,Create Mode,"Execute Dev Story workflow implementing tasks and tests. Use when developing story features and functionality.",,,
19
+ gds,4-production,Code Review,CR,50,_bmad/gds/workflows/4-production/code-review/workflow.yaml,bmad-gds-code-review,false,game-dev,Create Mode,"Perform thorough clean context QA code review on stories flagged Ready for Review. Use after story development for quality checks.",,,
20
+ gds,4-production,Correct Course,CC,55,_bmad/gds/workflows/4-production/correct-course/workflow.yaml,bmad-gds-correct-course,false,game-scrum-master,Create Mode,"Navigate significant changes during game dev sprint when implementation is off-track. Use when major course corrections are needed.",planning_artifacts,"change proposal",
21
+ gds,4-production,Retrospective,ER,60,_bmad/gds/workflows/4-production/retrospective/workflow.yaml,bmad-gds-retrospective,false,game-scrum-master,Create Mode,"Facilitate team retrospective after a game development epic is completed. Use for continuous improvement after epic completion.",implementation_artifacts,"retrospective",
22
+ gds,gametest,Test Automate,TA,10,_bmad/gds/workflows/gametest/automate/workflow.yaml,bmad-gds-test-automate,false,game-qa,Create Mode,"Generate automated game tests. Use for automated test coverage of gameplay systems.",,,
23
+ gds,gametest,E2E Scaffold,ES,20,_bmad/gds/workflows/gametest/e2e-scaffold/workflow.yaml,bmad-gds-e2e-scaffold,false,game-qa,Create Mode,"Scaffold E2E testing infrastructure. Use when setting up end-to-end automated testing.",,,
24
+ gds,gametest,Playtest Plan,PP,30,_bmad/gds/workflows/gametest/playtest-plan/workflow.yaml,bmad-gds-playtest-plan,false,game-qa,Create Mode,"Create structured playtesting plan. Use when planning user testing sessions or gathering player feedback.",planning_artifacts,"playtest plan",
25
+ gds,gametest,Performance Test,PT,40,_bmad/gds/workflows/gametest/performance/workflow.yaml,bmad-gds-performance-test,false,game-qa,Create Mode,"Design performance testing strategy. Use when optimizing game performance or profiling resource usage.",planning_artifacts,"performance strategy",
26
+ gds,gametest,Test Review,TR,50,_bmad/gds/workflows/gametest/test-review/workflow.yaml,bmad-gds-test-review,false,game-qa,Create Mode,"Review test quality and coverage. Use when evaluating test effectiveness or identifying coverage gaps.",,,
package/src/module.yaml CHANGED
@@ -63,3 +63,9 @@ primary_platform:
63
63
  label: "Godot"
64
64
  - value: "other"
65
65
  label: "Custom / Other"
66
+
67
+ # Directories to create during installation (declarative, no code execution)
68
+ directories:
69
+ - "{planning_artifacts}"
70
+ - "{implementation_artifacts}"
71
+ - "{project_knowledge}"
@@ -0,0 +1,450 @@
1
+ /**
2
+ * BMad Game Dev Studio Documentation Build Pipeline
3
+ *
4
+ * Consolidates docs from multiple sources, generates LLM-friendly files,
5
+ * and builds the Astro+Starlight site.
6
+ *
7
+ * Build outputs:
8
+ * build/artifacts/ - With llms.txt, llms-full.txt
9
+ * build/site/ - Final Astro output (deployable)
10
+ */
11
+
12
+ import { execSync } from 'node:child_process';
13
+ import fs from 'node:fs';
14
+ import path from 'node:path';
15
+ import { fileURLToPath } from 'node:url';
16
+ import { getSiteUrl } from '../website/src/lib/site-url.mjs';
17
+
18
+ // =============================================================================
19
+ // Configuration
20
+ // =============================================================================
21
+
22
+ const PROJECT_ROOT = path.dirname(path.dirname(fileURLToPath(import.meta.url)));
23
+ const BUILD_DIR = path.join(PROJECT_ROOT, 'build');
24
+
25
+ const REPO_URL = 'https://github.com/bmad-code-org/bmad-module-game-dev-studio';
26
+
27
+ // DO NOT CHANGE THESE VALUES!
28
+ // llms-full.txt is consumed by AI agents as context. Most LLMs have ~200k token limits.
29
+ // 600k chars ≈ 150k tokens (safe margin). Exceeding this breaks AI agent functionality.
30
+ const LLM_MAX_CHARS = 600_000;
31
+ const LLM_WARN_CHARS = 500_000;
32
+
33
+ const LLM_EXCLUDE_PATTERNS = [
34
+ 'changelog',
35
+ 'archived',
36
+ // Note: Files/dirs starting with _ (like _STYLE_GUIDE.md, _archive/) are excluded in shouldExcludeFromLlm()
37
+ ];
38
+
39
+ // =============================================================================
40
+ // Main Entry Point
41
+ /**
42
+ * Orchestrates the full BMad Game Dev Studio documentation build pipeline.
43
+ *
44
+ * Executes the high-level build steps in sequence: prints headers and paths, validates internal
45
+ * documentation links, cleans the build directory, generates artifacts from the `docs/` folder,
46
+ * builds the Astro site, and prints a final build summary.
47
+ */
48
+
49
+ async function main() {
50
+ console.log();
51
+ printBanner('BMad Game Dev Studio Documentation Build Pipeline');
52
+ console.log();
53
+ console.log(`Project root: ${PROJECT_ROOT}`);
54
+ console.log(`Build directory: ${BUILD_DIR}`);
55
+ console.log();
56
+
57
+ cleanBuildDirectory();
58
+
59
+ const docsDir = path.join(PROJECT_ROOT, 'docs');
60
+ const artifactsDir = await generateArtifacts(docsDir);
61
+ const siteDir = buildAstroSite();
62
+
63
+ printBuildSummary(docsDir, artifactsDir, siteDir);
64
+ }
65
+
66
+ main().catch((error) => {
67
+ console.error(error);
68
+ process.exit(1);
69
+ });
70
+
71
+ // =============================================================================
72
+ // Pipeline Stages
73
+ /**
74
+ * Generate LLM files for the documentation pipeline.
75
+ *
76
+ * Creates the build/artifacts directory and writes `llms.txt` and `llms-full.txt` (sourced from the provided docs directory).
77
+ *
78
+ * @param {string} docsDir - Path to the source docs directory containing Markdown files.
79
+ * @returns {string} Path to the created artifacts directory.
80
+ */
81
+
82
+ async function generateArtifacts(docsDir) {
83
+ printHeader('Generating LLM files');
84
+
85
+ const outputDir = path.join(BUILD_DIR, 'artifacts');
86
+ fs.mkdirSync(outputDir, { recursive: true });
87
+
88
+ // Generate LLM files reading from docs/, output to artifacts/
89
+ generateLlmsTxt(outputDir);
90
+ generateLlmsFullTxt(docsDir, outputDir);
91
+
92
+ console.log();
93
+ console.log(` \u001B[32m✓\u001B[0m Artifact generation complete`);
94
+
95
+ return outputDir;
96
+ }
97
+
98
+ /**
99
+ * Builds the Astro + Starlight site and copies generated artifacts into the site output directory.
100
+ *
101
+ * @returns {string} The filesystem path to the built site directory (e.g., build/site).
102
+ */
103
+ function buildAstroSite() {
104
+ printHeader('Building Astro + Starlight site');
105
+
106
+ const siteDir = path.join(BUILD_DIR, 'site');
107
+ const artifactsDir = path.join(BUILD_DIR, 'artifacts');
108
+
109
+ // Build Astro site (outputs to build/site via astro.config.mjs)
110
+ runAstroBuild();
111
+ copyArtifactsToSite(artifactsDir, siteDir);
112
+
113
+ console.log();
114
+ console.log(` \u001B[32m✓\u001B[0m Astro build complete`);
115
+
116
+ return siteDir;
117
+ }
118
+
119
+ // =============================================================================
120
+ // LLM File Generation
121
+ /**
122
+ * Create a concise llms.txt summary file containing project metadata, core links, and quick navigation entries for LLM consumption.
123
+ *
124
+ * Writes the file to `${outputDir}/llms.txt`.
125
+ *
126
+ * @param {string} outputDir - Destination directory where `llms.txt` will be written.
127
+ */
128
+
129
+ function generateLlmsTxt(outputDir) {
130
+ console.log(' → Generating llms.txt...');
131
+
132
+ const siteUrl = getSiteUrl();
133
+ const content = [
134
+ '# BMad Game Dev Studio Documentation',
135
+ '',
136
+ '> Game development (Unity, Unreal, Godot) module for the BMad Method.',
137
+ '',
138
+ `Documentation: ${siteUrl}`,
139
+ `Repository: ${REPO_URL}`,
140
+ `Full docs: ${siteUrl}/llms-full.txt`,
141
+ '',
142
+ '## Quick Start',
143
+ '',
144
+ `- **[Quick Start](${siteUrl}/tutorials/quick-start)** - Get started with BMGD`,
145
+ `- **[Installation](${siteUrl}/reference/installation)** - Installation guide`,
146
+ '',
147
+ '## Core Concepts',
148
+ '',
149
+ `- **[What is BMGD?](${siteUrl}/explanation/what-is-bmgd)** - Understanding the module`,
150
+ `- **[Unity Support](${siteUrl}/how-to/unity)** - Unity game development`,
151
+ `- **[Unreal Support](${siteUrl}/how-to/unreal)** - Unreal game development`,
152
+ `- **[Godot Support](${siteUrl}/how-to/godot)** - Godot game development`,
153
+ '',
154
+ '---',
155
+ '',
156
+ '## Quick Links',
157
+ '',
158
+ `- [Full Documentation (llms-full.txt)](${siteUrl}/llms-full.txt) - Complete docs for AI context`,
159
+ '',
160
+ ].join('\n');
161
+
162
+ const outputPath = path.join(outputDir, 'llms.txt');
163
+ fs.writeFileSync(outputPath, content, 'utf-8');
164
+ console.log(` Generated llms.txt (${content.length.toLocaleString()} chars)`);
165
+ }
166
+
167
+ /**
168
+ * Builds a consolidated llms-full.txt containing all Markdown files under docsDir wrapped in <document path="..."> tags for LLM consumption.
169
+ *
170
+ * Writes the generated file to outputDir/llms-full.txt. Files matching LLM_EXCLUDE_PATTERNS are skipped; read errors for individual files are logged. The combined content is validated against configured size thresholds (will exit on overflow and warn if near limit).
171
+ * @param {string} docsDir - Root directory containing source Markdown files; paths in the output are relative to this directory.
172
+ * @param {string} outputDir - Directory where llms-full.txt will be written.
173
+ */
174
+ function generateLlmsFullTxt(docsDir, outputDir) {
175
+ console.log(' → Generating llms-full.txt...');
176
+
177
+ const date = new Date().toISOString().split('T')[0];
178
+ const files = getAllMarkdownFiles(docsDir).sort(compareLlmDocs);
179
+
180
+ const output = [
181
+ '# BMad Game Dev Studio Documentation (Full)',
182
+ '',
183
+ '> Complete documentation for AI consumption',
184
+ `> Generated: ${date}`,
185
+ `> Repository: ${REPO_URL}`,
186
+ '',
187
+ ];
188
+
189
+ let fileCount = 0;
190
+ let skippedCount = 0;
191
+
192
+ for (const mdPath of files) {
193
+ if (shouldExcludeFromLlm(mdPath)) {
194
+ skippedCount++;
195
+ continue;
196
+ }
197
+
198
+ const fullPath = path.join(docsDir, mdPath);
199
+ try {
200
+ const content = readMarkdownContent(fullPath);
201
+ output.push(`<document path="${mdPath}">`, content, '</document>', '');
202
+ fileCount++;
203
+ } catch (error) {
204
+ console.error(` Warning: Could not read ${mdPath}: ${error.message}`);
205
+ }
206
+ }
207
+
208
+ const result = output.join('\n');
209
+ validateLlmSize(result);
210
+
211
+ const outputPath = path.join(outputDir, 'llms-full.txt');
212
+ fs.writeFileSync(outputPath, result, 'utf-8');
213
+
214
+ const tokenEstimate = Math.floor(result.length / 4).toLocaleString();
215
+ console.log(
216
+ ` Processed ${fileCount} files (skipped ${skippedCount}), ${result.length.toLocaleString()} chars (~${tokenEstimate} tokens)`,
217
+ );
218
+ }
219
+
220
+ function compareLlmDocs(a, b) {
221
+ const aKey = getLlmSortKey(a);
222
+ const bKey = getLlmSortKey(b);
223
+
224
+ if (aKey !== bKey) return aKey - bKey;
225
+ return a.localeCompare(b);
226
+ }
227
+
228
+ function getLlmSortKey(filePath) {
229
+ if (filePath === 'index.md') return 0;
230
+ if (filePath.startsWith(`tutorials${path.sep}`) || filePath.startsWith('tutorials/')) return 2;
231
+ if (filePath.startsWith(`how-to${path.sep}`) || filePath.startsWith('how-to/')) return 3;
232
+ if (filePath.startsWith(`explanation${path.sep}`) || filePath.startsWith('explanation/')) return 4;
233
+ if (filePath.startsWith(`reference${path.sep}`) || filePath.startsWith('reference/')) return 5;
234
+ if (filePath.startsWith(`game-dev${path.sep}`) || filePath.startsWith('game-dev/')) return 6;
235
+ return 7;
236
+ }
237
+
238
+ /**
239
+ * Collects all Markdown (.md) files under a directory and returns their paths relative to a base directory.
240
+ * @param {string} dir - Directory to search for Markdown files.
241
+ * @param {string} [baseDir=dir] - Base directory used to compute returned relative paths.
242
+ * @returns {string[]} An array of file paths (relative to `baseDir`) for every `.md` file found under `dir`.
243
+ */
244
+ function getAllMarkdownFiles(dir, baseDir = dir) {
245
+ const files = [];
246
+
247
+ for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
248
+ const fullPath = path.join(dir, entry.name);
249
+
250
+ if (entry.isDirectory()) {
251
+ files.push(...getAllMarkdownFiles(fullPath, baseDir));
252
+ } else if (entry.name.endsWith('.md')) {
253
+ // Return relative path from baseDir
254
+ const relativePath = path.relative(baseDir, fullPath);
255
+ files.push(relativePath);
256
+ }
257
+ }
258
+
259
+ return files;
260
+ }
261
+
262
+ /**
263
+ * Determine whether a file path matches any configured LLM exclusion pattern.
264
+ * Also excludes any files or directories starting with underscore.
265
+ * @param {string} filePath - The file path to test.
266
+ * @returns {boolean} `true` if excluded, `false` otherwise.
267
+ */
268
+ function shouldExcludeFromLlm(filePath) {
269
+ // Exclude if ANY path component starts with underscore
270
+ // (e.g., _STYLE_GUIDE.md, _archive/file.md, dir/_STYLE_GUIDE.md)
271
+ const pathParts = filePath.split(path.sep);
272
+ if (pathParts.some((part) => part.startsWith('_'))) return true;
273
+
274
+ // Check configured patterns
275
+ return LLM_EXCLUDE_PATTERNS.some((pattern) => filePath.includes(pattern));
276
+ }
277
+
278
+ function readMarkdownContent(filePath) {
279
+ let content = fs.readFileSync(filePath, 'utf-8');
280
+
281
+ if (content.startsWith('---')) {
282
+ const end = content.indexOf('---', 3);
283
+ if (end !== -1) {
284
+ content = content.slice(end + 3).trim();
285
+ }
286
+ }
287
+
288
+ return content;
289
+ }
290
+
291
+ function validateLlmSize(content) {
292
+ const charCount = content.length;
293
+
294
+ if (charCount > LLM_MAX_CHARS) {
295
+ console.error(` ERROR: Exceeds ${LLM_MAX_CHARS.toLocaleString()} char limit`);
296
+ process.exit(1);
297
+ } else if (charCount > LLM_WARN_CHARS) {
298
+ console.warn(` \u001B[33mWARNING: Approaching ${LLM_WARN_CHARS.toLocaleString()} char limit\u001B[0m`);
299
+ }
300
+ }
301
+
302
+ // =============================================================================
303
+ // Astro Build
304
+ /**
305
+ * Builds the Astro site to build/site (configured in astro.config.mjs).
306
+ */
307
+ function runAstroBuild() {
308
+ console.log(' → Running astro build...');
309
+ execSync('npx astro build --root website', {
310
+ cwd: PROJECT_ROOT,
311
+ stdio: 'inherit',
312
+ env: {
313
+ ...process.env,
314
+ },
315
+ });
316
+ }
317
+
318
+ /**
319
+ * Copy generated artifact files into the built site directory.
320
+ *
321
+ * Copies llms.txt and llms-full.txt from the artifacts directory into the site directory.
322
+ *
323
+ * @param {string} artifactsDir - Path to the build artifacts directory containing generated files.
324
+ * @param {string} siteDir - Path to the target site directory where artifacts should be placed.
325
+ */
326
+ function copyArtifactsToSite(artifactsDir, siteDir) {
327
+ console.log(' → Copying artifacts to site...');
328
+
329
+ fs.copyFileSync(path.join(artifactsDir, 'llms.txt'), path.join(siteDir, 'llms.txt'));
330
+ fs.copyFileSync(path.join(artifactsDir, 'llms-full.txt'), path.join(siteDir, 'llms-full.txt'));
331
+ }
332
+
333
+ // =============================================================================
334
+ // Build Summary
335
+ /**
336
+ * Prints a concise end-of-build summary and displays a sample listing of the final site directory.
337
+ *
338
+ * @param {string} docsDir - Path to the source documentation directory used for the build.
339
+ * @param {string} artifactsDir - Path to the directory containing generated artifacts (e.g., llms.txt).
340
+ * @param {string} siteDir - Path to the final built site directory whose contents will be listed.
341
+ */
342
+
343
+ function printBuildSummary(docsDir, artifactsDir, siteDir) {
344
+ console.log();
345
+ printBanner('Build Complete!');
346
+ console.log();
347
+ console.log('Build artifacts:');
348
+ console.log(` Source docs: ${docsDir}`);
349
+ console.log(` Generated files: ${artifactsDir}`);
350
+ console.log(` Final site: ${siteDir}`);
351
+ console.log();
352
+ console.log(`Deployable output: ${siteDir}/`);
353
+ console.log();
354
+
355
+ listDirectoryContents(siteDir);
356
+ }
357
+
358
+ function listDirectoryContents(dir) {
359
+ const entries = fs.readdirSync(dir).slice(0, 15);
360
+
361
+ for (const entry of entries) {
362
+ const fullPath = path.join(dir, entry);
363
+ const stat = fs.statSync(fullPath);
364
+
365
+ if (stat.isFile()) {
366
+ const sizeStr = formatFileSize(stat.size);
367
+ console.log(` ${entry.padEnd(40)} ${sizeStr.padStart(8)}`);
368
+ } else {
369
+ console.log(` ${entry}/`);
370
+ }
371
+ }
372
+ }
373
+
374
+ /**
375
+ * Format a byte count into a compact human-readable string using B, K, or M units.
376
+ * @param {number} bytes - The number of bytes to format.
377
+ * @returns {string} The formatted size: bytes as `N B` (e.g. `512B`), kilobytes truncated to an integer with `K` (e.g. `2K`), or megabytes with one decimal and `M` (e.g. `1.2M`).
378
+ */
379
+ function formatFileSize(bytes) {
380
+ if (bytes > 1024 * 1024) {
381
+ return `${(bytes / 1024 / 1024).toFixed(1)}M`;
382
+ } else if (bytes > 1024) {
383
+ return `${Math.floor(bytes / 1024)}K`;
384
+ }
385
+ return `${bytes}B`;
386
+ }
387
+
388
+ // =============================================================================
389
+ // File System Utilities
390
+ /**
391
+ * Remove any existing build output and recreate the build directory.
392
+ *
393
+ * Ensures the configured BUILD_DIR is empty by deleting it if present and then creating a fresh directory.
394
+ */
395
+
396
+ function cleanBuildDirectory() {
397
+ console.log('Cleaning previous build...');
398
+
399
+ if (fs.existsSync(BUILD_DIR)) {
400
+ fs.rmSync(BUILD_DIR, { recursive: true });
401
+ }
402
+ fs.mkdirSync(BUILD_DIR, { recursive: true });
403
+ }
404
+
405
+ /**
406
+ * Recursively copies all files and subdirectories from one directory to another, creating the destination if needed.
407
+ *
408
+ * @param {string} src - Path to the source directory to copy from.
409
+ * @param {string} dest - Path to the destination directory to copy to.
410
+ * @param {string[]} [exclude=[]] - List of file or directory names (not paths) to skip while copying.
411
+ * @returns {boolean} `true` if the source existed and copying proceeded, `false` if the source did not exist.
412
+ */
413
+ function copyDirectory(src, dest, exclude = []) {
414
+ if (!fs.existsSync(src)) return false;
415
+ fs.mkdirSync(dest, { recursive: true });
416
+
417
+ for (const entry of fs.readdirSync(src, { withFileTypes: true })) {
418
+ if (exclude.includes(entry.name)) continue;
419
+
420
+ const srcPath = path.join(src, entry.name);
421
+ const destPath = path.join(dest, entry.name);
422
+
423
+ if (entry.isDirectory()) {
424
+ copyDirectory(srcPath, destPath, exclude);
425
+ } else {
426
+ fs.copyFileSync(srcPath, destPath);
427
+ }
428
+ }
429
+ return true;
430
+ }
431
+
432
+ // =============================================================================
433
+ // Console Output Formatting
434
+ // =============================================================================
435
+
436
+ function printHeader(title) {
437
+ console.log();
438
+ console.log('┌' + '─'.repeat(62) + '┐');
439
+ console.log(`│ ${title.padEnd(60)} │`);
440
+ console.log('└' + '─'.repeat(62) + '┘');
441
+ }
442
+
443
+ /**
444
+ * Prints a centered decorative ASCII banner to the console using the provided title.
445
+ * @param {string} title - Text to display centered inside the banner. */
446
+ function printBanner(title) {
447
+ console.log('╔' + '═'.repeat(62) + '╗');
448
+ console.log(`║${title.padStart(31 + title.length / 2).padEnd(62)}║`);
449
+ console.log('╚' + '═'.repeat(62) + '╝');
450
+ }