c64bridge 0.5.0
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/.github/prompts/README.md +6 -0
- package/.github/prompts/assembly-routine-session.prompt.md +13 -0
- package/.github/prompts/basic-program-session.prompt.md +13 -0
- package/.github/prompts/drive-management-session.prompt.md +13 -0
- package/.github/prompts/petscii-art-session.prompt.md +13 -0
- package/.github/prompts/play-classic-game.prompt.md +13 -0
- package/.github/prompts/sid-music-session.prompt.md +13 -0
- package/AGENTS.md +173 -0
- package/LICENSE +339 -0
- package/README.md +582 -0
- package/data/README.md +16 -0
- package/data/api/basic-api-spec.md +154 -0
- package/data/api/kernal-api-spec.md +68 -0
- package/data/assembly/assembly-spec.md +196 -0
- package/data/assembly/examples/effects/sinewave.asm +5 -0
- package/data/assembly/examples/graphics/sprite/mover.asm +15 -0
- package/data/assembly/examples/sid-file-structure.md +8 -0
- package/data/assembly/examples/sid-overview.md +11 -0
- package/data/audio/examples/Biosphere.sid +0 -0
- package/data/audio/sid-file-structure.md +91 -0
- package/data/audio/sid-programming-best-practices.md +198 -0
- package/data/audio/sid-spec.md +166 -0
- package/data/audio/sidwave.md +131 -0
- package/data/audio/sidwave.schema.json +64 -0
- package/data/basic/basic-spec.md +230 -0
- package/data/basic/examples/audio/alle-meine-entchen-expressive.bas +41 -0
- package/data/basic/examples/audio/c-major-scale-pleasant.bas +29 -0
- package/data/basic/examples/io/joystick.bas +5 -0
- package/data/basic/examples/video/bounce.bas +8 -0
- package/data/basic/examples/video/entchen-petscii.bas +16 -0
- package/data/basic/examples/video/hello-world.bas +4 -0
- package/data/basic/examples/video/wave.bas +7 -0
- package/data/context/bootstrap.md +148 -0
- package/data/context/chat.md +36 -0
- package/data/drive/drive-spec.md +215 -0
- package/data/embeddings_asm.json +1 -0
- package/data/embeddings_basic.json +1 -0
- package/data/embeddings_hardware.json +1 -0
- package/data/embeddings_mixed.json +1 -0
- package/data/embeddings_other.json +1 -0
- package/data/io/cia-spec.md +115 -0
- package/data/io/io-spec.md +124 -0
- package/data/memory/kernal-memory-map.md +227 -0
- package/data/memory/low-memory-map.md +133 -0
- package/data/memory/memory-map.md +186 -0
- package/data/printer/printer-commodore-bitmap.md +31 -0
- package/data/printer/printer-commodore.md +28 -0
- package/data/printer/printer-epson-bitmap.md +29 -0
- package/data/printer/printer-epson.md +30 -0
- package/data/printer/printer-prompts.md +29 -0
- package/data/printer/printer-spec.md +180 -0
- package/data/video/character-set.csv +257 -0
- package/data/video/vic-spec.md +276 -0
- package/dist/assemblyConverter.js +1299 -0
- package/dist/audio/record_and_analyze_audio.js +292 -0
- package/dist/basicConverter.js +193 -0
- package/dist/bootstrap/stdio-logger.js +32 -0
- package/dist/c64Client.js +1052 -0
- package/dist/chargen.js +197 -0
- package/dist/config.js +142 -0
- package/dist/context.js +157 -0
- package/dist/device.js +413 -0
- package/dist/index.js +7 -0
- package/dist/knowledge.js +454 -0
- package/dist/logger.js +182 -0
- package/dist/loggingHttpClient.js +88 -0
- package/dist/mcp-server.js +426 -0
- package/dist/petscii.js +135 -0
- package/dist/petsciiArt.js +356 -0
- package/dist/platform.js +82 -0
- package/dist/prompts/registry.js +560 -0
- package/dist/rag/discover.config.json +41 -0
- package/dist/rag/discover.js +401 -0
- package/dist/rag/embeddings.js +60 -0
- package/dist/rag/externalFetcher.js +934 -0
- package/dist/rag/indexer.js +770 -0
- package/dist/rag/init.js +139 -0
- package/dist/rag/knowledgeIndex.js +361 -0
- package/dist/rag/loggingRetriever.js +46 -0
- package/dist/rag/rateLimiter.js +127 -0
- package/dist/rag/retriever.js +74 -0
- package/dist/rag/sources.csv +31 -0
- package/dist/rag/types.js +5 -0
- package/dist/rag/urlUtils.js +38 -0
- package/dist/sidplayRunner.js +240 -0
- package/dist/sidwave.js +101 -0
- package/dist/sidwaveCompiler.js +329 -0
- package/dist/tools/audio.js +944 -0
- package/dist/tools/developer.js +515 -0
- package/dist/tools/errors.js +59 -0
- package/dist/tools/graphics.js +469 -0
- package/dist/tools/machineControl.js +267 -0
- package/dist/tools/memory.js +224 -0
- package/dist/tools/printer.js +482 -0
- package/dist/tools/programRunners.js +315 -0
- package/dist/tools/rag.js +153 -0
- package/dist/tools/registry.js +58 -0
- package/dist/tools/responses.js +36 -0
- package/dist/tools/schema.js +304 -0
- package/dist/tools/storage.js +740 -0
- package/dist/tools/streaming.js +132 -0
- package/dist/tools/types.js +99 -0
- package/dist/viceRunner.js +239 -0
- package/doc/MCP_SETUP.md +153 -0
- package/doc/README.md +7 -0
- package/doc/developer.md +312 -0
- package/doc/img/logo.png +0 -0
- package/doc/img/prompts/duck_petscii.png +0 -0
- package/doc/img/prompts/duck_song.png +0 -0
- package/doc/img/vscode/vscode-copilot-c64-chat-mode.png +0 -0
- package/doc/img/vscode/vscode-copilot-hello-world.png +0 -0
- package/doc/prompts/README.md +96 -0
- package/doc/prompts/user-prompt-ideas.md +147 -0
- package/doc/rest/c64-openapi.yaml +979 -0
- package/doc/rest/c64-rest-api.md +106 -0
- package/doc/troubleshooting-mcp.md +177 -0
- package/generated/c64/index.js +857 -0
- package/mcp.json +106 -0
- package/package.json +79 -0
- package/scripts/c64-cli.mjs +142 -0
- package/scripts/c64-tool.sh +83 -0
- package/scripts/check-package.mjs +89 -0
- package/scripts/cli.js +61 -0
- package/scripts/fetch-external-sources.mjs +67 -0
- package/scripts/generate-changelog.mjs +131 -0
- package/scripts/postbuild.mjs +101 -0
- package/scripts/prepare-release.mjs +58 -0
- package/scripts/rag-rebuild.mjs +53 -0
- package/scripts/register-ts-node.mjs +6 -0
- package/scripts/run-mcp-check.sh +104 -0
- package/scripts/run-tests.mjs +195 -0
- package/scripts/sid2wav.sh +94 -0
- package/scripts/smoke-run.sh +65 -0
- package/scripts/start-mock-c64.mjs +51 -0
- package/scripts/start-mock.mjs +31 -0
- package/scripts/start.mjs +72 -0
- package/scripts/update-readme.ts +164 -0
- package/scripts/verify-package.mjs +147 -0
package/README.md
ADDED
|
@@ -0,0 +1,582 @@
|
|
|
1
|
+

|
|
2
|
+
|
|
3
|
+
# C64 Bridge
|
|
4
|
+
|
|
5
|
+
Your AI Command Bridge for the Commodore 64.
|
|
6
|
+
|
|
7
|
+
[](https://www.npmjs.com/package/c64bridge)
|
|
8
|
+
[](https://github.com/chrisgleissner/c64bridge/actions/workflows/ci.yaml)
|
|
9
|
+
[](https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html)
|
|
10
|
+
[](doc/developer.md)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
## About
|
|
14
|
+
|
|
15
|
+
C64 Bridge is a Model Context Protocol ([MCP](https://modelcontextprotocol.io/docs/getting-started/intro)) server for driving a Commodore 64 with AI via the REST API of the [Commodore 64 Ultimate](https://www.commodore.net/) or [Ultimate 64](https://ultimate64.com/). It is built on the official TypeScript `@modelcontextprotocol/sdk` and communicates over the stdio transport.
|
|
16
|
+
|
|
17
|
+
Exposes tools and knowledge that enable [LLM agents](https://www.promptingguide.ai/research/llm-agents) to upload and run BASIC or assembly programs, read/write RAM, control the VIC or SID, print documents, and more.
|
|
18
|
+
|
|
19
|
+
## Features ✨
|
|
20
|
+
|
|
21
|
+
- **Code** in Basic or Assembly
|
|
22
|
+
- **Compose** music
|
|
23
|
+
- **Create** PETSCII drawings
|
|
24
|
+
- **Custom Knowledge Base** with built-in local Retrieval-Augmented Generation ([RAG](https://en.wikipedia.org/wiki/Retrieval-augmented_generation)) for prompt enrichment
|
|
25
|
+
|
|
26
|
+
## What is MCP?
|
|
27
|
+
|
|
28
|
+
The **Model Context Protocol (MCP)** defines a universal, secure, and consistent way for LLM-based applications to connect with external systems and data sources.
|
|
29
|
+
|
|
30
|
+
Often called [*“the USB-C port for AI”*](https://docs.anthropic.com/en/docs/mcp), it provides a standardized interface that allows language models to access information and perform actions safely, predictably, and repeatably.
|
|
31
|
+
|
|
32
|
+
Although it resembles a traditional API, MCP is designed specifically for the way LLMs think and interact. An MCP server can:
|
|
33
|
+
|
|
34
|
+
- **Expose data** through **Resources** — structured information the model can draw into its working context.
|
|
35
|
+
- **Provide functionality** through **Tools** — executable actions that perform tasks or cause effects.
|
|
36
|
+
- **Offer guidance** through **Prompts** — reusable conversation patterns for complex operations.
|
|
37
|
+
|
|
38
|
+
**C64 Bridge** applies this to the **Commodore 64**, serving as an **AI bridge and control deck**.
|
|
39
|
+
|
|
40
|
+
You’re the Commodore at the helm — AI assists, extending the reach of your commands into the 8-bit world.
|
|
41
|
+
|
|
42
|
+
## Examples 🎬
|
|
43
|
+
|
|
44
|
+
Let's compose a children song on the C64 using ChatGPT and VS Code:
|
|
45
|
+
|
|
46
|
+
1. We type the prompt:
|
|
47
|
+
`play a children song on the c64`.
|
|
48
|
+
1. ChatGPT reads our prompt and creates a song. In this case it creates a Basic program that plays a song, but direct SID creation is work in progress.
|
|
49
|
+
1. The LLM then uses this MCP to transfer the Basic program to the Ultimate 64 and play it.
|
|
50
|
+
|
|
51
|
+
The following image shows the final output, using the [C64 Stream](https://github.com/chrisgleissner/c64stream/) OBS plugin to capture the C64 video and audio output:
|
|
52
|
+
|
|
53
|
+

|
|
54
|
+
|
|
55
|
+
1. After the follow-up prompt `Now create a PETSCII image related to that song` the following image of ducks swimming on a pond appears:
|
|
56
|
+
|
|
57
|
+

|
|
58
|
+
|
|
59
|
+
...and our C64 is now AI-powered!
|
|
60
|
+
|
|
61
|
+
## Installation 📦
|
|
62
|
+
|
|
63
|
+
The installation consists of two steps: Installing Node.js and then installing and running the MCP server.
|
|
64
|
+
|
|
65
|
+
### Install Node.js
|
|
66
|
+
|
|
67
|
+
Requires Node.js 18+ (20+ recommended) and npm.
|
|
68
|
+
|
|
69
|
+
- Linux (Ubuntu/Debian)
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
sudo apt update
|
|
73
|
+
sudo apt install -y curl ca-certificates
|
|
74
|
+
# Option A: distro packages (may be older)
|
|
75
|
+
sudo apt install -y nodejs npm
|
|
76
|
+
# Option B (recommended): NodeSource LTS (20.x)
|
|
77
|
+
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
|
|
78
|
+
sudo apt install -y nodejs
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
- macOS
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" # if Homebrew not installed
|
|
85
|
+
brew install node@20
|
|
86
|
+
brew link --overwrite node@20
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
- Windows
|
|
90
|
+
|
|
91
|
+
```powershell
|
|
92
|
+
# Option A: winget (Windows 10/11)
|
|
93
|
+
winget install OpenJS.NodeJS.LTS
|
|
94
|
+
# Option B: Chocolatey
|
|
95
|
+
choco install nodejs-lts -y
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Verify:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
node --version # v18+ (v20+ recommended)
|
|
102
|
+
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Install and Run the MCP Server
|
|
106
|
+
|
|
107
|
+
You have three options to install and run the MCP server: quick start with npx, persistent install via npm, or install from source via GitHub if you want to run tests and contribute.
|
|
108
|
+
|
|
109
|
+
#### Quick start (npx, zero-setup)
|
|
110
|
+
|
|
111
|
+
Run the prebuilt server without creating a project. npx downloads the package and expands all bundled files on disk for this session.
|
|
112
|
+
|
|
113
|
+
```sh
|
|
114
|
+
npx -y c64bridge@latest
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
By default, the MCP server looks for `~/.c64bridge.json`. To target your device, create:
|
|
118
|
+
|
|
119
|
+
```json
|
|
120
|
+
{
|
|
121
|
+
"c64u": {
|
|
122
|
+
"host": "<hostname or IP>",
|
|
123
|
+
"port": 80
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
#### Persistent install (npm)
|
|
129
|
+
|
|
130
|
+
This installs the prebuilt `c64bridge` Node package from [npm](https://www.npmjs.com/package/c64bridge) and then runs the server. No build step required.
|
|
131
|
+
|
|
132
|
+
1. Create a folder (or use an existing project) and install the package:
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
mkdir -p ~/c64bridge && cd ~/c64bridge
|
|
136
|
+
npm init -y
|
|
137
|
+
npm install c64bridge
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
1. Configure your C64 target (optional but recommended):
|
|
141
|
+
|
|
142
|
+
Create `~/.c64bridge.json` with your device settings:
|
|
143
|
+
|
|
144
|
+
```json
|
|
145
|
+
{ "c64u": { "host": "c64u" } }
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
1. Start the server (stdio MCP):
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
node ./node_modules/c64bridge/dist/index.js
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
Notes
|
|
155
|
+
|
|
156
|
+
- Works fully offline. The npm package bundles `doc/`, `data/`, and `mcp.json`.
|
|
157
|
+
- All environment flags (e.g., `RAG_BUILD_ON_START=1`) apply the same as in a source checkout.
|
|
158
|
+
- Using npx or a local install both place the package contents on the filesystem in expanded form.
|
|
159
|
+
|
|
160
|
+
#### Install from source (GitHub)
|
|
161
|
+
|
|
162
|
+
Use this path if you plan to run tests or contribute code; `npm start` automatically prefers the TypeScript sources (via ts-node) when they are available and falls back to the compiled JavaScript otherwise.
|
|
163
|
+
|
|
164
|
+
1. Clone and install dependencies
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
git clone https://github.com/chrisgleissner/c64bridge.git
|
|
168
|
+
cd c64bridge
|
|
169
|
+
npm install
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
1. Start the development server
|
|
173
|
+
|
|
174
|
+
```bash
|
|
175
|
+
npm start
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
The dev server runs via ts-node; to build the compiled output, you can run:
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
npm run build
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
By default the server speaks MCP over stdio, which is the recommended mode for local editor integrations such as GitHub Copilot. If you need to expose the server to other machines, you can bridge it over HTTP with:
|
|
185
|
+
|
|
186
|
+
```bash
|
|
187
|
+
npm start -- --http [<port>]
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
Omitting the port uses `8000`. Only switch to HTTP when remote clients require it; stdio remains the preferred option because it avoids extra networking and keeps tool discovery automatic inside your editor.
|
|
191
|
+
|
|
192
|
+
### Setup GitHub Copilot in VS Code 💻
|
|
193
|
+
|
|
194
|
+
GitHub Copilot Chat (version 1.214+) includes native MCP support. To enable C64 Bridge integration:
|
|
195
|
+
|
|
196
|
+
#### Step 1: Enable MCP in Copilot Chat
|
|
197
|
+
|
|
198
|
+
- Open VS Code and ensure GitHub Copilot Chat extension is installed and signed in.
|
|
199
|
+
- Open **Settings** → **Extensions** → **GitHub Copilot** → **Chat: Experimental: MCP**.
|
|
200
|
+
- Enable the **MCP** checkbox.
|
|
201
|
+
- Restart VS Code.
|
|
202
|
+
|
|
203
|
+
#### Step 2: Configure the C64 Bridge Server
|
|
204
|
+
|
|
205
|
+
Add this configuration to your workspace `.vscode/settings.json` (stdio transport):
|
|
206
|
+
|
|
207
|
+
```json
|
|
208
|
+
{
|
|
209
|
+
"github.copilot.chat.experimental.mcp": {
|
|
210
|
+
"servers": [
|
|
211
|
+
{
|
|
212
|
+
"name": "c64bridge",
|
|
213
|
+
"command": "node",
|
|
214
|
+
"args": ["./node_modules/c64bridge/dist/index.js"],
|
|
215
|
+
"type": "stdio"
|
|
216
|
+
}
|
|
217
|
+
]
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
MCP clients discover tools dynamically at runtime; no manifest file is required.
|
|
223
|
+
|
|
224
|
+
#### Step 3: Start the MCP Server
|
|
225
|
+
|
|
226
|
+
Normally it gets started automatically, but if not, please see the previous chapter on [Installing and Running the MCP Server](#install-and-run-the-mcp-server).
|
|
227
|
+
|
|
228
|
+
Keep this running—it will log successful connectivity to your C64 device.
|
|
229
|
+
|
|
230
|
+
#### Step 4: Use MCP Tools in Copilot Chat
|
|
231
|
+
|
|
232
|
+
More system, drive, file, streaming, and SID tools are available. For the full list and parameters, ask the MCP client to list tools.
|
|
233
|
+
|
|
234
|
+
#### Step 5: Activate the C64 Chat Mode
|
|
235
|
+
|
|
236
|
+
1. In VS Code, select **Menu → View → Chat** to open the Copilot Chat window.
|
|
237
|
+
1. At the bottom of that window, use the drop-down that lists `Agent`, `Ask`, `Edit`, and `C64`. The `C64` option should be auto-discovered from the `.github/chatmodes/c64.chatmode.md` file bundled with this project.
|
|
238
|
+
1. Select **C64** to switch into the dedicated chat mode, as shown below.
|
|
239
|
+

|
|
240
|
+
|
|
241
|
+
#### Step 6: Run Your First C64 AI Prompt
|
|
242
|
+
|
|
243
|
+
Prompt Copilot with **"Print a greeting on the screen"** to watch the MCP server upload and execute a BASIC greeting on your C64.
|
|
244
|
+
|
|
245
|
+
You should now see a greeting on the screen of your C64 device:
|
|
246
|
+
|
|
247
|
+

|
|
248
|
+
|
|
249
|
+
## Documentation 📚
|
|
250
|
+
|
|
251
|
+
- [`mcp.json`](mcp.json): project configuration (entry point, env vars, metadata).
|
|
252
|
+
- [`AGENTS.md`](AGENTS.md) — Quick-start guidance for automation agents and persona definitions.
|
|
253
|
+
- [`doc/MCP_SETUP.md`](doc/MCP_SETUP.md) — More details on MCP setup and integration with Visual Code.
|
|
254
|
+
- [`doc/developer.md`](doc/developer.md) — Development environment and workflow details. Also covers how to extend and rebuild the local RAG embeddings.
|
|
255
|
+
- [`doc/rest/c64-openapi.yaml`](doc/rest/c64-openapi.yaml) — OpenAPI 3.1 description of the REST surface.
|
|
256
|
+
- [`data/context/bootstrap.md`](data/context/bootstrap.md) — Core primer injected ahead of agent prompts.
|
|
257
|
+
|
|
258
|
+
## Configuration ⚙️
|
|
259
|
+
|
|
260
|
+
The MCP server reads its configuration from a JSON file called `.c64bridge.json` which is resolved as follows (first match wins):
|
|
261
|
+
|
|
262
|
+
1. explicit `C64BRIDGE_CONFIG` env var containing the absolute path to the config file
|
|
263
|
+
1. `~/.c64bridge.json` (from user home)
|
|
264
|
+
1. `./c64bridge.json` (from current working directory)
|
|
265
|
+
|
|
266
|
+
If no config file is found, it uses defaults: `host=c64u`, `port=80`
|
|
267
|
+
|
|
268
|
+
The configuration has a dedicated section for each supported platform (i.e. a real or software-emulated C64 device) as described in the chapters below.
|
|
269
|
+
|
|
270
|
+
### C64U (real hardware)
|
|
271
|
+
|
|
272
|
+
Use this section to point the server at an Commodore 64 Ultimate or Ultimate 64 device.
|
|
273
|
+
|
|
274
|
+
Provide the host (DNS name or IP, defaults to `c64u`) and a port (defaults to `80`).
|
|
275
|
+
|
|
276
|
+
```json
|
|
277
|
+
{
|
|
278
|
+
"c64u": {
|
|
279
|
+
"host": "c64u",
|
|
280
|
+
"port": 80
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
### VICE (software emulator)
|
|
286
|
+
|
|
287
|
+
> [!NOTE] This is an experimental feature that is currently very limited.
|
|
288
|
+
|
|
289
|
+
This backend starts a fresh [VICE](https://vice-emu.sourceforge.io/) process for each PRG run using the emulator binary. In phase one, memory/register operations are not supported; the focus is deterministic PRG execution.
|
|
290
|
+
|
|
291
|
+
```json
|
|
292
|
+
{
|
|
293
|
+
"vice": {
|
|
294
|
+
"exe": "/usr/bin/x64sc"
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
Notes:
|
|
300
|
+
|
|
301
|
+
- If `vice.exe` is not set, the server attempts to find `x64sc` (or `x64`) on your `PATH`.
|
|
302
|
+
- Each program execution spawns a new VICE instance, e.g.:
|
|
303
|
+
|
|
304
|
+
```bash
|
|
305
|
+
x64sc -autostart "program.prg" -silent -warp
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
### Backend selection rules
|
|
309
|
+
|
|
310
|
+
Backend selection is automatic with clear logging. The following precedence applies:
|
|
311
|
+
|
|
312
|
+
1. Explicit override: if `C64_MODE=c64u` or `C64_MODE=vice` is set in the environment, that backend is used.
|
|
313
|
+
2. Config presence: if only one of `c64u` or `vice` is configured, it is used.
|
|
314
|
+
3. Both configured: prefer `c64u` unless VICE is explicitly requested via `C64_MODE=vice`.
|
|
315
|
+
4. No configuration: probe the default C64U address (`http://c64u`); if unavailable, fall back to VICE.
|
|
316
|
+
|
|
317
|
+
On startup, the server logs the selected backend and reason, for example:
|
|
318
|
+
|
|
319
|
+
- `Active backend: c64u (from config)`
|
|
320
|
+
- `Active backend: vice (fallback – hardware unavailable)`
|
|
321
|
+
|
|
322
|
+
### Log Level
|
|
323
|
+
|
|
324
|
+
By default, the server logs info-level messages and above.
|
|
325
|
+
|
|
326
|
+
To enable debug logging, set the environment variable `LOG_LEVEL=debug` before starting the server.
|
|
327
|
+
|
|
328
|
+
In Visual Code, you can achieve this via an entry in your `.env` file at the project root:
|
|
329
|
+
|
|
330
|
+
```txt
|
|
331
|
+
LOG_LEVEL=debug
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
Please note that all logs use `stderr` since `stdout` is reserved for the MCP protocol messages.
|
|
335
|
+
|
|
336
|
+
## Build & Test 🧪
|
|
337
|
+
|
|
338
|
+
- `npm run build` — type-check the TypeScript sources, normalize the dist layout for packaging, and regenerate the MCP API tables in `README.md`.
|
|
339
|
+
- `npm test` — run the integration tests against an in-process mock that emulates the c64 REST API.
|
|
340
|
+
- `npm test -- --real` — exercise the same tests against a real c64 device. The runner reuses your MCP config (`~/.c64bridge.json` or `C64BRIDGE_CONFIG`) to determine the REST endpoint. You can also override explicitly with `--base-url=http://<host>`.
|
|
341
|
+
- `npm run check` — convenience command that runs both the type-check and the mock-backed test suite.
|
|
342
|
+
|
|
343
|
+
The test runner accepts the following options:
|
|
344
|
+
|
|
345
|
+
- `--mock` (default): use the bundled mock hardware emulator.
|
|
346
|
+
- `--real`: talk to physical hardware (requires reachable C64 device).
|
|
347
|
+
- `--base-url=http://host[:port]`: override the REST endpoint when running with `--real`.
|
|
348
|
+
|
|
349
|
+
## MCP API Reference
|
|
350
|
+
|
|
351
|
+
<!-- AUTO-GENERATED:MCP-DOCS-START -->
|
|
352
|
+
|
|
353
|
+
### Tools
|
|
354
|
+
|
|
355
|
+
#### Programs
|
|
356
|
+
> Program uploaders, runners, and compilation workflows for BASIC, assembly, and PRG files.
|
|
357
|
+
|
|
358
|
+
**Workflow hints:**
|
|
359
|
+
- Choose BASIC or assembly uploaders based on the language you just generated for the user.
|
|
360
|
+
- Prefer PRG or CRT runners when the user supplies an Ultimate filesystem path instead of source text.
|
|
361
|
+
|
|
362
|
+
**Default tags:** `programs`, `execution`
|
|
363
|
+
|
|
364
|
+
| Name | Description | Tags |
|
|
365
|
+
| --- | --- | --- |
|
|
366
|
+
| `load_prg_file` | Load a PRG into C64 memory without executing it. | `programs`, `execution`, `file` |
|
|
367
|
+
| `run_crt_file` | Run a cartridge image stored on the Ultimate filesystem. | `programs`, `execution`, `cartridge` |
|
|
368
|
+
| `run_prg_file` | Run a PRG located on the Ultimate filesystem without uploading source. | `programs`, `execution`, `file` |
|
|
369
|
+
| `upload_and_run_asm` | Assemble 6502/6510 source code, upload the PRG, and run it immediately. See c64://specs/assembly. | `programs`, `execution`, `assembly` |
|
|
370
|
+
| `upload_and_run_basic` | Upload a BASIC program to the C64 and execute it immediately. Refer to c64://specs/basic for syntax and device I/O. | `programs`, `execution`, `basic` |
|
|
371
|
+
|
|
372
|
+
#### Memory
|
|
373
|
+
> Screen, main memory, and low-level inspection utilities.
|
|
374
|
+
|
|
375
|
+
**Workflow hints:**
|
|
376
|
+
- Pair memory operations with documentation snippets so addresses and symbols stay meaningful to the user.
|
|
377
|
+
- Confirm intent before mutating RAM and explain how the change affects the running program.
|
|
378
|
+
|
|
379
|
+
**Default tags:** `memory`, `debug`
|
|
380
|
+
|
|
381
|
+
| Name | Description | Tags |
|
|
382
|
+
| --- | --- | --- |
|
|
383
|
+
| `read_memory` | Read a range of bytes from main memory and return the data as hexadecimal. Consult c64://specs/assembly and docs index. | `memory`, `debug`, `hex` |
|
|
384
|
+
| `read_screen` | Read the current text screen (40x25) and return its ASCII representation. For PETSCII details, see c64://specs/basic. | `memory`, `debug`, `screen` |
|
|
385
|
+
| `write_memory` | Write a hexadecimal byte sequence into main memory at the specified address. See c64://context/bootstrap for safety rules. | `memory`, `debug`, `hex`, `write` |
|
|
386
|
+
|
|
387
|
+
#### Audio
|
|
388
|
+
> SID composition, playback, and audio analysis workflows.
|
|
389
|
+
|
|
390
|
+
**Workflow hints:**
|
|
391
|
+
- Reach for SID helpers when the user talks about sound design, playback quality, or stuck notes.
|
|
392
|
+
- After changing playback state, suggest verify-by-ear steps such as analyze_audio so the user gets concrete feedback.
|
|
393
|
+
|
|
394
|
+
**Default tags:** `sid`, `audio`
|
|
395
|
+
|
|
396
|
+
| Name | Description | Tags |
|
|
397
|
+
| --- | --- | --- |
|
|
398
|
+
| `analyze_audio` | Automatically analyze SID playback when the user requests verification feedback. | `sid`, `audio`, `analysis` |
|
|
399
|
+
| `modplay_file` | Play a MOD tracker module stored on the Ultimate filesystem. | `sid`, `audio`, `playback` |
|
|
400
|
+
| `music_compile_and_play` | Compile a SIDWAVE composition to PRG or SID and optionally play it immediately. | `sid`, `audio`, `music`, `compiler` |
|
|
401
|
+
| `music_generate` | Generate a lightweight arpeggio and schedule playback on SID voice 1. | `sid`, `audio`, `music`, `generator` |
|
|
402
|
+
| `record_and_analyze_audio` | Record audio from the default input device and analyze SID playback characteristics. | `sid`, `audio`, `analysis` |
|
|
403
|
+
| `sid_note_off` | Release a SID voice by clearing its GATE bit. | `sid`, `audio`, `control`, `music` |
|
|
404
|
+
| `sid_note_on` | Trigger a SID voice with configurable waveform, pulse width, and ADSR envelope. See c64://specs/sid. | `sid`, `audio`, `control`, `music` |
|
|
405
|
+
| `sid_reset` | Reset the SID chip either softly (silence) or with a full register scrub. | `sid`, `audio`, `control` |
|
|
406
|
+
| `sid_silence_all` | Silence all SID voices by clearing control and envelope registers. | `sid`, `audio`, `control` |
|
|
407
|
+
| `sid_volume` | Set the SID master volume register at $D418. See c64://specs/sid. | `sid`, `audio`, `control` |
|
|
408
|
+
| `sidplay_file` | Play a SID file stored on the Ultimate filesystem via the firmware player. | `sid`, `audio`, `playback` |
|
|
409
|
+
|
|
410
|
+
#### Machine
|
|
411
|
+
> Power, reset, pause/resume, and diagnostic controls for the C64 and Ultimate hardware.
|
|
412
|
+
|
|
413
|
+
**Workflow hints:**
|
|
414
|
+
- Reach for machine controls when the user mentions resets, power states, or DMA pause/resume.
|
|
415
|
+
- Explain the operational impact (e.g. soft reset vs firmware reboot) so the user knows what changed.
|
|
416
|
+
|
|
417
|
+
**Default tags:** `machine`, `control`
|
|
418
|
+
|
|
419
|
+
| Name | Description | Tags |
|
|
420
|
+
| --- | --- | --- |
|
|
421
|
+
| `menu_button` | Toggle the Ultimate 64 menu button. | `machine`, `control`, `menu` |
|
|
422
|
+
| `pause` | Pause the machine using DMA halt. See memory safety checklist in c64://context/bootstrap. | `machine`, `control`, `pause` |
|
|
423
|
+
| `poweroff` | Power off the machine via Ultimate firmware. See safety notes in c64://context/bootstrap. | `machine`, `control`, `power` |
|
|
424
|
+
| `reboot_c64` | Reboot the Ultimate firmware and C64. See c64://context/bootstrap. | `machine`, `control`, `reboot` |
|
|
425
|
+
| `reset_c64` | Reset the C64 via Ultimate firmware. Review c64://context/bootstrap safety rules. | `machine`, `control`, `reset` |
|
|
426
|
+
| `resume` | Resume the machine after a DMA pause. | `machine`, `control`, `resume` |
|
|
427
|
+
|
|
428
|
+
#### Storage
|
|
429
|
+
> Drive management, disk image creation, and file inspection utilities.
|
|
430
|
+
|
|
431
|
+
**Workflow hints:**
|
|
432
|
+
- Reach for storage tools when the user mentions drives, disk images, or Ultimate slots.
|
|
433
|
+
- Spell out which slot or path you touched so the user can replicate actions on hardware.
|
|
434
|
+
|
|
435
|
+
**Default tags:** `drive`, `storage`
|
|
436
|
+
|
|
437
|
+
| Name | Description | Tags |
|
|
438
|
+
| --- | --- | --- |
|
|
439
|
+
| `create_d64` | Create a blank D64 disk image on the Ultimate filesystem. | `drive`, `storage`, `disk`, `create` |
|
|
440
|
+
| `create_d71` | Create a blank D71 disk image on the Ultimate filesystem. | `drive`, `storage`, `disk`, `create` |
|
|
441
|
+
| `create_d81` | Create a blank D81 disk image on the Ultimate filesystem. | `drive`, `storage`, `disk`, `create` |
|
|
442
|
+
| `create_dnp` | Create a blank DNP disk image on the Ultimate filesystem. | `drive`, `storage`, `disk`, `create` |
|
|
443
|
+
| `drive_load_rom` | Temporarily load a custom ROM into an Ultimate drive slot. | `drive`, `storage`, `rom` |
|
|
444
|
+
| `drive_mode` | Set the emulation mode for an Ultimate drive slot (1541/1571/1581). | `drive`, `storage`, `mode` |
|
|
445
|
+
| `drive_mount` | Mount a disk image onto a specific Ultimate drive slot. | `drive`, `storage`, `mount` |
|
|
446
|
+
| `drive_off` | Power off a specific Ultimate drive slot. | `drive`, `storage`, `power` |
|
|
447
|
+
| `drive_on` | Power on a specific Ultimate drive slot. | `drive`, `storage`, `power` |
|
|
448
|
+
| `drive_remove` | Remove the currently mounted disk image from an Ultimate drive slot. | `drive`, `storage`, `unmount` |
|
|
449
|
+
| `drive_reset` | Reset the selected Ultimate drive slot. | `drive`, `storage`, `reset` |
|
|
450
|
+
| `drives_list` | List Ultimate drive slots and their currently mounted images. Read c64://context/bootstrap for drive safety. | `drive`, `storage`, `status` |
|
|
451
|
+
| `file_info` | Inspect metadata for a file on the Ultimate filesystem. | `drive`, `storage`, `info` |
|
|
452
|
+
|
|
453
|
+
#### Graphics
|
|
454
|
+
> PETSCII art, sprite workflows, and VIC-II graphics helpers.
|
|
455
|
+
|
|
456
|
+
**Workflow hints:**
|
|
457
|
+
- Suggest graphics helpers when the user asks for sprites, PETSCII art, or screen layout tweaks.
|
|
458
|
+
- Mention how VIC-II state changes (colours, sprite positions) affect follow-up memory operations.
|
|
459
|
+
|
|
460
|
+
**Default tags:** `graphics`, `vic`
|
|
461
|
+
|
|
462
|
+
| Name | Description | Tags |
|
|
463
|
+
| --- | --- | --- |
|
|
464
|
+
| `create_petscii_image` | Create PETSCII art from prompts or text, optionally run it on the C64, and return metadata. See c64://specs/basic and c64://specs/vic. | `graphics`, `vic`, `petscii`, `basic` |
|
|
465
|
+
| `generate_sprite_prg` | Generate and execute a PRG that displays a sprite from raw 63-byte data. See c64://specs/vic for registers. | `graphics`, `vic`, `sprite`, `assembly` |
|
|
466
|
+
| `render_petscii_screen` | Render PETSCII text to the screen with optional border/background colours. See c64://specs/basic. | `graphics`, `vic`, `basic`, `screen` |
|
|
467
|
+
|
|
468
|
+
#### Printer
|
|
469
|
+
> Printer workflow helpers for Commodore MPS and Epson FX devices, including prompt templates.
|
|
470
|
+
|
|
471
|
+
**Workflow hints:**
|
|
472
|
+
- Reach for printer tools when the user references device 4, hardcopy output, or specific printer models.
|
|
473
|
+
- Clarify which workflow (Commodore vs Epson) you chose so the user can prepare matching paper or ribbons.
|
|
474
|
+
|
|
475
|
+
**Default tags:** `printer`
|
|
476
|
+
|
|
477
|
+
| Name | Description | Tags |
|
|
478
|
+
| --- | --- | --- |
|
|
479
|
+
| `define_printer_chars` | Define custom characters on Commodore MPS printers using DLL mode. | `printer`, `dll`, `commodore` |
|
|
480
|
+
| `print_bitmap_commodore` | Print a Commodore MPS bit-image row using BIM BASIC helpers. | `printer`, `bitmap`, `commodore` |
|
|
481
|
+
| `print_bitmap_epson` | Print an Epson FX bit-image row using ESC/P commands. | `printer`, `bitmap`, `epson` |
|
|
482
|
+
| `print_text` | Print text on device 4 using Commodore or Epson workflows. See c64://docs/printer/guide. | `printer`, `text` |
|
|
483
|
+
|
|
484
|
+
#### Rag
|
|
485
|
+
> Retrieval-augmented generation helpers for BASIC and assembly examples.
|
|
486
|
+
|
|
487
|
+
**Workflow hints:**
|
|
488
|
+
- Call RAG tools when the user needs references or examples before generating new code.
|
|
489
|
+
- Summarise the number of refs returned and suggest follow-up actions like reading specific docs.
|
|
490
|
+
|
|
491
|
+
**Default tags:** `rag`, `search`
|
|
492
|
+
|
|
493
|
+
| Name | Description | Tags |
|
|
494
|
+
| --- | --- | --- |
|
|
495
|
+
| `rag_retrieve_asm` | Retrieve 6502/6510 assembly references from local knowledge. See c64://specs/assembly. | `rag`, `search`, `asm` |
|
|
496
|
+
| `rag_retrieve_basic` | Retrieve BASIC references from local knowledge. See c64://specs/basic before coding. | `rag`, `search`, `basic` |
|
|
497
|
+
|
|
498
|
+
#### Developer
|
|
499
|
+
> Configuration management, diagnostics, and helper utilities for advanced workflows.
|
|
500
|
+
|
|
501
|
+
**Workflow hints:**
|
|
502
|
+
- Use developer tools for firmware configuration, diagnostics, or advanced register tweaks.
|
|
503
|
+
- Call out any risky operations (like flash writes) so the user understands the impact.
|
|
504
|
+
|
|
505
|
+
**Default tags:** `developer`, `config`, `debug`
|
|
506
|
+
|
|
507
|
+
| Name | Description | Tags |
|
|
508
|
+
| --- | --- | --- |
|
|
509
|
+
| `config_batch_update` | Apply multiple configuration changes in a single request. | `developer`, `config`, `debug`, `write` |
|
|
510
|
+
| `config_get` | Read a configuration category or specific item. | `developer`, `config`, `debug`, `read` |
|
|
511
|
+
| `config_list` | List configuration categories available on the Ultimate firmware. | `developer`, `config`, `debug`, `list` |
|
|
512
|
+
| `config_load_from_flash` | Load configuration settings from flash storage. | `developer`, `config`, `debug`, `flash` |
|
|
513
|
+
| `config_reset_to_default` | Reset configuration categories to their factory defaults. | `developer`, `config`, `debug`, `reset` |
|
|
514
|
+
| `config_save_to_flash` | Persist current configuration settings to flash storage. | `developer`, `config`, `debug`, `flash` |
|
|
515
|
+
| `config_set` | Set a configuration value within a category. | `developer`, `config`, `debug`, `write` |
|
|
516
|
+
| `debugreg_read` | Read the Ultimate debug register ($D7FF). | `developer`, `config`, `debug` |
|
|
517
|
+
| `debugreg_write` | Write a value into the Ultimate debug register ($D7FF). | `developer`, `config`, `debug` |
|
|
518
|
+
| `info` | Retrieve Ultimate hardware information and status. | `developer`, `config`, `debug`, `diagnostics`, `info` |
|
|
519
|
+
| `version` | Retrieve Ultimate firmware and API version information. | `developer`, `config`, `debug`, `diagnostics`, `version` |
|
|
520
|
+
|
|
521
|
+
#### Streaming
|
|
522
|
+
> Long-running or streaming workflows such as audio capture or SID playback monitoring.
|
|
523
|
+
|
|
524
|
+
**Workflow hints:**
|
|
525
|
+
- Use streaming tools for long-running capture or monitoring workflows such as audio verification.
|
|
526
|
+
- Clarify that streams keep running until stopped so the user can manage resources.
|
|
527
|
+
|
|
528
|
+
**Default tags:** `stream`, `monitoring`
|
|
529
|
+
|
|
530
|
+
| Name | Description | Tags |
|
|
531
|
+
| --- | --- | --- |
|
|
532
|
+
| `stream_start` | Start an Ultimate streaming session (video/audio/debug) targeting a host:port destination. See c64://docs/index for usage notes. | `stream`, `monitoring`, `start` |
|
|
533
|
+
| `stream_stop` | Stop an Ultimate streaming session (video/audio/debug). | `stream`, `monitoring`, `stop` |
|
|
534
|
+
|
|
535
|
+
### Resources
|
|
536
|
+
|
|
537
|
+
| Name | Summary |
|
|
538
|
+
| --- | --- |
|
|
539
|
+
| `c64://docs/index` | Explains how to approach each knowledge bundle and when to consult it. |
|
|
540
|
+
| `c64://context/bootstrap` | Step-by-step rules for safe automation, verification, and rollback on the C64. |
|
|
541
|
+
| `c64://specs/basic` | Token definitions, syntax rules, and device I/O guidance for BASIC v2. |
|
|
542
|
+
| `c64://specs/assembly` | Official opcode matrix, addressing modes, and zero-page strategy for the 6510 CPU. |
|
|
543
|
+
| `c64://specs/sid` | Register map, waveform behaviour, and ADSR envelopes for expressive SID playback. |
|
|
544
|
+
| `c64://specs/sidwave` | Defines the SIDWAVE interchange format used by the SID composer workflow. |
|
|
545
|
+
| `c64://docs/sid/file-structure` | Explains PSID/RSID headers, metadata blocks, and compatibility notes for imported music. |
|
|
546
|
+
| `c64://specs/vic` | Covers raster timing, sprite control, colour RAM, and bitmap modes on the VIC-II. |
|
|
547
|
+
| `c64://specs/printer` | Covers device setup, control codes, and Ultimate 64 integration for printers. |
|
|
548
|
+
| `c64://docs/printer/guide` | Quick-look workflow covering setup, troubleshooting, and sample jobs for both printer families. |
|
|
549
|
+
| `c64://docs/printer/commodore-text` | Character sets, control codes, and formatting for Commodore MPS text output. |
|
|
550
|
+
| `c64://docs/printer/commodore-bitmap` | Details bitmap modes, graphics commands, and data layout for MPS bitmap printing. |
|
|
551
|
+
| `c64://docs/printer/epson-text` | Lists ESC/P control codes and formatting advice for Epson FX text output. |
|
|
552
|
+
| `c64://docs/printer/epson-bitmap` | Explains bit-image modes, density options, and data packing for Epson bitmap jobs. |
|
|
553
|
+
| `c64://docs/printer/prompts` | Reusable prompt templates that drive complex printer jobs through the MCP server. |
|
|
554
|
+
|
|
555
|
+
### Prompts
|
|
556
|
+
|
|
557
|
+
| Name | Description |
|
|
558
|
+
| --- | --- |
|
|
559
|
+
| `assembly-program` | Author 6502/6510 assembly routines with precise hardware guidance. |
|
|
560
|
+
| `basic-program` | Plan, implement, and verify Commodore BASIC v2 programs safely. |
|
|
561
|
+
| `drive-manager` | Mount, create, or power drives while preserving running workloads. |
|
|
562
|
+
| `graphics-demo` | Create VIC-II graphics demos with safe setup and validation steps. |
|
|
563
|
+
| `memory-debug` | Inspect or patch memory ranges with reversible steps and logging. |
|
|
564
|
+
| `printer-job` | Send formatted output to Commodore or Epson printers with safe teardown steps. |
|
|
565
|
+
| `sid-music` | Compose SID music with expressive phrasing and iterative audio verification. |
|
|
566
|
+
|
|
567
|
+
<!-- AUTO-GENERATED:MCP-DOCS-END -->
|
|
568
|
+
|
|
569
|
+
|
|
570
|
+
|
|
571
|
+
## Troubleshooting 🛟
|
|
572
|
+
|
|
573
|
+
If the MCP server is not reachable or VS Code integration isn't working, see the comprehensive troubleshooting guide:
|
|
574
|
+
|
|
575
|
+
**📋 [MCP Troubleshooting Guide](doc/troubleshooting-mcp.md)**
|
|
576
|
+
|
|
577
|
+
Quick diagnosis commands:
|
|
578
|
+
|
|
579
|
+
```bash
|
|
580
|
+
# Start stdio server
|
|
581
|
+
npm start
|
|
582
|
+
```
|
package/data/README.md
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Data Folder
|
|
2
|
+
|
|
3
|
+
This directory contains the **source knowledge corpus** for the Model Context Protocol (MCP) server. It includes raw reference materials on the **Commodore 64 (C64)** hardware, software, and programming environment. All files in this section are considered **authoritative input data** for the Retrieval-Augmented Generation (RAG) pipeline.
|
|
4
|
+
|
|
5
|
+
Developers may add new source documents here to extend the MCP’s contextual understanding. Supported formats include Markdown (`.md`), plain text (`.txt`), and structured data formats (`.json`, `.csv`). Binary or non-textual assets should be avoided.
|
|
6
|
+
|
|
7
|
+
## RAG Embeddings
|
|
8
|
+
|
|
9
|
+
The `embeddings_*.json` files contain the **vectorized representations** of the knowledge corpus. These are produced by the RAG embedding pipeline using the configuration defined in `src/rag/`. Each file encodes the **semantic embeddings** that power contextual retrieval and reasoning within the MCP AI runtime.
|
|
10
|
+
|
|
11
|
+
The embeddings are generated from:
|
|
12
|
+
|
|
13
|
+
- Documents stored in this directory and its subdirectories.
|
|
14
|
+
- External sources declared in [`src/rag/sources.csv`](../src/rag/sources.csv) and downloaded to the `external` folder.
|
|
15
|
+
|
|
16
|
+
When new knowledge files are added, re-run the embedding process to keep the RAG index synchronized. For more details, see the **Local RAG** chapter in the [README](../README.md).
|