@henols/c64-re-tools 2.7.0 → 2.8.0-rc.1

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.
Files changed (69) hide show
  1. package/package.json +1 -1
  2. package/skills/c64-assembler/SKILL.md +23 -38
  3. package/skills/c64-assembler/scripts/assembler.ts +114 -16
  4. package/skills/c64-basic/SKILL.md +11 -31
  5. package/skills/c64-basic/scripts/basic.ts +4 -1
  6. package/skills/c64-development/SKILL.md +2 -2
  7. package/skills/c64-disk/SKILL.md +11 -32
  8. package/skills/c64-docs/SKILL.md +27 -45
  9. package/skills/c64-docs/references/page-types.md +20 -18
  10. package/skills/c64-docs/references/style.md +10 -4
  11. package/skills/c64-docs/scripts/docs.ts +13 -2
  12. package/skills/c64-docs/scripts/lib/reference.ts +47 -5
  13. package/skills/c64-knowledge/SKILL.md +138 -267
  14. package/skills/c64-knowledge/references/batches.md +48 -0
  15. package/skills/c64-knowledge/references/coverage.md +29 -0
  16. package/skills/c64-knowledge/references/source-knowledge.md +72 -0
  17. package/skills/c64-knowledge/references/start-screen.md +44 -0
  18. package/skills/c64-knowledge/scripts/knowledge.ts +266 -61
  19. package/skills/c64-knowledge/scripts/lib/check.ts +133 -0
  20. package/skills/c64-knowledge/scripts/lib/listing.ts +72 -8
  21. package/skills/c64-memory-map/SKILL.md +11 -32
  22. package/skills/c64-packer/SKILL.md +11 -31
  23. package/skills/c64-provenance/SKILL.md +40 -62
  24. package/skills/c64-provenance/scripts/lib/leftovers.ts +8 -3
  25. package/skills/c64-provenance/scripts/provenance.ts +64 -55
  26. package/skills/c64-reverse-engineering/SKILL.md +20 -47
  27. package/skills/c64-reverse-engineering/references/comment-check.md +42 -0
  28. package/skills/c64-reverse-engineering/references/versions.md +47 -0
  29. package/skills/c64-source/SKILL.md +43 -235
  30. package/skills/c64-source/references/export.md +50 -0
  31. package/skills/c64-source/references/loader.md +78 -0
  32. package/skills/c64-source/references/source-format.md +46 -0
  33. package/skills/c64-source/scripts/lib/export.ts +20 -7
  34. package/skills/c64-source/scripts/lib/loader.ts +116 -104
  35. package/skills/c64-source/scripts/source.ts +62 -52
  36. package/skills/c64-static-analysis/SKILL.md +51 -52
  37. package/skills/c64-static-analysis/scripts/lib/coverage.ts +55 -2
  38. package/skills/c64-static-analysis/scripts/lib/idioms.ts +28 -9
  39. package/skills/c64-static-analysis/scripts/static-analysis.ts +69 -15
  40. package/skills/c64-testing/SKILL.md +77 -59
  41. package/skills/c64-testing/references/recording-format.md +5 -79
  42. package/skills/c64-testing/references/scenario-format.md +4 -12
  43. package/skills/c64-testing/scripts/lib/play.ts +16 -8
  44. package/skills/c64-testing/scripts/lib/recording.ts +76 -9
  45. package/skills/c64-testing/scripts/lib/replay.ts +14 -0
  46. package/skills/c64-testing/scripts/lib/runs.ts +112 -1
  47. package/skills/c64-testing/scripts/lib/scenario.ts +12 -6
  48. package/skills/c64-testing/scripts/lib/start-screen.ts +27 -0
  49. package/skills/c64-testing/scripts/testing.ts +37 -15
  50. package/skills/c64-unpacker/SKILL.md +10 -30
  51. package/skills/emulator/SKILL.md +7 -36
  52. package/src/build-name.ts +12 -1
  53. package/src/knowledge/history.ts +8 -0
  54. package/src/knowledge/program.ts +73 -1
  55. package/src/knowledge/read.ts +46 -2
  56. package/src/knowledge/recording-files.ts +32 -0
  57. package/src/knowledge/schema.ts +3 -1
  58. package/src/knowledge/separate.ts +90 -3
  59. package/src/knowledge/start-screen.ts +99 -17
  60. package/src/knowledge/text.ts +2 -1
  61. package/src/knowledge/write.ts +15 -8
  62. package/src/loader.ts +167 -0
  63. package/src/native/c64run.ts +11 -0
  64. package/src/native/decompiler/analyze.ts +7 -6
  65. package/src/native/decompiler/walk.ts +32 -2
  66. package/src/native/dxa.ts +4 -4
  67. package/src/native/types.ts +32 -4
  68. package/src/script.ts +87 -17
  69. package/skills/c64-export/SKILL.md +0 -63
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: c64-provenance
3
- description: Compares two or more releases of a C64 program byte by byte and tells which releases agree at each difference. It can run each release and tell how the program uses each difference. It gives evidence for each range of the program in the project knowledge. It finds the leftovers in the program, for example texts, assembler source, BASIC lines, unused bytes, copies and dead code. It keeps a library of routines that several programs share, and finds these routines in a program. Use it to separate the program from the changes of a crack or of a release. The bytes that the releases share do not prove the bytes of the commercial original. Use it to find the history of a program in its leftovers. Use it to find known routines, for example a music driver, in a program. It does not disassemble or analyze the code, and it does not change the project knowledge.
3
+ description: Compares two or more releases of a C64 program byte by byte and tells which releases agree at each difference. It can run each release and tell how the program uses each difference. It gives evidence for each range of the program in the project knowledge. It finds the leftovers in the program, for example texts, assembler source, BASIC lines, unused bytes, copies and dead code. It keeps a library of routines that several programs share, and finds these routines in a program. Use it to separate the program from the changes of a crack or of a release. The bytes that the releases share do not prove the bytes of the commercial original. Use it to find the history of a program in its leftovers. Use it to find known routines, for example a music driver, in a program. It does not disassemble or analyze the code. It changes the project knowledge only when it writes the names of the found routines.
4
4
  ---
5
5
 
6
6
  # C64 provenance
@@ -28,9 +28,11 @@ To get the command list, run the script with no arguments.
28
28
  | Compare only the bytes in a range | `compare releases/a.prg releases/b.prg --range '$0900-$09ff'` |
29
29
  | Map two releases with moved code in blocks of equal bytes | `compare releases/a/image.json releases/b/image.json --align --range '$0400-$bfff'` |
30
30
  | Find how each release uses each difference | `compare knowledge .c64-re-tools/local/b/image.json --frames 600 --steps .c64-re-tools/local/start-game.json` |
31
- | Get the evidence for each range of the program in the project knowledge | `separate --out .c64-re-tools/local/separate.json` |
32
- | Find the leftovers in the program | `leftovers --out .c64-re-tools/local/leftovers.json` |
31
+ | Get the evidence for each range of the program in the project knowledge | `separate` |
32
+ | Find the leftovers in the program | `leftovers` |
33
+ | Get all items of one list of leftovers | `leftovers --max-listed 1000 --fields deadCode` |
33
34
  | Find short texts, for example a group name | `leftovers --min-text 6` |
