MSX2 BASIC Knowledge Base
A source-grounded knowledge base for a future model that reads and generates MSX2 BASIC programs, supported by language documentation, authentic program listings, and validation tools.
A chronological record of the requests that shaped the MSX2 BASIC knowledge base — from its initial structure to validation tools and generation rules.
This selected history contains user requests and accompanying context notes. Entry 001 was backfilled on September 19, 2026; its original receipt time is unavailable. Automatically injected application context is excluded.
Stage 1. Prepare knowledge about the language. What format should the documentation use? What file types and/or file structures should be used?
002
User promptOriginal English
Populate the knowledge base
We are going to build language-knowledge base for the future MSX2 Basic Model.
Read the book in the folder @"C:WorkspaceMSX2_LLMMSX2 docs"
Go other language-knowledge and fill in relevant data.
Remove irrelevant stub files.
File extension for basic files is .bas
Recursively read this path: C:WorkspaceMSX2_LLMMSX2 docsBAS Examples
These are real, correct programs written in MSX2 Basic.
Improve language-knowledge
You had used a two pass detokenizer. Create a powershell script with the detokinizer in tools/detokinizer
005
User prompt
Level-one syntax checker
### Build a syntax checker
Having a checker will greatly improve the result, but it does not have to be ready before the first prototype.
It is better to divide validation into three levels.
#### Level 1 — a simple validator
Implement:
- maximum line length checks;
- string literal validity checks;
- balanced parentheses checks;
- known command checks;
- command parameter checks;
- reference checks for `GOTO`, `GOSUB`, `THEN`, `RESTORE`;
- `FOR`/`NEXT` matching;
- `IF` compliance with MSX BASIC syntax;
- checks that called subroutines exist;
Place the checker script in tools/syntaxChecker
006
User prompt
BASIC generation rules in AGENTS
Add to AGENTS:
# MSX2 BASIC generation rules
1. Generate code only for MSX2 BASIC.
2. Do not use GW-BASIC, QuickBASIC, or Visual Basic syntax.
3. Before generation, find the following in language-knowledge:
- a description of every command used;
- at least one similar example program.
4. Do not invent commands, functions, or parameters.
5. All GOTO, GOSUB, THEN, and RESTORE jumps must lead
to existing lines.
6. Check FOR/NEXT and GOSUB/RETURN matching.
7. Take the selected SCREEN mode into account.
8. Return the complete program listing by default.
9. If a required capability is not described in the knowledge base,
report this instead of inventing syntax.
007
User prompt
Root knowledge routing index
Add a root index, for example:
language-knowledge/
├── INDEX.md
├── registry/
│ └── commands.yaml
├── commands/
├── specification/
├── examples/
└── grammar/
Describe routing in INDEX.md, for example:
# Knowledge index
## Graphics
- commands/screen.md
- commands/line.md
- commands/circle.md
- examples/graphics/
## Sprites
- commands/sprite.md
- commands/put-sprite.md
- examples/sprites/
## Sound
- commands/sound.md
- commands/play.md
- examples/sound/
## Files
- commands/open.md
- commands/close.md
- commands/input.md
- examples/files/
So that the agent reads INDEX.md first instead of scanning all of language-knowledge.
External AI contribution
An external AI result was used and added here.
External prompt: