@henols/c64-re-tools 2.4.0-rc.2 → 2.4.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 +1 -1
- package/skills/c64-assembler/SKILL.md +6 -3
- package/skills/c64-assembler/scripts/assembler.ts +6 -16
- package/skills/c64-disk/SKILL.md +19 -4
- package/skills/c64-disk/scripts/disk.ts +43 -3
- package/skills/c64-provenance/SKILL.md +8 -4
- package/skills/c64-provenance/scripts/lib/library.ts +85 -11
- package/skills/c64-provenance/scripts/provenance.ts +4 -3
- package/skills/c64-source/SKILL.md +8 -2
- package/skills/c64-source/scripts/lib/export.ts +3 -3
- package/skills/c64-source/scripts/lib/source.ts +80 -24
- package/skills/c64-source/scripts/source.ts +49 -8
- package/skills/c64-static-analysis/SKILL.md +1 -1
- package/skills/c64-testing/SKILL.md +11 -1
- package/skills/c64-testing/references/recording-format.md +5 -1
- package/skills/c64-testing/references/scenario-format.md +5 -3
- package/skills/c64-testing/scripts/lib/recording.ts +32 -6
- package/skills/c64-testing/scripts/lib/runs.ts +13 -7
- package/skills/c64-testing/scripts/lib/scenario.ts +13 -6
- package/skills/c64-testing/scripts/testing.ts +6 -3
- package/src/host/server.ts +31 -6
- package/src/host/tools/c1541.ts +32 -8
- package/src/host/vice/binary-monitor.ts +19 -7
- package/src/host/vice/session.ts +6 -2
- package/src/host-client/connect.ts +12 -2
- package/src/host-client/tools.ts +9 -4
- package/src/host-client/transfer.ts +54 -1
- package/src/host-client/vice-session.ts +10 -3
- package/src/knowledge/import.ts +28 -5
- package/src/knowledge/write.ts +4 -0
- package/src/mcp/main.ts +4 -66
- package/src/mcp/session-source.ts +76 -0
- package/src/native/acme.ts +45 -12
- package/src/native/c64run.ts +1 -1
- package/src/native/types.ts +5 -2
- package/src/protocol/framing.ts +15 -2
- package/src/protocol/messages.ts +77 -25
- package/src/protocol/tools.ts +33 -4
- package/src/protocol/vice.ts +40 -20
- package/tools/c64run.c +48 -12
package/package.json
CHANGED
|
@@ -25,6 +25,7 @@ To get the command list, run the script with no arguments.
|
|
|
25
25
|
|---|---|
|
|
26
26
|
| Build the program from the source | `build src main.a --out build/game.prg` |
|
|
27
27
|
| Build a source that includes files from a folder | `build src main.a --out build/game.prg --include lib` |
|
|
28
|
+
| Build a source that includes a file that you generated into a folder next to the source root | `build src boot.asm --out build/boot.prg --include ../build` |
|
|
28
29
|
| Build a source that sets no start address | `build src main.a --out build/game.prg --set-pc '$0801'` |
|
|
29
30
|
| Check that the rebuild is identical to the program in the project knowledge | `build src main.asm --out build/game.prg --compare` |
|
|
30
31
|
| Build a release and check it against the file of that release | `build src main.asm --out build/original.prg --release ORIGINAL --compare` |
|
|
@@ -37,7 +38,8 @@ To get the command list, run the script with no arguments.
|
|
|
37
38
|
|
|
38
39
|
## The source and the program
|
|
39
40
|
|
|
40
|
-
- `<source-root>` is the folder in the project that holds
|
|
41
|
+
- `<source-root>` is the folder in the project that holds the source files of the program. The script reads only the files in the source root and in the include folders.
|
|
42
|
+
- An include folder is a path relative to the source root, inside the project folder. It can be outside the source root, for example `--include ../build`.
|
|
41
43
|
- `<entry>` is the main source file, relative to the source root. It normally sets its start address, for example `* = $0801`. If it does not, give `--set-pc`.
|
|
42
44
|
- For a source that you generated from the project knowledge, the source root is the folder of that source. The entry is `main.asm`.
|
|
43
45
|
- `--out` is the path of the program, relative to the project folder.
|
|
@@ -77,7 +79,7 @@ Each flag applies only to the commands in the table. On another command, the scr
|
|
|
77
79
|
| Flag | Command | Effect |
|
|
78
80
|
|---|---|---|
|
|
79
81
|
| `--out <file.prg>` | `build` | Required. The path of the program, relative to the project folder. |
|
|
80
|
-
| `--include <dir>` | `build` | An include folder
|
|
82
|
+
| `--include <dir>` | `build` | An include folder: a path relative to the source root, inside the project folder. Give the flag again for each folder. The default is no include folder. |
|
|
81
83
|
| `--define NAME=VALUE` | `build` | An assembler symbol: an integer, also `$` and hex digits, or `true` or `false`. Give the flag again for each symbol. Do not use it for a switch. |
|
|
82
84
|
| `--set-pc <address>` | `build` | The start address when the source does not set one, for example `'$0801'`. |
|
|
83
85
|
| `--release <label>` | `build` | Build a release of the project knowledge. Each switch gets the value of that release. With `--compare`, the reference is the file of the release. |
|
|
@@ -109,7 +111,7 @@ Assembles the source and writes the program to `--out`.
|
|
|
109
111
|
- `used` is `false` when the source does not use the symbol.
|
|
110
112
|
- `symbolsFile`: the file of `--out-symbols`, with `out`, `bytes` and `sha256`.
|
|
111
113
|
- `unusedConstants`: the count of the constants that the list does not include. It is not in the body with `--all-symbols`.
|
|
112
|
-
- `diagnostics`: each item has `severity` (`error`, `warning` or `note`), `file`, `line` and `message`. `file` and `line` are not in an item without a location in the source.
|
|
114
|
+
- `diagnostics`: each item has `severity` (`error`, `warning` or `note`), `file`, `line` and `message`. `file` is relative to the source root. A file in an include folder outside the source root starts with `../`. `file` and `line` are not in an item without a location in the source.
|
|
113
115
|
- `compare`: only with `--compare`. `identical` is `true` when each segment is identical. `segments` has one item for each segment of the reference program, with `start`, `end` and `result`:
|
|
114
116
|
- `identical`.
|
|
115
117
|
- `different`, with `differences` and `firstDifference`. `firstDifference` gives `address`, and the byte of the build (`built`) and of the reference (`reference`), each as `$` and two hex digits.
|
|
@@ -123,6 +125,7 @@ Do as the result tells:
|
|
|
123
125
|
- `hint` tells that `symbols` is cut: give a larger `--max-listed`, or `--out-symbols <file.json>` for the full list.
|
|
124
126
|
- Error `not-found` names the entry: give the main source file relative to the source root.
|
|
125
127
|
- Error `not-found` names an include folder: give `--include` a folder with files, relative to the source root.
|
|
128
|
+
- Error `invalid-input` names an include folder: the folder is outside the project folder. Give `--include` a folder inside the project folder.
|
|
126
129
|
- Error `not-found` names a release: the project knowledge has no release with that label. Record the release in the project knowledge, or give the label of a recorded release.
|
|
127
130
|
- Error `not-found` tells that the knowledge has no program: put the program bytes into the project knowledge. Then use `--compare` again.
|
|
128
131
|
- Error `invalid-input`: an option or a path is wrong. Do as `hint` tells. The script refuses `--space` without `--compare` or `--release`.
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
// The c64-assembler script: assembles project source with ACME, which it runs
|
|
2
2
|
// itself, and writes the program into the project.
|
|
3
3
|
|
|
4
|
-
import { posix } from "node:path";
|
|
5
|
-
|
|
6
4
|
import { formatC64Address } from "#src/c64.ts";
|
|
7
5
|
import { Refusal } from "#src/errors.ts";
|
|
8
6
|
import { readImage } from "#src/host-client/image.ts";
|
|
9
|
-
import {
|
|
7
|
+
import { readSourceTree, writeReported } from "#src/host-client/transfer.ts";
|
|
10
8
|
import { openForRead } from "#src/knowledge/database.ts";
|
|
11
9
|
import { knowledgeNames } from "#src/knowledge/names.ts";
|
|
12
10
|
import { requireProgram } from "#src/knowledge/program.ts";
|
|
@@ -42,7 +40,7 @@ await runScript({
|
|
|
42
40
|
],
|
|
43
41
|
options: {
|
|
44
42
|
out: { ...OPTIONS.out, output: "file", value: "<file.prg>", help: "where to write the program, relative to the project folder", required: true },
|
|
45
|
-
include: { kind: "text", value: "<dir>", multiple: true, help: "an include folder
|
|
43
|
+
include: { kind: "text", value: "<dir>", multiple: true, help: "an include folder: a path relative to the source root, inside the project folder" },
|
|
46
44
|
define: { kind: "text", value: "NAME=VALUE", multiple: true, help: "an assembler symbol: an integer ($hex allowed) or true/false" },
|
|
47
45
|
"set-pc": { kind: "address", value: "<address>", help: "the start address when the source sets none, for example '$0801'" },
|
|
48
46
|
release: { kind: "text", value: "<label>", help: `build a release of the knowledge: defines ${RELEASE_DEFINE}<label>=1, so each switch has the value of that release. With --compare, the reference is the file of the release` },
|
|
@@ -77,19 +75,11 @@ await runScript({
|
|
|
77
75
|
}
|
|
78
76
|
}
|
|
79
77
|
const setPc = call.address("set-pc");
|
|
80
|
-
const tree =
|
|
81
|
-
if (!tree.files.some((file) => file.path === entry)) throw new Refusal("not-found", `${entry} is not a file in ${sourceRoot}. Give the main source file relative to the source root.`);
|
|
82
|
-
|
|
83
|
-
for (const folder of call.strings("include")) {
|
|
84
|
-
const inside = posix.normalize(folder.replaceAll("\\", "/")).replace(/\/+$/, "");
|
|
85
|
-
if (inside === "." || inside === ".." || inside.startsWith("../") || posix.isAbsolute(inside)) continue;
|
|
86
|
-
if (!tree.files.some((file) => file.path.startsWith(`${inside}/`))) {
|
|
87
|
-
throw new Refusal("not-found", `There is no include folder ${folder} with files in the source root ${sourceRoot}. Give --include a folder relative to the source root.`);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
const params: AcmeParams = { files: tree.files, entrySource: entry, includeDirs: call.strings("include"), defines: { ...releaseDefine, ...Object.fromEntries(call.strings("define").map(parseDefine)) }, ...(setPc === undefined ? {} : { setPc }) };
|
|
78
|
+
const { contents, ...tree } = readSourceTree(sourceRoot, call.strings("include"));
|
|
79
|
+
if (!tree.files.some((file) => file.path === (tree.sourceDir === "" ? entry : `${tree.sourceDir}/${entry}`))) throw new Refusal("not-found", `${entry} is not a file in ${sourceRoot}. Give the main source file relative to the source root.`);
|
|
80
|
+
const params: AcmeParams = { ...tree, entrySource: entry, defines: { ...releaseDefine, ...Object.fromEntries(call.strings("define").map(parseDefine)) }, ...(setPc === undefined ? {} : { setPc }) };
|
|
91
81
|
|
|
92
|
-
const { result, attachments } = await assemble(params,
|
|
82
|
+
const { result, attachments } = await assemble(params, contents, localToolContext());
|
|
93
83
|
if (!result.assembled) return reply({ result: "FAIL", assembled: false, diagnostics: result.diagnostics }, { hint: "The source has errors, and no program was written. Correct the source at the file and the line of each diagnostic. Then run build again." });
|
|
94
84
|
const plain = call.flag("plain");
|
|
95
85
|
const written = writeReported(out, plain ? attachments![0]!.subarray(2) : attachments![0]!, { what: "--out" });
|
package/skills/c64-disk/SKILL.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: c64-disk
|
|
3
|
-
description: Examines a C64 disk image (D64, D71, D81 or G64), a T64 tape file or a CRT cartridge file. It extracts files from it into the project. It shows the directory, the BAM, the directory entry of a file and the sector chain of a file. It writes each bank of a cartridge as a PRG. Use it when a program comes as a disk image, a tape file or a cartridge file. Use it to find the sectors that a loader reads directly. It does not run the program, it does not decode BASIC, and it does not change the disk image.
|
|
3
|
+
description: Examines a C64 disk image (D64, D71, D81 or G64), a T64 tape file or a CRT cartridge file. It extracts files from it into the project. It shows the directory, the BAM, the directory entry of a file and the sector chain of a file. It writes the bytes of sectors to a file. It writes each bank of a cartridge as a PRG. Use it when a program comes as a disk image, a tape file or a cartridge file. Use it to find the sectors that a loader reads directly. It does not run the program, it does not decode BASIC, and it does not change the disk image.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# C64 disk
|
|
@@ -28,6 +28,8 @@ To get the command list, run the script with no arguments.
|
|
|
28
28
|
| Get the type, the size and the first block of one file | `entry original/game.d64 GAME` |
|
|
29
29
|
| Get the track and the sector of each block of one file | `chain original/game.d64 GAME` |
|
|
30
30
|
| Find the used sectors that no file uses | `bam original/game.d64` |
|
|
31
|
+
| Write the bytes of the used sectors that no file uses | `sectors original/game.d64 --unreferenced --out .c64-re-tools/local/hidden.bin` |
|
|
32
|
+
| Write the bytes of some sectors | `sectors original/game.d64 18/0 20/5 --out .c64-re-tools/local/sectors.bin` |
|
|
31
33
|
| Get the files of a tape | `directory original/game.t64` |
|
|
32
34
|
| Extract one file of a tape | `read original/game.t64 GAME --out extracted/game.prg` |
|
|
33
35
|
| Get the banks of a cartridge | `directory original/game.crt` |
|
|
@@ -41,7 +43,7 @@ To get the command list, run the script with no arguments.
|
|
|
41
43
|
|---|---|
|
|
42
44
|
| `directory` | `.d64`, `.d71`, `.d81`, `.g64`, `.t64`, `.crt` |
|
|
43
45
|
| `read` | `.d64`, `.d71`, `.d81`, `.g64`, `.t64` |
|
|
44
|
-
| `bam`, `entry`, `chain` | `.d64`, `.d71`, `.d81`, `.g64` |
|
|
46
|
+
| `bam`, `entry`, `chain`, `sectors` | `.d64`, `.d71`, `.d81`, `.g64` |
|
|
45
47
|
| `crt` | `.crt` |
|
|
46
48
|
|
|
47
49
|
- `<name>` is a file name from the result of `directory`. Write the name in the same form as the directory shows it. The letter case of a name is not important.
|
|
@@ -76,7 +78,8 @@ Each flag applies only to the commands in the table. On another command, the scr
|
|
|
76
78
|
|
|
77
79
|
| Flag | Command | Effect |
|
|
78
80
|
|---|---|---|
|
|
79
|
-
| `--out <file>` | `read` | The file to write, relative to the project folder. Required. |
|
|
81
|
+
| `--out <file>` | `read`, `sectors` | The file to write, relative to the project folder. Required. |
|
|
82
|
+
| `--unreferenced` | `sectors` | Write also the used sectors that no file uses, after the given sectors. |
|
|
80
83
|
| `--out <dir>` | `crt` | The folder for the bank files and `crt.json`, relative to the project folder. Required. |
|
|
81
84
|
|
|
82
85
|
---
|
|
@@ -99,6 +102,8 @@ Do not record the directory list in the project knowledge.
|
|
|
99
102
|
|
|
100
103
|
`body.tracks` gives the `freeSectors` and the `usedSectors` of each track. `body.unreferenced` lists the used sectors that no file uses. The list does not include the header, the directory and the BAM blocks. These sectors can hold data that a loader reads directly.
|
|
101
104
|
|
|
105
|
+
When `body.unreferenced` is not empty, `nextAction` is the `sectors` command that writes their bytes.
|
|
106
|
+
|
|
102
107
|
### `entry <image> <name>`
|
|
103
108
|
|
|
104
109
|
`body` holds `found: true` and `entry`: the `name`, `type`, `blocks`, `closed`, `locked`, `startTrack` and `startSector` of the file. Use it when the disk structure is important, for example for a loader that reads sectors directly.
|
|
@@ -119,6 +124,16 @@ Writes the bytes of one file at `--out`. A PRG file keeps its 2-byte load addres
|
|
|
119
124
|
|
|
120
125
|
For a cartridge file, the script refuses `read`. Use `crt`.
|
|
121
126
|
|
|
127
|
+
### `sectors <image> [<track>/<sector>...]`
|
|
128
|
+
|
|
129
|
+
Writes the 256 bytes of each sector at `--out`, in the given sequence. Give each sector as `<track>/<sector>` in decimal, for example `18/1`. With `--unreferenced`, the file also gets the used sectors that no file uses, after the given sectors. Give at least one sector or `--unreferenced`.
|
|
130
|
+
|
|
131
|
+
`body.count` is the number of sectors. `body.sectors` gives the `track`, the `sector` and the `offset` of each sector in the file. `body` also holds the written file as `out`, `bytes` and `sha256`.
|
|
132
|
+
|
|
133
|
+
When the disk has no used sectors that no file uses and you give no sectors, the script writes no file. Then `body.count` is 0, and `hint` tells it.
|
|
134
|
+
|
|
135
|
+
- `invalid-input` with "The disk has no track": the disk does not have that sector. Run `bam` and give a sector that it shows.
|
|
136
|
+
|
|
122
137
|
### `crt <file.crt>`
|
|
123
138
|
|
|
124
139
|
Writes one PRG for each CHIP packet of the cartridge, for example `bank3-8000.prg`. It also writes `crt.json` with the header and the packets. The script reads hardware types 0 (normal 8K, 16K or Ultimax), 5 (Ocean), 19 (Magic Desk) and 32 (EasyFlash).
|
|
@@ -134,7 +149,7 @@ All banks use the same addresses. Thus `hint` tells you to analyze each bank PRG
|
|
|
134
149
|
1. Run `directory`. Find the file in `entries`.
|
|
135
150
|
2. Run `read` to extract the file. For a cartridge, run `crt`.
|
|
136
151
|
3. Run `entry` or `chain` only when the disk structure is important.
|
|
137
|
-
4. Run `bam` only to find the used sectors that no file uses.
|
|
152
|
+
4. Run `bam` only to find the used sectors that no file uses. Then run `sectors --unreferenced` to examine their bytes.
|
|
138
153
|
5. Give the extracted file to the next task. Decode a BASIC program, unpack a packed program, or disassemble machine code.
|
|
139
154
|
|
|
140
155
|
---
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import { formatC64Address } from "#src/c64.ts";
|
|
6
6
|
import { isRefusal, Refusal } from "#src/errors.ts";
|
|
7
|
-
import { DISK_IMAGE_TYPES, inspectDisk } from "#src/host-client/tools.ts";
|
|
7
|
+
import { DISK_BLOCK_BYTES, DISK_IMAGE_TYPES, inspectDisk, MAX_DISK_SECTORS } from "#src/host-client/tools.ts";
|
|
8
8
|
import { readProjectFile, writeReported } from "#src/host-client/transfer.ts";
|
|
9
9
|
import { OPTIONS, reply, runScript, type Call, type SubjectSpec } from "#src/script.ts";
|
|
10
10
|
import { parseCrt, parseT64, tapeFile } from "./lib/containers.ts";
|
|
@@ -75,6 +75,16 @@ function cartridge(image: string) {
|
|
|
75
75
|
/** A command that takes only a disk image. */
|
|
76
76
|
const diskOnly = (call: Call, action: string) => kindFor(action, call.subject(0), ["disk"]);
|
|
77
77
|
|
|
78
|
+
/** A sector as <track>/<sector> in decimal, for example 18/1. */
|
|
79
|
+
function sectorOf(text: string): { track: number; sector: number } {
|
|
80
|
+
const match = /^(\d{1,3})\/(\d{1,3})$/.exec(text);
|
|
81
|
+
const [track, sector] = [Number(match?.[1]), Number(match?.[2])];
|
|
82
|
+
if (match === null || track < 1 || track > 255 || sector > 255) {
|
|
83
|
+
throw new Refusal("invalid-input", `${text} is not a sector. Give <track>/<sector> in decimal, for example 18/1.`);
|
|
84
|
+
}
|
|
85
|
+
return { track, sector };
|
|
86
|
+
}
|
|
87
|
+
|
|
78
88
|
await runScript({
|
|
79
89
|
name: "disk",
|
|
80
90
|
summary: "Inspects a disk image and extracts files into the project. It also reads T64 tape files and CRT cartridge files. A CRT can have hardware type 0 (normal 8K, 16K or Ultimax), 5 (Ocean), 19 (Magic Desk) or 32 (EasyFlash).",
|
|
@@ -101,9 +111,16 @@ await runScript({
|
|
|
101
111
|
name: "bam",
|
|
102
112
|
summary: "The free and used sectors of each track, and the used sectors that no file holds.",
|
|
103
113
|
subjects: [IMAGE],
|
|
104
|
-
run: (call) => {
|
|
114
|
+
run: async (call) => {
|
|
105
115
|
diskOnly(call, "bam");
|
|
106
|
-
|
|
116
|
+
const image = call.subject(0);
|
|
117
|
+
const output = (await inspect(call, "bam")) as { unreferenced: unknown[] };
|
|
118
|
+
if (output.unreferenced.length === 0) return output;
|
|
119
|
+
const base = image.split("/").at(-1)!.replace(/\.[^.]*$/, "");
|
|
120
|
+
return reply(output, {
|
|
121
|
+
hint: "Write the unreferenced sectors to a file to examine their bytes.",
|
|
122
|
+
nextAction: call.next("sectors", image, "--unreferenced", "--out", `.c64-re-tools/local/${base}-unreferenced.bin`),
|
|
123
|
+
});
|
|
107
124
|
},
|
|
108
125
|
},
|
|
109
126
|
{
|
|
@@ -146,6 +163,29 @@ await runScript({
|
|
|
146
163
|
return { name: result.name, ...writeReported(out, result.data!, { what: "--out" }) };
|
|
147
164
|
},
|
|
148
165
|
},
|
|
166
|
+
{
|
|
167
|
+
name: "sectors",
|
|
168
|
+
summary: "Writes the 256 bytes of each given sector into one file, in the given order. It can also write the used sectors that no file holds.",
|
|
169
|
+
subjects: [IMAGE, { name: "<track>/<sector>", help: "a sector in decimal, for example 18/1. Give more sectors to write them in that order", optional: true, list: true }],
|
|
170
|
+
options: {
|
|
171
|
+
unreferenced: { kind: "flag", help: "write also the used sectors that no file holds, as bam lists them, after the given sectors" },
|
|
172
|
+
out: { ...OPTIONS.out, output: "file", value: "<file>", help: "the file to write, relative to the project folder", required: true },
|
|
173
|
+
},
|
|
174
|
+
run: async (call) => {
|
|
175
|
+
diskOnly(call, "sectors");
|
|
176
|
+
const image = call.subject(0);
|
|
177
|
+
const out = call.string("out")!;
|
|
178
|
+
const sectors = call.rest(1).map(sectorOf);
|
|
179
|
+
const unreferenced = call.flag("unreferenced");
|
|
180
|
+
if (sectors.length === 0 && !unreferenced) throw new Refusal("invalid-input", "sectors needs a sector or --unreferenced. Give <track>/<sector>, for example 18/1, or --unreferenced.");
|
|
181
|
+
if (sectors.length > MAX_DISK_SECTORS) throw new Refusal("limit-exceeded", `${sectors.length} sectors are too many. Give at most ${MAX_DISK_SECTORS} sectors.`);
|
|
182
|
+
const result = await inspectDisk({ image, action: "sectors", sectors, ...(unreferenced ? { unreferenced } : {}) });
|
|
183
|
+
if (result.action !== "sectors") throw new Refusal("operation-failed", "The disk inspection gave no sectors.");
|
|
184
|
+
const index = result.sectors.map((at, position) => ({ track: at.track, sector: at.sector, offset: position * DISK_BLOCK_BYTES }));
|
|
185
|
+
if (index.length === 0) return reply({ count: 0, sectors: [] }, { hint: "The disk has no used sectors that no file holds. The script wrote no file." });
|
|
186
|
+
return { count: index.length, sectors: index, ...writeReported(out, result.data!, { what: "--out" }) };
|
|
187
|
+
},
|
|
188
|
+
},
|
|
149
189
|
{
|
|
150
190
|
name: "crt",
|
|
151
191
|
summary: "Writes each CHIP packet of a cartridge as a PRG, and crt.json with the header and the packets.",
|
|
@@ -261,20 +261,24 @@ Finds each routine of the library in the program of the project knowledge.
|
|
|
261
261
|
- `library` and `routines`: the library folder and the number of routines in it.
|
|
262
262
|
- `matches`: each item has `routine`, `start`, `end` and `shift`. `shift` is the address in the program minus the address in the library.
|
|
263
263
|
- `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.
|
|
264
|
-
- `batch`: only with `--out`. `out`, `bytes` and `sha256` give the batch file. `writes` counts its writes. `known` counts the writes that the project knowledge has already. `leftOut` lists the writes that the script left out, and why.
|
|
264
|
+
- `batch`: only with `--out`. `out`, `bytes` and `sha256` give the batch file. `writes` counts its writes. `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 the batch 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. Examine each comment, and correct its text in the batch file if it is necessary.
|
|
265
265
|
|
|
266
266
|
The batch has 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:
|
|
267
267
|
|
|
268
268
|
- The program has a user or LLM row at that place.
|
|
269
269
|
- The program uses the name at another address.
|
|
270
270
|
- A removal holds at that place.
|
|
271
|
-
- The routine occurs
|
|
271
|
+
- The routine occurs more than one time, and the script did not choose this copy.
|
|
272
272
|
- The script left out the name that an operand expression uses, or the expression does not give the operand in the program.
|
|
273
273
|
|
|
274
|
+
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 `batch.leftOut` gives each copy with the reason `ambiguous`.
|
|
275
|
+
|
|
276
|
+
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 `batch.check` gives the comment.
|
|
277
|
+
|
|
274
278
|
`hint` and `nextAction`:
|
|
275
279
|
|
|
276
280
|
- Without `--out`, with matches: `nextAction` runs `match` with `--out`. Examine `differing` of each match first.
|
|
277
|
-
- With `--out`, with writes: `hint` tells you to apply the changes in the batch file to the project knowledge. Read `batch.leftOut` first. Apply the changes as one revision of the LLM.
|
|
281
|
+
- With `--out`, with writes: `hint` tells you to apply the changes in the batch file to the project knowledge. Read `batch.leftOut` first. When `batch.check` has comments, `hint` tells you to examine them first. Apply the changes as one revision of the LLM.
|
|
278
282
|
- No match: `hint` tells that a packed program can hold a routine in a packed form. Unpack the program, put it into the project knowledge, and run `match` again.
|
|
279
283
|
|
|
280
284
|
Traps:
|
|
@@ -325,7 +329,7 @@ Traps:
|
|
|
325
329
|
1. Put the program into the project knowledge, and name the routine there.
|
|
326
330
|
2. Run `routine`. Read `leftOut`.
|
|
327
331
|
3. In another project, put the program into the project knowledge. Run `match`.
|
|
328
|
-
4. Run `match` with `--out`. Read `batch.leftOut`.
|
|
332
|
+
4. Run `match` with `--out`. Read `batch.leftOut` and `batch.check`.
|
|
329
333
|
5. Apply the changes in the batch file to the project knowledge.
|
|
330
334
|
|
|
331
335
|
---
|
|
@@ -405,7 +405,8 @@ function relocated(relocation: Relocation, start: number, part: 0 | 1): number |
|
|
|
405
405
|
/**
|
|
406
406
|
* The places where the routine occurs in the image: its fixed bytes equal,
|
|
407
407
|
* each relocation pointing into the routine at one shift, and the variable
|
|
408
|
-
* bytes free. Matches
|
|
408
|
+
* bytes free. Matches can overlap: a short routine with many variable bytes
|
|
409
|
+
* can fit at several places close together, and each place is a candidate.
|
|
409
410
|
*/
|
|
410
411
|
export function findRoutine(routine: Routine, image: Searched, origin = routine.from.start): Match[] {
|
|
411
412
|
const length = routine.bytes.length;
|
|
@@ -442,7 +443,6 @@ export function findRoutine(routine: Routine, image: Searched, origin = routine.
|
|
|
442
443
|
if (library !== program) differing.push({ address: start + offset, library, program, size: size as 1 | 2 });
|
|
443
444
|
}
|
|
444
445
|
matches.push({ routine: routine.name, start, shift: start - origin, differing });
|
|
445
|
-
start += length - 1;
|
|
446
446
|
}
|
|
447
447
|
}
|
|
448
448
|
return matches;
|
|
@@ -472,26 +472,95 @@ export interface Skipped {
|
|
|
472
472
|
reason: string;
|
|
473
473
|
}
|
|
474
474
|
|
|
475
|
+
/** A comment of the batch that names an address outside its routine: that address can be different in the program. */
|
|
476
|
+
export interface Check {
|
|
477
|
+
routine: string;
|
|
478
|
+
address: string;
|
|
479
|
+
comment: string;
|
|
480
|
+
outside: string[];
|
|
481
|
+
}
|
|
482
|
+
|
|
475
483
|
export interface Suggestions {
|
|
476
484
|
batch: BatchWrite[];
|
|
477
485
|
/** Writes that the program already has. */
|
|
478
486
|
known: number;
|
|
479
487
|
leftOut: Skipped[];
|
|
488
|
+
check: Check[];
|
|
480
489
|
}
|
|
481
490
|
|
|
482
491
|
const semantic = (row: { origin: string }) => isSemantic(row.origin);
|
|
483
492
|
|
|
493
|
+
/**
|
|
494
|
+
* The copy of each routine that gets its names, and the copies left out. A
|
|
495
|
+
* routine with one match is named there. For a routine with several matches,
|
|
496
|
+
* the routines of the same library program that matched once give the shift:
|
|
497
|
+
* the nearest one below it and the nearest one above it, by their start in that
|
|
498
|
+
* program. A copy fits when its shift is the shift of one of these two
|
|
499
|
+
* neighbours: code that moved as a block keeps the shift of its neighbours, and
|
|
500
|
+
* at the border of a block only one side has it. The routine is named only when
|
|
501
|
+
* exactly one copy fits. With no neighbour, with no fitting copy, or with a
|
|
502
|
+
* fitting copy for each of two different neighbour shifts, no copy is named.
|
|
503
|
+
*/
|
|
504
|
+
function chooseCopies(found: ReadonlyArray<{ routine: Routine; matches: Match[] }>): Array<{ chosen?: Match; leftOut: Skipped[] }> {
|
|
505
|
+
const show = formatC64Address;
|
|
506
|
+
const unique = found.filter(({ matches }) => matches.length === 1);
|
|
507
|
+
return found.map(({ routine, matches }) => {
|
|
508
|
+
if (matches.length <= 1) return { ...(matches[0] === undefined ? {} : { chosen: matches[0] }), leftOut: [] };
|
|
509
|
+
const beside = unique.filter((item) => item.routine !== routine && item.routine.from.program === routine.from.program);
|
|
510
|
+
const below = beside.filter((item) => item.routine.from.start < routine.from.start).sort((a, b) => b.routine.from.start - a.routine.from.start)[0];
|
|
511
|
+
const above = beside.filter((item) => item.routine.from.start > routine.from.start).sort((a, b) => a.routine.from.start - b.routine.from.start)[0];
|
|
512
|
+
const neighbours = [below, above].filter((item) => item !== undefined);
|
|
513
|
+
const copies = [...matches].sort((a, b) => a.start - b.start);
|
|
514
|
+
const fitting = copies.filter((match) => neighbours.some((item) => item.matches[0]!.shift === match.shift));
|
|
515
|
+
if (fitting.length !== 1) {
|
|
516
|
+
return { leftOut: copies.map((match) => ({ routine: routine.name, address: show(match.start), reason: `ambiguous: ${copies.length} copies of the routine, and the shift of no library neighbour chooses one copy` })) };
|
|
517
|
+
}
|
|
518
|
+
const chosen = fitting[0]!;
|
|
519
|
+
const by = neighbours.filter((item) => item.matches[0]!.shift === chosen.shift).map((item) => item.routine.name);
|
|
520
|
+
const reason = `another copy of the routine; the copy at ${show(chosen.start)} has the shift ${chosen.shift} of its library neighbour${by.length === 1 ? "" : "s"} ${by.join(" and ")}`;
|
|
521
|
+
return { chosen, leftOut: copies.filter((match) => match !== chosen).map((match) => ({ routine: routine.name, address: show(match.start), reason })) };
|
|
522
|
+
});
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
/** A $xxxx address in a comment: four hex digits, not more. */
|
|
526
|
+
const COMMENT_ADDRESS = /\$([0-9a-fA-F]{4})(?![0-9a-fA-F])/g;
|
|
527
|
+
|
|
528
|
+
/**
|
|
529
|
+
* The comment text in the program: each $xxxx address inside the library range
|
|
530
|
+
* of the routine moves by the shift, with upper-case digits when the text has
|
|
531
|
+
* them. The addresses outside that range stay, and are returned as `outside`.
|
|
532
|
+
*/
|
|
533
|
+
function movedComment(text: string, routine: Routine, shift: number): { text: string; outside: string[] } {
|
|
534
|
+
const first = routine.from.start;
|
|
535
|
+
const last = first + routine.bytes.length - 1;
|
|
536
|
+
const outside = new Set<string>();
|
|
537
|
+
const moved = text.replace(COMMENT_ADDRESS, (whole, digits: string) => {
|
|
538
|
+
const value = Number.parseInt(digits, 16);
|
|
539
|
+
if (value < first || value > last) {
|
|
540
|
+
outside.add(formatC64Address(value));
|
|
541
|
+
return whole;
|
|
542
|
+
}
|
|
543
|
+
const shown = formatC64Address(value + shift);
|
|
544
|
+
return /[A-F]/.test(digits) ? shown.toUpperCase() : shown;
|
|
545
|
+
});
|
|
546
|
+
return { text: moved, outside: [...outside] };
|
|
547
|
+
}
|
|
548
|
+
|
|
484
549
|
/**
|
|
485
550
|
* The names, regions, comments, references and operand expressions of each
|
|
486
551
|
* matched routine at its program addresses, as an apply batch. A write that
|
|
487
552
|
* the program already has is counted as known. A write that would replace a
|
|
488
553
|
* user or LLM row, take a name that the program uses elsewhere, undo a
|
|
489
554
|
* removal, or give an operand that is not in the image, is left out with the
|
|
490
|
-
* reason.
|
|
555
|
+
* reason. A routine with several matches gets its names at the copy that
|
|
556
|
+
* chooseCopies gives, or nowhere. Each $xxxx address of a comment inside the
|
|
557
|
+
* routine moves with it; a written comment with an address outside the routine
|
|
558
|
+
* is in `check`.
|
|
491
559
|
*/
|
|
492
560
|
export function suggest(found: ReadonlyArray<{ routine: Routine; matches: Match[] }>, program: ProgramKnowledge, image: Searched, platform: ReadonlyMap<string, number>): Suggestions {
|
|
493
561
|
const batch: BatchWrite[] = [];
|
|
494
562
|
const leftOut: Skipped[] = [];
|
|
563
|
+
const check: Check[] = [];
|
|
495
564
|
let known = 0;
|
|
496
565
|
const show = formatC64Address;
|
|
497
566
|
/** The names that are at their place after the batch: written here or known. */
|
|
@@ -499,11 +568,12 @@ export function suggest(found: ReadonlyArray<{ routine: Routine; matches: Match[
|
|
|
499
568
|
const symbolsHere = new Map<number, string>();
|
|
500
569
|
const regionsHere: Array<{ start: number; end: number }> = [];
|
|
501
570
|
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
571
|
+
const copies = chooseCopies(found);
|
|
572
|
+
for (const [index, { routine }] of found.entries()) {
|
|
573
|
+
const { chosen, leftOut: others } = copies[index]!;
|
|
574
|
+
leftOut.push(...others);
|
|
575
|
+
if (chosen === undefined) continue;
|
|
576
|
+
const at = (offset: number) => chosen.start + offset;
|
|
507
577
|
const skip = (address: number, op: string, reason: string) => leftOut.push({ routine: routine.name, address: show(address), op, reason });
|
|
508
578
|
|
|
509
579
|
for (const symbol of routine.symbols) {
|
|
@@ -544,9 +614,13 @@ export function suggest(found: ReadonlyArray<{ routine: Routine; matches: Match[
|
|
|
544
614
|
for (const comment of routine.comments) {
|
|
545
615
|
const address = at(comment.at);
|
|
546
616
|
const existing = program.commentsAt(address).find((item) => item.placement === comment.placement);
|
|
547
|
-
|
|
617
|
+
const { text, outside } = movedComment(comment.text, routine, chosen.shift);
|
|
618
|
+
if (existing?.text === text) known++;
|
|
548
619
|
else if (existing !== undefined) skip(address, "comment", `the program has a ${comment.placement} comment there (${existing.origin})`);
|
|
549
|
-
else
|
|
620
|
+
else {
|
|
621
|
+
batch.push({ op: "comment", address: show(address), placement: comment.placement, text });
|
|
622
|
+
if (outside.length > 0) check.push({ routine: routine.name, address: show(address), comment: text, outside });
|
|
623
|
+
}
|
|
550
624
|
}
|
|
551
625
|
|
|
552
626
|
for (const reference of routine.references) {
|
|
@@ -590,7 +664,7 @@ export function suggest(found: ReadonlyArray<{ routine: Routine; matches: Match[
|
|
|
590
664
|
});
|
|
591
665
|
}
|
|
592
666
|
}
|
|
593
|
-
return { batch, known, leftOut };
|
|
667
|
+
return { batch, known, leftOut, check };
|
|
594
668
|
}
|
|
595
669
|
|
|
596
670
|
/** Why the expression is not the operand of the instruction at `address` in the image, or undefined when it is. */
|
|
@@ -522,13 +522,14 @@ function matchCommand(call: Call): unknown {
|
|
|
522
522
|
} finally {
|
|
523
523
|
db?.close();
|
|
524
524
|
}
|
|
525
|
-
const { batch, known, leftOut } = suggestions;
|
|
525
|
+
const { batch, known, leftOut, check } = suggestions;
|
|
526
526
|
const written = writeReported(out, batch.length === 0 ? "[]\n" : `[\n${batch.map((write) => ` ${JSON.stringify(write)}`).join(",\n")}\n]\n`, { what: "--out" });
|
|
527
|
-
const body = { ...result, batch: { ...written, writes: batch.length, known, leftOut: list(leftOut) } };
|
|
527
|
+
const body = { ...result, batch: { ...written, writes: batch.length, known, leftOut: list(leftOut), check: list(check) } };
|
|
528
528
|
// The batch is applied by the knowledge, not by this script: the hint gives the task, not a command.
|
|
529
529
|
if (matches.length === 0) return reply(body, { hint: noMatch });
|
|
530
530
|
if (batch.length === 0) return reply(body, { hint: withNote(body, "The batch has no writes. The project knowledge has the names of the found routines already, or batch.leftOut tells why the script left out a write.") });
|
|
531
|
-
|
|
531
|
+
const review = check.length === 0 ? "" : " First examine batch.check: each comment there gives an address outside its routine, which can be different in this program. Correct the comment text in the batch file when it is different.";
|
|
532
|
+
return reply(body, { hint: withNote(body, `Apply the changes in ${out} to the project knowledge.${review}`) });
|
|
532
533
|
}
|
|
533
534
|
|
|
534
535
|
const LIBRARY = { kind: "text", value: "<folder>", required: true, help: "the library: a plain folder of routine files beside the projects, relative to the project folder, for example ../library" } as const;
|
|
@@ -69,7 +69,7 @@ Each flag applies only to the commands in the table. On another command, the scr
|
|
|
69
69
|
|
|
70
70
|
| Flag | Command | Effect |
|
|
71
71
|
|---|---|---|
|
|
72
|
-
| `--out <dir>` | `generate` | The folder for the source files. It is necessary. The script writes over the files of an earlier run. 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. |
|
|
72
|
+
| `--out <dir>` | `generate` | The folder for the source files. It is necessary. The script writes over the files of an earlier run. 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. `staleLoader` tells when they are of another knowledge revision. |
|
|
73
73
|
| `--entry <address>` | `generate` | An address where code starts. Give the flag again for more addresses. There is no default. |
|
|
74
74
|
| `--space <space>` | `generate` | The knowledge space: `c64`, `drive8`, or `bank0` to `bank255`. The default is `c64`. The coverage, `--loader` and the platform names apply only to `c64`. |
|
|
75
75
|
| `--loader` | `generate` | Also write `loader.asm` and `loader.prg`. It needs a capture in the knowledge. The default is no loader. |
|
|
@@ -114,6 +114,7 @@ To make the source better, change the project knowledge. Then generate again.
|
|
|
114
114
|
- `patchesNotWritten`: each patch that the source does not have, with its range, `switch` and `reason`.
|
|
115
115
|
- `switches`, `default`, `releases`: the checks of the switches. See "Switches and releases".
|
|
116
116
|
- `loader`: the check of the loader. See "The loader".
|
|
117
|
+
- `staleLoader`: a run without `--loader` kept `loader.asm` and `loader.prg` of another knowledge revision. `files` gives the files. `revision` gives the revision of `loader.asm`. Without `revision`, `loader.asm` does not give one. `noEntryState: true` tells that the knowledge has no entry state for a new loader.
|
|
117
118
|
|
|
118
119
|
`result` is `FAIL` for each of these:
|
|
119
120
|
|
|
@@ -141,12 +142,13 @@ Do these actions for the findings:
|
|
|
141
142
|
| `invalid-input` that names a symbol or a module | Change that symbol or module in the project knowledge. |
|
|
142
143
|
| `conflict` | The knowledge has conflicts from a git merge. Merge the open changes of the project knowledge. Then run the command again. |
|
|
143
144
|
| A list with `rest` | Give a larger `--max-listed`. For `notExecuted`, read the file in `rest`. |
|
|
145
|
+
| `staleLoader` | The loader can copy bytes that are not the bytes of the source. Run `nextAction`, which generates with `--loader`. With `noEntryState: true`, remove the files when the build does not use them. |
|
|
144
146
|
|
|
145
147
|
#### The source files
|
|
146
148
|
|
|
147
149
|
- `main.asm` sets the address of each segment. It includes the files in address order.
|
|
148
150
|
- Each module in the knowledge is one file. A module starts at its address. It stops at the next module or at the end of its segment. Without modules, each segment is one file, `segment_xxxx.asm`.
|
|
149
|
-
- `constants.asm` holds the names of addresses outside the program, for example `EXTCOL = $d020`. The names are in groups by memory area, in address order. Drive code and banks have one group only.
|
|
151
|
+
- `constants.asm` holds the names of addresses outside the program, for example `EXTCOL = $d020`. It also holds the register names in the program, for example `RASTER = $d012`. The names are in groups by memory area, in address order. Drive code and banks have one group only.
|
|
150
152
|
- The side comment of a constant is the knowledge comment of the address. Without a comment, it is the platform meaning. When the knowledge name is not the platform name, the platform name comes first. For an I/O mirror without a meaning, the comment gives the register that the mirror repeats.
|
|
151
153
|
- After the side comment, `Used:` counts how the source uses the name. The kinds are `read`, `written`, `modified`, `called`, `jumped to`, `jumped through`, `branched to`, `pointer`, `address`, `table` and `macro argument`. `address` is an immediate operand expression. `table` is an entry in a table of addresses.
|
|
152
154
|
- `config.asm` holds the value of each switch, for example `PROTECTION = 0`. The switches are in groups by kind. The side comment gives the releases that have the switch on, the ranges of its patches and the comment of the switch.
|
|
@@ -159,6 +161,8 @@ Do these actions for the findings:
|
|
|
159
161
|
- A label or a constant gets the name of the address in the knowledge.
|
|
160
162
|
- Without a knowledge name, it gets the platform name, for example `EXTCOL` or `CHROUT`. A platform name wins over an analyzer name (`dxa`, `ghidra` or `heuristic`), for example `EXTCOL` over `ld020`. A `user` or `llm` name wins over a platform name.
|
|
161
163
|
- An address in the program without a name gets `l_xxxx`.
|
|
164
|
+
- A read or a write in the I/O area `$d000-$dfff` uses the register, also when the program has RAM there. For example, `lda $dd0e` is `lda CI2CRA` and `sta $d012` is `sta RASTER`. `constants.asm` has these names. An address without a platform name stays a number, for example `sta $d800,x`. The data label of the RAM stays at its data. A `user` or `llm` name of the address wins over the register.
|
|
165
|
+
- A platform name in an operand expression of the knowledge stays in the source. When the program has the address, `constants.asm` has the name, and the RAM there keeps its label.
|
|
162
166
|
- The source uses the names of a ROM only when the program uses that ROM. With coverage, the program uses a ROM 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.
|
|
163
167
|
- When the program uses no ROM, the zero page and pages 2 and 3 get no system names. An operand expression or a macro use with such a name gets that reason.
|
|
164
168
|
|
|
@@ -242,6 +246,7 @@ The entry state is the state of the base release. Thus the script builds and che
|
|
|
242
246
|
- `verified: true`: the check ran `loader.prg` to its jump to the entry. There, the memory, $00/$01, the registers and the VIC-II are equal to the entry state. The raster line and the CIA values are also equal. An interrupt can run right at the entry, as in the original program.
|
|
243
247
|
- `limits`: each CIA value that the loader cannot set as it was at the entry. An old capture has no CIA values. Then capture the program again at its entry point.
|
|
244
248
|
- `packed`: `packedBytes` and `unpackedBytes` of the packed form.
|
|
249
|
+
- When the check of `loader.prg` cannot run, the script removes `loader.prg`. `loader.asm` stays. `reason` tells why the check did not run.
|
|
245
250
|
|
|
246
251
|
Do these actions when `verified` is `false`:
|
|
247
252
|
|
|
@@ -250,6 +255,7 @@ Do these actions when `verified` is `false`:
|
|
|
250
255
|
| `reason` about the copy order, the free pages or the count of copies | The reason gives the ranges. Capture the program again with fewer segments, or write the loader by hand. |
|
|
251
256
|
| `reason` about the packed form | If a tool is missing, stop the task and give the message to the user. If the free ranges are too small, write the loader by hand. If the check of the unpack fails, give the reason to the user. |
|
|
252
257
|
| `reason` that the source does not assemble | Correct the source first. The loader includes the source. |
|
|
258
|
+
| `reason` that the check of `loader.prg` did not run | Stop the task and give the reason to the user. When the user tells you that the emulator is available, run the same command again. |
|
|
253
259
|
| `differences` | The loader ran. The list gives the bytes and the registers that are not equal. |
|
|
254
260
|
| `stop` | The loader did not get to its copier or its jump. `stop` gives the address and `port`, the value of $01. `history` gives the last 16 instructions. `cause` gives the first byte of the copier or of a copy that is not correct. |
|
|
255
261
|
|
|
@@ -377,16 +377,16 @@ export function rewriteTest(text: string, name: string, symbols: ReadonlyMap<str
|
|
|
377
377
|
if (inside(address, free)) return { reason: `it names ${location}, which is in a free range` };
|
|
378
378
|
} else if (!symbols.has(location)) return { reason: `it names ${location}, which the exported program does not have` };
|
|
379
379
|
}
|
|
380
|
-
const side = (
|
|
380
|
+
const side = (program: string) => ({ program: `${program}.prg`, symbols: `${program}.json` });
|
|
381
381
|
if (scenario) {
|
|
382
382
|
// Both sides are the exported program now: a step of the original alone (for example a key for its intro) goes, and a step of the rebuild alone runs on both sides.
|
|
383
|
-
const { original, rebuild, steps, ...rest } = test;
|
|
383
|
+
const { original: _original, rebuild: _rebuild, steps, ...rest } = test;
|
|
384
384
|
const both = (steps as unknown[]).flatMap((step) => {
|
|
385
385
|
if (step === null || typeof step !== "object" || !("side" in step)) return [step];
|
|
386
386
|
const { side: only, ...action } = step as Record<string, unknown>;
|
|
387
387
|
return only === "original" ? [] : [action];
|
|
388
388
|
});
|
|
389
|
-
return { kind: "scenario", text: `${JSON.stringify({ ...rest, original: side(
|
|
389
|
+
return { kind: "scenario", text: `${JSON.stringify({ ...rest, original: side(`baseline/${name}`), rebuild: side(`build/${name}`), steps: both }, null, 2)}\n` };
|
|
390
390
|
}
|
|
391
391
|
const start = test.start as Record<string, unknown>;
|
|
392
392
|
const symbolsFile = test.symbols === undefined || test.symbols === "none" ? {} : { symbols: `build/${name}.json` };
|