35
+ | Keep all leftovers in a file for a later step | `leftovers --out .c64-re-tools/local/leftovers.json` |
34
36
  | Save a module of the program as a routine of the library | `routine '$1000' --library ../library` |
35
37
  | Save a range of the program as a routine with a name | `routine '$1000-$1026' --name play --library ../library` |
36
38
  | Find the routines of the library in the program | `match --library ../library` |
@@ -43,7 +45,7 @@ To get the command list, run the script with no arguments.
43
45
  - `compare` takes two or more releases. A release is one of these:
44
46
  - `knowledge`: the program in the project knowledge.
45
47
  - A PRG file. The script puts it at its load address.
46
- - The `image.json` of a capture of the unpacked program. Put its `entry_state.json` beside it. Without that file, `--frames` cannot start the release.
48
+ - The `image.json` of a capture folder. Keep all files of the capture folder together. Without them, `--frames` cannot start the release.
47
49
  - Get a PRG out of a disk image before you compare it. The script refuses a disk image, a tape image and a cartridge image.
48
50
  - Unpack a packed release before you compare it.
49
51
  - The first release on the command line is release 1. `--shift` uses these numbers.
@@ -64,12 +66,11 @@ To get the command list, run the script with no arguments.
64
66
  - A range is `<start>-<end>`, for example `'$c000-$cfff'`. In a JSON file, a range is `start` and `end`.
65
67
  - Bytes in a JSON file are hex in a field `data`, for example `"data": "a900"`.
66
68
  - Write each file that you make for your work in `.c64-re-tools/local/` of the project. Git ignores that folder. Examples are results, batches, step files, runs, snapshots and memory dumps.
67
- - The script refuses an `--out` path in `.c64-re-tools/knowledge/` and the index of the knowledge. Change the project knowledge only with the commands that change it.
69
+ - The script refuses an `--out` path in `.c64-re-tools/knowledge/`. Change the project knowledge only with the commands that change it.
68
70
  - The script refuses a folder where the command writes a file. It refuses a file where the command writes a folder.
69
71
  - When a test or another file is the evidence for a finding in the project knowledge, move it out of `.c64-re-tools/local/` first. The project knowledge refuses that evidence in that folder.
70
- - A coverage map can stay in `.c64-re-tools/local/`. The project knowledge keeps its ranges and its SHA-256.
71
- - Do not move a coverage map after you put it into the project knowledge. The knowledge refers to the map by its path at that time.
72
- - Put a run that is evidence in `runs/<name>/`, with its run file, its results and its snapshot files. Change the paths in the run file to the new paths. Then git keeps them, and another person can do the run again.
72
+ - A coverage map can stay in `.c64-re-tools/local/`. Do not move a coverage map after you put it into the project knowledge.
73
+ - To keep a run as evidence, use the command that keeps a run. It copies the run, its results and its snapshot files into `runs/<name>/`, and it changes the paths in the copy. Then git keeps them, and another person can do the run again.
73
74
  - A shell redirect (`>`) is relative to the working directory, not to the project folder. From the folder above the project, write `<folder>/.c64-re-tools/local/result.json`.
74
75
 
75
76
  ---
@@ -86,7 +87,7 @@ Each flag applies only to the commands in the table. On another command, the scr
86
87
  | `--min-block <n>` | `compare` | With `--align`: the minimum number of bytes in a block, from 8. The default is 16. |
87
88
  | `--frames <n>` | `compare` | Run each release for `n` frames, and give each listed difference its runtime evidence. The default is no run. |
88
89
  | `--steps <file>` | `compare` | With `--frames`: run the action steps of this file before the frames. The default is no steps. |
89
- | `--out <file>` | `separate`, `leftovers` | Write all items to this file. The default is no file. |
90
+ | `--out <file>` | `separate`, `leftovers` | Write the fields of the body to this file, with all items of each list. The default is no file. |
90
91
  | `--apply` | `match` | Write the changes to the project knowledge as one revision of the LLM. Without it, `match` writes nothing. |
91
92
  | `--max-listed <n>` | `separate`, `leftovers`, `match` | List at most `n` items of each list. The default is 50. `count` always gives the full number. |
92
93
  | `--min-text <n>` | `leftovers` | The minimum number of characters in a text, from 4. The default is 8. A short text, for example a group name, can need 6. |
@@ -123,7 +124,7 @@ With `--frames`, the body also holds:
123
124
  - `changed`: `true` when the bytes at the end of the run are not the bytes of the release.
124
125
  - `run`: `frames`, `steps` and `releases`. `releases` tells for each release if it started, or the `reason` that it did not start. `skipped` tells that the releases have no differences, so no release ran.
125
126
 
126
- A PRG starts with RUN after its load. An image starts at its entry, with the state of `entry_state.json`.
127
+ A PRG starts with RUN after its load. An image starts at its entry, with the entry state of its capture.
127
128
 
128
129
  With `--align`, the body holds a map in place of `differences` and the shift suggestions:
129
130
 
@@ -143,7 +144,7 @@ With `--align`, the body holds a map in place of `differences` and the shift sug
143
144
  Traps:
144
145
 
145
146
  - `common` is empty: the releases do not have bytes at the same addresses. Give `--shift`, or a `--range` that all releases have.
146
- - A release has `started: false`: the PRG has no BASIC start, or the image has no `entry_state.json`. The `reason` tells which. The other releases still give evidence.
147
+ - A release has `started: false`: the PRG has no BASIC start, or the capture folder of the image has no entry state. The `reason` tells which. The other releases still give evidence.
147
148
  - Each release writes a range before it reads it: the range is probably runtime state, not a difference of the releases.
148
149
  - A range has `first: none` in each release: the run did not use it. Run more frames or other steps before you decide.
149
150
  - The script refuses `--align` with `--shift` or `--frames`. It refuses `--min-block` without `--align`, and `--steps` without `--frames`.
@@ -169,11 +170,11 @@ Gives evidence from the program in the project knowledge, its stages and its cov
169
170
  - A `read` byte right after executed code, or at a return address, can be a dummy read of the 6502. The program does not use it.
170
171
  - `roots`: the addresses where the reachability starts, each with `address` and `from`. The roots are the entry, and the NMI, RESET and IRQ vectors at `$fffa`-`$ffff` when the program holds them. A text in place of the list tells why no code region is reachable.
171
172
  - `codeRegions.total`: the number of code regions in the project knowledge.
