@henols/c64-re-tools 2.3.0-rc.2 → 2.3.0-rc.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@henols/c64-re-tools",
3
- "version": "2.3.0-rc.2",
3
+ "version": "2.3.0-rc.3",
4
4
  "description": "Agent-friendly Commodore 64 engineering toolkit for reverse engineering, debugging, development and testing.",
5
5
  "license": "MIT",
6
6
  "author": "Henrik Olsson",
@@ -26,8 +26,7 @@
26
26
  "tools/",
27
27
  "distribution/package.ts",
28
28
  "distribution/plugin.ts",
29
- "LICENSE",
30
- "README.md"
29
+ "LICENSE"
31
30
  ],
32
31
  "engines": {
33
32
  "node": ">=24.0.0"
@@ -18,9 +18,7 @@ This skill does not run the program and does not change project knowledge.
18
18
  - The output path: where to write the PRG, relative to the project folder.
19
19
  - Optional include directories, symbol definitions and a start address.
20
20
 
21
- ## Tools / execution path
22
-
23
- The script runs ACME on this machine. It copies the source root to a temporary directory, assembles it there and writes the program into the project. The host runtime is not necessary.
21
+ ## Tools
24
22
 
25
23
  ```
26
24
  node <skill>/scripts/assembler.ts build src main.a --out build/game.prg
@@ -38,7 +36,7 @@ node <skill>/scripts/assembler.ts build src main.a --out build/game.prg
38
36
  | `--max-listed 200` | Show at most 200 symbols in the result. The default is 50. `symbols.count` gives the count of all symbols. |
39
37
  | `--out-symbols build/game.json` | Write the symbols to this file as `{"symbols": [...]}`. Without `--all-symbols`, the file does not have the constants that the source does not use. Give this file to the c64-testing skill as the symbols of the rebuild. |
40
38
 
41
- The script copies the full source root. Put all files that the program includes under it. Version control directories stay out.
39
+ Put all files that the program includes under the source root.
42
40
 
43
41
  The target CPU is the 6510. The output is a C64 PRG, or the bytes only with `--plain`.
44
42
 
@@ -103,7 +101,7 @@ With `--compare`, `compare` gives `identical` and `segments`: one check for each
103
101
 
104
102
  - `FAIL` with `assembled: false`: the source has errors. Correct the source.
105
103
  - `FAIL` with `assembled: true`: the build is not identical to the program in the knowledge. Read `compare.segments`.
106
- - `installation-incomplete`, or `machine-unavailable` with a message that the host runtime does not run: stop the task. Give the message to the user and wait for the user. The message gives the remedy. Do not make a replacement for the tool or the host runtime, for example your own disk parser, disassembler or emulator script.
104
+ - `installation-incomplete` or `machine-unavailable`: stop the task. Give the message to the user and wait for the user. Do not install, start or change a tool yourself. Do not make a replacement for the tool, for example your own disk parser, disassembler or emulator script.
107
105
  - `invalid-input`: an option or a path is wrong. Read the message and correct the call.
108
106
  - `not-found`: the source root has no main source file with that name, or no folder with files for an `--include`. Give a path relative to the source root.
109
107
 
@@ -112,4 +110,4 @@ With `--compare`, `compare` gives `identical` and `segments`: one check for each
112
110
  - Run or debug the program → emulator
113
111
  - Compare the rebuild with the original → c64-testing
114
112
  - Pack the program into one small PRG that unpacks itself → c64-packer
115
- - Write a new program, or add a feature or a fix → c64-development
113
+ - Write a new program, or add a feature or a correction → c64-development
@@ -15,9 +15,7 @@ This skill does not run the program and does not change project knowledge.
15
15
 
16
16
  - The program: a PRG file, relative to the project folder.
17
17
 
18
- ## Tools / execution path
19
-
20
- The script sends the program to the host runtime. The host decodes it with petcat and finds the handoffs.
18
+ ## Tools
21
19
 
22
20
  ```
23
21
  node <skill>/scripts/basic.ts list extracted/game.prg
@@ -74,7 +72,7 @@ The listing and the handoff addresses.
74
72
 
75
73
  - `invalid-input` with "is no BASIC program": the file is not a BASIC program. Usually the file is machine code. Give it to the c64-static-analysis skill. A memory dump also gives this error: its first two bytes are not a load address, and its bytes go past `$ffff`.
76
74
  - An empty `handoffs` list: the BASIC does not start machine code with SYS or USR. Do not make up a handoff. Look for a POKE into a vector or a LOAD of another file in the listing.
77
- - `installation-incomplete`, or `machine-unavailable` with a message that the host runtime does not run: stop the task. Give the message to the user and wait for the user. The message gives the remedy. Do not make a replacement for the tool or the host runtime, for example your own disk parser, disassembler or emulator script.
75
+ - `installation-incomplete` or `machine-unavailable`: stop the task. Give the message to the user and wait for the user. Do not install, start or change a tool yourself. Do not make a replacement for the tool, for example your own disk parser, disassembler or emulator script.
78
76
  - `not-found` or another `invalid-input`: the path or an argument is wrong. Read the message and correct the call.
79
77
 
80
78
  ## Handoffs
@@ -17,9 +17,9 @@ This skill does not do the specialist work itself.
17
17
  - The acceptance checks: what the user must see or what memory must hold when the work is complete.
18
18
  - The project: its source, its tests and its knowledge.
19
19
 
20
- ## Tools / execution path
20
+ ## Tools
21
21
 
22
- This skill uses the other skills. It does not use the host runtime or the emulator directly.
22
+ This skill uses the other skills. It does not use the emulator tools directly.
23
23
 
24
24
  | Work | Skill |
25
25
  |---|---|
@@ -159,7 +159,7 @@ A program that builds, with a run file in `tests/` for each acceptance check, an
159
159
 
160
160
  ## Failure and conflicts
161
161
 
162
- - A skill reports `installation-incomplete`, or `machine-unavailable` with a message that the host runtime does not run: stop the whole task. Give the message to the user and wait for the user. Do not continue with other skills. Do not make a replacement for the tool or the host runtime, for example your own assembler or emulator script.
162
+ - A skill reports `installation-incomplete` or `machine-unavailable`: stop the whole task. Give the message to the user and wait for the user. Do not continue with other skills. Do not install, start or change a tool yourself. Do not make a replacement for the tool, for example your own assembler or emulator script.
163
163
  - A tool gives a wrong result: tell the user the defect and the evidence, and wait for the user. Do not make a workaround.
164
164
  - A test gives FAIL: change the program until the test gives PASS. Do not change the expected value to make the test pass. Change an expected value only when the user changes the acceptance check.
165
165
  - A run gives FAIL because a `runUntil` did not get to its target: the program did not get to that state. Find why with the emulator skill.
@@ -18,9 +18,7 @@ This skill does not change the disk image and does not change project knowledge.
18
18
  - To extract a file: the output path, relative to the project folder.
19
19
  - A T64 tape file or a CRT cartridge file, relative to the project folder.
20
20
 
21
- ## Tools / execution path
22
-
23
- The script sends a disk image to the host runtime. The host runs c1541 and sends the result back. The script writes an extracted file into the project. It reads T64 and CRT files itself.
21
+ ## Tools
24
22
 
25
23
  ```
26
24
  node <skill>/scripts/disk.ts <command> <image> [name] [--out <file>]
@@ -82,8 +80,6 @@ A downstream skill records the meaning of the extracted content.
82
80
 
83
81
  ## Tapes and cartridges
84
82
 
85
- The script reads T64 and CRT files itself. The host runtime is not necessary for them.
86
-
87
83
  - T64: `directory` and `read`. Many T64 files have a wrong end address. Then the entry has `fixedSize: true`, and the size comes from the position of the next file.
88
84
  - CRT: `directory` and `crt`. The script reads hardware types 0 (normal 8K, 16K or Ultimax), 5 (Ocean), 19 (Magic Desk) and 32 (EasyFlash). It refuses other types by name. `crt` writes `crt.json` and one PRG for each CHIP packet, for example `bank3-8000.prg`.
89
85
  - A cartridge bank uses the same addresses as other banks. Analyze each bank PRG with c64-static-analysis and `--space bank3`, and record its knowledge in space `bank3`.
@@ -99,8 +95,8 @@ The directory, the BAM, an entry or a sector chain as JSON.
99
95
 
100
96
  - `not-found`: the image file is missing, or the image has no file with that name. Read the directory again and compare the names.
101
97
  - `media-error`: the image, the T64 file or the CRT file has a defect, or its content is not of its type. A CRT with a hardware type that the script does not read also gives `media-error`. The message tells the problem, for example a sector chain that loops. Tell the user. Do not change the file.
102
- - `installation-incomplete`, or `machine-unavailable` with a message that the host runtime does not run: stop the task. Give the message to the user and wait for the user. The message gives the remedy. Do not make a replacement for the tool or the host runtime, for example your own disk parser, disassembler or emulator script.
103
- - `invalid-input`: an argument or a path is wrong. A file with an extension that the command does not take is also wrong. The message gives each type that the command takes. Read the message and correct the call.
98
+ - `installation-incomplete` or `machine-unavailable`: stop the task. Give the message to the user and wait for the user. Do not install, start or change a tool yourself. Do not make a replacement for the tool, for example your own disk parser, disassembler or emulator script.
99
+ - `invalid-input`: an argument or a path is wrong. A file with an extension that the command does not take is also wrong. The message gives each type that the command takes. Read the message and change the call.
104
100
 
105
101
  A file that is not `closed` was not written fully. Its data can be incomplete.
106
102
 
@@ -22,9 +22,7 @@ This skill does not change the knowledge.
22
22
  - The program in the knowledge. Put it in with `image` of the c64-knowledge skill. The reference decodes the tables and shows the graphics from it.
23
23
  - The entry page `README.md` and the directory of the other pages, for example `docs`. The reference goes into a directory of its own, for example `docs/reference`.
24
24
 
25
- ## Tools / execution path
26
-
27
- The script runs on this machine. It does not use the emulator or the host runtime.
25
+ ## Tools
28
26
 
29
27
  ```
30
28
  node <skill>/scripts/docs.ts generate src --out docs/reference
@@ -107,7 +105,7 @@ node <skill>/scripts/docs.ts link README.md docs --source src --check
107
105
 
108
106
  - The reference draws each sprite, bitmap and charset region, and it decodes each table. To get the image of a graphic or the entries of a table, classify its region with c64-knowledge. Do not write a script that draws or decodes them.
109
107
  - A script of the project decodes only a format of the program, for example a packed map or a music stream. Put the script in `tools/` of the project. Its output files are the assets, for example in `assets/rooms/`.
110
- - When the code of the program makes the data, run that code in VICE with a run of c64-testing. Observe the memory, or capture the screen. Do not write a 6502 emulator in the script.
108
+ - When the code of the program makes the data, run that code with a run of c64-testing. Observe the memory, or capture the screen. Do not write a 6502 emulator in the script.
111
109
 
112
110
  In the call graph, a solid arrow is a call, a thick arrow is a table entry, and a dotted arrow is a jump. A table entry goes from each routine that reads the table to each target in code. A table of data addresses gives no arrow.
113
111
 
@@ -17,9 +17,9 @@ This skill does not change the rebuilt project or its knowledge.
17
17
  - The folder of the new project. It must be new or empty, and no project can hold it. Use a folder beside the project, for example `../game-new`.
18
18
  - Optional: the coverage of the runs in the knowledge. Without coverage, nothing becomes free by itself.
19
19
 
20
- ## Tools / execution path
20
+ ## Tools
21
21
 
22
- This skill uses the other skills. It does not use the host runtime directly.
22
+ This skill uses the other skills.
23
23
 
24
24
  | Work | Skill |
25
25
  |---|---|
@@ -75,7 +75,7 @@ A new project folder and a zip file of it. Its build is identical to its baselin
75
75
  - `export` gives FAIL with `stage`: read `reason`. The c64-source skill tells what to do for each stage.
76
76
  - `export` refuses the folder: give a new or empty folder outside every project. Remove a folder or a zip file of an earlier export only when this task made it.
77
77
  - A test of the new project gives FAIL: the export dropped a range that the program uses. Remove the folder and the zip file. Run `export` again with `--keep` for the range, then test again.
78
- - A skill reports `installation-incomplete`, or `machine-unavailable` with a message that the host runtime does not run: stop the whole task. Give the message to the user and wait for the user. Do not make a replacement for the tool or the host runtime.
78
+ - A skill reports `installation-incomplete` or `machine-unavailable`: stop the whole task. Give the message to the user and wait for the user. Do not continue with other skills. Do not install, start or change a tool yourself. Do not make a replacement for the tool.
79
79
 
80
80
  ## Handoffs
81
81
 
@@ -84,4 +84,4 @@ A new project folder and a zip file of it. Its build is identical to its baselin
84
84
  - Switches and the code at an address → c64-knowledge
85
85
  - The build of the new project → c64-assembler
86
86
  - The tests of the new project → c64-testing
87
- - A new feature or a fix in the new project → c64-development
87
+ - A new feature or a correction in the new project → c64-development
@@ -7,7 +7,7 @@ description: Use this skill to read, write, correct and review the durable knowl
7
7
 
8
8
  ## Purpose
9
9
 
10
- Read, write, correct and review the durable understanding of a C64 project. The knowledge also holds the program: its bytes, its entry state and the stages of its unpacker. It holds the coverage of the runs too. The other skills read the program and the coverage from the knowledge. The knowledge is text in `.c64-re-tools/knowledge/` in the project folder: one JSON line for each row. Commit that folder with git. The script keeps an index of the text in `.c64-re-tools/local/knowledge.db` and makes the index again when the text changes. Do not commit the index.
10
+ Read, write, correct and review the durable understanding of a C64 project. The knowledge also holds the program: its bytes, its entry state and the stages of its unpacker. It holds the coverage of the runs too. The other skills read the program and the coverage from the knowledge. The knowledge is text in `.c64-re-tools/knowledge/` in the project folder: one JSON line for each row. Commit that folder with git. The index of the text is `.c64-re-tools/local/knowledge.db`. Do not commit the index.
11
11
 
12
12
  This skill is the only write path for conclusions of the user and the LLM. It does not run an emulator or an analyzer. Write the knowledge only with the script. The script checks each write. Do not write or edit the files in `.c64-re-tools/knowledge/` or the index yourself.
13
13
 
@@ -21,7 +21,7 @@ One of these:
21
21
  - a capture of the c64-unpacker skill, a PRG, or coverage maps to put into the knowledge
22
22
  - a request to see the history or a revision.
23
23
 
24
- ## Tools / execution path
24
+ ## Tools
25
25
 
26
26
  ```
27
27
  node <skill>/scripts/knowledge.ts <command> [subjects] [options]
@@ -223,7 +223,7 @@ Give one selector:
223
223
  | `--value <symbol>` | The symbol plus the offset | `lda bar_colours-1,x` |
224
224
  | `--expr <text>` | ACME expression text with names and numbers | `lda #(sprite_bank + 5*64) / 64` |
225
225
 
226
- - The address is the start of an instruction in a code region. The script decodes the instructions from the start of the region, as `listing` does. It refuses an address in no code region and an operand byte of an instruction. Classify the code first.
226
+ - The address is the start of an instruction in a code region, as `listing` shows it. The script refuses an address in no code region and an operand byte of an instruction. Classify the code first.
227
227
  - `--offset` adds a whole number to the symbol. Write a negative offset as `--offset=-1`.
228
228
  - A name is a symbol of the knowledge or a platform name of the c64-memory-map skill.
229
229
  - `--expr` takes `$`, `%` and decimal numbers, names, brackets, the operators `+ - * / % << >> >>> & | XOR`, and `<`, `>`, `-` and `!` before an operand.
@@ -16,9 +16,7 @@ This skill does not read the emulator and does not change project knowledge.
16
16
  - One or more addresses.
17
17
  - Or a register and a value to decode.
18
18
 
19
- ## Tools / execution path
20
-
21
- The script looks up local reference data. It does not use the host runtime.
19
+ ## Tools
22
20
 
23
21
  ```
24
22
  node <skill>/scripts/memory-map.ts at '$d020' '$0314' '$ffd2'
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: c64-packer
3
- description: Use this skill to pack and crunch a C64 program with Exomizer into one PRG that unpacks itself and starts with RUN. It can merge more PRG files into one program. It unpacks the result in an emulator and checks each byte and the entry before it writes the PRG. Use it to make a small release file of a rebuilt or new program. Do not use it to unpack a packed program. Use the c64-unpacker skill for that.
3
+ description: Use this skill to pack and crunch a C64 program with Exomizer into one PRG that unpacks itself and starts with RUN. It can merge more PRG files into one program. It checks each byte and the entry of the result before it writes the PRG. Use it to make a small release file of a rebuilt or new program. Do not use it to unpack a packed program. Use the c64-unpacker skill for that.
4
4
  ---
5
5
 
6
6
  # c64-packer
@@ -9,7 +9,7 @@ description: Use this skill to pack and crunch a C64 program with Exomizer into
9
9
 
10
10
  Pack and crunch PRG files of the project with Exomizer into one PRG. The PRG loads at $0801, starts with RUN, unpacks the program and jumps to its entry. Check the result before you use it.
11
11
 
12
- This skill does not assemble the program, does not run it in VICE and does not change project knowledge.
12
+ This skill does not assemble the program, does not run it in the emulator and does not change project knowledge.
13
13
 
14
14
  ## Inputs
15
15
 
@@ -18,9 +18,7 @@ This skill does not assemble the program, does not run it in VICE and does not c
18
18
  - The entry: the address where the program starts after the unpack. If the first PRG is a BASIC program at $0801 with `SYS` and a number, the script uses that address.
19
19
  - Optional: the value of $01 when the program starts.
20
20
 
21
- ## Tools / execution path
22
-
23
- The script runs Exomizer on this machine. Exomizer packs the files with `sfx`. Then the script unpacks the result with `desfx` in the 6502 emulator of Exomizer. It compares the unpacked bytes with the bytes of the inputs, and the jump address with the entry. The host runtime is not necessary.
21
+ ## Tools
24
22
 
25
23
  ```
26
24
  node <skill>/scripts/packer.ts pack build/game.prg --out build/game-packed.prg
@@ -29,7 +27,7 @@ node <skill>/scripts/packer.ts pack build/loader.prg build/main.prg --entry '$04
29
27
 
30
28
  | Option | Meaning |
31
29
  |---|---|
32
- | `--entry '$0400'` | The address where the program starts after the unpack. It must be `$0400` or higher. A name of the knowledge is also correct. Without it, the script uses the `SYS` address of the BASIC line of the first input. |
30
+ | `--entry '$0400'` | The address where the program starts after the unpack. It must be `$0400` or higher. It can also be a name of the knowledge. Without it, the script uses the `SYS` address of the BASIC line of the first input. |
33
31
  | `--exit-memory '$35'` | The value of $01 when the program starts, `$34` to `$37`. Without it, the value is `$37`: BASIC, KERNAL and I/O. With it, the program starts with interrupts off. |
34
32
 
35
33
  ### Calling the script
@@ -66,7 +64,7 @@ node <skill>/scripts/packer.ts pack build/loader.prg build/main.prg --entry '$04
66
64
 
67
65
  The packed program starts the unpacker with `SYS 2061`, at $080d. A BASIC program at $0801 often has its entry at $080d too. Then the CPU gets to $080d two times: first before the unpack, then at the start of the program. To examine the program at its entry in the emulator, stop at $080d, run one frame, and stop at $080d again.
68
66
 
69
- The unpacker uses $0334 to $03ff and the zero page while it runs. A program that loads into these addresses can fail. Then Exomizer stops with an error, or the check gives `FAIL`.
67
+ The unpacker uses $0334 to $03ff and the zero page while it runs. A program that loads into these addresses can fail. Then the script gives `operation-failed`, or the check gives `FAIL`.
70
68
 
71
69
  ## Knowledge
72
70
 
@@ -83,11 +81,11 @@ Do not store:
83
81
 
84
82
  - `PASS`: the packed program unpacks to the bytes of all inputs and jumps to the entry. The PRG is at `out`.
85
83
  - `FAIL`: the packed program unpacks to different bytes, or jumps to a different address. The script did not write a file.
86
- - `INCONCLUSIVE`: the emulator of Exomizer keeps only the largest range that the unpacker wrote. Bytes of the inputs outside that range have no check. This occurs when the inputs have gaps between them. The PRG is at `out`.
84
+ - `INCONCLUSIVE`: the check has only the largest range that the unpacker wrote. Bytes of the inputs outside that range have no check. This occurs when the inputs have gaps between them. The PRG is at `out`.
87
85
 
88
86
  Other fields:
89
87
  - `packedBytes` and `unpackedBytes`: the size of the packed PRG and of the bytes of the inputs. `percent` is the packed size as a percentage of the unpacked size.
90
- - `unpackSeconds`: the time of the unpack in the emulator of Exomizer, in seconds at the PAL clock. A real C64 can need more time.
88
+ - `unpackSeconds`: the time of the unpack, in seconds at the PAL clock. A real C64 can need more time.
91
89
  - `inputs`: each input with its `loadRange` and its `bytes`.
92
90
  - `check.entry`: the address where the unpacker jumped.
93
91
  - `check.segments`: one check for each segment of the merged inputs. The `result` of a segment is `identical`, `different` with `firstDifference`, or `not covered`. `firstDifference` gives the `address`, the unpacked byte (`built`) and the input byte (`reference`).
@@ -97,8 +95,8 @@ Other fields:
97
95
  - `FAIL`: do not use the packed program. Read `check`. Give the call and the result to the user.
98
96
  - `invalid-input` with `Give --entry`: the first input has no BASIC line with `SYS` and a number. Give `--entry`.
99
97
  - `invalid-input` for the entry: the entry is below $0400. The unpacker runs there. A program with an entry below $0400 needs a different packer.
100
- - `operation-failed` with `Exomizer could not pack the program`: read the last output of Exomizer in the message. Correct the inputs, or give the message to the user.
101
- - `installation-incomplete`, or `machine-unavailable` with a message that the host runtime does not run: stop the task. Give the message to the user and wait for the user. The message gives the remedy. Do not make a replacement for the tool or the host runtime, for example your own disk parser, disassembler or emulator script.
98
+ - `operation-failed` with `Exomizer could not pack the program`: read the last output of Exomizer in the message. Change the inputs, or give the message to the user.
99
+ - `installation-incomplete` or `machine-unavailable`: stop the task. Give the message to the user and wait for the user. Do not install, start or change a tool yourself. Do not make a replacement for the tool, for example your own disk parser, disassembler or emulator script.
102
100
  - `not-found`: there is no file at an input path. Give a path relative to the project folder.
103
101
 
104
102
  ## Handoffs
@@ -25,9 +25,7 @@ This skill does not change project knowledge.
25
25
  - For one release: the program, the coverage and the other knowledge of the project. Put the program and the coverage in with `image` and `coverage` of the c64-knowledge skill.
26
26
  - For the library: the program and the other knowledge of its project, and the library folder.
27
27
 
28
- ## Tools / execution path
29
-
30
- The script compares the releases locally. Only `--frames` uses the host runtime: each release runs in its own emulator.
28
+ ## Tools
31
29
 
32
30
  ```
33
31
  node <skill>/scripts/provenance.ts compare releases/a.prg releases/b.prg releases/c.prg
@@ -60,7 +58,7 @@ Use `--align` for two releases with added code and moved data. One shift does no
60
58
  - `alignedShare`: the share of the bytes of the two releases that a block holds, with 3 decimals.
61
59
  - Each list shows at most 64 items. `moreBlocks`, `moreOnlyInA` and `moreOnlyInB` give the number of the items that the list does not show. Use `--range` to see them.
62
60
 
63
- With `--frames`, a PRG starts with autostart and RUN. An image starts from its bytes: the script writes the segments and the entry state from `entry_state.json` into the emulator, and starts at the entry. Watchpoints on each difference stop the run at its first access.
61
+ With `--frames`, a PRG starts with autostart and RUN. An image starts at its entry, with the entry state from `entry_state.json`. The run records the first access to each difference.
64
62
 
65
63
  ### Calling the script
66
64
 
@@ -226,7 +224,7 @@ The runtime evidence and the leftovers are evidence only. The script does not de
226
224
  - Do not call a byte original only because one release has it. A majority of releases is also not proof.
227
225
  - `common` is empty: the releases do not cover the same addresses. Use `--shift`, or compare a range that all releases cover.
228
226
  - `run.releases` shows `started: false`: a PRG without a BASIC start, or an image without `entry_state.json`. The reason tells which. The other releases still give evidence.
229
- - `installation-incomplete`, or `machine-unavailable` with a message that the host runtime does not run: stop the task. Give the message to the user and wait for the user. The message gives the remedy. Do not make a replacement for the tool or the host runtime, for example your own emulator script.
227
+ - `installation-incomplete` or `machine-unavailable`: stop the task. Give the message to the user and wait for the user. Do not install, start or change a tool yourself. Do not make a replacement for the tool, for example your own emulator script.
230
228
  - `moreDifferences: true`: the script shows only the first differences. Use `--range` to see the others.
231
229
  - `not-found`: the project has no file at that path.
232
230
  - `not-found` from `match`: the library folder does not exist, or it has no routine files. Save a routine with `routine` first.
@@ -22,9 +22,9 @@ This skill does not do the specialist work itself.
22
22
  - reverse engineer and rebuild the whole program
23
23
  - The current project knowledge.
24
24
 
25
- ## Tools / execution path
25
+ ## Tools
26
26
 
27
- This skill uses the other skills. It does not use the host runtime or the emulator directly.
27
+ This skill uses the other skills. It does not use the emulator tools directly.
28
28
 
29
29
  ### Project folder
30
30
 
@@ -175,7 +175,7 @@ A clear answer for the scope, with the durable conclusions in the project knowle
175
175
 
176
176
  ## Failure and conflicts
177
177
 
178
- - A skill reports `installation-incomplete`, or `machine-unavailable` with a message that the host runtime does not run: stop the whole task. Give the message to the user and wait for the user. Do not continue with other skills. Do not make a replacement for the tool or the host runtime, for example your own disk parser, disassembler or emulator script.
178
+ - A skill reports `installation-incomplete` or `machine-unavailable`: stop the whole task. Give the message to the user and wait for the user. Do not continue with other skills. Do not install, start or change a tool yourself. Do not make a replacement for the tool, for example your own disk parser, disassembler or emulator script.
179
179
  - A tool gives a wrong result, and the exit check of a stage cannot be true. Tell the user the defect and the evidence, and wait for the user. Do not make a workaround, for example a change to a generated file. When the user accepts an exception, give the defect and the exception in the answer of stage 12.
180
180
  - If the evidence does not support a conclusion, keep the unknown and get more evidence. Do not make up a meaning.
181
181
  - Before you replace current knowledge from the user or the LLM, read its history and the evidence for it.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: c64-source
3
- description: Use this skill to generate ACME source code for a C64 program from the project knowledge. The knowledge holds the program, its entry state, the coverage and the names. The script runs Ghidra for the instructions and writes the source files. It checks with ACME that the source assembles to the same bytes as the program. It can also write a loader that sets the entry state of an unpacked program. It can also export the program as the start of a new program. The export is a new project with one value for each switch and without unused code. Use it to make a rebuild. Do not edit the generated files. Change the knowledge and generate again.
3
+ description: Use this skill to generate ACME source code for a C64 program from the project knowledge. The knowledge holds the program, its entry state, the coverage and the names. The script writes the source files. It checks that the source assembles to the same bytes as the program. It can also write a loader that sets the entry state of an unpacked program. It can also export the program as the start of a new program. The export is a new project with one value for each switch and without unused code. Use it to make a rebuild. Do not edit the generated files. Change the knowledge and generate again.
4
4
  ---
5
5
 
6
6
  # c64-source
@@ -15,13 +15,11 @@ This skill does not change the knowledge.
15
15
 
16
16
  - The program in the knowledge. Put it in with `image` of the c64-knowledge skill: a capture of the c64-unpacker skill, or a PRG.
17
17
  - The output directory for the source files, relative to the project folder.
18
- - Optional entry points for Ghidra.
18
+ - Optional entry points of code.
19
19
  - Optional: the coverage in the knowledge. Add it with `coverage` of the c64-knowledge skill.
20
20
  - For the loader: the entry state of a capture in the knowledge.
21
21
 
22
- ## Tools / execution path
23
-
24
- The script runs Ghidra and ACME on this machine. With `--loader`, it also runs the loader in the emulator through the host runtime.
22
+ ## Tools
25
23
 
26
24
  ```
27
25
  node <skill>/scripts/source.ts generate --out src
@@ -32,13 +30,13 @@ node <skill>/scripts/source.ts generate --out src --loader
32
30
  | Option | Meaning |
33
31
  |---|---|
34
32
  | `--out src` | The directory for the source files. The script writes over the files that it generated before. It removes a generated `.asm` file that this run does not write. A run without `--loader` keeps `loader.asm` and `loader.prg` of an earlier run. |
35
- | `--entry '$080d'` | An entry point for Ghidra. Use it again for more entry points. The entry of the program, the routines and the code regions in the knowledge are entry points too. |
33
+ | `--entry '$080d'` | An address where code starts. Use it again for more entry points. The entry of the program, the routines and the code regions in the knowledge are entry points too. |
36
34
  | `--analyzer-names` | Name an address that has no symbol and no platform name with its analyzer name, for example `FUN_17e2`. The order is heuristic, Ghidra, then DXA. Without it, the source makes its own names, for example `l_17e2`. |
37
35
  | `--space drive8` | Generate the source of drive code or a cartridge bank from the knowledge of that space. The coverage, `--loader` and the platform names are only for `c64`. |
38
36
  | `--loader` | Also write `loader.asm` and `loader.prg`. This needs a capture in the knowledge, with its entry and its entry state. |
39
37
  | `--max-listed 20` | List at most this number of items in each list. The default is 50. The counts are always in the result. |
40
38
 
41
- When the knowledge has coverage, code that no run executed gets the line `; not executed` with its range. `notExecuted` lists it. The executed code is also a seed for Ghidra. Thus the source has the code after a JSR to a routine that Ghidra thinks does not return.
39
+ When the knowledge has coverage, code that no run executed gets the line `; not executed` with its range. `notExecuted` lists it. The executed code is always instructions in the source.
42
40
 
43
41
  ### Calling the script
44
42
 
@@ -83,7 +81,7 @@ When the knowledge has coverage, code that no run executed gets the line `; not
83
81
  - A label or a constant gets the name of the address in the knowledge. Without a knowledge name, it gets the platform name of the c64-memory-map skill, for example `EXTCOL` or `CHROUT`. A platform name wins over a name from an analyzer (`dxa`, `ghidra` or `heuristic`), for example `EXTCOL` over `ld020`. A `user` or `llm` name wins over a platform name. An address in the program without a name gets `l_xxxx`.
84
82
  - The source uses the names of a ROM only when the program uses that ROM. When the knowledge has coverage, a ROM is in use when a run executed code of it. A read of ROM bytes as data does not count. Without coverage, `$01` of the entry state tells which ROMs are in. When the program uses neither ROM, the zero page and pages 2 and 3 get no system names. `romNamesLeftOut` gives the ROMs that the source did not name, and the evidence. An operand expression or a macro use with such a name gets that reason.
85
83
  - `sta $d011 ; $d011: yScroll 3, rows 25, displayEnabled` is a store of an immediate to a register that the c64-memory-map skill decodes. The side comment gives the decoded value. A side comment in the knowledge replaces it.
86
- - Code regions, and the instructions that Ghidra decodes outside of data regions, become instructions.
84
+ - Code regions, and the decoded instructions outside of data regions, become instructions.
87
85
  - Data regions become data by their type: `!byte`, `!word`, `!pet`, `!scr`, `!fill`, tables of labels, and sprite bytes in binary.
88
86
  - `lda+2 $0012` is an absolute operand below $0100. `+1` is a zero-page operand with a label.
89
87
  - `sta NMINV+1` is an address inside a platform entry of more than one byte, for example the high byte of a vector.
@@ -92,7 +90,7 @@ When the knowledge has coverage, code that no run executed gets the line `; not
92
90
  - `lda #<irq_handler` and `lda bar_colours-1,x` are operand expressions of the knowledge. The script writes each name of an expression with the name of its address in the source. An operand expression in a non-immediate mode that starts with a bracket gets `0+` before it, because ACME reads `(...)` as indirect.
93
91
  - `; = <irq_handler` at the end of an instruction with a number: the source cannot use this operand expression. `operandsAsNumbers` gives the reason.
94
92
  - `!byte` with an instruction as its comment: ACME writes this instruction with a different opcode. The bytes keep the source identical.
95
- - `not decoded` marks bytes in a code region that Ghidra did not decode.
93
+ - `not decoded` marks bytes in a code region that the script did not decode.
96
94
  - `; not executed $xxxx-$yyyy` starts code that no run of the coverage executed. The range is the same as in `not_executed.json`.
97
95
  - `+inc16 ptr` is a use of a macro of the knowledge. `macros.asm` holds the macros. `main.asm` and `loader.asm` include it. The comments inside a use go to its side comment.
98
96
  - `!zone patch_PROTECTION_100e` starts a patch of the knowledge. The condition is the state that the program does not have. It is `!if TRAINER` when the base release has the switch off. It is `!if PROTECTION = 0` when the base release has it on. The block has the code of the patch and NOP to the end of the range. `else` has the original code. The labels inside the range come before the zone as `name = * + n`. Thus all builds have them.
@@ -136,21 +134,21 @@ The copy table, the copier and the jump to the entry use labels, not numbers. `l
136
134
 
137
135
  The flags go through the free stack byte below the stack pointer (`stackByte`). The loader changes this byte. The loader does not set the SID, the time of day of the CIAs, the CIA interrupt flags or the interrupt registers of the VIC-II. `loader.limits` names each CIA value that the loader cannot set as it was at the entry. A program that reads the SID voice 3 for random numbers can still differ in a scenario. A raster sync does not change a timer or the SID. Then observe after the program sets up its own random numbers. To sync the original and the rebuild in a test, see the sync rules of the c64-testing skill.
138
136
 
139
- The script simulates the copies first. Then it runs `loader.prg` in the emulator to its jump to the entry. It compares the memory, $00/$01, the registers, the screen registers of the VIC-II, the VIC bank and the raster line with the entry state there. It also compares the CIA timers, latches and interrupt masks. `loader.verified: true` tells that all of them are equal. An interrupt can run right at the entry, as in the original program.
137
+ The script runs `loader.prg` to its jump to the entry. It compares the memory, $00/$01, the registers, the screen registers of the VIC-II, the VIC bank and the raster line with the entry state there. It also compares the CIA timers, latches and interrupt masks. `loader.verified: true` tells that all of them are equal. An interrupt can run right at the entry, as in the original program.
140
138
 
141
139
  The entry state is the state of the base release. Thus the script builds and checks `loader.prg` with the switch values of the base release. For a loader of the default build, build `loader.asm` with the c64-assembler skill and no option.
142
140
 
143
141
  ### The packed loader
144
142
 
145
- A loader file that loads into $d000 or higher writes the I/O area. When the image is too large for one loader file, `loader.asm` has the packed form. The packed form needs Exomizer. It has these differences:
143
+ A loader file that loads into $d000 or higher writes the I/O area. When the image is too large for one loader file, `loader.asm` has the packed form. It has these differences:
146
144
 
147
145
  - `loader.asm` holds only the copier and the bytes below $0400: pages $0002-$03ff of the entry state and the parts of segments there. The copier is in one free range, at `loader.copier`. The bytes below $0400 go into free ranges. When one range is too small, they go into more ranges, and each piece is a copy. Between these ranges, `loader.asm` holds the bytes of the image. The segments at $0400 and higher are not in `loader.asm`.
148
- - The script packs the build of `main.asm` from $0400 and the build of `loader.asm` into `loader.prg` with Exomizer. Where the two builds overlap, the bytes of `loader.asm` are in `loader.prg`.
146
+ - The script packs the build of `main.asm` from $0400 and the build of `loader.asm` into `loader.prg`. Where the two builds overlap, the bytes of `loader.asm` are in `loader.prg`.
149
147
  - `10 SYS` starts the unpacker. The unpacker writes all bytes, also at $d000-$dfff. Then it jumps to the copier with all RAM visible ($01 = $34).
150
148
  - The unpacker uses the zero page and $0334-$03ff. Thus the copier writes pages $0002-$03ff after the unpack. Then it does steps 4 to 6.
151
149
  - The jump to the entry uses the address of the entry, not its label. The build of `loader.asm` does not include `main.asm`.
152
150
 
153
- The script checks the unpack in the emulator of Exomizer. All bytes of the two builds must be correct, and the unpacker must jump to the copier. Then the script runs `loader.prg` in the emulator, as for the plain loader. `loader.packed` gives `packedBytes` and `unpackedBytes`.
151
+ The script checks the unpack. All bytes of the two builds must be correct, and the unpacker must jump to the copier. Then the script checks `loader.prg` as for the plain loader. `loader.packed` gives `packedBytes` and `unpackedBytes`.
154
152
 
155
153
  To make the packed loader for other switch values, do these steps:
156
154
 
@@ -186,7 +184,7 @@ The script does these steps. It writes nothing until all the checks pass.
186
184
  - `change`: its default.
187
185
  3. It builds the program with these values. This build can change bytes only in the patches.
188
186
  4. It finds the free ranges. Each free range gets the bytes $00 and the label `free_xxxx`. No address moves.
189
- 5. It makes the source of the new program. ACME must assemble the source to the new program byte by byte. For a capture with an entry state, the script also makes `loader.asm` and simulates its copies. It does not run the loader in the emulator.
187
+ 5. It makes the source of the new program. The source must assemble to the new program byte by byte. For a capture with an entry state, the script also makes `loader.asm` and checks its copies. It does not run the loader.
190
188
  6. It writes the new project and the zip file.
191
189
 
192
190
  ### The free ranges
@@ -260,13 +258,13 @@ Do not store:
260
258
  - `removed`: the files of an earlier run that the script removed from `--out` and did not write again.
261
259
  - `instructions`, `dataBytes` and `undecodedBytes`.
262
260
  - `labels`: `named` labels from the knowledge and `generated` labels `l_xxxx`.
263
- - `entriesInData`: each `--entry` in a data region of the knowledge, with the `region` and its `origin`. Ghidra does not decode an entry in a data region.
261
+ - `entriesInData`: each `--entry` in a data region of the knowledge, with the `region` and its `origin`. The script does not decode an entry in a data region.
264
262
  - `asBytes`: the instructions that the source has as bytes.
265
263
  - `operandExpressions`: the count of instructions that the source has with an operand expression.
266
- - `operandsAsNumbers`: the operand expressions that the source has as a number with a side comment, each with its `address`, `expression` and `reason`. An expression becomes a number when no instruction with an operand value is at the address, or when a name has no address. An expression that ACME refuses or does not assemble to the program also becomes a number. Then the script assembles the source again, at most six times.
264
+ - `operandsAsNumbers`: the operand expressions that the source has as a number with a side comment, each with its `address`, `expression` and `reason`. An expression becomes a number when no instruction with an operand value is at the address, or when a name has no address. An expression that does not assemble to the program also becomes a number.
267
265
  - `unusedModules`: modules in the knowledge whose start is in no segment of the program. Often this tells that the program does not hold code that the knowledge describes.
268
266
  - `entryOutside`: the entry is in no segment of the program in the knowledge, with a `reason`. The capture does not hold the program.
269
- - `dataOnly`: the knowledge has no entry, no routine, no code region and no executed address in the space. Thus the source has only data, and Ghidra does not run. A table or a key page in a cartridge bank is an example.
267
+ - `dataOnly`: the knowledge has no entry, no routine, no code region and no executed address in the space. Thus the source has only data. A table or a key page in a cartridge bank is an example.
270
268
  - `notExecuted`: when the knowledge has coverage, the count of instructions that no run executed, the count of their ranges, and the first ranges. `rest` names the file `not_executed.json` in `--out` when the list is not complete. This file has all of the ranges. Each range has its source `file` and the `routine` before it. `files` counts the ranges in each file.
271
269
  - `macroUses`: the count of macro uses that the source has.
272
270
  - `macrosAsInstructions`: the macro uses that the source has as instructions, each with its `start`, `end`, `macro` and `reason`.
@@ -277,7 +275,7 @@ Do not store:
277
275
  - `releases`: the build of each release. Each item has `label`, `base`, `file`, the `define` and the `result`. `identical` tells that the build gives the bytes of the file. `different` gives the segments that differ. `layout differs` tells that the release has other segments than the program: patches cannot move code, so this result does not fail the run. `file changed` tells that the file is not the file that the knowledge recorded. `does not assemble` gives the diagnostics of ACME.
278
276
  - `loader`: the program, the copies in their order, the copier page, `stackByte`, `verified` and `differences`. A packed loader also has `packed` with `packedBytes` and `unpackedBytes`. `limits` lists the CIA values that the loader cannot set. An entry state from an old capture has no CIA values. Then `limits` tells you to capture the program again. When the script cannot make the loader, `loader` has `verified: false` and a `reason`. The loader includes the source. Thus a source that does not assemble to the program also stops the loader.
279
277
 
280
- `result` is `PASS` when the source is identical and the emulator check of the loader passes. `result` is `FAIL` for a failed check and for an entry in no segment. These also give `FAIL`:
278
+ `result` is `PASS` when the source is identical and the check of the loader passes. `result` is `FAIL` for a failed check and for an entry in no segment. These also give `FAIL`:
281
279
 
282
280
  - a patch that the source does not have
283
281
  - a switch or a default build that does not fit
@@ -302,14 +300,14 @@ Do not store:
302
300
  - `dataOnly`: this is not a failure. If the space has code, give `--entry` or classify the code with the c64-knowledge skill. Then generate again.
303
301
  - `entriesInData`: an analyzer region of data hides the code at the entry. If the entry is code, record a code region at the entry with the c64-knowledge skill, for example `classify '$0500-$05ff' code`. A region of the user or the LLM replaces the analyzer region. Then generate again.
304
302
  - `loader.verified: false` with a `reason`: the script did not make the loader. The script still writes and checks the source. When no copy order or no free pages exist, or the loader needs too many copies, the reason gives the ranges. Capture the program again with fewer segments, or write the loader by hand.
305
- - `loader.verified: false` with a `reason` about the packed form: the image is too large for one loader file. If the reason tells that Exomizer is not installed, stop the task. Give the message to the user. If the free ranges are too small for the copier and the bytes below $0400, the reason gives the largest free ranges. Write the loader by hand. If the unpack check of Exomizer fails, give the reason to the user.
303
+ - `loader.verified: false` with a `reason` about the packed form: the image is too large for one loader file. If the reason tells that a tool is missing, stop the task. Give the message to the user. If the free ranges are too small for the copier and the bytes below $0400, the reason gives the largest free ranges. Write the loader by hand. If the unpack check fails, give the reason to the user.
306
304
  - `loader.verified: false` with `differences`: the loader ran, and `differences` gives the bytes and registers that are not equal.
307
305
  - `loader.verified: false` with `stop`: the loader did not get to its copier or to its jump. `stop` gives the address where it stopped and `port`, the value of $01. `history` gives the last 16 instructions. `cause` gives the first byte of the copier that is not equal to its byte in the loader file. For a packed loader, `cause` gives the first byte of the copier that the unpack did not write. If the copier ran, `cause` can also give the first byte that a copy did not write correctly.
308
306
  - `export` with `stage: "original"`: the source of the knowledge does not pass. Run `generate`, and correct the knowledge until `generate` gives PASS.
309
307
  - `export` with `stage: "switches"`: the build with the export values changes bytes outside the patches, or a patch does not fit. Read `build`. Correct the patches.
310
308
  - `export` refuses two switches that change one range: the export puts both alternatives in. Give all but one of them the kind `change` and the default of the base release with `switch` of the c64-knowledge skill.
311
309
  - `export` refuses `--drop`: read the message. It names the code that stays and goes to the range or reads it, or the code or region that the range cuts.
312
- - `installation-incomplete`, or `machine-unavailable` with a message that the host runtime does not run: stop the task. Give the message to the user and wait for the user. The message gives the remedy. Do not make a replacement for the tool or the host runtime, for example your own disassembler or emulator script.
310
+ - `installation-incomplete` or `machine-unavailable`: stop the task. Give the message to the user and wait for the user. Do not install, start or change a tool yourself. Do not make a replacement for the tool, for example your own disassembler or emulator script.
313
311
 
314
312
  ## Handoffs
315
313
 
@@ -16,9 +16,9 @@ Find the static structure of a C64 program. Record the structure in the project
16
16
  - Entry points: addresses where code starts, for example the SYS address from the c64-basic skill. Routine symbols in the knowledge are entry points too. Ghidra needs at least one. DXA finds the SYS of a BASIC start by itself.
17
17
  - Optional: routines to decompile (Ghidra), or a file for the listing (DXA).
18
18
 
19
- ## Tools / execution path
19
+ ## Tools
20
20
 
21
- The script reads the program, the coverage and the current knowledge, and runs DXA or Ghidra on this machine. The host runtime is not necessary. The script records the result in the project knowledge, `.c64-re-tools/knowledge/`.
21
+ The script reads the program, the coverage and the current knowledge. It records the result in the project knowledge, `.c64-re-tools/knowledge/`.
22
22
 
23
23
  ```
24
24
  node <skill>/scripts/static-analysis.ts analyze --analyzer dxa --out-listing .c64-re-tools/local/game.lst
@@ -138,8 +138,8 @@ The exit status is 0, also with conflicts.
138
138
  - `invalid-input` with a message about an entry point: no entry point is inside the program for Ghidra. Give one with `--entry`.
139
139
  - `stale-revision`: the knowledge changed during the analysis. The script recorded nothing. Run the analysis again.
140
140
  - `operation-failed` with a message about an incomplete result or listing: the analyzer did not give a complete result. The script recorded nothing. Tell the user.
141
- - `installation-incomplete`, or `machine-unavailable` with a message that the host runtime does not run: stop the task. Give the message to the user and wait for the user. The message gives the remedy. Do not make a replacement for the tool or the host runtime, for example your own disk parser, disassembler or emulator script.
142
- - `notDecompiled`: Ghidra did not decompile these routines. Each entry has the reason. If the reason says that the decompiler did not start, tell the user the remedy in the reason. On macOS, Ghidra has no native decompiler until the user builds it: `./gradlew buildNatives` in the `support/gradle` directory of Ghidra.
141
+ - `installation-incomplete` or `machine-unavailable`: stop the task. Give the message to the user and wait for the user. Do not install, start or change a tool yourself. Do not make a replacement for the tool, for example your own disk parser, disassembler or emulator script.
142
+ - `notDecompiled`: Ghidra did not decompile these routines. Each entry has the reason. If the reason says that the decompiler did not start, tell the user the remedy in the reason.
143
143
 
144
144
  ## Handoffs
145
145
 
@@ -17,9 +17,9 @@ A PASS proves only the behavior that the scenario does and observes. It does not
17
17
  - The symbols of each side. For the original, the project knowledge. For the rebuild, the JSON output of the c64-assembler skill in a file.
18
18
  - A scenario file: the steps, the checkpoints and the observations. See [references/scenario-format.md](references/scenario-format.md).
19
19
 
20
- ## Tools / execution path
20
+ ## Tools
21
21
 
22
- The script starts one emulator through the host runtime. It runs the scenario on the original and then on the rebuild. Before each side, it does a hard reset of the emulator. The CPU then stops at the reset vector.
22
+ The script runs the scenario on the original and then on the rebuild. Before each side, it does a hard reset. The CPU then stops at the reset vector.
23
23
 
24
24
  ```
25
25
  node <skill>/scripts/testing.ts test tests/moves-left.json --out .c64-re-tools/local/results/moves-left
@@ -30,7 +30,7 @@ node <skill>/scripts/testing.ts checklist tests/moves-left.json --item 'FIRE sta
30
30
 
31
31
  `testing.ts checklist` gives a Markdown checklist for a human tester in `text`.
32
32
 
33
- Before the emulator starts, `testing.ts test` examines each file that the scenario names: the program and the symbols of each side, and each snapshot file. A missing file gives `not-found`. A program must be a PRG. The script refuses a disk, tape or cartridge image.
33
+ Before the test starts, `testing.ts test` examines each file that the scenario names: the program and the symbols of each side, and each snapshot file. A missing file gives `not-found`. A program must be a PRG. The script refuses a disk, tape or cartridge image.
34
34
 
35
35
  ### Runs
36
36
 
@@ -53,7 +53,7 @@ The run file gives where to start (a program, or a snapshot file), the steps, an
53
53
  | `{ "observe": "all3", "memory": "all" }` | Write all 64 KiB of RAM to `all3.bin`, also the RAM under the ROMs and the I/O area. |
54
54
  | `{ "expect": "title", "memory": [{ "address": "$0400", "text": "HELLO" }], "registers": { "a": 0 } }` | Compare memory and registers with the expected values. `data` gives hex bytes, `text` gives screen codes. `mask` compares only some bits. A value that is not equal does not stop the run. |
55
55
 
56
- Each step that writes a file must have its own file name. The script refuses a run where two steps write the same file, for example `{ "coverage": "x" }` and `{ "observe": "x", "memory": "all" }`, which both write `x.bin`. The script also examines the start program and each snapshot file before the emulator starts.
56
+ Each step that writes a file must have its own file name. The script refuses a run where two steps write the same file, for example `{ "coverage": "x" }` and `{ "observe": "x", "memory": "all" }`, which both write `x.bin`. The script also examines the start program and each snapshot file before the run starts.
57
57
 
58
58
  A memory item can have `"view": "ram"`. Then it reads the RAM under the ROMs and the I/O area, for example code at `$e000` under the KERNAL. The default view `cpu` reads as the CPU sees memory. An item larger than 4096 bytes goes into its own `.bin` file, and `results.json` gives the file name.
59
59
 
@@ -63,7 +63,7 @@ See [references/scenario-format.md](references/scenario-format.md), section Runs
63
63
 
64
64
  A recording keeps a session of the original program, for example a play through some rooms of a game. A replay gives the same input to a rebuild and compares the game state. Make the recordings early, before you change the program. A recording needs no names. Its coverage also helps the static analysis.
65
65
 
66
- `testing.ts record` and `testing.ts replay` run the replay core `c64run` on this machine, not the emulator of the host runtime. The replay core has no disk drive. The program must be a PRG file.
66
+ The emulator tools cannot examine the C64 of a recording or a replay. That C64 has no disk drive. The program must be a PRG file.
67
67
 
68
68
  Ask the user to play first. Tell the user which parts of the program the recordings must have, for example each room, a fight and a lost life. Make a scripted recording only for a part that the sessions of the user do not have, or when the user cannot play.
69
69
 
@@ -72,7 +72,7 @@ node <skill>/scripts/testing.ts record tests/record/start.json --out tests/recor
72
72
  ```
73
73
 
74
74
  - With `--play`, a person plays the program after the steps of the record file. The steps can start the program, for example a key for an intro.
75
- - The script writes the address of a page to stderr. Give the address to the user. In a dev container, the port of the page (default 6465) must be forwarded.
75
+ - The script writes the address of a page to stderr. Give the address to the user.
76
76
  - The page shows the screen after the steps. The C64 is frozen until the user presses Enter or clicks Start. Tell the user to read the screen first.
77
77
  - Give `--joystick` the port that the program reads: port 2 is `$DC00`, and port 1 is `$DC01`. Find the port in the code or in the knowledge. If you do not know the port, use 2. Tell the user that F9 changes the port.
78
78
  - The page has the full C64 keyboard and the joystick. F10 changes the arrow keys and space between the joystick and the C64 keys. A gamepad is always the joystick. See the key maps in [references/recording-format.md](references/recording-format.md).
@@ -98,7 +98,7 @@ A checkpoint is one entry of a routine. Use a routine that the program executes
98
98
 
99
99
  The input is the reads of the joystick ports and the keyboard matrix. It is also the reads of the four SID registers that a program can read: the paddles, the noise of voice 3 and its envelope. It is also the reads of `$DE00`-`$DFFF`, where a C64 without a cartridge gives the last byte on the bus. On a replay, the n-th read of each instruction gets the value of the n-th read in the recording. Thus a rebuild with different timing gets the same input and the same SID random numbers. A `press`, `joystick` or `frames` step is input. A `type`, `write`, `registers` or `runUntil` step is not input. The replay does that step again at the same read of the program.
100
100
 
101
- A replay is deterministic. The replay core has no random source and no clock: the same recording gives the same session, to the cycle. Sometimes the recording has no value for a read of an input. Then the read gets a fixed value: `$FF` for the joystick, keyboard and paddle registers, `$00` for the others. `idleReads` in the result counts these reads on the rebuild. On the original, such a read makes the result INCONCLUSIVE.
101
+ A replay is deterministic. A replay has no random source and no clock: the same recording gives the same session, to the cycle. Sometimes the recording has no value for a read of an input. Then the read gets a fixed value: `$FF` for the joystick, keyboard and paddle registers, `$00` for the others. `idleReads` in the result counts these reads on the rebuild. On the original, such a read makes the result INCONCLUSIVE.
102
102
 
103
103
  Control each source of random numbers:
104
104
 
@@ -119,7 +119,7 @@ node <skill>/scripts/testing.ts diff .c64-re-tools/local/runs/rooms/results.json
119
119
 
120
120
  `testing.ts diff` tells what changed between two states of one kind. Use it in place of your own compare script.
121
121
 
122
- - Two snapshot files: the script restores each one in its own emulator. It gives the changed ranges of the RAM and of the colour RAM, and the changed VIC-II, CIA, SID and CPU registers.
122
+ - Two snapshot files: the changed ranges of the RAM and of the colour RAM, and the changed VIC-II, CIA, SID and CPU registers.
123
123
  - Two memory files of a run: the changed ranges. For a file of less than 64 KiB, `--address` gives the address of its first byte.
124
124
  - Two observations of runs, also of one run: the changed memory items and registers. `compared` gives the count of items that both observations have. With `compared: 0`, `reason` tells what each observation has. Then the diff compared nothing, and the observations are not equal.
125
125
 
@@ -127,7 +127,7 @@ For two snapshot files, `$00` and `$01` are the CPU port of the snapshot: the di
127
127
 
128
128
  `registers` gives each changed register and chip value. `cpu.pc` is a `$` address. Each CPU flag is `cpu.flags.<flag>`, for example `cpu.flags.c`, with `true` or `false`.
129
129
 
130
- The script refuses a snapshot that does not restore in its emulator. An example is a PAL snapshot with `--ntsc`. Give `--ntsc` only for snapshots of an NTSC machine.
130
+ The script refuses a snapshot that does not restore. An example is a PAL snapshot with `--ntsc`. Give `--ntsc` only for snapshots of an NTSC machine.
131
131
 
132
132
  `--gap N` joins ranges across N equal bytes. `--out` writes all ranges and all changed registers to a project file. The file uses the names of the result.
133
133
 
@@ -197,19 +197,19 @@ PASS, FAIL or INCONCLUSIVE, the checkpoints and the smallest differences that ex
197
197
  - `not-found` before the run: a file of the scenario or the run file is missing, for example the rebuild program. Build the rebuild, or change the path.
198
198
  - INCONCLUSIVE, "did not reach the checkpoint": one side did not reach the checkpoint in the frame limit. Find the reason with the emulator skill. Do not report a FAIL.
199
199
  - INCONCLUSIVE, "has no symbol": one side has no symbol with that name. Add the name to the knowledge or to the rebuild source.
200
- - INCONCLUSIVE, "no emulator" or "could not run": the host runtime or the emulator failed. Tell the user the message.
201
- - `installation-incomplete`, or `machine-unavailable` with a message that the host runtime does not run: stop the task. Give the message to the user and wait for the user. The message gives the remedy. Do not make a replacement for the tool or the host runtime, for example your own disk parser, disassembler or emulator script.
200
+ - INCONCLUSIVE, "no emulator" or "could not run": the emulator failed. Tell the user the message.
201
+ - `installation-incomplete` or `machine-unavailable`: stop the task. Give the message to the user and wait for the user. Do not install, start or change a tool yourself. Do not make a replacement for the tool, for example your own disk parser, disassembler or emulator script.
202
202
  - A FAIL with only a `screen` difference: add `vicii` or `sprites` to the observation to find which chip state is different.
203
203
  - A program that uses random numbers: set the random seed with a `write` step on both sides. If that is not possible, observe only values that do not depend on the random numbers.
204
204
  - The two sides start differently, for example the original after a cracked intro. Give the steps that only one side needs a `side`. Then make the memory the same with a `normalize` step. It writes the entry state of the capture in the knowledge.
205
205
  - Frame counts drift by one frame between the sides: the sides got to the same address at different raster positions. Do not sync on an IRQ handler. Sync on a value that the IRQ changes, with a `runUntil` `memory` target. Or sync on an `address` target with a `raster` condition.
206
- - INCONCLUSIVE, "does not reproduce": the original does not end the session with the recorded state. Record the session again with this `c64run`.
206
+ - INCONCLUSIVE, "does not reproduce": the original does not end the session with the recorded state. Record the session again.
207
207
  - INCONCLUSIVE, "never came to the checkpoint": the original did not execute the checkpoint routine in the session. Give another routine.
208
208
  - INCONCLUSIVE, "is not the program of the recording": the program file changed after the recording. Record the session again.
209
209
  - A record result FAIL with `recorded` false: `reason` names the step that did not complete. Examples are a `runUntil` that did not reach its target, and a `type` step with too many keys. Change the step.
210
210
  - A record result with `executed` 0: the program never read its input from RAM, so the coverage map is empty. The recording can still replay.
211
211
  - A FAIL from a replay: compare the two RAM files of `--out` with `testing.ts diff`. Then examine the first different state item with the emulator skill.
212
- - A program that loads more files from a disk: the replay core has no disk drive. Use a test scenario in the emulator.
212
+ - A program that loads more files from a disk: a recording has no disk drive. Use a test scenario in the emulator.
213
213
  - A byte that cannot be the same on both sides, for example a read-only collision register: use `exclude` with the reason. Do not use `exclude` to hide a real difference.
214
214
 
215
215
  Do not add a mask or a tolerance only to make a test pass. A tolerance must have a reason in the behavior of the program.
@@ -101,7 +101,7 @@ The page sends input only between Start and End. The input of the page goes into
101
101
 
102
102
  A site is the address of the instruction that reads. The values are hex. `<from>` and `<count>` are decimal.
103
103
 
104
- `testing.ts replay` checks `recording.json` before the replay core starts. A recording of version 2.0 can have events or a comparison in the old form, for example `"at"` in place of `"address"`. The script refuses it with `invalid-input`. The message names the event, the old field and the form to write. Record the session again.
104
+ `testing.ts replay` checks `recording.json` before the replay starts. A recording of version 2.0 can have events or a comparison in the old form, for example `"at"` in place of `"address"`. The script refuses it with `invalid-input`. The message names the event, the old field and the form to write. Record the session again.
105
105
 
106
106
  ## Replay
107
107
 
@@ -156,11 +156,11 @@ Example: visit two rooms from the same start.
156
156
 
157
157
  ## Checks
158
158
 
159
- The script checks the scenario before it starts the emulator. A step with an unknown key or a wrong value stops the script with `invalid-input`. The message names the step.
159
+ The script checks the scenario before it does a step. A step with an unknown key or a wrong value stops the script with `invalid-input`. The message names the step.
160
160
 
161
- The script also examines each file before it starts the emulator: the program and the symbols of each side, and each snapshot file. A missing file stops the script with `not-found`. A program that is not a PRG, for example a disk image, stops the script with `invalid-input`. A snapshot file that does not start with the signature of a VICE snapshot file also stops the script with `invalid-input`. The message names the step and the file.
161
+ The script also examines each file before it does a step: the program and the symbols of each side, and each snapshot file. A missing file stops the script with `not-found`. A program that is not a PRG, for example a disk image, stops the script with `invalid-input`. A snapshot file that does not start with the signature of a VICE snapshot file also stops the script with `invalid-input`. The message names the step and the file.
162
162
 
163
- A run also examines each name of its steps before it starts the emulator. An unknown name stops the run with `invalid-input`, and the message names the step. In a scenario, a side that does not have a name gives INCONCLUSIVE, and `reason` names the step.
163
+ A run also examines each name of its steps before it does a step. An unknown name stops the run with `invalid-input`, and the message names the step. In a scenario, a side that does not have a name gives INCONCLUSIVE, and `reason` names the step.
164
164
 
165
165
  A step in the form of version 2.0 stops the script with `invalid-input`. The message names the old field and gives the step to write. For example, the script refuses `{ "runUntil": { "at": "main_loop" }, "timeoutFrames": 300 }` and gives `{"runUntil": {"target": {"kind": "address", "address": "main_loop"}, "timeoutFrames": 300}}`. A memory item with `at` gets the same refusal: write `address`.
166
166
 
@@ -16,7 +16,7 @@ This skill does not change project knowledge.
16
16
  - The program: a PRG file, relative to the project folder. `inspect`, `trace`, `stages` and `capture` refuse a disk, tape or cartridge image. For such an image, use `loads`, or get the PRG with `disk.ts read` of the c64-disk skill.
17
17
  - For a capture: the address where the unpacked program starts, and the directory for the result.
18
18
 
19
- ## Tools / execution path
19
+ ## Tools
20
20
 
21
21
  ```
22
22
  node <skill>/scripts/unpacker.ts inspect original/game.prg
@@ -26,7 +26,7 @@ node <skill>/scripts/unpacker.ts capture original/game.prg --until '$c000' --out
26
26
  node <skill>/scripts/unpacker.ts loads original/game.d64 --steps .c64-re-tools/local/parts.json --out .c64-re-tools/local/parts --drive
27
27
  ```
28
28
 
29
- `inspect` examines the file locally. `trace`, `stages`, `capture` and `loads` start their own emulator through the host runtime and start the program. `trace` runs the program and finds the memory that the program wrote and then executed. `stages` runs the program and finds each stage: a decruncher, an intro, a copier, and then the program. For each stage it gives the entry, the frames, the written memory (`wrote`) and the entry of the next stage (`next`). `wrote` lists each block that the stage wrote, also a small block. `capture` stops the program when the CPU gets to the `--until` address. In `stages` and `capture`, a `frames` step and a `runUntil` step to an address without a condition count as run time. `stages` refuses a different `runUntil` step.
29
+ `inspect` examines the file and does not run the program. `trace`, `stages`, `capture` and `loads` run the program. `trace` runs the program and finds the memory that the program wrote and then executed. `stages` runs the program and finds each stage: a decruncher, an intro, a copier, and then the program. For each stage it gives the entry, the frames, the written memory (`wrote`) and the entry of the next stage (`next`). `wrote` lists each block that the stage wrote, also a small block. `capture` stops the program when the CPU gets to the `--until` address. In `stages` and `capture`, a `frames` step and a `runUntil` step to an address without a condition count as run time. `stages` refuses a different `runUntil` step.
30
30
 
31
31
  | Option | Meaning |
32
32
  |---|---|
@@ -43,9 +43,9 @@ node <skill>/scripts/unpacker.ts loads original/game.d64 --steps .c64-re-tools/l
43
43
  | `--min-block 64` | `loads` only: the smallest block of changed memory that becomes a segment (default 64). The result counts smaller changes as `smallChanges`. |
44
44
  | `--min-stage 64` | `stages` and `capture`: the smallest block of written memory that starts a new stage when the CPU executes it (default 64). It does not change `wrote` or the segments. |
45
45
 
46
- The capture reads RAM, also the RAM under the ROMs and the I/O area. A segment can be in the RAM under the I/O area at `$d000`-`$dfff`. VICE shows each write there as an I/O write. Thus the script compares that RAM at the end of each stage or capture. The script refuses an option that the command does not use. It refuses a wrong `--range` or `--exclude` before the emulator starts.
46
+ The capture reads RAM, also the RAM under the ROMs and the I/O area. A segment can be in the RAM under the I/O area at `$d000`-`$dfff`. The script refuses an option that the command does not use. It refuses a wrong `--range` or `--exclude` before the program runs.
47
47
 
48
- A steps file is a JSON list of steps. Each step has the input of the MCP tool of the same action. An address in a step can be a name. The script refuses an unknown name before the emulator starts. The message gives the file and the step. For example, wait 50 frames and type a space:
48
+ A steps file is a JSON list of steps. Each step has the input of the MCP tool of the same action. An address in a step can be a name. The script refuses an unknown name before the program runs. The message gives the file and the step. For example, wait 50 frames and type a space:
49
49
 
50
50
  ```json
51
51
  [{ "frames": 50 }, { "type": { "mode": "text", "text": " " } }]
@@ -120,7 +120,7 @@ The scripts refuse a step in the form of version 2.0, for example `{ "runUntil":
120
120
 
121
121
  ## Multi-load programs
122
122
 
123
- A multi-load program loads more parts from the disk while it runs, for example one part for each level. Use `loads` to capture each part. The program can be a PRG, or a disk, tape or cartridge image that VICE starts. `loads` starts a PRG with RUN. Thus the PRG must have a BASIC start line. For a PRG without a BASIC start line, use `capture` with `--entry`.
123
+ A multi-load program loads more parts from the disk while it runs, for example one part for each level. Use `loads` to capture each part. The program can be a PRG, or a disk, tape or cartridge image. `loads` starts a PRG with RUN. Thus the PRG must have a BASIC start line. For a PRG without a BASIC start line, use `capture` with `--entry`.
124
124
 
125
125
  1. Write a steps file. Put a `capture` step after each point where a part is in memory, for example:
126
126
 
@@ -139,7 +139,7 @@ A multi-load program loads more parts from the disk while it runs, for example o
139
139
  4. Put the part that you work on into the knowledge with `image <out>/<name>/image.json` of the c64-knowledge skill.
140
140
  5. With `--drive`, `drive8.prg` is the drive RAM at `$0000`-`$07ff`. Put it into the knowledge with `image <out>/<name>/drive8.prg --space drive8`. Then analyze it with c64-static-analysis and `--space drive8`.
141
141
 
142
- VICE records no memory access map for the drive CPU. Thus no tool gives coverage of drive code.
142
+ No tool gives coverage of drive code.
143
143
 
144
144
  ## Knowledge
145
145
 
@@ -160,16 +160,16 @@ For `loads`: `captures`, with the name, the PC, the segments, `differsFromReset`
160
160
 
161
161
  ## Failure and conflicts
162
162
 
163
- - `traced: false` or `followed: false`: the emulator did not load the program into memory in the time limit. The reason gives the load address. Make sure that the file is a PRG that the C64 can load.
164
- - `traced: false` or `followed: false` with `stopReason`: the CPU stopped before the frames ran, for example at a JAM instruction. `pc` gives the address. Make sure that `--entry` is the start of the code that the file holds at that time, and that the steps are correct.
163
+ - `traced: false` or `followed: false`: the C64 did not load the program into memory in the time limit. The reason gives the load address. Make sure that the file is a PRG that the C64 can load.
164
+ - `traced: false` or `followed: false` with `stopReason`: the CPU stopped before the frames ran, for example at a JAM instruction. `pc` gives the address. Make sure that `--entry` is the start of the code that the file holds at that time, and that the steps have no error.
165
165
  - `captured: false`: the program did not get to the address in the time limit. The reason tells where it stopped. Find a better address with the emulator skill, or give more frames. If it stopped in a key wait, give `--steps` with a `type` step.
166
166
  - A step did not reach its target: the reason names the step. Change the step or give it more frames.
167
167
  - `loaded: false` with an empty `captures` and the reason `BASIC ran no program line`: the PRG has no BASIC start line. Use `capture` with `--entry`.
168
- - `loaded: false` and no capture has a segment: the program did not load a part, or it did not start. `keyWait: true` on a capture tells that the C64 waited for a key at the READY prompt or at an INPUT statement. For a tape image, read `emulatorFlaw`. A known VICE flaw can stop a tape load. Tell the user to install the latest VICE.
168
+ - `loaded: false` and no capture has a segment: the program did not load a part, or it did not start. `keyWait: true` on a capture tells that the C64 waited for a key at the READY prompt or at an INPUT statement. For a tape image, read `emulatorFlaw`. It names a known flaw of the emulator that can stop a tape load. Give it to the user.
169
169
  - Do not name a packer from weak evidence. The script never names one.
170
170
  - Some programs unpack in more than one stage. Run `stages` to find each stage. Capture at the entry of the last stage. Make sure that it is the application and not a second unpacker.
171
171
  - `not-found` or `invalid-input`: a path or an argument is wrong. Read the message.
172
- - `installation-incomplete`, or `machine-unavailable` with a message that the host runtime does not run: stop the task. Give the message to the user and wait for the user. The message gives the remedy. Do not make a replacement for the tool or the host runtime, for example your own disk parser, disassembler or emulator script.
172
+ - `installation-incomplete` or `machine-unavailable`: stop the task. Give the message to the user and wait for the user. Do not install, start or change a tool yourself. Do not make a replacement for the tool, for example your own disk parser, disassembler or emulator script.
173
173
 
174
174
  ## Handoffs
175
175
 
@@ -21,7 +21,7 @@ The MCP server knows the machine and the emulator. Its instructions, its tool de
21
21
 
22
22
  A tool takes addresses, not names. The server instructions give the address format. Get the address of a name with `knowledge.ts at <name>` of the c64-knowledge skill.
23
23
 
24
- ## Tools / execution path
24
+ ## Tools
25
25
 
26
26
  Use only the MCP tools. Each MCP session has its own machine. Nothing else can change that machine.
27
27
 
@@ -91,7 +91,7 @@ The emulator has no window. When the user must type, play or look at the machine
91
91
  3. Wait until the user tells you that they finished.
92
92
  4. Close the window with `c64_window` action `close`.
93
93
 
94
- The result field `notCarried` names the data that the move cleared.
94
+ The result field `notCarried` names the data that the open or the close cleared.
95
95
 
96
96
  ## Knowledge
97
97
 
@@ -120,7 +120,7 @@ If you cannot get the machine into the necessary state, say which state you coul
120
120
 
121
121
  An error is `{"error": {"code": "...", "message": "..."}}`. The message tells what is wrong and what to do. Obey the message. These rules also apply:
122
122
 
123
- - `installation-incomplete`, or `machine-unavailable` with a message that the host runtime does not run: stop the task. Give the message to the user and wait for the user. Do not make a replacement for the tool or the host runtime, for example your own disk parser, disassembler or emulator script. Do not try to repair the installation.
123
+ - `installation-incomplete` or `machine-unavailable`: stop the task. Give the message to the user and wait for the user. Do not install, start or change a tool yourself. Do not make a replacement for the tool, for example your own disk parser, disassembler or emulator script.
124
124
  - `machine-unavailable` with a message that names a pause or a dialog in the window: do not send more operations. Give the message to the user. When the user tells you that the emulator runs again, do the operation again.
125
125
  - `machine-unavailable` for a different cause: wait a few seconds. Then do the operation again one time. If you get the same error again, stop the task. Tell the user to restart the c64-re-tools MCP server, and wait for the user.
126
126
  - `machine-state-lost`: do not use results from before the error. Do what the message tells. Then read the machine state again.
@@ -177,6 +177,36 @@ export function tidyAfterUninstall(items: readonly InstallItem[], scope: Scope,
177
177
  }
178
178
  }
179
179
 
180
+ /**
181
+ * After an install or update: deletes the files of the items that the
182
+ * earlier install made and this one no longer has, for example a skill that
183
+ * a version renamed, then the directories that they leave empty. Only the
184
+ * harnesses that this install wrote count, and an MCP item never goes: its
185
+ * file holds other servers too. A file that this install also wrote stays.
186
+ * Returns the names of the removed items.
187
+ */
188
+ export function removeDroppedItems(before: readonly InstallItem[], scope: Scope, cwd = process.cwd()): string[] {
189
+ const root = scopeRoot(scope, cwd);
190
+ const absolute = (file: string) => (isAbsolute(file) ? file : resolve(root, file));
191
+ const after = installedItems(scope, undefined, cwd);
192
+ const key = (item: InstallItem) => `${item.harness}/${item.kind}/${item.name}`;
193
+ const kept = new Set(after.map(key));
194
+ const harnesses = new Set(after.map((item) => item.harness));
195
+ const keptFiles = new Set(after.flatMap((item) => item.files.map(absolute)));
196
+ const dropped = before.filter((item) => item.kind !== "mcp" && harnesses.has(item.harness) && !kept.has(key(item)));
197
+ const directories = new Set<string>();
198
+ for (const item of dropped) {
199
+ for (const file of item.files.map(absolute)) {
200
+ if (keptFiles.has(file) || !isWithin(root, file)) continue;
201
+ if (existsSync(file)) unlinkSync(file);
202
+ directories.add(dirname(file));
203
+ }
204
+ }
205
+ // Deepest first, so a parent is tried after its children.
206
+ for (const directory of [...directories].sort((a, b) => b.length - a.length)) removeEmptyDirectories(directory, root);
207
+ return [...new Set(dropped.map((item) => item.name))];
208
+ }
209
+
180
210
  const ANSI = new RegExp(String.fromCharCode(27) + "\\[[0-9;]*m", "g");
181
211
 
182
212
  /** AP SDK's report without its Windsurf MCP line and that line's detail, for when the CLI undid that item. */
package/src/cli/main.ts CHANGED
@@ -13,7 +13,7 @@ import { localToolStatus } from "../native/status.ts";
13
13
  import { isRefusal } from "../errors.ts";
14
14
  import { startTrace } from "../trace.ts";
15
15
  import { runApSdk } from "./ap-sdk.ts";
16
- import { installedItems, parseTargets, tidyAfterUninstall, undoWindsurfProjectMcp, windsurfBefore, withoutWindsurfMcp, type Scope } from "./cleanup.ts";
16
+ import { installedItems, parseTargets, removeDroppedItems, tidyAfterUninstall, type Scope, undoWindsurfProjectMcp, windsurfBefore, withoutWindsurfMcp } from "./cleanup.ts";
17
17
  import { hostStatusLines, installedLines, toolLines } from "./status.ts";
18
18
 
19
19
  const HELP = `c64-re-tools: Commodore 64 reverse engineering and development
@@ -86,11 +86,15 @@ async function main(argv: string[]): Promise<number> {
86
86
  case "install":
87
87
  case "update": {
88
88
  const before = windsurfBefore();
89
+ const earlier = installedItems(scope, targets);
89
90
  const { code, output } = await apSdk("install", flags);
90
91
  // A project install leaves the home directory as it was.
91
92
  const note = scope === "project" && (targets === undefined || targets.includes("windsurf")) ? undoWindsurfProjectMcp(before) : undefined;
92
93
  process.stdout.write(note === undefined ? output : withoutWindsurfMcp(output));
93
94
  if (note !== undefined) console.log(` ${note}\n`);
95
+ // A skill that this version renamed or dropped must not stay next to the new ones.
96
+ const removed = code === 0 ? removeDroppedItems(earlier, scope) : [];
97
+ if (removed.length > 0) console.log(` Removed, because this version no longer has them: ${removed.join(", ")}\n`);
94
98
  return code;
95
99
  }
96
100
  case "uninstall": {
@@ -53,7 +53,7 @@ export const c64Window = defineTool({
53
53
  name: "c64_window",
54
54
  title: "Emulator window",
55
55
  description:
56
- "Show the C64 in a window on the host, or hide it again. The emulator has no window until you open one. " +
56
+ "Show the C64 in a window, or hide it again. The emulator has no window until you open one. " +
57
57
  "Open the window when the user must type, play or look at the C64. Then tell the user. Wait until the user tells you that they finished. " +
58
58
  "Then close the window. The machine, the disk in drive 8, breakpoints, watchpoints, joysticks, warp mode and c64_timing go along. " +
59
59
  "The run state of the machine does not change. The result names the data that does not go along (notCarried). " +
@@ -98,7 +98,7 @@ export const c64Warp = defineTool({
98
98
  name: "c64_warp",
99
99
  title: "Warp mode",
100
100
  description:
101
- "Turn warp mode on or off. In warp mode the C64 runs as fast as the host can run it. " +
101
+ "Turn warp mode on or off. In warp mode the C64 runs as fast as possible. " +
102
102
  "Warp mode does not change what the C64 does. This does not change the run state of the machine.",
103
103
  inputSchema: z.object({ enabled: z.boolean().describe("true turns warp mode on") }).strict(),
104
104
  outputSchema: z.object({ enabled: z.boolean() }),
package/README.md DELETED
@@ -1,143 +0,0 @@
1
- # c64-re-tools
2
-
3
- <img src="assets/branding/c64-re-tools-transparent.svg" alt="C64 RE Tools" width="440">
4
-
5
-
6
- Let an AI agent work on Commodore 64 programs. The agent drives a real VICE
7
- emulator and runs ACME, DXA, Ghidra and Exomizer. Use it to build new C64 apps and games,
8
- and to reverse engineer old ones.
9
-
10
- It works with Claude Code, Codex, pi, opencode, Gemini, Copilot, Cursor and
11
- Windsurf.
12
-
13
- ## What it can do
14
-
15
- Ask for what you want in plain words. The agent picks the skill for each step.
16
-
17
- **Build new apps and games**
18
-
19
- - Assemble 6510 source with ACME, with errors by file and line, and symbols.
20
- - Pack and crunch a program with Exomizer into one PRG that unpacks itself, checked byte for byte before it is written.
21
- - Load and run the program in VICE. Set breakpoints and watchpoints, step, and read the CPU history and the call stack.
22
- - Read, write, search and compare memory, and disassemble it.
23
- - Show the VIC-II, sprite, SID and CIA state, and capture the screen.
24
- - Type on the keyboard and move the joystick.
25
- - Count cycles, profile the code, and wait for a raster line.
26
- - Run many steps in one go and keep screens, snapshots and coverage as files.
27
- - Tell what any address or register value means on the C64.
28
- - Add features and fixes to a program. Each change has a switch, so you can build the program with it or without it.
29
- - Test a program with scenarios: steps with expected values that give PASS or FAIL.
30
-
31
- **Reverse engineer existing programs**
32
-
33
- - Read D64, D71, D81, G64, T64 and CRT images, list BASIC and find the SYS address.
34
- - Find packers and capture the unpacked program from the emulator.
35
- - Analyse the code with DXA and Ghidra. The toolkit brings its own NMOS 6510 language for Ghidra, with all 256 opcodes.
36
- - Keep names, regions and comments as text in the project, ready for git.
37
- - Compare releases, and find routines that several programs share.
38
- - Generate ACME source that rebuilds the program byte for byte, and its documentation.
39
- - Test that a rebuild behaves as the original: PASS, FAIL or INCONCLUSIVE.
40
- - Export a rebuild as the start of a new program: one value for each switch, unused code removed, as a zip file.
41
-
42
- ## How it works
43
-
44
- VICE and the Host Runtime run on your computer, where VICE can open a window.
45
- The agent runs in a dev container in your project. It reaches VICE through an
46
- MCP server, and it runs ACME, DXA, Ghidra, Exomizer and c64run through its skills.
47
-
48
- ## Install
49
-
50
- ### Host
51
-
52
- You need Node.js 24 or newer and VICE 3.9 or later (`x64sc`, `c1541`, `petcat`)
53
- with its ROM files. Use the latest VICE release.
54
-
55
- Start the Host Runtime, and leave it running:
56
-
57
- ```
58
- npx -y --package=@henols/c64-re-tools@latest c64-re-tools-host
59
- ```
60
-
61
- ### Dev container
62
-
63
- You need Docker or Podman. Copy the example into your project:
64
-
65
- ```
66
- mkdir -p .devcontainer
67
- curl -fsSL -o .devcontainer/devcontainer.json https://raw.githubusercontent.com/henols/c64-re-tools/main/devcontainer/example/devcontainer.json
68
- ```
69
-
70
- Its comments tell what to change: the harness, the release channel, the image
71
- and the address of the Host Runtime. If the project already has a
72
- `devcontainer.json`, copy the c64-re-tools Feature and `runArgs` into it.
73
-
74
- Open the project in the container, for example with "Reopen in Container" in
75
- VS Code, or with `npx -y @devcontainers/cli up --workspace-folder .`. The
76
- Feature gives the container ACME, dxa, Exomizer, Java 21, Ghidra and c64run. At each
77
- start it installs the newest toolkit of its channel into the project, with the
78
- tools of that version. It reads its options only when the container is built:
79
- rebuild after a change.
80
-
81
- Check what works, in the container:
82
-
83
- ```
84
- npx -y @henols/c64-re-tools@latest status
85
- ```
86
-
87
- ## Use it
88
-
89
- Start the agent in the project, for example `claude`, and ask for what you want:
90
-
91
- ```
92
- Write a game in ACME where a sprite moves with the joystick and the border
93
- flashes when it hits the edge. Build it, run it, and show me the screen.
94
- ```
95
- ```
96
- The music stops when the title screen starts. Find out why.
97
- ```
98
- ```
99
- Reverse engineer original/game.d64. Find how it starts, unpack it if it is
100
- packed, and name the main routines.
101
- ```
102
- ```
103
- Find the routine that draws the score, and explain how it works.
104
- ```
105
-
106
- The agent keeps what it learns about a program as text in
107
- `.c64-re-tools/knowledge/`. Commit that folder with the project. If a command
108
- reports conflicts after a `git pull`, run `knowledge.ts merge`.
109
-
110
- Several programs in one repository: open the repository root in the dev
111
- container and give each program its own folder. A folder with `.c64-re-tools/` is a project.
112
-
113
- ## Settings
114
-
115
- Set the host variables where the Host Runtime starts, and the others in
116
- `containerEnv` of the `devcontainer.json`.
117
-
118
- | Variable | Meaning |
119
- | --- | --- |
120
- | `C64RT_VICE`, `C64RT_C1541`, `C64RT_PETCAT` | Full path of the VICE tool, when it is not on `PATH` (host). |
121
- | `C64RT_HOST` | `host:port` of the Host Runtime, when it is not on 127.0.0.1, `host.docker.internal` or `host.containers.internal` at port 6464. |
122
- | `C64RT_VIDEO` | `pal` (default) or `ntsc`. |
123
- | `C64RT_TRACE` | A directory for the trace of the MCP server and the skill scripts. See [Trace](#trace). |
124
-
125
- ## Trace
126
-
127
- Turn on the trace when a tool fails and its error does not tell why. Each
128
- program then writes what it does to a directory, as JSON lines. The Host
129
- Runtime also keeps a copy of the VICE log. The agent does not see the trace.
130
-
131
- On the host, `--log-dir` names the directory, and `--log-console` prints the
132
- same events:
133
-
134
- ```
135
- npx -y --package=@henols/c64-re-tools@latest c64-re-tools-host --log-dir $HOME/c64-trace --log-console
136
- ```
137
-
138
- For the MCP server and the skill scripts, set `C64RT_TRACE` to an absolute
139
- directory in `containerEnv` of the `devcontainer.json`.
140
-
141
- ## License
142
-
143
- MIT. See [LICENSE](LICENSE).