172
- - `codeRegions.unreachable`: the code regions that no chain of call and jump references reaches from a root. The CPU also continues into the next code region when the last instruction of a region is not RTS, RTI, JMP, BRK or JAM.
173
- - `outside`: only with coverage. `read` and `executed` give the RAM outside the program that the program used but did not write. A loader or an earlier stage put these bytes there. `generated` gives the code that the program wrote outside its segments. A `generated` range can have gaps of two bytes or less: these are operand bytes.
174
- - `out`, `bytes` and `sha256`: the file of `--out`. It holds the roots, and all ranges, code regions and outside ranges.
173
+ - `codeRegions.unreachable`: the code regions that no chain of call and jump references reaches from a root.
174
+ - `outside`: only with coverage. `read` and `executed` give the RAM outside the program that the program used but did not write. A loader or an earlier stage put these bytes there. `generated` gives the code that the program wrote outside its segments.
175
+ - `out`, `bytes` and `sha256`: the `--out` file. It has the fields of the body, with all items of each list.
175
176
 
176
- `hint`: a list is cut. Without `--out`, give a larger `--max-listed`, or give `--out`. With `--out`, read the file.
177
+ `hint`: a list is cut. Run the command again with a larger `--max-listed`.
177
178
 
178
179
  Traps:
179
180
 
@@ -185,7 +186,7 @@ Traps:
185
186
 
186
187
  Finds what the program in the project knowledge holds in addition to its working code. It gives evidence, not a decision.
187
188
 
188
- `body` holds `entry`, `roots`, and `stages` or `noStages`, as `separate` gives them. `noCoverage` tells that the project knowledge has no coverage. Then `residue` is empty and no finding has `access`. The body also holds these lists:
189
+ `body` holds `entry`, `roots`, and `stages` or `noStages`, as `separate` gives them. `noCoverage` tells that the project knowledge has no coverage. Then `residue` is empty and no finding has `access`. The body also has one list for each kind of finding. Each list holds at most `--max-listed` findings, and its `count` gives all of them:
189
190
 
190
191
  | List | What it holds |
191
192
  |---|---|
@@ -195,12 +196,13 @@ Finds what the program in the project knowledge holds in addition to its working
195
196
  | `residue` | Bytes that no run touched, and that are not text, BASIC, fill or a code region. `bytes` shows the first 16 bytes. |
196
197
  | `copies` | At least 32 bytes that are the same as earlier bytes of the program. `copyOf` is the address of the earlier bytes. |
197
198
  | `deadCode` | Code regions that no root reaches, as in `codeRegions.unreachable` of `separate`, and that no run executed. |
199
+ | `unknownCode` | Code regions that no root reaches and that no run executed, but that are not dead code. No coverage shows that they did not run, or a flow in `unresolved` can go to them. Each flow has `at` and `kind`. |
198
200
 
199
201
  Each finding has `stages`: the unpack stages that wrote its bytes. A stage before the last stage is a depacker, an intro or a loader. Each finding also has `access`: the accesses of its bytes in the coverage.
200
202
 
201
- `out`, `bytes` and `sha256` give the file of `--out`. It holds all findings with the full texts.
203
+ `out`, `bytes` and `sha256` give the `--out` file. It has the fields of the body, with all findings and the full texts.
202
204
 
203
- `hint`: a list is cut. Without `--out`, give a larger `--max-listed`, or give `--out`. With `--out`, read the file.
205
+ `hint`: a list is cut. Run the command again with a larger `--max-listed`. To get only the lists that you need, give `--fields`, for example `--fields text,deadCode`.
204
206
 
205
207
  Text from another computer can show the tools of the developer:
206
208
 
@@ -219,6 +221,7 @@ Traps:
219
221
 
220
222
  - No coverage: `residue` is empty. Put the coverage of runs that use many parts of the program into the project knowledge.
221
223
  - No code regions: `deadCode` is empty, and `residue` can include code. Analyze the program for its code regions first.
224
+ - `unknownCode` has items: a flow in `unresolved` can go to the code, or the knowledge has no coverage. Do not call this code dead. Find the targets of each flow in the emulator, and record a jump reference from the flow to each target in the project knowledge. When the flow goes outside the program, record the reference to that address.
222
225
  - Error `not-found`: the project knowledge has no program. Put the program into the project knowledge.
223
226
 
224
227
  ---
@@ -227,7 +230,7 @@ Traps:
227
230
 
228
231
  ### `routine <module|range>`
229
232
 
230
- Saves a routine of the program in the project knowledge to the library. The file keeps the user and LLM names, comments, regions, references and operand expressions in the range. It also keeps the code regions of each origin.
233
+ Saves a routine of the program in the project knowledge to the library. The routine file keeps the user and LLM names, comments, regions, references and operand expressions in the range.
231
234
 
232
235
  - A module ends at the next module, or at the end of its segment.
233
236
  - A routine has at least 16 bytes. Its last instruction must end in the range.
@@ -266,19 +269,12 @@ Finds each routine of the library in the program of the project knowledge.
266
269
  - `library` and `routines`: the library folder and the number of routines in it.
267
270
  - `matches`: each item has `routine`, `start`, `end` and `shift`. `shift` is the address in the program minus the address in the library.
268
271
  - `differing` in each match: each operand that addresses something outside the routine and that is different. It gives the value in the `library` and in the `program`. Examine each one. For example, the program can use other variables or another SID voice.
269
- - `changes`: with matches. `writes` lists the writes for the project knowledge. `known` counts the writes that the project knowledge has already. `leftOut` lists the writes that the script left out, and why. `check` lists each comment of `writes` that gives an address outside its routine. Each item has `routine`, `address`, `comment` and the `outside` addresses. Such an address can be different in this program. With `--apply`, `revision` gives the revision of the changes.
270
-
271
- The changes have the names, regions, comments, references and operand expressions of each routine at its address in the program. The script leaves out a write in these conditions:
272
-
273
- - The program has a user or LLM row at that place.
274
- - The program uses the name at another address.
275
- - A removal holds at that place.
276
- - The routine occurs more than one time, and the script did not choose this copy.
277
- - The script left out the name that an operand expression uses, or the expression does not give the operand in the program.
278
-
279
- A routine can occur more than one time. Then the script finds the nearest routines before and after it in the library that occur only one time. The script writes the names at the copy that has the shift of one of these routines. If no copy or more than one copy has such a shift, the script writes no names for the routine. Then `changes.leftOut` gives each copy with the reason `ambiguous`.
280
-
281
- An address `$xxxx` in a comment moves with the routine when the address is in the routine. An address outside the routine does not move, and `changes.check` gives the comment.
272
+ - `changes`: with matches.
273
+ - `writes`: the names, regions, comments, references and operand expressions of each routine at its address in the program. An address in a comment moves with the routine when the address is in the routine.
274
+ - `known`: the count of the writes that the project knowledge has already.
275
+ - `leftOut`: the writes that the script left out, each with its `reason`. For example, the program has a user or LLM row at that place. Or the routine has two or more copies, and the script cannot choose one (`ambiguous`).
276
+ - `check`: each comment of `writes` that gives an address outside its routine. Each item has `routine`, `address`, `comment` and the `outside` addresses. Such an address can be different in this program.
277
+ - `revision`: with `--apply`, the revision of the changes.
282
278
 
283
279
  `hint` and `nextAction`:
284
280
 
@@ -288,7 +284,8 @@ An address `$xxxx` in a comment moves with the routine when the address is in th
288
284
 
289
285
  Traps:
290
286
 
291
- - `match` does not change the project knowledge.
287
+ - Without `--apply`, `match` does not change the project knowledge.
288
+ - A copy in `changes.leftOut` with the reason `ambiguous` gets no names. Examine each copy. Record the names of the copy that you prove in the project knowledge.
292
289
  - Error `not-found`: the library folder does not exist, or it has no routine files. Save a routine with `routine` first.
293
290
  - Error `invalid-input` with "is a project folder": the library folder is a project. Give a folder beside the projects.
294
291
 
@@ -307,13 +304,13 @@ Traps:
307
304
  - Do not call releases independent when you do not know their relation. Two cracks can come from the same source.
308
305
  - Do not call a byte a byte of the commercial original only because one release has it. A majority of releases is also not proof.
309
306
  7. Record each release in the project knowledge. The base release is the program in the project knowledge.
310
- 8. Record each difference in the project knowledge as a switch and a patch. Select the kind of the switch:
307
+ 8. Record a switch in the project knowledge for each difference. Give the switch the labels of the releases that have it on. Select the kind of the switch:
311
308
  - `protection`: a copy protection, or the code that a crack changed to remove it.
312
309
  - `trainer` or `cheat`: a trainer or a cheat.
313
310
  - `crack`: another change of a cracker in the program, for example a credit text.
314
311
  - `fix`: a correction of a bug. Make one switch for each correction, not one switch for each release.
315
312
  - `change`: another difference.
316
- 9. Give the switch the labels of the releases that have it on. The patch holds the bytes that the base release does not have.
313
+ 9. For each range of a switch, record the patch from the bytes of a release that has the switch on. The patch holds the bytes that the base release does not have.
317
314
  10. Record each other conclusion in the project knowledge as a comment or a region. Do not record the full comparison.
318
315
 
319
316
  ### Find the leftovers
@@ -322,7 +319,7 @@ Traps:
322
319
  2. Put the coverage of runs that use many parts of the program into the project knowledge.
323
320
  3. Analyze the program for its code regions.
324
321
  4. Run `leftovers`. When you have two or more releases, also run `compare`.
325
- 5. Read `text` first: names, dates, greetings and credits. Then read `copies`, `residue`, `basic` and `deadCode`.
322
+ 5. Read `text` first: names, dates, greetings and credits. Then read `copies`, `residue`, `basic`, `fill` and `deadCode`.
326
323
  6. Examine each important finding. Disassemble or analyze its bytes, or examine them in the emulator.
327
324
  - Old code or old source text is evidence of the development. It does not prove the computer of the authors, the order of their work, or the path of a copy through the crackers.
328
325
  7. Record each finding that you proved in the project knowledge. Do not record the full list of leftovers.
@@ -344,24 +341,15 @@ Traps:
344
341
 
345
342
  Each command prints one JSON envelope on one line on stdout. Notes go to stderr.
346
343
 
347
- On success, the exit code is 0:
348
-
349
- ```json
350
- {"ok": true, "command": "<command>", "body": {}, "hint": "...", "nextAction": "..."}
351
- ```
352
-
353
- On failure, the exit code is 2:
354
-
355
- ```json
356
- {"ok": false, "command": "<command>", "code": "<code>", "error": "...", "hint": "...", "nextAction": "..."}
357
- ```
358
-
344
+ - On success, the exit code is 0: `{"ok": true, "command": "<command>", "body": {}, "hint": "...", "nextAction": "..."}`
345
+ - On failure, the exit code is 2: `{"ok": false, "command": "<command>", "code": "<code>", "error": "...", "hint": "...", "nextAction": "..."}`
359
346
  - `body` holds the result. The section of each command gives the fields of its body.
360
347
  - A check gives its verdict in `body.result`: `PASS`, `FAIL` or `INCONCLUSIVE`. The exit code is 0 for each verdict. Thus read `body.result`, not the exit code.
361
- - `error` is one sentence. It tells what is wrong.
362
- - `hint` tells what to do or what to examine. Read it before your next step. Some envelopes have no `hint`.
363
- - `nextAction` is a full command line. It runs from any directory. Run it when it agrees with your task. Some envelopes have no `nextAction`.
364
- - `code` does not change between versions. Do the action for the code:
348
+ - `error` is one sentence. It tells what is wrong. `hint` tells what to do or what to examine. Read it before your next step.
349
+ - `nextAction` is a full command line. It runs from any directory. Run it when it agrees with your task.
350
+ - A list has `count`, `listed` and `rest`. `listed` holds at most `--max-listed` items. `rest` tells how to get the other items. A file that the command wrote has `out`, `bytes` and `sha256`.
351
+ - To get only some fields of `body`, give `--fields <path>,<path>`, for example `--fields count,listed.start`. A path through a list gives that field of each item. Do not write code to filter an envelope.
352
+ - To get the command list, run the script with no arguments. To get the subjects and the flags of one command, run `<command> --help`.
365
353
 
366
354
  | `code` | Action |
367
355
  |---|---|
@@ -369,13 +357,3 @@ On failure, the exit code is 2:
369
357
  | `invalid-input`, `not-found` | Correct the call as `hint` tells. Then run the command again. |
370
358
  | `operation-failed` | Give `error` and `hint` to the user. |
371
359
  | Another code | Do as `hint` tells. |
372
-
373
- These fields have the same meaning in each body:
374
-
375
- | Field | Meaning |
376
- |---|---|
377
- | `out`, `bytes`, `sha256` | A file that the command wrote: its path, its size and its SHA-256. |
378
- | `count`, `listed`, `rest` | A list. `count` is the number of items. `listed` holds the first items, at most `--max-listed`. `rest` tells how to get the other items. |
379
-
380
- To get the command list, run the script with no arguments. The envelope has `command: "help"`, and `body.commands` gives the name, the summary and the synopsis of each command.
381
- To get the subjects and the flags of one command, run `<command> --help`. Then `body.subjects` and `body.options` give them.
@@ -76,6 +76,8 @@ export interface Leftovers {
76
76
  residue: ResidueFinding[];
77
77
  copies: CopyFinding[];
78
78
  deadCode: DeadCodeFinding[];
79
+ /** Code that nothing reaches and that no run executed, which is not dead: a flow that nobody resolved can go there, or no coverage shows that it did not run. */
80
+ unknownCode: DeadCodeFinding[];
79
81
  }
80
82
 
81
83
  const MIN_TEXT = 8;
@@ -435,8 +437,11 @@ export function findLeftovers(input: LeftoversInput): Leftovers {
435
437
  const explained = [...text, ...basic, ...fill, ...separation.codeRegions];
436
438
  const residue = untouched.flatMap((range) => without(range, explained, MIN_RESIDUE));
437
439
  // The references miss IRQ vectors and jumps through tables: code that ran is not dead.
438
- const deadCode: DeadCodeFinding[] = separation.codeRegions
440
+ const unreached = separation.codeRegions
439
441
  .filter((region) => region.reachable === false && region.executed !== true)
440
- .map((region) => ({ start: region.start, end: region.end, type: region.type, ...(region.executed === false ? { executed: false as const } : {}) }));
441
- return { text: placed(text), basic: placed(basic), fill: placed(fill), residue: placed(residue), copies: placed(findCopies(memory, segments)), deadCode: placed(deadCode) };
442
+ .map((region) => ({ start: region.start, end: region.end, type: region.type, ...(region.executed === false ? { executed: false as const } : {}), unknown: region.unknown === true }));
443
+ const finding = ({ unknown: _, ...region }: (typeof unreached)[number]): DeadCodeFinding => region;
444
+ const deadCode = unreached.filter((region) => !region.unknown).map(finding);
445
+ const unknownCode = unreached.filter((region) => region.unknown).map(finding);
446
+ return { text: placed(text), basic: placed(basic), fill: placed(fill), residue: placed(residue), copies: placed(findCopies(memory, segments)), deadCode: placed(deadCode), unknownCode: placed(unknownCode) };
442
447
  }
@@ -1,12 +1,12 @@
1
1
  // The c64-provenance script: compares two or more releases byte by byte at
2
2
  // their addresses and reports where they differ and which releases agree. A
3
- // release is a PRG or an unpacker image.json. With --run, each release
3
+ // release is a PRG or an unpacker image.json. With --frames, each release
4
4
  // runs in its own emulator, and each listed difference gets its first access
5
5
  // and whether the run changed it. The separate command gives evidence from
6
6
  // the program in the knowledge, and the leftovers command lists what its
7
7
  // unused bytes hold: text, BASIC lines, fills and copies. The routine and match commands keep
8
8
  // routines that several programs share in a library folder and find them in the
9
- // program (D71).
9
+ // program.
10
10
 
11
11
  import { basename } from "node:path";
12
12
 
@@ -282,6 +282,8 @@ function programEvidence() {
282
282
  ...(coverage === undefined ? {} : { coverage }),
283
283
  codeRegions: regions,
284
284
  references,
285
+ // A reference of the user or the LLM from a jump gives the targets of its flow.
286
+ resolvedSites: new Set(references.filter((reference) => (SEMANTIC_ORIGINS as readonly string[]).includes(reference.origin)).map((reference) => reference.from)),
285
287
  });
286
288
  return { program, stages, coverage, found };
287
289
  }
@@ -293,10 +295,9 @@ const NO_ROOTS = "none: the program in the knowledge has no entry, and the image
293
295
 
294
296
  const NO_STAGES = "The program in the knowledge has no stage log. Only a capture of the unpack stages gives one. A capture of the loads of a loader holds one part of a program and has none.";
295
297
 
296
- /** separate: evidence from the program in the knowledge, with all ranges in --out and the first ones in the result. */
298
+ /** separate: evidence from the program in the knowledge. --out gets the fields of the body with all items of each list. */
297
299
  function separateCommand(call: Call): unknown {
298
300
  const out = call.string("out");
299
- const max = call.count("max-listed")!;
300
301
  const { program, stages, coverage, found } = programEvidence();
301
302
  const loaded = { entry: program.entry, stages };
302
303
  const show = (range: AddressRange) => ({ start: formatC64Address(range.start), end: formatC64Address(range.end) });
@@ -304,31 +305,32 @@ function separateCommand(call: Call): unknown {
304
305
  const codeRegions = found.codeRegions.map((region) => ({ ...show(region), type: region.type, ...(region.reachable === undefined ? {} : { reachable: region.reachable }), ...(region.executed === undefined ? {} : { executed: region.executed }) }));
305
306
  const outside = { read: found.outside.read.map(show), executed: found.outside.executed.map(show), generated: found.outside.generated.map(show) };
306
307
  const roots = showRoots(found.roots);
307
- const written = out === undefined ? undefined : writeReported(out, `${JSON.stringify({ roots, ranges, codeRegions, outside }, null, 1)}\n`, { what: "--out" });
308
- const list = <T>(items: T[]) => listed(items, max, undefined, out ?? "a larger --max-listed, or --out <file>");
309
308
  const bytes = (filter: (range: (typeof found.ranges)[number]) => boolean) => found.ranges.filter(filter).reduce((sum, range) => sum + range.end - range.start + 1, 0);
310
309
  const lastStage = loaded.stages === undefined ? undefined : loaded.stages.length - 1;
311
- const body = {
312
- ...(loaded.entry === undefined ? {} : { entry: formatC64Address(loaded.entry) }),
313
- ...(lastStage === undefined
314
- ? { noStages: NO_STAGES }
315
- : {
316
- stages: lastStage + 1,
317
- bytesByStage: Object.fromEntries([...[...Array(lastStage + 1).keys()].map((stage): [string, number] => [String(stage), bytes((range) => range.stage === stage)]), ["none", bytes((range) => range.stage === undefined)]]),
318
- }),
319
- ...(coverage === undefined ? {} : { bytesByAccess: Object.fromEntries((["executed", "read", "written", "read-written", "untouched"] as const).map((access) => [access, bytes((range) => range.access === access)])) }),
320
- ranges: list(ranges),
321
- // The roots of the reachability: the entry and the hardware vectors in the image.
322
- roots: roots.length === 0 ? NO_ROOTS : roots,
323
- // total counts every code region; unreachable is a list like the others.
324
- codeRegions: {
325
- total: codeRegions.length,
326
- ...(roots.length === 0 ? {} : { unreachable: list(codeRegions.filter((region) => region.reachable === false)) }),
327
- },
328
- ...(coverage === undefined ? {} : { outside: { read: list(outside.read), executed: list(outside.executed), generated: list(outside.generated) } }),
329
- ...(written === undefined ? {} : written),
310
+ /** The body with at most `most` items in each list. */
311
+ const bodyOf = (most: number) => {
312
+ const list = <T>(items: T[]) => listed(items, most);
313
+ return {
314
+ ...(loaded.entry === undefined ? {} : { entry: formatC64Address(loaded.entry) }),
315
+ ...(lastStage === undefined
316
+ ? { noStages: NO_STAGES }
317
+ : {
318
+ stages: lastStage + 1,
319
+ bytesByStage: Object.fromEntries([...[...Array(lastStage + 1).keys()].map((stage): [string, number] => [String(stage), bytes((range) => range.stage === stage)]), ["none", bytes((range) => range.stage === undefined)]]),
320
+ }),
321
+ ...(coverage === undefined ? {} : { bytesByAccess: Object.fromEntries((["executed", "read", "written", "read-written", "untouched"] as const).map((access) => [access, bytes((range) => range.access === access)])) }),
322
+ ranges: list(ranges),
323
+ // The roots of the reachability: the entry and the hardware vectors in the image.
324
+ roots: roots.length === 0 ? NO_ROOTS : roots,
325
+ // total counts every code region; unreachable is a list like the others.
326
+ codeRegions: {
327
+ total: codeRegions.length,
328
+ ...(roots.length === 0 ? {} : { unreachable: list(codeRegions.filter((region) => region.reachable === false)) }),
329
+ },
330
+ ...(coverage === undefined ? {} : { outside: { read: list(outside.read), executed: list(outside.executed), generated: list(outside.generated) } }),
331
+ };
330
332
  };
331
- return withFile(body, out);
333
+ return withFile(bodyOf, call.count("max-listed")!, out);
332
334
  }
333
335
 
334
336
  /** True when a list of the body ({count, listed}) holds fewer items than its count. */
@@ -339,25 +341,27 @@ function hasCutList(value: unknown, depth = 0): boolean {
339
341
  return Object.values(value).some((item) => hasCutList(item, depth + 1));
340
342
  }
341
343
 
342
- /** The note for a cut list: with --out, the file holds all items; without it, a larger --max-listed or --out gives them. */
343
- function cutNote(body: unknown, out: string | undefined): string | undefined {
344
- if (!hasCutList(body)) return undefined;
345
- return out === undefined ? "A list in the body is cut: count gives its full size. To get the rest, give a larger --max-listed." : `A list in the body is cut: count gives its full size. ${out} holds all items.`;
344
+ /** The note for a cut list of match: a larger --max-listed gives the rest. */
345
+ function cutNote(body: unknown): string | undefined {
346
+ return hasCutList(body) ? "A list in the body is cut: count gives its full size. To get the rest, give a larger --max-listed." : undefined;
346
347
  }
347
348
 
348
- /** A body with the note for a cut list when --out holds all items. Without --out, the envelope gives the note itself. */
349
- function withFile(body: unknown, out: string | undefined): unknown {
350
- const note = out === undefined ? undefined : cutNote(body, out);
351
- return note === undefined ? body : reply(body, { hint: note });
349
+ /**
350
+ * The body with at most `max` items in each list, and with --out the file of
351
+ * the same fields with all items. A cut list names a larger --max-listed: the
352
+ * envelope gives that note.
353
+ */
354
+ function withFile(bodyOf: (most: number) => Record<string, unknown>, max: number, out: string | undefined): Record<string, unknown> {
355
+ const written = out === undefined ? undefined : writeReported(out, `${JSON.stringify(bodyOf(Number.POSITIVE_INFINITY), null, 1)}\n`, { what: "--out" });
356
+ return { ...bodyOf(max), ...(written === undefined ? {} : written) };
352
357
  }
353
358
 
354
359
  /** The longest text that the result shows; --out has all of it. */
355
360
  const SHOWN_TEXT = 120;
356
361
 
357
- /** leftovers: what the program in the knowledge holds besides its working code, with all findings in --out and the first ones in the result. */
362
+ /** leftovers: what the program in the knowledge holds besides its working code. --out gets the fields of the body with all items and the full texts. */
358
363
  function leftoversCommand(call: Call): unknown {
359
364
  const out = call.string("out");
360
- const max = call.count("max-listed")!;
361
365
  const min = call.count("min-text")!;
362
366
  const { program, stages, coverage, found } = programEvidence();
363
367
  const leftovers = findLeftovers({
@@ -381,28 +385,33 @@ function leftoversCommand(call: Call): unknown {
381
385
  residue: leftovers.residue.map((range) => ({ ...show(range), bytes: hexBytes([...program.memory.subarray(range.start, Math.min(range.end, range.start + 15) + 1)]) + (range.end - range.start >= 16 ? " ..." : "") })),
382
386
  copies: leftovers.copies.map(({ copyOf, ...rest }) => ({ ...show(rest), copyOf: formatC64Address(copyOf) })),
383
387
  deadCode: leftovers.deadCode.map(show),
388
+ unknownCode: leftovers.unknownCode.map(show),
389
+ unresolved: found.unresolved.map((flow) => ({ at: formatC64Address(flow.at), kind: flow.kind })),
384
390
  };
385
- const written = out === undefined ? undefined : writeReported(out, `${JSON.stringify(all, null, 1)}\n`, { what: "--out" });
386
- const list = <T>(items: T[]) => listed(items, max, undefined, out ?? "a larger --max-listed, or --out <file>");
387
- const body = {
388
- ...(program.entry === undefined ? {} : { entry: formatC64Address(program.entry) }),
389
- roots: found.roots.length === 0 ? NO_ROOTS : showRoots(found.roots),
390
- ...(stages === undefined ? { noStages: NO_STAGES } : { stages: stages.length }),
391
- ...(coverage === undefined ? { noCoverage: "The knowledge has no coverage, so residue is empty and no finding has access. Put the coverage of runs into the project knowledge." } : {}),
392
- text: list(all.text.map((item) => (item.text.length > SHOWN_TEXT ? { ...item, text: `${item.text.slice(0, SHOWN_TEXT)} ...`, length: item.text.length } : item))),
393
- basic: list(all.basic),
394
- fill: list(all.fill),
395
- residue: list(all.residue),
396
- copies: list(all.copies),
397
- deadCode: list(all.deadCode),
398
- ...(written === undefined ? {} : written),
391
+ /** The body with at most `most` items in each list; the file has the full texts. */
392
+ const bodyOf = (most: number) => {
393
+ const list = <T>(items: T[]) => listed(items, most);
394
+ const shown = Number.isFinite(most) ? SHOWN_TEXT : Number.POSITIVE_INFINITY;
395
+ return {
396
+ ...(program.entry === undefined ? {} : { entry: formatC64Address(program.entry) }),
397
+ roots: found.roots.length === 0 ? NO_ROOTS : showRoots(found.roots),
398
+ ...(stages === undefined ? { noStages: NO_STAGES } : { stages: stages.length }),
399
+ ...(coverage === undefined ? { noCoverage: "The knowledge has no coverage, so residue is empty and no finding has access. Put the coverage of runs into the project knowledge." } : {}),
400
+ text: list(all.text.map((item) => (item.text.length > shown ? { ...item, text: `${item.text.slice(0, shown)} ...`, length: item.text.length } : item))),
401
+ basic: list(all.basic),
402
+ fill: list(all.fill),
403
+ residue: list(all.residue),
404
+ copies: list(all.copies),
405
+ deadCode: list(all.deadCode),
406
+ ...(all.unknownCode.length === 0 ? {} : { unknownCode: list(all.unknownCode), unresolved: list(all.unresolved) }),
407
+ };
399
408
  };
400
- return withFile(body, out);
409
+ return withFile(bodyOf, call.count("max-listed")!, out);
401
410
  }
402
411
 
403
412
  const platform = () => new Map(platformNames().map((entry) => [entry.name, entry.address]));
404
413
 
405
- /** routine: saves a module or a range of the program in the knowledge, with its knowledge, as a routine of the library (D71). */
414
+ /** routine: saves a module or a range of the program in the knowledge, with its knowledge, as a routine of the library. */
406
415
  function routineCommand(call: Call): unknown {
407
416
  const given = call.subject(0);
408
417
  const library = call.string("library")!;
@@ -497,7 +506,7 @@ function matchCommand(call: Call): unknown {
497
506
  .sort((a, b) => a.start.localeCompare(b.start));
498
507
  const result: Record<string, unknown> = { library, routines: routines.length, matches: list(matches) };
499
508
  const noMatch = "No routine of the library is in the program. A packed program can hold a routine in a packed form. Unpack the program, put the unpacked program into the project knowledge, and run match again.";
500
- const withNote = (shown: unknown, hint: string) => [cutNote(shown, undefined), hint].filter((part) => part !== undefined).join(" ");
509
+ const withNote = (shown: unknown, hint: string) => [cutNote(shown), hint].filter((part) => part !== undefined).join(" ");
501
510
  if (matches.length === 0) return reply(result, { hint: noMatch });
502
511
  const db = openForRead();
503
512
  let suggestions: ReturnType<typeof suggest>;
@@ -569,14 +578,14 @@ const COMMANDS: CommandSpec[] = [
569
578
  {
570
579
  name: "separate",
571
580
  summary: "Evidence from the program in the knowledge: the unpack stage that wrote each range, its access in the coverage, whether call and jump references, or the run on from the code before it, reach each code region from the entry, and what the program reads or executes outside its segments.",
572
- options: { out: { ...OPTIONS.out, output: "file", value: "<file>", help: "write all ranges to this file" }, "max-listed": OPTIONS["max-listed"] },
581
+ options: { out: { ...OPTIONS.out, output: "file", value: "<file>", help: "write the fields of the body, with all items of each list, to this file" }, "max-listed": OPTIONS["max-listed"] },
573
582
  run: separateCommand,
574
583
  },
575
584
  {
576
585
  name: "leftovers",
577
586
  summary: "What the program in the knowledge holds besides its working code: texts in PETSCII, screen codes, ASCII or with bit 7 set (Apple II), assembler source, BASIC lines away from the BASIC start, fills, untouched bytes outside code, copies of earlier bytes, and code regions that nothing reaches and no run executed.",
578
587
  options: {
579
- out: { ...OPTIONS.out, output: "file", value: "<file>", help: "write all findings to this file" },
588
+ out: { ...OPTIONS.out, output: "file", value: "<file>", help: "write the fields of the body, with all findings and the full texts, to this file" },
580
589
  "min-text": { kind: "count", value: "<n>", min: 4, max: 999, default: 8, help: "the shortest text to find (default 8)" },
581
590
  "max-listed": OPTIONS["max-listed"],
582
591
  },
@@ -98,25 +98,32 @@ Do the stages in this sequence. Go to the next stage only when its exit check is
98
98
  | 2. Get | List the disk image. Extract the start file into `releases/`. | The start file is in the project. |
99
99
  | 3. Start | Find the SYS address of the BASIC start. | You have the entry address. |
100
100
  | 4. Unpack | Examine the program for a packer. Trace it and find its stages. Capture a packed program into `.c64-re-tools/local/`. When a segment is the data of a cracktro and the program does not read it, capture again and exclude that range. Put the capture, or the PRG of a program without a packer, into the project knowledge. | The program in the project knowledge has the segments and the entry. |
101
- | 5. Run | First, record. Ask the user to play each part that the scope names, in a recording session. Tell the user which parts. Record a part yourself only when the sessions of the user do not have it. Put the recordings in `tests/recordings/`. Then run the parts that a recording cannot have, in the emulator or as test runs. Write a coverage map for each part into `.c64-re-tools/local/`. Add the maps and the `coverage.bin` of each recording to the project knowledge. | The program in the project knowledge has a coverage map for each part that the scope names. |
101
+ | 5. Run | First, record. Ask the user to play each part that the scope names, in a recording session. Tell the user which parts. Record a part yourself only when the sessions of the user do not have it. Put the recordings in `tests/recordings/`. Then run the parts that a recording cannot have, in the emulator or as test runs. Write a coverage map for each part into `.c64-re-tools/local/`. Put each map and the coverage of each recording into the project knowledge. | The program in the project knowledge has a coverage map for each part that the scope names. |
102
102
  | 6. Analyze | Analyze the program statically. The analysis reads the program and the coverage from the project knowledge. | No coverage conflict is open. |
103
103
  | 7. Name | If the workspace has a routine library, match the program against it. Write the names of the matches to the project knowledge. Then name each routine in the scope and give it a comment. Find the platform addresses in the memory map of the C64. Record the modules. Put the modules of one part of the program in one folder, for example `music/`, `irq/` or `graphics/`. When the scope has hundreds of routines, ask the user which routines to name. The source gives the other routines an `l_xxxx` label. | Each routine that the user selected has a name and a comment. |
104
104
  | 8. Releases and switches | Record the examined reference file, or its capture, as the base release in the project knowledge. The project knowledge keeps the bytes of each release. Record each other release. Compare the releases. Find the leftovers. Record a switch for each copy protection, trainer, cheat, crack change and correction. Record a patch for each range of a switch. Record each leftover as a region with a comment. | The project knowledge lists each switch. Each difference between the releases is in a patch, or the answer gives it as an exception. |
105
105
  | 9. Generate | Generate the source from the project knowledge into `src`. For an unpacked program, also generate the loader. | The result of the generation is PASS. A release whose code is at other addresses is a version with a project of its own, or an exception in the answer. See "Versions of one program". |
106
- | 10. Build and test | Build the base release into `build/`, and compare it with the base release in the project knowledge. The compare includes each segment of the base release. Build the default build. For a generated source with a loader, the default build is `build/clean_loader.prg`. Else it is `build/clean.prg`. Replay each recording on the default build. For each replay, give the checkpoint routine, the state and the random state with the names of stage 7. Then do only the tests that the next paragraph gives. | The criteria of stage 1 are true. |
107
- | 11. Document | When the criteria ask for documentation, generate it into `README.md` and `docs/`. For versions in a group folder, also write the shared pages of the group folder. Write the reference files and the limits of the evidence in the first paragraph. Then link the pages. | The link check of the documentation gives PASS. Each claim stays in the limits of its evidence. |
106
+ | 10. Build and test | Build the base release into `build/`, and compare it with the base release in the project knowledge. The compare includes each segment of the base release. Build the default build: the loader program when the source has a loader, else the clean build. The result of the generation gives its file. Replay each recording on the default build. For each replay, give the checkpoint routine, the state and the random state with the names of stage 7. Then do only the tests that the next paragraph gives. | The criteria of stage 1 are true. |
107
+ | 11. Document | When the criteria ask for documentation, generate it into `README.md` and `docs/`. For versions in a group folder, also write the shared pages of the group folder. Write the reference files, the limits of the evidence and the result of the last comment check in the first paragraph. Then link the pages. | The link check of the documentation gives PASS. Each claim stays in the limits of its evidence. |
108
108
  | 12. Hand over | Find each file that you made outside `.c64-re-tools/local/` and that is not a deliverable. Move it into `.c64-re-tools/local/`. Then give the answer (below). | Each file that you made outside `.c64-re-tools/local/` is a deliverable. |
109
109
 
110
110
  In stage 5, make the recordings before you change the program. A recording needs no names, and its coverage gives the analysis of stage 6 more code. If you cannot get to a part of the program, ask the user how to get to it. Do stages 7 to 9 again until the source is clear. Each generation writes the source again.
111
111
 
112
112
  In stage 10, a build that is identical to the base release proves the source. It proves only the bytes of the base release. Do not test the base release more. The capture of stage 4 can leave out ranges, for example the data of a cracktro. Give each such range in the answer. The default build is different from the base release only in its patches, its leftovers and its loader. The replays on the default build test these differences:
113
113
 
114
- - Replay only the default build: `build/clean_loader.prg` for a source with a loader, else `build/clean.prg`. Do not replay a release build or a build with a switch that is not at its default.
114
+ - Replay only the default build. Do not replay a release build or a build with a switch that is not at its default.
115
115
  - Write a test scenario only for a test that a replay cannot do. Examples are a program that loads more files from a disk, and a criterion of the user.
116
116
  - Do the other tests of stage 1 only when the user selected them.
117
117
 
118
118
  After stage 7, save each routine that other programs can have to the routine library of the workspace. Examples are a music driver, a decruncher and a loader. Ask the user before you make a library.
119
119
 
120
+ After the last pass of stages 7 to 9, check the comments:
121
+
122
+ 1. Start a check of 30 comments of the LLM in the project knowledge. Keep the seed of the check.
123
+ 2. Give the check to an agent that did not write the comments, for example a new subagent. Give it the seed and the instructions in `<skill>/references/comment-check.md`.
124
+ 3. Get the result of the check. Correct each `wrong` comment and name in the project knowledge. Give the file of the verdicts as evidence of each correction.
125
+ 4. Generate the source again.
126
+
120
127
  ### Deliverables of a full rebuild
121
128
 
122
129
  - `.c64-re-tools/knowledge/` with the program, its entry state, the coverage, the names, the regions, the comments, the modules, the releases, the switches and the patches
@@ -136,55 +143,16 @@ All other files that you made are not deliverables. Keep them in `.c64-re-tools/
136
143
  Give the user a short answer at the end. Do not write a report file. Write a report file only when the user asks for it. The knowledge, `docs/` and the scenarios keep the durable results. The answer has:
137
144
 
138
145
  1. Each criterion of stage 1 and its result, and each exception that the user accepted.
139
- 2. The count of the code ranges that no run executed. The ranges are in `.c64-re-tools/local/generated/src/not_executed.json` for the source in `src/`.
146
+ 2. The count of the code ranges that no run executed. The result of the generation gives the count and the ranges.
140
147
  3. The switches: the name, the kind and the default of each, and the releases that have it on. Also a copy protection that a crack removed and that no release has.
141
148
  4. Open questions: what the evidence does not explain.
149
+ 5. The result of each comment check: the seed, the number of comments in the sample, and the number of `wrong` and `unsure` comments before the corrections.
142
150
 
143
151
  Keep observed facts apart from your conclusions.
144
152
 
145
- ### Project layout
146
-
147
- If the project has no layout, use this one. No script checks it. Each script takes the paths that you give.
148
-
149
- ```
150
- releases/ the disk image or the program as you got it
151
- src/ the generated source
152
- build/ the built programs. Do not commit them: each build writes them again.
153
- tests/ the test scenarios, and the recordings in tests/recordings/
154
- runs/ the runs that the knowledge gives as evidence
155
- docs/ the documentation, with the reference in docs/reference/
156
- tools/ scripts for the formats of this program only
157
- README.md the entry page of the documentation
158
- ```
159
-
160
- Commit each folder of the layout other than `build/`, and `.c64-re-tools/knowledge/`. The knowledge holds the program, the entry state, the bytes of each release and the coverage, so the project needs no other folder for them. Put all other files that you make in `.c64-re-tools/local/`, also the captures and the coverage maps after you put them into the knowledge. Do not let git ignore a folder of the layout other than `build/`. Do not change the `.gitignore` files of the project.
161
-
162
- If the project has a layout, use that layout.
153
+ ### Project layout and versions
163
154
 
164
- A workspace with several projects keeps its routine library in `library/` beside the projects. The library is not a project folder.
165
-
166
- ### Versions of one program
167
-
168
- Some releases of a program have a different layout. Their code is at different addresses, so patches cannot hold the differences. Each of these releases is a version of the program. Give each version a project of its own in a group folder:
169
-
170
- ```
171
- <game>/ the group folder: not a project
172
- README.md the shared entry page: the program, each version, and how the versions differ
173
- docs/ the shared pages: the development, the changes between the versions, the releases, the disk layout
174
- library/ the routine library of the versions
175
- tools/ the scripts for the formats of the program, for all versions
176
- v1/ the project of the first version, with the project layout
177
- v2/ the project of the second version, with the project layout
178
- ```
179
-
180
- 1. Make the group folder in the git repository. Do not put `.c64-re-tools/` in it.
181
- 2. Ask the user before you move a project folder. Then move the current project into `<game>/v1/`. The project knowledge keeps its paths relative to the project folder. Thus the knowledge stays valid after the move.
182
- 3. Make a project folder for the new version, for example `<game>/v2/`. Start at stage 2 with the file of that release. From the group folder, give `--project v2`. In the empty folder `v2/`, give `--project .`. The first write makes the project.
183
- 4. Keep the releases with the same layout in one version. Record them as releases with switches. For example, `v2` holds a base release and a second release from a different crack.
184
- 5. Save the routines of `v1` to the routine library in `<game>/library/`. Give `--library ../library`, because `--library` is relative to the project folder. In stage 7 of `v2`, match the program against that library. Then `v2` gets the names of `v1` for the same routines.
185
- 6. Use the same folders in each version, for example `src` and `docs/reference`.
186
- 7. From the group folder, give `--project v1` or `--project v2` to each script. A script can read a file of another version, for example `../v1/releases/<file>`. Use this to compare the releases of two versions. Record each release only in the project of its version.
187
- 8. Write the facts that the versions share one time, in the pages of the group folder. The pages of each version tell only how that version works.
155
+ For a project without a layout, and for a release whose code is at other addresses, read `<skill>/references/versions.md`. It gives the project layout and the group folder of the versions of one program.
188
156
 
189
157
  ## Knowledge
190
158
 
@@ -214,3 +182,8 @@ A clear answer for the scope, with the durable conclusions in the project knowle
214
182
 
215
183
  - To add a feature or a correction to the rebuilt program, develop it as a change of a rebuilt program.
216
184
  - To start a new program from the rebuilt program, export the rebuilt program as a new project.
185
+
186
+ ## Reference
187
+
188
+ - `<skill>/references/versions.md`: the project layout, and the group folder for the versions of one program.
189
+ - `<skill>/references/comment-check.md`: the instructions for the agent that checks a sample of comments.